This file contains hidden or 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 CommonCache | |
def initialize(prefix, expire) | |
@prefix = prefix | |
@expire = expire | |
end | |
def key(id) | |
"#{@prefix}_#{id}" | |
end |
This file contains hidden or 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 python3 | |
# -*- coding:utf-8 -*- | |
import sys | |
import redis | |
HOST_NAME = "" | |
DB_NUMBER = 0 | |
if __name__ == "__main__": |
This file contains hidden or 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.nio.file.{Path, Files => JFiles} | |
import java.nio.file.attribute.BasicFileAttributes | |
import java.util.function.{BiPredicate, Consumer} | |
import scala.collection.JavaConverters._ | |
object Files { | |
import JFunction._ | |
def find(path: Path, depth: Int = Int.MaxValue)(matcher: (Path, BasicFileAttributes) => Boolean): Iterator[Path] = | |
JFiles.find(path, depth, matcher.asJava).iterator().asScala |
This file contains hidden or 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 actors | |
import java.net.URI | |
import akka.actor.{Actor, ActorRef, Props} | |
import akka.pattern.{ask, pipe} | |
import akka.util.Timeout | |
import skinny.http.HTTP | |
import scala.collection.mutable |
This file contains hidden or 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
#MAKE_FLAGS="-j2" |
This file contains hidden or 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.io.StdIn | |
object Main extends App { | |
val input = StdIn.readLine() | |
val heights = input.foldLeft(Seq(0)) { case (hs, x) => | |
val add = x match { | |
case '\\' => hs.last - 1 | |
case '/' => hs.last + 1 | |
case '_' => hs.last | |
} |
This file contains hidden or 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 InsertionSort { | |
def sort[A](ary: Array[A])(implicit ord: math.Ordering[A]): Unit = { | |
if(2 <= ary.length) { | |
ary.indices.tail.foreach { i => | |
val j = (0 until i).indexWhere { j => ord.lt(ary(i), ary(j)) } | |
if(0 <= j) insert(ary, i, j) | |
println(ary.mkString("(", ", ", ")")) | |
} | |
} |
This file contains hidden or 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
#include <stdio.h> | |
#include <math.h> | |
typedef struct { | |
double x; | |
double y; | |
} point_t; | |
typedef struct { | |
point_t* center; |
This file contains hidden or 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.io.File | |
import javax.imageio.ImageIO | |
object Main extends App { | |
assert(args.nonEmpty) | |
val image = ImageIO.read(new File(args.head)) | |
println(image.getWidth, image.getHeight) | |
} |
This file contains hidden or 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/sh | |
java -jar $HOME/.sbt/launchers/0.13.9/sbt-launch.jar -Dsbt.main.class=sbt.ScriptMain -Dsbt.boot.directory=$HOME/.sbt/boot "$@" |