Skip to content

Instantly share code, notes, and snippets.

@yellow5
yellow5 / tables_with_foreign_keys.sql
Created February 14, 2013 20:28
Query to list all foreign keys for a given schema in MySQL.
SELECT table_name, constraint_name
FROM information_schema.table_constraints
WHERE
table_schema = 'DATABASE_NAME' AND
constraint_type= 'FOREIGN KEY'
;
require 'rubygems'
class Cell
attr_accessor :n, :s, :e, :w, :visited
def initialize(n, s, e, w, visited)
@n, @s, @e, @w, @visited = n, s, e, w, visited
end
def []=(key, value)
self.send("#{key.to_s}=", value)
end
@yellow5
yellow5 / mysql_snip.sql
Created February 17, 2011 21:35
An example of a quick way to list tables in a database containing a given column name
select table_name
from `information_schema`.`columns`
where table_schema = 'DB_NAME' and column_name = 'DESIRED_COLUMN_NAME';
@rud
rud / chop.sh
Created May 19, 2010 12:43
chop - remove the current branch in git, switch to master
#!/bin/sh -x
set -o errexit
CURRENT_BRANCH=$(git branch | grep '\*')
git checkout ${1:-"master"} || exit 1
git branch -d ${CURRENT_BRANCH:2}
#!/bin/sh -x
# Exit if any error is encountered:
set -o errexit
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git merge ${CURRENT}
git push origin master
git checkout ${CURRENT}
#!/bin/sh -x
# Exit if any error is encountered:
set -o errexit
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git pull --rebase origin master
git checkout ${CURRENT}
git rebase master