Dualistic

Pol Llovet :: Life & Work

plum blossoms

Case What?

So, I was merging some changes (the postgres chef recipe), and I ran across the following:

why would you do this?
1
2
3
4
5
6
7
8
case
when platform_version.to_f <= 5.0
  service_name "postgresql-#{node['postgresql']['version']}"
when platform_version =~ /squeeze/
  service_name "postgresql"
else
  service_name "postgresql"
end

I am confused. Why would you do this? What possible benefit does this have over just using an if/else/elsif block? So… I’m going to just change it to:

why would you do this?
1
2
3
4
5
6
7
if platform_version.to_f <= 5.0
  service_name "postgresql-#{node['postgresql']['version']}"
elsif platform_version =~ /squeeze/
  service_name "postgresql"
else
  service_name "postgresql"
end

Because that seems, you know, sensible…

I Know We Can Do Better, Ruby (a Simple Setup in 8 Excruciating Steps)

I love Ruby, but it can be a total pain in the ass. Not the language, mind you, but the ecosystem. And the crazy thing is, the Rubygems+RVM setup is basically unparalleled in the development world for flexibility and ease of use. I really can’t think of any other dev environment that is half as cool. So, what’s wrong? Well, let’s go on a little journey…

SOAPing With Ruby and PHP

So, there are some folks on campus who would like to have their faculty’s journals listed on their faculty pages. This is certainly doable with some web-scraping, but the Web of Science (Web of Knowledge, actually) has an API, and the folks I have talked to have secured access to said API.

Unfortunately, it is a SOAP API, something which I know nothing about. But, hey, how hard can it be?

There Has Never Been a Better Time to Be a Self-taught Coder

I posted this as a response to a blog post, and I thought it might be more generally appreciated. It was in response to a short quote in the post where she was wondering which degrees might be worth the astronomical cost of tuition, “Computer Science, I guess…”

I hate to say it but to be honest, there has never been a better time to not be in the process of getting a computer science degree. I work in academia, so this is a really tough thing to admit, but I think it’s true. It’s not just the spiraling cost of education, and the cost/benefit analysis of tuition. The whole situation is changing.

Everything Past Here Is Old

This is just a note. All of the rest of the posts here on this blog are imported from my old blog and are from 2008. They are woefully out of date, and I just imported them for posterity and continuity.

Ruby Dbi and Mysql Driver

If you want to do direct access to mysql (or other databse) you can use the dbi gem to do it. But what the docs don’t tell you is that you need to gem install a database driver also.

Apache2 Mod_rails Recipe

I recently had to write a recipe to set up instances of mod_rails apps for apache2. The goal of this process is to have a server that has apps hosted at http://server/app1, http://server/app2, etc.

The recipe is going to be used to create a puppet script, but it could also be boiled down to a ruby or shell script to easily create app instances for anyone’s use.

Multi-OS Password Management

It’s a problem trying to keep track of all of your passwords. I have a mac laptop, mac workstation at work, and a windows machine at home. Add to that the myriad of websites, servers and services that I have users and passwords for. It’s a mess. However, I managed to find a perfect solution…

Openvz and Mod_rails

Setting it up was pretty easy, though I had to triple my memory allocation over what I was using with nginx+mongrel.

  • I created a new virtual machine, but with more memory than usual: PRIVVMPAGES="150000:300000"
  • I vzctl enter <the new machine>
  • as root:
1
2
3
4
$ apt-get ruby ruby1.8-dev rubygems apache2 apache2-mpm-prefork build-essential vim
$ gem install fastthread 
$ gem install rake (i have rails frozen into my apps, otherwise I would have installed it also)
$ gem install passenger
  • for some reason, my binaries were not linked, nor the rubygems path exported, so:
1
$ ln -s /var/lib/gems/1.8/bin/* /usr/bin (heavy handed, but it works)
  • run passenger-install-apache2-module and follow the instructions

after starting apache2, i was able to see my site up and running. yay!

The History Meme

See Here.

1
2
3
4
5
6
7
8
9
10
11
chem69:ipm pol$ history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
123 cd
118 ls
97 hg
19 vim
19 script/server
17 rake
12 script/generate
12 cp
8 ssh
7 script/plugin