Skip to content

Instantly share code, notes, and snippets.

View zarinfam's full-sized avatar

Saeed Zarinfam zarinfam

View GitHub Profile
@zarinfam
zarinfam / gist.java
Last active October 1, 2019 11:51
Created with Copy to Gist
interface LogReaderStreamer extends LogReader, LogStreamer {
}
@zarinfam
zarinfam / gist.java
Last active October 1, 2019 11:50
Created with Copy to Gist
interface LogReader {
List<String> read();
}
interface LogStreamer {
void stream(String message);
}
@zarinfam
zarinfam / gist.scala
Created August 19, 2019 12:38
Created with Copy to Gist
echoConcat[Id]("Hello", "World!")
@zarinfam
zarinfam / gist.scala
Created August 19, 2019 12:36
Created with Copy to Gist
echoConcat("Hello": Id[String], "World!": Id[String])
@zarinfam
zarinfam / gist.scala
Created August 16, 2019 07:59
Created with Copy to Gist
trait Monad[F[_]] {
def pure[A](value: A): F[A]
def flatMap[A, B](value: F[A])(func: A => F[B]): F[B]
}
@zarinfam
zarinfam / gist.scala
Created August 2, 2019 13:52
Created with Copy to Gist
type Id[A] = A
@zarinfam
zarinfam / gist.scala
Created August 2, 2019 13:37
Created with Copy to Gist
def echoConcat[F[_]: Monad](s1: F[String], s2: F[String]): F[String] = for {
x <- s1
y <- s2
} yield s"echo $x $y"
echoConcat(Option("Hello"), Option("World!"))
@zarinfam
zarinfam / gist.java
Created July 29, 2019 10:19
Created with Copy to Gist
public synchronized void printText(String text) throws PrintingException {
final PrintTask printTask = new PrintTask();
PrintingListener printingListener = new PrintingListener() {
@Override
public void onSuccess(SuccessResult successResult) {
printTask.setResult(PrintTask.RESULT_SUCCESS);
}
@Override
@zarinfam
zarinfam / gist.java
Created July 29, 2019 10:03
Created with Copy to Gist
public synchronized void printText(String text) throws PrintingException {
final CompletableFuture<SuccessResult> result = new CompletableFuture();
PrintingListener printingListener = new PrintingListener() {
@Override
public void onSuccess(SuccessResult successResult) {
result.complete(successResult);
}
@Override
@zarinfam
zarinfam / gist.java
Created July 29, 2019 08:43
Created with Copy to Gist
public class PrintTask {
public static final String RESULT_SUCCESS = "SUCCESS_PRINT";
public static final String RESULT_FAILURE = "FAILURE_PRINT";
public static final String RESULT_TIMEOUT = "TIMEOUT_PRINT";
public static final String RESULT_NOTHING = "NOTHING_RESULT";
private String result = RESULT_NOTHING;
public void getResult() throws PrintingException {