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
# 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()
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
@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);
@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 / 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)