Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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:

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 / elementary-os-luna-fix-ppa-errors.md
Last active February 23, 2016 18:14
Unable to add PPA in elementary OS

Solution

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install --reinstall base-files=6.5ubuntu6.7+elementary8~ubuntu0.2.1

Error was related to /etc/os-release and /etc/lsb-release. The files looked like this before:

@srijanshetty
srijanshetty / keybase.md
Last active September 10, 2019 06:13
Keybase Proof

Keybase proof

I hereby claim:

  • I am srijanshetty on github.
  • I am srijanshetty (https://keybase.io/srijanshetty) on keybase.
  • I have a public key ASBp2Y-KsbCsRcnWRk-J2dX68fY1hX6NXsPfnhuobDbC0go

To claim this, I am signing this object:

@srijanshetty
srijanshetty / lamp-setup.sh
Last active October 10, 2015 13:20
LAMP setup
# Install LAMP stack - Apache, MySQL, PHP
# as per http://fideloper.com/ubuntu-install-php54-lamp and/or http://fideloper.com/ubuntu-12-04-lamp-server-setup
sudo apt-get update # Update package repositories
sudo apt-get install -y git-core wget vim curl build-essential python-software-properties zsh # Install basics
sudo add-apt-repository -y ppa:ondrej/php5 # Add repository for php5.5 and Apache 2.4
sudo apt-get update # Update package repositories again after adding repository
sudo apt-get install -y php5 php5-mcrypt php5-gd php5-curl php5-mysql # Install PHP and common modules
sudo apt-get install -y apache2 libapache2-mod-php5 # Install Apache2
sudo apt-get install -y mysql-server # Install MySQL
@srijanshetty
srijanshetty / cli-smtp.py
Last active August 29, 2015 14:04
SMTP client
#!/bin/python
def send_mail():
import smtplib
gmail_user=''
gmail_password=''
FROM=''
TO=['', '']
@srijanshetty
srijanshetty / bash-tricks
Last active August 29, 2015 14:03
Shell Tricks
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg