This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from Tkinter import * | |
import colorsys | |
import optparse | |
import random | |
""" | |
Use genetic algorithms to create graphical rainbows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have a table of accounts and a table of transactions. There's a | |
one-to-many relationship between accounts and transactions; | |
transactions.account_id is a foreign key into accounts. For all | |
accounts where < 50% of transactions are authorized, I want to | |
get the account id and that percentage: | |
SELECT a.id, SUM(t.authorized=1)/COUNT(*) AS percentage | |
FROM accounts a, transaction_info t | |
WHERE a.id=t.account_id | |
GROUP BY a.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# date field is of type 'date' | |
mysql> SELECT YEAR(date) AS year, MONTH(date) AS month, count(*) AS count FROM my_table GROUP BY year, month ORDER BY year, month; | |
+------+-------+-------+ | |
| year | month | count | | |
+------+-------+-------+ | |
| 2008 | 6 | 1 | | |
| 2009 | 3 | 1 | | |
| 2009 | 5 | 2 | | |
| 2009 | 6 | 1 | | |
| 2009 | 7 | 1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DIY bandwidth summaries | |
1. ifconfig | |
ifconfig -a will give you transmitted and received bytes by interface since last boot. | |
Gets its info from /proc/net/dev | |
2. iptables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# alphanumeric | |
</dev/urandom tr -dc [:alnum:] | head -c10 | |
# all printable characters, excluding whitespace | |
</dev/urandom tr -dc [:graph:] | head -c10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export colorvar=31; export PROMPT_COMMAND='export PS1="\e[""$colorvar"";40m\w> "; colorvar=$(((colorvar + 1) % 7 + 31));' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import pycurl | |
import re | |
import urlparse | |
from StringIO import StringIO | |
from Growl import GrowlNotifier | |
""" | |
Check ticket trackers for new tickets and generate notifications for them |
NewerOlder