Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick patricksimpson

View GitHub Profile
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
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;
}
View DataStructures.md

Data Structures

Linked List

  • A Linked List is a linear collection of data elements, called nodes, each pointing to the next node by means of a pointer. It is a data structure consisting of a group of nodes which together represent a sequence.
  • Singly-linked list: linked list in which each node points to the next node and the last node points to null
  • Doubly-linked list: linked list in which each node has two pointers, p and n, such that p points to the previous node and n points to the next node; the last node's n pointer points to null
  • Circular-linked list: linked list in which each node points to the next node and the last node points back to the first node
  • Time Complexity:
    • Access: O(n)
@patricksimpson
patricksimpson / carExpert.js
Last active Feb 13, 2019
Car Expert - Decision Tree
View carExpert.js
/*
* key: 'unqiue_key'
question: 'string',
responses: [{
response: 'positive',
answer: 'battery_terminal'
}],
*/
const carExpert = [{
key: 'start',
@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();
You can’t perform that action at this time.