Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python
import os, sys, gtk, pynotify
import optparse
def print_version(*args):
print os.path.basename(sys.argv[0]) + " 1.0"
exit()
def parse_hint(option, opt_str, value, parser):
#!/usr/bin/env perl
# Author: Ian Yang <doit dot ian (at) gmail dot com>
# URL: http://gist.github.com/gists/173151
#
# This script depends on script `notify-send.py', which can be
# downloaded from http://gist.github.com/172910. Script
# `notify-send.py' requires python library `pynotify'.
#
# This script sends mpc status to `notify-osd'. I have not tested in
(dbus-call-method
:session "org.freedesktop.Notifications"
"/org/freedesktop/Notifications"
"org.freedesktop.Notifications" "Notify"
"GNU Emacs" ;; Application name.
0 ;; No replacement of other notifications.
"" ;; No icon.
"Notification summary" ;; Summary.
(format ;; Body.
"This is a test notification, raised from %s" (emacs-version))
#!/bin/bash
# Author: Ian Yang
_is_emacs_daemon_started () {
netstat -nlpx 2> /dev/null | awk '{print $NF}' | grep -qF "/tmp/emacs$UID/server"
}
_is_emacs_window_exist () {
wmctrl -lx 2> /dev/null | awk '{print $3}' | grep -qF 'emacs.Emacs'
}
# paths
PREFIX = /usr/local
INCS =
LIBS =
CXX_FLAGS = -O2 -g -Wall ${INCS}
LD_FLAGS = ${LIBS}
# compiler and linker
groot() {
local dir=`pwd`
dir=${dir%/}
until [ -z "$dir" -o -d "$dir/.git" ]; do
dir=${dir%/*}
done
cd "$dir/"
}
if [ -n "$SSH_AUTH_SOCK" ] && netstat -nlpx 2> /dev/null | awk '{print $NF}' | grep -qF "$SSH_AUTH_SOCK"; then
echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > /tmp/ssh-agent$UID
if [ -n "$SSH_AGENT_PID" ]; then
echo "export SSH_AGENT_PID=$SSH_AGENT_PID" >> /tmp/ssh-agent$UID
elif [ -n "$GNOME_KEYRING_PID" ]; then
echo "export GNOME_KEYRING_SOCKET=$GNOME_KEYRING_SOCKET" >> /tmp/ssh-agent$UID
echo "export GNOME_KEYRING_PID=$GNOME_KEYRING_PID" >> /tmp/ssh-agent$UID
fi
else
SSH_AUTH_SOCK=
#
# Example of a user's .screenrc file
#
# This is how one can set a reattach password:
# password ODSJQf.4IJN7E # "1234"
# no annoying audible bell, please
vbell off
#!/usr/bin/env perl
#
# Author: Ian Yang <doit dot ian at gmail dot com>
# Updated: <2009-10-24 22:11:10>
#
# This script will separate header file into block and sort them in
# each block
#
# Usage:
#
# This snippet is indended to be paseted in `.xinitrc'. Then D-Bus Daemon
# can be started on startup and all sub-processes the windows manager can
# communicate with the daemon.
#
# `.bashrc' also can source the file `/tmp/dbus-session$UID' to restore the
# environment variables
dbus_address=$(echo "$DBUS_SESSION_BUS_ADDRESS" |\
awk 's/^.*unix:abstract=\([^,]*\),.*$/\1/')
if [ -S "$dbus_address" ] && netstat -nlpx 2> /dev/null |\