Skip to content

Instantly share code, notes, and snippets.

View itsprdp's full-sized avatar

Pradeep Gangadharaiah itsprdp

View GitHub Profile
@itsprdp
itsprdp / grouped-bar-d3.html
Created February 18, 2015 07:35
Grouped bar chart with d3
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
@itsprdp
itsprdp / dual-y-axes-line-chart-d3.html
Created February 18, 2015 07:36
Dual y axes line chart using d3.js
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<style>
path {
fill: none;
}
.axis {
@itsprdp
itsprdp / Dual-y-Axes-grouped-bar-chart-using-d3.markdown
Created February 18, 2015 12:32
Dual y-Axes grouped bar chart using d3
@itsprdp
itsprdp / blah
Created February 22, 2015 17:16
Sys V-init.d example. Equivalent to upstart
#! /bin/sh
# /etc/init.d/blah
#
# Some things that run always
touch /var/lock/blah
# Carry out specific functions when asked to by the system
case "$1" in
start)
# place in lib/tasks/
namespace :sidekiq do
desc "Strano | Stop sidekiq"
task :stop do
system "bundle exec sidekiqctl stop #{pidfile}"
end
desc "Strano | Start sidekiq"
task :start do
@itsprdp
itsprdp / delayed_job_service.erb
Created March 26, 2015 11:42
# Systemd service for delayed_job. File path: etc/systemd/system/delayed_job.service
[Unit]
Description=Delayed Job - Database based asynchronous priority queue system
[Service]
Type=forking
PIDFile=/home/<%= fetch(:user) %>/<%= fetch(:application) %>/current/tmp/pids/delayed_job.pid
ExecStartPre=/bin/rm -f /home/<%= fetch(:user) %>/<%= fetch(:application) %>/current/tmp/pids/delayed_job.pid
ExecStart=/etc/init.d/delayed_job start
Restart=always
#!/usr/bin/env bash
APP_DIR=<%= current_path %>
CURRENT_DIR="cd $APP_DIR"
STAGE=<%= fetch(:stage) %>
DJ_PID="$APP_DIR/tmp/pids/delayed_job.pid"
check_pid(){
if [ -f $DJ_PID ]; then
PID=`cat $DJ_PID`

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@itsprdp
itsprdp / data.json
Created July 11, 2015 18:33
D3 Pie Chart
[
{"apples": 53245, "oranges": 200},
{"apples": 28479, "oranges": 200},
{"apples": 19697, "oranges": 200},
{"apples": 24037, "oranges": 200},
{"apples": 40245, "oranges": 200}
]
@itsprdp
itsprdp / vagrant.log
Last active August 29, 2015 14:26
Vagrant up log
$ vagrant up
Bringing machine 'management' up with 'virtualbox' provider...
Bringing machine 'lb' up with 'virtualbox' provider...
Bringing machine 'web1' up with 'virtualbox' provider...
Bringing machine 'web2' up with 'virtualbox' provider...
==> management: Importing base box 'ubuntu/trusty64'...
==> management: Matching MAC address for NAT networking...
==> management: Checking if box 'ubuntu/trusty64' is up to date...
==> management: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> management: have version '20150521.0.0'. The latest is version '20150609.0.10'. Run