Posted: October 19th, 2011 | Author: jgeiger | Filed under: Uncategorized | No Comments »
I was trying to find a way to add my current directory plus a subdirectory to my PATH.
If you add ./subdirectory to your windows PATH environment variable it works and you can run anything in your current_dir/subdirectory.
Posted: June 28th, 2011 | Author: jgeiger | Filed under: mongodb, ruby | Tags: elasticsearch, mongodb, mongoid, ruby | 1 Comment »
I just setup a quick app with MongoDB, mongoid, elasticsearch and the tire gem. The system seems to work nicely but there is an issue you should be aware of. Since tire uses the ‘after_save’ callback to insert data into elasticsearch it will be pretty automatic, which for the most part is nice.
The issue occurs when you have a unique index in mongodb but don’t have a ‘validates_uniqueness_of’ in your model. With this combination and two similar records, mongo will reject the new record, but it will still insert into elasticsearch giving you a record in elasticsearch that doesn’t exist in mongodb. This is potentially a nasty bug.
The quick fix is to make sure that any unique index in your database also includes the ‘validates_uniqueness_of’ validator in your model.
Posted: June 8th, 2011 | Author: jgeiger | Filed under: ruby | No Comments »
WARNING: ‘task :t, arg, :needs => [deps]‘ is deprecated. Please use ‘task :t, [args] => [deps]‘ instead.
I updated a project from Rake 0.8.7 to 0.9.2 (now that it doesn’t gag on the older code) and was met with this new “error”
So as an example here is one of my old tasks without arguments. I’ve
desc "Persist the dataset"
task(:dataset, :needs => :environment) do |t, args|
end
And the fixed version.
desc "Persist the dataset"
task(:dataset, [] => [:environment]) do |t, args|
end
Now an example with arguments.
desc "Insert the RGD genes into the database"
task :rgd_gene, :filename, :needs => :environment do |t, args|
end
And the fixed version.
desc "Insert the RGD genes into the database"
task :rgd_gene, [:filename] => [:environment] do |t, args|
end
I’m not sure if you need to use the arrays, but it works and the examples do show that.
Posted: June 7th, 2011 | Author: jgeiger | Filed under: ruby, web | 3 Comments »
I decided to create a site that uses the new Rails 3.1rc. I have a nice setup for nginx to serve my static assets and I was able to get it working with rails 3.1. There’s nothing really too tricky since it’s setup to do it, but you need to make sure that you pre-compile your assets when deploying. The only confusing bit is that you should remove all of your assets before running the rake task to make sure you’re not duplicating files and/or serving the wrong thing. I did a bit of testing and found it was necessary to remove the files and re-compile before starting the server to get the correct files served. I’ve added a small snippet of code below to show how I did it. I also decided it wasn’t necessary to symlink the files into the shared directory since they were getting removed on every deploy anyway. I’m sure there’s a way to only delete the files that changed, but for now this works.
Posted: April 22nd, 2011 | Author: jgeiger | Filed under: ruby, web | Tags: gminer, redis, ruby | No Comments »
The title really isn’t great but it does describe an issue I recently ran into. I’m working on a web application that lets a user set wether an attached term is correct or incorrect. While this can be done on a record by record basis, it becomes quite tedious. I set up a system that would show a listing of all of the terms along with a snippet of the text where the term was annotated. This worked well as I had searching, sorting and pagination and users could always move to page two or three if they wanted. This also worked when I had 1000 records. Once I bumped the dataset up to 300k records, pagination in MySQL became pretty lethargic.
I decided to remove the pagination and show the user the first set of records available. It then dawned on me that once you had multiple people working on the same page, they would all see the same records. This isn’t very efficient when you have a lot of stuff to get done. On a side note, this same problem existed in the paginated version, but when you have a link to move to the next page, it doesn’t crop up as much)
So now I needed to figure out a way to determine who was seeing what records, make sure that someone else didn’t see those same records at the same time, and make sure that if nothing was done to the records, they would return to the general pool in a reasonable amount of time.
Enter Redis.
I like redis. I’ve used it on a few other projects and felt that it would be a good fit since it has some nice set manipulation commands and the ability to expire a key after a specified amount of time. I started thinking about how to remove records after the user processed them and such, but I ran into some issues with possible AJAX search lag and that some records I didn’t really care about might be removed from the general population. Also, what do you do if the user only wanted to update a subset of those records? By modifying the key, I’d need to reset the expiration timer.
After writing a bit of code, I figured out that if I deleted the current user’s key before I make a union of all the users records, I wouldn’t have to worry about orphan records and unmodified records. Every time the user saw a list of records, only the current visible set would be removed from the general population.
Here’s a quick overview of what the script does.
2. Add the current user id to the set of curator ids
3. Remove the key that holds the current user’s reserved records
4. Get all the curator ids
5. Generate keys for all the curator reserved records
6. Get the union of all of the reserved records
I have to make a special note here. Redis expects arguments in the form SUNION “key1″ “key2″ “key3″. When you have an array in ruby, generally it will look something like ["key1", "key2", "key3"] The * (splat) operator splits out the array into a group of keys that works for the Redis command.
7-10. Find the first 15 currently available records and store the ids in the current user’s set in Redis.
11. Add a five minute expiration to the current user’s key.
It was interesting to me after thinking about it for a while that the solution ended up being so simple.
Posted: April 14th, 2011 | Author: jgeiger | Filed under: Uncategorized | No Comments »
From lack of posting. I just went through my google reader account and removed about 15-20 rails blogs that haven’t had a post in over a year. Then I thought about my own blog and realized I haven’t been posting at all. Maybe it’s because I don’t have a lot to post, but I do think it’s important that there is at least something there.
Hopefully I’ll be able to do more updates.
Posted: November 16th, 2010 | Author: jgeiger | Filed under: jquery, web | No Comments »
I had been running some features that were working on older versions of cucumebr/capybara with the selenium driver which had recently broke. I was able to find a site that has a nice explanation of how to do it. I was already doing most of this as I had found it before, but adding this step was very helpful.
Posted: November 15th, 2010 | Author: jgeiger | Filed under: ruby, web | 1 Comment »
So, for the longest time I thought this was “rail-tees”. If you look at it, it’s actually “rail-ties”, you know, like the big wood pieces that go between train tracks?
Anyway, this was probably blatantly obvious to a lot of people, but I figured I’d clear it up…
Posted: October 25th, 2010 | Author: jgeiger | Filed under: ruby, web | Tags: dreamhost, linode.com, rails 3, ruby | 1 Comment »
Use *linode.com
Email sent to Dreamhost back in August.
I’m going to make a request for this for you. Please note, it’s a significant bump from what we have right now, Rack 1.1.0, so only our rails expert can make the call, and check to make sure it won’t break anything. She’s on vacation this week, but I’ll send her a follow up email, so she can get back with you on this as soon as she’s back.
This was the response I got from Dreamhost after waiting for two months for an answer. (After I had to ask “hey, what’s up?”)
Thanks for writing. We have to be careful with the upgrade as we have a high number of dependency packages that need to go through the upgrade. It’s scheduled and being worked on, and the current estimate for the full upgrade to 3.0.1 is within a month of two. I’ll get back to you again when there is an update, but feel free to contact me if you have any more questions.
*Link includes my referral code
Posted: October 11th, 2010 | Author: jgeiger | Filed under: Uncategorized | Tags: chevrolet, fail, volt | No Comments »
Chevy has been trying so long to be relevant that they’re willing to push the hype meter too far. If you’re claiming to have an electric car… build one. Don’t market it, publicize it and show it off as an electric car when really, it’s just another hybrid. You delayed 2 years… for this? Sad.