This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.thegeekstuff.com/2010/07/bash-string-manipulation/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://serverfault.com/questions/54736/how-to-check-if-a-library-is-installed | |
# work 99% of the time | |
alias libcheck='ldconfig -p | grep ' | |
# other ways | |
# for deb-based distribution | |
# dpkg -s packagename | |
# for exact filename search | |
# locate filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://gist.github.com/MohamedAlaa/2961058 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun system-process-running-p (regex-str) | |
"Check whether there is a system process running whom name matches REGEX-STR." | |
(dolist (pid (list-system-processes)) | |
(let ((attrs (process-attributes pid))) | |
(if (string-match-p regex-str | |
(cdr (assoc 'comm attrs))) | |
(return t))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar api-query "http://api.netimpact.com/qv1.php?key=your-key&qt=geoip&d=json&q=") | |
(defun locate-ip (&optional ip) | |
(let ((url-request-method "GET")) | |
(url-retrieve (concat api-query ip) | |
(lambda (status) (switch-to-buffer (current-buffer)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import izip | |
def _fold(func, iterable, iterize): | |
_iter = iterize(iterable) | |
res = _iter.next() | |
yield res | |
for i in _iter: | |
res = func(res, i) | |
yield res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def tail(f, from_start=False): | |
try: | |
if from_start: | |
f.seek(0, 2) # go to the end of file | |
while True: | |
line = f.readline() | |
if not line: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def point_inside_triangle(p, a, b, c): | |
''' | |
Check whether point p is inside the triangle of (a,b,c). | |
''' | |
return same_side(p, a, b, c) \ | |
and same_side(p, b, a, c) \ | |
and same_side(p, c, a, b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun last-modified-file (parent-dir &optional pattern) | |
"Get the last modified file under `parent-dir'. | |
A regex `pattern' can be provided to only look for those that match." | |
(let ((default-directory parent-dir)) | |
(first | |
(sort | |
(directory-files default-directory 'absolute pattern 'nosort) | |
(lambda (x y) | |
(time-less-p (nth 5 (file-attributes y)) | |
(nth 5 (file-attributes x)))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFLAGS=-g -O2 -W -Wall | |
TEST_USE_POOL=-DTEST_USE_POOL | |
OBJS=main.o pool.o | |
DEPS=pool.h | |
TARGETS=test_pool test_no_pool | |
TEMPS=main_pool.c | |
.PHONY : all clean test |