Skip to content

Instantly share code, notes, and snippets.

namespace :db do
namespace :sessions do
desc "Clean up expired Active Record sessions (updated before ENV['UPDATED_AT'], defaults to 1 month ago)."
task :expire => :environment do
time = Time.parse( ENV['UPDATED_AT'] || 1.month.ago.to_s(:db) )
say "cleaning up expired sessions (older than #{time}) ..."
session = ActiveRecord::SessionStore::Session
rows = session.delete_all ["updated_at < ?", time]
say "deleted #{rows} session row(s) - there are #{session.count} session row(s) left"
end
module AlertConfirmer
class << self
def reject_confirm_from &block
handle_js_modal 'confirm', false, &block
end
def accept_confirm_from &block
handle_js_modal 'confirm', true, &block
end
class Api::RegistrationsController < Api::BaseController
respond_to :json
def create
user = User.new(params[:user])
if user.save
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201
return
else
@xarimanx
xarimanx / deploy.rb
Created September 27, 2013 06:57 — forked from ryancheung/deploy.rb
require "rvm/capistrano" # Load RVM's capistrano plugin.
require "bundler/capistrano"
set :rvm_ruby_string, '1.9.3'
set :rvm_type, :user # Literal ":user"
set :application, "blog_test"
set :repository, "[email protected]:ryancheung/blog.git"
set :scm, :git
@xarimanx
xarimanx / gist:1844502
Created February 16, 2012 12:25 — forked from oleksiilevzhynskyi/gist:1259158
Problem with blame in TextMate
mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://github.com/timcharper/git-tmbundle.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
Ctr+Shift+G => blame
enjoy!
@xarimanx
xarimanx / gist:1800759
Created February 11, 2012 15:23 — forked from oleksiilevzhynskyi/gist:1258663
How to get git-completion.bash to work on Mac OS X?
sudo port install git-core +bash_completion
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_ps1 " {%s}")\[\033[00m\]\$ '
@xarimanx
xarimanx / gist:1798864
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1146869
Failed to build gem 'nokogiri' native extension.
sudo apt-get install libxslt1-dev
libxml, libxml-dev, libxslt, libzslt-dev
@xarimanx
xarimanx / gist:1798863
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1186087
Removing rvm
rvm implode
rm ~/.rvmrc
curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer --version 1.8.0
;
rvm implode
gem uninstall rvm
@xarimanx
xarimanx / gist:1798862
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1230077
Hot keys in terminal
ctrl+a or Home - Moves the cursor to the start of a line.
ctrl+e or End - Moves the cursor to the end of a line.
ctrl+b - Moves to the beginning of the previous or current word.
ctrl+k - Deletes from the current cursor position to the end of the line.
ctrl+u - Deletes the whole of the current line.
ctrl+w - Deletes the word before the cursor.