Skip to content

Instantly share code, notes, and snippets.

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@srijanshetty
srijanshetty / node-cli-application.md
Last active August 29, 2015 14:12
Create a Nodejs CLI application
  1. Add the following lines to package.json
"preferGlobal": "true",
  "bin": {
    "commandname" : "path/to/command"
  }
  1. Add the following line to the main script:
@srijanshetty
srijanshetty / 2fa-github-password.md
Last active August 29, 2015 14:12
Using a Personal Access token as a password when you have enabled github 2FA

I recently added 2 factor authentication to my GitHub account (and you should too!). However, when I went back to the command line, I could not longer log-in to my account! After doing some searching, it turns out that, with 2FA turned on, you no longer use your password on the command line. Instead, you need to use a personal oauth token. Generating one is super easy, but I wish I had figured this out before hand to save myself the headache of anxiously Googling!

Here are the steps to creating your personal access token:

  1. Log into GitHub and access your account settings
  2. Select the “Applications” tab on the left-hand navigation
  3. Under “Personal Access Tokens” click “create new”
  4. Enter a description for your token (so you can keep track and revoke them individually later, should you have a security breach)
  5. Copy the token (40 characters long) and use that as your password on the command line.
@srijanshetty
srijanshetty / package-vagrant-box.md
Last active June 20, 2023 08:49
Clean up a vagrant box before packaging

We’re now going to clean up disk space on the VM so when we package it into a new Vagrant box, it’s as clean as possible. First, remove APT cache

$ sudo apt-get clean

Then, “zero out” the drive (this is for Ubuntu):

$ sudo dd if=/dev/zero of=/EMPTY bs=1M
@srijanshetty
srijanshetty / tmux_local_install.sh
Last active August 29, 2015 14:14 — forked from sharjeelsayed/tmux_local_install.sh
Install tmux without root
#!/bin/bash
# Source: https://gist.github.com/ryin/3106801
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
TMUX_VERSION=1.9
@srijanshetty
srijanshetty / zsh-dynamic-completions
Last active August 29, 2015 14:16
ZSH dynamic completions
#compdef savesolarized
_arguments "1: :($(lssolarized | tr "\n" " "))"
@srijanshetty
srijanshetty / ramda
Last active August 29, 2015 14:20 — forked from raine/ramda
Ramda documentation browser using command line
#!/usr/bin/env bash
# Browse Ramda documentation in Terminal
# Requires jq and a tool such as fzf or peco for interactive filtering
LATEST="https://raw.githubusercontent.com/raine/ramda-json-docs/gh-pages/latest.json"
DOCS_URL="http://ramdajs.com/docs/"
json=$(curl -s $LATEST)
functions=$(echo "$json" | jq -r '.[] | if .sig and (.sig | length > 0) then .name + " :: " + .sig else .name end')

If you're using GNU make and you need help debugging a makefile then there's a single line your should add. And it's so useful that you should add it to every makefile you create.

It's:

print-%: ; @echo $=$($) It allows you to quickly get the value of any makefile variable. For example, suppose you want to know the value of a variable called SOURCE_FILES. You'd just type:

make print-SOURCE_FILES If you are using GNU make 3.82 or above it's not even necessary to modify the makefile itself. Just do

@srijanshetty
srijanshetty / zsh-static-completions
Created May 21, 2015 05:21
ZSH static completions
#compdef repos
typeset -A opt_args
local context state line
_arguments -s -S \
'--add-git[add a github configuration]'\
'--add-bit[add a bitbucket configuration]'\
'--available[List all available configurations.]'\
'--check[list all repos not in mrconfig]'\
@srijanshetty
srijanshetty / vagrant-lamp
Created May 21, 2015 07:03
Vagrant File for lampbox
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.hostname = "scotchbox"
config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]