Skip to content

Instantly share code, notes, and snippets.

View IcyMidnight's full-sized avatar

Damien B IcyMidnight

  • San Francisco, CA
View GitHub Profile
for i in $(seq 0 1 9); do cmd $i args; done
sysctl kernel.hostname
sysctl kernel.hostname=new_hostname
gitdiff HEAD FETCH_HEAD
@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}
@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}$"
for f in *.yml.example; do cp "$f" "`basename "$f" .yml.example`".yml; done;
@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 }'`
@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 / 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;