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
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
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
# new branch from stash | |
git stash create new-branch stash@{0} | |
# push a local branch to repo if does not exist remotely | |
git push origin branch_name:refs/heads/branch_name | |
# to start tracking a branch | |
git branch --track branch_name origin/branch_name | |
# create remote git branch from head of master |
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
#!/usr/bin/env ruby | |
# urlmonitor - print out the URLs requested system wide on the main network interface | |
# Accept a network interface name as an optional argument | |
iface = ARGV.first | |
# No interface specified? Try to guess which one is king.. | |
unless iface | |
`ifconfig -l`.split.each do |iface| | |
next if iface =~ /^lo/ |
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
1: | |
CTRL CMD N: OPEN NEW PROJECT | |
2: | |
ESC: PRINT WORDS USED IN CURRENT FILE | |
3: | |
CMD F2: SET BOOKMARK | |
4: | |
F2: GO TO A BOOKMARK | |
5: | |
F1: FOLD/EXPAND A TEXTBLOCK |
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
class StateMachine::TestBaseMixin < ActiveRecord::Base | |
# Make this class active recordish without the table | |
# and add the attributes as columns | |
def self.columns | |
@columns ||= [] | |
end | |
def self.column(name, sql_type = nil, default = nil, null = true) |
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
# taken and modified from http://www.andrewmcdonough.com/2009/10/20/colorized-logs-in-ruby | |
def colorify(string, color, options = {}) | |
offsets = ["gray","red", "green", "yellow", "blue", "magenta", "cyan","white"] | |
# I don't think below LOC is quite right due to the fact that xx and underline strings | |
# are appearing multiple times; will fix it when I am about to use this script. | |
styles = ["normal","bold","dark","italic","underline","xx","xx","underline","xx","strikethrough"] | |
start = options[:bg] ? 40 : 30 | |
color_code = start + offsets.index(color) | |
style_code = styles.index(options[:style]) || 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
#!/usr/local/bin/ruby | |
require 'rubygems' | |
require 'highline/import' | |
require 'twitter' | |
user = ask("Enter your twitter username:") {|q| q.echo = 'x'} | |
passwd = ask("Enter your twitter password:") {|q| q.echo = 'x'} | |
http_auth = Twitter::HTTPAuth.new user, passwd | |
client = Twitter::Base.new(http_auth) |
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
class RomanNumeralCalculator | |
def calculate(numeral) | |
if numeral =~ /^\d+$/ | |
arabic_to_roman(numeral) | |
else | |
roman_to_arabic(numeral) | |
end | |
end | |
private |
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
class A | |
def self.before_filters | |
@before_filters ||= [] | |
end | |
def self.before_filter(callback, params={}) | |
before_filters << params.merge(:callback => callback) | |
end | |
def self.inherited(child_class) |
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
#! /usr/bin/ruby | |
raise "Provide the dir path" unless ARGV[0] =~ /[a-z]*/ | |
to_dir = ARGV[0].strip | |
raise "Provide the dir path" if to_dir.nil? | |
site = 'http://url' | |
print "Processing home page ... " |
OlderNewer