Skip to content

Instantly share code, notes, and snippets.

@nebirhos
nebirhos / README.md
Last active Sep 4, 2018
Convert AngularJS templateUrl to template with jscodeshift
View README.md

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

View postgresql.md

Templates

Create a template

=> CREATE DATABASE foo TEMPLATE template0;
=> \c foo
...set up template...
=> UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'foo';
View 000 :: Unicorn + Upstart + Capistrano 3 :: README.md
@nebirhos
nebirhos / slowconnection
Last active Aug 29, 2015 — forked from trongthanh/gist:1196596
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
View slowconnection
#!/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
View cached-bundle
#!/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 / 000-Guard::LiveReload README.md
Last active Mar 5, 2016
Multi device Guard::LiveReload with Chrome Android
View 000-Guard::LiveReload README.md
View strozziscrape.rb
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)
@nebirhos
nebirhos / jquery.ajax.progress.js
Created Oct 15, 2012 — forked from db/jquery.ajax.progress.js
add XHR2 upload and download progress events to jQuery.ajax
View jquery.ajax.progress.js
(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 / dropbox
Created Oct 4, 2012 — forked from migrs/dropbox
/etc/init.d/dropbox
View 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 / e
Created May 26, 2011
Emacsclient wrapper
View e
#!/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`
You can’t perform that action at this time.