Skip to content

Instantly share code, notes, and snippets.

# easy way to remove circular references when stringifying
var cache = [];
JSON.stringify(o, function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
cache.push(value);
# When you get this: "The authenticity of host 'HOSTNAME (IP)' can't be established.",
# including a fingerprint, and then "Are you sure you want to continue connecting (yes/no)?".
# This is due to a hostname check previously accepted fingerprint/hostname.
# This isn't helpful during automated tests, turn it off with this:
StrictHostKeyChecking=no
# get fingerprint of server
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
# The following useful in /etc/ssh/ssh_config
# Used for my Windows 10 bash terminal
# This tmux usually has remote tmux's nested in it
# change status bar background to yellow so it doesn't confuse me with remote session's color
set -g status-bg yellow
# set current window's background to green to match remote session's color
set -g window-status-current-bg green
# turn off C-b for this Windows session, since we always remote into another tmux ssession
set-option -g prefix C-n
@bitsandbytes
bitsandbytes / intellij.txt
Last active November 26, 2022 20:22
IntelliJ secrets
# In CentOs 6, edit /etc/sysctl.conf
fs.inotify.max_user_watches = 524288
# Then make change take effect
sudo sysctl -p
# Then start up IntelliJ
@bitsandbytes
bitsandbytes / .git_tips.sh
Last active October 4, 2021 13:36
Git Secrets
Git Secrets
# how to find the commit that deleted a file
# find a file that you're not certain where it is anymore, if it's been deleted
git log --all --full-history -- "*MyFile.*"
# find the path of the above
git show --pretty="" --name-only <sha1-commit-hash>
# now limit the above file's commits to just the exact path you want
git log --all --full-history -- <path-to-file>
# take the last commit, that'll show you the commit that deleted the file
@bitsandbytes
bitsandbytes / ..bash_secrets
Last active April 25, 2023 17:23
Bash setup
# Conditionally set one parameter to another, or use default value
# If ${1} is unset or null, this will set SOME_VAR to "default_value" instead
SOME_VAR=${1:-default_value}
# If ${1} is unset or null, this will set SOME_VAR to the value of OTHER_VAR instead
SOME_VAR=${1:=OTHER_VAR}
# ^M
# in vim
# no really
# here's how to enter ^M so that you can remove it from a file