Skip to content

Instantly share code, notes, and snippets.

View nviennot's full-sized avatar

Nicolas Viennot nviennot

View GitHub Profile
#!/usr/bin/env ruby
def to_human(t)
ms = ((t-t.floor)*10).floor
sec = t.floor
hour = (sec/3600).floor
sec -= hour * 3600
min = (sec/60).floor
sec -= min * 60
sprintf "%02d:%02d:%02d.%01d", hour, min, sec, ms
#!/usr/bin/env ruby
def to_human(t)
ms = ((t-t.floor)*10).floor
sec = t.floor
hour = (sec/3600).floor
sec -= hour * 3600
min = (sec/60).floor
sec -= min * 60
sprintf "%02d:%02d:%02d.%01d", hour, min, sec, ms
import os
import tempfile
import subprocess
import errno
def _popen(cmd, stdin=None, stdout=None, stderr=None, notty=False):
if notty:
try:
p1 = subprocess.Popen(cmd, stdin=stdin,
stdout=subprocess.PIPE,
@nviennot
nviennot / tmux-login
Created May 31, 2012 10:24
tmux login script to always have tmux loaded
#!/bin/bash
if [[ -t 0 && -t 1 && -t 2 && $# == 0 ]]; then
exec tmux -q -2 set -g default-shell /bin/zsh \; new-session
else
exec /bin/bash "$@"
fi
#!/bin/sh
if [[ $TMUX != "" && `/usr/bin/tmux show-options 2> /dev/null | grep "^status off$"` ]]; then
/usr/bin/tmux set status on \; $@ &> /dev/null
else
if [[ $1 == "--nostatus" ]]; then
/usr/bin/tmux -2 new-session \; set status off
else
/usr/bin/tmux -2 $@
fi
fi