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
class C | |
{ | |
static C() | |
{ | |
// Let's run the initialization on another thread! | |
var thread = new System.Threading.Thread(Initialize); | |
thread.Start(); | |
thread.Join(); | |
} | |
static void Initialize() { } |
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
(def ^{:private true} not-nil? (comp not nil?)) | |
(defprotocol Matcher | |
"Protocol for types that can be used to search a Hiccup data structure." | |
(matches [this elem])) | |
(defn- comp-name [x y] | |
(and (not-nil? y) (= (name x) (name y)))) | |
(extend-protocol Matcher |
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
type Partition[A] = List[List[A]] | |
def partitions[A](xs: List[A]): List[Partition[A]] = l match { | |
case Nil => Nil | |
case h :: Nil => List(List(List(h))) | |
case h :: t => | |
val ps = partitions(t) | |
ps.map(List(h) :: _) ::: ps.flatMap(interpolate(h, _)) | |
} |
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
int conditional(int x, int y, int z) { | |
int nx = !x - 1; | |
return (nx & y) | (~nx & z); | |
} |
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
nSumCombinations :: (Integral a) => Int -> a -> [a] -> [[a]] | |
nSumCombinations _ _ [] = [] | |
nSumCombinations 1 s xs = map (\x -> [x]) $ filter (== s) xs | |
nSumCombinations n s (x:xs) = (map (x:) $ nSumCombinations (n - 1) (s - x) xs) ++ (nSumCombinations n s xs) |
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
//harry huang [huanghui.huang@gmail.com] | |
// | |
//After reading the original post [http://jboner.github.com/2008/10/06/real-world-scala-dependency-injection-di.html, ] | |
//the original cake pattern seems quite verbose for me, and it is quite invasive, so I spent a bit time | |
//and come up with an improved version of cake pattern, which I call it "Auto Cake DI". It is working | |
//well with any POST(plain old scala trait)/POSO(plain old scala object) which means that anything can be | |
//injected without modification or introducing new traits. | |
/*---------inject trait---------*/ | |
trait Inject[+T] { def inject: T } |
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
On page 3, 2nd column bottom: a = ⊥, b = 1 or a = 1 <- I think it should be 2. | |
On page 4, start of 2nd column: "applied to as applied to" seems to have an | |
extra "applied to". | |
On page 5, overview: it's said that it's the transaction that has sibling items, | |
but from the rest of the paper it would seem better to say that it's the version | |
that has sibling items. | |
On page 5, in the description of RAMP-List, can it be said that two versions are |
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.{Timer, TimerTask} | |
import scala.concurrent.duration._ | |
import rx.lang.scala.{Observable, Observer, Subscription, Scheduler} | |
import rx.lang.scala.observables.ConnectableObservable | |
import rx.lang.scala.subscriptions.{CompositeSubscription, MultipleAssignmentSubscription} | |
import rx.lang.scala.schedulers.NewThreadScheduler | |
object RxExplorations{ | |
implicit class SchedulerOps(val s: Scheduler) extends AnyVal { |
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.ConcurrentLinkedQueue; | |
import java.util.concurrent.CyclicBarrier; | |
import static java.lang.System.out; | |
public class CLQ { | |
public static final long WARMUP_ITERATIONS = 100L * 1000L; | |
public static final long ITERATIONS = 25L * 1000L * 1000L; | |
static private long[] consumptions; |
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 | |
# | |
# Bash must have been compiled with this ability: --enable-net-redirections | |
# The device files below do not actually exist. | |
# Use /dev/udp for UDP sockets | |
exec 3<>/dev/tcp/host/port | |
# Write to the socket as with any file descriptor | |
echo "Write this to the socket" >&3 |