Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
ryo1kato / gist:1953986
Created March 1, 2012 23:26
CSS for Firefox Stylish add-on
img {
opacity: 0.2 !important;
filter: alpha(opacity=20) !important;
zoom: 1; /* needed to trigger "hasLayout" in IE if no width or height is set */
}
/*
*, body > *, body > * > *, body > * > * > * {
background: none!important;
}
*/
@ryo1kato
ryo1kato / cutlink
Created April 3, 2012 09:56
cutlink - convert hard-linked file to just a copied file.
@ryo1kato
ryo1kato / now.rb
Created April 3, 2012 12:35
now - 1/10 sec accu. clock for text console
#! /usr/bin/ruby
ACCURACY = 0.08
$chrono = false
@ryo1kato
ryo1kato / perror
Created April 3, 2012 12:37
perror - bash implementation
#!/bin/bash
errno_headers="/usr/include/asm-generic/errno-base.h /usr/include/asm-generic/errno.h"
print_usage () {
echo "Usage: ${0##*/} ERRNO"
}
case $1 in
@ryo1kato
ryo1kato / epoch2time
Created April 3, 2012 12:49
convert second from epoch to calendar clock time
#!/usr/bin/ruby
# ruby ./epoch2time $(date '+%s')
def sec2time(sec)
thetime = Time.at(sec)
return thetime.to_s
end
if ARGV.length < 1
@ryo1kato
ryo1kato / mv-if-grep
Created April 3, 2012 12:53
mv-if-grep
#!/bin/sh
#
# TODO:
# - Parhaps TARGET_DIR should be a last argument (like mv)
# - Option like grep's -r switch might be useful(?)
# - Verbose option to report witch files are moved and which are skipped
DIE () {
echo "ERROR: $@"
exit 1
@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])