Skip to content

Instantly share code, notes, and snippets.

@sammachin
sammachin / getquota.py
Created February 10, 2014 10:15
AAISP GET Quota, snippet to get your remaining quota from Andrews & Arnolds 'clueless' server in python, needs requests & beautifulsoup4 modules
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
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
@sammachin
sammachin / setup.py
Created August 7, 2014 11:29
Setup The
#! /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
@sammachin
sammachin / response.json
Created August 7, 2014 11:31
JSON STAT response from the API
{
"QS104EW": {
"source": "Office for National Statistics",
"updated": "17/10/2013 16:51:00",
"dimension": {
"2011WARDH": {
"category": {
"index": {
"K04000001": 0
},
@sammachin
sammachin / parse.py
Created August 7, 2014 11:33
Parse JSON STAT
#First we create an empty dict object
data = {}
#We need to specify the dataset name
dataset = "QS104EW"
# We get the actaul observation values from the JSON-STAT as a list
values = obj[dataset]['value']
# Then we get the index of the observations and its asccociated categories as a dict
@sammachin
sammachin / data.py
Created August 7, 2014 11:34
Result of parsing json-stat
{u'Females': 28502536, u'Males': 27573376, u'All categories: Sex': 56075912}
@sammachin
sammachin / test.r
Created August 20, 2014 14:07
rjstat problems
# Using v0.1 copy from our GitHub repo
install_github("rjstat", "ONSDigital")
url <- "http://s3.sammachin.com/QS103EW.json"
results <- fromJSONstat(readLines(url))
length(results$`Age by single year`$value)
[1] 102
### Keybase proof
I hereby claim:
* I am sammachin on github.
* I am sammachin (https://keybase.io/sammachin) on keybase.
* I have a public key whose fingerprint is 4867 9F57 F2C9 7E38 62D2 5838 890C 49E3 52CD 329B
To claim this, I am signing this object:
@sammachin
sammachin / config.xml
Created November 23, 2014 14:54
Firebrick Twilio Config
<rule-set no-match-action="continue">
<rule target-port="5060"
action="accept"/>
</rule-set>
<rule-set name="Block Incomming"
source-interface="pppoe"
target-interface="LAN"
no-match-action="reject"
comment="Default firewall rule - block incoming">
@sammachin
sammachin / gist:3bd36c1957787206d060
Last active August 29, 2015 14:11
Excerpt from my asterisk extenstions.conf to screen my incomming calls and ask unknown's to press 1 before it will call me
[from-external]
// Send Notification
exten => 01934xxxxxx,1,AGI(agi://192.168.1.11:4573/log?chan=landline&cli=${CALLERID(num)})
// Allow whitelisted numbers
exten => 01934xxxxxx/07970xxxxxx,2,Dial(SIP/1000&SIP/1001&SIP/1002&SIP/2000)
exten => 01934xxxxxx/01202xxxxxx,2,Dial(SIP/1000&SIP/1001&SIP/1002&SIP/2000)