Skip to content

Instantly share code, notes, and snippets.

View josnidhin's full-sized avatar

Jose Davis Nidhin josnidhin

View GitHub Profile
@josnidhin
josnidhin / git_prompt.sh
Last active May 30, 2018 06:23
Display the current git branch name in bash
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function git_prompt {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
@josnidhin
josnidhin / gist:2822114
Created May 29, 2012 01:55
Installing RVM and Ruby 1.9 on AWS Linux AMI
sudo -s
yum update
groupadd rvm
gpasswd -a ec2-user rvm
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
@josnidhin
josnidhin / mem_watch.sh
Created December 2, 2012 15:02
AWS AMI instance memory static to Cloudwatch
#!/bin/bash
export AWS_CLOUDWATCH_HOME=/opt/aws/apitools/mon # cloudwatch command line tools
export AWS_CLOUDWATCH_URL=https://monitoring.amazonaws.com # cloudwatch end point
export PATH=$AWS_CLOUDWATCH_HOME/bin:$PATH
export JAVA_HOME=/usr/lib/jvm/jre
# cloudwatch credential
CLOUDWATCHCREDENTIAL=/root/aws-custom-monitor/cloudwatch_credential.txt
@josnidhin
josnidhin / README.md
Last active October 13, 2015 12:08
WebGL Pipe wireframe

I was trying to draw a pipe in webgl and this what I came up with. It can be viewed here

@josnidhin
josnidhin / .screenrc
Last active December 10, 2015 09:49
GNU screen settings
startup_message off
defscrollback 10000
vbell off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
@josnidhin
josnidhin / parse_filename_1.sh
Last active December 24, 2015 06:39
Parses the filename and adds it as a text to the image using imagemagick tool
#! /bin/bash
#
# This script parses filenames of the following format "s1_c-sq-0x_1_1369921304_1.PNG" and add
# certain info to the image
#
FILES=*.PNG
for file in $FILES; do
while IFS='_' read -ra filename; do
@josnidhin
josnidhin / SimpleSocketServer.js
Last active December 31, 2015 02:49
A very simple NodeJS socket server. The server echos back whatever the client send. Start the server by executing node SimpleScoketServer.js. Connect to the server using nc localhost 5001
var net = require( 'net' );
var serverAddress = 'localhost',
serverPort = 5001;
var server = net.createServer( function( socket ) {
console.log( 'New socket connection.\n' );
// send welcome message
socket.write( "Connected to Server.\n" );
@josnidhin
josnidhin / main.js
Created April 22, 2014 04:53
Javascript: Printing to Console from Web Worker
// create the worker object
var worker = new Worker( "worker.js" );
// add message event listener
worker.addEventListener( 'message', function( event ) {
switch ( event.data.type ) {
case "debug":
console.log( event.data.message );
break;
case "result":
@josnidhin
josnidhin / input.txt
Created May 8, 2014 02:01
A script to parse polhemus liberty motion data output. The script separates a single file containing data from 2 stations into separate files.
1 20.465 -16.439 -4.668 65.601 -6.760 -144.382 1853586 0x75d90b 0
2 21.251 -26.413 -5.341 172.982 25.081 -151.184 1853586 0x75d90b 0
@josnidhin
josnidhin / permutation.rb
Last active August 29, 2015 14:06
Prints all the permutation of the given string
def permutation(prefix, str)
n = str.length
if n == 0
p prefix
else
for i in 0..n-1 do
if i == 0
perm("#{prefix}#{str[i]}", str[i+1..n-1])
else
perm("#{prefix}#{str[i]}", "#{str[0..i-1]}#{str[i+1..n-1]}")