Skip to content

Instantly share code, notes, and snippets.

View nickrobson's full-sized avatar
👨‍💻
beeping and booping

Nick Robson nickrobson

👨‍💻
beeping and booping
View GitHub Profile
@nickrobson
nickrobson / colours.h
Last active August 29, 2015 14:17
colours!
//
// colours.h
// COMP1917
//
// Created by Nick Robson on 20/03/2015.
// Copyright (c) 2015 Nick Robson. All rights reserved.
//
#ifndef __COMP1917__colours__
#define __COMP1917__colours__
@nickrobson
nickrobson / filecontents.c
Created March 27, 2015 01:20
Get the contents of a file.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
char fileName[30];
printf("Enter file name: ");
scanf("%s", fileName);
FILE* file = fopen(fileName, "r");
@nickrobson
nickrobson / trident.sh
Last active August 29, 2015 14:25
Trident Workspace Fetcher (now can built TridentSDK & Trident using Maven)
tridentsdk="TridentSDK"
trident="Trident"
env="Env"
clear
# Print 'header' info
echo "\x1b[35;1m===================================="
echo "== Trident Workspace Fetcher v2.0 =="
echo "===================================="
@nickrobson
nickrobson / rom.js
Created January 17, 2016 02:36
Converts decimal numbers to roman numerals.
function convert(num) {
var map = [
[1, 1, 'I'],
[1, 5, 'V'],
[2, 10, 'X'],
[2, 50, 'L'],
[3, 100, 'C'],
[3, 500, 'D'],
[4, 1000, 'M'],
[4, 5000, ''],
@nickrobson
nickrobson / permutations.rb
Last active January 29, 2016 07:15
Gets all permutations of a given number.
def number_shuffle(number)
dig = number.to_s.split ''
if dig.length == 1
return dig
end
out = []
(0...dig.length).each do |d|
nums = []
if d > 0
nums = nums << dig[0..d-1]
@nickrobson
nickrobson / strawpoll.py
Last active May 20, 2016 13:27
Automatic Strawpoll voter
import sys
import time
import urllib
import urllib2
import bs4
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0'}
def scrape(id):
req = urllib2.Request('http://www.strawpoll.me/%s' % id, headers=headers)
@nickrobson
nickrobson / temperature.pde
Last active June 2, 2016 11:07
Read a temperature from A0, print to LCD at 0x3F.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define I2C_ADDR 0x3F
#define TEMP_SENSOR A0
LiquidCrystal_I2C lcd(I2C_ADDR, 20, 4);
void setup() {
@nickrobson
nickrobson / euref.py
Created June 24, 2016 02:41
EU Referendum Scraper:
#!/usr/bin/env python
import re
import urllib2
import bs4
BASE_URL = 'http://www.bbc.co.uk/news/politics/eu_referendum/results/local/'
VOTES = re.compile(r'[0-9]+(?:,[0-9]+)*')
def get_urls():
@nickrobson
nickrobson / euref.py
Last active June 25, 2016 00:50
Brexit Results Scraper: Gets current voting status.
#!/usr/bin/env python
import re
import urllib2
import bs4
BASE_URL = 'http://www.bbc.co.uk/news/politics/eu_referendum/results/local/'
VOTES = re.compile(r'[0-9]+(?:,[0-9]+)*')
def get_urls():
package ass1;
public class MyCoolGameObject extends GameObject {
public MyCoolGameObject() {
super(GameObject.ROOT);
new PolygonalGameObject(this, new double[] {0, 0, 0, .5, .5, .5, .5, 0}, new double[] {1, 0, 0, .5}, null);
new LineGameObject(this, 0, 0, 1, 0, new double[] {0, 1, 0, .5});
new LineGameObject(this, 0, 0, 0, 1, new double[] {0, 1, 0, .5});