Skip to content

Instantly share code, notes, and snippets.

@homburg
homburg / venv.sh
Created April 18, 2013 11:07
Generic virtual environment
#!/usr/bin/env bash
echo "*** Remeber to call this with source ***"
echo "Activating \"virtual environment\" (modifying PATH).
Use \"deactivate\" to escape"
function deactivate () {
PS1=$_OLD_PS1
PATH=$_OLD_PATH
@homburg
homburg / gist:5807786
Created June 18, 2013 18:04
Google spreadsheets scripting: search/replace hyperlinks
function MogensHyperlinkOffset() {
var sheet = SpreadsheetApp.getActiveSheet();
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ranges = ["M:M", "Q:Q"];
var totalCells = 0;
for (var r in ranges) {
ss.toast("Running range: "+ranges[r])
var dRange = sheet.getRange(ranges[r])
@homburg
homburg / nginx-proxy
Created April 29, 2014 11:38
Minimal nginx proxy setup with forced ssl
server {
listen 80;
server_name some-service.example.org;
location / {
rewrite ^(.*)$ https://some-service.example.org$1 permanent;
}
}
server {
@homburg
homburg / my-go-service.conf
Last active January 4, 2019 21:09
Golang upstart init script (from githbucket.org/kardianos/service)
# /etc/init/my-go-service.conf
# My go service
description "My go service"
env DAEMON=/usr/local/bin/my-go-service
env NAME=my-go-service
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
@homburg
homburg / playbook-book.yml
Last active August 29, 2015 14:01
Ansible command line booleans
---
- hosts: all
vars:
docker: 0
tasks:
- name: ensure bool variables work
debug: msg="docker {{ docker }}.."
# When: takes a jinja2 expression
# 0 evaluates to false
# >= 1 evaluates to true
@homburg
homburg / git-get
Last active August 29, 2015 14:05
git clone to home dir + repo path
#!/usr/bin/env python
import os, sys, errno
if len(sys.argv) <= 1:
os.execlp("git", "git")
repo = str(sys.argv[-1])
if repo.endswith(".git"):
repo = repo[:-4]
@homburg
homburg / maybe-pager.go
Created November 3, 2014 21:55
Pager pipe (like git)
package main
// From
// http://stackoverflow.com/questions/21738674/how-do-i-print-a-buffer-to-stdout-piped-through-a-pager
// http://rosettacode.org/wiki/Terminal_control/Dimensions
import (
"bufio"
"io"
"os"
"os/exec"
@homburg
homburg / keybase.md
Created March 7, 2015 09:28
keybase.md

Keybase proof

I hereby claim:

  • I am homburg on github.
  • I am homburg (https://keybase.io/homburg) on keybase.
  • I have a public key whose fingerprint is 99EF C7E0 5AFB 2375 33E9 7F45 5235 277B C827 0040

To claim this, I am signing this object:

@homburg
homburg / Counter.elm
Created March 21, 2016 13:43
Elm compiler misleading error
module Counter where
import Html exposing (..)
import Html.Attributes exposing (style)
import Html.Events exposing (onClick)
-- MODEL
type alias Model = Int
@homburg
homburg / dk
Last active March 25, 2018 16:07
Ubuntu custom keyboard layout
# Custom layout
# Add to /usr/share/X11/xkb/symbols/dk
partial alphanumeric_keys
xkb_symbols "custom" {
include "dk(basic)"
name[Group1]="Danish (custom)";
key <TLDE> { [ dollar, asciitilde, threequartes, paragraph ] };