Skip to content

Instantly share code, notes, and snippets.

@acspike
acspike / SpaceBar.pde
Created December 18, 2012 23:40
An arduino sketch for a foot actuated usb spacebar
// Much code borrowed from the following
// https://github.com/practicalarduino/VirtualUsbKeyboard
// http://playground.arduino.cc/Learning/SoftwareDebounce
#include "UsbKeyboard.h"
#define BUTTON_PIN 12
#define LED_PIN 13
#define KEY_SPACE 0x2C
from __future__ import print_function
import random, itertools, sets
## The following represents thought process and has not been subjected to rigorus proof
# Possible pairings can be represented as two varieties of cycles in the permutations of the residents due to the restriction on reflexive pairings.
# For each permutation there is a single cycle through all 7 name and a two disjoint cycles through 3 names and 4 names respectively.
# Total unique pairings are therefore less than 7!*2 = 10080 (less because cycles of a particular permutation generate equivalent pairings)
# There are 7! permutations. Cycles through all 7 that produce equivalent pairings can be elminiated by considering only permutations that begin with a particular digit (eg. 6).
# Therefore unique pairings for cycles through all 7 generates 6! = 720 (ie 7!/7) pairings.
# Considering 3,4 cycles inside of each permutation there should be (7!/(4!*3))(4!/4) = 420
from __future__ import print_function
import random, itertools, sets
## The following represents thought process and has not been subjected to rigorus proof
# Possible pairings can be represented as two varieties of cycles in the permutations of the residents due to the restriction on reflexive pairings.
# For each permutation there is a single cycle through all 7 name and a two disjoint cycles through 3 names and 4 names respectively.
# Total unique pairings are therefore less than 7!*2 = 10080 (less because cycles of a particular permutation generate equivalent pairings)
# There are 7! permutations. Cycles through all 7 that produce equivalent pairings can be elminiated by considering only permutations that begin with a particular digit (eg. 6).
# Therefore unique pairings for cycles through all 7 generates 6! = 720 (ie 7!/7) pairings.
# Considering 3,4 cycles inside of each permutation there should be (7!/(4!*3))(4!/4) = 420
from __future__ import print_function
import random, itertools, sets
## The following represents thought process and has not been subjected to rigorus proof
# Possible pairings can be represented as two varieties of cycles in the permutations of the residents due to the restriction on reflexive pairings.
# For each permutation there is a single cycle through all 7 name and a two disjoint cycles through 3 names and 4 names respectively.
# Total unique pairings are therefore less than 7!*2 = 10080 (less because cycles of a particular permutation generate equivalent pairings)
# There are 7! permutations. Cycles through all 7 that produce equivalent pairings can be elminiated by considering only permutations that begin with a particular digit (eg. 6).
# Therefore unique pairings for cycles through all 7 generates 6! = 720 (ie 7!/7) pairings.
# Considering 3,4 cycles inside of each permutation there should be (7!/(4!*3))(4!/4) = 420
from __future__ import print_function
import random, itertools, sets
## The following represents thought process and has not been subjected to rigorus proof
# Possible pairings can be represented as two varieties of cycles in the permutations of the residents due to the restriction on reflexive pairings.
# For each permutation there is a single cycle through all 7 name and a two disjoint cycles through 3 names and 4 names respectively.
# Total unique pairings are therefore less than 7!*2 = 10080 (less because cycles of a particular permutation generate equivalent pairings)
# There are 7! permutations. Cycles through all 7 that produce equivalent pairings can be elminiated by considering only permutations that begin with a particular digit (eg. 6).
# Therefore unique pairings for cycles through all 7 generates 6! = 720 (ie 7!/7) pairings.
# Considering 3,4 cycles inside of each permutation there should be (7!/(4!*3))(4!/4) = 420
@acspike
acspike / gist:7999179
Last active December 31, 2015 14:19
Save in two sizes
#target photoshop
main();
function main() {
if(!documents.length) return;
var doc = app.activeDocument;
try{
var Path = activeDocument.path;
import select
import serial
serial_dev = '/dev/ttyS1'
select_timeout = 30
port = serial.Serial(serial_dev, timeout=None)
port.flushInput()
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 / 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
@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() {