stuart's posterous

coder, photographer, mac guy, recent capetonian, surfer, muay thai student, thinker

Being my own University

I've had an itch since I started my current job, that being a feeling of inadequacy. Not like the kind of inadequacy one might get from an invoice for Cialis. More like the way Chad Fowler puts it, "being the worst guy in the band".

I'm very lucky to be constantly around several of some of the smartest and most talented sysadmins and developers I know.

That said, it makes me feel very humbled and the disappointed with myself. Not being able to eclipse my peers, albeit a 10 year age gap.

I have piles of blog posts in my feeds marked for further reading or just reading. I can never get around to it all. To add to the never ending list of cool stuff out there I want to be great at my job.

So my plan for the next few weeks is to address the problem of getting around to researching and practicing. It's not like I've never attempted to learn or practice after hours, heck, I do it regularly. But the dilemma is that its often not constructive, or 'whole' either despite any practice at all being a good thing.

Another issue that frustrates me no end (and possibly always will) is that week after week goes by and I'll go, "Damn! I should have really put a few more hours down on jQuery.", this is even worse if a situation arises where I would have better off for solving a problem if said hours had been constructive.

So in order to solve this problem, or at least make me feel better I will attempt to make a basic curriculum of material I would like to get through and make estimates on how long each section will take. Making room for reflection and playing around. But always having an expected output.

Having a well defined goal really accelerates productivity. To add to this, I'm going to make notes and snippets. Might even make a few posts about some subjects. It's common knowledge that your understanding of something is deepened by either writing about it or explaining it to someone else.

So here goes.

MSSQL2005 on Rails on Snow Leopard (the easiest way I know how)

I have a few battle scars from working with MSSQL via *nix/OSX, it always seems to take 17.8x longer than you plan for it to take just to install everything and getting it working. And despite installing and configuring this set up about 5 times, I end up hitting some wall of some sort. So in an effort to lower my blood pressure I’m going to give a quick run down on what has worked for me.

Many many thanks go out to all the hundreds of people who have lost sleep over this process before me (PHP, Phython & Ruby coders alike). From their bitchin' and stupid questions, I wouldn’t have even got it configured. So in memory of their tortured souls:

First install Homebrew

Homebrew’s standard install does not install with pointers to unixODBC, FreeTDS automatically uses the first one it finds, and in this case (OSX) will be iODBC. Normally this wouldn’t be an issue but the version of iODBC that comes with OSX needs to be updated in order to play nicely with FreeTDS.

I will be investigating using an update version of iODBC, but have been using UnixODBC for the sake of being like my production environment.

So first lets modify Homebrew’s FreeTDS brew to add a flag if unixODBC has been installed.

Go into the terminal and enter:

brew edit freetds

Copy and paste the code belong over the current contents def install method.

args = ["--prefix=#{prefix}",
        "--with-tdsver=7.0",
        "--enable-msdblib",
        "--mandir=#{man}"]

args << "--with-unixodbc=/usr/local" if Formula.factory('unixodbc').installed?

system "./configure", *args
system 'make'
system 'make install'

Once you’ve saved the changes we can install all the components

brew install unixodbc freetds ruby-odbc

Remember, unixODBC must be installed before FreeTDS as the ./configure will not be done with the unixODBC path and will compile with iODBC libs instead.

To test that this works, you can enter tsql -C into the terminal and you can see how FreeTDS was compiled. At the bottom you should see unixODBC: yes.

Another test that should be done is that FreeTDS can actually talk to your server. Again using the tsql tool attempt to connect.

tsql -S [ip_address] -U [user_name] -P [password] -D [database]

Without getting all schmancy, I usually test with something simple like SELECT 1 and then entering GO on the next line.

Ok the easy part is done. Now lets configure the DSN.

At the time of writing I couldn’t get a DSN-less connection working which from a Rails development perspective and for the sake of application portability I prefer that approach. This however works fine on my Debian dev & production environments I will be investigating further in a quest to get this to work but for now the methods below worked without a hitch.

Open up /usr/local/etc/freetds.conf in your favouritist text editor (mine being TextMate)

[SQLSERVERNAME]
 host = IPADDRESS
 port = 1433
 tds version = 7.0

Obviously changing the “SQLSERVERNAME” to something you like, lower case usually (not sure it matters).

Next open up /usr/local/etc/odbc.ini

[DSNNAME]
Driver = /usr/local/lib/libtdsodbc.so
Server = IPADDRESS
Database = DATABASENAME
client charset = UTF-8  #needed only on osx

DSNNAME is the name that you will use in your database.yml so make it something nice.

Open up your database.yml file and use this an example for your environments:

