Skip to content

Instantly share code, notes, and snippets.

@reinhrst
reinhrst / adam.css
Created September 17, 2012 14:28
Spotify Style Sheets
/**
* Adam Theme / Dark Theme
* Standard Layout for Spotify Client
* Defines the basic styles for an app
* @copyright 2011 by Spotify
*/
/**
* Declarations for Adam Theme
*
@reinhrst
reinhrst / gist:4341358
Created December 19, 2012 22:57
Capacitive touch on electic imp. Just load the code, and touch pin 1!
//Checks for touch
imp.configure("Touch", [], []);
function test() {
local cycles = 0;
hardware.pin1.configure(DIGITAL_OUT);
hardware.pin1.write(1);
imp.sleep(0.01);
hardware.pin1.configure(DIGITAL_IN);
@reinhrst
reinhrst / gist:8053792
Created December 20, 2013 11:58
gopher key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCgQXVOL8MNiukq0+F/L8JajkhpoONIqg9Urr+RAqF2q91ZFMbkzfBk1W0Wbr+uiIk8hvrZnX+QON4DLHGxVrzY4fYgdcx3JTaTz7UlGqsatnZcvzg1Dew2fipoZvPIxnTu+SX0jno4DINbyW8PL3LAXN3s2Tif7kEFlfu6b/Ww0e1b1PCipuNdMdrUor55Ilue/IAXQNhuOncXbAiM+p6ae+zse02Nl7Q/gmpQkLTuEE/ATd398zmP2HXrPtf8+nwiLlgbkcBThRBLtWRG6xRruDZ6Mfp1+REwQRp8GiRHhll63MQn5iU1Z0P9qU8q+4M89dv9TPX2tDJLZLWKf5T1 gopher@claude.nl
--- seqlock_atom.ll 2014-01-04 11:47:54.000000000 +0000
+++ seqlock_seq_cst.ll 2014-01-04 11:47:41.000000000 +0000
@@ -17,6 +17,10 @@
entry:
%i = alloca i32, align 4
%local_lock = alloca i32, align 4
+ %.atomictmp = alloca i32, align 4
+ %.atomictmp2 = alloca i32, align 4
+ %.atomictmp3 = alloca i32, align 4
+ %.atomictmp4 = alloca i32, align 4
@reinhrst
reinhrst / campfirestatus.py
Last active August 29, 2015 14:08
Proof of concept for Buildbot 0.89 / Campfire integration. For sure makes some assumptions on our buildbot setup!
import base64
from twisted.internet import reactor
from buildbot.interfaces import IStatusReceiver
from twisted.application import service
from twisted.web.client import getPage
from zope.interface import implements
from twisted.internet import defer
import httpstream
import json
@reinhrst
reinhrst / tutorial.md
Last active August 29, 2015 14:17
Ecmascript 6+: Babel + Webpack for the browser and serverside (without flowtype, but with sourcemaps).

NOTE: code accompanying this text [here][11].

After [my initial flirting with some advanced python][2] for the backend at Lone Rooftop, in the end we decided to go all-in on the nodejs trail. There are a number of reasons for this.

  1. Even though it's quite doable to keep two languages in one's head, python for server-side, and javascript client-side, I do still notice that I mix them up (answer quickly: how to add an element to a python list? And how to a javascript array?). And wouldn't it be better to only have to keep one in one's head (and use the saved brain-space to keep more of the application in there)?
  2. Like any developer I spened a lot of time setting up my editor (in my case vim) in just the way I like it. It's probably better to only have to do this once, for one language, then having to do this twice. And personally I don't believe in editors that come fully set-up.... In the end there is always some small thing that I'd like to change.
  3. Even though the two points above are minor nuisanc
@reinhrst
reinhrst / install_opencv3_python3_osx.sh
Last active September 21, 2016 03:25
Install opencv master (2015-04-02) on python 3 on OSX
brew install python3
pip3 install numpy
brew install cmake
git clone --depth=1 https://github.com/Itseez/opencv.git
cd opencv
mkdir build
cd build
# note: in the next line, adjust paths to point to the correct python version
cmake -DBUILD_opencv_python3=YES -DBUILD_opencv_python2=NO -DINSTALL_PYTHON_EXAMPLES=YES -DPYTHON3_EXECUTABLE=/usr/local/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/site-packages/numpy/core/include/ -DPYTHON3_PACKAGES_PATH=/usr/local/lib/python3.4/site-packages/ ..
make -j8
@reinhrst
reinhrst / .vimrc
Created August 23, 2015 21:09
Vim function to quickly toggle between dict notation `a["x"]` and dot notation `a.x`. Uses vim-repeat in the end, to enable repeat
function DictDotToggle()
python << endpython
import re, vim
(row, col) = vim.current.window.cursor
line = vim.current.buffer[row - 1]
re_word = "(?P<word>[a-zA-Z_][a-zA-Z0-9_]*)"
dottedwords = re.finditer(r"\." + re_word, line)
for dottedword in dottedwords:
if dottedword.start("word") <= col and dottedword.end("word") > col:
new_line = (
@reinhrst
reinhrst / server.py
Last active February 26, 2016 15:18
Tornado async testing framework with asyncio and using your own server options
import tornado.web
import tornado.httpserver
def make_app():
app = tornado.web.Application(
[(r"/.*", PageHandler)],
debug=tornado.options.options.serverdebug,
cookie_secret=config.COOKIE_SECRET,
compress_response=True)
return app
@reinhrst
reinhrst / dates.sh
Last active November 8, 2015 11:57
#!/bin/bash
# oneliner to print a range of dates, ending today
for i in $(seq -f %.0f $(date -j -f %Y-%m-%d 2015-10-15 +%s) $((24 * 60 * 60)) $(date +%s)); do date -jf %s $i +%Y-%m-%d; done
# and one in python
python -c "import datetime; date = datetime.date(2015, 10, 5); days = range((datetime.date.today() - date).days); print(' '.join(str(date + datetime.timedelta(day)) for day in days))"