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
// An Arduino sketch for continually reading the temperature from | |
// a Dallas DS18B20 digital thermometer and turning on or off red, | |
// yellow or green LEDs to indicate the temperature range | |
// OneWire 2 library (an improved version of the original OneWire) | |
// http://www.pjrc.com/teensy/td_libs_OneWire.html | |
#include <OneWire.h> | |
// Dallas Temperature Control library from | |
// http://milesburton.com/Dallas_Temperature_Control_Library |
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
""" | |
A Python web service client which GETs temperatures over a web service API | |
from an Arduino based server and PUTs the status of LEDs back to the Arduino | |
to provide a visual temperature indication. | |
The intent of this system is to demonstrate how control logic can be moved | |
to remote systems which communicate with the Arduino over the network. | |
Pass the base url of the server e.g. "http://192.168.1.101" as the | |
only command line argument. |
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
#!/bin/bash | |
# Create a new Python 3.3 venv and configure it with pip | |
# Usage: source path/to/mkvenv <path> | |
set -e | |
pyvenv $1 | |
cd $1 | |
source bin/activate | |
curl -O http://python-distribute.org/distribute_setup.py | |
python distribute_setup.py | |
easy_install pip |
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
function FindProxyForURL(url, host) | |
{ | |
if (shExpMatch(url, "*.bbc.co.uk/iplayer*") | |
|| shExpMatch(url, "*.bbc.co.uk/mediaselector*") | |
|| shExpMatch(url, "zaphod-live.bbc.co.uk.edgesuite.net/*") | |
|| shExpMatch(url, "bbcfmhds.vo.llnwd.net/*")) | |
{ | |
return "SOCKS 127.0.0.1:8080"; | |
} | |
else |
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 csv | |
with open('faithful.dat', newline='') as csvfile: | |
reader = csv.reader(csvfile, quoting=csv.QUOTE_NONNUMERIC) | |
names = next(reader) | |
columns = zip(*reader) | |
data = {name: column for name, column in zip(names, columns)} |
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
def group_when(pred, iterable): | |
"""Yield groups (as lists), starting a new group when pred(item) is True. | |
The predicate is ignored for the first item in iterable, which always starts | |
a new group. | |
Args: | |
pred: A predicate function used to determine when a new group | |
should be started. | |
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
"""Transducers in Python | |
http://blog.cognitect.com/blog/2014/8/6/transducers-are-coming | |
""" | |
from functools import reduce | |
def compose(*fs): | |
"""Compose functions right to left. |
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
"""Transducers in Python | |
http://blog.cognitect.com/blog/2014/8/6/transducers-are-coming | |
""" | |
from abc import abstractmethod, ABCMeta | |
from collections import deque | |
from functools import reduce | |
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
def pop_count_until(stack, predicate): | |
"""Count the number of items which need to be popped off a stack | |
for the top item to satisfy a predicate. | |
The stack argument is modified by this call. If the return value is | |
non-negative the top item on the stack will satisfy the predicate | |
on return. | |
Args: | |
stack: Any object supporting: |
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
def d(t):s=ord(t)-65;h=lambda i:'-'*(s-i)+chr(i+65)+'-'*i;m=[h(i)+h(i)[-2::-1] for i in range(s+1)];return'\n'.join(m+m[-2::-1]) |
OlderNewer