Skip to content

Instantly share code, notes, and snippets.

View siwells's full-sized avatar

Simon Wells siwells

View GitHub Profile
@siwells
siwells / moving.line.py
Created August 20, 2012 16:19
PyGame Moving line Animation
#! /usr/bin/env python
import pygame
y = 0
dir = 1
running = 1
width = 800
height = 600
screen = pygame.display.set_mode((width, height))
@siwells
siwells / omero_homebrew.sh
Created February 20, 2012 11:39 — forked from joshmoore/README.md
Bootstrap script for creating and installing OMERO via Homebrew.
#!/bin/bash
set -e
set -u
DIR=$1
shift
OMERO_GIT=${OMERO_URL:-git://github.com/joshmoore/homebrew.git}
OMERO_URL=${OMERO_URL:-https://github.com/joshmoore/homebrew/tarball/omero}
@siwells
siwells / gist:1723895
Created February 2, 2012 15:09
Pipeline to inspect octal permissions of a file in a cross-platform (GNU & BSD Userland) fashion
ls -l $file | awk '{ print $1 }' | colrm 1 1 | sed -e 's/@$//' | sed -e 's/--x/1/g' -e 's/-w-/2/g' -e 's/-wx/3/g' -e 's/r--/4/g' -e 's/r-x/5/g' -e 's/rw-/6/g' -e 's/rwx/7/g' -e 's/---/0/g'
@siwells
siwells / jqplot_test001.html
Created December 16, 2011 15:19
Using the JQPlot API to draw a simple line chart
<html>
<head>
<title>Line Chart Test</title>
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
<script language="javascript" type="text/javascript" src="plugins/jqplot.barRenderer.min.js"></script>
<script language="javascript" type="text/javascript" src="plugins/jqplot.dateAxisRenderer.min.js"></script>
<script language="javascript" type="text/javascript" src="plugins/jqplot.canvasTextRenderer.min.js"></script>
@siwells
siwells / delof.sh
Created December 7, 2011 15:22
OMERO: Delete OriginalFiles Script
#!/bin/bash
OriginalFileName="TypeA"
RAWFILE="/tmp/$(basename $0).$$.raw.tmp"
PREPFILE="/tmp/$(basename $0).$$.prep.tmp"
LOGFILE="$(basename $0).$$.log"
# Retrieve data
omero hql -q --limit=1000 "select name, id from OriginalFile where name = '$OriginalFileName'" > $RAWFILE
@siwells
siwells / rot13.py
Created October 31, 2011 16:57
A little python rot13 coder
#!/usr/bin/python
from string import maketrans
rot13trans = maketrans('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 'NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm')
def rot13(text):
return text.translate(rot13trans)
def main():
@siwells
siwells / generator.py
Created October 13, 2011 16:11
Begginnings of a data generation suite for OMERO/HIC datasets & schemas
from xml.sax.saxutils import XMLGenerator
from xml.sax.xmlreader import AttributesNSImpl
import hashlib
class SchemaGen:
def __init__(self, output, encoding, projectID, initial_prochi):
"""
"""
anonschema = XMLGenerator(output, encoding)
@siwells
siwells / bimap.py
Created October 11, 2011 16:14
Playing with bimapped dictionaries in Python
class Bimap(dict):
# def alias(self,obj):
def lkey(self, obj):
return self[obj]
def rkey(self, obj):
for key,val in self.iteritems():
if val is obj:
@siwells
siwells / Tkinter_hello_world.py
Created October 10, 2011 15:38
A Python GUI "Hello World" using Tkinter
from Tkinter import *
root = Tk()
w = Label(root, text="Hello World")
w.pack()
root.mainloop()
@siwells
siwells / server.js
Created October 3, 2011 14:00
Playing with node.js :: A "Hello World" node
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');