Skip to content

Instantly share code, notes, and snippets.

@rcmdnk
rcmdnk / vim_ime.ahk
Last active February 19, 2020 02:10
Automatic IME off for Vim by AutoHotkey. IME.ahk is needed to be placed in the same directory with this setting script (http://www6.atwiki.jp/eamat/pages/17.html).
; Auto execute section is the region before any return/hotkey
; For Terminal/Vim
GroupAdd Terminal, ahk_class PuTTY
GroupAdd Terminal, ahk_class mintty ; cygwin
GroupAdd TerminalVim, ahk_group Terminal
GroupAdd TerminalVim, ahk_class Vim
; Include IME.hak
; http://www6.atwiki.jp/eamat/pages/17.html
@rodneyrehm
rodneyrehm / anti-keygrabber.user.js
Last active July 5, 2022 01:31
GreaseMonkey: Prevent Web Applications From Grabbing Certain HotKeys
// ==UserScript==
// @name anti key-grabber
// @description Prevent web apps from capturing and muting vital keyboard shortcuts
// @grant none
// @version 1.1
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode === 116) {
@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 / 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 / cutlink
Created April 3, 2012 09:56
cutlink - convert hard-linked file to just a copied file.