This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
def __init__(self, value): | |
self.value = value | |
self.next = None | |
def __repr__(self): | |
return 'Node %s' % self.value | |
class LinkedList(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
class Stack(object): | |
def __init__(self): | |
self.items = [] | |
def push(self, item): | |
self.items.append(item) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
def __init__(self, value): | |
self.value = value | |
self.next = None | |
def __repr__(self): | |
return 'Node %s' % self.value | |
class Queue(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node(object): | |
"""A node referencing other nodes, forming a subtree.""" | |
def __init__(self, data): | |
self.left = None | |
self.right = None | |
self.data = data | |
def __repr__(self): | |
"""A (not-so-good) display.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: java $JVM_OPTS -cp target/webdev.jar clojure.main -m webdev.core $PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pingping.core | |
(:import [java.awt.event KeyEvent]) | |
(:require [quil.core :as q])) | |
(defn draw-rect [r] | |
(q/rect (:x r) (:y r) (:w r) (:h r))) | |
;; define left- and right-side rackets, as well as a ball and ball velocity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Adafruit_BBIO.UART as UART | |
import serial | |
UART.setup("UART1") | |
ser = serial.Serial(port="/dev/ttyO1", baudrate=9600, timeout=1) | |
ser.close() | |
ser.open() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input_data = open('data.csv', 'r') | |
output_data = open('out.csv', 'w') | |
for line in input_data: | |
data = line[0:-2] # snip off the new line character and trailing comma | |
output_data.write( data + '\n' ) # add the newline back | |
input_data.close() | |
output_data.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
optparse_testing.py | |
some recipes from http://www.alexonlinux.com/pythons-optparse-for-human-beings | |
''' | |
import optparse | |
parser = optparse.OptionParser() | |
# basics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://www.neotitans.com/resources/python/python-threads-multithreading-tutorial.html | |
import sys | |
import time | |
import random | |
import threading | |
def worker(name): | |
print 'I am %s and starting now' % name | |
wait = random.randint(2,7) | |
time.sleep(wait) |