Skip to content

Instantly share code, notes, and snippets.

View xrogaan's full-sized avatar

Ludovic Bellière xrogaan

View GitHub Profile
@xrogaan
xrogaan / synonym.js
Created April 17, 2009 17:04
Ubiquity command to search for french synonyms at www.cnrtl.fr
function getSynonymie(previewBlock, word) {
var searchUrl = "http://www.cnrtl.fr/synonymie/";
CmdUtils.previewAjax(previewBlock, {
type: "GET",
url: searchUrl + word,
error: function() {
previewBlock.innerHTML = "<i>Error retreiving synonyms list.</i>";
},
success: function(responseData) {
#!/bin/bash
# Copyright 2006 Bellière Ludovic <xrogaan@gmail.com>
# Distributed under the terms of the GNU General Public License v2
PWD=`pwd`
DIR="${PWD}"
GREEN=""
RED=""
CYAN=""
@xrogaan
xrogaan / main.c
Created September 23, 2009 18:54
#include <stdio.h>
int main() {
float temps, tauxInteretAnnuel, capital, interet, md;
const int annee = 365;
capital = 10000.00;
tauxInteretAnnuel = 0.035;
interet = 0;
temps = 1000.00/annee;
<?php
function genKey($id) {
$rand = rand(0, 1000000);
$shaRand = sha1($rand);
$shaId = sha1($id);
$p1 = rand(0,strlen($shaId)*0.2);
$p2 = rand(strlen($shaId)*0.6, strlen($shaId));
// on retourne shaRand et une partie du hash de l'id.
return uniqid($shaRand.((strlen($p2) >= strlen($shaId)*0.8) ? substr($shaId, -$p2) : substr($shaId, $p1, $p2)));
@xrogaan
xrogaan / function.form_base.php
Created October 9, 2009 17:34
smarty plugin for powaform
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {form_base} function plugin
@xrogaan
xrogaan / SAMPLE_powalib+galette.php
Created October 17, 2009 19:44
powaform and smarty
<?php
$form = new FormBase( 'editer_intitules', // son nom
url_from_get_vars( false ), // son url de submit est l'url du script courant (url_from_get_vars)
false, // préfixe de clé par défaut
array( // liste des champs du form
"Informations intitulés", // Titre du chapitre 1
#include <stdio.h>
#include "gestion.h"
float MOYENNE( float tableau[6])
{
int i,y;
float min=tableau[0],somme=0;
for (i=0; min<6; i++) {
if (tableau[i]<min){
@xrogaan
xrogaan / tools.php
Created March 13, 2010 22:09
two function to make html table
<?php
/**
* Calcule le nombre de lignes et de colonnes pour afficher un tableau harmonieux
*
* la taille max demandée. Si $prefer_few_cols est true, génère un tableau avec $maxcols colonnes
* et plus de lignes, sinon génère un tableau avec $maxrows lignes et plus de colonnes.
*
* @param integer $ncells nombre d'éléments à mettre dans le tableau
* @param integer $maxcols nombre maxi de colonnes
@xrogaan
xrogaan / tree.php
Created April 12, 2010 16:56
List an array in a tree-like format
<?php
/**
* Copyright 2010 Ludovic Bellière. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
@xrogaan
xrogaan / buildmessagefromarray.php
Created July 11, 2010 01:52
try to print a pretty array
<?php
error_reporting(E_ALL);
define('OBIWANKENOBI', true);
function debug($message) {
if (OBIWANKENOBI) {
if (!is_array($message)) {
printf("DEBUG : %s\n", $message);