Skip to content

Instantly share code, notes, and snippets.

View cmbuckley's full-sized avatar

Chris Buckley cmbuckley

View GitHub Profile
@cmbuckley
cmbuckley / mac-mouse-scroll.sh
Last active July 30, 2025 08:15
Natural scrolling on a trackpad, but classic scrolling when a mouse is plugged in
#!/bin/bash
# flip scroll direction based on whether a mouse is plugged in
defaults write -g com.apple.swipescrolldirection -bool $(ioreg -p IOUSB -w0 | grep -q Mouse && echo false || echo true)
const config = {
target: 'Working Locations',
};
// copy working locations and Holiday events to a separate calendar
function syncLocations() {
const targetId = Calendar.CalendarList.list({showHidden: true}).items.find(c => c.summary == config.target).id;
const start = new Date();
start.setDate(start.getDate() - 7);
@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 = {
'[email protected]': {
prefix: 'Source',
color: CalendarApp.EventColor.PALE_RED,
visibility: 'private'
},
'[email protected]': {
target: 'Other Calendar Name',
attendees: false,
prefix: 'Company',
@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