Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
#!/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
#!/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 ' |
# Useful Hash and Array extensions
# works well with Sams Extlib
#
class Hash
def with(overrides = {})
self.merge overrides
end
# 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 }
# 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)
#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';
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
"AF": "Afghanistan"
"AX": "Åland Islands"
"AL": "Albania"
"DZ": "Algeria"
"AS": "American Samoa"
"AD": "Andorra"
"AO": "Angola"
"AI": "Anguilla"
"AQ": "Antarctica"
"AG": "Antigua And Barbuda"
<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 &amp; Canada)</option>
<option value="-7.0">(GMT -7:00) Mountain Time (US &amp; Canada)</option>
<option value="-6.0">(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
<option value="-5.0">(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
<option value="-4.0">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
@mdp
mdp / googlelog.rb
Created July 1, 2009 23:21
Log to Google Spreadsheet
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}"))