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 / 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);
@xrogaan
xrogaan / toolz.php
Created November 19, 2010 19:52
powa toolz
<?php
/* Construit une URL en reprenant l'URL actuelle et certains de ses paramètres GET
si $keep est un array, seuls les éléments de $keep sont conservés
si $remove est un array, les éléments de $remove sont enlevés
si $add est un array( clé => valeur ), ces paramètres sont ajoutés à l'URL
exemple :
url actuelle : truc.php?a=1&b=2
url_from_get_vars( array( 'a' ), false, array( 'c' => 3 ) )
=> truc.php?a=1&c=3