Skip to content

Instantly share code, notes, and snippets.

View ansrivas's full-sized avatar

Ankur Srivastava ansrivas

View GitHub Profile
### curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
@ansrivas
ansrivas / include_this.py
Created October 26, 2018 15:41
Sqlite foreign keys on with sqlalchemy
from sqlalchemy import event
from sqlalchemy.engine import Engine
@event.listens_for(Engine, "connect")
def set_sqlite_pragma(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("PRAGMA foreign_keys=ON")
cursor.close()
@ansrivas
ansrivas / example.toml
Created September 30, 2018 12:59
TOML Example File
# This is a TOML document. Boom.
title = "TOML Example (v0.4.0)"
#------------------------------ Comments ------------------------------
# This is a full-line comment
key = "value" # This is a comment at the end of a line
#--------------------------- Key/Value Pair ---------------------------
@ansrivas
ansrivas / branch-rename.md
Created September 20, 2018 10:55
Rename a git branch locally and remotely
git branch -m old_branch new_branch         # Rename branch locally    
git push origin :old_branch                 # Delete the old branch    
git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote
@ansrivas
ansrivas / rust_smart_pointers
Created September 12, 2018 23:04
smart_pointers.rs
Box<T> is for single ownership.
Rc<T> is for multiple ownership.
Arc<T> is for multiple ownership, but threadsafe.
Cell<T> is for “interior mutability” for Copy types; that is, when you need to mutate something behind a &T.
@ansrivas
ansrivas / git_rebase.md
Created August 4, 2018 17:53 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@ansrivas
ansrivas / sshFix.go
Created June 29, 2018 16:02
Fix ssh directory permissions
package main
import (
"log"
"os"
"os/user"
"path/filepath"
"strings"
"time"
)

$ vim /etc/profile.d/envvars.sh

export SCALA_ENV="prod"
export SPARK_HOME="/home/sparkuser/spark"
export PATH=$PATH:$SPARK_HOME