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
val uri = "http://www.yahoo.com" | |
val reqEntity = Array[Byte]() | |
val respEntity = for { | |
request <- Marshal(reqEntity).to[RequestEntity] | |
response <- Http().singleRequest(HttpRequest(method = HttpMethods.POST, uri = uri, entity = request)) | |
entity <- Unmarshal(response.entity).to[ByteString] | |
} yield entity | |
val payload = respEntity.andThen { |
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 chana.jpql | |
import chana.jpql.nodes._ | |
import chana.schema.SchemaBoard | |
import org.apache.avro.Schema | |
import org.apache.avro.SchemaBuilder | |
import org.apache.avro.SchemaBuilder.FieldAssembler | |
import scala.collection.immutable | |
sealed abstract class MetaNode { |
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
function entityStateNotity(id, record, fieldName, fields, print, http_get, http_post) { | |
var arr = record.get(fieldName); | |
var lastAction = arr[arr.length-1].get('action'); | |
http_post.apply('http://localhost:8080/kwafer/insert/'+id, '.entityState\n{"' + | |
lastAction.get('opKey') + '": "' + | |
lastAction.get('opValue') + '"}') | |
} |
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
val p1: Function[(Int, Int), String] = { | |
x => "OK" | |
} | |
val p2: Function[(Int, Int), String] = { | |
x => | |
x match { | |
case (a: Int, b: Int) => "OK" | |
} | |
} |
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
function calc() { | |
var llt = account.get("lastLoginTime"); | |
llt += 1; | |
account.put("lastLoginTime", llt); | |
llt = account.get("lastLoginTime"); | |
notify(llt) | |
} | |
function notify(value) { | |
print(id + ":" + value); |
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
private boolean isApplicationBroughtToBackground() { | |
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
List<RunningTaskInfo> tasks = am.getRunningTasks(1); | |
if (!tasks.isEmpty()) { | |
ComponentName topActivity = tasks.get(0).topActivity; | |
if (!topActivity.getPackageName().equals(context.getPackageName())) { | |
return true; | |
} | |
} | |
return 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
package spray.can.websocket.frame | |
import akka.util.ByteIterator | |
import akka.util.ByteString | |
import scala.annotation.tailrec | |
object FrameParser { | |
var frameSizeLimit: Long = Long.MaxValue | |
/** |
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
val observer = new Observer[OnEvent] { | |
override def onNext(value: OnEvent) { | |
case OnEvent("Hi!", args, context) => | |
if (value.packet.hasAckData) { | |
value.ack("[]") | |
} | |
value.reply("welcome", List(Msg("Greeting")).toJson.toString) | |
} | |
} |
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 System.{currentTimeMillis => now} | |
import collection.mutable.ArrayBuffer | |
import actors.Actor | |
import scala.actors.Reactor | |
/** | |
* @author <a href="mailto:[email protected]">zhongl<a> | |
*/ | |
object ActorBasedPrime extends App { |
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
scala> def p(implicit i:Int) = print(i) | |
p: (implicit i: Int)Unit | |
scala> p(i) | |
3 | |
scala> def p = print("no implicit p(i) any more") | |
p: Unit | |
scala> p | |
no implicit p(i) any more |
NewerOlder