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 com.github.akihiro4chawon.arm._ | |
import scalaz._ | |
import Scalaz._ | |
object Main extends App { | |
import java.io._ | |
// なんの変哲もない部分 | |
def copyStream(is: InputStream, os: OutputStream, buffSize: Int) { | |
val buff = new Array[Byte](buffSize) |
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 com.github.okomok.ken | |
object ArrowLoopFib extends ken.Main { | |
import ken._ | |
import List.{tail, zipWith} | |
import Tuple2.snd | |
val fibSeqFrom = locally { | |
// use Function Arrow in this environment | |
import Function.{app, loop, &&&:, ***:, <<<:, >>>:} |
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 bash | |
# This is very hacky remedy to following error people using sbt | |
# and 2.10.0-M1 release of Scala are going to see: | |
# | |
# API.scala:261: error: type mismatch; | |
# found : API.this.global.tpnme.NameType | |
# (which expands to) API.this.global.TypeName | |
# required: String | |
# sym.isLocalClass || sym.isAnonymousClass || sym.fullName.endsWith(LocalChild) | |
# |
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.collection.JavaConversions._ | |
case class Foo(s: String) | |
val map: Map[Foo, String] = | |
Map( | |
Foo("a") -> "a", | |
Foo("b") -> "b") | |
val v = map.get("a") // should be a type error, actually returns null |
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
sealed trait SList { | |
type Self <: SList | |
type Function[A] | |
def apply[A](f: Function[A]): A | |
def ::[A](a: A) = SCons(a, this.asInstanceOf[Self]) | |
} | |
case object SNil extends SList { | |
type Self = SNil.type | |
type Function[A] = A |
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
// See this mailing list thread for context: | |
// https://groups.google.com/d/topic/scala-language/ImqJuGylyi8/discussion | |
case class Companion[-C, T](t : T) | |
trait Publish[C, T] { self : T => | |
implicit val companion = Companion[C, T](this) | |
} | |
trait StaticKey { |
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
# coding:utf-8 | |
# Usage: ruby aozora_sort.rb URL [--morph] > kokoro_sorted.txt | |
%w(kconv MeCab open-uri rubygems nokogiri).each{|x| require x} | |
def main(argv) | |
morph = argv[1] == '--morph' | |
text = Nokogiri::HTML.parse(open(argv[0]).read).xpath('/html/body').text | |
text.gsub!(/[\r\n\s ]/u, '') | |
arr = morph ? split_with_morph(text) : split_with_char(text) | |
arr.sort.each_with_index do |s, i| |
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
// Written in the D programming language. | |
/** | |
* High peformance downloader | |
* | |
* Implemented according to <a href="http://yusukebe.com/archives/20120229/072808.html">this implementation</a>. | |
* | |
* Example: | |
* ----- | |
* dmd -L-lcurl -run downloader.d |
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
// ==UserScript== | |
// @match http://twitter.com/* | |
// @match https://twitter.com/* | |
// ==/UserScript== | |
elems = document.getElementsByClassName('tweet') | |
for (var i=0; i<elems.length; i++) { | |
e = elems[i]; | |
if (e.nodeName.toLowerCase() == 'div' && | |
e.attributes['data-promoted'] && | |
e.attributes['data-promoted'].value == "true") { |
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
type Product[F[_], G[_], A] = (F[A], G[A]) | |
trait Prod[F[_], G[_]] { | |
type and[H[_]] = Prod[F, ({type λ[α] = Prod[G, H, α]})#λ] | |
type apply[A] = (F[A], G[A]) | |
} | |
type product[F[_], G[_]] = Prod[F, G] | |
type Coproduct[F[_], G[_], A] = Either[F[A], G[A]] |