Skip to content

Instantly share code, notes, and snippets.

View boffbowsh's full-sized avatar

Paul Bowsher boffbowsh

View GitHub Profile
import requests
from django.core.management.base import BaseCommand
from uk_political_parties.models import Party, PartyEmblem
class Command(BaseCommand):
def clean_party(self, party_id, party):
import base64
from io import BytesIO
from os.path import basename, splitext, sep
import re
import sys
import boto3
from PIL import Image, ImageOps
client = boto3.client('s3')
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.2
-- Dumped by pg_dump version 10.1
-- Started on 2017-12-18 13:59:03 GMT
SET statement_timeout = 0;
1501146000 ?dimension15=200&dimension16=TLSv1.2&dimension11=1&dimension1=driving+and+transport&dimension2=transaction&dimension3=other&dimension4=00000000-0000-0000-0000-000000000000&dimension17=transaction&dimension20=frontend&dimension32=none&dimension33=thing&dimension34=guidance&dimension56=other&dimension57=other&dimension58=other&dimension59=other&dimension39=false&dimension26=3&dimension27=7&eventType=pageview&referrer=&gaClientId=107929329.1480593742&windowWidth=1366&windowHeight=662&screenWidth=1366&screenHeight=768&colorDepth=24&navigationType=0&redirectCount=0&timing_navigationStart=1501145996896&timing_unloadEventStart=0&timing_unloadEventEnd=0&timing_redirectStart=0&timing_redirectEnd=0&timing_fetchStart=1501145997069&timing_domainLookupStart=1501145997069&timing_domainLookupEnd=1501145997069&timing_connectStart=1501145997069&timing_connectEnd=1501145997069&timing_secureConnectionStart=0&timing_requestStart=1501145997085&timing_responseStart=1501145997128&timing_responseEnd=1501145997143&tim
Start of month Uploads
2009-04-01 00:00:00+00 5
2009-05-01 00:00:00+00 348
2009-06-01 00:00:00+00 33
2009-07-01 00:00:00+00 24
2009-08-01 00:00:00+00 3
2009-09-01 00:00:00+00 3
2009-11-01 00:00:00+00 13
2009-12-01 00:00:00+00 31
2010-01-01 00:00:00+00 37
import urllib
import json
def lambda_handler(event, context):
json_text = json.dumps({
"text": "Tea is ready at Corestom",
"icon_url": "https://emoji.slack-edge.com/T026J8X3T/corestum/30c38516350c8fc6.png",
"username": "Corestom Teabot"
})
params = urllib.urlencode({'payload': json_text})
@boffbowsh
boffbowsh / Vagrantfile
Created March 19, 2017 16:52
A vagrantfile for starting a master + 2 node kubernetes cluster
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provision "shell", inline: <<-SHELL
apt-get update && apt-get dist-upgrade -y && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo 'deb http://apt.kubernetes.io/ kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list
schema_name body image format_display_type first_public_at change_note change_history tags withdrawn_notice archive_notice emphasised_organisations publish_time public_updated_at opening_date closing_date government political held_on_another_website_url national_applicability documents ways_to_respond public_feedback_publication_date public_feedback_detail public_feedback_documents final_outcome_publication_date final_outcome_detail final_outcome_documents slug title description quick_links query_response_time contact_form_links more_info_contact_form contact_type feature_on_homepage email_addresses more_info_email_address phone_numbers more_info_phone_number post_addresses more_info_post_address language related_mainstream_content alternative_scotland_url alternative_wales_url alternative_nothern_ireland_url collection_groups subscriber_list email_alert_type summary breadcrumbs govdelivery_title beta beta_message document_noun default_documents_per_page logo_path default_order filter reject facets format_nam
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.3.1
-----> Installing dependencies using bundler 1.13.6
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/.......
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Using rake 11.2.2
Using PriorityQueue 0.1.2
from sys import argv
from bs4 import BeautifulSoup
import requests
if __name__ == "__main__":
search = requests.get("https://www.gov.uk/api/search.json?q=%s&filter_format%%5B%%5D=answer" % argv[1])
for result in search.json()["results"]:
answer = requests.get("https://www.gov.uk%s" % result["link"])