Skip to content

Instantly share code, notes, and snippets.

View Actors.scala
package hellodotty
import java.util.concurrent.LinkedTransferQueue
import scala.collection._
import scala.concurrent.ExecutionContext
import scala.reflect.ClassTag
object Actors:
trait Channel[A]:

Keybase proof

I hereby claim:

  • I am weihsiu on github.
  • I am weihsiu ( on keybase.
  • I have a public key ASB6GjLt6f3b4py5zOvdVa4qaBLoBjdXeSCxHNPXrsS5HAo

To claim this, I am signing this object:

View NGrams2.scala
package ngrams
import{ BufferedReader, FileReader }
import scala.collection.mutable
object NGrams2 extends App {
val start = System.currentTimeMillis
// download from
val br = new BufferedReader(new FileReader("ngrams.tsv"))
val kvs = mutable.Map.empty[String, Int]
weihsiu / GuessTheNumber.scala
Created Apr 11, 2017
Example of using Eff monad
View GuessTheNumber.scala
package catssandbox
import aiyou._
import aiyou.implicits._
import cats._
import org.atnos.eff._
import org.atnos.eff.all._
import org.atnos.eff.syntax.all._
import IOEffect._
View Exprs.scala
package matryoshkasandbox
import matryoshka._
import matryoshka.implicits._
import scalaz.Functor
object Exprs extends App {
sealed trait Expr[A]
View gist:53c0e846a23156060272
#include <stdio.h>
// recursive function, "a" is the accumulator
int _reverse(int n, int a) {
if (n < 10)
return n + a;
return _reverse(n / 10, (a + (n % 10)) * 10);
View designer.html
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
weihsiu / interpreter.scala
Created Mar 11, 2012 — forked from chrislewis/interpreter.scala
quick interpreter for nescala
View interpreter.scala
package necsala.embedded
import{Global, Settings}
import{AbstractFile, VirtualDirectory}
import java.util.jar.JarFile
weihsiu / cake_pattern_di.scala
Created Nov 19, 2011 — forked from HarryHuang/cake_pattern_di.scala
Scala Dependency Injection: an improved cake pattern
View cake_pattern_di.scala
//harry huang []
//After reading the original post [, ]
//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 a "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 }
View twitter_translate.user.js
// ==UserScript==
// @name Twitter Translate
// @namespace
// @description Translate tweets in a foreign language to English
// @require
// @include*
// ==/UserScript==
$(document).ready(function() {
function addTranslate() {