Skip to content

Instantly share code, notes, and snippets.

View redirectors.json
{
"createdBy": "Redirector v3.5.3",
"createdAt": "2021-10-16T12:28:52.532Z",
"redirects": [
{
"description": "Medium -> Scribe",
"exampleUrl": "https://medium.com/@user/post-123456abcdef",
"exampleResult": "https://scribe.rip/@user/post-123456abcdef",
"error": null,
"includePattern": " *medium.com/(.*)",
@patricksimpson
patricksimpson / static-search.js
Created Jan 14, 2019
A little search for static sites, using Lunr.js!
View static-search.js
(function() {
if (window.fetch) {
let searchPage = document.querySelector('.search-body');
if (searchPage) {
let addLunr = document.createElement('script');
addLunr.src = '/static/js/lunr.js';
document.body.appendChild(addLunr);
addLunr.onload = function() {
fetch('/lunr.json').then(function(response) {
return response.json();
View simple-pack.sh
#!/bin/sh
dir=app
files=*.js
output=dist.js
find $dir/$files -exec cat {} \; > $output
while true; do
watch -d -g ls -lR $dir/$files
@patricksimpson
patricksimpson / module.js
Last active Apr 16, 2020
JavaScript Design Patterns
View module.js
var options = {
username: 'blah',
server: '127.0.0.1'
};
var ConfigObject = (function(params) {
var username = params.username || '',
server = params.server || '',
password = params.password || '';
View .xmodmap
! undo any meta keys already set
clear Mod1
! keycodes 63 and 71 are the left and right COMMAND buttons adjacent to the spacebar; set them to be control keys
keycode 63 = Control_L
keycode 71 = Control_R
! keycodes 66 and 69 are the option/alt keys; assign them as Meta keys
keycode 66 = Escape NoSymbol Escape
keycode 69 = Meta_R
View keyboard-xmod
xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
xmodmap -e "keycode 133 = Alt_L"
xmodmap -e "keycode 37 = Control_L"
xmodmap -e "keycode 64 = Control_L"
View gist:717b92bae64b1318b669758f1175c532
{
"name": "test",
"version": "1.0.0",
"description": "Hello.",
"main": "index.js",
"scripts": {
"cachebust": "cachebust"
},
"author": "",
"license": "ISC",
View backup-script
#!/usr/bin/env ruby
$prefix = 'com.apple.TimeMachine.'
$host = 'rsync'
$repo = 'laptop'
# Where the snapshot will be mounted.
$mount = "#{Dir.home}/borg"
$ref_file = "#{Dir.home}/.borg-snapshot"
# Define exclusions here.
# https://borgbackup.readthedocs.io/en/latest/usage/help.html#borg-help-patterns
$exclude_file = "#{Dir.home}/.borg-exclude.txt"
View add.js
function add(x, y) {
while (y != 0) {
carry = x & y;
x = x ^ y;
y = carry << 1;
}
return x;
}