Skip to content

Instantly share code, notes, and snippets.

View samueljackson92's full-sized avatar

Samuel Jackson samueljackson92

  • UKAEA
  • Wallingford, Oxfordshire, UK
View GitHub Profile
@samueljackson92
samueljackson92 / sierpinskicarpet.pl
Created November 12, 2012 17:39
Generating a sierpinski carpet with a perl script
#!/usr/bin/perl
use strict;
use warnings;
my @carpet;
my $total;
carpet(2);
foreach my $row(@carpet){
@samueljackson92
samueljackson92 / concatdir.pl
Created November 12, 2012 17:43
Perl script to concat directories full of text files.
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use File::Find::Rule;
#Perl script for combining sub directories of text files
GetOptions('recursive' => \my $isRecursive,
#!/usr/bin/env python
from json import load
from urllib2 import urlopen, URLError
from argparse import ArgumentParser
def printError(e):
print "Error connecting to API: "
print "\t", e
def getLinks():
@samueljackson92
samueljackson92 / simple_graph.py
Created February 4, 2013 17:46
A python script that defines a simple graph data structure.
################################################
# Simple Graph
# Author: Samuel Jackson
# Created: 28/1/13
################################################
class Node:
def __init__(self, data):
self.adjacents = []
self.set_data(data)
@samueljackson92
samueljackson92 / fuzzy.py
Created February 11, 2013 16:25
Fuzzy set logic tipping system python code.
#!/usr/bin/env python
#####################################################
#Fuzzy logic implementation of simple tipping system
#Author: Samuel Jackson ([email protected])
#Date: 10/2/13
#####################################################
#################################
# Functions for calculating #
@samueljackson92
samueljackson92 / image.tex
Created February 19, 2013 23:17
LaTeX code for importing, formatting, centring, captioning and labelling an image. Will force images to follow after each other and stay in the same section. Compliments of @cgddrd
% Include the required packages.
\usepackage{float}
\usepackage{graphicx}
% insert a single centred image into a LaTeX document.
\begin{figure}[H]
\centering
\includegraphics[width=0.7\textwidth]{<path-to-file>}
\caption{<image-caption>}
\label{fig:<image label>}
@samueljackson92
samueljackson92 / JSONExample.js
Created March 12, 2013 14:36
JSON object notion example for Connor
var ar = {
"Hello": {
score: 12,
run: function()
{
return "hi";
}
}
};
@samueljackson92
samueljackson92 / delta.cpp
Created March 21, 2013 17:53
C/C++ code for calculating delta time. Output in seconds.
timeval t1, t2;
double elapsedTime;
//start timer
gettimeofday(&t1, NULL);
//do stuff...
//stop timer
gettimeofday(&t2, NULL);
@samueljackson92
samueljackson92 / priority.java
Last active December 15, 2015 14:28
Weight priority selection.
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
new Main().calcSlot(7);
}
public int calcSlot(int priority) {
//list of jobs
@samueljackson92
samueljackson92 / stuff.tex
Created April 22, 2013 12:45
ACM Proceeding template
\documentclass{acm_proc_article-sp}
\usepackage{graphicx}
\usepackage{epstopdf}
\begin{document}
\title{A Comparison of Scheduling Algorithms}
\numberofauthors{1}
\author{
\alignauthor