Skip to content

Instantly share code, notes, and snippets.

View redspider's full-sized avatar

Richard Clark redspider

  • Red Spider Limited
  • Wellington, New Zealand
View GitHub Profile
@redspider
redspider / tar_example.md
Created July 31, 2012 05:47
Tar extraction example

Demonstration of a partial tar extraction.

First we set up a dir for testing:

$ ls -lR
.:
total 4
drwxr-xr-x 5 richard richard 4096 2012-07-31 17:46 root_dir
@redspider
redspider / permute.py
Created September 26, 2012 11:09
Simple string permutation
def permute(items):
"""
Return the permutations of the provided set
:param items: Set of items to permute
:type items: set
:return: list of permutations
:rtype: list
"""
var compactListingDirective = m.directive('compactListing', function (listingService) {
return {
replace: true,
scope: {
listing: '=compactListing'
},
controller: function ($scope, $attrs, listingService) {
$scope.listingService = listingService;
},
templateUrl: TMPL.compact_listing

We have a sequence of IDs, 1, 2, 3, 4... that are references to data. We wish to use these IDs in a URL, however we do not want them to be iterable - that is, given 3, it should not be possible to derive the URL for 2 or 4.

Our proposed solution is to generate the URL as follows:

/<hmac>-<id>/

Where hmac consists of a SHA256 HMAC of the ID using a secret key. We then verify the hmac when the URL is used.

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto('PING', ('127.0.0.1',540))
data, addr = s.recvfrom(1024)
print data, addr
#!/usr/bin/env python
# Test code for Adafruit LED Pixels, uses hardware SPI
import RPi.GPIO as GPIO, time, os
DEBUG = 1
GPIO.setmode(GPIO.BCM)
import time, os
try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
class Color(object):
def __init__(self, r, g, b):
import random
import time, os
try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
try:
import xtermcolor
import random
import time, os
try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
try:
import xtermcolor
import math
import random
import time, os
try:
import RPi.GPIO as GPIO
except ImportError:
GPIO = None
try: