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
I need a regular expression that matches the word 'do' on this line: | |
things.each do |x| | |
but not on this line: | |
x = "do your worst" | |
Specifically, I'd like to match on the word 'do' only when it is NOT followed by a quote character later on the same line. |
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
history | grep -i "$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
Steps to combine multiple git repos into one | |
0. Make sure all repos you are moving are checked in and backed up | |
1. cd projects/project1 | |
2. mkdir proj | |
3. git mv * proj/ #will error when copying project1 directory to itself | |
4. git commit -m "about to migrate to new repo" | |
repeat 1 - 4 for other repos you want to combine |
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
history | tail -$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
################################################## | |
# Fancy PWD display function | |
################################################## | |
# The home directory (HOME) is replaced with a ~ | |
# The last pwdmaxlen characters of the PWD are displayed | |
# Leading partial directory names are striped off | |
# /home/me/stuff -> ~/stuff if USER=me | |
# /usr/share/big_dir_name -> ../share/big_dir_name if pwdmaxlen=20 | |
################################################## | |
bash_prompt_command() { |
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
create_file ".rvmrc", "rvm #{`rvm-prompt`}" | |
generate("scaffold","admin_user username:string password:string name:string email:string") | |
generate("scaffold","admin_group name:string description:string") | |
generate("migration","create_admin_group_admin_user") | |
insert_into_file("db/migrations/\*create_admin_group_admin_user.rb", " add_column :admin_group_admin_user :admin_group_id, :integer\n add_column :admin_group_admin_user :admin_user_id, :integer\n", :after=>"def self.up") | |
insert_into_file("db/migrations/\*create_admin_group_admin_user.rb", " remove_column :admin_group_admin_user :admin_group_id\n remove_column :admin_group_admin_user :admin_user_id\n", :after=>"def self.down") |
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
#!/bin/sh | |
#meant to reside in script/ directory of a rails install | |
PORT=8200 | |
ROR_ENV=production | |
LOC=`dirname $0` | |
case "$1" in | |
start) | |
passenger start -p $PORT -e $ROR_ENV -d | |
;; |
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
state = { | |
'AL' => 'Alabama', | |
'AK' => 'Alaska', | |
'AS' => 'America Samoa', | |
'AZ' => 'Arizona', | |
'AR' => 'Arkansas', | |
'CA' => 'California', | |
'CO' => 'Colorado', | |
'CT' => 'Connecticut', | |
'DE' => 'Delaware', |
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
#returns binary representation of a POSTNET encoded zip code | |
#could be used to filter a zip code and then generate an image | |
#1 = full bar, 0 = half bar | |
class PostnetBin | |
def self.convert(zip) | |
codes = ["11000","00011","00101","00110","01001","01010","01100","10001","10010","10100"] | |
r = "1" #bookend | |
total = 0 | |
zip.gsub(/[^\d]/,'').each_char do |c| | |
r += codes[c.to_i] |
NewerOlder