This file contains hidden or 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/bash | |
set -e | |
function warn { | |
# Yellow'ish | |
echo -e "\033[1;33m$1\033[0m" 1>&2 | |
} | |
function info { |
This file contains hidden or 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
sed -i "s/THING_TO_REPLACE/REPLACE_WITH_THIS/g" path/to/file |
This file contains hidden or 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
^(?:(?:(https?):)?\/\/)?([\w\.]+)\/? |
This file contains hidden or 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
# Uses this regex: ^((?:(?!(?:near|in)).)*)(?:(?:near|in)\s*(.*))?$ | |
irb(main):001:0> /^((?:(?!(?:near|in)).)*)(?:(?:near|in)\s*(.*))?$/.match('police records near sacramento, ca') | |
=> #<MatchData "police records near sacramento, ca" 1:"police records " 2:"sacramento, ca"> | |
irb(main):002:0> r=/^((?:(?!(?:near|in)).)*)(?:(?:near|in)\s*(.*))?$/.match('police records near sacramento, ca') | |
=> #<MatchData "police records near sacramento, ca" 1:"police records " 2:"sacramento, ca"> | |
irb(main):003:0> r[0] | |
=> "police records near sacramento, ca" | |
irb(main):004:0> r[1] | |
=> "police records " |
This file contains hidden or 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
group :test, :development do | |
... | |
gem "rspec-rails", "~> 2.0" | |
gem "cucumber-rails", :require => false | |
gem "capybara" | |
gem "debugger" | |
... | |
end |
This file contains hidden or 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/bash | |
$ git log --oneline | |
066087b Adding new support. | |
3f21325 removing the test file | |
a4cde53 updating a file again | |
a86af8a updating a file | |
cdec8c0 testing a git commit | |
c25db10 added assets | |
2554c74 made header text a link |
This file contains hidden or 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/bash | |
set -e | |
die () { | |
echo >&2 "$@" | |
echo >&2 | |
echo >&2 "USAGE: $0 [database]" | |
exit 1 | |
} |
This file contains hidden or 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/bash | |
for DB_FILE in $(ls *.sql); do | |
echo "Using $DB_FILE" | |
head -c $(expr length "Using $DB_FILE") < /dev/zero | tr '\0' '=' | |
echo | |
mysql erictest2 < $DB_FILE | |
mysql erictest2 --batch --silent -e 'show tables' | xargs -I tbl bash -c "echo Table structure for \'tbl\' && mysql erictest2 -t -e 'desc tbl' && mysql erictest2 -t -e 'select * from tbl limit 3\G; drop table tbl;'" | |
echo | |
done > out.txt |
This file contains hidden or 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
-- Locations | |
create table locations ( | |
id int not null auto_increment primary key, | |
feature_id int not null, | |
state_id int not null, | |
place_id int not null, | |
type varchar(255) not null, | |
name varchar(255) not null, | |
county_name varchar(255), | |
latlng point NOT NULL, |
This file contains hidden or 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
# Take the last 2 commits from git and create a patch file | |
$ git format-patch -2 HEAD --stdout > 0001-last-2-commits.patch | |
# Doing a dry run of a patch | |
$ patch --dry-run -i 0001-last-2-commits.patch -p1 | |
patching file ... | |
# Actually applying the patch file | |
$ patch -i 0001-last-2-commits.patch -p1 | |
patching file ... |