Skip to content

Instantly share code, notes, and snippets.

View dohzya's full-sized avatar

Étienne Vallette d'Osia dohzya

  • EY Fabernovel
  • Paris, France
  • 17:08 (UTC +02:00)
View GitHub Profile
@dohzya
dohzya / gist:8712825
Created January 30, 2014 16:40
Better than zip
package ffutures
import scala.concurrent._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.language.postfixOps
object FFutures {
@dohzya
dohzya / gist:9345645
Last active August 29, 2015 13:56
Heterogeneous List
// No need to define an HList trait
case class #::[A, B](head: A, tail: B) {
def #::[S](e: S): S #:: A #:: B = new #::(e, this)
override def toString = s"$head #:: $tail"
}
trait HNil
case object HNil extends HNil {
def #::[S](e: S): S #:: HNil = new #::(e, HNil)
override def toString = "HNil"
}

I have this code

module M1
  module M2
    module M3
      module M4
        module M5
          def foo; end
a = 1
@dohzya
dohzya / main.js
Created May 30, 2014 09:46
Test of folding a specific just-created node
define(function (require, exports, module) {
'use strict';
var Extensions = require('ft/core/extensions').Extensions;
function updateTree(tree, fn) {
try {
tree.beginUpdates();
fn();
} finally {

Keybase proof

I hereby claim:

  • I am dohzya on github.
  • I am dohzya (https://keybase.io/dohzya) on keybase.
  • I have a public key whose fingerprint is 7BE4 EB58 913B A60A 0BDC 7DA8 189A FB68 1243 CC07

To claim this, I am signing this object:

@dohzya
dohzya / gist:cda8f97f43b2e4bff9e7
Last active August 29, 2015 14:08
Is it possible to defer a type declaration in Scala?
type Store[A, B] = (A => B) => B
def store[A, B](a: A): Store[A, B] = (x: A => B) => x(a)
// This version does not compile (returns A instead of B):
// def get[A, B](s: F[A, B]) = s(identity)
// There is a version which works, but which is kind of useless:
def get[A](s: Store[A, A]) = s(identity)
// This version does not compile (returns Int instead of Nothing)
package main
import (
"http"
"io"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.Copy(w, r.Body)
// avoid warnings about the use of Higher Kinds
import scala.language.higherKinds
// implementing Forall
trait Forall[+G[_]] { def apply[A]: G[A] }
// note: this implementation is covariant, in order to make Null works
// The Cons type, based on Forall
type Cons[+A, +B] = Forall[({ type G[C] = ((A, B) => C) => C })#G]
def cons[A, B](a: A, b: B): Cons[A, B] = new Cons[A, B] {
# You can pass any object implementing the same methods as the BasicCache
# https://github.com/prismicio/ruby-kit/blob/master/lib/prismic/cache/basic.rb
cache = Prismic::BasicCache.new
api = Prismic::api('https://lesbonneschoses.prismic.io/api', cache: cache)
# The Api will use the custom cache object
@dohzya
dohzya / gist:a6a724124a0ccb603f81
Last active August 29, 2015 14:09
Is Ruby stringly typed?

I just can't explain what I think in 140 chars, so here is a longer text.

Note that my goal is not to say “I'm right” but to be sure we understand each other. (hey, if I'm right it's good for my ego, but if I'm not it's even better for my intellect).

So please tell me if you don't agree ;-)

"hey" + 3