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
#!/usr/bin/env ruby | |
# Simple summary-to-full-feed proxy for a single, hard-coded feed. | |
# Caches each entry by GUID and timestamp. | |
FEED = "http://mylittleboudoir.com/feed/" | |
CACHE_DIR = "/tmp" | |
require "open-uri" | |
require "rubygems" | |
require "nokogiri" |
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
# Want to show hidden files and folders in your TextMate project drawer? Simple, just modify the file and folder patterns in TextMate's preferences. | |
# Instructions: | |
# Go to TextMate > Preferences... | |
# Click Advanced | |
# Select Folder References | |
# Replace the following: | |
# File Pattern |
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
// A simple Tweet POJO: | |
// $> javac TweetEvent.java | |
public class TweetEvent { | |
private String user; | |
private String text; | |
private String timezone; | |
private int retweets; | |
public TweetEvent(String user, String text, String timezone, int retweets) { |
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
trait Enum { //DIY enum type | |
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia | |
type EnumVal <: Value //This is a type that needs to be found in the implementing class | |
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values | |
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal | |
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS} | |
val oldVec = get |
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
(extend-type js/RegExp | |
cljs.core/IFn | |
(-invoke ([this s] (re-matches this s)))) | |
(#"foo.*" "foobar") ;=> "foobar" | |
(#"zoo.*" "foobar") ;=> nil | |
(filter #".*foo.*" ["foobar" "goobar" "foobaz"]) ;=> ("foobar" "foobaz") |
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
(ns extmap | |
(:import | |
[clojure.lang ILookup Associative])) | |
;; ---------------------------------------------------------------- | |
;; TrackableMap is a persistent map which keeps track of the number of | |
;; times `get` was called on it. | |
(defprotocol Trackable | |
(getStats [self])) |
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
(use '[clojure.core.match :only [match]]) | |
(defn evaluate [env [sym x y]] | |
(match [sym] | |
['Number] x | |
['Add] (+ (evaluate env x) (evaluate env y)) | |
['Multiply] (* (evaluate env x) (evaluate env y)) | |
['Variable] (env x))) | |
(def environment {"a" 3, "b" 4, "c" 5}) |
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
package com.md_5.jcaptive; | |
import io.netty.bootstrap.Bootstrap; | |
import io.netty.bootstrap.ServerBootstrap; | |
import io.netty.channel.Channel; | |
import io.netty.channel.ChannelFuture; | |
import io.netty.channel.ChannelFutureListener; | |
import io.netty.channel.ChannelHandlerContext; | |
import io.netty.channel.ChannelInboundMessageHandlerAdapter; | |
import io.netty.channel.ChannelInitializer; |
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
macro sexp { | |
case () => { | |
; | |
} | |
case ($p) => { | |
$p | |
} | |
case ($x $y) => { | |
$x($y); | |
} |
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
#lang racket | |
(define dict "/etc/dictionaries-common/words") | |
(define (choose l) (list-ref l (random (length l)))) | |
(define words (for/list ([i (file->lines dict)] | |
#:when (regexp-match? "^[a-z]*$" i) | |
#:when (3 . < . (string-length i)) | |
#:when (10 . > . (string-length i))) | |
i)) |
OlderNewer