This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.concurrent.{BlockingQueue, ArrayBlockingQueue, CountDownLatch, Executors, TimeUnit} | |
| /* | |
| Abstracts away the common pattern of producing items into a queue that are | |
| consumed concurrently by a pool of workers. | |
| */ | |
| class ConcurrentBlockingQueueConsumer[T](queue: BlockingQueue[T], producer: Iterator[T], concurrencyLevel: Int) { | |
| lazy val stopLatch = new CountDownLatch(1) | |
| lazy val pool = Executors.newFixedThreadPool(concurrencyLevel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ever get tired of people messing with your ruby classes? | |
| # now you can put the hammer down and stop them. Just | |
| # include this module and no one will be able to modify the | |
| # class implementation or any instance implementations. | |
| module Stop | |
| module CantTouchThis | |
| def self.included(mod) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isVisible = false; | |
| function onVisible() { | |
| isVisible = true; | |
| jQuery.getScript("http://www.google-analytics.com/ga.js"); | |
| } | |
| if ( document.webkitVisibilityState === undefined || document.webkitVisibilityState === "visible" ) { | |
| onVisible(); | |
| } else { | |
| jQuery.bind( "webkitvisibilitychange", function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'oauth' | |
| require 'awesome_print' | |
| require 'uri' | |
| # Usage: | |
| # 1) Get consumer key/secret from https://dev.twitter.com/apps | |
| # 2) Run ruby oauth_util.rb https://api.twitter.com/statuses/home_timeline.json | |
| # 3) Authorize as instructed | |
| # 4) $$$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LAYOUT=sfdp | |
| SIZE=300 | |
| echo `date`: Producing graph | |
| cat mutual_uoi_follows | perl -ne 's/(\w+)\t(\w+)/"\1"\t->\t"\2"/ and print' | samp 1 | graphify > graph.gv | |
| echo `date`: Splitting out largest connected component | |
| cat graph.gv | ccomps -zX#0 > graph-cc0.gv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| var CSSCriticalPath = function(w, d, opts) { | |
| var opt = opts || {}; | |
| var css = {}; | |
| var pushCSS = function(r) { | |
| if(!!css[r.selectorText] === false) css[r.selectorText] = {}; | |
| var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/); | |
| for(var i = 0; i < styles.length; i++) { | |
| if(!!styles[i] === false) continue; | |
| var pair = styles[i].split(": "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Twit = require("twit"); | |
| var config = require('./oauthconfig'); | |
| console.log("config:"); | |
| console.log(config); | |
| var T = new Twit({ | |
| consumer_key: config.consumer_key, | |
| consumer_secret: config.consumer_secret, | |
| access_token: config.access_token, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Ever get tired of people messing with your ruby classes? | |
| # now you can put the hammer down and stop them. Just | |
| # include this module and no one will be able to modify the | |
| # class implementation or any instance implementations. | |
| module Stop | |
| module CantTouchThis | |
| def self.included(mod) |
OlderNewer