Skip to content

Instantly share code, notes, and snippets.

View ktoso's full-sized avatar
🗻
Life is Study!

Konrad `ktoso` Malawski ktoso

🗻
Life is Study!
View GitHub Profile
scala> :javap MongoDB
public class MongoDB$ extends java.lang.Object {
public static final MongoDB$ MODULE$; // actual instance of our `object`
public static {};
public MongoDB$();
// ...
}
import pl.project13.hadoop.scalding.NoJarTool
import com.twitter.scalding
import org.apache.hadoop.util.ToolRunner
import org.apache.hadoop.conf.Configuration
val conf = new Configuration
val masterIp = "10.0.0.1"
def writeAsync(persistentBatch: immutable.Seq[PersistentRepr]): Future[Unit]
def deleteAsync(processorId: String, fromSequenceNr: Long, toSequenceNr: Long, permanent: Boolean): Future[Unit]
def confirmAsync(processorId: String, sequenceNr: Long, channelId: String): Future[Unit]
// and "replay":
def replayAsync(processorId: String, fromSequenceNr: Long, toSequenceNr: Long)
(replayCallback: (PersistentRepr) => Unit): Future[Long]
@ktoso
ktoso / 0_reuse_code.js
Created January 12, 2014 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ktoso
ktoso / EventStreamAllMessages.scala
Last active January 3, 2016 20:29
raft testing with akka
/**
* Use for testing.
*
* Forwards all messages received to the system's EventStream.
* Use this to deterministically `awaitForLeaderElection` etc.
*/
trait EventStreamAllMessages {
this: Actor =>
override def aroundReceive(receive: Actor.Receive, msg: Any) = {
for {
item <- items
transformed = transform(item)
} yield transformed
// let's say you need a println
def print(a: Any) = { println(a); a }
for {
item <- items
@ktoso
ktoso / eventsourced-example.scala
Created March 31, 2014 22:34
eventsourced processor example
case class ManyCommand(nums: List[Int])
case class State(count: Int) {
def updated(more: Int) = State(count + more)
}
sealed trait Event
case class AddOneEvent(num: Int) extends Event
class MultiCounter extends EventsourcedProcessor {

Monday June 16th

Scala: The Simple Parts

Tuesday June 17th

@ktoso
ktoso / jstack
Last active August 29, 2015 14:02
sbt publishing, stuck
2014-06-22 12:45:37
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode):
"Attach Listener" #87 daemon prio=9 os_prio=31 tid=0x00007fe6bc084000 nid=0x651f waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"pool-9-thread-7" #86 prio=5 os_prio=31 tid=0x00007fe6bf504800 nid=0x9d03 waiting on condition [0x0000000126b70000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x0000000780f9f760> (a java.util.concurrent.SynchronousQueue$TransferStack)