Skip to content

Instantly share code, notes, and snippets.

diff --git a/src/preferences.c b/src/preferences.c
index 79bf452..0954024 100644
--- a/src/preferences.c
+++ b/src/preferences.c
@@ -25,6 +25,10 @@
#include "preferences.h"
#include "parcellite-i18n.h"
#define MAX_HISTORY 1000
+
+/* gtk2.10 (on RHEL5.x) doesn't have this function */
@ryo1kato
ryo1kato / unix2excel-time
Created November 29, 2012 01:28
convert unix epoch time to Excel time
#!/usr/bin/env python
#
# Read a CSV file from STDIN, assume the 1st column is unix-seconds
# convert it to excel time value ( (UNIXSEC + 32400) / 86400 + 25569 )
# and insert it as 2nd column
#
import sys
for line in sys.stdin.readlines():
(unixsec_str, delim, rest) = line.partition(',')
@ryo1kato
ryo1kato / time-map.py
Created October 30, 2012 16:39
time-map.py
#!/usr/bin/env python
import datetime
import sys
def time_map_by_dow(dt, begindate):
"""
Convert a datetime object dt to
the same time, same day-of-week of duration
within begindate and begindate + 6 (inclusive)
@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
@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 / 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 / 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 / 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 / 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 / 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