Skip to content

Instantly share code, notes, and snippets.

View Cairnarvon's full-sized avatar

Koen Crolla Cairnarvon

View GitHub Profile
@Cairnarvon
Cairnarvon / hash.py
Created July 5, 2012 23:48
A possibly gooder interface for hashes.
>>> from hash import Tripcode
>>> a, b = Tripcode('WokonZwxw2'), Tripcode.create('tea')
>>> a
Tripcode('WokonZwxw2')
>>> b
Tripcode.create('tea')
>>> print a, b
WokonZwxw2 WokonZwxw2
>>> a == b
True
@Cairnarvon
Cairnarvon / formspring_markov.py
Created July 1, 2012 02:23
Tired of answering Formspring questions? Let Andrey Markov do it for you.
#!/usr/bin/python
import collections
import random
import sqlite3
import sys
try:
from nltk.tokenize import sent_tokenize
except ImportError:
@Cairnarvon
Cairnarvon / duri.rb
Created May 8, 2012 00:20
Data URI scheme encoder
#!/usr/bin/ruby -w
require 'optparse'
require 'base64'
options = {}
optparse = OptionParser.new do |opts|
opts.banner = "Usage: #$0 [options] FILE"
options[:type] = nil
@Cairnarvon
Cairnarvon / progfs.py
Created April 17, 2012 12:34
The original point of progscrape was to back an interface like this one.
#!/usr/bin/python
import argparse
import errno
import json
import os
import re
import stat
import sys
import time
@Cairnarvon
Cairnarvon / chaos.c
Created October 25, 2011 22:41
What ho, chaos game.
/* gcc -Wall -Wextra `allegro-config --libs` -lm w.c */
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <allegro.h>
#define POINTS 3
#define WIDTH 600
@Cairnarvon
Cairnarvon / flashsave.sh
Created June 12, 2011 18:40
Browser extensions suck.
#!/bin/bash
# Open a Youtube or other video in your browser, wait for it to load, leave the
# browser window open. Run script. Profit.
# May not work with Gnash &c.
lsof -u $(whoami) | grep Flash | awk '{sub(/[^0-9]+/, "", $4)
sub(/\/tmp\//, "", $9)
print "/proc/"$2"/fd/"$4, $9".flv"}' | xargs -rn 2 cp -n
@Cairnarvon
Cairnarvon / nottineye.py
Created June 4, 2011 14:25
Tineye-style image search, locally. Everyone's a winner. (Requires PIL. --help for usage.)
#!/usr/bin/python
import glob
import math
import os
import getopt
import sys
from PIL import Image
@Cairnarvon
Cairnarvon / tripfind.c
Created May 26, 2011 21:20
Distributed tripcode finder using Open MPI.
/* mpicc -lssl -o tripfind tripfind.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <regex.h>
#include <signal.h>
#include <sys/time.h>
#include <openssl/des.h>
@Cairnarvon
Cairnarvon / tineye.sh
Created May 10, 2011 20:28
Tineye bash script. Usage: ./tineye.sh image1.jpg [image2.jpg...]
#!/bin/bash
for f; do
if [ -f "$f" ]; then
TINURL=$(curl -s -F "image=@$f" http://www.tineye.com/search |
grep -E -o 'http://www.tineye.com/search/[0-9a-f]+/' |
head -n 1)
if [ -z "$TINURL" ]; then
echo "You have reached your daily search limit or something." >&2
else
@Cairnarvon
Cairnarvon / mandel.tcl
Created October 31, 2010 08:38
Trying to decide if Tcl is worth learning.
#!/usr/bin/tclsh
set rows 40
set cols 80
if {$argc == 2} {
set rows [lindex $argv 0]
set cols [lindex $argv 1]
} elseif {$argc != 0} {
puts "Invalid arguments! Need two (rows, cols) or none."