development:
  adapter: sqlserver
  mode: odbc
  dsn: DSNNAME
  username: USERNAME
  password: PASSWORD

Now last but not least. You gonna need a couple of gems to be installed for Rails to talk to ODBC and also wrap activerecords interpretations into MSSQL friendly commands.

I use bundler, if you’re not using it, you’re doing it wrong!

Add these gems to your Gemfile:

gem 'dbd-odbc', :require => false
gem 'activerecord-sqlserver-adapter', :require => false

It seems DBI is not longer required with newer versions of activerecord-sqlserver-adapter. Which is nice.

And thats it. Do your bundle install and rock and roll.

Why I dropped uncapped

So a few months ago, MWEB launched there uncapped packages. Myself being one for only taking what I need, I opted in for the 384kbps uncapped account. After going through the many hoops and several phone calls to MWEB’s sales staff I was eventually connected and began to use the account.

Needless to the say the quality of the data service was pretty rubbish, with ping times soaring past the 500ms mark and downloads fluctuating like my line was having a stroke.

I did log a few complaints with MWEB (coz if you don’t try and fix it, you can’t complain about I say). I had a few very pleasant people phone me and made me do some traceroutes and ping tests.

A unique case

I use an VPN to our datacenter in JHB, which adds roughly 40-80ms to the trip time. So immediately as I mentioned that the MWEB consultants backed up and blamed my VPN. Despite not actually being on the VPN when the tests were done. And actually never really getting back to me regarding my speed complaints.

According the troll’s lair that is mybroadband.co.za, everyone seems to be complaining about it over the past 2 months. But then again these are South Africans on the internet so I do take everything with a pinch of salt. After all we are whiners.

Oddly enough after benchmarking my connection for over a month, I found I had better and more consistent speeds through my VPN than without it. At the same time flapping and fluctuating on the connection like crazy. And quite a few times, I actually had banners and sites timeout during loading, which I haven’t experienced since I had a dial-up modem. But then I remembered, this is what it feels like to share a connection with too many people.

You get what you pay for

The biggest problem with the uncappped service is not the ISPs themselves, but rather the IPC providers that sell their bandwidth at unbelievably high rates. So in order for them to make any profit at all they have to break up their bandwidth into smaller chunks and sell you a piece of the actual full capacity you need. See contention ratio

You don’t protest to McDonald’s when your burger, is ‘substandard’. You go somewhere else. But people seem to be shocked and annoyed at the crappy service that these uncapped accounts give us. If they only knew what it cost to have someone with a 4mb connection downloading 24/7/365, the same person who ‘only’ pays R999pm including line rental.

However uncapped does work for some, and actually quite well, there is no other way to pull down over 200GB in one month for under R1k.

You don’t need uncapped

Well I realised after 1 month, I certainly don’t. Don’t get me wrong, I need a lot of bandwidth. But more important than that is speed and consistency. I don’t have time to wait. I expect stuff to happen, I want the weakest part of my online experience to be me.

Now if you don’t want to do 200GB a month, and need more than the standard 3-8GB offerings of Telkom, where does that leave you. Uncapped has been the current flavor solution to this problem. I use between 30-50GB a month, and thats me. The thing with uncapped is that you are paying for hundreds of little torrent hoards to download their 500GB per month of Anime/Porn or whatever else they feel is worth filling a hard disk with.

Shameless plug

So what did I do, I cancelled my MWEB account. I bumped up from 384kbps, to 4Mb (which is now 8Mb thanks to the recent DSLAM upgrades by Telkom). And more importantly I moved to WebAfrica with their Titan Special (which for some insane reason isn’t in their product list.)

I’m plugging them because I believe in their product. The fact that they stated that uncapped was unsustainable at a quality rate and being in my opinion absolutely right. The speeds are super consistant, I get record pings. And I get what I pay for.

/rant

P.S. I have a referral code at WebAfrica now, since I tested out their service 2 months ago and liked it so much. So if you are going to make a switch, I would appreciate my code being meantion. My referral code being OYO03.

A nasty little typo

I’ve just spent about an hour and a half hunting down what the cause of not just a strange error, but rather a ‘no error crash’ on Webrick and Rails. I was dumb founded when Webrick took about 20 seconds to render a page when eventually the terminal just said: Killed

What? Why? How?

I poked around in the development log and saw that the page had in fact been rendered properly, or at least according to the logs.

I eventually tracked it down to one partial, the one containing my tabs for the application:

#tabs
  %ul
    =render :partial => "shared/tabs/#{current_section}", :locals => { :tab => current_tab }

It was a new controller and didn’t have anything setting the section or tab of the controller. So those methods were returning nil.

Which in turn becomes an empty string. Normally I would say, ‘so what?’. Why didn’t it return an error of some sort.

