Skip to content

Instantly share code, notes, and snippets.

View ghl3's full-sized avatar

George Lewis ghl3

View GitHub Profile
@ghl3
ghl3 / wiki_downloader.py
Last active May 1, 2023 16:36
Using python threading to download random wikipedia articles.
import time
import urllib2
import threading
from Queue import Queue
from random import choice
def get_random_article(namespace=None):
""" Download a random wikipiedia article"""
try:
@ghl3
ghl3 / Makefile
Created November 29, 2012 14:26
Makefile for python unittest
RUNTEST=python -m unittest -v -b
ALLMODULES=$(patsubst %.py, %, $(wildcard test_*.py))
all:
${RUNTEST} ${ALLMODULES}
% : test_%.py
${RUNTEST} test_$@
@ghl3
ghl3 / Makefile
Created October 29, 2012 17:47
Compile CERN ROOT script using g++
CXX=`root-config --cxx`
CXXFLAGS=`root-config --cflags`
LDFLAGS=`root-config --ldflags`
LDLIBS=`root-config --glibs`
ROOTLIBS='-lRooFit -lHtml -lMinuit -lRooFitCore -lRooStats -lHistFactory'
# Assumes that the script is in MyScript.C
# and it must contain a main() function
@ghl3
ghl3 / gist:3005396
Created June 27, 2012 17:00
Directory of a bash script being run
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@ghl3
ghl3 / gist:2924685
Created June 13, 2012 15:14
Custom Runtime Exception
#include <stdexcept>
class my_custom_exception : public std::runtime_error {
public:
my_custom_exception(const std::string& msg):std::runtime_error(msg){};
};
@ghl3
ghl3 / DoctagsAsDescription
Created April 26, 2012 19:15
Using the main function's doctags as the optparse description
import optparse
desc = " ".join(main.__doc__.split())
vers = "1.0"
parser = optparse.OptionParser( description = desc, version = vers, usage = "%prog [options]" )