Skip to content

Instantly share code, notes, and snippets.

View ggendre's full-sized avatar

Guillaume Gendre ggendre

View GitHub Profile
@ggendre
ggendre / gist:1497632
Created December 19, 2011 15:18
python get timestamp
import time
time.time()
#-> 1324305354.0857329
@ggendre
ggendre / gist:1476027
Created December 14, 2011 10:21
css animating popup apparition with css3
.popup{
transition-property: top;
transition-duration:2s;
top:-1000px
}
.popup.showing{
top:50px;
}
@ggendre
ggendre / gist:1476024
Created December 14, 2011 10:20
javascript typical canvas loop with jquery
//25 frames per sec
var framerate=1000 / 25;
function move(){
$.each(myObjects, function(index, obj) {
//do stufs with obj
});
redraw();
setTimeout(move,framerate);
}
@ggendre
ggendre / gist:1476017
Created December 14, 2011 10:19
CSS & Canvas, how to share the same coords context
<style type="text/css">
#dessin{ width: 960px; height:785px; position:relative; }
#dessin #canvasContainer{ width: 100%; height:100%; position:absolute; z-index:2; }
#dessin #htmlDrawContainer{ width: 100%; height:100%; position:absolute; z-index:2; }
#dessin #htmlDrawContainer a{ position:absolute; display:block; }
</style>
<div id="dessin">
<div id="canvasContainer"><!--canvas will be here--></div>
<div id="htmlDrawContainer"></div>
</div>
@ggendre
ggendre / gist:1476012
Created December 14, 2011 10:17
javascript canvas initialisation with excanvas.js.
var canvasContainer = document.getElementById("canvasContainer");
var canvas = document.createElement('canvas');
canvas.setAttribute("id", "canvas");
canvas.setAttribute("width", 960);
canvas.setAttribute("height", 785);
canvasContainer.appendChild(canvas);
if (typeof(G_vmlCanvasManager) != 'undefined')
canvas = G_vmlCanvasManager.initElement(canvas);
ctx=canvas.getContext("2d");
@ggendre
ggendre / gist:1258774
Created October 3, 2011 09:28
django & dotcloud wsgi file
import os
import sys
appName="myApp" #change this with your application name
#this way, you can use "import myfile" instead of "import myproject.myapp.myfile" everywhere in your app.
sys.path.append(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), appName)))
os.environ['DJANGO_SETTINGS_MODULE'] = appName+'.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
@ggendre
ggendre / gist:1180593
Created August 30, 2011 10:11
django mini internationalized DB values.
#
# see http://ggendre.posterous.com/django-mini-localized-db-values for details
#
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import gettext as _
import settings
import utils
from django.utils import translation
@ggendre
ggendre / gist:1053969
Created June 29, 2011 14:42
SQL find duplicates 2/2
SELECT user.*
FROM user, (SELECT * FROM user) AS doublons
WHERE user.nom = doublons.nom
AND user.prenom = doublons.prenom
AND user.id!=doublons.id
@ggendre
ggendre / gist:1053964
Created June 29, 2011 14:40
SQL find duplicates 1/2
SELECT user.*
FROM user,
(SELECT id_user
FROM user
GROUP BY id_user
HAVING count( * ) >1
) doublons
WHERE user.id_user = doublons.id_user;
<noscript>
<link rel="stylesheet" type="text/css" href="css/noscript.css" />
</noscript>