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 | |
# PNGCrush Script | |
# Copyright James Mates -- http://sial.org/blog/scripts/ | |
# Color information stripping added by Mark Percival - http://mpercival.com | |
if [ -z "$1" ]; then | |
echo "Usage: `basename $0` png-image [...]" >&2 | |
exit 1 | |
fi | |
for file in "$@"; do | |
TMPFILE=`mktemp .crush-png-tmp.XXXXXXXX` || exit 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
#!/usr/bin/env bash | |
# mySQL to SQLite3 Conversion Bash Script | |
# | |
# EXAMPLE USAGE: ./mysql2sqlite.sh BDB-sql-2008-03-28.sql | sqlite3 baseball.db | |
# | |
cat $1 | | |
grep -v 'LOCK' | | |
grep -v ' KEY ' | | |
grep -v ' UNIQUE 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
# Useful Hash and Array extensions | |
# works well with Sams Extlib | |
# | |
class Hash | |
def with(overrides = {}) | |
self.merge overrides | |
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
# RSA encryption via openssl ruby | |
# Shamelessly stolen from Leetsoft.com | |
require 'openssl' | |
module Crypto | |
def self.create_keys(priv = "rsa_key", pub = "#{priv}.pub", bits = 1024) | |
private_key = OpenSSL::PKey::RSA.new(bits) | |
File.open(priv, "w+") { |fp| fp << private_key.to_s } |
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
# OpenSSL RSA Cipher | |
# I always forget this, time to write it down | |
require "openssl" | |
require "base64" | |
private_key = OpenSSL::PKey::RSA.new(1024) | |
key = OpenSSL::PKey::RSA.new(private_key.public_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
#mySQL CSV Exports | |
## On the command line | |
mysql -u exampleuser -p letmein exampledb -B -e "select * from \`person\`;" | sed ’s/\t/”,”/g;s/^/”/;s/$/”/;s/\n//g’ > filename.csv | |
## and with a direct mySQL query | |
SELECT * INTO OUTFILE '/tmp/result.txt' | |
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' | |
LINES TERMINATED BY '\n' | |
FROM test_table WHERE 'all'='good'; |
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
desc "Stop merb cluster" | |
task :stop, :roles => :app do | |
run "kill -9 `ps ax | grep merb | grep -v grep | awk '{print $1}'`; exit 0" | |
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
"AF": "Afghanistan" | |
"AX": "Åland Islands" | |
"AL": "Albania" | |
"DZ": "Algeria" | |
"AS": "American Samoa" | |
"AD": "Andorra" | |
"AO": "Angola" | |
"AI": "Anguilla" | |
"AQ": "Antarctica" | |
"AG": "Antigua And Barbuda" |
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
<select name="DropDownTimezone" id="DropDownTimezone"> | |
<option value="-12.0">(GMT -12:00) Eniwetok, Kwajalein</option> | |
<option value="-11.0">(GMT -11:00) Midway Island, Samoa</option> | |
<option value="-10.0">(GMT -10:00) Hawaii</option> | |
<option value="-9.0">(GMT -9:00) Alaska</option> | |
<option value="-8.0">(GMT -8:00) Pacific Time (US & Canada)</option> | |
<option value="-7.0">(GMT -7:00) Mountain Time (US & Canada)</option> | |
<option value="-6.0">(GMT -6:00) Central Time (US & Canada), Mexico City</option> | |
<option value="-5.0">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option> | |
<option value="-4.0">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option> |
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 'uri' | |
require 'cgi' | |
def log2spreadsheet(application, message) | |
formkey = "ck9iWFJsVzdRQlpSUXRwbkpmSWttdGc6MA.." | |
application = CGI.escape(application) | |
message = CGI.escape(message) | |
Net::HTTP.get(URI.parse( | |
"http://spreadsheets.google.com/a/mpercival.com/formResponse?formkey=#{formkey}&entry.1.single=#{application}&entry.2.single=#{message}")) |
OlderNewer