Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@puneetar
puneetar / bash_profile_set_terminal_colors
Created August 27, 2018 05:05
Set colors to bash terminal
### Add this to `~/.bash_profile
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
@puneetar
puneetar / git_branch_name_bash_profile
Created August 20, 2018 20:51
To show proper git branch name when present in the console.
#--------To show proper git branch name when present in the console.
#--------Add this to ~/.bash_profile or ~/.bash_rc
#--------This will start showing branch names in the terminal like
#--------puneetar folder_name (branch_name) $
#--------
parse_git_branch() {
   #  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
git branch 2> /dev/null | grep '*' | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@puneetar
puneetar / git-completion.bash
Created August 16, 2017 18:38
Git base completion script
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
# *) local and remote tag names
@puneetar
puneetar / karabiner_diamond_cursor_option_ijkl.json
Created August 13, 2017 08:13
Karabiner : Diamond Cursor : Change option + I/J/K/L to Arrow Keys
{
"title": "Diamond Cursor",
"rules": [
{
"description": "Change option + I/J/K/L to Arrow Keys",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "i",
# custom IntelliJ IDEA VM options
# references from https://gist.github.com/P7h/4388881 and https://gist.github.com/devnulled/4120215
# running Scala with Scalaz on JVM 1.8.0 64 bit for IntelliJ 2017.1
-server
-Xms2048m
-Xmx3048m
-XX:ReservedCodeCacheSize=240m
-XX:NewSize=512m
-XX:MaxNewSize=512m
@puneetar
puneetar / JSONToCSVConverter
Created September 8, 2016 20:14
Javascript function to convert JSON to CSV
export function JSONToCSVConvertor(JSONData, fileName, ShowLabel, errorCallback) {
var arrData = typeof JSONData != 'object' ? JSON.parse(JSONData) : JSONData;
var CSV = '';
if (ShowLabel) { //This condition will generate the Label/Header
var row = "";
for (var index in arrData[0]) { //This loop will extract the label from 1st index of on array
if (arrData[0].hasOwnProperty(index)) {
row += index + ','; //Now convert each value to string and comma-seprated
}
@puneetar
puneetar / .git_hooks_commit-msg
Created May 25, 2016 23:55
git commit hook : file : commit-msg
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
# For eg : branch name : puneet/CHOW-142412-this-works
# will result into commit message : "CHOW-142412: this is my commit message"
#
#NAME=$(git branch | grep '*' | sed 's/* //')
NAME=$(git branch | grep '*' | sed 's/* \(.*\)\///' | sed 's/\([0-9]\)-.*/\1/')
DESCRIPTION=$(git config branch."$NAME".description)