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 / tricks.less
Created October 25, 2011 18:19
Some tricky LessCss mixins
.opacity(@val) {
opacity: @val;
@filter: @val*100;
filter: ~"alpha(opacity=@{filter})";
}
@gre
gre / text2speech_playframework.scala
Created August 10, 2011 18:06
Play framework + Scala : a text to speech in 2 line of code using google translate - this is an action, put it in any controller ;)
def speech(text:String) = {
val audio = WS.url("http://translate.google.com/translate_tts?tl=en").setParameter("q", text).get()
response.contentType = audio.getContentType()
audio.getStream()
}
/*
This is a Play! framework controller's action.
Put it in any scala controller.
Don't forget to import play.libs.WS
*/
@gre
gre / pusher.scala
Created August 6, 2011 14:38
Using Pusher API with Play framework in scala for publishing events
// Implementing the publishing Pusher REST API
// @see http://pusher.com/docs/rest_api
// with Play (scala) Framework
// @see http://scala.playframework.org/
class Pusher {
val appId = Play.configuration.getProperty("pusher.appId")
val key = Play.configuration.getProperty("pusher.key")
val secret = Play.configuration.getProperty("pusher.secret")
@gre
gre / RealTime.js
Created August 1, 2011 17:39
RealTime.js - update system for building ajax stuff like autocompletes
/**
* RealTime.js : Update system
* Manage input (or textarea) smart callback on change
* @author Gaetan Renaudeau <[email protected]>, Namolovan Nicolae <[email protected]>
*/
var RealTime = function(node, o) {
var self = this;
this.input = node;
var getTime = function() {
<section id="game">
<div class="turnleft"></div>
<div class="turnright"></div>
<div class="gameStatus">
<a class="i18n-back back" href="#!/">Back</a>
<span class="timeline">
<span class="remainingSeconds"><span class="remainingSecondsTime"></span> s</span>
</span>
</div>
<div id="gameContainer">
@gre
gre / mocking.css
Created June 5, 2011 10:49
some CSS to style a <todo> element used during mocking pages.
todo {
display: inline-block;
font-style: italic;
padding: 5px 10px;
margin: 10px;
color: #666;
font-size: 0.9em;
border: 2px dashed #ccc;
background: #eee;
}
@gre
gre / Makefile
Created May 27, 2011 19:34
Web App Maker - Makefile sample (used by Same Game Gravity - Android version)
# Same Game Gravity - Android full version #
### ~ Web App Builder ~ ###
# a Makefile to compile a web project. #
# designed for web project with different devices #
# (mobile, tablet, desktop) but with common code. #
### by @greweb - http://greweb.fr/ ###
# BUILD_DIR : PATH to Web App Builder /build directory (the directory containing all build tools)
BUILD_DIR = ../build
@gre
gre / header.js
Created May 15, 2011 16:55
My blog header canvas animation
(function(){
if(!document.createElement('canvas').getContext)
return; // canvas is required.
var requestAnimFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
@gre
gre / concept.txt
Created May 2, 2011 09:48
a game score web service
- The web service provides a highscore system (keep <N> top scores, where N depending of the account plan)
- It can be easily embedded in a web page with widgets (JS). There is a clean API to send scores.
- Different ways to send scores : Usage of social network (Twitter), direct send with REST
- One account have N different scores where N depending of the account plan
- Some simple analytics
Ways to send scores :
- Connecting with social network like Twitter : exemple: "http://grenlibre.fr/same - My highscores on Same Game: easy: 12, normal: 23, hard: 45. @samegamegravity $a45c2" :
* a twitter account with an app configured - the WS will retrieve mentions
* We can easily retrieve usernames and avatars
@gre
gre / grayscale.js
Created March 25, 2011 10:37
Proof Of Concept : JS code to grayscale any web page
(function(){
var svg = document.createElement('div'), body = document.getElementsByTagName('body')[0];
if(/(msie) ([\w.]+)/.exec(navigator.userAgent)) {
body.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)';
return;
}
svg.innerHTML = '<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events"><clipPath id="c1" clipPathUnits="objectBoundingBox"><rect x="0" y="0" rx="0.05" ry="0.05" width="1" height="1"/></clipPath><filter id="desaturate"><feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0"/></filter></svg>';
body.appendChild(svg);
body.style.filter = 'url(#desaturate)';
}())