Skip to content

Instantly share code, notes, and snippets.

@gauteh
gauteh / .gitconfig
Created August 23, 2013 10:49
Command/alias for setting up branches for pull requests for a github repository: In a github cloned repository do ```$ git pullify```. Now pull requests can be accessed through origin/pr/#
[alias]
pullify = config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
# /bin/bash
#
# Makes a sparsebundle and set it up
hostname=$(hostname)
# create sparsebundle
hdiutil create -size 300g -library SPUD -fs HFS+J -type SPARSEBUNDLE -volname "Backup-${hostname}" "${hostname}.sparsebundle"
# enable unsupported volumes
@gauteh
gauteh / startify-favex.vim
Last active August 8, 2016 08:30
show favex entries in startify
" Bookmarks and FavEx: combining startify and FavEx
let g:startify_bookmarks = []
" \ '~/.vim/vimrc',
" \ ]
for line in readfile (expand('~/.vim/bundle/FavEx/favlist'))
if line !~ '\"' && line != ""
call add (g:startify_bookmarks, line)
endif
endfor
#! /usr/bin/python
#
# Author: Gaute Hope <eg@gaute.vetsj.com> / 2016-08-12
#
# Find all substrings in a string with the number of occurences of a set of
# characters pre-defined.
#
# A prime number is assigned to each character in the key set, all other
# characters are assigned 1. The product of the key set will match the product
# of the substring. Search the string with a running product to find substring
#! /bin/bash
#
# do a quick check if there are new messages in a gmail account
#
# based on: http://cpbl.wordpress.com/2011/11/16/how-to-alpine-maildir-offlineimap/
#
# Gaute Hope / 2013-12-13 / eg@gaute.vetsj.com
#
# requires: curl
#
@gauteh
gauteh / onchange.sh
Created June 7, 2017 08:34 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <senko.rasic@dobarkod.hr>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@gauteh
gauteh / github-thread.py
Last active October 17, 2017 10:53
Open GitHub issue from Notmuch thread or Message ID
#! /usr/bin/env python
#
# Author: Gaute Hope <eg@gaute.vetsj.com> / 2017-10-08
import os, sys, os.path
import subprocess
import notmuch
import email
import email.parser
import email.policy
" ----------------------------------------------------------------------------
" DiffRev
" ----------------------------------------------------------------------------
let s:git_status_dictionary = {
\ "A": "Added",
\ "B": "Broken",
\ "C": "Copied",
\ "D": "Deleted",
\ "M": "Modified",
\ "R": "Renamed",
@gauteh
gauteh / crypttest.cs
Last active October 7, 2019 09:30
Demonstrates how to serialize and encrypt any object in C#
/*
* crypttest.cs: Demonstrates how to serialize and encrypt any object
*
* Gaute Hope <eg@gaute.vetsj.com>
*
* To deserialize it you need to know the unencrypted serialized length.
* So to store or send also pass the length, e.g. create a struct like this:
*
* public struct EncryptedObject {
* public int length;
#! bash
#
# From: https://askubuntu.com/a/985386
echo -e '\e[1mbold\e[22m'
echo -e '\e[2mdim\e[22m'
echo -e '\e[3mitalic\e[23m'
echo -e '\e[4munderline\e[24m'
echo -e '\e[4:1mthis is also underline (new in 0.52)\e[4:0m'
echo -e '\e[21mdouble underline (new in 0.52)\e[24m'
echo -e '\e[4:2mthis is also double underline (new in 0.52)\e[4:0m'