Skip to content

Instantly share code, notes, and snippets.

View kane-thornwyrd's full-sized avatar
🏠
Working from home

Jean-cédric T. kane-thornwyrd

🏠
Working from home
  • Betterway
  • France
  • 12:16 (UTC +02:00)
View GitHub Profile
@kane-thornwyrd
kane-thornwyrd / exemple.php
Created December 16, 2011 10:26
Kane's best practice concerning Drupal Form's default Values.
<?php
function my_drupal_module_form_values($key, $form_state = array(), $default = NULL) {
$settings = array(
// Define here your form hierachies and default values
);
if (isset($form_state['values'])) {
$settings = array_merge($settings, $form_state['values']);
}
if (isset($form_state['storage']['my_form_root_element'])) {
$settings = array_merge($settings, $form_state['storage']);
var cubes, list, math, num, number, opposite, race, square,
__slice = Array.prototype.slice;
number = 42;
opposite = true;
if (opposite) number = -42;
square = function(x) {
@kane-thornwyrd
kane-thornwyrd / gist:1527752
Created December 28, 2011 12:10
Keycode handling
if (event.which == null)
char= String.fromCharCode(event.keyCode); // old IE
else if (event.which != 0 && event.charCode != 0)
char= String.fromCharCode(event.which); // All others
else
// special key
@kane-thornwyrd
kane-thornwyrd / gist:1564459
Created January 5, 2012 09:45
Sphinx search on Debian/GNU Linux (verbatim + update)
====== Sphinx on Debian/GNU Linux ======
This document explains how to build Sphinx debian package from source on a [[http://debian.org/|Debian]] GNU/Linux system.
===== 1. Why use a Debian-specific method? =====
It is easy to configure, compile and install Sphinx, but this method is not portable.
The Debian way is probably easier.
Even when building Sphinx manually, in the long run the Debian way will probably save labour, and is certainly the most reliable method.
@kane-thornwyrd
kane-thornwyrd / test.md
Created January 10, 2012 17:25
Juste un test IFTTT

Juste un test simple

@kane-thornwyrd
kane-thornwyrd / gist:1710797
Created January 31, 2012 14:34
Migrer les mots de passe de D6 à D7
<?php
// bootstrap stuff
define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
// Lower than DRUPAL_HASH_COUNT to make the update run at a reasonable speed.
@kane-thornwyrd
kane-thornwyrd / SplClassLoader.php
Created February 22, 2012 16:29 — forked from jwage/SplClassLoader.php
PSR0 implementation
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@kane-thornwyrd
kane-thornwyrd / README.md
Created March 16, 2012 10:27
Easy ripping command for shoutcast streams ;)

How To

  1. Save streamrip.sh as in the ~/.bash_script directory
  2. Add alias streamrip='~/.bash_script/streamrip.sh' to your .bash_aliases
  3. $ chmod a+x ~/.bash_script/streamrip.sh
  4. $ source ~/.bashrc
  5. $ cd ~/Music
  6. $ streamrip [url of your stream]
  7. Profit !
@kane-thornwyrd
kane-thornwyrd / decorator.coffee
Created March 20, 2012 14:03
Easy function decorator in Coffeescript
extendStart = (func)->
func ?= ()->
Function::extendEnd = (args...)=>
@kane-thornwyrd
kane-thornwyrd / FizzFuzzSimple.php
Created April 6, 2012 11:12
Juste un exemple de FizzFuzz
<?php
$array = range(0, 100);
print_r($array);
function fizzfuzz(array $array){
foreach ($array as $key => $value){
$array[$key] = '';
if(!($value%3)){
$array[$key] .= 'Fizz';
}