Skip to content

Instantly share code, notes, and snippets.

@helena
helena / TrySamples.scala
Last active July 13, 2021 15:03
Try introduced in Scala 2.10.0
// Start by adding these
import scala.util.{ Try, Success, Failure }
/**
* Sample runs code that raises the exception:
* java.lang.ArithmeticException: / by zero
*/
object Sample {
def main(args: Array[String]): Unit = {
@taichi
taichi / testing_javascript.md
Last active February 7, 2018 00:09
javascript におけるユニットテストについて (2013/01)

javascript におけるユニットテストについて (2013/01)

ここの所、数か月おきにjsのユニットテストってどうやるのが良いのか悩んでいる気がするので、一つ情報集約の為にメモ書きをしておきます。

何かちゃんと文章書いておけば、それに対する反応が集まって、オレサマハッピー的な展開を望んでいます。

そもそも何を探しているのか

単体テストというか、ユニットテストというか、そういうアレを書く為のフレームワークを探しています。
覚える事が少なくて強力なやつ。

機能テストというか、e2eテストいうか、そういうアレの事は別途考える必要がありますので、今回はスコープ外とします。

@puffnfresh
puffnfresh / deferredmonad.js
Created February 7, 2013 05:17
jQuery.Deferred's monad
(function() {
function bind(d, f) {
return d.pipe(f)
}
function point(a) {
var d = $.Deferred();
d.resolve(a);
return d.promise();
}
@jdegoes
jdegoes / DataScienceInScala.scala
Created February 8, 2013 15:11
Example code for the Creating a Data Science Platform in Scala talk.
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)
@pthariensflame
pthariensflame / IndexedState.md
Last active June 15, 2022 18:42
An introduction to the indexed state monad in Haskell, Scala, and C#.

The Indexed State Monad in Haskell, Scala, and C#

Have you ever had to write code that made a complex series of succesive modifications to a single piece of mutable state? (Almost certainly yes.)

Did you ever wish you could make the compiler tell you if a particular operation on the state was illegal at a given point in the modifications? (If you're a fan of static typing, probably yes.)

If that's the case, the indexed state monad can help!

Motivation

@halcat0x15a
halcat0x15a / gist:5075401
Last active December 14, 2015 10:58
Machines and Argonaut
import scala.util.Try
import scalaz._, Scalaz._
import scalaz.effect._, IO._
import com.clarifi.machines._
import argonaut._, Argonaut._
object Sample extends SafeApp {
@halcat0x15a
halcat0x15a / TwitterMachine.scala
Last active December 15, 2015 00:28
Twitter User Streams with scala-machines!
import scala.language.postfixOps
import java.io._
import scalaj.http._
import scalaz._, Scalaz._
import scalaz.effect._, Effect._, IO._
import scalaz.concurrent.Promise
@halcat0x15a
halcat0x15a / gist:5180752
Created March 17, 2013 09:07
渋谷.cljの資料

!SLIDE

純粋な世界で生きるために

halcat0x15a

!SLIDE

基本的なアプリケーション

@xuwei-k
xuwei-k / keys-scala.diff
Last active December 15, 2015 02:49
git diff v0.12.3:main/Keys.scala v0.13.0-M2:main/src/main/scala/sbt/Keys.scala
diff --git a/v0.12.3:main/Keys.scala b/v0.13.0-M2:main/src/main/scala/sbt/Keys.scala
index 49bf4d1..fa0e04e 100644
--- a/v0.12.3:main/Keys.scala
+++ b/v0.13.0-M2:main/src/main/scala/sbt/Keys.scala
@@ -5,7 +5,7 @@ package sbt
import java.io.File
import java.net.URL
- import Project.ScopedKey
+ import Def.ScopedKey