Skip to content

Instantly share code, notes, and snippets.

View francisluong's full-sized avatar

Francis Luong (Franco) francisluong

View GitHub Profile
@francisluong
francisluong / DefaultKeyBinding.dict
Last active September 6, 2015 20:03
~/Library/KeyBindings/DefaultKeyBinding.dict - remap home and end keys in OSX
{
// via http://apple.stackexchange.com/questions/16135/remap-home-and-end-to-beginning-and-end-of-line
"\UF729" = moveToBeginningOfParagraph:; // home
"\UF72B" = moveToEndOfParagraph:; // end
"$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
"$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
// Add to ~/Library/KeyBindings/DefaultKeyBinding.dict and restart your program.
}
@francisluong
francisluong / Vagrantfile
Last active September 19, 2015 19:18
Vagrant Bootstrapping for Ubuntu
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "public_network"
config.vm.synced_folder "../data", "/vagrant_data"
$ gem build expect-behaviors.gemspec
WARNING: open-ended dependency on net-ssh (>= 0) is not recommended
if net-ssh is semantically versioned, use:
add_runtime_dependency 'net-ssh', '~> 0'
WARNING: open-ended dependency on codeclimate-test-reporter (>= 0, development) is not recommended
if codeclimate-test-reporter is semantically versioned, use:
add_development_dependency 'codeclimate-test-reporter', '~> 0'
WARNING: pessimistic dependency on mocha (~> 1.1.0, development) may be overly strict
if mocha is semantically versioned, use:
add_development_dependency 'mocha', '~> 1.1', '>= 1.1.0'
require 'eventmachine'
require 'em-http'
require 'logger'
class HTTPAsyncMulti
@@multi = []
@@multi_done = []
@@concurrency = 2
@@logger = Logger.new($stdout)
@francisluong
francisluong / em-http-000.rb
Last active July 24, 2016 20:38
EM-HTTP-Request - Example 000 - Single Request
require 'eventmachine'
require 'em-http-request'
require 'logger'
require 'pry'
##
# Single request
@start_time = Time.now
@logger = Logger.new($stdout)
@francisluong
francisluong / em-http-020-async-with-em-iterator.rb
Last active July 24, 2016 20:55
EM-HTTP-Request - Example 020 - Async Concurrency Limit using EM-Iterator
require 'eventmachine'
require 'em-http-request'
require 'logger'
require 'pry'
##
# concurrent requests with EM::Iterator concurrency limit of 2
FIVE = 'http://ipv4.download.thinkbroadband.com/5MB.zip'
TEN = 'http://ipv4.download.thinkbroadband.com/10MB.zip'
@francisluong
francisluong / em-http-010-async.rb
Last active July 24, 2016 21:13
EM-HTTP-Request - Example 010 - Async Concurrency
require 'eventmachine'
require 'em-http-request'
require 'logger'
require 'pry'
##
# concurrent requests without concurrency limits
FIVE = 'http://ipv4.download.thinkbroadband.com/5MB.zip'
TEN = 'http://ipv4.download.thinkbroadband.com/10MB.zip'
user=> (def c [{:next-hop "192.168.1.1", :prefix "172.16.1.1/32", :route-status "*|e"}
#_=> {:next-hop "192.168.255.255", :prefix nil, :route-status "*>e"}])
#'user/c
user=>
user=> (let [prev (atom nil)]
#_=> (map (fn [r]
#_=> (if (and @prev (not (:prefix r)))
#_=> (assoc r :prefix @prev)
#_=> (do (reset! prev (:prefix r))
@francisluong
francisluong / screen.lock.automator.applescript
Created December 15, 2014 22:28
OSX Automator Applescript to Create a Start Screensaver (Lock Screen) Hotkey
#Service receives *no input* in *any application*
# bind to ctrl-alt-l in keyboard shortcuts
on run {input, parameters}
tell application "System Events" to start current screen saver
return input
end run
@francisluong
francisluong / remove_namespace.xslt
Created June 29, 2014 19:16
XSLT to Remove Namespaces
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<!-- stylesheet to remove all namespaces from a document -->
<!-- note: this will lead to attribute name clash if an element contains two attributes with same local name but different namespace prefix -->
<!-- template to copy elements -->
<xsl:template match="*">
<xsl:element name="{local-name()}">