In my opinion the killer blow was trying to render a ‘folder’, seeing that it was given a partial path like this:

"shared/tabs/"

So yeah, it’s a silly mistake, but in a large app, can be very hard to track down. I’ve learnt my lesson.

Form Validation 'bug' in Rails

I just discovered, or rather, stumbled upon an existing bug in Rails that generates invalid HTML.

 
Basically if you are using scaffolded forms, when the form comes back from validation and some fields were marked as invalid Rails wraps the elements in DIV tags and marks them with a class. Which is essence is great, it makes styling really easy.
 
The problem is with the way it does it, scaffolded forms put all the form input elements in P tags. According to XHTML standards, you can't put DIV tags inside a P tag.
 
Below is a form generated with scaffolds.
 
Cleanexample
 
And below is what happens when the form comes around again from the controller with failed validations. Notice how the browser rejects the attempts of nesting the DIV tag inside the P tag. Some real emotional issues going on in there.
 
Badhtml
 
I don't have a problem with wrapping things in DIVs for these kinds of reasons at all. Only when it causes my stylesheets to be 9x more complicated to compensate for all this.
 
So I did a bit of digging and I found this VERY old ticket: http://dev.rubyonrails.org/ticket/2210
 
Seems that this problem has been around for about 5 years and has since then been marked as "Won't Fix". Most of the posters on the ticket have some pretty solid and obvious ideas about tackling it, but nothing seemed to bounce off. Which is disappointing.
 
I've now learnt that ActionView::Base has a setter method for the field error, and you can overwrite it with this:
 
Stick this at the bottom of your environment.rb
 
 
And voila! The html is correct... and not driving me nuts.
Attachment file

Some future thinking

I have recently (and finally) finished, and delivered my cousins wedding photos. I dropped off the album yesterday. They live across the country so I will have to wait and hear back from them.

I will be posting images from the wedding as soon as he has seen the images, including the wedding album. For those of you who are interested.

I've had a lot swirling around in my brain, mostly about how to improve life's little processes. Being a software developer and someone who has the attention span of a flea, I really never can find a piece of software for 2 things that drives me nuts: personal finance & document organisation.

I hate looking at my bank account at the end of every month and going, "what the hell did I do with that money?". So I've been developing a Rails app called 'Financer'. It's in very early stages, and won't be comprehensive. Just for my needs. However it will be open source so as to give back in any way it can.

Another app that I've wanted to build is a document managent app with tags and uploading. For managing bills/contracts etc. The catch 22 is building something above my own needs and 'possibly' building something awesome, or just being selfish I guess. Haha. It's been a long time learning but I think I'll start small and then see where it takes me.

I'm intending to blog a lot more now, I'm intentionally changing my life so I can spend more time doing geeky personal projects.

Why I'm excited about Quicken Essentials

When moving to Mac about 3 years ago, the void in personal accounting software was very apparent.

Now I want to emphasize, personal accounting software, there is Quicken and a host of other accounting packages, that want your money and time.
But when using any of them, I feel like using them either requires a Phd. or needs enough time to make you feel like you are working around the application.

Being a picky person about how my software works and how it affects my life, the last thing I wanted was to spend 10 hours month trying to comprehend a piece of software that is supposed to help me.

So I went back to ad-hoc accounting with paper and pen.
So what about before I used a Mac? Funnily enough I've always said, Microsoft have done 2 things right: SQL Server & Money. Obviously the former is a topic for another day. Microsoft Money 2007 was a fantastic application, actually one of the few development departments in the company that was separated from the general direction of Microsoft and that was very apparent in how the application looked and felt. Apart from coming in 3 flavors, all of which were so similar it begged questioning on the price.

So when I switched to a Mac, I ran Windows via bootcamp for the sole purpose of running MS Money, this obviously grew tiresome after a while and I was also concerned about the portability of my data if I decided to switch to something else.

Alas MS Money was discontinued in 2009.

So what now?

Quicken have been busy for about 4 years, reinventing Quicken for the Mac, the last version release was in 2006. This version also falls in the category of apps I refuse to use. I was part of the beta program for Quicken Financial Life, which when it's beta came out was faulty as all hell. But despite that, gave a good idea on the direction they were taking. All very mac-like, and very pretty (compared to Quicken 2006).

Now the delays we for many reasons, it seems that installing the founder and CEO of Mint.com as the new VP and general manager could have had alot to do with it. Intuit now own Mint.com. If there was any move they could have taken to make Quicken easier to use and more human-ready then stealing (now borrowing) from Mint.com seemed like the only option. And they have taken that step.

All in all there is a lot to be discovered about the new product. I'm very excited to put my faith in this new app.