Friday, December 5, 2014

Putting Groovy on Mint (and other Linux distros) the easy way

Installing Groovy on any Linux distro is a pain in the ass. Generally, the procedure is:

  1. Install the requisites. This could be an involved process because you could be potentially install a lot of stuff but at minimum just need Java.
  2. Download the binaries for groovy. If your Linux distro has a repo like Debian, I don't recommend using it because it not the latest.
  3. Do a bit of file handling and doing a bunch of sym links to the binaries.
  4. Configure your bash shell for groovy. Just like step 3, not fun and just plain tedious.
Fortunately for me, I've found a much easier way to do these steps with GVM. GVM is a tool for managing parallel Versions of multiple Software Development Kits on most Unix based systems. Inspired by Ruby's RVM, it's a convenient command line interface for installing, switching, removing and listing Groovy libraries. GVM call these libraries as candidates.

Just do this to install GVM:

curl -s get.gvmtool.net | bash

And then do this to install Groovy.

gvm install groovy

That should install the latest version of groovy and we're off and running with groovy development.

Thursday, November 27, 2014

Jasper Reports, 1kb PDFs and "I swear they did this on purpose"

I ran into this seemingly weird situation with Jasper Reports 5.0.1 where I was getting 1kb size PDFs which was weird. So after doing *lots* (lots) of debugging I couldn't find anything wrong. The lines where pretty straight forward:

  InputStream is1 = evalSummaryReportPage1.getResource().openStream(); //jrxml source
  Map reportParams1 = new HashMap(); // standard hashmap
  reportParams1.put(......)
  ..
  ..
  JasperDesign page1Design = JRXmlLoader.load(is1);
  JasperReport page1Compiled = JasperCompileManager.compileReport(page1Design);
  JasperPrint page1 = JasperFillManager.fillReport(page1Compiled, reportParams1); 

  JRPdfExporter exporter = new JRPdfExporter();
  exporter.setParameter(JRExporterParameter.JASPER_PRINT, page1);
  exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename); 
  exporter.exportReport();

Until I found about JREmptyDataSource class. Apparently the fillReport() method of the JasperFillManager doesn't do shit when it doesn't has a third or the datasource parameter. It was bullshit because the same fillReport methods is overloaded and can be called with only two parameters. You can then compile with no problems or warnings. A warning would have been nice but no. I swear the Jasper devs did this on purpose just to fuck with me.

So to fix this shit:
  ..
  JasperDesign page1Design = JRXmlLoader.load(is1);
  JasperReport page1Compiled = JasperCompileManager.compileReport(page1Design);
  JasperPrint page1 = JasperFillManager.fillReport(page1Compiled, reportParams1, new JREmptyDataSource()); 
  ..
There, it now correctly generates the report.

zzzzzzzzz

Thursday, November 20, 2014

Why u no format SQL SQL Server Management Studio

Microsoft probably just loves developers but not DBAs because I find it amazing that the SQL Server Management Studio (SSMS) doesn't have a format SQL thing. It has the other stuff like Upper or lower case text, indent, undent, comment and uncomment BUT no freakin' format SQL. That is bullshit.

Of course, you could argue that I should buy some of those 1000 dollar plugins like Redgate SQL Prompt but that seems excessive. I just need to format SQL. That's it.

So after googling a bit on this I was able to find PoorSQL which a not only a website that formats SQL but is also a plugin in for SSMS and Visual Studio. Amazingly, it's also a open-source and free.