Created by Christopher Manning
Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.
The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.
| /* | |
| * Example how to preload HTML5 video on the iPad (iOS 3.2+) | |
| * @author Miller Medeiros | |
| * Released under WTFPL | |
| */ | |
| var vid = document.createElement('video'); | |
| vid.src = 'lol_catz.mp4'; | |
| document.getElementById('video-holder').appendChild(vid); |
Created by Christopher Manning
Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.
The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.
| 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 |
| import scala.concurrent.duration._ | |
| import scala.concurrent.ExecutionContext | |
| import scala.concurrent.Future | |
| import akka.pattern.after | |
| import akka.actor.Scheduler | |
| /** | |
| * Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown, | |
| * in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through | |
| * the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure. |
| import tools.nsc.interpreter.IMain | |
| import tools.nsc.Settings | |
| object CommaSeperatedData extends App { | |
| val data = """ "Doe, John", 35, 225, "5'10\"", "555-0123" """ | |
| val settings = new Settings | |
| settings.usejavacp.value = true | |
| val n = new IMain(settings) | |
| n.interpret("List(" + data + ")") |
| def name2id1(name: String): Option[String] = name match { | |
| case "name1" => Some("id1") | |
| case "name2" => Some("id2") | |
| case "name3" => Some("id3") | |
| case _ => None | |
| } | |
| def name2id2(name: String): Option[String] = name match { | |
| case "name1" => None | |
| case "name2" => Some("id2") | |
| case "name3" => Some("id3") |
| package akkahttptest | |
| import akka.actor.ActorSystem | |
| import akka.http.Http | |
| import akka.stream.FlowMaterializer | |
| import akka.http.server._ | |
| import akka.http.marshalling.PredefinedToResponseMarshallers._ | |
| import akka.stream.scaladsl.{HeadSink, Source} | |
| object Proxy extends App { |
| sudo yum install libmpc-devel mpfr-devel gmp-devel | |
| cd ~/Downloads | |
| curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O | |
| tar xvfj gcc-4.9.2.tar.bz2 | |
| cd gcc-4.9.2 | |
| ./configure --disable-multilib --enable-languages=c,c++ | |
| make -j 4 | |
| make install |
计算一组Range所覆盖的不重复整数的个数,求 < O(n*n) 的算法。
def cover(rs: Range*):Int = ???
assert(cover(0 to 4, 1 to 5) == 6)
assert(cover(0 to 4, 1 to 3) == 5)
assert(cover(0 to 4, 6 to 7) == 7)
assert(cover(0 to 4, 6 to 7, 2 to 6) == 8)| package com.gtan.turing | |
| import akka.shapeless.HNil | |
| import org.parboiled2._ | |
| import scala.util.Try | |
| /** | |
| * Created by zhang on 2015/7/14. | |
| */ |