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 _ssh_sesslog() { | |
_sesdir="<path/to/session/logs>" | |
mkdir -p "${_sesdir}" && \ | |
ssh $@ 2>&1 | tee -a "${_sesdir}/$(date +%Y%m%d).log" | |
} | |
# Alias: |
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
# Graph # of connections for each hosts | |
netstat -an | \ | |
grep ESTABLISHED | \ | |
awk '{print $5}' | \ | |
awk -F: '{print $1}' | \ | |
grep -v -e '^[[:space:]]*$' | \ | |
sort | uniq -c | \ | |
awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' | |
# Monitor open connections for specific port including listen, count and sort it per IP |
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 python | |
# -*- coding: utf-8 -*- | |
# example output: | |
# | |
# A.var1 c_int(1) 4509637024 | |
# a1.var1 c_int(3) 4509637704 False | |
# a1.__class__.var1 c_int(1) 4509637024 True | |
# -------------------------------------------------------------------- |
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 python | |
import pdb | |
import sys | |
import traceback | |
def main(): | |
# some WIP code that maybe raises an exception | |
raise BaseException("oh no, exception!") | |
return 0 |
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 python | |
# -*- coding: utf-8 -*- | |
# with help from https://gist.github.com/miketaylr/5969656 | |
import sys | |
try: | |
from LaunchServices import ( | |
LSSetDefaultHandlerForURLScheme, |
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 python | |
# -*- coding: utf-8 -*- | |
""" | |
Create a link named json2yml and yml2json to this file. | |
If invoked as json2yml, it will convert json file to yml. | |
If invoked as yml2json, it will convert yml file to json. | |
""" | |
import sys | |
import json |
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
# disable verifying developer | |
spctl --master-disable | |
defaults write com.apple.dock expose-animation-duration -float 0.1 | |
defaults write com.apple.LaunchServices LSQuarantine -bool false | |
defaults write com.apple.finder DisableAllAnimations -bool true | |
defaults write com.apple.finder ShowStatusBar -bool true | |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true | |
defaults write com.apple.finder _FXSortFoldersFirst -bool true | |
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false |
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 log2(x): | |
if x == 0: | |
return False | |
return math.log10(x) / math.log10(2) | |
def is_power_of_two(n): | |
return math.ceil(log2(n)) == math.floor(log2(n)) |
I use .env
files to set environment variables for projects, but those values are different in local vs test
vs prod. I also want support from my IDE and the commandline. VSCode and Intellij both support .env
files,
but if you want to point your application from local to test or prod, you have to update the .env
file, which
leaves me with an env file with lots of comments. Alternatively, you can update the IDE to point to another
env file, but that gets a little non-standard by not using .env
.