Skip to content

Instantly share code, notes, and snippets.

@nijotz
nijotz / .gitconfig
Last active October 23, 2025 16:14
git aliases
[alias]
st = status -sb
me = log --author=Nick
lg = log --pretty=format:'%C(yellow)%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative --graph
lgd = log --pretty=format:'%C(yellow)%h%C(reset) - %C(green)%cd %C(reset)%s %C(cyan)<%an>%C(yellow)%d%C(reset)' --abbrev-commit --graph --date=format:'%Y-%m-%d %a %H:%M'
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /' | sort
@nijotz
nijotz / blame.sh
Created September 26, 2025 20:33
See who has the most typescript errors
while read FILE LINE COL; do git blame -L $LINE,$LINE $FILE | sed -re 's/.*\(([^0-9]*) [0-9].*/\1/'; done < <(npx tsc --noEmit | grep -Po '[^: ]+\([0-9]+,[0-9]+\)' | sed -re 's/\(([0-9]+),([0-9]+)\)/ \1 \2/g') | sort | uniq -c | sort -nr
// cleaner output, but same results without
const Promise = require('bluebird');
// What is the best way to run async functions
// * in parallel
// * fail fast
// * not have unhandled promises
// * single failure path (try/catch)
// ?
function sleepReject(time, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => reject(msg || 'reject'), time);
});
}
async function test() {
try {
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x));
let valuePromises2 = [4000, 5000].map(x => sleepReject(x));
function sleepReject(time, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => reject(msg || 'reject'), time);
});
}
async function test() {
try {
let valuePromises1 = [1000, 2000, 3000].map(x => sleepReject(x));
async function test() {
var p1 = new Promise((resolve, reject) => {
setTimeout(() => reject('one'), 1000);
});
var p2 = new Promise((resolve, reject) => {
setTimeout(() => reject('two'), 2000);
});
var p3 = new Promise((resolve, reject) => {
setTimeout(() => reject('three'), 3000);
});
@nijotz
nijotz / DiscoStrobe.ino
Created August 13, 2016 06:03 — forked from kriegsman/DiscoStrobe.ino
DiscoStrobe - Flashing rainbow lights that zoom back and forth to a beat
#include "FastLED.h"
// DiscoStrobe
// *Flashing* rainbow lights that zoom back and forth to a beat.
// See your doctor before using this code if you have certain neurological conditions.
//
// Mark Kriegsman, July 2015
#if FASTLED_VERSION < 3001000
@nijotz
nijotz / lolbow.txt
Created June 9, 2016 19:08
LOLBOW winners
[4800x0C:07:19nick@nijotz~/.weechat/logs]$ grep -B1 LOLBOW irc.freenode.#infoforcefeed.weechatlog | grep -Ev '(LOLBOW|--)' | awk '{print $3}' | sort | uniq -c | sort -nr
24 cblgh
17 nijotz
17 jnerula
14 Pilate
12 trinque
11 vhost-
11 uptime
11 ben_vulpes
9 lykkin
@nijotz
nijotz / tensorflow2.py
Created April 3, 2016 21:18
Deep MNIST
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape):
@nijotz
nijotz / tensorflow.py
Last active April 3, 2016 20:43
Handwritten digit analysis
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
# 784 pixels (28 x 28 pixel images), 10 possibile outputs
x = tf.placeholder(tf.float32, [None, 784]) # placeholder
W = tf.Variable(tf.zeros([784, 10])) # weights
b = tf.Variable(tf.zeros([10])) # biases