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 / R_scatter
Last active August 29, 2015 14:16
Scatterplot example in R
args <- commandArgs(trailingOnly = TRUE)
file_name <- args[1]
library('ggplot2')
data_df <- read.csv(file_name, header=TRUE)
plot <- ggplot(data_df, aes(x=X0, y=X1)) + geom_point(aes(color=class))
# Remove ticks marks from plot
plot + scale_y_discrete(breaks=NULL) + scale_x_discrete(breaks=NULL)
@samueljackson92
samueljackson92 / arduino_code.ino
Created September 18, 2014 10:38
Arduino serial communication
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
const int sensorPin = A0;
const int messageBufferSize = 17;
char messageBuffer[17];
void read_serial()
{
char inputChar = -1;
import time
import notify2
from abc import ABCMeta
from jenkinsapi.jenkins import Jenkins
class JenkinsPoller():
__metaclass__ = ABCMeta
@samueljackson92
samueljackson92 / const.cpp
Created April 29, 2014 08:38
Constants in C++
const int* p; // the thing pointed to is const, you can change the value of p
int const *q; // same as p
int * const r; // the pointer is const, but the thing pointed to can change value
int const * const s; // the pointer is const and the thing pointed to is const
@samueljackson92
samueljackson92 / sequence_compress.py
Created March 28, 2014 10:49
Script to compress linear sequences of numbers as a strings with repeating sections taking the form: start:width:stop
import numpy as np
def findSequence(x, delta_x, start=0):
string = ""
if len(x) == 1: return str(x[0]) + ','
if len(x) == 2: return str(x[0]) + ',' + str(x[1]) + ','
while (start<delta_x.size-1):
end = start+1
@samueljackson92
samueljackson92 / timed.py
Created January 6, 2014 14:02
Simple decorator to wrap a function and print out some basic profiling information.
def timed(f):
import cProfile, pstats, StringIO
def wrap(*args):
#start profiling
pr = cProfile.Profile()
pr.enable()
#execute function
ret = f(*args)
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
4.6,3.1,1.5,0.2,Iris-setosa
5.0,3.6,1.4,0.2,Iris-setosa
5.4,3.9,1.7,0.4,Iris-setosa
4.6,3.4,1.4,0.3,Iris-setosa
5.0,3.4,1.5,0.2,Iris-setosa
4.4,2.9,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
@samueljackson92
samueljackson92 / config.json
Created November 23, 2013 09:02
Secret Santa program. Takes a list of names and emails and some details to connect to an SMTP server and pairs each person with another person and sends out emails to each participant informing them who they are secret Santa for.
{
"email": "[email protected]",
"password": "yourpasswordhere",
"server": "smtp.gmail.com",
"port": 587
}
@samueljackson92
samueljackson92 / sieve.py
Created August 4, 2013 14:15
Sieve Of Eratosthenes
#!/usr/bin/env python
################################################
# Sieve Of Eratosthenes
# Implementation the sieve of eratosthenes for
# finding all prime numbers up to a given limit
# Author: Samuel Jackson ([email protected])
# Date: 4/8/13
################################################
@samueljackson92
samueljackson92 / quirk.js
Created July 28, 2013 08:25
JS formatting quirk
function foo() {
return {
bar : "Hello World!"
}
}
function foo2()
{
return
{