This file contains hidden or 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
<ns0:kml xmlns:ns0="http://www.opengis.net/kml/2.2"> | |
<ns0:Document> | |
<ns0:Style id="BasicStyle"> | |
<ns0:BalloonStyle> | |
<ns0:text>$[description]</ns0:text> | |
</ns0:BalloonStyle> | |
<ns0:IconStyle> | |
<ns0:color>FFFFFFFF</ns0:color> | |
<ns0:scale>1.1</ns0:scale> | |
<ns0:hotSpot x="0.5" xunits="fraction" y="0" yunits="fraction" /><ns0:Icon> |
This file contains hidden or 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
+V----------------+ | |
| # # # < | |
| # # # # # ######| | |
| # # # # # | | |
| # # # # ########| | |
| # # # # # | | |
| # # # # # ######| | |
| # # # | | |
|######## ####### | | |
| | |
This file contains hidden or 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
// Flags for the direction register | |
#define FLAG_M1_CCW 0 | |
#define FLAG_M1_CW 1 | |
#define FLAG_M2_CCW 2 | |
#define FLAG_M2_CW 3 | |
// Flags for the inopts register | |
#define FLAG_PULLUP_I1 0 | |
#define FLAG_PULLUP_I2 1 | |
#define FLAG_INVERT_I1 2 |
This file contains hidden or 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
char data[10]; | |
for(int i = 0; i < 9; i++) | |
data[i] = Serial.read(); | |
data[9] = '\0'; | |
int r, g, b; | |
sscanf(data, "%3x%3x%3x", &r, &g, &b); | |
// r, g and b now contain the color values |
This file contains hidden or 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
def prefetch_refprops(entities, *props): | |
fields = [(entity, prop) for entity in entities for prop in props] | |
ref_keys = set(prop.get_value_for_datastore(x) for x, prop in fields) | |
ref_keys.discard(None) | |
ref_entities = dict((x.key(), x) for x in db.get(ref_keys)) | |
for (entity, prop), ref_key in zip(fields, ref_keys): | |
prop.__set__(entity, ref_entities[ref_key]) | |
return entities |
This file contains hidden or 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 heapq | |
class EventReactor(object): | |
"""Processes a set of EventStream and executes their events in order.""" | |
def __init__(self): | |
self.time = 0.0 # Current time | |
self.events = [] # Holds (time, event function, stream) tuples in a heapq | |
def add_stream(self, stream): | |
"""Adds an event stream to the reactor. |
This file contains hidden or 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 copy_reg | |
import cPickle | |
import marshal | |
import types | |
def restorefunction(func_name, dump): | |
return types.FunctionType(marshal.loads(dump), globals(), func_name) | |
def reducefunction(func): | |
return (restorefunction, (func.func_name, marshal.dumps(func.func_code))) |
This file contains hidden or 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
def _make_skel_func(code, num_closures): | |
""" Creates a skeleton function object that contains just the provided | |
code and the correct number of cells in func_closure. All other | |
func attributes (e.g. func_globals) are empty. | |
""" | |
#build closure (cells): | |
cellnew = ctypes.pythonapi.PyCell_New | |
cellnew.restype = ctypes.py_object | |
cellnew.argtypes = (ctypes.py_object,) | |
dummy_closure = tuple(map(lambda i: cellnew(None), range(num_closures))) |
This file contains hidden or 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 math | |
sintable = [int(math.sin(x*math.pi/512)*32768+32768) for x in range(256)] | |
def fp_sin(a): | |
"""Fixed point sine. Input range is [0-2^16), output range likewise.""" | |
a = a & 0xffff | |
quadrant = a >> 14 | |
index = (a >> 6) & 0xff | |
if quadrant == 1 or quadrant == 3: |
This file contains hidden or 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/python | |
# -*- coding: utf-8 -*- | |
"""# piclang: A Python EDSL for making paths of interesting shapes. # | |
Nick Johnson and Kragen Javier Sitaker | |
<https://gist.github.com/2555227> | |
This is a simple calculus for easily composing interesting 2-D | |
parametric curves. There are three fundamental curves, called | |
`circle`, `line`, and constant; everything else is built up from these |