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 Thrift < Formula | |
desc "Framework for scalable cross-language services development" | |
homepage "https://thrift.apache.org/" | |
url "https://www.apache.org/dyn/closer.cgi?path=/thrift/0.13.0/thrift-0.13.0.tar.gz" | |
sha256 "7ad348b88033af46ce49148097afe354d513c1fca7c607b59c33ebb6064b5179" | |
bottle do | |
cellar :any | |
sha256 "3a6dccee60ca25d75f99245cc46a7d84351c87c654b77837c3370c5247c80c49" => :catalina | |
sha256 "385c454b28a354be187de75d67c0133bca17cd1341f1e1abd10cba368e29a80d" => :mojave |
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 strchr(char *s, char c) { | |
// Return the index of the first occurrence of `c` in `s`. If there are | |
// no occurrences, return the length of `s`. | |
// Ex: | |
// strchr("Hello world", 'l') | |
// > 2 | |
// strchr("Hello world", 'z') | |
// > 11 | |
} |
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 Game2048(object): | |
def __init__(self, s):self.s = s | |
def input(self, d): | |
from itertools import product as b;import random as h | |
e,f,z,w=[0,1,0,-1],[1,0,-1,0],range,len;r=z(4);g=b(r,r) | |
t=[(x,y)for x,y in g if not(0<=x-e[d]<4and 0<=y-f[d]<4)] | |
for (x,y),s in zip(t,[self.s]*w(t)): | |
l,k=[v for v in[s[x+i*e[d]][y+i*f[d]]for i in r]if v],[] | |
for i,g,a in zip(z(w(l)),[b(r,r)]*w(l),[h.choice]*w(l)): | |
k+=((i<w(l)-1and l[i]==l[i+1])and(i==0 or not k[i-1]),) |
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
@RunWith(classOf[JUnitRunner]) | |
class YQLTest extends Specification with YQL { | |
implicit val system = ActorSystem("yql-test") | |
"YQL" should { | |
"issue request and get response" in { | |
val query = | |
"""select * from yahoo.finance.quote |
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 scala.concurrent._ | |
import akka.actor.ActorSystem | |
import spray.http._ | |
import HttpMethods._ | |
import spray.client.pipelining._ | |
trait YQL { | |
implicit val system: ActorSystem | |
import system.dispatcher |
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
object SequenceExample extends App { | |
val seq1 = new ArithmeticSequence(5, 3) | |
val seq2 = for (x <- seq1) yield x * x | |
val seq3 = for (x <- seq2) yield if (x % 2 == 0) x else 0 | |
println(s"${seq1(4)} ${seq2(4)} ${seq3(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
trait Sequence { | |
def apply(i: Int): Int | |
def map(f: Int => Int): Sequence | |
} | |
class ArithmeticSequence(start: Int, diff: Int) extends Sequence { | |
def apply(i: Int): Int = start + i * diff | |
def map(f: Int => Int): Sequence = new MappedSequence(this, f) | |
} |
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 WebClient { | |
private val cache = // ... | |
private val rdbms = // ... | |
def get(key: String): Option[String] = { | |
val cachedValue = cache.get(key) | |
cachedValue.orElse { | |
val dbValue = rdbms.get(key) | |
dbValue.foreach(cache.put(key, _)) |
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 UnaryFunction interface { | |
Apply(x int) int | |
} | |
type UnaryInvertible interface { | |
Invert() UnaryFunction | |
} | |
type PlusOne struct {} | |
type MinusOne struct {} |
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 sem = make(chan int, MaxOutstanding) | |
func init() { | |
for i := 0; i < MaxOutstanding; i++ { | |
sem <- 1 | |
} | |
} | |
func Serve(queue chan *Request) { | |
for req := range queue { |
NewerOlder