Skip to content

Instantly share code, notes, and snippets.

View itsprdp's full-sized avatar

Pradeep Gangadharaiah itsprdp

View GitHub Profile
@itsprdp
itsprdp / git-clone-and-check-out-to-latest.sh
Last active December 21, 2015 10:40
Clone the git repo and checkout to latest tag/release version
git clone <git-url> <dest-dir>
cd <dest-dir>
git checkout tags/$(git tag -l | tail -1)
@itsprdp
itsprdp / carrier_wave.rb
Created November 12, 2015 11:06 — forked from gshaw/carrier_wave.rb
CarrierWave initialization file for testing with fixtures and support S3 in staging and production.
# NullStorage provider for CarrierWave for use in tests. Doesn't actually
# upload or store files but allows test to pass as if files were stored and
# the use of fixtures.
class NullStorage
attr_reader :uploader
def initialize(uploader)
@uploader = uploader
end
@itsprdp
itsprdp / setup
Last active November 10, 2015 10:00
Create postgres superuser with no password for login
####################################################
# WARNING: Don't use this on production environments
####################################################
# Login to psql terminal with postgres user
psql -U postgres
DROP ROLE root; # Run this if role root already exists
CREATE ROLE root WITH SUPERUSER LOGIN PASSWORD NULL;
createdb root;
@itsprdp
itsprdp / tv_series.md
Last active September 20, 2017 02:40
TV Series I have watched till date

Completed

24
Band of Brothers
Breaking Bad
Dexter
Golaith
Friends
HIMYM

@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
@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}
]

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

#!/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`
@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
# 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