Skip to content

Instantly share code, notes, and snippets.

View dohzya's full-sized avatar

Étienne Vallette d'Osia dohzya

  • EY Fabernovel
  • Paris, France
  • 02:22 (UTC +02:00)
View GitHub Profile
@dohzya
dohzya / MyActor.scala
Last active November 18, 2018 13:17
Sequential actor
package actors
import scala.concurrent.duration._
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import akka.actor.{ Actor, ActorRef, Props }
import akka.pattern.ask
import akka.util.Timeout
<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 / tmux-lsa.rb
Last active March 9, 2017 12:52
List tmux sessions (for every sockets)
#!/usr/bin/env ruby
sockets = %x(ps ax -o args=).lines.grep(/tmux.*-L/).map{|l| l.chomp.match(/-L +([^ ]+)/)[1] }.uniq
servers = [['default', nil]] + sockets.sort.map{|s| [s, s] }
res = []
servers.each do |srv, sock|
res << "#{srv}:"
arg = sock ? "-L #{sock}" : ""
%x(tmux #{arg} ls 2> /dev/null).each_line{|l| res << "- #{l.chomp}" }
res << ""
@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

Test de message embedded :-)

/*
SublimeLinter default settings
*/
{
/*
Sets the mode in which SublimeLinter runs:
true - Linting occurs in the background as you type (the default).
false - Linting only occurs when you initiate it.
"load-save" - Linting occurs only when a file is loaded and saved.
@dohzya
dohzya / JsResult2Try.scala
Last active December 15, 2015 13:59
Full example of implicit transformation of JsResult into Try
package foo
import scala.util._
import play.api._
import play.api.data.validation.ValidationError
import play.api.libs.json._
object Foo {
My awesome question