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.


Friday, November 7, 2014

All up in the clouds

I haven't posted in a long while because I've been busy moving into a new place. Things have settled a bit and I'm starting to write again. This time I'm talking about the two cloud services I've been using: Google App Engine(GAE) and DigitalOcean(DO).

GAE is a platform. Think of folder where you put files and have a specific API to use to interact with your data store. The data store here is Google's. Of course, you could use other ones external from Google like mongolab if you into the whole NoSQL thing. The upside to this is you don't have to worry about maintaining servers, binaries and such. It makes you focus on your app. The downside though is that the "folder" is a sandbox. You are limited to what the API has.

DO is a VM. Think server. You can start off with a bare bones Linux server - there are Debian and Redhat variants - or if you could start off with a complete configured LAMP server. Either way, you will manage this via an SSH connection. The downside, will you have to manage that VM and if you happen to be a sucky (or worst lazy) administrator you might end up screwing up a lot. The upside is you have full control.


Sunday, September 14, 2014

SparkJava and Webjars

I've been playing around with Per Wendel's Spark framework. It's a micro framework inspired by Sinatra and it's in the same vein of node.js and ruby-on-rails. Just the thing is, Spark is Java and by being Java, the whole Java ecosystem is available.

I started learning Spark via the readme section of the site. Once you get through the basics, you start working in your favorite Java stuff. For me, the first thing I wanted to work in is Webjars.

Webjars is this thing we it pack jars with client-side libraries. This allows us to manage client-side libraries using various Java build tools like maven, ivy or gradle.

Adding webjars into an maven project is painless. It's a dependency. Here's a webjar for bootstrap3:

<dependency>  
    <groupId>org.webjars</groupId>  
    <artifactId>bootstrap</artifactId>  
    <version>3.2.0</version>  
</dependency>  

With the webjar added. We now need to tell Spark about it and serve them files. This took me a couple of hours to make it work. I had to figure out that webjars unpack to /META-INF/resources folder and tell Spark about it. It also helped that I looked at Spark's source code and realized that is a special Java servelet.

// Serve our client-side files from here
staticFileLocation("/META-INF/resources"); 

And reference it in our template like this:
<link rel='stylesheet' href='webjars/bootstrap/3.1.0/css/bootstrap.min.css'>

There. Spark app with webjars.