This file contains hidden or 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
// reducer_active_contact.js | |
export default function(state = null, action) { | |
switch (action.type) { | |
case 'CONTACT_SELECTED': | |
return action.payload | |
} | |
// i dont care about the action because it is not inside my | |
// list of actions I am interested int (case statements inside the switch) | |
return state | |
} |
This file contains hidden or 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
# code from: https://code.tutsplus.com/articles/what-is-genserver-and-why-should-you-care--cms-29143 | |
defmodule MathServer do | |
def start do | |
spawn &listen/0 | |
end | |
defp listen do | |
receive do | |
{:sqrt, caller, arg} -> send(caller, {:result, do_sqrt(arg)}) |
This file contains hidden or 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
// actions/action_select_contact.js | |
function selectContact(contact) { | |
return { | |
type: 'CONTACT_SELECTED', | |
payload: contact | |
} | |
} | |
export default selectContact; |
This file contains hidden or 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.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
import scala.concurrent.Await | |
import github4s.Github | |
import github4s.Github._ | |
import github4s.GithubResponses.GHResult | |
import github4s.jvm.Implicits._ |
This file contains hidden or 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._ | |
import scala.concurrent.Await | |
import scala.concurrent.duration._ | |
object RebelAkktorsGist extends App { | |
/**************************** | |
* Messages * | |
***************************/ |
This file contains hidden or 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
<?php | |
error_reporting(E_ALL ^ E_NOTICE); | |
abstract class Option { | |
protected $value; | |
public function __construct($value) { | |
if (isset($value)) return some($value); | |
else return none(); | |
} |
This file contains hidden or 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.util.Try | |
object FizzBuzz { | |
def main(args: Array[String]): Unit = { | |
val iterations = Try(args(0).toInt).getOrElse(0) | |
(1 to iterations).foreach {i => | |
if (i % 15 == 0) println(s"$i - FizzBuzz") | |
else if (i % 3 == 0) println(s"$i - Fizz") | |
else if (i % 5 == 0) println(s"$i - Buzz") | |
else println(s"$i") |
This file contains hidden or 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
*************************************** | |
ScaleraBlog: Scala Rx Example, 1st Post | |
*************************************** | |
a vale 1 | |
b vale 2 | |
Lo guardamos en resultado, que es reactiva de a y b: 3 | |
Cambiamos el valor de b=6 | |
Resultado ahora debería valer 7 | |
7 |
This file contains hidden or 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.language.postfixOps | |
import scala.util.{Success, Failure} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
import scala.concurrent._ | |
import scala.util.Try | |
import sys.process._ | |
import concurrent.Future | |
import concurrent.Promise |
This file contains hidden or 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.util.Random | |
object ProgressBar extends App { | |
// list of times to sleep between each step of the progess, with different probabilities | |
val timesToSleep = List(500, 500, 500, 500, 600, 600, 600, 1000, 1000, 1000, 2000, 2000, 5000) | |
print("Progress [ ]") | |
Thread.sleep(500); | |
// 11 backspaces to override " ]" |
NewerOlder