Skip to content

Instantly share code, notes, and snippets.

View donalmacc's full-sized avatar

Donal Mac Carthy donalmacc

  • @AnchorPoint_Inc
  • Edinburgh, Scotland
View GitHub Profile
@donalmacc
donalmacc / arm.s
Created April 25, 2012 12:09
ARM Intterrupt
#I assume here that all the memory addresses are set up correctly.
IMPORT main
EXPORT start
start
ldr r0,=VICVectAddr0
ldr r1,=irqhan
str r1,[r0] ; associate our interrupt handler with Vectored Interrupt 0
ldr r0,=VICVectCtrl0
mov r1,#Timer0ChannelNumber+(1<<IRQslot_en)
@donalmacc
donalmacc / proj.py
Created April 30, 2012 00:17
Simple projectiles
#Donal Mac Carthy, simple projectiles
import math
#Calculates the distance in the specified direction at the given time
def distattime(u, a, t):
#A formula
x = (u*t)+(0.5*a*t*t)
#Ignore if the distance is negative
if( x >= 0):
return x
@donalmacc
donalmacc / why.js
Created May 16, 2012 19:20
Why, for zach
function resetDailyStats()
//EFFECTS: Creates a new object to store in the array of stats,
// resets the various station's stats
{
console.log("resetDailyStats() was called");
App.tempStats = App.Stats.create();
var day = App.SimObject.get('simDay');
console.log(day);
console.log(App.tempStats.get('greenIdle'));
App.SimObject.set(simStats[day], App.tempStats);
import socket
#Create the socket connection
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("", 1756)) # Bind the connection
s.listen(1) # Listen for the connection. Will not advance unless a connection is received
conn, addr = s.accept() # Accepts a connection
print "Listening..." # Debug
while 1:
data = conn.recv(1024) # Receive transmission
# Sender client
import socket
HOST = '127.0.0.1' # The remote host
PORT = 1756 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
print"Please enter your message:"
msg = raw_input()
@donalmacc
donalmacc / box2dModifyingGravity.cpp
Created August 19, 2012 23:12
Shows a simple modification of gravity in Box2D
#ifndef FOOTEST_H
#define FOOTEST_H
class FooTest : public Test
{
public:
// List of shapes
b2Body *dynamicBody; // The players shape
b2Body* lowerground; // The horizontal platform
b2Body* sideground; // The vertical platform
@donalmacc
donalmacc / setup.sh
Created November 1, 2012 11:04
Set up ubuntu machines for development
sudo sh
apt-get update
apt-get install python2.7
apt-get install python-numpy
apt-get install python-opencv
apt-get install eclipse-platform
apt-get install eclipse-cdt
apt-get install g++
apt-get install clang
apt-get install git
@donalmacc
donalmacc / rgb.cpp
Created November 22, 2012 23:38
RGB from Grayscale Image
//Create an RGB image from a grayscale image. Grayscale is grayScaleImage
result_image = cvCreateImage(cvGetSize(grayScaleImage),IPL_DEPTH_8U, 3);
cvMerge(grayScaleImage, grayScaleImage, grayScaleImage, NULL, result_image);
bool keys[255];
// constructor
EventHandler::EventHandler()
{
for(int i = 0; i < 255; i++)
keys[i] = false;
}
EventHandler::keyPressed(unsigned char key)
@donalmacc
donalmacc / threadedInput.py
Created October 4, 2013 16:36
Input threaded.
import time
from threading import *
key = "lol"
def getInput():
global key
lock = Lock()
while True:
with lock:
key = raw_input()