Skip to content

Instantly share code, notes, and snippets.

View byteshiva's full-sized avatar
🎯
Focusing

Siva byteshiva

🎯
Focusing
View GitHub Profile

How to install PhantomJS on Ubuntu

Version: 1.9.7

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
@byteshiva
byteshiva / rails-vagrant-provision.sh
Created January 14, 2016 08:45 — forked from johanneswuerbach/rails-vagrant-provision.sh
Provision a vagrant box with ruby stable (using rvm), postgres, redis and node (using nvm)
#!/usr/bin/env bash
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8
sudo apt-get update
sudo apt-get install -y build-essential git curl libxslt1-dev libxml2-dev libssl-dev
# postgres
@byteshiva
byteshiva / Dockerfile
Created February 16, 2016 04:52 — forked from benschw/Dockerfile
MySQL Docker Container
FROM ubuntu
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -s /bin/true /sbin/initctl
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get -y install mysql-client mysql-server
@byteshiva
byteshiva / ConvertFiletoStringWithNewLineSpace.awk
Last active March 8, 2016 11:03
ConvertFiletoStringWithNewLineSpace
awk -v ORS=" " 'BEGIN {print "\""} {printf $0 "\\n"} END {print "\""}' filename
@byteshiva
byteshiva / converToString.sh
Created March 8, 2016 11:16
Shell Script to Convert to String
#!/bin/bash
filename=$1
awk -v ORS=" " 'BEGIN {print "\""} {printf $0 "\\n"} END {print "\""}' $filename | xargs -0 echo
@byteshiva
byteshiva / converToString.sh
Created March 8, 2016 11:16
Shell Script to Convert to String
#!/bin/bash
filename=$1
awk -v ORS=" " 'BEGIN {print "\""} {printf $0 "\\n"} END {print "\""}' $filename | xargs -0 echo
# -*- mode: ruby -*-
# vi: set ft=ruby :
=begin
ModernIE VMs
config.vm.box = "modernIE/vista-ie7"
config.vm.box = "modernIE/w7-ie8"
config.vm.box = "modernIE/w7-ie9"
config.vm.box = "modernIE/w7-ie10"
@byteshiva
byteshiva / search-replace-all.awk
Created March 14, 2016 12:17
Search and Replace all Items
awk -F 'value=' 'function randint(n) { return int(1 + n * rand()) } BEGIN{server[1]="server01";server[2]="server02";zone[1]="us-east"; zone[2]="us-west"; zone[3]="us-north"; zone[4]="us-south"; srand();} {s1=randint(2); t1=randint(4); gsub("server01",server[s1], $1); gsub("us-west",zone[t1],$1); if ($2 == "2.0") print ($1 "value="rand())""; else print $2","}' cpu_data.txt
@byteshiva
byteshiva / ZSPLIT.lua
Created March 18, 2016 10:37 — forked from alexanderscott/ZSPLIT.lua
Redis Lua script to split a ZSET in two (round-robin)
-- @desc: Split a ZSET in two via round-robin
-- @usage: redis-cli eval "$(cat ZSPLIT)" 2 <originalZset> <newZset>
-- @return: list of moved members
local function ZSPLIT(zset1, zset2)
local zset1size = redis.call("ZCARD", zset1)
if zset1size == 0 then return {} end
local members = redis.call("ZREVRANGEBYSCORE", zset1, "+INF", "-INF", "WITHSCORES")
@byteshiva
byteshiva / _helpers.js
Created June 2, 2016 14:22 — forked from elclanrs/_helpers.js
Monads in JavaScript
var extend = function(a, b) {
for (var i in b)
a[i] = b[i];
return a;
};
var fluent = function(f) {
return function() {
var clone = extend(Object.create(null), this);
f.apply(clone, arguments);