Skip to content

Instantly share code, notes, and snippets.

@leodagdag
leodagdag / .bashrc
Created February 13, 2018 09:19
bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[1;35m\]\u@\h\[\033[00m\] (\D{%F %T}):\[\033[1;34m\] \w$(__git_ps1 "\[\033[1;32m\] (%s)")\[\033[0;37m\] > '
export ANSIBLE_NOCOWS=1
@leodagdag
leodagdag / .gitconfig
Last active February 13, 2018 09:18
git lola
[alias]
lola = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all
@leodagdag
leodagdag / gist:5718003
Last active December 18, 2015 03:28
test nodejs - mongodb
var MongoClient = require('mongodb').MongoClient;
// Some docs for insertion
var docs = [{
type: 'switch',
duration:0
},{
type: 'switch',
duration:0
},{
object Main {
def writeFile(fileName: String) {
val letter = new FileWriter(s"${System.getenv("USERPROFILE")}/${fileName}.txt")
try {
Stream.continually(readLine()).takeWhile(_ != ".").map(_ + "\n").foreach(letter.write)
} finally {
letter.close()
}
}
@leodagdag
leodagdag / gist:4016317
Created November 5, 2012 09:31
very simple HTTP server with Nodejs
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs');
var mimeTypes = {
"html": "text/html",
"jpeg": "image/jpeg",
"jpg": "image/jpeg",
"png": "image/png",
"js": "text/javascript",
@leodagdag
leodagdag / gist:3207759
Created July 30, 2012 15:22
playframework stage starts with windows
@echo off
if "%OS%" == "Windows_NT" (
set "DIRNAME=%~dp0%"
) else (
set DIRNAME=.\
)
java -cp "%DIRNAME%\lib\*" %* play.core.server.NettyServer
@leodagdag
leodagdag / gist:3183045
Created July 26, 2012 16:22
linux init script for playframework 2
#!/bin/sh
### BEGIN INIT INFO
# Provides: playframework
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop playframework
### END INIT INFO
#
@leodagdag
leodagdag / gist:2276707
Created April 1, 2012 16:15
Scala example : Parse String
val suffix: Map[Symbol,Map[Symbol,Tuple2[String,String]]] =
"""
en=y:year,years|M:month,months|d:day,days|h:hour,hours|m:minute,minutes|s:seconde,secondes
fr=y:année,années|M:mois,mois|d:jour,jours|h:heure,heures|m:minute,minutes|s:seconde,secondes
""".split('\n').map(_.trim).filter(_.size > 0).map(_.split('=')).map {
line: Array[String] => // ["en","y:year,years|M:month,months|d:day,days|h:hour,hours|m:minute,minutes|s:seconde,secondes"]
Symbol(line(0)) -> line(1).split('|').map {
period: String => // "y:year,years"
Symbol(period(0).toString) -> period.drop(2).mkString
}.toMap.map {