Skip to content

Instantly share code, notes, and snippets.

View gre's full-sized avatar
3 cups required

@greweb gre

3 cups required
View GitHub Profile
@gre
gre / decodeBase64.scala
Created November 15, 2012 13:43
Easy way to decode a base64 in Scala
import org.apache.commons.codec.binary.Base64
val base64 = "data:([a-z]+);base64,(.*)".r
def decodeBase64 (src: String): Option[(String, Array[Byte])] = {
src match {
case base64(mimetype, data) => Some( (mimetype, Base64.decodeBase64(data.getBytes("utf-8"))) )
case _ => None
}
}
@gre
gre / poc.scala
Last active December 9, 2015 20:58 — forked from anonymous/poc.scala
[Feature Request] Play Framework Iteratees + UNIX Pipe
// https://github.com/gre/playCLI
var n = 10000000000000000;
for (var i = n; i < n+9; i++) { console.log(i) }
var n = 1000;
var from = 10000000000000000;
var to = from + n;
var i = from;
var missing = [];
while (i < to) {
var incr = 1;
while (i === i+incr) {
missing.push(i+" + "+incr);
incr ++;
/**
* Imagine a web server storing tweet_id reference as Long.
* For instance, 289455363407884288L
* Now, let's say I send it to javascript as JS number:
*/
var myWebserviceResponse = { tweetId: 289455363407884288 /*, ...*/ };
doSomethingWith(myWebserviceResponse.tweetId);
// ...
console.log("https://twitter.com/greweb/status/"+289455363407884288)
// <- You have just missed my tweet!
@gre
gre / Makefile
Created February 4, 2013 20:06
Tiny Makefile to build your Javascript libraries with Closure Compiler minification via Cloud. ( see also http://blog.greweb.fr/?p=1713 )
LIB=myLib.min.js
all: $(LIB)
%.min.js: %.js
@curl -d compilation_level=SIMPLE_OPTIMIZATIONS -d output_format=text -d output_info=compiled_code --data-urlencode "js_code@$<" http://closure-compiler.appspot.com/compile > $@
clean:
@rm $(LIB)
@gre
gre / gist:4744775
Created February 9, 2013 10:19
Convert all *.wav in .mp3 and .ogg (useful for HTML5 audio support on all browsers...)
for f in *.wav; do sox $f ${f%%.wav}.mp3; sox $f ${f%%.wav}.ogg; done
@gre
gre / balls.html
Created February 18, 2013 10:03
Made for a tutorial video: http://blog.greweb.fr/?p=2163
<!DOCTYPE html>
<canvas id="game" width="600" height="400"></canvas>
<script id="fragment" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 resolution;
uniform float time;
struct Ball {
@gre
gre / code
Created March 1, 2013 09:58
toto
test
@gre
gre / LICENSE.txt
Last active December 14, 2015 09:19 — forked from zxamplez/CODE
retrieve, process and re-encode a video with #PlayCLI and #Iteratees .
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2013 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE