Skip to content

Instantly share code, notes, and snippets.

View dillonchr's full-sized avatar

Dillon Christensen dillonchr

  • Bixby, OK
View GitHub Profile
@dillonchr
dillonchr / index.js
Last active August 29, 2015 14:06
updating for showing page numbers instead of article number
// old way of doing it
var number = $('<div class="number"></div>');
var articleNumber = i +1;
if(articleNumber < 10) {
number.text('0' + articleNumber);
} else {
number.text(articleNumber);
}
// but instead do this
@dillonchr
dillonchr / rgb2hex.js
Created December 1, 2017 18:11
Javascript snippet collection
export default rgb2hex = rgb => rgb.trim()
.replace(/^rgb\(|\)/g, '')
.split(',')
.reduce((str, v) => str + parseInt(v).toString(16).padLeft(2, '0'), '#');
@dillonchr
dillonchr / converter.js
Last active January 31, 2018 15:00
native unicode emojis css sheet with slack-like names
((items) => {
convertEmoji = str => {
// Converts a string of characters to CSS escapes
// str: sequence of Unicode characters
let highsurrogate, outputString;
highsurrogate = 0;
outputString = '';
for (let i = 0; i < str.length; i++) {
let cc = str.charCodeAt(i);
if (cc < 0 || cc > 0xFFFF) {
@dillonchr
dillonchr / dedupe.js
Created December 14, 2017 21:48
Bitwarden export de-duper
const fs = require('fs');
const rawCsv = fs.readFileSync('export.csv', 'utf8');
const lines = rawCsv.split('\n');
const headers = lines.shift().split(',').map(h => h.trim());
const csv = lines
.map(l => {
const cols = l.split(',').map(c => c.trim());
if (cols.length === headers.length) {
return headers.reduce((obj, h, i) => {
@dillonchr
dillonchr / random-88x31-button.js
Created December 19, 2017 20:56
cool retro button images
// found on http://www.n-sane.net/88x31-buttons.php
// stumbled upon from websitering.neocities.org
const buttonOptions = ["http://www.n-sane.net/88x31-buttons/n-sane-001-1.jpg","http://www.n-sane.net/88x31-buttons/n-sane-001-2.jpg","http://www.n-sane.net/88x31-buttons/n-sane-001-3.jpg","http://www.n-sane.net/88x31-buttons/n-sane-001-4.jpg","http://www.n-sane.net/88x31-buttons/n-sane-001-5.jpg","http://www.n-sane.net/88x31-buttons/n-sane-002-1.jpg","http://www.n-sane.net/88x31-buttons/n-sane-002-2.jpg","http://www.n-sane.net/88x31-buttons/n-sane-002-3.jpg","http://www.n-sane.net/88x31-buttons/n-sane-002-4.jpg","http://www.n-sane.net/88x31-buttons/n-sane-002-5.jpg","http://www.n-sane.net/88x31-buttons/n-sane-003-1.jpg","http://www.n-sane.net/88x31-buttons/n-sane-003-2.jpg","http://www.n-sane.net/88x31-buttons/n-sane-003-3.jpg","http://www.n-sane.net/88x31-buttons/n-sane-003-4.jpg","http://www.n-sane.net/88x31-buttons/n-sane-003-5.jpg","http://www.n-sane.net/88x31-buttons/n-sane-004-1.jpg","http://www.n-sane.
@dillonchr
dillonchr / next-muni.sh
Created August 27, 2019 06:19
When's the next #3 muni?
#!/bin/bash
curl -s http://webservices.nextbus.com/service/publicJSONFeed\?command\=predictions\&a\=sf-muni\&r\=3\&s\=6604 | jq '.predictions.direction.prediction[0].minutes'
@dillonchr
dillonchr / README.md
Created August 29, 2019 05:21 — forked from grantland/README.md
NextBus API
@dillonchr
dillonchr / release_notes.sh
Created September 12, 2019 20:00
release notes based off of git commits
#!/bin/bash
git log --pretty=format:"%cr - %s" --no-merges -7
@dillonchr
dillonchr / mkvjoin.sh
Last active April 2, 2020 00:28
mkv-joiner
#!/bin/bash
if [ -z "$1 " ]
then
today=$(date '+%Y-%m-%d')
else
today=$1
fi
file="$today.txt"
@dillonchr
dillonchr / sweet.spec.js
Created April 4, 2020 03:37
js diagonal sort thingy
const assert = require('assert');
function *sweetFunction(array) {
const colCount = array[0].length;
const rowCount = array.length;
const diagonalCount = 1 << (Math.max(colCount, rowCount) - 1);
for (let d = 0; d <= diagonalCount; ++d) {
const minR = d >= colCount ? d - colCount + 1 : 0;
let r = d < rowCount ? d : rowCount - 1;