Archive for February, 2010
Two years with Ruby
Tonight I realized that its now been two years since I first started working with Ruby. Back in February of 2008, I’d posted about my first experiments with Rails. Lo and behold, its now been two years. I do say two years with Ruby though, not Rails. I’ve been using Merb for about the past year and a half. Although I have started messing around with Rails 3 and really like what I see so far.
So in the past two years, what have I done? Sadly, a lot of it is sorely behind and out dated, but take a bit of a trip down memory lane…
- The SkitchDav I originally blogged about, but now no longer use
- DM-DBSlayer. I was using it in a personal app, but the app didn’t need scale, so eventually removed it.
- DM-Paperclip. I really need to dust this off, it needs some TLC.
- Some hacking on Warehouse, which eventually led to my ideas for Trunks.
- Branches, which was basically a ruby port of Gitosis. I wrote it anticipating using it for Trunks so I could interact with the DB in Ruby. I did in the first incarnation of trunks, but am now on “Branches 2.0″ which was done from scratch and super simplified so it is Trunks-only and structured to do both Git and Mercurial. Would actually be nice to pull it out of Trunks and release it. Damn, another project for my list.
- Tigger. Really bad name. When I first wrote Trunks but was unsure about launching it, tried to redo the interface as a better read-only web interface to git repos. The app should still work… was on Merb 1.0.
- And of course, Trunks. Merb 1.1-pre.
And I’ve also had several apps that haven’t seen the light of day and were more for my personal use or tinkering.
- For a while I was into EVE Online and wrote an app to parse and process item reports from Eve Central. It allowed me to locate items that were selling under market rate quickly, compare prices across markets, and I could somewhat defer what items were selling most at different market hubs. Really geeky. Probably put several months into it. Merb app.
- Also wrote an app to track my sales by location, by item, and comparing sales volumes based on price as I played with prices. Merb app.
- And another for EVE Online… came up with the “Jita Mineral Index” which tracked mineral prices in the main market hub in the game. I left it up for several months after I stopped playing, until I found that the app that processed the emails from Eve Central broke and had like 200k+ unprocessed messages in its inbox. Merb app.
- Some time ago, was playing with different virtualization APIs and wrote an app that would provision and deploy virtual servers in KVM and in XenServer. I’m probably too much of a nut about virtualization. Mixture of stuff… Ruby, Nanite, Merb.
- A really basic Sinatra app to handle my domains that just have static pages. Rather than having multiple sites, I have just one and it determines which template to render based on the host header. Was my first Sinatra app.
And of course some other stuff on Github and Gist.
And I have some that will likely be coming soon:
- This, which I’ll likely blog about once I get a name for it and a domain. And update the incorrect launch date in the News part, oops.
- Was actually thinking of dusting off my original SkitchDav as a Sinatra app. What triggered me to write this.
- Also thinking of dusting off an app I prototyped a while ago involving Rack and Solr.
- Always got ideas brewing in my head… just a matter of parsing out which are really worth my free time.
All this Ruby has also helped me to grow so much more as a .NET developer.
- More languages you know the better.
- Exposure to new methodologies and mindsets, new more progressive community.
- Exposure to testing. Testing is far easier in dynamic languages, and grasping the concepts in a dynamic language makes it easier to apply to a static language.
- MVC. Thank god for MVC. Unlearned all the webforms crap and re-learned plain and simple HTTP and a logical structure for your app.
- Making programming fun again. Its nothing against .NET, but sometimes you need to break out from the familiar and learn something new to remind you why you love programming. Before Ruby, I was stuck in what I knew and don’t really think I was coding for fun much.
Migrating datacenters: How to forward traffic
I have some of my own datacenter space with a couple of servers that I use for a little bit of hosting that I do. This weekend, I’m finishing a migration and having done this type of thing a couple of times, thought I’d share a few tips.
First of all, one thing that is very nice to do, if you have a presence in both places at the same time, is to configure IP forwarding from your old site to your new site. While it is a best practice to set the TTL on your DNS records really low (mine are currently 60 seconds), ISPs don’t always honor the TTLs and some will be more aggressive with caching. As a rule, its usually 8-24 hours before you can really count on old caches being expired.
To combat this, forwarding any traffic that might be going to the old addresses to the new ones can be very helpful, and fairly easy to do.
There can be several ways to do this, but can often times end up more complicated. The pure and simple way to do it is to use an application called rinetd, which is basically an “internet redirection server”. You simple edit its configuration file, specify the old IP address and port, and the new IP address and port. Run it and you’re good!
I run ESXi on some of my systems, so I simply created a new virtual machine with a very basic configuration and installed Ubuntu on it. I gave it a base IP that I wasn’t going to be forwarding, installed SSH on it (to remotely manage it), and then went to town setting up what I needed forwarded. First, I added the IPs to be forwarded as aliases in /etc/network/interfaces:
auto eth0:0
iface eth0:0 inet static
address 192.168.1.111
netmask 255.255.255.0
Now, I need rinetd. On Ubuntu, it is readily available as a package, so just run sudo apt-get install rinetd and you’re set. Edit the /etc/rinetd.conf to list out how you want things forwarded:
# old ip old port new ip new port 192.168.1.111 80 172.16.1.222 80
Afterwards, all you need to do is restart networking and rinetd. So run sudo /etc/init.d/networking restart and sudo /etc/init.d/rinetd restart.
Few things worth noting. rinetd binds to the address/port you specify, so if you are trying to forward port 80, you can’t have something else bound to port 80 on that IP, such as a webserver. So if you need to forward something that you might have in use, you may have to tweak things. If you need to forward SSH, it might be best to configure SSH to use another port for a little while. Second, I’d sometimes just reboot the virtual machine instead of restarting networking. I’d migrate some stuff one night and have it forward for 24 hours, then next night migrate something else and have it forwarded. It’d sometimes get a little hairy adding/removing/reconfiguring aliases a lot, so I’d just reboot.
Another plus with rinetd is that a port of it exists for Windows! A download exists on its site and it is also possible to configure it as a Windows service using ServiceEx. I haven’t tried it myself, but I did find some pretty detailed instructions about configuring it on Windows.
One of these things is not like the other, except to SQL
Was recently working on an issue that was so perplexing, that I almost had David Penton, our resident SQL expert stumped.
We had an issue with some username handling and it ended up boiling down to there we could go into SQL Server, run this query, and get a result when you’d normally expect it to not match:
select 1 where N'ß' = N'ss'
After that, I was truly stumped. I’d Googled everything I could think of any came up empty. Had I known what the German sharp S was, life would have been easier. Come to find out through some sources, that some of the SQL standards (in this case, SQL92 is referenced) call for the German sharp S is translated down to “ss” in string comparisons. So although it might seem like a bug, it is to-spec. Oracle is also reported as working this way.
To work around the behavior, one option is a workaround function for SQL Server which essentially has you convert the string to a binary column and store it. This may be outside what you can do in your application though, as in ours, we’d need to update every place that does string comparisons on the username as well as altering the ASP.NET Membership tables and stored procedures.
An alternative is to change your database collation to use one that is more binary dependent such as Latin1_General_BIN. This will treat ß and ’ss’ separately, though also be aware since it is binary, it is case insensitive and some behaviors such as sorting may also change.
A topic like this is important for any developer for a few reasons:
First, being in the US, it is easy to be ignorant of other culture’s language handling. You may work to add resource labels so your application can be translated and such, but every so often you will find behaviors related to internalization that perplex you because you’ve never heard of the German sharp S (as in this case).
Second, when its an issue in SQL and you’re in doubt, look at collation first. SQL Server has a huge list of collations, and each one does something different. Its either a behavior with the one you’re using, or the user is using a collation you haven’t tried (tested) before.
And finally… need to try harder to stump Penton. It can be done!
Hiring in today’s market
It is crazy how today’s job market is. Earlier I was looking over the new topics on Hacker News for the “Ask HN” threads and was surprised to find three “whose hiring” ones in the past 7 hours.
Today’s market is super competitive, especially at the entry level jobs. My sister graduated from CSU Fullerton with a degree in Journalism and Graphic Design, which has a strong communications program and is well respected. She was also a contributing author to the school newspaper, interned at Us Weekly in Los Angeles for two years, and interned for Us Weekly in New York over the summer.
She graduated in May, but just now was able to get a job in her field. That is nuts. Granted over the summer she was doing an internship in New York, expected to stay there but later decided to come back to California. But she still was actively looking for a job from August to the end of January. On the job she finally got, she beat out 250 other people who’d submitted resumes. She was also in consideration for another job, that one was up against even more people and it came down to her and one other person.
The market today is a stark contrast from when I was in college and all my professors and advisors were touting how easy it’ll be to get a job and making $60k easy. I would be scared to be graduating in today’s market.
Today, a degree is just a piece of paper. Everyone else who is graduating with you has the same piece of paper. To beat them out, its who you know and the experience you have. I’m by no means saying college is worthless, but rather it isn’t everything. I’m a college drop out… I left college to work at Telligent. I’ve been luck enough to have it work out, and now my work experience would be more relevant. Its no longer enough to just go to college.
Building on James’s comment in my last post, a web developer today needs Google juice behind them. A degree is great, but so is a blog with relevant topics, involvements in projects, a Github profile, and more.
Being professional and managing your identity
This new podcast has been causing quite the discussion on Twitter this morning and I thought I’d take a moment with a few thoughts. The podcast is this one and you might want to listen to it, for the first couple minutes, but it will be truly be a waste of your time and will leave you feeling dirty about some of the other people in your profession. Sexist, racist, homophobic, they run the full gamut. One person was brave enough to post on forums.asp.net “announcing” the podcast with his normal user account, but it got deleted as the podcast is quite inappropriate. He had another post looking for contributors, but that whole thing is besides my point. I won’t link to him to spare him additional Google hits to damage what remains of his credibility. And I don’t want to necessarily talk about the podcast.
I want to talk about professionalism and your brand.
It is kind of ironic that the podcast talks about how you should always be professional in your code comments while producing what they did (think beyond just code comments). In this day and age, the internet is pervasive and data is everywhere. Google crawls everything, and it remembers everything. The post looking for contributors talks about other podcasts being “careful about how they talk”. When its online, it isn’t about being careful how you talk, or even being professional. It is about managing your identity.
The days of “dress to impress” are over. You are no longer judged just by how you physically present yourself, you are your Google results. You could go into a job interview dressed to the T, well presented and the pillar of what they are looking for. But its becoming more common where they’ll Google your name and finding out who you really are.
What you do online stays with your forever. You don’t need to be prim and proper by any means. Just use common sense. You are managing your brand. What your coworkers see, your family, your future employers. You can be bold and opinionated, you can still speak your mind, but do it intelligently. Something like that single podcast can ignite a fire of comments and posts, links, name mentions, and then when someone Google’s your name, they’ll find your drunk rants And it can be hard to manage your brand once it has taken off like that.
A while ago, I’d found this presentation through Twitter about “Evangelizing Yourself” by Whitney Hess. It is chalked full of wisdom. Listen to it (the play button has the audio, I missed that at first). It is all about what I’m trying to say and says it much better.