Skip to content

Instantly share code, notes, and snippets.

View vikashvikram's full-sized avatar

Vikash Vikram vikashvikram

  • McKinsey & Company
  • Gurgaon, India
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Hello React</title>
<script src="https://fb.me/react-with-addons-0.13.2.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.2.js"></script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<style>
.example-enter {
opacity: 0.01;
#use `` to execute shell commands
#use expr shell command to do math
echo "add 4 and 5"
a=4
b=5
echo `expr $a + $b`
#Suppose you have file called 'hotel.txt' with 100 lines data, And from 'hotel.txt'
#you would like to print contains
@vikashvikram
vikashvikram / slice.go
Created May 14, 2015 07:54
Examples of how to use slices in Go programming language
package main
import (
"fmt"
"bytes"
)
func AddOneToEachElement(slice []int) {
for i := range slice {
slice[i]++
@vikashvikram
vikashvikram / combinations.go
Created May 14, 2015 10:51
Get all combinations of a given number of items from an array of int64 items (can type as per your requirement).
package main
import (
"fmt"
)
func GetAllSubsets(arr []int64, size int) [][]int64{
if len(arr) == size {
result := [][]int64{arr}
return result
@vikashvikram
vikashvikram / join.go
Created May 14, 2015 16:43
Join integer array elements with a string e.g. [1,2,3,4] => "1, 2, 3, 4"
package main
import (
"fmt"
"strconv"
)
func Join(arr []int64, str string) string {
result := ""
last_index := len(arr) - 1
@vikashvikram
vikashvikram / sample.ts
Created May 19, 2015 12:04
Sample code for TypeScript language
var isDone: boolean = false;
//As in JavaScript, all numbers in TypeScript are floating point values.
var height: number = 6;
console.log('isDone: ', isDone);
console.log('height: ', height)
var name: string = "bob";
name = 'smith';
//: Playground - noun: a place where people can play
import UIKit
var constantString = "Hi"
var str: String? = "Hello, playground"
//str = nil
# FrankensteinHash is a subclass of Hash
# It lets you create many levels of keys in Hash at one go.
class FrankensteinHash < Hash
def [](key)
fetch(key) {|el| self[el] = FrankensteinHash.new}
end
end
h = FrankensteinHash.new
h["a"]["b"]["c"] = 1 #=> 1
@vikashvikram
vikashvikram / Neo4j.rb
Created February 8, 2016 05:33
Neo4j Cheatsheet
# get the sample rails app
# git clone https://github.com/vikashvikram/neo4jrails.git
# in case you are using neo4j with rails app, run follwoing commands to setup
rake neo4j:install[community-latest]
# to start a neo4j server from rails app
rake neo4j:start[development]
# start neo4j shell from a rails app
@vikashvikram
vikashvikram / nginx.conf
Last active March 13, 2016 06:23
A sample nginx.conf file setting nginx and passenger for a ruby on rails application.
#user nobody;
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;