Skip to content

Instantly share code, notes, and snippets.

@timothyw
timothyw / gist:865293
Created March 11, 2011 01:08
Print out size of tables in mysql
#!/bin/bash
# Calculate the storage space used up by all tables in a given MySQL database
# Ben Dowling - www.coderholic.com
database=$1
username=$2
password=$3
if [ ${#database} -eq 0 ]
then
echo "Usage: $0 <database> [username [password]]"
defaults write com.apple.Dock showhidden -bool YES
killall Dock

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

mysql> SET GLOBAL general_log = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'general%';
+------------------+---------------------------------+
| Variable_name | Value |
+------------------+---------------------------------+
| general_log | ON |
| general_log_file | /usr/log/mysql/mysql.log |
+------------------+---------------------------------+
def test(n)
if n <= 0
return [[]]
else
return test(n-1).map do |x| [true] + x end + test(n-1).map do |x| [false] + x end
end
end
Mostly because yacc does not allow it. It confuses
lambda { |foo = bar| puts foo }
as
lambda { |foo = (bar| puts foo) }
and causes syntax error.
# Does NOT work
define_method :method_name do |first_arg="default1", second_arg="default2"|
# ...
end
# Does NOT work
define_method :method_name do |first_arg="default1", second_arg="default2|
# ...
end
# Using optional arguments, with a default value for "two"
define_method :method_name do |required, *optional|
# one, two, = *optional
one, two, *ignored = *optional
# two will have a default value
two ||= "Default value"
# ...
end