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
ps -p <PID> -wwwE | |
# or | |
ps -p <PID> -wwwe | |
# more info https://serverfault.com/questions/66363/environment-variables-of-a-running-process-on-unix |
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
atime() { | |
local times=() | |
local start end total | |
for i in {1..10}; do | |
start=$(/usr/local/opt/coreutils/libexec/gnubin/date +%s%N) | |
"$@" >/dev/null 2>&1 | |
end=$(/usr/local/opt/coreutils/libexec/gnubin/date +%s%N) | |
total=$(expr $end - $start) | |
times+=( $total ) |
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
find . -name *.jpg # find all *.jpg files | |
find . -type f -name '*.*' | sed 's|.*\.||' | sort -u # find all unique file extensions | |
find . -type f ! -name "*.*" # find all files without extensions | |
find . -type f ! -name "*.*" | sed 's!.*/!!' | sort -u # find all unique file names without extension |
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
// Difference between a pointer and a reference in C++ | |
// http://cpp.sh/64ahf | |
#include <iostream> | |
int main() | |
{ | |
int a = 123; | |
int b = 456; | |
int & ra = a; // reference, also "int &ra = a; |
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
function powMod(num, pow, mod) { | |
let res = 1; | |
for (let i = 0; i < pow; ++i) { | |
res = res * num % mod; | |
} | |
return 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
function evalprint { | |
printf "\e[0;92m%s\n\n\e[0m" "$@" | |
eval "$@" | |
} | |
function gp { | |
local args=$(echo "$@") | |
evalprint "git push --no-verify $args; git status;" | |
} | |
__git_complete gp _git_push |
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
gpgconf --kill gpg-agent | |
# You shouldn’t need to manually restart it. GPG will restart it when it’s needed. |
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 GCDWebServer | |
class CorsProxy { | |
init(webserver : GCDWebServer!, urlPrefix: String) { | |
var prefix = | |
(urlPrefix.hasPrefix("/") ? "" : "/") | |
+ urlPrefix | |
+ (urlPrefix.hasSuffix("/") ? "" : "/") | |
let pattern = "^" + NSRegularExpression.escapedPatternForString(prefix) + ".*" |
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
Method 1 | |
git config --global core.editor "'c:/program files/sublime text 3/sublime_text.exe' -w" | |
Method 2 | |
git config --global core.editor "subl -n -w" | |
Method 3 | |
$ echo 'alias subl="/cygdrive/c/Program\ Files/Sublime\ Text\ 3/sublime_text.exe"' >> ~/.bashrc |
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
# In order for gpg to find gpg-agent, gpg-agent must be running, and there must be an env | |
# variable pointing GPG to the gpg-agent socket. This little script, which must be sourced | |
# in your shell's init script (ie, .bash_profile, .zshrc, whatever), will either start | |
# gpg-agent or set up the GPG_AGENT_INFO variable if it's already running. | |
# Add the following to your shell init to set up gpg-agent automatically for every shell | |
if [ -f ~/.gnupg/.gpg-agent-info ] && [ -n "$(pgrep gpg-agent)" ]; then | |
source ~/.gnupg/.gpg-agent-info | |
export GPG_AGENT_INFO | |
else |