Using the Timecop gem, you can easily test your password timeouts for your users. I use the following snippet in […]
Category: Ruby
Discover flakes by running new tests many times
Tests that only sometimes succeed are a huge nuisance: – They can lead to developers rerunning their build over and […]
Leveraging Subject in RSpec – A rough cut!
Do you use subject in RSpec? No. Follow the link below to blog post that intends to help you get […]
Delete all Redis keys with Redis-rb
REDIS.keys.each {|k| REDIS.del k }
Count occurrences of uniques in ruby
for any given array arr, where you want to count the occurrences of each unique object in the array, arr.inject(Hash.new(0)) […]
Run Sphinx in Rails using Foreman
Using Foreman, Sphinx, and Thinking Sphinx in a Rails project? Here’s how you can run Sphinx from your Procfile: web: […]
Using ActionView helpers from a spec
Still walking the old and used paths of rspec 1 and Rails 2.3 I’ve now battled with helpers … Turns […]
Install rbenv on Mac OS X
Delete RVM source lines from .bashrc (.zshrc/.bash_profile/.profile) Remove RVM installation: rvm implode –force Remove .rvmrc exec $SHELL -l brew update […]
Remove ugly #_=_ string from URL when using Facebook OmniAuth
I was recently working on a Ruby on Rails project with the OmniAuth gem to provide Facebook Authentication. When redirected […]
Bind an EventMachine server to an ephemeral port
EventMachine will happily bind a server to an ephemeral port when you pass a port number of zero to EM.start_server. […]
Use build_stubbed instead of build in FactoryGirl
build_stubbed will never hit the database, whereas build does for associations… much faster! http://robots.thoughtbot.com/post/22670085288/use-factory-girls-build-stubbed-for-a-faster-test
ruby array assignment
The assignments of values separated by commas leads to interesting results: a = 1, b = 2, c = 3 […]
Creating and overriding .rvmrc
If you don’t know what is RVM, check it out. Setting your project environment with rvmrc rvmrc is a file […]
Rails ‘devise’ alternative: Password-less (2FA) & Database-less User Sign-in/Sign-up Using One-Time-Password in 2 Minutes
Definition Password-less login (authentication) means the user does not need to remember her credentials. Instead when she identifies herself using […]
About jRuby 1.7.5 and Warbler
Hey, First post around here (among many other I hope). Okay, right to the point, at my work we often […]
Rails Quick Tips – Pluck Multiple Columns
Did you know that pluck was even more powerful than previously thought? Who woulda thunk it!? While going through the […]
How to reduce iOS development time
Use Rubymotion instead of Objective-C. www.rubymotion.com
Hash uses frozen String key
str = ‘str’ {str => 1}.key(1).eql? str #=> true {str => 1}.key(1).equal? str #=> false str = ‘str’.freeze {str => […]
Upgrading Ruby on FreeBSD
Recently I have had the pleasure of upgrading from end-of-life FreeBSD 7.0 to the latest 9.1. Along with it, I […]
Inconsistent Color Palettes
After I saw the Alyssa post about Inconsistent Color Palettes and her Ruby script, I decided to try it. It […]