Skip to content

Instantly share code, notes, and snippets.

View dohzya's full-sized avatar

Étienne Vallette d'Osia dohzya

  • EY Fabernovel
  • Paris, France
  • 21:23 (UTC +01:00)
View GitHub Profile
<html>
<head>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/codemirror.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.35.0/theme/material.css">
<style>
body {
background: #EFEFEF;
}
.display {
border: 1px solid #AAA;
#!/bin/bash
debug="${DEBUG:-false}"
if [[ "$1" == "-d" ]]; then debug="true"; fi
timeout="${TIMEOUT:-300}" # 5 minutes
sleep_time="${SLEEP:-1}" # 1 second
check_docker_running() {
docker system info >/dev/null 2>&1
@dohzya
dohzya / sort-json.rb
Last active December 5, 2016 08:52
Sort JSON content (for easy comparison)
#!/usr/bin/env ruby
require 'json'
def sort_json(json)
case json
when Hash; Hash[json.map { |k, v| [k, sort_json(v)] }.sort_by { |k| k }]
when Array; json.map { |v| sort_json(v) }.sort_by{ |v| v.to_json }
else json
end
#!/bin/bash
first_url="$1"
dir="$2"
if [[ -z "$first_url" || -z "$dir" ]]; then
echo "usage: $0 <request url> <output directory>" >&2
exit 1
fi
@dohzya
dohzya / nosubs.rb
Last active August 29, 2015 14:13
Push without submodules
#!/usr/bin/env ruby
$dry_run = ENV['NOSUB_DRYRUN'] && %w(1 t true y yes).include?(ENV['NOSUB_DRYRUN'].downcase)
$debug = ENV['NOSUB_DEBUG'] && %w(1 t true y yes).include?(ENV['NOSUB_DEBUG'].downcase)
def usage
puts <<-USAGE
usage: $0 [-n] [-d] <remote> <ref>"
-d | --debug : Show performed operations
-n | --dry-run : Don't actually perform the operations
// B must be defined when calling foo
def foo[A, B](a: A) = (f: A => B) => f(a)
// Do not do “val foo3 = foo(3)”: the type of B will be Nothing
val foo3 = foo[Int, Int](3)
foo3 { x => x * 2 }
// impossible to do something like “foo3 { x => s"(%x)" }”
// defining Forall
trait Forall[F[_]] { def apply[A]: F[A] }
@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

# 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
// 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] {
package main
import (
"http"
"io"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
io.Copy(w, r.Body)