Tags
array bash benchmark bug chrome cli configuration css diy editorial firefox fixes gotcha grub hack hardware html5 input instance_eval javascript jquery jsperf linux mouse multi touch multitouch nginx opera performance preferences prototype ruby snippet ssh syntax touch pad touchpad trackpad track pad ubuntu udev virtualbox web standards wii windowsCategories
-
Recent Posts
Recent Comments
- Chema Gallego on Clone Ubuntu VMs in VirtualBox
- Ryan Finnie on Compacting a VMDK (Virtual Machine Disk Format image)
- Prevent Virtual Machines from Saving Network Interface udev Rules | splat operator on Clone Ubuntu VMs in VirtualBox
- David on Ruby instance_eval gotcha
- force on Clone Ubuntu VMs in VirtualBox
Archives
Meta
Tag Archives: ruby
Render a template from a hash in Ruby
A hash is a great way to manage a list of key/value pairs, and templates are a great way to render content. So here’s a simple way to render a template from a hash. template.erb My favorite color is <%= … Continue reading
Posted in ruby
Tagged binding, context, erb, hash, instance_eval, openstruct, ruby, template
Leave a comment
extconf.rb:4:in `require’: no such file to load — mkmf (LoadError)
I’ve hit this a dozen times and I always forget the solution. When you get this on Ubuntu, sudo apt-get install ruby-dev
Show Duplicate Filenames with Ruby
Here’s a quick one. I want to show just the names of files that have the same basename in a directory. Code require ‘find’ require ‘set’ all_files = [] duplicates = {} basenames = Set.new ARGV.each do |dir| Find.find … Continue reading
Ruby instance_eval gotcha
I don’t know how much of a “gotcha” this is since it’s just a defined behavior and feature of the language, but I still found it a little counterintuitive when I encountered it, and I had to actually read the … Continue reading
Run Sinatra App in a Subdirectory with Rack::Builder.map
Thank god I found Tanner Burson’s blog. I was about to explode. I recommend reading Tanner’s original post, but the short answer is that you want Rack to do some routing for you via Rack::Bundler.map. Here is a super simple … Continue reading
Request Tracker Watchdog
I recently upgraded from Request Tracker 3.8.0 to 4.0.2 and started running it with FastCGI. Works great except for the odd Bad Gateway message from nginx (still haven’t figured that one out). While v4 makes a lot of improvements over … Continue reading
Running Rails 2.3.14 on Ruby 1.9.2
While trying to run Rails 2.3.14 on Ruby 1.9.2, I was getting an error page with ActionView::TemplateError (invalid byte sequence in US-ASCII) Turns out Rails 2.3.14 on Ruby 1.9.2 was trying to read my UTF-8 data as US-ASCII. Solution Don’t … Continue reading
Sanitizing File Names with Ruby
At work, I ran into a problem wherein I was copying files from one filesystem (FAT32) to another (NTFS), and there were file names with characters that were legal in the first, but not the second. I wrote a Ruby … Continue reading