Skip to content

Instantly share code, notes, and snippets.

View jonhoo's full-sized avatar
🤦‍♂️
Permanent 418 status code.

Jon Gjengset jonhoo

🤦‍♂️
Permanent 418 status code.
View GitHub Profile
#!/bin/bash
dry=0
if [[ $# -gt 0 && $1 == "-n" ]]; then
dry=1
shift
fi
prefix="v"
if [[ $# -gt 0 ]]; then
if [[ $1 = -* || $# -gt 1 ]]; then
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
@jonhoo
jonhoo / discord-legibility.css
Last active July 6, 2018 16:31
Stylesheet for making Discord Light at least somewhat easier to read
.message-group .comment .markup, .chat {
color: inherit;
}
.message-group.compact .message .timestamp {
color: #555;
float: right;
}
.reaction .reaction-count {
color: inherit;
@progandy
progandy / PKGBUILD
Last active March 6, 2024 17:51
Minimal MPRIS2 support for mpv
# PKGBUILD for lua52-lgi
# Maintainer: NONE
# lua-lgi Maintainer: speps <speps at aur dot archlinux dot org>
# lua-lgi Maintainer: Sébastien Luttringer
_pkgbase=lgi
pkgname=lua52-lgi
pkgver=0.9.1
pkgrel=1
pkgdesc='Lua 5.2 bindings for gnome/gobject using gobject-introspection library'
anonymous
anonymous / playground.rs
Created April 6, 2016 16:26
Shared via Rust Playground
//! This code demonstrates a data flow-like programming pattern, in which each
//! vertex of a DAG is associated with a long-running thead. The vertices
//! forward information along the edges, and the leaves just print out any data
//! they see. In this example, the vertices perform no computation, whereas
//! normally they would.
use std::thread;
use std::sync;
use std::sync::mpsc;
use std::collections::HashMap;
@jonhoo
jonhoo / go-test-many.sh
Last active November 12, 2024 16:18
Script for running go tests many times in parallel, printing the current status, and logging errors
#!/bin/bash
#
# Script for running `go test` a bunch of times, in parallel, storing the test
# output as you go, and showing a nice status output telling you how you're
# doing.
#
# Normally, you should be able to execute this script with
#
# ./go-test-many.sh
#
@jonhoo
jonhoo / README.md
Created April 15, 2015 21:06
Go slices and `interface{}`s

When passing Go slices through interface{} values, beware that this slows your application down. If possible, you should instead be passing around pointers to slices, and dereference them after the cast:

$ go test -c
$ ./x.test -test.bench . -test.run Benchmark -test.benchtime 3s
BenchmarkInterfaceSlice		30000000	        148 ns/op
BenchmarkInterfaceSlicePtr	300000000	       14.0 ns/op
$ go tool pprof -text -cum x.test slice.out | grep -vE 'testing|goexit|Benchmark'
4420ms of 4610ms total (95.88%)
Dropped 16 nodes (cum <= 23.05ms)
@jonhoo
jonhoo / README.md
Created January 8, 2015 22:50
Plot commit activity across all local git repositories

These scripts will find all git repositories on the local machine, find all commits made by some user (specified as arguments to find-commits), and plot the number of commits, lines added, and lines removed over time. Commits that add or remove over 10000 lines will be ignored (for huge data files and such).

To run:

$ ./find-commits.sh [email protected] [email protected] > commits.txt
$ cat commits.txt | ./draw-commits.sh
@Kroc
Kroc / domtemplate.php
Created January 4, 2012 14:55
DOM Template Class
<?php
//DOM Templating classes v7 © copyright (cc-by) Kroc Camen 2012
//you may do whatever you want with this code as long as you give credit
//documentation at http://camendesign.com/dom_templating
class DOMTemplate extends DOMTemplateNode {
private $DOMDocument;
private $keep_prolog = false;
@gf3
gf3 / ago.js
Created June 2, 2011 18:43
Super small relative dates
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }