<omitted>
Month: August 2007
Load Balancing Mongrel with Pen on Windows 2003 server x64 64bit 64 bit
Rails, WindowsAlright – so there was a stupid software company. And they write in ASP.net and c# for web based apps. Ew.
So they said – we need a windows server that has 64 bits.
This server is also the server my company wants me to deploy my Ruby on Rails app onto, which is not fun.
First off its windows…and windows doesn’t always place nice unlike its friendly penguin counterpart…oh and this other company wanted everything running out of Microsoft SQL instead of MySQL…ew again.
So I complied and got my app switched to MsSQL (that’s a whole other post). And its nearly impossible to run a rails app behind another app that’s using IIS on a 64 bit machine (it requires $100 software and that’s another post too.)
Hokay so, turns out the other company’s program didn’t work and I got to remove it. Yay! Now I can use Mongrel instead of IIS…Yay! Well here’s the rub – turns out Mongrel wasn’t able to run as a service on 64 bit machine until one of the Mongrel guys figured it out about 6 weeks ago.
To get mongrel running you need to install the service with mongrel:service and but you have to include the FULL PATH to ruby.exe – then it works!
Ok great now I have some mongrels that run as service and startup when the server restarts. I decide to go with Pen for load balancing: easy and lightweight sounds great. So I try to install Pen as a service so I don’t have to login and run it everytime the windows server crashes and restarts (hopefully not ever but the gods are against me and I probably won’t be at this company to start the webservers up for them in the future).
No go with installing Pen as a service with the usual SrVany.exe route – maybe I just don’t know how to edit the registry correctly or setup SrVany on a 64 bit machine – but the usual route was giving me “service would not start promptly” error immediately when I press “start” under the services control panel.
Today I figured out a workaround – I used Scheduled Tasks to add a command prompt task every time the server starts. Then I changed the program from c:\system\someDir\cmd.exe under advanced options to a .bat file that contained my startup script: d:\pen\pen.bat
echo Start Pen for Mongrel Balancing
"d:\path\to\pen\pen.exe" -H 80 localhost:3000 localhost:3001 localhost:3002 localhost:3003
echo end of Batch file
pause
I tested it and it works!
US and Canada Area Codes and States
RailsSo I compiled a list of the area codes in US and Canada and their appropriate mappings to states. I have to do this because my Rails program must geocode based on a caller’s information: first it tries zip code, if that’s not present, then state, and finally it looks up the area code of the caller and maps the state and then sends the state to google for geocoding.
So I compiled the list into a nice CSV file (so you can load into your db with FasterCSV) from http://www.bennetyee.org/ucsd-pages/area.html
You can download my CSV file here.
File Upload in Ruby…so stupidly simple
RailsOn a form:
<%= form_tag({:action=>:save_csv_file}, :multipart => true)%>
<input name="csv_file" type="file">
<%= submit_tag "upload it" %>
<%=end_form_tag%>
Then in the controller:
@name=UserLogs.new #Store the filename in my db
@file=params['csv_file'] # get the file from the form (its called 'csv_file')
if @file.original_filename.index(".csv") #this checks the filename
#in this case its a CSV file
I add a time stamp to the file name:
@filename=@file.original_filename.chomp(".csv")+"_"+Time.now.strftime('%m-%d-%Y_%H_%M_%S')
Next is the where you chose the directory, “wb” is so Windows doesn’t fumble a binary file: File.open("#{RAILS_ROOT}/public/upload/#{@filename}.csv", "wb") do |f|
#This writes to the opened space above:
f.write(params['csv_file'].read)
end
Below saves the filename to the db so I can link to the filename later:
@name.filename=@filename+".csv"
@name.kind="csv_upload"
@name.save
Now you have a user uploaded file stored to the filesystem with its name and type stored in the db.
Ruby Console to the Rescue
RailsI hadn’t used Ruby console ever to test things out. That means lots of code tweaking and page refreshes to test things…not a good approach I know.
So I figured I’d fire up the console
$ cd /MyRails/AppDirectory/
$ ruby script/console
So from there I was able to test all kinds of silly stuff. Like how to remove non digit characters from a string and leave only a number. I was able to test several different ways and it instantly tells me if my syntax is wrong and its quick and easy to fix a missing comma or something like that.
It was also very helpful testing out the GeoKit plugin for mapping and GeoCoding addresses. After only 10 minutes instead of like an hour I was able to work out the syntax and get the thing working, w00t.
And this morning I needed to figure out how to combine a date and time from two separate user fields into one field stored in my silly silly MS SQL database. And I did it in about 2 minutes instead of the normal 20 or so of fooling in my code and refreshing the page and building test pieces and then backing out the test pieces and getting distracted with another problem on the page and fumbling with syntax for 10 page reloads and and and….
All in all Ruby console to the rescue.
Ubuntu on Acer Aspire 5570z
LinuxI successfully installed Ubuntu to my laptop and after all weekend finally got wireless and sound working.
Wireless was the hard part – for anyone looking how to set this up I followed the instructions here.
Update 8-29-07:
the above link is to the end of the post – the directions are at the beginning: http://ubuntuforums.org/showthread.php?t=512828&page=1
Worked awesome once I ran the scripts and restarted – had a hard time however connecting to a WEP encrypted network even though I had all three different passkeys.Sound wasn’t working and I was worried I would have to hunt down obscure drivers that might not exist. The Aspire boasts HD surround audio and sounds great so I was disappointed when it didn’t come up right away.
Of course it was a super simple fix. Double click the volume icon in the tray. Under Preferences check Surround and then increase the volume on the new Surround slider and unmute it. Worked perfectly and no installation or searching for drivers.
I’m working on setting up gedit so I can work on my Rails projects like I do here in the office.
Configuration Clusterfuck.
Linux, WindowsSo after the “fiasco,” or rather, “disappointment” of signing over my software today all hell broke loose.
The company that shares office space with the company I’m contracting for moved out today and they wanted me here to make sure they didn’t take our server down.
That went smooth so I decided to disconnect all the unused ports from the empty offices so I could add two switches. We for some reason, have a 24 port switch for over 50 data ports in the office. So the <omitted> company that was moving had installed their own switches to add computers to offices. So I wanted to add the switches to the locked telco room instead of having them floating around under desks.
I disconnected several of the ports, careful not to take down any of my company’s offices. So then I come back to my linux machine and I can’t get internet. At the same time no one can print. And the fax machine ran out of ink.
So I could not figure out why I couldn’t get an IP address on any of the connections that had been unplugged and plugged back in. Turns out the DHCP server was on one of the servers that got moved. Awesome. So I fire up the <omitted> beast and get DHCP working after an hour of trying everything else.
Great, now I can get a connection, cool. I hook up an old fax and the old lady trying to use it keeps getting an error. I decide to ignore her, usually best to leave frustrated women the hell alone, and I focus on the printer. After another hour of tinkering turns out the printer can’t get an IP. I end up having to set it statically and no config of any other machines on the network was needed.
Ok, awesome, internet and printing, but no fax. I decide to fax my dad a test sheet. He’s not at his office at 7:00 fucking-o’clock on Friday but it went through without error. Old lady musta had her numbers wrong…I’ll deal with her on Monday.
What a Friday…t<omitted> deadline. I think I’ll get schwasted tonight.
Don’t Get Screwed by your client Part 2.
RailsSo here’s what happened.
Yesterday afternoon at about 4:00 the CFO approached me about this
matter. This is after 4 months of development, so its seemed a little
late and out of the blue.
They were concerned that my product is so well suited for this
industry, and that there is nothing off-the-shelf for less than $100k,
that they want full control of the product.
I talked to a few of people and they said here are your options:
1. Pull the plug and walk away. Finish it and try to sell it on your
own – this forfeits about $4000 of income in the next three weeks.(which I never actually got from them)
2. Agree to share in the future licensing and sign over the copyright
for a period of time.
3. License it and make them agree to open source (yeah right)
4. Hand over the copyright but demand full market value for the
product.
So this morning I walk in and the big boss has his golf club out ready
to “discuss.”
He says “Sign over everything by noon or walk.”
“Well I need some legal counsel on the matter I’ll get back to you by
Monday.”
“No way…noon or your outta here”
They do pay me a monthly “retainer” and have provided me office space
so I’m in a bit of a bind with a half finished product.
So I actually just signed everything over with a provision for an
agreement, after full completion of the product, that I get paid a
portion of any licensing or sale of the product (their attorney was
witness to this).
They stated that since it was a “funded” project (I’ll have made about
$15k over a 6 month span of development) that they “own” the copyright
– which isn’t so according to work-for-hire law. They have to have an
agreement signed and it was foolish not to sign one at the outset.
This is my first programming job and they allowed me to learn as I go
and I’m only 23 so there are plenty more opportunities out there.
And like Brian said I can always start a new project from scratch as
long as it is sufficiently different in design and function for any
other competitor and I have not signed a non-compete, thank god (I’m
sure they’ll have one lined up after product completion)
Don’t Get Screwed by your client.
RailsI was hired as a contractor to advise on technical and IT issues for a
<omitted> company in April.
They were searching for a database system that would work for them.
We couldn’t find one off the shelf so I said I could code one with
Rails for them.
Well now the <omitted> piece is done and the <omitted> piece
is half done and they asked me today to sign over my copyright so I
can’t sell the software to any other companies.
I am employed as a sub contractor and the checks go to my LLC.
I am (well was) planning on marketing this software to several other
<omitted> companies as there is no solution like the one I’ve made
available so my price is (was) going to be substantially high.
My question is how do I retain copyright, appease my
client, and sell my software?
My thoughts were to license it exclusively under some sort of open
source license to the client, so that I could, as an “outside”
developer, use my own code and resell it after modifying under the
terms of the license.
Now fully working in Ubuntu Linux
Linux, RailsI got Ubuntu installed and up and running on my machine at work.
Its great to back in the Linux environment after being in Windows:( for so long.
Getting everything up and running was a bit of a process and I’ll post more about getting Rails and Ruby code editing up as well as some of the other problems I’ve had, like mouse issues, and sound issues, and network issues.
I love the easy of getting new applications with sudo apt-get install
I don’t love Banshee’s lack of podcast support. By this I mean no chapters menu, and it burns podcasts as all one track to CD unlike iTunes.
Why isn’t iTunes supported on Linux?
I hate DRM music from iTunes – I can’t listen to a third of my music in Banshee or anything for that matter.
I love workspaces
I love assigning my keyboard shortcuts (even made my own in firefox)
