Skip to content

Instantly share code, notes, and snippets.

💁

Tycho Grouwstra tycho01

💁
Block or report user

Report or block tycho01

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tycho01
tycho01 / ecosia-vim.user.js
Last active Nov 13, 2019
*monkey userscript: DDG-like Vim keybindings for Ecosia
View ecosia-vim.user.js
// ==UserScript==
// @name DDG-like Vim keybindings for Ecosia
// @namespace https://gist.github.com/tycho01/f5d319a89d0c21ebcdae94f68b6bf604
// @version 0.03
// @description plants trees while navigating search results by keyboard!
// @author tycho01
// @match https://www.ecosia.org/search?*
// @grant none
// @esversion 6
// ==/UserScript==
@tycho01
tycho01 / crop.sh
Created Jun 23, 2019
crop images to printing aspect ratio
View crop.sh
# for landscape pics
for f in *.*; do
echo $f
convert $f -gravity center -crop 1.41421356237:1 +repage crop_$f
done
# for portrait pics
for f in *.*; do
echo $f
convert $f -gravity center -crop 1:1.41421356237 +repage crop_$f
@tycho01
tycho01 / arch.sh
Last active Sep 13, 2019
Arch install notes
View arch.sh
# follow https://www.addictivetips.com/ubuntu-linux-tips/how-to-install-arch-linux/, except:
# - use `/dev/sdb`
# - let ext4 get 100%, not swap
# - ditch grub for systemd-boot, see https://www.addictivetips.com/ubuntu-linux-tips/set-up-systemd-boot-on-arch-linux/
# - in install step swap `xorg-server-utils` for `xorg-apps` -- just in case also install `dialog` and `wpa_supplicant`
# also see: https://wiki.archlinux.org/index.php/Installation_guide
# bluetooth
sudo pacman -S bluez bluez-utils
systemctl enable bluetooth
@tycho01
tycho01 / pull-forks.js
Last active May 12, 2019
pull github forks
View pull-forks.js
// https://github.com/uvadlc/uvadlc_practicals_2019/network/members
// paste in JS console to get `git remote add` commands
[...document.getElementsByClassName('repo')].splice(1).map(x => {
repo = x.children[3].getAttribute('href').substr(1);
user = repo.split('/')[0];
return `git remote add ${user} git@github.com:${repo}.git`;
}).join('\n')
// run that at your repo, then `git pull --all`
@tycho01
tycho01 / hardware-configuration.nix
Created Mar 9, 2019
NixOS hardware configuration backup
View hardware-configuration.nix
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
imports =
[ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];
@tycho01
tycho01 / quantum.m
Last active Feb 17, 2019
octave snippets for UvA course quantum computing
View quantum.m
# unitaries/gates: input |row>, output |col>
half = 1/sqrt(2);
X = [0 1; 1 0];
Z = [1 0; 0 -1];
H = half * [1 1; 1 -1];
R = @(phi) [1 0; 0 e^(phi*i)];
T = R(pi/4);
function ret = controlled(U)
@tycho01
tycho01 / studentenwoningweb.js
Last active Feb 21, 2019
ramda.js snippet to filter json results from studentenwoningweb
View studentenwoningweb.js
// https://ramdajs.com/docs/dist/ramda.js
// convert degrees to radians
var deg2rad = (deg) => deg * (Math.PI/180);
// calculate distance to my university for a lat-long point using the Haversine formula
var dist = R.curry((lat1,lon1,lat2,lon2) => {
var R = 6371; // Radius of the earth in km
var dLat = deg2rad(lat2-lat1); // deg2rad below
var dLon = deg2rad(lon2-lon1);
@tycho01
tycho01 / 1000-sudokus.txt
Last active Feb 22, 2019
UvA 2019 Knowledge Representation sudoku data
View 1000-sudokus.txt
.94...13..............76..2.8..1.....32.........2...6.....5.4.......8..7..63.4..8
............942.8.16.....29........89.6.....14..25......4.......2...8.9..5....7..
.....7....9...1.......45..6....2.....36...41.5.....8.9........4....18....815...32
.5247.....6............8.1.4.......97..95.....2..4..3....8...9......37.6....91...
.9.........1..6....6..8..7.3......1.....39.......5...217.4...28.....3....86....57
.....5....2...4.1..3..8..2......84..8..6......9..1.7.5..6......95...3.6...3.....1
5...68..........6..42.5.......8..9....1....4.9.3...62.7....1..9..42....3.8.......
.7..21..4....3....6.1.....2.......6...86..7.319.....4..1....2.842.9..............
........1..7.5.3.9..48...2...........3...57....942.........3.....1...4.7.6.278...
.....8..3.16.2.9.7.3...46...........9.5...2...2.13...9..3....2..7...5.........4..
View BentCigarFunction.java
import java.util.Properties;
import javabbob.JNIfgeneric;
import javabbob.JNIfgeneric.Params;
import org.vu.contest.ContestEvaluation;
public class BentCigarFunction implements ContestEvaluation {
private static final int EVALS_LIMIT_ = 10000;
private static final int bbobid_ = 12;
private static final double BASE_ = 9273454.0 D;
private JNIfgeneric function_ = null;
View gist:07c2e9d6f48baf377db9a17de8044dad
// let R = import 'ramdajs';
// either install ramda library first or run at https://ramdajs.com/docs/ or https://npm.runkit.com/ramda
let prisonersDilemma = (a_coop = true, b_coop = true) =>
(a_coop && b_coop) ? [-1, -1] :
(!a_coop && !b_coop) ? [-2, -2] :
(a_coop) ? [-3, 0] : [0, -3];
let niceAgent = () => true;
You can’t perform that action at this time.