Skip to content

Instantly share code, notes, and snippets.

import pyb
switch = pyb.Switch()
leds = [pyb.LED(i+1) for i in range(4)]
accel = pyb.Accel()
i = 0
while not switch():
y = accel.y()
i = (i + (1 if y > 0 else -1)) % len(leds)
@hawkz
hawkz / html5video.sh
Created January 6, 2016 13:53 — forked from liamcurry/html5video.sh
automated conversion of a file to all three html5 compatible video formats - h.264, ogg, and webm
#!/bin/sh
# Output file for HTML5 video
# requirements: ffmpeg .6+
# usage: ./html5video.sh infile.mp4 640x360
target_directory='converted'
file=`basename $1`
filename=${file%.*}
filepath=`dirname $1`
@hawkz
hawkz / SVG Stroke Text Effect.markdown
Created September 5, 2015 17:30
SVG Stroke Text Effect
@hawkz
hawkz / gist:6350440
Created August 27, 2013 06:59
PyCon UK 2013 Song
We code in Python when we're able.
use 'geek' as a proud label.
We script routines its in our genes:
white space is so read-able.
Learn PEP8 here as you'll be taught,
in sprints and jams and talks the lot.
We code in Python when we're able
version 3. is fast. and stable
@hawkz
hawkz / rem-fallback.less
Last active December 14, 2015 08:08 — forked from drublic/rem-fallback.less
Quick modification for multiple values - not the most concise, but this is being compiled pre-upload...
@main-font-size: 16px;
.x-rem (@property, @value) {
// This is a workaround, inspired by https://github.com/borodean/less-properties
@px-fallback: @value * @main-font-size;
-: ~`(function () { return ';@{property}: @{px-fallback}'; }())`;
-: ~`(function () { return ';@{property}: @{value}rem'; }())`;
}
.x-rem (@property, @v1, @v2) {
@px-v1: @v1 * @main-font-size;
@hawkz
hawkz / python33.txt
Created July 15, 2012 22:34
Python in 33 sentences
print - lets you output numbers and characters to the console.
if - let's you choose which statements are executed if an expression is true
else - denotes the statements that execute if the expression isn't true
elif - let's you combine if statements
while - is a way of repeating statements in a loop until an expression is false.
break - is a way to jump out of the statement flow of a loop.
continue - let's you skip a cycle of the flow without ending it.
for - is used to iterate over items of a collection in the order they appear in a container