Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# Usage: cached-bundle install --deployment
#
# After running `bundle`, caches the `vendor/bundle` directory to S3.
# On the next run, restores the cached directory before running `bundle`.
# When `Gemfile.lock` changes, the cache gets rebuilt.
#
# Requirements:
# - Gemfile.lock
# - REPO_SLUG
@nebirhos
nebirhos / slowconnection
Last active August 29, 2015 14:04 — forked from trongthanh/gist:1196596
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
#!/bin/bash
# Refer: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delaying_only_some_traffic
# Refer: http://www.bomisofmab.com/blog/?p=100
# Refer: http://drija.com/linux/41983/simulating-a-low-bandwidth-high-latency-network-connection-on-linux/
case "$1" in
start)
# Setup the rate control and delay
sudo tc qdisc add dev lo root handle 1: htb default 12
@nebirhos
nebirhos / e
Created May 26, 2011 01:32
Emacsclient wrapper
#!/bin/bash
# e - Edit file in emacs client, launchin emacs daemon if necessary
# alternate falls on emacs --daemon
EMACS='emacsclient --alternate-editor=""'
# count opened window frames
XFRAMES=`emacsclient -e "(frame-list)" 2>/dev/null | grep -o '#<frame [^F][^>]*>' | wc -l`
@nebirhos
nebirhos / dropbox
Created October 4, 2012 08:25 — forked from migrs/dropbox
/etc/init.d/dropbox
# /etc/init.d/dropbox
### BEGIN INIT INFO
# Provides: dropbox
# Required-Start: $network $syslog $remote_fs
# Required-Stop: $network $syslog $remote_fs
# Should-Start: $named $time
# Should-Stop: $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop the dropbox daemon for debian/ubuntu
@nebirhos
nebirhos / strozziscrape.rb
Created November 5, 2012 13:12
Grabs exposition images from www.palazzostrozzi.org
require "rubygems"
require "mechanize"
url = "http://www.palazzostrozzi.org/AnagraficaOpere.jsp?idForm=13&idMostra=%u"
browser = Mechanize.new { |agent| agent.user_agent_alias = 'Mac Safari' }
(1..20).each do |id_mostra|
begin
page = browser.get(url % id_mostra)

Templates

Create a template

=> CREATE DATABASE foo TEMPLATE template0;
=> \c foo
...set up template...
=> UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'foo';
@nebirhos
nebirhos / jquery.ajax.progress.js
Created October 15, 2012 11:26 — forked from db/jquery.ajax.progress.js
add XHR2 upload and download progress events to jQuery.ajax
(function addXhrProgressEvent($) {
var originalXhr = $.ajaxSettings.xhr;
$.ajaxSetup({
xhr: function() {
var req = originalXhr(), that = this;
if (req) {
if (typeof req.addEventListener == "function" && that.progress !== undefined) {
req.addEventListener("progress", function(evt) {
that.progress(evt);
}, false);
@nebirhos
nebirhos / 000 :: Unicorn + Upstart + Capistrano 3 :: README.md
Last active August 30, 2017 00:56
Unicorn + Upstart + Capistrano 3
@nebirhos
nebirhos / README.md
Last active May 26, 2019 23:55
Convert AngularJS templateUrl to template with jscodeshift

Convert AngularJS templateUrl to template with jscodeshift

npm install -g jscodeshift@0.3.32

jscodeshift -t codemods/templateCacheToWebpackImport.js src/

See https://github.com/cpojer/js-codemod

@nebirhos
nebirhos / 000-Guard::LiveReload README.md
Last active May 19, 2020 10:19
Multi device Guard::LiveReload with Chrome Android