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
#!/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
@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'
@jonhoo
jonhoo / go-test-many.sh
Last active October 19, 2023 16:33
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
#
#!/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
@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 }
@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;
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;
@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;
@jonhoo
jonhoo / seriex.markdown
Created November 30, 2010 05:06
A script for automatically give good filenames to TV-series episodes. Requires IMDB::Film >= 0.49
@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)