Skip to content

Instantly share code, notes, and snippets.

View cmbuckley's full-sized avatar

Chris Buckley cmbuckley

View GitHub Profile
@cmbuckley
cmbuckley / pwned.sh
Created February 6, 2024 17:27
Quick and dirty script to check Have I Been Pwned
#!/bin/bash
echo 'This script checks the HIBP API to see if a password has been breached.'
echo 'Only the first 5 characters of the SHA1 hash of the password leave the device.'
echo
echo -n 'Password: '
read -s password
hash=$(echo -n "$password" | sha1sum | cut -c 1-40)
@cmbuckley
cmbuckley / stack-streak.js
Last active January 18, 2023 11:58
How close am I to the Fanatic badge on Stack Overflow?
$.get('/users/daily-site-access/' + StackExchange.options.user.userId, t => {
eval(t.match(/var visited = {.+};/)[0]);
const firstYear = Object.keys(visited)[0],
firstMonth = Object.keys(visited[firstYear])[0],
firstDay = Object.keys(visited[firstYear][firstMonth])[0],
date = new Date(firstYear, firstMonth - 1, firstDay),
today = Date.now();
let days = [], seq = 0, streaks = [0], fewest = 100, fewestDate;
do {
days[++seq] = !!visited[date.getFullYear()][date.getMonth() + 1][date.getDate()];
const config = {
'source.email@gmail.com': {
prefix: 'Source',
color: CalendarApp.EventColor.PALE_RED,
visibility: 'private'
},
};
function onCalendarChanged(trigger) {
copyEvents(trigger.calendarId);
@cmbuckley
cmbuckley / 617179.php
Last active September 29, 2022 00:39
<?php
$headers = [
"Content-Security-Policy: style-src 'self'",
"Content-Type: application/json",
];
foreach ($headers as $header) {
header($header);
}
@cmbuckley
cmbuckley / amazon-cards.bookmarklet.js
Created December 14, 2021 00:43
Amazon Cards Bookmarklet
javascript:(function (doc) {
let cards = {
1111: 'Card #1',
2222: 'Card #2',
};
doc.querySelectorAll('[data-number]').forEach(function (card) {
card.parentNode.querySelector('span').innerText = cards[card.dataset.number]);
});
})(document);
tell application "Photos"
activate
set folderList to name of every folder
set selectedFolders to choose from list folderList with prompt "Select folders:" with multiple selections allowed
set destination to POSIX path of (choose folder with prompt "Please select a backup location:")
repeat with f in folders
if selectedFolders contains name of f then
my exportFolder(f, destination)
end if
@cmbuckley
cmbuckley / .gitattributes
Last active December 7, 2021 21:11
Using gron as an external git diff driver
*.json diff=gron
@cmbuckley
cmbuckley / tools.md
Last active February 11, 2021 21:35
Tools I use and sometimes forget the name
@cmbuckley
cmbuckley / lockdown.json
Last active October 22, 2020 14:16
Match postcode to COVID lockdown key points
{
"E92000001": {
"country_or_area": "England",
"council": 0,
"wards": 0,
"postcodes": 0,
"full_or_partial": "F",
"key_points": "Your area is under Covid restrictions, in the Tier 1 (medium alert) category for England.",
"meeting_friends_and_family": "* You can mix socially in a group of up to six people from multiple households. This includes children and applies indoors and outdoors, including private homes. \n* Socialising in larger groups is against the law, with fines up to £6,400.\n* There are exceptions, for example if your household or support bubble is larger than six, or if someone enters your house to carry out work, registered childcare or care for a vulnerable person.\n",