Skip to content

Instantly share code, notes, and snippets.

View khamidou's full-sized avatar
🎧

Karim Hamidou khamidou

🎧
View GitHub Profile
@jeremyjarrell
jeremyjarrell / Idempotent migration in MySQL example
Created July 25, 2013 20:06
In MySQL, IF statements cannot exist outside of stored procedures. Therefore, to create an idempotent migration for MySQL it's necessary to wrap the migration in a stored procedure and execute that stored procedure against the database to perform the migration.
DELIMITER $$
DROP PROCEDURE IF EXISTS add_email_address_column_to_customers_table $$
-- Create the stored procedure to perform the migration
CREATE PROCEDURE add_email_address_column_to_customers_table()
BEGIN
-- Add the email_address column to the customers table, if it doesn't already exist
@esamattis
esamattis / .pdbrc
Created August 4, 2011 12:18
What every python developer should have in their ~/.pdbrc
# Enable tab completion
import rlcompleter
import pdb
pdb.Pdb.complete = rlcompleter.Completer(locals()).complete
# Sometimes when you do something funky, you may lose your terminal echo. This
# should restore it when spanwning new pdb.
import termios, sys
termios_fd = sys.stdin.fileno()
termios_echo = termios.tcgetattr(termios_fd)