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
@vikashvikram
vikashvikram / elix_tut.ex
Created March 28, 2018 03:59
Elixir Cheat sheet
# Vikram March 28, 2018
# Based on video on elixir by Derek
# commands to run: iex, c("elix_tut.ex"), M.main
defmodule M do
def main do
# string_stuff()
# math_stuff()
# compare_stuff()
# decision_stuff()
# tuple_stuff()
@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;
@vikashvikram
vikashvikram / setup_nginx_with_ror_on_mac.md
Last active August 22, 2019 10:37
How to setup nginx and passenger for a ruby on rails application on Mac OS X

Setting up nginx with passenger for a Ruby on Rails app on Mac OSX

Nginx with passenger is a very popular choice for production and staging environment for rails applications. It is always a good practice to replicate the production and staging environments on our local systems so that we do not have last minute surprises while deploying. Most of the Ruby on Rails developers use Mac OS as their development environment so this document is regarding setting up Nginx with on it for an already existing rails app. The assumption for this doc is that you do not even have ruby installed on your system. So feel free to skip the steps that are not relevant.

Installing Ruby, setting up Rails app, installing gems and nginx

The recommended way to work on a rails app is to use rvm for installing ruby. We need to have multiple versions of ruby and our gems

@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
# 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
//: Playground - noun: a place where people can play
import UIKit
var constantString = "Hi"
var str: String? = "Hello, playground"
//str = nil
@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';
@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 / 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 / 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]++