Skip to content

Instantly share code, notes, and snippets.

#
# zsh script to show how long a command took to run
# put in your .zshrc
#
BG_BLUE='\e[0;44m'
OCOLOR='\e[0m'
BOLD='\e[1;39m'
prompt_command_start=0
show_time_threash=5
#!/usr/bin/env python
"""
Plot histogram from list of dates
Usage
=====
Feed newline separated unix time via STDIN.
Ex.1: plot repository activity::
@justgord
justgord / jsonpath.js
Created September 5, 2011 05:46
handy command line util for looking into JSON files - based on JSONPath npm module
#!/usr/bin/env node
var fs = require('fs');
var jsonpath = require('JSONPath');
if (process.argv.length<3)
{
console.log('usage: jsonpath json_filename json_path_expr');
exit;
@ryo1kato
ryo1kato / cutlink
Created April 3, 2012 09:56
cutlink - convert hard-linked file to just a copied file.
@ryo1kato
ryo1kato / monitor-screensaver
Created April 5, 2012 02:38
Watch screensaver activity and log
#!/bin/bash
# watch screensaver's lock/unlock activity and log
log=$HOME/usr/var/log/screensaver.log
DIE () {
touch $log
echo "ERROR: $*" | tee -a $log >&2
}
@ryo1kato
ryo1kato / urldecode
Created April 6, 2012 02:08
decode % encoded URL
#!/usr/bin/python
import sys
import urllib
print urllib.unquote_plus(sys.argv[1])
@ryo1kato
ryo1kato / bash functrace
Created July 13, 2012 05:54
Backtrace for bash
#!/bin/bash
set -ue
bash_trace () {
typeset -i i=0
for func in "${FUNCNAME[@]}"
do
printf '%15s() %s:%d\n' \
"$func" "${BASH_SOURCE[$i]}" "${BASH_LINENO[$i]}"
@ryo1kato
ryo1kato / realpath.py
Created September 13, 2012 07:22
realpath in Python
#!/usr/bin/python
import sys
import os
if len(sys.argv) <= 1:
print os.path.realpath(os.getcwd())
else:
print os.path.realpath(sys.argv[1])
@ryo1kato
ryo1kato / chrt-synergy
Created September 26, 2012 01:40
A wrapper to allow sudo chrt for synergys
#!/bin/bash
#
# Give sudo right to run chrt for giving RT prio for synergys
# (relatively) safely to avoid delay of cursor or
# keyboard input in remote end.
#
# So far scheduler (SCHED_RR) and prio (50) is hard-coded.
synergys_exepath="/usr/bin/synergys"
@ryo1kato
ryo1kato / apt
Created September 27, 2012 05:10
short-cut wrapper for apt-get and apt-cache
#!/bin/bash
# a lazy guy's wrapper for apt commands
case $1 in
showpkg|showsrc|stats|search|show|depends|rdepends|pkgnames)
set -x
apt-cache "$@"
;;
# short-cuts