Skip to content

Instantly share code, notes, and snippets.

@nnutter
nnutter / tm.sh
Last active August 29, 2015 14:01
_tm_complete() {
COMPREPLY=()
local SESSIONS=$(tmux list-sessions | cut -f 1 -d :)
if [ ${#COMP_WORDS[@]} -eq 2 ]; then
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W "$SESSIONS" -- $cur))
fi
}
complete -F _tm_complete tm
_tm_complete() {
local rx
local token=${COMP_WORDS[$COMP_CWORD]}
local IFS=$'\t'
local words
if [ $COMP_CWORD -eq 1 ]; then
words=$(tmux -q list-sessions 2> /dev/null | cut -f 1 -d ':' | tr "\n" " " | sed 's/ $//')
fi
if [ $COMP_CWORD -eq 2 ]; then
words=$(tmux list-windows -t ${COMP_WORDS[1]} 2> /dev/null | awk '{print $2}' | tr -d '*-' | tr "\n" " " | sed 's/ $//')
@nnutter
nnutter / tmux.bash
Last active August 29, 2015 14:01 — forked from ttscoff/tm.bash
# Brett Terpstra 2014
# <http://brettterpstra.com>
#
# tmux wrapper
# tm session-name [window-name]
# Names can be partial from the beginning and first match will connect.
# If no match is found a new session will be created.
# If there's a second argument, it will be used to attach directly to a
# window in the session, or to name the first window in a new session.
tm() {
package Sorter;
use strict;
use warnings;
my @chromosome = (1..22, 'X', 'Y', 'MT');
# don't leave it up to humans unless you need to!
sub index_of {
my $i = 0;
@nnutter
nnutter / gist:65b454bc7df9f2b6bffd
Created July 2, 2014 01:45
Pointers vs. References

I translated the Go example to Perl by making simple syntax transformations:

  • Printing is done with say instead of fmt.Println.
  • Variables have a sigil that define their "type", for example, $a instead of a.
  • Address of a variable is return with \ instead of &.
  • References/Pointers are dereferenced with $ instead of *.
  • Comments are made with # instead of //.
  • Perl requires semicolons.

Here's the program:

use strict;
use warnings;
use Genome;
use Devel::Size qw(size total_size);
use List::Util qw(sum);
use Scalar::Util qw(weaken);
my $list = [];
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'genome/ubuntu-lucid-puppet'
config.vm.hostname = 'localhost'
@nnutter
nnutter / about.md
Created August 27, 2011 17:28 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@nnutter
nnutter / post-receive.sh
Created June 24, 2012 06:26
Git Post-Receive Hook to Deploy Code to a Working Directory
#!/bin/sh
read OLDREV NEWREV REFNAME
BRANCHNAME=${REFNAME#refs/heads/}
export GIT_WORK_TREE=$HOME/deploy/genome/$BRANCHNAME
mkdir -p $GIT_WORK_TREE
echo "Deploying to $GIT_WORK_TREE..."
/usr/bin/git checkout -f $BRANCHNAME
echo "Deploy done."