This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
def convert(input): | |
v1 = struct.pack('>I', int(input, 2)) | |
v2 = struct.unpack('<I', v1) | |
output = int(''.join(map(str,v2))) | |
return output | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my($input) = 0b01000000010000100000111100000000; | |
my $v1 = pack("I>", $input); | |
my $v2 = unpack("I<", $v1); | |
print "$v2" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Validate(tornado.web.RequestHandler): | |
@tornado.web.asynchronous | |
def get(self): | |
signature = self.request.headers.get('X-Twilio-Signature') | |
AUTH_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx' | |
validator = RequestValidator(AUTH_TOKEN) | |
url = self.request.uri | |
var = self.request.arguments | |
for x in var: | |
var[x] = ''.join(var[x]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
from twilio import twiml | |
from oauth2client.client import SignedJwtAssertionCredentials | |
from twilio.util import RequestValidator | |
class ValidateHandler(tornado.web.RequestHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import tornado.httpserver | |
import tornado.websocket | |
import tornado.ioloop | |
import tornado.web | |
from datetime import datetime | |
import sched, time | |
class WSHandler(tornado.websocket.WebSocketHandler): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def toCash(amount): | |
pounds,pence = divmod(amount, 1) | |
pounds = int(pounds) | |
pence = pence*100 | |
pence = int(round(pence)) | |
notes = [50, 20, 10, 5, 1] #These are the whole amounts Yes I know the £1 & £2 are coins in the UK! | |
coins = [50, 20, 10, 5, 2, 1] #These are the less than whole amounts eg the pence | |
for note in notes: | |
count = pounds / note | |
if count >= 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def normalise(number): | |
if re.match("^00.*", number): | |
return number.lstrip("0") | |
elif re.match("^0[1-9].*", number): | |
return "44" + number.lstrip("0") | |
elif re.match("^\+44.*", number) | |
return number.lstrip("+") | |
else: | |
return number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timer = false; | |
function doSomething(){ | |
if (timer == false){ | |
console.log("DOING SOMETHING"); | |
timer = true; | |
console.log("Timer is set") | |
setTimeout(function(){timer = false; | |
console.log("Timer is clear") | |
},10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Examples written using httpie as a command line tool) | |
username and password are the values you use on the tropo web portal | |
Request a selection of avalible numbers for a given city prefix in this case 415 (San Francisco) | |
http --auth username:password GET http://api.tropo.com/addresses available==1 prefix==1415 | |
This will return a JSON object as below that contains a selection of avalible numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1900x1200 at 32bit depth, DMT mode | |
disable_overscan=1 | |
framebuffer_width=1900 | |
framebuffer_height=1200 | |
framebuffer_depth=32 | |
framebuffer_ignore_alpha=1 | |
hdmi_pixel_encoding=1 | |
hdmi_group=2 |