Skip to content

Instantly share code, notes, and snippets.

@coderjo
coderjo / parseit.py
Created November 6, 2011 09:58
simple scientific american pdf url builder
#!/usr/bin/env python
from HTMLParser import HTMLParser
import urllib2, re
pdfre = re.compile(r"^pdf/1[89][0-9][0-9]-[0-9]{2}-[0-9]{2}\.pdf$")
journalpage = re.compile(r"^/scientificamerican/journal/v([1-9]|[1-9][0-9]|10[01])/")
class SAParser(HTMLParser):
def __init__(self, linkcallback):
@coderjo
coderjo / gist:1432614
Created December 5, 2011 06:53
python win32 file api workarounds
def stathax(path):
if "Windows" == platform.system():
return os.stat(u'\\\\?\\%s' % path)
else:
return os.stat(path)
def openhax(path, mode):
if "Windows" == platform.system():
return open(u'\\\\?\\%s' % path, mode)
else:
@coderjo
coderjo / sqlite_integrity_check.py
Created December 6, 2011 17:40
whitemice's sql integrity check
#!/usr/bin/env python
import sqlite3, sys, fnmatch, os, platform
def verify_database_file(path):
connection = None
sys.stdout.write('Checking database @ "{0}".\n'.format(path))
try:
connection = sqlite3.connect(path, isolation_level="EXCLUSIVE")
except Exception, e:
sys.stderr.write('Unable to connect to database.\n')
@coderjo
coderjo / ustream.py
Created December 12, 2011 20:33
simple script to build the proper rtmpdump command line for a live ustream feed
#!/usr/bin/env python
flashVer = "WIN 10,3,183,7"
from HTMLParser import HTMLParser
from pyamf.remoting.client import RemotingService
import urllib2, sys
from time import time
# first we need to define a very basic html parser to get two meta properties
@coderjo
coderjo / gist:2255976
Created March 30, 2012 22:05
2xSDS drive info
=======================
1.4Mb 2xSDS
Y-E Data 6130S or 6331S
=======================
600 RPM (Normal) 720 RPM *
------------------- -------------
ET '' ET ''
PC '' PC ''
IT '' IT ''
@coderjo
coderjo / ps.txt
Created November 24, 2013 03:13
Evidence that the current official debian wheezy 7.2 ec2 images run the user-data script twice, and from where.
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
1 1518 1518 1518 ? -1 Ss 0 0:00 /bin/sh /etc/init.d/rc 2
1518 1527 1518 1518 ? -1 SL 0 0:00 \_ startpar -p 4 -t 20 -T 3 -M start -P N -R 2
1527 1593 1593 1518 ? -1 S 0 0:00 \_ /bin/bash /etc/init.d/ec2-run-user-data start
1593 1603 1593 1518 ? -1 S 0 0:00 \_ /bin/sh /tmp/ec2agEOii.user-data
1603 1607 1593 1518 ? -1 R 0 0:00 | \_ ps axjfww
1593 1604 1593 1518 ? -1 S 0 0:00 \_ logger -t user-data
PPID PID PGID SID TTY TPGID STAT UID TIME COMMAND
1 1518 1518 1518 ? -1 Ss 0 0:00 /bin/sh /etc/init.d/rc 2
@coderjo
coderjo / README
Last active December 29, 2015 12:29
ArchiveTeam project worker EC2 user-data script.
This is a user-data script for starting up ec2 instances to run an ArchiveTeam project downloader.
steps:
1. save the file to your drive.
2. change where it says YOURNICKHERE to the name you want to show up on the tracker.
3. pick the 32-bit Debian Wheezy 7.2 AMI for the region you plan to use.
4. put the ENTIRE contents of your file as the user-data field.
- If you are using the command-line ec2 tools, you can say --user-data-file YOURFILENAME
- If you are using the web console, on page 3 ("Configure Instance"), expand the "Advanced Details" section and either paste the contents into the "user data" box, or pick "as file" then click browse to select your file.
5. finish setting up your instance. Don't forget to configure a security group to allow you SSH access.
@coderjo
coderjo / attach_cow_image.sh
Last active April 7, 2024 02:48
access a disk image read-only with a copy-on-write overlay to allow fsck or the like to write changes
#!/bin/bash
# usage: attach_cow_image.sh [imagefile] [cowfile] [devname]
# imagefile: path to the image file you want to load
# cowfile: path to the file to store writes into. If it doesn't exist, a sparse 1GB file will be created.
# devname: the name you want the drive to show up as in /dev/mapper
imgfile="$1"
cowfile="$2"
dmname="$3"
@coderjo
coderjo / colorcmds.py
Last active October 31, 2017 17:07
Python script to encode TASBot pixelart script
#!/usr/bin/env python
import argparse
import sys
from PIL import Image
def loadimage(result):
# assuming pixel values are 0..255.. perhaps I should use the image's getextrema func...
for y in xrange(0, result.height):
@coderjo
coderjo / DDR20th.txt
Created September 26, 2018 15:46
Long post about DDR 20th anniversary
It's the 20th anniversary of Dance Dance Revolution. DDR has changed my life quite a bit:
Back in 2000-2001, on the AMV editors mailing list, I saw mention of this crazy little project. They were taking the DDR 3rd mix non-stop mix CD from the soundtrack and divided it up among a number of different editors, one per song. They would edit the song, with some leader and trailer of adjacent songs. These separate videos would then be edited together into one long, 60 to 74 minute video. (I'd never heard of DDR before this project)
This video was to premiere at Anime Weekend Atlanta in 2001. It sounded so awesome, I had to check it out. So I made hotel reservations and booked flights, attending my first convention EVER, all by myself.
I wound up meeting some of the other editors. I also wound up helping out, first by running interference for Quu so he could finish editing it together, but also holding down the fort in the VAT overnight Saturday.
I made friends and caught the volunteering bug. I've volunteered