Skip to content

Instantly share code, notes, and snippets.

@stt
stt / pidgin-chatbot.pl
Created May 27, 2011 09:37
Chatbot plugin for Pidgin instant messaging client
#
# Chatbot integration plugin for Pidgin
# (c)2011, <samuli@tuomola.net>
#
# INSTALL:
# 1. Get Net::AIML, e.g. sudo cpan App::cpanminus; sudo cpanm Net::AIML
# 2. Copy the script in your ~/.purple/plugins/ directory
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@stt
stt / amtfix.py
Created July 20, 2011 12:43
Dosbox cheating support
import sys, sqlite3
if len(sys.argv) < 2:
print 'Syntax: %s gameid' % sys.argv[0]
exit()
gameid = sys.argv[1]
con = sqlite3.connect('test.db')
c = con.cursor()
sql = 'select name,addr from fields where gameid=?'
@stt
stt / sqlaus.jison
Created October 18, 2011 21:15
Jison rules for turning boolean expressions into SQL clauses
/*
* Jison rules for parsing simple boolean expressions
* (c)2011, <samuli@tuomola.net>
*
* Usage: npm install jison && jison sqlaus.jison && node test-sqlaus.js
*
* Meant primarily for generating SQL clauses for m:m table structure.
*
* Depends on shared scope to provide..
* functions:
@stt
stt / .bashrc.dircrawl
Created December 2, 2011 18:14
Collection of linux commandline customizations (helloware, leave a comment if you find any of it useful)
# Renounce thy manual directory crawling and embrace the key shortcuts
cd() {
#set -x # uncomment to debug
local D="${*-~}" MAX=$(( ${#DIRSTACK[@]}-1 )) POS=
D=${D/#~/$HOME}
[ "$D" == "-" ] && D=+1
# if given a shift parameter, verify dir still exists
if is_numeric "$D"; then
@stt
stt / svnxml2html.py
Created December 22, 2011 13:51
Generate an HTML table of the most recent changes in a set of SVN projects
#!/usr/bin/env python
"""
A short example of a web.py page that triggers a refresh of
the SVN log html fragment periodically when the page is visited.
To configure WSGI for apache do something like this..
<IfModule mod_wsgi.c>
# http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives
# default: processes=1 threads=15
WSGIDaemonProcess ci user=tomcat
@stt
stt / 0001-Warn-if-export-extension-is-supported-by-multiple-wr.patch
Created March 16, 2012 18:05
0001-Warn-if-export-extension-is-supported-by-multiple-wr.patch
From 646ed51cc5e2de3feb79f22d6b832b47a92ac433 Mon Sep 17 00:00:00 2001
From: Samuli Tuomola <samuli.tuomola@gmail.com>
Date: Fri, 16 Mar 2012 21:27:02 +0200
Subject: [PATCH] Warn if export extension is supported by multiple writers.
Also, skip plugins that don't report any name filters.
---
src/tiled/mainwindow.cpp | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
@stt
stt / FormController.cls
Created July 24, 2012 11:08
Salesforce.com: How to bind multipicklist into checkboxes dynamically
/**
* NOTE: requires customization, likely not working as-is.
*/
public class FormController {
public Account_detail__c detail {get;set;} // DIY
public List<String> detailFields {get;set;}
public Map<String,String> detailTypes {get;set;}
public Map<String,String> detailListAsJSON {get;set;}
public FormController(ApexPages.StandardController controller) {
@stt
stt / govanilla.py
Last active August 29, 2015 13:56
Revert Skyrim installation back to vanilla
# Revert Skyrim installation back to vanilla
# 2014, <samuli@tuomola.net>
import os
from datetime import datetime
def mkbackupdir(prefix='../skyrim-backup-'):
dn = os.path.abspath(prefix + datetime.strftime(datetime.now(), '%Y%m%d-%H%M%S'))
os.mkdir(dn)
return dn
@stt
stt / gist:743e954296d2b9f52c70
Last active August 29, 2015 14:00
Bookmarklet for easier imageboard browsing
javascript:if(typeof(_4ac)!=='undefined') _4ac.remove();
_4ac=(function() {
var links = [].slice.call(document.querySelectorAll('.file'));
var cur_link = -1;
var expand = true;
function isNext(e) { return e.keyCode == 188 || e.keyCode == 192; };
function isPrev(e) { return e.keyCode == 190 || (e.keyCode == 192 && e.shiftKey); };
function handleKey(e){
if(isPrev(e) || isNext(e)) {
open(cur_link + (isPrev(e)?-1:1));
@stt
stt / openimgs
Last active August 29, 2015 14:03
bash function where you pipe in a list of image filenames and it open them up in a webbrowser
# put it in .bash_aliases
# generates html from stdin, takes size of batch as argument
function openimgs {
MAX=${1:-6}
TMPL=~/openimgs-template.html
OUTF="openimgs-$$.html"
local IFS=$'\n'
BUF=($(cat -))
local IFS=$' \n'