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
curl -I -s -o/dev/null -w"%{url_effective} %{http_code}\n" -m 5 URL |
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
vim $(find . -regex '.*\.\(php\|tpl\|html\|shtml\)' -print0 | xargs -0 grep -l "foo") |
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
c = ActiveRecord::Base.connection | |
c.execute("SHOW TABLES").each do |t| | |
table = t[0] | |
c.execute("SELECT COUNT(*) FROM `#{table}`").each do |n| | |
count = n[0] | |
next if count == 0 | |
puts | |
puts "#{table.upcase}: #{count}" | |
collist = c.execute("DESC `#{table}`").map {|x| x[0]} | |
.select { |x| !['created_at', 'updated_at', 'id', 'visible'].include?(x) } |
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
# Little script that stashes outstanding changes, performs an svn dcommit, and pops the stash | |
git_stashed=0 | |
git diff-index --quiet HEAD > /dev/null | |
if [ $? -eq 1 ] | |
then | |
echo "Stashing current work..." | |
git stash | |
git_stashed=1 | |
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
#In /etc/hosts | |
127.0.0.1 testsite.localdomain |
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
import md5 | |
import datetime | |
def output_line(line): | |
timestamp = datetime.datetime.today().strftime("%Y-%d-%m %H:%M:%S") | |
print(timestamp + ': ' + line) | |
output_line("Starting program...") | |
list_file = open('mp3_list.txt','r') | |
counter = 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
import csv | |
f = open('mycsv.csv','r') | |
try: | |
reader = csv.reader(f) | |
for row in reader: | |
print row | |
finally: | |
f.close() |
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
writer = csv.DictWriter(csvfile, header_list) | |
writer.writerow(dict((h,h) for h in header_list)) |
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
sys.stdout.write('1') | |
sys.stdout.write('2') |
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
//Table1 has two foreign keys to Table2 | |
abstract class Table1 extends Doctrine_Record { | |
public function setUp() { | |
//... | |
$this->hasOne('Table2 as FirstAlias', array( | |
'local' => 'table2_id_first', | |
'foreign' => 'id')); |
NewerOlder