Skip to content

Instantly share code, notes, and snippets.

@avramirez
avramirez / [iOS] Parse.com SDK Snippets
Last active December 28, 2015 20:39
Snippets for Parse.com iOS SDK
//Recursion
// Use for synchronizing a background thread.
-(void)init{
recursionSample(0);
}
-(void)recursionSample:(int)counter{
int limit = 10;
if(counter < limit){
@avramirez
avramirez / ActorSelection_Path_Test.scala
Created January 21, 2015 07:48
[Test] Scala actor path. Restarting / Creating a new actor with same path. Will it still work using the old path?
import akka.actor._
implicit val system = ActorSystem("smdp")
case class TestMessage(msg:String)
class Dependency1 extends Actor{
def receive ={
case msg:TestMessage => println("MessageReceived")
}
@avramirez
avramirez / ScheduleAndKillScheduleHolder.scala
Last active August 29, 2015 14:14
Akka.Scheduler Tests
import akka.actor._
import scala.concurrent.duration._
implicit val system = ActorSystem("test")
case class TestMessage(msg:String)
class SchedulerController(receiveMessage:ActorRef) extends Actor{
import context.dispatcher
@avramirez
avramirez / FilterFunction.scala
Created February 4, 2015 03:11
Scala Collections Sandbox
/*
--------------------------------------
BASIC SHIT Test if fuction will work as filter
--------------------------------------
*/
val a = Seq("a","b","c")
val b = a.filter(letter => {
val localLetter = letter
letter == "a" || letter == "b"
import akka.actor._
import akka.routing._
implicit val system = ActorSystem("smdp")
case class TestMessage(msg:String)
class Dependency1 extends Actor{
def receive ={
case msg:TestMessage =>
@avramirez
avramirez / SupervisorStrategyTest.scala
Last active August 29, 2015 14:18
[Test] Supervisor Strategy test and supervisor - children hierarchy test
/*
* What I'm trying to do here is to check if
* actorA { val test = context.ActorSelection("/user/Test") }
* will test be a part of ActorA children and will it be part of the supervisor strategy of ActorA?
*/
import akka.actor._
import akka.routing._
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
@avramirez
avramirez / ActorSelectionSystemAndContext.scala
Created April 6, 2015 07:14
[Test] Absolute vs Relative path , context.actorSelection system.actorSelection
/*
* If you use context.ActorSelection a relative path is valid as long as that actor/path is
* really a child of the actor.
*/
import akka.actor._
import akka.routing._
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import scala.concurrent.duration._
@avramirez
avramirez / ActorLifeCycleChildParent.scala
Created June 1, 2015 04:39
[Test] ActorLifeCycle and Child-Parent relation / Supervisor
import akka.actor._
import akka.event.LoggingReceive
import akka.routing._
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy._
import scala.concurrent.duration._
implicit val system = ActorSystem("testSytem")
object ViewChildren
@avramirez
avramirez / XPathQueryInScalaUsingJavax.scala
Last active August 29, 2015 14:26
How to do a XPath qeury in scala. Using the native javax.xml library
import javax.xml.xpath._
import org.xml.sax.InputSource
import java.io.StringReader
import javax.xml.parsers._
import javax.xml.transform.dom.DOMSource
import java.io.StringWriter
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.TransformerFactory
import javax.xml.namespace.NamespaceContext
import java.io.ByteArrayInputStream
@avramirez
avramirez / FutureTestException.scala
Last active September 28, 2017 11:32
Testing Scala Future with For comprehension
import scala.util.{ Failure, Success }
import scala.language.implicitConversions
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
val a = Future{println("a"); "a"}
val b = Future{println("b"); "b"}
val c = Future{throw new Exception("Test")}
val d = Future{
Thread.sleep(3000)