Skip to content

Instantly share code, notes, and snippets.

@gabhi
gabhi / gist:7ac44eae1b159cebb50a
Created September 1, 2015 08:04
Docker image
Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y curl
//Build image
docker build -t aa/abc:1.0 .
//Run image
@gabhi
gabhi / gist:dbe44ef5e638357399cc
Last active August 28, 2015 18:52
unix stuff
sudo chown -R $(whoami) . //change owner for given folder recursively
find /opt/ais -user root //find all directories whose owner is user Root
@gabhi
gabhi / LICENSE
Last active August 29, 2015 14:27 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@gabhi
gabhi / compress.java
Created August 5, 2015 22:34
Basic string compression counting repeated characters
public String compress(String str) {
if (str.isEmpty()) {
return "";
}
char[] chars = str.toCharArray();
StringBuilder builder = new StringBuilder();
int count = 1;
char prev = chars[0];
@gabhi
gabhi / gist:bb4a20d9c3ece3b8a2cf
Last active August 29, 2015 14:25
block facebook
http://osxdaily.com/2010/11/21/block-facebook/
127.0.0.1 facebook.com
127.0.0.1 login.facebook.com
127.0.0.1 www.facebook.com
dscacheutil -flushcache
@gabhi
gabhi / gist:af06adc3b5d464f84163
Created June 30, 2015 06:35
Median in a stream of integers (running integers)
Similar to balancing BST in Method 2 above, we can use a max heap on left side to represent elements that are less than effective median, and a min heap on right side to represent elements that are greater than effective median.
After processing an incoming element, the number of elements in heaps differ utmost by 1 element. When both heaps contain same number of elements, we pick average of heaps root data as effective median. When the heaps are not balanced, we select effective median from the root of heap containing more elements.
@gabhi
gabhi / gist:ac00c31130b6812b9b64
Created June 25, 2015 01:45
get Zodiac sign from birthdate javascript
function getZodiacSign(day, month) {
var zodiacSigns = {
'capricorn':'capricorn',
'aquarius':'aquarius',
'pisces':'pisces',
'aries':'aries',
'taurus':'taurus',
'gemini':'gemini',
'cancer':'cancer',
dse cassandra -k -t //spark
dse cassandra -s //solr
@gabhi
gabhi / gist:232132ec7bae6dacc349
Created June 21, 2015 06:36
install node on amazon ec2 linux server
sudo yum install nodejs npm --enablerepo=epel
@gabhi
gabhi / gist:b9b97bf691359e91d6ff
Last active August 29, 2015 14:23
beanstalk cli
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html
eb init
eb create
eb open
eb config -change aws:elasticbeanstalk:container:nodejs:NodeCommand to reflect the start command