Skip to content

Instantly share code, notes, and snippets.

View themadsens's full-sized avatar

Flemming Madsen themadsens

View GitHub Profile
@themadsens
themadsens / tmux-cheatsheet.markdown
Created September 27, 2015 16:21 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@themadsens
themadsens / tmux.md
Created September 28, 2015 14:38 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@themadsens
themadsens / gkermit-progress.patch
Created February 29, 2016 14:56
PATCH: gkermit progress meter
Up for grabs:
gkermit progress meter
diff -u -ur org/gkermit.c ./gkermit.c
--- org/gkermit.c 1999-12-27 03:11:19.000000000 +0100
+++ ./gkermit.c 2016-02-29 15:45:29.000000000 +0100
@@ -89,6 +89,10 @@
int recvtype = 0; /* Type of last packet received */
int datalen = 0; /* Length of received data field */
@themadsens
themadsens / jsonvis.sh
Created April 29, 2016 07:39
Visualize / inspect json files in your browsers devtools
#!/bin/bash
if [[ $# -lt 1 ]] ;then
echo "Inspect json files in your browsers devtools"
echo "Usage: jsonvis <file>"
exit
fi
( printf "console.log('FILE: $1\134n-----------\134n', "; cat $1 ; echo ");" ) > /tmp/jsonvis.js
cat << EOF > /tmp/jsonvis.html
@themadsens
themadsens / pathogen-update.sh
Last active May 2, 2016 10:03
Put this in your .vim dir to maintain a list of vim plugins with pathogen
#!/bin/bash
mkdir -p bundle
cd bundle
# Maintain your list of plugins here
(cat << EOF
https://github.com/vim-scripts/matchit.zip
https://github.com/JalaiAmitahl/maven-compiler.vim
https://github.com/junegunn/vim-easy-align
EOF
) | \
@themadsens
themadsens / 256-colors.js
Last active October 13, 2016 06:19
Demonstrate generators in my fav scripting engines
#!/usr/bin/env node --harmony
// jshint esversion: 6
// ported to Node from https://gist.github.com/graven/921334
// Demonstrate using es6 generators
// console.log("color indexes should be drawn in bold text of the same color.\n");
function pad(elm, len, base) {
let str = base ? elm.toString(base) : elm;
let padding = base ? "00000000000000000000" : " ";
return str.length >= len ? str : (padding+str).substr(0-len);
@themadsens
themadsens / v_u.vim
Created July 8, 2016 11:25
Vim visual u disaster prevention. For when you spent a few hours cleaning up the mess after an accidental 'u' that went unnoticed for a while (until build!) ..
" Disaster prevention
vmap u <Esc>
vmap U <Esc>
vnoremap gu u
vnoremap gU U
@themadsens
themadsens / JumpBuffers.vim
Last active July 22, 2016 11:59
In vim, show a list of recent buffers to jump to. List is created from the jumplist
function! JumpBuffers()
let jumptxt = ""
redir! => jumptxt
silent jumps
redir END
let byName = {}
let byIndex = []
for line in reverse(split(jumptxt, '\n'))
let name = strpart(line, 16)
let bufno = bufnr(name)
/**
* A function for converting hex <-> dec w/o loss of precision.
*
* The problem is that parseInt("0x12345...") isn't precise enough to convert
* 64-bit integers correctly.
*
* Internally, this uses arrays to encode decimal digits starting with the least
* significant:
* 8 = [8]
* 16 = [6, 1]
@themadsens
themadsens / gauge.js
Created September 27, 2016 20:09 — forked from tomerd/gauge.js
google style gauges using javascript d3.js
function Gauge(placeholderName, configuration)
{
this.placeholderName = placeholderName;
var self = this; // for internal d3 functions
this.configure = function(configuration)
{
this.config = configuration;