Skip to content

Instantly share code, notes, and snippets.

View mdp's full-sized avatar

Mark Percival mdp

View GitHub Profile
@mdp
mdp / watch_folder.plist
Last active August 29, 2015 13:56
Watch a folder on mac and file off a script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>im.mdp.geeknote_watch</string>
<key>ProgramArguments</key>
<array>
<string>/Users/mdp/.geeknote/sync_notes.sh</string>
</array>
@mdp
mdp / gist:e733fff433ccbe3d41cd
Created May 29, 2014 16:54
Local time in javascript
function localTime(offset) {
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
return new Date(utc + (3600000*offset));
}
localTime(5.5);
localTime(-8)
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is 3D13 2F63 3496 5AD3 5ECF 8001 8162 FA3B 5DE5 6C9A
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is 3D13 2F63 3496 5AD3 5ECF 8001 8162 FA3B 5DE5 6C9A
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am mdp on github.
* I am mdp (https://keybase.io/mdp) on keybase.
* I have a public key whose fingerprint is E1E8 7928 C499 5D0A E31D 1514 D4BF DAC7 74ED EA2A
To claim this, I am signing this object:
# Useful Hash and Array extensions
# works well with Sams Extlib
#
class Hash
def with(overrides = {})
self.merge overrides
end
#!/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 ' |
# 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)