A collection of Play Framework code snippets used by PlayByExample (snippets aggregator) - inspired by 140byt.es
- Fork this gist to create a new snippet.
- Modify your gist according to Rules.
#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); |
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]]; | |
} |
/** | |
* 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. | |
*/ | |
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 }); | |
}, |
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") |
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") | |
} |
implicit val ColorWrites = Writes[java.awt.Color] { c => | |
JsString("#%02x%02x%02x" format (c.getRed, c.getGreen, c.getBlue)) | |
} |
val file = Play.getFile("example.jpg") | |
def colorsQuantization = Action { | |
Ok.stream(Enumerator.fromFile(file) &> convertColors(14)) | |
.withHeaders(CONTENT_TYPE -> "image/png") | |
} |
#!/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"; |