Skip to content

Instantly share code, notes, and snippets.

View politrons's full-sized avatar
🏠
In Home

Pablo Picouto García politrons

🏠
In Home
View GitHub Profile
@petitviolet
petitviolet / AkkaStreamPracWithActor.scala
Last active April 11, 2021 21:07
Akka-Stream with Actor using ActorPublisher and ActorSubscriber
package net.petitviolet.ex.persistence.task
import akka.NotUsed
import akka.actor._
import akka.pattern.ask
import akka.stream.actor.ActorSubscriberMessage.{ OnComplete, OnNext }
import akka.stream.actor.{ ActorPublisher, ActorSubscriber, OneByOneRequestStrategy, RequestStrategy }
import akka.stream.{ ActorMaterializer, ClosedShape }
import akka.util.Timeout
import org.reactivestreams.Publisher
@eamelink
eamelink / recursion-and-trampolines-in-scala.md
Last active April 10, 2024 15:57
Recursion and Trampolines in Scala

Recursion and Trampolines in Scala

Recursion is beautiful. As an example, let's consider this perfectly acceptable example of defining the functions even and odd in Scala, whose semantics you can guess:

def even(i: Int): Boolean = i match {
  case 0 => true
  case _ => odd(i - 1)
}

def odd(i: Int): Boolean = i match {

@Rubentxu
Rubentxu / maybe.go
Created September 24, 2015 23:34
Implementing the Maybe monad in Golang
package main
import (
"fmt"
"errors"
)
type Maybe interface {
Return(value interface{}) Maybe
Bind(func(interface{}) Maybe) Maybe
package main
import (
"fmt"
"io"
"os"
)
var path = "/Users/novalagung/Documents/temp/test.txt"
@akirillov
akirillov / FinalgeHttpClientWithRetries
Created October 7, 2014 13:06
Finagle default HttpClient configured with timeouts and retry filters
val retry = new RetryingFilter[HttpRequest, HttpResponse](
retryPolicy = RetryPolicy.tries(3),
timer = DefaultTimer.twitter
)
val timeout = new TimeoutFilter[HttpRequest, HttpResponse](
timeout = 3.seconds,
timer = DefaultTimer.twitter
)
@rajapaju
rajapaju / facebook-login.sh
Created October 12, 2011 18:00 — forked from hubgit/facebook-login.sh
Login to Facebook using cURL
#!/bin/bash
# If it redirects to http://www.facebook.com/login.php at the end, wait a few minutes and try again
EMAIL='YOUR_EMAIL' # edit this
PASS='YOUR_PASSWORD' # edit this
COOKIES='cookies.txt'
USER_AGENT='Firefox/3.5'