Skip to content

Instantly share code, notes, and snippets.

View zapstar's full-sized avatar

Thirumal Venkat zapstar

View GitHub Profile
@zapstar
zapstar / VirtualBox Guest Settings.md
Created April 13, 2016 07:41
My Dnsmasq configuration on OSX. This acts as both DNS & DHCP server for my VirtualBox host-only network
  • First create a host-only network if not already done so. Use the IP Address 192.168.56.1 with the netmask 255.255.255.0. Don't enable DHCP server (next tab), it should be unchecked.

  • Make sure two network interfaces are assigned to the VM. The first being a NAT interface (note: NOT NAT Network). The second being a Host-Only Adapter.

  • In the Ubuntu guest the /etc/network/interfaces file should look something similar to below.

# This file describes the network interfaces available on your system
@zapstar
zapstar / show-256-colors.pl
Created March 3, 2016 07:24
Show all possible colors on the terminal via a perl script.
#!/usr/bin/perl
# Author: Todd Larason <jtl@molehill.org>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@zapstar
zapstar / Makefile
Created February 12, 2016 06:50
Create individual binaries per C file
############################################################################
# 'A Generic Makefile for Building Multiple main() Targets in $PWD'
# Author: Robert A. Nader (2012)
# Email: naderra at some g
# Web: xiberix
############################################################################
# The purpose of this makefile is to compile to executable all C source
# files in CWD, where each .c file has a main() function, and each object
# links with a common LDFLAG.
#
@zapstar
zapstar / bst2dll.cpp
Created October 12, 2015 12:10
Convert a binary search tree into a doubly linked list (left acts as prev, right acts as next)
#include <stdexcept>
#include <iostream>
using namespace std;
struct node {
int val;
struct node *left;
struct node *right;
};
@zapstar
zapstar / cfglog_tutorial.sh
Created September 23, 2015 08:52
AIX cfglog tutorial - Useful to debug disk stuff
# Set cfglog environment variable
# cmd = trace commands
# meth = trace methods
# lib = trace libraries
# verbosity:xx (0-9) verbosity
export CFGLOG="cmd,meth,lib,verbosity:9"
# File where this gets logged: /var/adm/ras/cfglog
# Read cfglog entries:
@zapstar
zapstar / run_spark_job.sh
Created April 7, 2015 07:15
Run Spark Job by looking at the build File
#!/bin/sh
# NOTE: Make sure we have $SPARK_HOME set...
# Identify the build file
BUILD_FILE=`ls *.sbt`
# Find out the required variable from the build file
PROJECT_NAME=`grep name $BUILD_FILE | cut -d" " -f 3- | sed -e 's/ /-/g' | awk '{ gsub(/"/, "", $0); print tolower($0) }'`
SCALA_VERSION=`grep scalaVersion $BUILD_FILE | awk '{ gsub(/"/, "", $3); print $3 }' | rev | cut -d '.' -f 2- | rev`
@zapstar
zapstar / max2.c
Created March 9, 2015 12:26
Find the two largest numbers among the three.
#include <stdio.h>
void max2(int a, int b, int c) {
int first, second;
printf("a = %d, b = %d, c = %d\n", a, b, c);
if (a > b) {
second = a;
if (a > c) {
first = a;
if (b > c) {
@zapstar
zapstar / .vimrc
Last active December 29, 2020 09:21
My vimrc
""""""""""""""""""
" PACKAGES START "
""""""""""""""""""
set nocompatible
call plug#begin('~/.vim/plugged')
" Start adding Vundle plugins from here
" Package manager itself
@zapstar
zapstar / tryMongoDB.js
Last active August 29, 2015 14:14
Notes from the MongoDB introductory tutorial present at http://try.mongodb.org
// This is the MongoDB tutorial from http://try.mongodb.org
// Get started with `help`
// To try out an interactive tutorial type `tutorial`
// This shell is a (limited) javascript interpreter, so any commands you are familiar from javascript should work here. Try out:
var a = 5;
a * 10;
for(i=0; i<10; i++) { print('hello'); };
// You can move onto the next step anytime by typing `next`
@zapstar
zapstar / isitme.sh
Created September 3, 2014 04:12
Simple shell script to check whether a website is down only for me or everyone else. Uses curl and isup.me service.
# Simple script to figure out whether a site is up or not
TOOL_SITE="http://www.isup.me/"
if [ $# -ne 1 ]
then
echo "Incorrect arguments specified"
exit 1
fi