Skip to content

Instantly share code, notes, and snippets.

@nareshganesan
nareshganesan / install-vscode.bash
Created December 6, 2017 15:55
Install vscode Ubuntu 16.04
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
# install vs code
sudo apt-get update
sudo apt-get install code # or code-insiders
@nareshganesan
nareshganesan / install-go.bash
Last active January 10, 2018 23:40
ubuntu install go from source
#!/bin/bash
err_report() {
echo "Error on line $1"
}
trap 'err_report $LINENO' ERR
usage() {
echo "Usage: $0
@nareshganesan
nareshganesan / install-kubernetes-baremetal.bash
Last active December 5, 2017 20:31
Install kubernetes - Ubuntu 16.04 (kubeadm)
#!/bin/bash
#Install Base docker-engine
sed -i 's/http:\/\/us./http:\/\//g' /etc/apt/sources.list
apt-get update
apt-get remove docker docker-engine
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
@nareshganesan
nareshganesan / gcc_compiler_swap.bash
Created March 10, 2017 13:42
script to swap gcc compiler in ubuntu
# Tested in Ubuntu 14.04
# 14.04 comes with gcc version 4.8.4
# Reference: http://lektiondestages.blogspot.in/2013/05/installing-and-switching-gccg-versions.html
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get install g++-4.9
# to find os details
uname -a
# 1. Add / update / delete / list - users in linux os
# list all user in linux
cat /etc/passwd # also /etc/passwd, /etc/group and /etc/shadow or /etc/master.passwd could be used
# sample output for list users:
root:x:0:0:root:/root:/bin/bash - root is the username
# check amazon os
cat /etc/os-release
# os architecture
uname -a
# group install dev tools
yum groupinstall "Development Tools"
# python development tools
@nareshganesan
nareshganesan / github_remote_switch.sh
Last active January 11, 2017 06:46 — forked from jay-hankins/github_remote_switch.sh
Basic shell function to switch your GitHub repo remote URL from (https|ssh) to (ssh|https) respectively.
# Basic shell function to switch your GitHub repo
# remote URL from (https|ssh) to (ssh|https) respectively.
# Tested with zsh and zprezto on macOS 10.12
github_ssh_to_https (){
URL_PART=$("grep" "-Eo" "([A-z0-9-]+\/[A-z0-9-]+.git)" <<< $1)
# echo $URL_PART
NEW_URL="https://github.com/"
NEW_URL+=$URL_PART
@nareshganesan
nareshganesan / module_watcher.py
Created August 3, 2016 14:30 — forked from eberle1080/module_watcher.py
Automatically reload python module / package on file change
#!/usr/bin/env python
# Author: Chris Eberle <[email protected]>
# Watch for any changes in a module or package, and reload it automatically
import pyinotify
import imp
import os
class ModuleWatcher(pyinotify.ProcessEvent):
"""
@nareshganesan
nareshganesan / parse_yaml.sh
Last active July 21, 2016 09:56 — forked from pkuczynski/LICENSE
Read YAML file from Bash script
#!/bin/sh
parse_yaml() {
local prefix=$2
local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
-e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
awk -F$fs '{
indent = length($1)/2;
vname[indent] = $2;
for (i in vname) {if (i > indent) {delete vname[i]}}
@nareshganesan
nareshganesan / dlib OS X installation.txt
Last active July 8, 2016 13:40
Dlib OS X 10.11 El Capitan
# Download source from the following link
# http://dlib.net/compile.html
2. cd in to dlib folder
3. python setup.py install
4. if you get any linking error use the below link to resolve the linking issue.