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 urllib | |
import urllib2 | |
import contextlib | |
import json | |
import time | |
# Get an opener | |
opener = urllib2.build_opener() | |
# Base URL with params for requesting a formtoken via a call to auth1 (GET) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct Nodee { | |
void* value; | |
struct Nodee* prev; | |
struct Nodee* next; | |
} Node; | |
typedef struct Listt { |
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 Op[A] | |
case class EachOp[A]() extends Op[A] | |
case class CollectOp[A]() extends Op[A] | |
case class RubyIterator[B, A](iter: Iterator[A], op: Op[B]) { | |
def `do`(f: A => B): List[B] = { | |
op match { | |
case EachOp() => | |
iter.foreach(f) | |
List.empty[B] |
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
trait PlaceholderExample { | |
def process[A](f: A => Unit) | |
val set: Set[_ => Unit] | |
set.foreach(process(_)) // No Error | |
set.foreach(x => process(x)) // No Error | |
val process1 = process _ | |
set.foreach(process1) // No Error | |
set.foreach(process _) // Error |
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
trait ListContainer[A <: ListContainer[A]] { | |
this: List[A] => | |
def takeOne = take(1) | |
} | |
class MyContainer extends ListContainer[MyContainer] { | |
this: List[MyContainer] => | |
def takeTwo = takeOne :: takeOne :: Nil |
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.collection.immutable.IntMap | |
import scala.language.higherKinds | |
object main { | |
def main(args: Array[String]): Unit = { | |
trait Container[M[_]] { def put[A](x: A): M[A]; def get[A](m: M[A]): A } | |
implicit val listContainer = new Container[List] { def put[A](x: A) = List(x); def get[A](m: List[A]) = m.head } | |
implicit val optionContainer = new Container[Some] { def put[A](x: A) = Some(x); def get[A](m: Some[A]) = m.get } | |
// Can't parametrize on general maps, since Container expects a parametrized type with 1 type parameter, maps generally take 2 |
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
// Dies with: | |
// | |
// Error:(151, 98) missing parameter type for expanded function | |
// The argument types of an anonymous function must be fully known. (SLS 8.5) | |
// Expected type was: scala.util.Try[?] => ? | |
// coffees.length.result.flatMap(_ => DBIO.failed(new Exception())).transactionally.asTry.map { | |
// ^ | |
coffees.length.result.flatMap(_ => DBIO.failed(new Exception())).transactionally.asTry.map { | |
case Failure(e: Throwable) => "failed" | |
case Success(_) => "succeeded" |
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
19 ooooxooooooxooo.v.ooooooxooooxoooo (82.133.91.37) 271.062 ms 262.427 ms 287.285 ms | |
20 ooxoooooxooooo.mmm.ooooooooxxoooxo (82.133.91.18) 262.883 ms 272.324 ms 277.339 ms | |
21 oooxoooooxooo.eeeee.oooxoooooxoooo (82.133.91.63) 289.099 ms 273.337 ms 288.960 ms | |
22 ooooxooxooox.rrrrrrr.ooooooxooooox (82.133.91.56) 261.431 ms 278.393 ms 254.542 ms | |
23 oxooooooxoo.rrrrrrrrr.oooxooooooxo (82.133.91.55) 287.949 ms 283.869 ms 281.962 ms | |
24 xoooxooooo.yyyyyyyyyyy.oooxooooxoo (82.133.91.58) 250.730 ms 265.093 ms 269.916 ms | |
25 ooxoooooxooooo.ccc.ooooooooxoooxoo (82.133.91.96) 273.542 ms 270.435 ms 272.161 ms | |
26 oooooxooo.hhhhhhhhhhhhh.oxoooxoooo (82.133.91.23) 273.479 ms 294.211 ms 297.685 ms | |
27 ooxooxoo.rrrrrrrrrrrrrrr.ooxoooxoo (82.133.91.49) 275.232 ms 287.565 ms 271.983 ms | |
28 oxoooxo.iiiiiiiiiiiiiiiii.oooxooxo (82.133.91.60) 270.243 ms 272.478 ms 271.520 ms |
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
// From Shapeless `coproduct.scala` | |
sealed trait Animal | |
case class Cat(name: String, livesLeft: Int) extends Animal | |
case class Dog(name: String, bonesBuried: Int) extends Animal | |
case class Koala(name: String, leavesEaten: Int) extends Animal |
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 shapeless.syntax.std.tuple._ | |
import shapeless._, syntax.singleton._ | |
object ShapelessMain { | |
def main(args: Array[String]): Unit = { | |
val l = 23 :: "foo" :: true :: HNil | |
l(1) | |
val t = (23, "foo", true) | |
t(1) |
OlderNewer