Skip to content

Instantly share code, notes, and snippets.

View jasoncartwright's full-sized avatar
👋
🐦

Jason Cartwright jasoncartwright

👋
🐦
View GitHub Profile
def is_uk(lat_lng):
lat = float(lat_lng.split(",")[0])
lng = float(lat_lng.split(",")[1])
sw_lat = 49.1
sw_lng = -14.015517
ne_lat = 61.061
ne_lng = 2.0919117
def fibonacci_sequence(n):
if n <= 0:
return []
elif n == 1:
return [0]
elif n == 2:
return [0, 1]
fib_sequence = [0, 1]
NUMBER_TO = 9699690
OUTPUTS = {
2:"Weil",
3:"Fizz",
5:"Buzz",
7:"Argh",
11:"Zarp",
13:"Plop",
17:"Dilp",
@jasoncartwright
jasoncartwright / tabber.js
Last active October 12, 2023 19:37
Dead Simple Bulma Tab Javascript
function changetab(section) {
document.querySelectorAll(".tabs li").forEach(item => {
item.classList.remove("is-active")
})
document.querySelector("." + section).parentNode.classList.add("is-active")
document.querySelectorAll(".sections .column").forEach(item => {
item.classList.add("is-hidden")
})
document.querySelectorAll("." + section).forEach(item => {
item.classList.remove("is-hidden")
@jasoncartwright
jasoncartwright / purgecache.js
Created May 18, 2023 05:02
Cloudflare Worker Purge Cache
addEventListener('fetch', event => {
event.respondWith(purgeCache(event.request))
})
async function purgeCache(request) {
const url = new URL(request.url)
urls = new URLSearchParams(url.search).getAll("url")
urls.forEach(function (url, index) {
@jasoncartwright
jasoncartwright / sitemaperrors.py
Last active February 28, 2023 09:15
Hit all URLs in a sitemap and report any non-200 responses
import requests, re
# PUT YOUR SITEMAP URL RIGHT HERE PLEASE
SITEMAP_URL = "https://www.example.com/sitemap.xml"
# REPORT BACK EVERY X URLS DOWNLOADED
REPORT_EVERY = 100
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:100.0) Gecko/20100101 Firefox/100.0",
}
@jasoncartwright
jasoncartwright / 1984.txt
Last active July 7, 2022 18:48
Nineteen Eighty-Four in 280 character chunks
It was a bright cold day in April, and the clocks were striking thirteen.
Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him.
The hallway smelt of boiled cabbage and old rag mats.
At one end of it a coloured poster, too large for indoor display, had been tacked to the wall.
It depicted simply an enormous face, more than a metre wide: the face of a man of about forty-five, with a heavy black moustache and ruggedly handsome features.
Winston made for the stairs.
It was no use trying the lift.
Even at the best of times it was seldom working, and at present the electric current was cut off during daylight hours.
It was part of the economy drive in preparation for Hate Week.
The flat was seven flights up, and Winston, who was thirty-nine and had a varicose ulcer above his right ankle, went slowly, resting several times on the way.
RICK_ASTLEY = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
url(r'^wp-login\.php$', RedirectView.as_view(url=RICK_ASTLEY)),
parlcon_party = {'Morecambe and Lunesdale': 'Conservative', 'North East Hertfordshire': 'Conservative', 'Blaydon': 'Labour', 'Thornbury and Yate': 'Conservative', 'South Antrim': 'DUP', 'Belfast North': 'Sinn F\xc3\xa9in', 'Fermanagh and South Tyrone': 'Sinn F\xc3\xa9in', 'Ipswich': 'Conservative', 'Castle Point': 'Conservative', 'Rochdale': 'Labour', 'Neath': 'Labour Co-operative', 'Leeds West': 'Labour', 'South Leicestershire': 'Conservative', 'Ashton-under-Lyne': 'Labour', 'Epsom and Ewell': 'Conservative', 'Walsall North': 'Conservative', 'Penistone and Stocksbridge': 'Conservative', 'New Forest East': 'Conservative', 'Chipping Barnet': 'Conservative', 'Kilmarnock and Loudoun': 'Scottish National', 'Kettering': 'Conservative', 'Orkney and Shetland': 'Liberal Democrats', 'Aberavon': 'Labour', 'Rossendale and Darwen': 'Conservative', 'Angus': 'Scottish National', 'Westmorland and Lonsdale': 'Liberal Democrats', 'Solihull': 'Conservative', 'Totnes': 'Conservative', 'Manchester Withington': 'Labour', 'Garston
parlcon_mp = {'Morecambe and Lunesdale': 'David Morris', 'North East Hertfordshire': 'Oliver Heald', 'Blaydon': 'Liz Twist', 'Thornbury and Yate': 'Luke Hall', 'South Antrim': 'Paul Girvan', 'Belfast North': 'John Finucane', 'Fermanagh and South Tyrone': 'Michelle Gildernew', 'Ipswich': 'Tom Hunt', 'Castle Point': 'Rebecca Harris', 'Rochdale': 'Tony Lloyd', 'Neath': 'Christina Rees', 'Leeds West': 'Rachel Reeves', 'South Leicestershire': 'Alberto Costa', 'Ashton-under-Lyne': 'Angela Rayner', 'Epsom and Ewell': 'Chris Grayling', 'Walsall North': 'Eddie Hughes', 'Penistone and Stocksbridge': 'Miriam Cates', 'New Forest East': 'Julian Lewis', 'Chipping Barnet': 'Theresa Villiers', 'Kilmarnock and Loudoun': 'Alan Brown', 'Kettering': 'Philip Hollobone', 'Orkney and Shetland': 'Alistair Carmichael', 'Aberavon': 'Stephen Kinnock', 'Rossendale and Darwen': 'Jake Berry', 'Angus': 'Dave Doogan', 'Westmorland and Lonsdale': 'Tim Farron', 'Solihull': 'Julian Knight', 'Totnes': 'Anthony Mangnall', 'Manchester Withington'