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
// Playground - noun: a place where people can play | |
func fizzBuzz1(i: Int) -> String { | |
switch (i % 5, i % 3) { | |
case (0, 0): | |
return "FuzzBuzz" | |
case (0, _): | |
return "Buzz" | |
case (_, 0): | |
return "Fizz" |
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 ArrayOps[A](val self: Array[A]) extends AnyVal { | |
def apply[I: ArrayIdx](i: I) = self(i.idx) | |
} | |
trait ToArrayOps { | |
implicit def ToArrayOps[A](array: Array[A]) = new ArrayOps[A](array) | |
} |
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
// Playground - noun: a place where people can play | |
import Cocoa | |
let a = [1, 2, 3] | |
var b = a | |
a === b // false |
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
SSLSocketFactory sslsf = new SSLSocketFactory(new TrustStrategy() { | |
@Override | |
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |
return true; | |
} | |
}, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); | |
HttpClient cli = new DefaultHttpClient(); | |
cli.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, sslsf)); |
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 akka.actor._ | |
class VarCounter extends Actor { | |
private[this] var count: Int = 0 | |
override def receive = { | |
case _: String => count = count + 1 | |
} | |
} |
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 akka.actor._ | |
trait AbstractActor[MesType] extends Actor { | |
override def receive = ... | |
} | |
case class MyMessage(mes: String) | |
class MyActor extends AbstractActor[MyMessage] |
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
def apply[S, A](f: (S) ⇒ (S, A)): State[S, A] |
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 org.nisshiee.vendingmachine | |
case class Juice(name: String, price: Int) | |
object Juice { | |
val coke = Juice("コーラ", 120) | |
val redbull = Juice("Red Bull", 200) | |
} |
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 dispatch._ | |
import com.ning.http.client.filter.{ ResponseFilter, FilterContext } | |
import scala.collection.JavaConverters._ | |
val MyHttp = Http.configure { builder => | |
builder.addResponseFilter(new ResponseFilter { | |
override def filter(ctx: FilterContext[_]) = { | |
ctx.getResponseHeaders.getHeaders.get("Content-Type").asScala.toList match { | |
case "text/html" :: Nil => | |
ctx.getResponseHeaders.getHeaders.put("Content-Type", List("text/html; charset=utf-8").asJava) |
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 | |
STATUS=`screen -ls` | |
new_session() { | |
exec screen | |
} | |
detach_and_reattach() { | |
exec screen -d -r |