Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# script command front end to add time stamp to the script
case $# in
0) PREFIX="";;
*) PREFIX="$1-";shift;
esac
exec script $PREFIX`date '+%Y-%m%d-%H%M%S'`.script $*
# Display progress blip on console
def blip_reset(ratio1 = 100, ratio2 = nil)
@blip_count = 0
@blip_ratio1 = ratio1
@blip_ratio2 = ratio2
if @blip_ratio2 == nil
@blip_ratio2 = ratio1 * ratio1
end
end
# Converting hexadecimal string (like: '001122deadbeaf')
# into binary string and vice-versa
def binary2hexstring(b)
b.unpack("H*")[0]
end
def hexstring2binary(h)
h.scan(/([0-9a-fA-F][0-9a-fA-F])/).collect{|v| v[0].hex.chr }.join
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
@shigeyas
shigeyas / Script to update whole MacPort ports
Created December 10, 2009 04:19
Script to update all ports and clean all builds
#!/bin/sh
# Script to update all ports and clean old builds
# Uncomment following to make build process noisier
#VERBOSE=-v
(for i in "sync" "selfupdate" "clean --dist outdated" "-p upgrade outdated" "-u
uninstall"
do
echo echo \'"==> port $i"\'
#!/bin/sh
#
# Open text editor Emacs with given file name. If no Emacs running, it launches
# automatically on MacOS X.
#
# save this file as whatever filename you like (I'm using 'e'), put in somehere
# in the path (I use ${HOME}/bin), make it executable (chmod +x e) then 'hash -r' or 'rehash'
#
if [ -x /usr/bin/open ]; then # may be MacOS
/usr/bin/open -a Emacs $*
@shigeyas
shigeyas / gist:280486
Created January 18, 2010 23:23
Turn off Input Method Head Up Display for MacOS X
#!/bin/sh
#
# hack to turn-off Head Up Display of Input methods on MacOS X
# (see http://bit.ly/1G8mal for detail)
# You need to run only once. Possibly need to logoff/login or reboot.
#
sudo defaults write /System/Library/LaunchAgents/com.apple.tiswitcher Disabled -bool yes
@shigeyas
shigeyas / c-file-in-openssl.txt
Created November 17, 2010 00:58
# fgrep double `find . -name '*.c'` in openssl-1.0.0a
./apps/apps.c:double app_tminterval(int stop,int usertime)
./apps/apps.c: double ret=0;
./apps/apps.c:double app_tminterval(int stop,int usertime)
./apps/apps.c: double ret=0;
./apps/apps.c: else ret = (clock()-tmstart)/(double)CLOCKS_PER_SEC;
./apps/apps.c:double app_tminterval(int stop,int usertime)
./apps/apps.c: double ret=0;
./apps/apps.c: else ret = (now - tmstart)/(double)sysClkRateGet();
./apps/apps.c:double app_tminterval(int stop,int usertime)
./apps/apps.c: double ret = 0;
@shigeyas
shigeyas / gist:702919
Created November 17, 2010 03:09
fgrep 'float|double' *.h in Crypt++ 5.5.2
bench.h:extern const double CLOCK_TICKS_PER_SECOND;
bench.h:void BenchmarkAll(double t, double hertz);
bench.h:void BenchmarkAll2(double t, double hertz);
config.h:// VC60 workaround: can't cast unsigned __int64 to float or double
hrtimer.h: double ElapsedTimeAsDouble();
hrtimer.h: double ConvertTo(TimerWord t, Unit unit);
network.h: double TimeToNextTransceive();
network.h: typedef std::deque<std::pair<double, lword> > OpQueue;
network.h: double m_nextTransceiveTime;
network.h: double GetCurTimeAndCleanUp();
@shigeyas
shigeyas / 910.local-snapshot-zfs
Created April 13, 2011 00:10
Simple shell script to take daily ZFS snapshot and backup on different partition via bzip2
#!/bin/sh
# For FreeBSD 8.x. Place this file in /etc/periodic/daily and configure via periodic.conf
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi