Skip to content

Instantly share code, notes, and snippets.

View redacted's full-sized avatar

Steven Tobin redacted

  • Ireland
View GitHub Profile
@redacted
redacted / gnuplot_folder.py
Created March 5, 2012 14:58
Create .pngs from every valid file in a folder. run with -h for config
#!/usr/bin/env python
# encoding: utf-8
import os
import shlex
import subprocess
import optparse
GNP_TEMPLATE="""
set term png size 800,600
@redacted
redacted / TCP.py
Created November 29, 2011 15:04
Tuesday's child problem
import random, time, collections, pprint
sample = collections.defaultdict(float)
now = time.time()
known_child = ('M', 2)
while sum(sample.values()) < 100000:
genders = [random.choice('MF') for dummy in '..']
http://www.elara.ie/productdetail.aspx?productcode=ECE1270099
http://www.dabs.ie/products/hp-laserjet-blk-toner-6-500pgs-4932.html?q=q7551A&src=3
@redacted
redacted / siesta
Created October 28, 2011 12:44 — forked from cathcart/siesta
siesta module
import subprocess
import os
import shutil
import glob
def list_variables():
return [line.split() for line in open("VARS")]
def new_input_file(parameters, var_names, file_name):
if len(parameters) != len(var_names):
import subprocess
from multiprocessing import Pool
import shlex
## Drive spheremodel automagically!
def do(string, desc=""):
""" execute a string as a shell call """
if len(desc) > 0: print(desc)
def floyd(f, x0):
# The main phase of the algorithm, finding a repetition x_mu = x_2mu
# The hare moves twice as quickly as the tortoise
tortoise = f(x0) # f(x0) is the element/node next to x0.
hare = f(f(x0))
while tortoise != hare:
tortoise = f(tortoise)
hare = f(f(hare))
# at this point the start of the loop is equi-distant from current tortoise
@redacted
redacted / README.mkd
Created October 4, 2011 16:15
Generate and email SLURM report

Generate and email report on SLURM jobs that exist in database.

Bonus tip: ssh cluster "python slurm_report.py" - no need to log in!

All credit to cathcart

import scipy.integrate as i
import scipy as s
print i.quad(lambda x:s.exp(-2*i.quad(lambda y:(1-s.exp(-y))/y,0,x)[0]),0,s.inf)[0]
@redacted
redacted / cmd2png
Created September 22, 2011 13:51
Command line screenshots. e.g. cmd2png "ls -ll" "ls.png"
#!/bin/sh
$1 | convert -background black -fill white \
-font Monaco-Regular -pointsize 13 \
-border 10 -bordercolor black \
label:@- $2
@redacted
redacted / Simplex.py
Created August 30, 2011 16:42
Simplex algorithm in Python (c) 2001 Vivake Gupta, retrieved from archive.org
#!/usr/bin/env python
#
# Copyright (c) 2001 Vivake Gupta (vivakeATomniscia.org). All rights reserved.
#
# 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 the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,