Skip to content

Instantly share code, notes, and snippets.

View arbaaz's full-sized avatar
🔥
Building an amazing product

Arbaaz arbaaz

🔥
Building an amazing product
View GitHub Profile
@arbaaz
arbaaz / storageMiddleware.js
Created April 30, 2017 10:56
Storage middleware
// utils/storage.js
export default function () {
return next => (reducer, initialState) => {
const store = next(reducer, initialState);
store.subscribe(() => {
const state = store.getState();
saveState(state);
});
return store;
@arbaaz
arbaaz / gist:1a7ca124d698af3219cd
Created March 1, 2016 08:41 — forked from trcarden/gist:3295935
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@arbaaz
arbaaz / latency.markdown
Created January 28, 2016 08:15 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

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

@arbaaz
arbaaz / install_postgres.sh
Created December 10, 2015 10:05 — forked from acsrujan/install_postgres.sh
Installs postgres 9.3
sudo touch /etc/apt/sources.list.d/pgdg.list
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-9.3 libpq-dev postgresql-contrib-9.3
sudo apt-get autoremove
sudo pg_dropcluster --stop 9.3 main
sudo pg_createcluster --start -e UTF-8 9.3 main
@arbaaz
arbaaz / .tmux.conf
Created November 8, 2015 07:19
Tmux Conf
unbind C-b
set -g prefix C-s
bind-key -r C-s send-prefix
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
# Smart pane switching with awareness of vim splits
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
@arbaaz
arbaaz / gist:c5e87738a7cabe6ce1e2
Created October 28, 2015 13:55 — forked from procky/gist:2fa788d564ce0850aa76
fuzzy search collections in backbone.js with fuse.js
// backbone collections lack a search functionality. This adds it to all collections.
// fuse.js is the library that powers the fuzzy search and requires being downloaded and included into your app
// http://kiro.me/projects/fuse.html
_.extend(Backbone.Collection.prototype, {
searchableFields: null,
buildSearchIndex: function(options) {
options = (typeof options !== 'undefined') ? options : {};
@arbaaz
arbaaz / import_json_appsscript.js
Last active August 29, 2015 14:27 — forked from chrislkeller/import_json_appsscript.js
Adds what amounts to an =ImportJSON() function to a Google spreadsheet... To use go to Tools --> Script Editor and add the script and save.
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@arbaaz
arbaaz / enc.gitattributes
Created May 12, 2015 19:24
enc.gitattributes
[filter "openssl"]
smudge = ~/.gitencrypt/smudge_filter_openssl
clean = ~/.gitencrypt/clean_filter_openssl
[diff "openssl"]
textconv = ~/.gitencrypt/diff_filter_openssl
@arbaaz
arbaaz / ph.js
Created February 6, 2015 14:20
phantom js log console.log messages in terminal of url
var args = require('system').args;
var page = require('webpage').create();
var url = 'http://localhost:3000/central/src/index.html#';
console.log('Loading a web page');
if (args.length === 1) {
console.log('Try to pass some arguments when invoking this script!');
phantom.exit();
} else {
url = url + args[1];
page.onConsoleMessage = function(msg) {
@arbaaz
arbaaz / new_line_remove.thor
Created February 3, 2015 08:52
remove last new line from all the files in the given folder
class Rboo < Thor
desc "remove_last_line dir", "remove last line from the all the files in the directory"
def remove_last_line(dir)
puts "You supplied the dir: #{dir}"
files = Dir["#{dir}/**/*.js"]
files.each do |filename|
puts filename
content = File.open(filename, "rb") { |io| io.read }
File.open(filename, "wb") { |io|
io.print content.chomp