Skip to content

Instantly share code, notes, and snippets.

View cmthakur's full-sized avatar
🎯
Focusing

Chandra M. Thakur cmthakur

🎯
Focusing
View GitHub Profile
@cmthakur
cmthakur / jquery.preload.js
Created September 18, 2012 09:37 — forked from mathiasbynens/jquery.preload.js
JavaScript preload() function
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
require 'sinatra/base'
require 'rack/flash'
require 'warden'
require 'slim'
require 'sequel'
require 'sqlite3'
DB = Sequel.sqlite
DB.create_table :users do
primary_key :id
@cmthakur
cmthakur / es.sh
Created September 23, 2013 19:09 — forked from sgringwe/es.sh
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre-headless -y
# Download the compiled elasticsearch rather than the source.
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
#!/bin/bash -ex
# Assumes:
# homebrew
# chruby
# ruby-install
# postgres.app
# this bit might not be necessary, but can't hurt
brew upgrade ruby-install

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
@cmthakur
cmthakur / _flash_messages.html.erb
Last active August 29, 2015 14:18 — forked from roberto/_flash_messages.html.erb
How to add flash message in Rails 4
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> alert-dismissable fade in">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<%= message %>
</div>
<% end %>
@cmthakur
cmthakur / application.rb
Last active August 29, 2015 14:26 — forked from basti/application.rb
Local Rails 4 assets precompilation using Capistrano 3 and rsync
# Speed things up by not loading Rails env
config.assets.initialize_on_precompile = false
@cmthakur
cmthakur / digital_ocean_setup.md
Last active August 29, 2015 14:26 — forked from ChuckJHardy/digital_ocean_setup.md
DigitalOcean Ubuntu 14.04 x64 + Rails 4 + Nginx + Unicorn + PostgreSQL + Capistrano 3 Setup Instructions