This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
module Kernel | |
alias old_require require | |
def require(path) | |
#unless caller.find { |caller_line| caller_line.match /dependencies\.rb/ } | |
# return old_require(path) | |
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails 2 and Rails 3 console | |
function rc { | |
if [ -e "./script/console" ]; then | |
./script/console $@ | |
else | |
rails console $@ | |
fi | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Delete large number of files: | |
ls|xargs -L 1000 rm | |
-- | |
Maintenace page for Rails | |
RewriteEngine on | |
RewriteCond %{DOCUMENT_ROOT}/../tmp/stop.txt -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use ssh-copy-id to install your public key in a remote machine's authorized_keys. Also takes care of the permissions of the remote user's .ssh and .ssh/authorized_keys. | |
ssh -t reachable_host ssh unreachable_host. Enables to connect to a host unreachable from current network but reachable from reachable_host's network. | |
To navigate to a directory, run a command and get back: (cd /to/dir && cmd_to_run) | |
To rip audio out of a video file: mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <out_file> <in_file> | |
Rsync: rsync --recursive -avz -e "ssh -p 2020" user@machine:/path dest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yours: current_user.projects.inject(0){|sum,p| sum+= (p.users.count-1); sum} | |
mine: current_user.projects.to_a.sum { |p| p.users.count -1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
your_rails_app/script/runner | |
====== | |
#!/usr/bin/env ruby | |
path_to_rails = File.dirname(File.expand_path(__FILE__)) | |
exec("#{path_to_rails}/rails runner #{ARGV[0]}") | |
====== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rvm use ree-1.8.7-2010.02@global | |
rvm gemset create rails2310 | |
gem install rails -v=2.3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
### | |
# Stupid simple class for uploading to imgur. | |
# | |
# client = Imgur2.new 'my imgur key' | |
# p File.open(ARGV[0], 'rb') { |f| | |
# client.upload f | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.s@\(\d\+\)@\=(submatch(1) + 17)@ | |
Search for numbers and replace them with results of expressions involving them. submatch(1) is \1 (groups in regexes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Usage: viz.py INPUT.csv [template.html] > OUTPUT.xhtml | |
''' | |
import re | |
import math | |
import logging | |
import datetime | |
import operator | |
from tornado import template |
OlderNewer