Skip to content

Instantly share code, notes, and snippets.

View tkrs's full-sized avatar
🤯
I may be slow to respond.

Takeru Sato tkrs

🤯
I may be slow to respond.
  • Gunma, Japan
  • 11:17 (UTC +09:00)
View GitHub Profile
@tkrs
tkrs / Main.scala
Last active May 10, 2017 04:26
Akka-Http - Outgoing request stream error
import java.nio.charset.StandardCharsets._
import akka.{Done, NotUsed}
import akka.actor.ActorSystem
import akka.http.scaladsl.Http.HostConnectionPool
import akka.http.scaladsl._
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Flow, Sink, Source}
@tkrs
tkrs / Cats0.scala
Last active May 9, 2017 07:50
Multiple way Coproduct in cats
import cats.data.Coproduct
import cats.free.{Free, Inject}
import cats.{Id, ~>}
// See [[http://underscore.io/blog/posts/2017/03/29/free-inject.html]]
sealed trait FOp[A]
object FOp {
case object One extends FOp[Int]
@tkrs
tkrs / main.rs
Created May 25, 2017 04:48
Type classes demo in Rust
trait Gettable<A> {
fn run(&self) -> A;
}
#[derive(Debug)]
struct Request {
a: String,
}
#[derive(Debug)]
@tkrs
tkrs / MonixGatherUnorderd.scala
Created June 23, 2017 04:06
Example - Monix.gatherUnorderd
package sandbox
import java.time.Instant
import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder}
import java.util.concurrent._
import cats.instances.future._
import cats.syntax.cartesian._
import monix.eval.{Callback, Task}
import monix.execution.{Ack, Cancelable, Scheduler}
@tkrs
tkrs / split.py
Last active October 18, 2018 06:48
Splits the file by the passed lines
import sys
import gzip
from itertools import islice
class FileSpliter:
def __init__(self, from_file, to_file_prefix):
self.from_file = from_file
self.to_file_prefix = to_file_prefix
@tkrs
tkrs / parser.go.y
Created February 13, 2018 05:31
goyacc tutorial
%{
package main
import (
"text/scanner"
"strconv"
"strings"
"fmt"
)
type Expression interface{}
type ParenExpr struct {
@tkrs
tkrs / ByteArrayBench.scala
Last active March 22, 2018 01:32
Array[Byte] Concatenate Benchmark
import java.nio.ByteBuffer
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
@State(Scope.Thread)
@BenchmarkMode(Array(Mode.Throughput))
@Warmup(iterations = 10, time = 1)
@Measurement(iterations = 10, time = 1)
@OutputTimeUnit(TimeUnit.SECONDS)
@tkrs
tkrs / main.rs
Last active April 24, 2018 06:43
Reconnectable Writer
use std::cell::RefCell;
use std::io;
use std::io::ErrorKind;
use std::io::Write;
use std::net::TcpStream;
use std::thread;
use std::time::Duration;
fn main() {
let mut writer = ReconnectableWriter::connect("127.0.0.1:24224".to_string())
@tkrs
tkrs / post.go
Created April 25, 2018 04:21
Print the HTTP response in Go
package main
import (
"bytes"
"compress/gzip"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
@tkrs
tkrs / json-bench-jmh-result.json
Last active May 17, 2018 04:31
JMH Result JSON format
[
{
"jmhVersion" : "1.21",
"benchmark" : "bench.Case1.decodeArgonaut",
"mode" : "thrpt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home/jre/bin/java",
"jvmArgs" : [
"-XX:+UseG1GC",