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
# > apache2 -V | |
# results in error like this: | |
# ... AH00111: Config variable ${APACHE_LOCK_DIR} is not defined | |
# | |
# we need to source the envvars file to create the configs in which apache2 relies on | |
source /etc/apache2/envvars |
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
If you happen to see this error during compilation for programs, for example that's nginx in my case: | |
... | |
./configure --disable-shared | |
/bin/sh: line 2: ./configure: No such file or directory | |
... | |
In this case I already configured nginx with my custom-built PCRE library: | |
./configure --with-pcre=<path-to-lib-containing-pcre> |
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
#!/usr/bin/env sh | |
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist | |
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist |
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
def valuedispatch(func): | |
""" | |
A simple decorator for multiple dispatch based on values, not types. | |
Transform a function into generic function, which can have different behaviours | |
depending upon the values of its keyword arguments. | |
""" | |
registry = {} | |
def register(**kwargs): | |
""" |
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, platform | |
from collections import defaultdict | |
from functools import wraps | |
get_time = time.clock if platform.system() == 'Windows' else time.time | |
__nop = lambda: None | |
__throttle_last_time = defaultdict(__nop) | |
def throttle(duration=1, **kw): |
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.ai.sri.com/pkarp/loop.html |
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
(coerce (read-line) 'list) |
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 reverse-nested-list (list) | |
"reverse nested list" | |
(mapcar #'(lambda (l) | |
(if (not (consp l)) | |
l | |
(reverse-deep l))) | |
(reverse list))) |
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 read-line-into-list () | |
(with-input-from-string (in (read-line)) | |
(loop for x = (read in nil nil) while x collect 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
""" | |
An utility module for timing code execution in various ways. | |
""" | |
import time | |
import platform | |
from functools import wraps | |
from contextlib import contextmanager |