Skip to content

Instantly share code, notes, and snippets.

View IcyMidnight's full-sized avatar

Damien B IcyMidnight

  • San Francisco, CA
View GitHub Profile
@IcyMidnight
IcyMidnight / Show All Foreign Keys in MySQL
Created June 19, 2009 10:05
Show All Foreign Keys in MySQL
SELECT constraint_schema AS `database`, constraint_name, concat(table_name, '.', column_name) AS 'foreign key', concat(referenced_table_name, '.', referenced_column_name) AS 'references' FROM information_schema.key_column_usage WHERE referenced_table_name IS NOT NULL;
@IcyMidnight
IcyMidnight / MySQL functions to convert between binary and string uuids
Created July 31, 2009 09:27
MySQL functions to convert between binary and string uuids
DELIMITER |
CREATE FUNCTION uuid_from_bin(b BINARY(16))
RETURNS CHAR(36) DETERMINISTIC
BEGIN
DECLARE hex CHAR(32);
SET hex = HEX(b);
RETURN CONCAT(LEFT(hex, 8), '-', MID(hex, 9,4), '-', MID(hex, 13,4), '-', MID(hex, 17,4), '-', RIGHT(hex, 12));
END
|
@IcyMidnight
IcyMidnight / gem uninstall with glob-like-iness
Created August 19, 2009 08:31
gem uninstall with glob-like-iness
sudo gem uninstall `gem list | grep merb | awk '{ print $1 }'`
for f in *.yml.example; do cp "$f" "`basename "$f" .yml.example`".yml; done;
@IcyMidnight
IcyMidnight / Size in current directory
Created November 12, 2009 05:24
Size for directories in current directory (hide output for recursion)
du -h|egrep "^[^/]*(/[^/]*){0,1}$"
@IcyMidnight
IcyMidnight / Log Sequel Queries.rb
Created November 14, 2009 00:58
Turn on the sequel gem's query logging in merb
Merb.logger.info.auto_flush = true; ::Sequel::DATABASES.each { |db| db.logger = Merb.logger.info}
gitdiff HEAD FETCH_HEAD
sysctl kernel.hostname
sysctl kernel.hostname=new_hostname
for i in $(seq 0 1 9); do cmd $i args; done
@IcyMidnight
IcyMidnight / gist:277643
Created January 15, 2010 00:08
Bash function to create a new git remote branch, a new local branch to track it, and then start using that branch
#!/bin/bash
function git-create-branch() {
if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 branch_name
exit 127
fi
branch_name=$1
# Create the remote branch
echo "git push origin master:refs/heads/$branch_name"