Skip to content

Instantly share code, notes, and snippets.

View cabbiepete's full-sized avatar

Peter Simmons cabbiepete

View GitHub Profile
@cabbiepete
cabbiepete / x-browser-audio
Created February 3, 2011 10:43
cross browser html 5 audio playback example
function supports_audio() {
return !!document.createElement('audio').canPlayType;
}
function supports_audio_type(audioType) {
if (!supports_audio()) { return false; }
var a = document.createElement("audio");
return a.canPlayType(audioType);
}
var alertFile = supports_audio_type("audio/ogg") ? "/sounds/redalert.ogg" : (supports_audio_type("audio/mp4") ? "/sounds/redalert.mp4" : '');
if (alertFile) {
@cabbiepete
cabbiepete / mysql2sqlite.sh
Created June 7, 2012 02:38 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@cabbiepete
cabbiepete / upgrade-virtualbox-addtions.sh
Created November 26, 2012 21:00
Helper script for upgrading VirtualBox Addtions on an Ubuntu guest
#!/bin/sh
sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r)
sudo mount /dev/cdrom /media/cdrom
cd /media/cdrom/
./VBoxLinuxAdditions.run
@cabbiepete
cabbiepete / help-vagrant.sh
Created November 26, 2012 21:03
Helper script to make sure network and /vagrant mount point working for Vagrant VirtualBox linux guests
#!/bin/sh
ifdown eth0
ifup eth0
mount -t vboxsf v-root /vagrant
(function() {
var u = 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore.js';
var s = document.createElement('script');
s.type = 'text/javascript';
s.charset = 'utf-8';
s.src = u;
document.body.appendChild(s);
})()
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite path-to-sandbox mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite ~/sandboxes/msb_5_6_28 --no-data myDbase | sqlite3 database.sqlite
@cabbiepete
cabbiepete / how-to-set-up-stress-free-ssl-on-os-x.md
Created February 22, 2017 23:24 — forked from jed/how-to-set-up-stress-free-ssl-on-os-x.md
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@cabbiepete
cabbiepete / README.md
Created September 27, 2018 22:30 — forked from medmunds/README.md
Taking back your Mandrill click-tracking links

Taking back your Mandrill click-tracking links

My company, like many, has recently switched away from using Mandrill for our transactional email.

We'd been using Mandrill's [click-tracking][mandrill-click-tracking] feature, and became worried about what would happen to all those old emailed links after we cancel our Mandrill account.

Why should we care about links in emails sent a month or more ago?