Skip to content

Instantly share code, notes, and snippets.

View trishume's full-sized avatar

Tristan Hume trishume

View GitHub Profile
nix-path () {
nix-instantiate --eval --expr 'with import <nixpkgs> {}; "${'"$1"'}"' | sed 's/"//g'
}
$ nix-path xorg.libX11
/nix/store/qyf0r9vfqyybdwjmrngy0k44gl4607nk-libX11-1.6.3-dev
@mbbx6spp
mbbx6spp / lstnix.sty
Created October 1, 2016 03:05
First effort at writing a Nix lstlisting language definition.
\definecolor{identifiercolor}{rgb}{0.8,0.6,0.9}
\definecolor{keywordcolor}{rgb}{0.6,0.9,0.6}
\definecolor{commentcolor}{rgb}{0.8,0.8,0.9}
\definecolor{stringcolor}{rgb}{0.5,0.6,0.9}
\lstdefinelanguage{Nix}{
% Anything betweeen $ becomes LaTeX math mode
mathescape=false,
% Comments may or not include Latex commands
texcl=false,
keywords=[1]{inherit,import,if,then,else,false,true,or,rec,let,in,assert,with},
@sagacity
sagacity / main.rs
Created July 25, 2017 15:46
A draft of the weld component system
use std::collections::HashMap;
use std::rc::Rc;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct Component {
events: HashMap<Event, Box<StateCallback>>,
children: Vec<Component>,
}
@robinst
robinst / gh-releases-to-changelog.sh
Created September 8, 2017 05:49
Commands to help convert GitHub releases to CHANGELOG.md
# Get releases for your repository (change the URL and add user/password if necessary)
# If there's more than one page, you might have to do more requests with `?page=2` etc
curl https://api.github.com/repos/:owner/:repo/releases > releases.json
# Use jq! https://stedolan.github.io/jq/
# "v" is a prefix to strip from the release names, might not be necessary
jq -r '.[] | "## [" + (.name | ltrimstr("v")) + "] - " + .created_at[:10] + "\n" + .body' releases.json >> CHANGELOG.md
# Now edit the CHANGELOG.md, see here: http://keepachangelog.com/en/1.0.0/
// works as of 2019-03-02
(function() {
// This function forces rustdoc to collapse documentation for all items,
// except for the methods defined in an impl block and the primary type's
// declaration. This is the most natural view IMO, since it provides the
// primary type along with an easy to scan overview of available methods.
//
// rustdoc does seemingly have user settings that purport to make this the
// default, but I could never cause them to work in a reliably consistent
// way. This is especially useful when writing documents, where you commonly
@nathansobo
nathansobo / log-linear-goto-intuition.md
Last active June 27, 2019 08:11
Intuition for `merge_op` in Raph Levein's GOTO implementation

When merging an operation O, there may be several operations scattered through the local history that are concurrent to O. We need to rearrange our history so that all of these concurrent operations are moved to the end of the history. Then we can transform O against each of these concurrent operations and append it to the end.

Say we're adding O a history with the following suffix. The operations surrounded by vertical bars are concurrent to O. Otherwise the operations causally precede O.

EO0 |EO1| EO2 EO3 |EO4| |EO5| EO6

We need to rearrange this history so it looks like this.

---- On Ryzen 3950X
SimpleProf :seconds calls count : clk/call clk/count
search_one : 0.3081 1 8388480 : 1078358365.0 128.55
search_one_pf : 0.3415 1 8388480 : 1195232920.0 142.49 <-- speculative prefetching (next options for L and R)
search_multi2 : 0.3062 1 8388480 : 1071663705.0 127.75
search_multi4 : 0.2454 1 8388480 : 859008465.0 102.40
search_multi8 : 0.2113 1 8388480 : 739533515.0 88.16
search_multi16 : 0.1996 1 8388480 : 698443550.0 83.26
search_multi32 : 0.1785 1 8388480 : 624785840.0 74.48
@CedricGuillemet
CedricGuillemet / YAP.h
Last active December 17, 2020 01:02
Yet Another Profiler
#pragma once
/*
_____.___. __ __ .__
\__ | | ____ _/ |_ _____ ____ ____ _/ |_ | |__ ____ _______
/ | |_/ __ \ \ __\ \__ \ / \ / _ \ \ __\| | \ _/ __ \ \_ __ \
\____ |\ ___/ | | / __ \_| | \( <_> ) | | | Y \\ ___/ | | \/
/ ______| \___ > |__| (____ /|___| / \____/ |__| |___| / \___ > |__|
\/ \/ \/ \/ \/ \/
__________ _____ .__ .__
@genekogan
genekogan / _Instructions.md
Last active March 5, 2021 13:10
instructions for generating a style transfer animation from a video

Instructions for making a Neural-Style movie

The following instructions are for creating your own animations using the style transfer technique described by Gatys, Ecker, and Bethge, and implemented by Justin Johnson. To see an example of such an animation, see this video of Alice in Wonderland re-styled by 17 paintings.

Setting up the environment

The easiest way to set up the environment is to simply load Samim's a pre-built Terminal.com snap or use another cloud service like Amazon EC2. Unfortunately the g2.2xlarge GPU instances cost $0.99 per hour, and depending on parameters selected, it may take 10-15 minutes to produce a 512px-wide image, so it can cost $2-3 to generate 1 sec of video at 12fps.

If you do load the

@BenjaminPoilve
BenjaminPoilve / eyeTrack.py
Created August 22, 2016 08:45
Fabian Timm eye center location algorithm in python
import operator
import numpy as np
import math
import cv2
from config import config
kGradientThreshold = 10.0
kWeightBlurSize = 5;
maxEyeSize=8;