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
#! /usr/bin/env node | |
var Bleacon = require('bleacon'); | |
var uuid = '842AF9C408F511E39282F23C91AEC05E'; | |
var major = 65000; | |
var measuredPower = -59; | |
function myLoop(){ | |
setTimeout(function () { | |
Bleacon.stopAdvertising(); |
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 requests | |
from bs4 import BeautifulSoup | |
aauser = 'xx99@a' | |
aapass = 'xxxxx' | |
def getQuota(): | |
r = requests.get('https://clueless.aa.net.uk/main.cgi', auth=(aauser, aapass)) | |
soup = BeautifulSoup(r.text) | |
qstring = soup.find_all('table')[1].find('tbody').find_all('td')[5].find('a').string |
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/python | |
import SimpleHTTPServer | |
import SocketServer | |
import logging | |
import cgi | |
PORT = 8001 | |
I = '0.0.0.0' |
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
Here is a hypothetical example I don't know if this is legal and correct but this is my idea. | |
Sam Systems Ltd. earns £10k from consulting work for Acme Mega Corp. | |
As SS is VAT registered on the flat rate scheme eh invoices 12K and pays £1680 of that to HMRC as VAT | |
He then takes the remaining £10320 and invests that in R&D of a prototype new product as follows: | |
He spends 2 months of his time building a back end system paying himself a minimal salary of £663/month |
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 requests #we're going to use the requests library for a nice HTTP | |
import json #and the JSON library for parsing the data |
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
# We need to specify our api key here to use in the request | |
apikey = "XXXXXX" | |
#Now we'll setup the base url for the ons API | |
baseurl = "http://data.ons.gov.uk/ons/api/data/dataset/" | |
# We need to specify the dataset we are after, in this case its just the split of gender | |
dataset = "QS104EW" | |
#And pass in some of our parameters |
OlderNewer