Skip to content

Instantly share code, notes, and snippets.

@Fabax
Fabax / centerAbsolute.css
Created November 20, 2014 10:58
center absolute div
#center{
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
@Fabax
Fabax / mask1.pde
Created October 19, 2014 13:47
Processing : mask pgraphic
PGraphics s, m;
void setup(){
size(220,220);
// Create a cookie cutter.
// White areas are kept. Black areas are not.
m = createGraphics( width, height, P2D );
m.beginDraw();
m.background(0);
m.fill(255);
@Fabax
Fabax / back up android
Created October 28, 2013 17:18
back up android file data
adb backup -f ~/data.ab -noapk app.name
dd if=data.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf -
void setup() {
size(500, 500);
noFill();
strokeWeight(3);
strokeJoin(BEVEL);
}
float th1, th2, r, x, y, t;
int N = 16;
@Fabax
Fabax / get midnight
Created August 30, 2013 06:57
return today's midnight timestamp
function getMidnight(){
$date = new DateTime();
$hours = $date->format('H');
$minutes = $date->format('i');
$seconds = $date->format('s');
$hours = ($hours*60)*60;
$minutes = $minutes*60;
$midnight = time()-($hours+$minutes+$seconds);
$midnight = $date = date('Y-m-d H-i-s', $midnight);
@Fabax
Fabax / echo Json
Created August 30, 2013 06:55
turn string into json p
function echoJSON($data) {
$json = json_encode($data);
echo isset($_GET['callback'])
? "{$_GET['callback']}($json)"
: $json;
}
<?php
$req = $bdd->prepare('INSERT INTO jeux_video(nom, possesseur, console, prix, nbre_joueurs_max, commentaires)
VALUES(:nom, :possesseur, :console, :prix, :nbre_joueurs_max, :commentaires)');
$req->execute(array(     'nom' => $nom,     'possesseur' => $possesseur,     'console' => $console,     'prix' => $prix,     'nbre_joueurs_max' => $nbre_joueurs_max,     'commentaires' => $commentaires     ));   echo 'Le jeu a bien été ajouté !'; ?>
@Fabax
Fabax / requete sql 1
Created August 21, 2013 16:15
Exemple de requete sql
try {
$sqlResquest = 'SELECT u1.user_id as user_id1,
u1.user_fname as user_fname1,
u1.user_lname as user_lname1,
u1.user_email as user_email1,
u1.user_duos as user_duos1,
u1.user_answers as user_answers1,
u1.user_img as user_img1,
d.duo_status as duo_status,
d.duo_id as duo_id,
float rot = 0;
void setup() {
size(400, 400);
background(100, 200, 50);
smooth();
noStroke();
}
void draw_rotating_rectangle(float x, float y, float rect_size, float r) {
translate(x, y);
size(400, 400);
noStroke();
background(23, 100, 240);
float x = 0;
while (x < width) {
float y = 0;
while (y < height) {
// in rare cases, paint using red color
if (random(100) > 98) {