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
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 ++;
var n = 10000000000000000;
for (var i = n; i < n+9; i++) { console.log(i) }
@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
@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 / Application.scala
Created November 12, 2012 11:10
Generate Zip on-the-fly with Play!> Framework (2.1+)
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller {
def zip = Action {
import play.api.libs.iteratee._
import java.util.zip._
@gre
gre / sine.scala
Created August 2, 2012 16:01
Pure Enumeratee-based sound generation POC for Zound PlayFramework experiment
object Application extends Controller {
val buffSize = 10000
var f = 200.
val rawStream = {
var i = 0;
val ticker = Enumerator.generateM[Int]({
i += 1;
Promise.timeout(Some(i), (1000.*buffSize.toDouble/44100.).toInt)
@gre
gre / MonoWaveEncoder.scala
Created July 28, 2012 09:45
Mono Wave Encoder
package encoders;
// Implementing the WAV format here!
case class MonoWaveEncoder (
frameRate: Int = 44100,
samplesPerFrame: Int = 1,
bitsPerSample: Int = 16 // not supported yet (need to adapt the encodeData function)
) {
val bytesPerSamples = ((bitsPerSample+7)/8).toInt
@gre
gre / perturbation.frag
Created June 18, 2012 20:19
GLSL Effects used by Drone Tank Arena ( http://dta.greweb.fr/ )
uniform float p;
uniform float amount;
uniform float seed;
uniform float lines;
uniform sampler2D tDiffuse;
varying vec2 vUv;
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@gre
gre / main.js
Created March 22, 2012 20:11
blog.greweb.fr canvas header
jQuery(function($){
if(!document.createElement('canvas').getContext) return; // canvas is required.
var requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
@gre
gre / GridUtils.js
Created March 6, 2012 16:33
Algorithm to find the best grid step for chart rendering
var GridUtils = function() {
var log10 = Math.log(10.)
function powOf10 (n) {
return Math.floor(Math.log(n)/log10)
}
return {
findNiceRoundStep: function (delta, preferedStep) {
var n = delta / preferedStep;