Skip to content

Instantly share code, notes, and snippets.

@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@otobrglez
otobrglez / article.rb
Created October 3, 2011 23:25
rails named scopes with lambda. a.k.a. problems with date/time in scopes!
Note that scopes defined with scope will be evaluated when they are defined, rather than when they are used. For example, the following would be INCORRECT!!!:
scope :published,
where(:published => 1)
.where(:hidden => 0)
.where("publish_date <= ?", Time.now)
The example above would be "frozen" to the Time.now value when the model class was defined, and so the resultant SQL query would always be the same. The correct way to do this would be via a lambda, which will re-evaluate the scope each time it is called:
scope :published, -> {
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@jhowarth
jhowarth / login.js
Created April 27, 2011 23:08
How to post data to create a new Devise session through ajax
function login() {
var email = $('#user_email').val();
var password = $('#user_password').val();
var data = {remote: true, commit: "Sign in", utf8: "✓",
user: {remember_me: 1, password: password, email: email}};
$.post('/users/sign_in.json', data, function(resp) {
if(resp.success) {
// process success case
} else {
// let the user know they failed authentication