This file contains 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 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 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 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 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 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 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 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 post also appears on lisper.in.
Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.
Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):
The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.
OlderNewer