Skip to content

Instantly share code, notes, and snippets.

@dellsystem
dellsystem / something.py
Created June 10, 2011 21:44
HOCR stuff
#!/usr/bin/env python
import os
import glob
"""
Put this in the same directory as the images (????.png)
"""
images = glob.glob('*.png')
@dellsystem
dellsystem / committeeslol
Created May 13, 2011 22:49
Input lists for SSUNS
Royal Dutch Shell Board of Directors
Charles de Gaulle's Cabinet
Peace of Solferino
New York Times Editorial Board
Indian Cabinet of Ministers
Shakespeare's Julius Caesar
Allende's Cabinet: 1973 Chilean coup d'etat
Her Majesty's Royal Secret Service:MI-6
Joint Crisis Committee: Somali Civil War
Joint Crisis Committee: Somali Civil War (Rebels)
@dellsystem
dellsystem / gist:969077
Created May 12, 2011 17:58
VIPS tile processing

Look at the largest dimension (width or height)

  • 1 zoom level: 1 to 256
  • 2 zoom levels: 257 to 513
  • 3 zoom levels: 514 to 1027
  • 4 zoom levels: 1028 to 2055
  • 5 zoom levels: 2056 to 4111
  • 6 zoom levels: 4112 to 8223
  • ...
  • n zoom levels: (2^(n-2)) * (256 + 1) to (2^(n-1) * (256 + 1)) - 1 (except when n = 1, in which case the lower bound is just 1)
@dellsystem
dellsystem / process.py
Created May 12, 2011 16:56
Converting and resizing images (pyramidal tiff)
#!/usr/bin/env python
import sys, os
from PIL import Image
import math
# Does all the image processing
# Just give it a directory of images in .tif/.tiff format that are not processed
# It will find the lowest max zoom, and resize all larger images to that zoom level
# Then it will convert all the images to pyramidal tiff format, and put them into a subdirectory
# Then it will copy everything from that subdirectory to /mnt/images/dir
@dellsystem
dellsystem / HuffmanTree.java
Created April 14, 2011 01:21
fillInFrequencies method
// Private, for the public constructor taking the string
private void fillInFrequencies(String str) {
// First convert the string to an array of char
char[] charArray = str.toCharArray();
// Initialise the charcode array
charCode = new CharCode[65536]; //2^16
// For-each loop to iterate over every character in the array
for (char c : charArray) {
@dellsystem
dellsystem / tile
Created April 6, 2011 17:48
converting tifs to pyramidal tiffs
#!/usr/bin/env bash
# A bash script for converting all the files in a directory to pyramidal tiff
# Pass the directory the images are stored in as an argument
# But it will put the images in the current directory ... to be fixed
if [ $# -lt 3 ]; then
echo 'Usage: tile <directory> <extension> <desired_prefix>'
else
echo 'Looking for all files in directory: $1/'
@dellsystem
dellsystem / cipher.c
Created March 18, 2011 23:44
comp206 ass3 q1
#ifndef IN_CIPHER
#define IN_CIPHER
#ifndef INCLUDE_STANDARDS
#define INCLUDE_STANDARDS
#include <stdio.h>
#include <stdlib.h>
#endif