Skip to content

Instantly share code, notes, and snippets.

@relsqui
relsqui / buses.py
Last active October 11, 2015 04:28
Morning readiness script.
#!/usr/bin/python
from urllib2 import urlopen
from json import loads
from xml.dom.minidom import parseString
from datetime import datetime, timedelta
from math import floor
TRIMET_API_KEY = "" # redacted for privacy
@relsqui
relsqui / cookiecountant.py
Last active December 23, 2015 23:29
A cookie accountancy script for Cookie Clicker.
"""
C:\home\relsqui> ./cookiecountant.py --help
usage: cookiecountant.py [-h] [-q N] [-c N] [-b N] price
Tool for planning Cookie Clicker expenditures. Supply the current price of a
building you're interested in, and cookiecountant will give you the total cost
to build more of them. (You can specify cookie quantities/rates in millions,
billions, etc. if you like--as long as the input is consistent, the output
will match its magnitude.)
@relsqui
relsqui / examples.txt
Last active September 28, 2017 03:55
Older versions of the PSU out list don't have great spacing, so the identity labels and the academic fields sort of run together. The result is funny. Rather than standing in the QRC reading the out list and giggling, here's a script to generate them.
C:\home\relsqui\queermajors> ./pickmajor.py
polyamorous music
C:\home\relsqui\queermajors> ./pickmajor.py
androgynous spanish
C:\home\relsqui\queermajors> ./pickmajor.py
genderfluid pre-health
C:\home\relsqui\queermajors> ./pickmajor.py
intersex music composition
C:\home\relsqui\queermajors> ./pickmajor.py
gay chemistry
@relsqui
relsqui / add
Created November 23, 2013 13:21
One-instruction computer.
2 5 0
0 2
2 1
2 2
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
@relsqui
relsqui / kill_high_uids.sh
Created February 11, 2014 23:35
Kill processes with UID > 1024.
#!/bin/sh
MAX_PROTECTED_UID=1024
ps auxn | tail -n +2 | while read uid pid process; do
if [ "$uid" -gt "$MAX_PROTECTED_UID" ]; then
kill $pid
if ps $pid > /dev/null; then
kill -9 $pid
fi
@relsqui
relsqui / example.txt
Last active August 29, 2015 13:56
Generate random fake Portland housing listings.
relsqui@raven:~$ for i in `seq 10`; do ./generate_listing.py; done
2220|2725|2|northeast|good schools|nice view|vaults|
1120|2958|1|southeast|quiet neighborhood|non-smoking|two-car garage|
1445|1579|1|Clackamas|cats ok|close to parks|quiet neighborhood|
1070|1330|2|St. Helens|gated property|close to shopping|close to parks|
1300|2595|4|Lake Oswego|quiet neighborhood|close to shopping|pool|
1810|2119|4|Hillsboro|cats ok|close to campus|laundry on-site|
1080|857|4|north Portland|duplex|fireplace|close to campus|
1960|3952|1|Vancouver|cats ok|quiet neighborhood|pool|
1720|1499|0|southwest|laundry on-site|close to shopping|fireplace|
@relsqui
relsqui / rcsedit.sh
Created March 23, 2015 21:06
Check a file out of RCS, edit it, check it back in.
#!/bin/bash
if [ "$1" == "-h" -o "$1" == "--help" ]; then
echo "Usage: rcsedit (filename|-h|--help)"
echo
echo "Checks a file out of RCS, opens it in your \$EDITOR, and checks it back in if the editor exits successfully." | fmt -$COLUMNS
exit 0
fi
> iter = Utils::iterate((string[]) {"foo", "bar", "baz"});
> string a;
> while (iter(&a)) {
+ printf("%s\n", a);
+ }
foo
bar
baz
@relsqui
relsqui / mininog.py
Last active December 18, 2015 04:28
AoC Day 17, Mini Version
import sys,itertools as i
s=map(int,sys.stdin)
r=1
while r:
c=sum(sum(d)==150for d in i.combinations(s,r));r+=1
if c:r=0;print c