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 Project | |
attr_reader :supervisor | |
# assume supervisor looks like: | |
# ["Harry", "Henderson", "hhendersonfake@me.com"] | |
def initialize(supervisor) | |
@supervisor = supervisor | |
end |
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
require 'hamster' | |
require 'hamster/experimental/mutable_hash' | |
# a bunch of threads with a read/write ratio of 10:1 | |
num_threads = 100 | |
num_reads_per_write = 10 | |
num_loops = 500 | |
hsh = Hamster.mutable_hash | |
puts RUBY_DESCRIPTION |
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
CREATE TABLE filler ( | |
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT | |
) ENGINE=Memory; | |
CREATE TABLE t_param ( | |
param INT NOT NULL PRIMARY KEY | |
) ENGINE=Memory; | |
CREATE TABLE t_source ( | |
id INT NOT NULL PRIMARY 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
package enriching_example | |
import scala.util.control.Exception.allCatch | |
case class StringWithToInt(s: String) { | |
def toIntOpt: Option[Int] = allCatch opt { s.toInt } | |
} | |
implicit def string2stringWithToInt(s: String) = StringWithToInt(s) |
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
#!/bin/bash | |
## | |
# A script to test our debian package naming policy. | |
# | |
# This script uses `dpkg --compare-versions` to test that provided | |
# sequences of package names are considered to be in ascending order | |
# by Debian's tools. | |
# | |
# Author: Marc Siegel <marc.siegel@timgroup.com> | |
# Modified: 2013-07-30 |
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
//// | |
// Output of running: | |
// $ scala -Xprint:parser -e "val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j" | |
//// | |
// | |
// Picked up _JAVA_OPTIONS: -Xss3m -XX:MaxPermSize=256M | |
// /tmp/scalacmd2064075741948415763.scala:1: error: value map is not a member | |
// of Product with Either[String,(Int, Int)] with Serializable | |
// val e: Either[String, Int] = Right(1); for {i <- e.right; j = i + 1} yield j | |
// ^ |
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.util.{Try, Success, Failure} | |
def f(s: String): Try[Int] = Try { s.toInt } | |
def g(i: Int): Try[Int] = Try { i * 2 } | |
def unit[T](v: T): Try[T] = Success(v) | |
//val v = "1" | |
val v = "bad" | |
val m = Success(v) |
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
/** | |
* ``` | |
* Does JDK8's Optional class satisfy the Monad laws? | |
* ================================================= | |
* 1. Left identity: true | |
* 2. Right identity: true | |
* 3. Associativity: true | |
* | |
* Yes, it does. | |
* ``` |
OlderNewer