Skip to content

Instantly share code, notes, and snippets.


Ole Jørgen Brønner olejorgenb

View GitHub Profile
olejorgenb /
Last active Sep 13, 2018 — forked from aherrmann/
Fully persistent Nix shell
#!/usr/bin/env bash
# This is free and unencumbered software released into the public domain.
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
olejorgenb / nix-shell-env.el
Last active Jan 30, 2017
Misc code for using emacsclient with nix-shell
View nix-shell-env.el
(defun nix-shell-c-system-header-paths ()
"Extract header search paths from the NIX_CFLAGS_COMPILE env variable"
(cl-labels ((every-other (li &optional pick)
(when li
(if pick
(cons (car li) (every-other (cdr li)))
(every-other (cdr li) (not pick))))
(let* ((cflags (getenv "NIX_CFLAGS_COMPILE")))
olejorgenb / configure-thinkpad-pointer.zsh
Created Dec 24, 2016
Thinkpad trackpoint configuration
View configure-thinkpad-pointer.zsh
#!/usr/bin/env zsh
### Thinkpad x220 config
xinput disable "SynPS/2 Synaptics TouchPad"
# Doc:
TP="TPPS/2 IBM TrackPoint"
olejorgenb / snippet.el
Created Nov 26, 2016
Highlight symbol at point on mouse click (emacs)
View snippet.el
;; Only tested with spacemacs
(defvar my-current-focus-symbol nil)
(make-variable-buffer-local 'my-current-focus-symbol)
(defvar my-focus-symbol-face 'hi-yellow)
(defun mouse-set-point-and-hl-symbol (event)
(interactive "e")
(mouse-set-point event)
;; Evil workaround crap (without this every other click visual state is activated...)
olejorgenb /
Last active Nov 25, 2016
Messy code that renders GIZA+ word alignments to latex
#!/usr/bin/env python3
# Requires the following preamble:
preamle = r"""
\usepackage{rotating} %% rotated column labels
\usepackage{colortbl} %% Colored cells
\usepackage{hhline} %% Borders that play nice with colortbl
olejorgenb / main.js
Created Nov 25, 2016
Simple webextension to include the show/movie title in the netflix tab title
View main.js
function expectOne(array) {
if(array.length === 1)
return array[0];
throw new Error("Expected one element, got " + array.length);
function findMediaTitle() {
var bag = expectOne(document.getElementsByClassName("playback-longpause-container"));
olejorgenb / propagatedPython.nix
Created Aug 12, 2016
Find python packages that are likely to fail when used through "nix-shell -p"
View propagatedPython.nix
with builtins;
# evaluate expr, returning default on error
tryDefault = expr: default:
let res = (tryEval expr);
in if res.success then res.value else default;
isPython = pkg: pkg?name && (parseDrvName == "python";
hasPropagatedPython = pkg:
olejorgenb / nix-defexpr.zsh
Created Jun 25, 2016
nix-env "default nix expression" / "active nix expression" / top-level
View nix-defexpr.zsh
_nix_build_defexpr () {
local -a result
local -a queue=($1)
setopt local_options null_glob
while [[ ${#queue} > 0 ]]; do
local current=$queue[1]
shift queue
if [[ -e $current/default.nix ]]; then