Skip to content

Instantly share code, notes, and snippets.

View mannykary's full-sized avatar

Manny Karyampudi mannykary

View GitHub Profile
@mannykary
mannykary / ssh_server_osx.md
Last active December 11, 2020 05:22
SSH Server on OS X

To set up SSH server on Mac OS X (tested on Sierra, and likely works for other OS X versions):

  1. Open Terminal, and run sudo nano /etc/ssh/sshd_config
  2. Make sure the line for PubkeyAuthentication is uncommented, and is set to yes. It should looke like PubKeyAuthentication yes. Save the file.
  3. Go to Preferences > Sharing
  4. Check "Remote Login"
  5. Select "Only these users:", and remove all users from the list except your own user.
  6. From the client, open the Terminal and generate an SSH key: ssh-keygen. It is best to call it something that describes your SSH server, so that you don't reuse the key with other SSH servers.
  7. Run ssh-copy-id -i ~/.ssh/private_key user@sshserverhostname
  8. On the SSH server, verify that the public key was added to ~/.ssh/authorized_keys
@mannykary
mannykary / Docker.md
Created November 1, 2020 19:25
Useful Docker Commands

Useful Docker commands

NOTE: this is a WIP; I will add more to this document.

Remove all dangling anonymous volumes

This removes all dangling anonymous volumes. They can take up a lot of space over a long period of time, and should be cleaned out periodically.

Since anonymous valumes are unnamed, they have a 64 character hex string, so we can use grep to filter only for 64-character long volume names.

@mannykary
mannykary / graceful_killer.py
Last active October 2, 2021 04:04
Python Graceful Killer
import signal
import time
class GracefulKiller:
kill_now = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)
def exit_gracefully(self, signum, frame):
@mannykary
mannykary / collate.sh
Created May 10, 2017 21:38
Interactive command line program to collate two PDFs
#!/bin/bash
# Requirements:
# OS X
# PDFTk server: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg
echo "input or drag and drop PDF with odd pages"
read oddpages
echo "input or drag and drop PDF with reversed even pages"
read evenpages
@mannykary
mannykary / vim_cheat_sheet.md
Last active September 6, 2016 22:22
Vim Cheat Sheet

Vim Cheat Sheet

##In Command mode (or Normal mode) ###Basics

  • Edit/enter Insert mode: i (shows -- INSERT -- in bottom-left corner)
  • Save/write to file: :w, then <Enter>
  • Save and quit: :wq, then <Enter>
  • Quit without saving (discard changes): :q!, then <Enter>

###Moving the cursor around the file

@mannykary
mannykary / keycodes.js
Created July 18, 2016 05:59
JavaScript keyCode hash
var keyCodes = {
'A': 65,
'B': 66,
'C': 67,
'D': 68,
'E': 69,
'F': 70,
'G': 71,
'H': 72,
'I': 73,
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
@mannykary
mannykary / .bash_profile
Last active December 6, 2020 04:11
.bash_profile with git branch, dirty status, terminal colors, ll alias, and sourcing of .bashrc and rvm
function parse_git_dirty {
if [[ -n "$(git status --porcelain 2> /dev/null)" ]]; then
echo -e " \033[0;31m✗"
else
echo -e " \033[0;32m✔"
fi
}
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ \1$(parse_git_dirty)/"