Skip to content

Instantly share code, notes, and snippets.

View fortitudepub's full-sized avatar
💭
Enthusiast of networking and systems, happy hacking

dyz fortitudepub

💭
Enthusiast of networking and systems, happy hacking
View GitHub Profile
@fortitudepub
fortitudepub / gist:8561649
Created January 22, 2014 16:15
Check standard input is a terminal.
#!/bin/sh
if [ -t 0 ]
then
echo "Input is a terminal"
else
echo "Input is NOT a terminal"
fi
@fortitudepub
fortitudepub / gist:8505367
Last active January 3, 2016 18:59
fontify #if0 for emacs c-mode.
;; This is a function copied from stackoverflow to facify #if 0/#else/#endif keywords.
;; The comments are added by myself to make it understandable.
(defun my-c-mode-font-lock-if0 (limit)
(save-restriction
(widen)
(save-excursion
(goto-char (point-min))
(let ((depth 0) str start start-depth)
;; Search #if/#else/#endif using regular expression.
(while (re-search-forward "^\\s-*#\\s-*\\(if\\|else\\|endif\\)" limit 'move)
@fortitudepub
fortitudepub / gist:8171020
Created December 29, 2013 14:38
one line command to take a screen shot on linux.
sleep 15; import xxx.jpg;
@fortitudepub
fortitudepub / gist:8024517
Created December 18, 2013 15:43
Open a file when emacs init to prevent scratch buffer from being created.
;; Open the default file if it is present.
(if (file-exists-p "~/org/TODO.org")
(setq initial-buffer-choice "~/org/TODO.org"))