Skip to content

Instantly share code, notes, and snippets.

@Lixivial
Lixivial / infobot.help
Created November 17, 2008 05:12
Preliminary Infobot qstat wrapper
qstat: Usage for '## <params>':
qstat: ----- __Aliasing__
qstat: -a - Add an alias
qstat: -c - Check an alias
qstat: -e - Edit an alias
qstat: -r - Remove an alias
qstat: ----- __Querying__
qstat: -h - List of hosts to report/query from.
qstat: -p - Player name to search for in output of -c or -h
qstat: -g - Game type to use to query.
@blinks
blinks / scanner.py
Created January 16, 2009 16:43
A simple Python token scanner.
"""
Scanner: match text to generate tokens.
Adam Blinkinsop <blinks@acm.org>
First, construct a scanner with the tokens you'd like to match described as
keyword arguments, using Python-syntax regular expressions.
WARNING: Group syntax in these expressions has an undefined effect.
>>> simple = Scan(ID=r'\w+')
@blinks
blinks / roll.py
Created January 16, 2009 16:43
A dice roller.
#!/usr/bin/env python
import logging
import random
import re
import sys
ROLL = re.compile(r'(\d*)d(\d+)')
def roll(dice):
"""Randomly generate the result of a dice roll.
@JakeWharton
JakeWharton / seven_seg.py
Created April 14, 2009 18:43
Python function to generate seven-segment number strings. Derived from Knio.
def seven_seg(x):
'''
_ _ _ _ _ _ _ _
|_||_| ||_ |_ |_| _| _| || |
_||_| ||_| _| | _||_ ||_|
1111101101 = 1005
1101110001 = 881
1101111100 = 892
@simonw
simonw / gist:104413
Created April 30, 2009 11:19
Turn a BeautifulSoup form in to a dict of fields and default values - useful for screen scraping forms and then resubmitting them
def extract_form_fields(self, soup):
"Turn a BeautifulSoup form in to a dict of fields and default values"
fields = {}
for input in soup.findAll('input'):
# ignore submit/image with no name attribute
if input['type'] in ('submit', 'image') and not input.has_key('name'):
continue
# single element nome/value fields
if input['type'] in ('text', 'hidden', 'password', 'submit', 'image'):
@sr
sr / Markdown in awk(1)
Created May 21, 2009 14:14
Markdown in awk(1)
#!/bin/awk -f
# md2html.awk
# by: Jesus Galan (yiyus) <yiyu.jgl@gmail>, May 2009
# Usage:
# md2html file.md > file.html
# Options: -v esc=false to not escape html
function newblock(nblock){
if(text)
@tycho
tycho / .bash_profile
Created May 31, 2009 07:15
my bashrc, used for setting up common paths and preferences I have
# /etc/skel/.bash_profile
# This file is sourced by bash for login shells. The following line
# runs your .bashrc and is recommended by the bash info pages.
[[ -f ~/.bashrc ]] && . ~/.bashrc
@Lixivial
Lixivial / README
Created June 7, 2009 12:30
a quick and dirty fallback downloader and load balancer
################
# INSTALLATION #
################
There should be no weird php.ini variables to set, so just move this to a server and set the appropriate permissions.
If you want to make it so a URL can be parsed as http://foo.bar/proxy/param1/param2/paramn, you can utilise a .htaccess
file to do this.
First, rename proxy.php to proxy and then put a .htaccess file in the same directory as proxy with the following information:
<Files proxy>
@zed9h
zed9h / 62kevin.pl
Last active May 12, 2022 22:15
six degrees to kevin bacon [and other queries] using dbpedia
#!/usr/bin/perl
use strict;
use warnings;
use Compress::Raw::Bzip2;
use Graph::Undirected;
use Storable;
use Term::ReadLine; # Term::ReadLine::Gnu
$|=1;
my $root = 'Kevin_Bacon'; # dbpedia resource name of an actor
@ssokolow
ssokolow / boilerplate.py
Last active January 8, 2022 17:43
Python boilerplate from which I start all my projects
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""[application description here]"""
__appname__ = "[application name here]"
__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__version__ = "0.0pre0"
__license__ = "GNU GPL 3.0 or later"
import logging