Skip to content

Instantly share code, notes, and snippets.

@shiva
shiva / countdown.sh
Created August 29, 2011 02:55
prints a number at the same location in a line until 0 (countdown)
#!/bin/sh -x
# -x prints every command before it executes it
# prints 3, 2, 1, 0 in the same location
echo -n " "
let i=3
while [ ${i} -ge 0 ]
do
printf "\b${i}"
let i-=1
@shiva
shiva / typedef-struct-example
Created September 5, 2011 23:01
Example - using a typedef and C structs
typedef struct list_node_s {
void *node;
int key;
} list_node_t;
list_node_t n;
@shiva
shiva / sample.haml
Created May 21, 2012 06:10
HTML vs HAML - HTML sample
I
%a{ :href => "http://twitter.com/shiva" } tweet
,
%a{ :href => "http://shiva.tumblr.com/" } tumble
,
%a{ :href => "http://facebook.com/shivanand" } facebook
\. Am I allowed to use that as a verb?! Who cares, to hell with correctness!
Ohh. I also
%a{ :href => "/blog" } blog in long form
\. Recently, I've started a project called
@shiva
shiva / ssh-config-multi-service
Created August 21, 2012 00:56
Using SSH keys with multiple services
Host *.github.com
IdentityFile ~/.ssh/id_rsa-github
User shiva
Host *.work
IdentityFile ~/.ssh/id_rsa.work
User shiva
@shiva
shiva / git-config-alias.txt
Last active July 27, 2018 22:02
Commonly used aliases for git
# git config --global -e
Then copy the following into the global git config
[alias]
lg = log --color --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --no-merges
st = status
c = commit
b = branch
co = checkout
@shiva
shiva / gist:5888496
Created June 28, 2013 22:03
Compiling VIM from source, with python and ruby interpreter support
sudo apt-get install libx11-dev libxt-dev python python2.7-dev
hg clone https://vim.googlecode.com/hg/ vim_source && cd vim_source && \
./configure --disable-nls --enable-multibyte --with-tlib=ncurses \
--enable-pythoninterp --enable-rubyinterp --with-features=huge && \
make -j 3 && sudo make install
@shiva
shiva / FindNim.cmake
Created October 21, 2014 12:47
cmake module for running nimrod compiler
include(CMakeParseArguments)
find_program(NIM_EXECUTABLE nimrod PATHS ENV PATH)
mark_as_advanced(NIM_EXECUTABLE)
# Determine the valac version
if(NIM_EXECUTABLE)
execute_process(COMMAND ${NIM_EXECUTABLE} "--version"
OUTPUT_VARIABLE NIM_VERSION
@shiva
shiva / Makefile
Last active April 6, 2018 05:34 — forked from wolfeidau/Makefile
Standard NodeJS make file.
REPORTER = spec
.PHONY: test tap unit jshint skel help
all: jshint test ## Run all targets
test: ## Run tests
@NODE_ENV=test ./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --timeout 3000
jshint: ## Run Static Analysis
@shiva
shiva / Makefile-AutoHelp
Last active November 1, 2015 23:38 — forked from prwhite/Makefile
Add a help target to a Makefile that will allow all targets to be self documenting
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
help: ## Show help
@IFS=$$'\n' ; \
help_lines=(`fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##/:/'`); \
printf "%-10s %s\n" "target" "help" ; \
printf "%-10s %s\n" "------" "----" ; \
for help_line in $${help_lines[@]}; do \
IFS=$$':' ; \
@shiva
shiva / rfind-git-status.sh
Last active December 29, 2016 21:30
List the status of all the git repos found at any depth in the current repo
$ for d in `find . -name ".git"`; do \
echo "processing $d ..."; \
git --git-dir=$d --work-tree=$d/.. status; \
done