Skip to content

Instantly share code, notes, and snippets.

View redacted's full-sized avatar

Steven Tobin redacted

  • Ireland
View GitHub Profile
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 / 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

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
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)
@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):
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 / 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 '..']
@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 / sc2_scrape.py
Created April 5, 2012 15:27
Checks balance of StarCraft 2 races based on sc2-replays.net results
import urllib2
from collections import defaultdict, namedtuple
import BeautifulSoup
import sys
import time
import socket
Factions = ["protoss", "zerg", "terran"]
@redacted
redacted / itunes100randomyoutube.py
Created May 4, 2012 10:16
Opens a song from the iTunes Top 100 in youtube (chosen at random)
'''
1) Gets top 100 songs from iTunes chart
2) Plays a random song from this list in YouTube
license: public domain
Dependancies:
1) BeautifulSoup http://www.crummy.com/software/BeautifulSoup/
'''
from urllib2 import urlopen