Skip to content

Instantly share code, notes, and snippets.

@max-giro
max-giro / multitouch.pde
Last active December 18, 2015 10:49
[Fixed code for multitouch Processing on Android example at http://www.akeric.com/blog/?p=1411]
// http://www.akeric.com/blog/?p=1411
// Eric Pavey - AkEric.com - 2010-12-29
// Example showing simple multi-touch detection in 'Processing - Android'.
// My Samsung Captivate (Galaxy S) can track 5 touch-points.
// Updated to work with Processing's surfaceTouchEvent instead of
// Android's dispatchTouchEvent.
// Should point out that API Level 9 has MotionEvent.PointerCoords class that
# A* Shortest Path Algorithm
# http://en.wikipedia.org/wiki/A*
# FB - 201012256
from heapq import heappush, heappop # for priority queue
import math
import time
import random
class node:
xPos = 0 # x position
@max-giro
max-giro / graph.py
Created January 6, 2013 14:32 — forked from n0phx/graph.py
# 6.00 Problem Set 10
# Graph optimization
#
# A set of data structures to represent graphs
#
class Node(object):
def __init__(self, name):
class RandomWalkRobot(Robot):
"""
A RandomWalkRobot is a robot with the "random walk" movement strategy: it
chooses a new direction at random at the end of each time-step.
"""
def updatePositionAndClean(self):
"""
Simulate the raise passage of a single time-step.
Move the robot to a new position and mark the tile it is on as having
# === Problem 1
class RectangularRoom(object):
"""
A RectangularRoom represents a rectangular region containing clean or dirty
tiles.
A room has a width and a height and contains (width * height) tiles. At any
particular time, each of these tiles is either clean or dirty.
"""
def __init__(self, width, height):
@max-giro
max-giro / RandomWalkRobot.py
Created November 26, 2012 04:23
RandomWalkRobot
class RandomWalkRobot(Robot):
"""
A RandomWalkRobot is a robot with the "random walk" movement strategy: it
chooses a new direction at random at the end of each time-step.
"""
def updatePositionAndClean(self):
"""
Simulate the raise passage of a single time-step.
Move the robot to a new position and mark the tile it is on as having
@max-giro
max-giro / L12_PROBLEM_3.py
Created November 25, 2012 01:40
L12 PROBLEM 3
def loadTemperatures(file):
lines = [line.strip() for line in open(file) if line[0].isdigit()]
data = []
[data.insert(int(line.split()[0]), int(line.split()[1])) for line in lines]
return data
temps = loadTemperatures("julyTemps.txt")
producePlot(temps)
@max-giro
max-giro / index.html
Created November 20, 2012 16:09
udacity.com output
<html><head>
<title>Udacity | Free Online Courses. Advance your College Education &amp; Career</title>
<meta name="google-site-verification" content="8BozdrktZ5uY63LYrPxB5iOkouVTdHipGsNzUW9V2pU">
<meta property="og:title" content="Udacity | Free Online Courses, Advance your College Education &amp; Career">
<meta property="og:type" content="website">
<meta property="og:url" content="http://www.udacity.com/">
<meta property="og:image" content="http://www.udacity.com/media/img/logos/Udacity_logo.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="89">
<meta property="og:image:height" content="98">
# This works
def isWordIn(word, text):
for sign in string.punctuation:
if (sign in text):
text = text.replace(sign, '')
print(text)
words = (text.lower()).split()
print(words)
return word in words
def buildCoder(shift):
dict_letters = {}
for letter in string.ascii_letters:
dict_letters[letter] = letter
for letter in dict_letters:
if (string.ascii_letters.find(letter) + shift) in range (0, 52):
#
dict_letters[letter] = string.ascii_letters[(string.ascii_letters.find(letter) + shift) % 52]
else: