Skip to content

Instantly share code, notes, and snippets.

View kyle-west's full-sized avatar
🍰
Writing code (as always)

Kyle West kyle-west

🍰
Writing code (as always)
View GitHub Profile
const minute = 60;
const hour = minute * 60;
const day = hour * 24;
const week = day * 7;
const month = day * 30;
const year = day * 365;
/**
* Convert a date to a relative time string, such as
* "a minute ago", "in 2 hours", "yesterday", "3 months ago", etc.
@kyle-west
kyle-west / secret-santa.js
Last active December 7, 2023 17:04
Classic Secret Santa Problem in 4 lines. Guarantees mathematically that no one will give to themselves and no two will give to each other.
function secretSanta(...names) {
const randomized = [...names].sort(() => Math.random() - Math.random());
const derrangement = [...randomized]
derrangement.unshift(derrangement.pop()) // shifting ensures a derrangement of the randomized list
return Object.fromEntries(randomized.map((name, idx) => [name, derrangement[idx]]))
}
secretSanta('Alice', 'Bob', 'Carter', 'David', 'Emily')
// { Carter: 'Emily', Bob: 'Carter', David: 'Bob', Alice: 'David', Emily: 'Alice' }
#include <Keyboard.h>
using namespace std;
// you MUST install ArduinoSTL library by Mike Matera
#define KEY_DELAY 200
// pins 2, 3, 4, 5, 6, 7, 8, 9, 10, 16
#define KEY0 2
#define KEY2 3
#define KEY3 4
#define KEY4 5
@kyle-west
kyle-west / co-authored
Created November 27, 2019 16:13
Append a commit message with a "Co-authored-by" message with just a GitHub username
#!/bin/bash
###########################################################################################
# co-authored : append a Co-authored-by message to your commit history with just a username
# co-authored <github-username> [<github-username>...]
###########################################################################################
for coAuthorUsername in $@; do
msg=$(git log --format=%B -n1)
coAuth="Co-authored-by: $(json <(curl -s "https://api.github.com/users/${coAuthorUsername}") $.name) <${coAuthorUsername}@users.noreply.github.com>"
@joeycozza
joeycozza / .gitconfig
Last active April 24, 2019 19:19
Some git aliases I have
[alias]
co = checkout
cob = checkout -b
md = merge develop
cm = commit -a -m
s = status
b = branch
graph = log --graph -100 --branches --remotes --tags --format=format:'%Cgreen%h %Cresetβ€’ %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order
precommit = diff --cached --diff-algorithm=minimal -w
cod = checkout develop
@kyle-west
kyle-west / UncertainValue.py
Created July 19, 2018 21:23
[MATH] Create a value from a random +/- uncertainty which can be treated like a float or integer.
##############################################################################
# @class UncertainValue
# (c) 2018 Kyle West - [email protected]
# MIT License. See: [Licensing Info](https://opensource.org/licenses/MIT)
#
# Create a value from a random +/- uncertainty which can be treated like a
# float or integer.
#
# x = UncertainValue(50, 5) # <--- random sample from 45 to 55.
#
@ebidel
ebidel / wcr_lazyload.html
Created January 21, 2016 18:56
How to use the WebComponentsReady when lazy loading the webcomponents.js polyfills (http://jsbin.com/dihasa/edit?html,output)
<!doctype html>
<html>
<head>
<base href="https://polygit.org/components/">
<!-- <script src="webcomponentsjs/webcomponents-lite.min.js"></script> -->
<link rel="import" href="paper-input/paper-input.html">
<link rel="import" href="paper-button/paper-button.html">
</head>
<body>

This is unmaintained, please visit Ben-PH/spacemacs-cheatsheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window
@rxaviers
rxaviers / gist:7360908
Last active December 10, 2025 16:26
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: πŸ˜„ :smile: πŸ˜† :laughing:
😊 :blush: πŸ˜ƒ :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
πŸ˜† :satisfied: 😁 :grin: πŸ˜‰ :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: πŸ˜€ :grinning:
πŸ˜— :kissing: πŸ˜™ :kissing_smiling_eyes: πŸ˜› :stuck_out_tongue: