Skip to content

Instantly share code, notes, and snippets.

@owainlewis
owainlewis / Functors.scala
Created December 16, 2013 14:10
Functors
// covariant functor
trait Functor[F[_]] {
def fmap[A, B](f: A => B): F[A] => F[B]
}
// contravariant functor
trait Contravariant[F[_]] {
def contramap[A, B](f: B => A): F[A] => F[B]
}
@deltheil
deltheil / libcurl_dns.md
Last active March 15, 2019 00:54
libcurl options to control DNS lookup (cache, timeout, resolving time, etc). The short URL for this page is: http://git.io/libcurl-dns.

Easy handle interface

Options

Info

@ashrithr
ashrithr / kafka.md
Last active March 14, 2024 21:16
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic
@PanzerKunst
PanzerKunst / EmailMessage.scala
Last active October 1, 2016 17:01
Small modification of Raúl Raja's Scala code to sent emails
import scala.concurrent.duration.FiniteDuration
/**
* The email message sent to Actors in charge of delivering email
*
* @param subject the email subject
* @param recipient the recipient
* @param from the sender
* @param text alternative simple text
* @param html html body
@drexin
drexin / Macros.scala
Last active October 27, 2016 09:41
macros to get current file and line, inspired by ruby's __FILE__ and __LINE__
import java.io.File
import language.experimental.macros
import scala.reflect.macros.Context
object Macros {
def LINE: Int = macro lineImpl
def lineImpl(c: Context): c.Expr[Int] = {
import c.universe._
@kazuho
kazuho / gist:5027236
Last active February 20, 2016 18:47
MessagePackの文字列型追加において、Extended型を導入する提案

#MessagePackの文字列型追加において、Extended型を導入する提案

本提案は https://gist.github.com/frsyuki/5022569 https://gist.github.com/frsyuki/5022460 において提案された「バイナリ型」の構造に変更を施すものである。

##解決しようとする問題

  • MessagePackへの拡張は今後行われないとしても、独自に拡張する提案が今後頻発しそう
  • 拡張フォーマットは、既存のMessagePackに対して後方互換にならない(なりようがない)ため、相互運用性を損なう可能性が高い。これが問題

##提案する手法

@clemensg
clemensg / curl_multi_test.c
Last active June 28, 2023 06:51
libcurl multi interface example
/* curl_multi_test.c
Clemens Gruber, 2013
<clemens.gruber@pqgruber.com>
Code description:
Requests 4 Web pages via the CURL multi interface
and checks if the HTTP status code is 200.
Update: Fixed! The check for !numfds was the problem.