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: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"))
@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: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: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:9151505
Created February 22, 2014 10:09
Linux Whell Group...
Modern Unix systems use user groups to control access privileges. The wheel group is a special user group used on some Unix systems to control access to the su command, which allows a user to masquerade as another user (usually the super user).
@fortitudepub
fortitudepub / gist:10289344
Created April 9, 2014 16:31
pulseaudio tips
1. pacmd is a good tool to help you get current pulseaudio information.
list-sinks
list-clients
@fortitudepub
fortitudepub / gist:5864ab8d1e834aae83b6
Created October 20, 2014 15:04
oneline command to dump dvd/cd video content.
mplayer2 -dumpstream /dev/sr0 -nocache -noidx -dumpfile record.mp4
@fortitudepub
fortitudepub / gist:9ce92e8dbb62af916a7a
Created February 3, 2016 05:41
calc if rx stats by shell script.
ifname=$1
let bytes1=0
while true; do
let bytes2=`ip -s link show $ifname | grep -A 1 RX | grep -v RX | awk '{print $1}'`
let diff=(bytes2 - bytes1)
let diff=(diff / 1024 / 1024)
echo "bandwitdth is $diff Mbps"
let bytes1=bytes2
sleep 1
@fortitudepub
fortitudepub / gist:bfb6537274e1b82b78689f27888b7b57
Created April 15, 2016 07:48
one liner to count rss memory size.
ps -eo rss,pid,comm | awk '{s+=$1} END {print s}'
@fortitudepub
fortitudepub / gist:dbf00fd3c0d156c97ccc155351b21220
Created April 22, 2016 07:38
quickly create many tcp connection to exploit service using python eventlet
import eventlet
pool = eventlet.GreenPool()
def bomb():
a = eventlet.connect(("127.0.0.1", 9697))
eventlet.sleep(10)
a.close()
i=0
while i<5000:
pool.spawn(bomb)