Skip to content

Instantly share code, notes, and snippets.


Noah Petherbridge kirsle

View GitHub Profile
# requires: libX11-devel, libXt-devel, libXtst-devel, /usr/bin/xinput
# sudo cpanm X11::GUITest
use threads;
use IO::Pty::Easy;
use IO::Handle;
use X11::GUITest qw(ClickMouseButton :CONST);
View Python in vs
import benchmark
class DictBenchmark(benchmark.Benchmark):
each = 5000
def setUp(self): = dict()
for i in range(0, 10000):["key_{}".format(i)] = "value {}".format(i)
kirsle /
Created Jul 18, 2014
AttrDict - A dict for Python that behaves like JavaScript.
#!/usr/bin/env python
"""A dict-like object that supports JS object syntax.
AttrDict is a dict that can be called using either square brackets, like a
normal dict, or by using attributes--just like in JavaScript.
Accessing the value for an undefined key will return None (Python's equivalent
to undefined).
kirsle /
Created Sep 22, 2014
Python decorator order

What order does Python execute decorators in? It seems like this changed sometime between when they were first introduced (2.4) and now (2.7).

Given the code:

def myfunc():
kirsle / iterative
Created Nov 30, 2014
Experiments for upgrading RiveScript's tag processing algorithm, to support nested tags such as <set oldname=<get name>> which previously didn't work, as I was doing a simple find/replace one tag-type at a time and <set> always came before <get>.
View iterative
#!/usr/bin/env python
"""Experiments to upgrade RiveScript's tag processing algorithm."""
from collections import deque
import re
import random
tests = [
"<set oldname=<get name>>I thought your name was <get oldname>?",
kirsle /
Created Dec 11, 2014
A test for Redis-based file locking when rapidly updating a JSON document (doesn't work)
#!/usr/bin/env python
"""Script to stress test rapid JSON DB writes.
1. When reading from disk, flock(LOCK_SH) is used on the file handle.
2. When writing to disk:
a. A lock is acquired in a Redis instance as added protection
b. File is locked with LOCK_EX during the write
c. After the file is written (while still Redis-locked), it attempts to read
the file again immediately (LOCK_SH) to verify that it wrote successfully
kirsle /
Created Dec 19, 2014
Just a dead simple "password cracker" that will brute force your plain lowercased passwords (letters only, no numbers or capitals).
# Simple password cracker. Tries every combination of plain lowercased
# passwords, from "a", "b", ..., "z", "aa", "ab", ... "az", "ba", "bb" ...
use 5.18.0;
use Time::HiRes qw(time);
use Digest::MD5 qw(md5_hex);
my $victim = $ARGV[0];
kirsle /
Created Dec 21, 2014
GTK Config for the panel text color on the XFCE Desktop

Save this code as ~/.gtkrc-2.0 and restart your XFCE panel with xfce4-panel -r

This file will set your panel text color to white (overriding the color setting from your current GTK theme). Change the #FFFFFF to another color if you want another color.

The engine "murrine" part will remove the text style for Murrine based themes (for example, a drop-shadow effect used in the Ubuntu Ambiance theme and Greybird).

style "panel"
    fg[NORMAL] = "#FFFFFF"
kirsle / tcp-server.diff
Created Feb 22, 2015
RiveScript Node TCP Server with Logging
View tcp-server.diff
diff --git a/node/tcp-server.js b/node/tcp-server.js
index 22b383f..08e9c02 100644
--- a/node/tcp-server.js
+++ b/node/tcp-server.js
@@ -4,6 +4,7 @@
// Run this and then telnet to localhost:2001 and chat with the bot!
+var fs = require("fs");
var net = require("net");
#!/usr/bin/env python
class WorkerBase(object):
def __init__(self, *args, **kwargs):
print "WorkerBase init"
class DBWorker(WorkerBase):
def __init__(self, *args, **kwargs):
print "DBWorker init"
You can’t perform that action at this time.