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 / TEMPLATE.glsl
Last active January 4, 2016 07:19
GLSL Transitions Editor template - GPL 3 license
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
gl_FragColor = mix(texture2D(from, p), texture2D(to, p), progress);
@gre
gre / random2elements.js
Created December 31, 2013 19:14
Returns 2 random different elements from an Array
function random2elements (array) {
var i = Math.floor(array.length*Math.random());
var j = Math.floor((array.length-1)*Math.random());
if (j >= i) j++;
return [array[i], array[j]];
}
@gre
gre / audioContextMicroLibraries.js
Last active December 25, 2015 12:19
thoughts on Javascript browserify and implicit audio context
/**
* I'm trying to define a lot of Audio Micro Libs with Browserify (NPM style) and the require() mecanism
*
* Our Audio Micro Libs will require an audio context to work
* (e.g. we will need to access the sampleRate field or use some createNode methods of the web audio context)
*
* + Eventually we can use different audio context: the "main" one and/or an OfflineAudioContext
* which will be used to fastly compute some audio and returns audio buffer.
*/
@gre
gre / extract.js
Last active December 20, 2015 09:19
Extract of ZOUND live main.js code
network.on({
"user-track-take": function (data, user) {
pattern.tracks.at(data.track).set("offmode", user, { network: true });
},
"user-track-release": function (data, user) {
pattern.tracks.at(data.track).set("offmode", null, { network: true });
},
"user-connect": function (data) {
users.add(new zound.models.User({ id: data.user }), { network: true });
},
@gre
gre / CODE.scala
Last active December 20, 2015 01:59 — forked from playxamplez-admin/CODE
retrieve, process and re-encode a video with #PlayCLI and #Iteratees
val videoStream: Enumerator[Array[Byte]]
val scaleVideoHalf = CLI.pipe("ffmpeg -i pipe:0 -vf scale=iw/2:-1 -f avi pipe:1")
Ok.stream(videoStream &> scaleVideoHalf).withHeaders(CONTENT_TYPE -> "video/avi")
@gre
gre / CODE.scala
Last active December 20, 2015 01:59 — forked from playxamplez-admin/CODE
Download an #OGG stream, add an echo effect, stream it again with #PlayCLI and #Iteratees
val audioStream: Enumerator[Array[Byte]] = getStream("http://radio.hbr1.com:19800/ambient.ogg")
val addEchoToOgg =CLI.pipe("sox -t ogg - -t ogg - echo 0.5 0.7 60 1")
def webRadioWithEcho = Action {
Ok.stream(audioStream &> addEchoToOgg)
.withHeaders(CONTENT_TYPE -> "audio/ogg")
}
@gre
gre / CODE.scala
Last active December 20, 2015 01:59 — forked from playxamplez-admin/CODE
Provides a #JSON implicit converter for java.awt.Color with #playJson.
implicit val ColorWrites = Writes[java.awt.Color] { c =>
JsString("#%02x%02x%02x" format (c.getRed, c.getGreen, c.getBlue))
}
@gre
gre / CODE.scala
Last active December 20, 2015 01:59 — forked from playxamplez-admin/CODE
Convert JPG to PNG with indexed colors (color quantization) using #PlayCLI and #imagemagick
val file = Play.getFile("example.jpg")
def colorsQuantization = Action {
Ok.stream(Enumerator.fromFile(file) &> convertColors(14))
.withHeaders(CONTENT_TYPE -> "image/png")
}
@gre
gre / README.md
Last active December 19, 2015 10:49 — forked from zxamplez/CODE
#test gist multi-files

Play By Example

A collection of Play Framework code snippets used by PlayByExample (snippets aggregator) - inspired by 140byt.es

How to use

  1. Fork this gist to create a new snippet.
  2. Modify your gist according to Rules.
@gre
gre / deploy.sh
Last active October 8, 2021 00:33
Super-small scripts for easy PlayFramework deployment
#!/bin/bash
REMOTE=play@SERVER_IP
REMOTE_APP=/home/play/PROJECT_NAME/
sbt stage || exit 1;
rsync -va target/ $REMOTE:$REMOTE_APP/target;
ssh $REMOTE "cd $REMOTE_APP; ./stop.sh";
ssh $REMOTE "cd $REMOTE_APP; ./start.sh";