Skip to content

Instantly share code, notes, and snippets.

@acspike
acspike / cms_plugin_processors.py
Created May 22, 2014 12:23
templatish tags for text plugins to avoid fragile internal urls
import re
from cms.models.pagemodel import Page
from django.contrib.sites.models import Site
from django.utils.safestring import mark_safe
TAG = re.compile(r'''
\{% # opening
import re
tag = re.compile(r'\{% ?([^ ]+(?: [^ ]+)*) ?%\}')
rules = {
'static': lambda x: 'statistically',
'page': lambda x: 'paging '+x[0]+' up to',
}
def replace(m):
args = m.groups()[0].split(' ')
@acspike
acspike / gist:7cdb82c73f09a911d1f1
Last active August 29, 2015 14:01
Using conditionals to light LEDs
int button = 2;
int led = 13;
int leds[] = {5,6,9,10,11};
int leds_count = 5;
int cursor = 0;
int direction = 1;
void setup() {
@acspike
acspike / gist:352ae483cf39cdc5233b
Created October 24, 2014 16:50
orbeon test #1
#######################################
# page-flow.xml
#######################################
<controller xmlns="http://www.orbeon.com/oxf/controller" matcher="regexp">
<service public-methods="GET HEAD POST PUT"
path="/mlc/test"
model="test.xpl"/>
<page path="/mlc/page"
@acspike
acspike / gist:f2ac7deac5fbc94effd5
Created October 24, 2014 16:59
orbeon test #1 log
2014-10-24 11:52:53,589 INFO ProcessorService - /mlc/test - Received request
2014-10-24 11:52:53,589 DEBUG URLGenerator - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/pipeline.rng
2014-10-24 11:52:53,590 DEBUG URLGenerator - OXF Protocol: Using ResourceManager for key /config/prologue-servlet.xpl
2014-10-24 11:52:53,590 DEBUG URLGenerator - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/aggregator.rng
2014-10-24 11:52:53,591 DEBUG ConcreteChooseProcessor - Choose: taking otherwise branch at line 25, column 40 of oxf:/config/prologue-servlet.xpl
2014-10-24 11:52:53,591 DEBUG URLGenerator - OXF Protocol: Using ResourceManager for key /org/orbeon/oxf/xml/schemas/page-flow-controller.rng
2014-10-24 11:52:53,591 DEBUG URLGenerator - OXF Protocol: Using ResourceManager for key /page-flow.xml
2014-10-24 11:52:53,592 DEBUG PageFlowControllerProcessor - processing page/service {controller: "oxf:/page-flow.xml", method: "PUT", path: "/mlc/test"}
2014-10-24 11
@acspike
acspike / gist:0011efa65b576e8f00f3
Last active August 29, 2015 14:08
arduino to norland test
#include "TICL.h"
#include "CBL2.h"
#include <IRremote.h>
#define r_play 0xE1447A85
#define r_stop 0xE14406F9
#define r_fwd 0xE1444AB5
#define r_rev 0xE144CA35
#define r_aud 0xE144DE21
#define r_sub 0xE1445EA1
@acspike
acspike / aaron.rb
Created February 9, 2010 02:58 — forked from boblmartens/aaron.rb
require 'net/imap'
require 'base64'
require 'rexml/document'
require 'yaml'
require 'open3'
require 'pp'
class GPG
def initialize(gpg_exec, gpg_home, gpg_pass)
'''calculate lists of indexes for n objects taken k at a time without respect for order'''
def indexlist1(n,k):
'''
soultion by counting up in binary with k pegs
'''
l = range(k)
yield list(l)
#until the first peg is in its maximum position
while l[0] < (n - k):
#!/usr/bin/env python
import time, getpass
class FakeStream(object):
def write(self, *args, **kwargs):
pass
def flush(self, *args, **kwargs):
pass
print '''TapTempo
@acspike
acspike / mspgcc4_win32_notes.txt
Created February 21, 2011 00:27
Outline for building mspgcc4 on win32
- install mingw with mingw-get-inst (c,c++,developer toolkit)
in msys
- mingw-get install msys-wget-bin
- ln -s /mingw/bin/libtool /bin/libtool
- install tortoise-git
- git clone git://mspgcc4.git.sourceforge.net/gitroot/mspgcc4/mspgcc4
in msys
- ./buildgcc.pl