Skip to content

Instantly share code, notes, and snippets.

🦁
Writing the open-source software that you may be using everyday

Maël Nison arcanis

🦁
Writing the open-source software that you may be using everyday
Block or report user

Report or block arcanis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1255791
/**
* @class foo
*/
var foo = function () {
/**
* Stop, hammertime.
* @member foo
* @returns 42
View BAD.js
/**
* @class
*/
var foo = function () {
/**
* Stop, hammertime.
*
* @memberOf foo#
View gist:1255883
/**
* @mixin foo
*/
var foo = {
/**
* Does something.
*/
@arcanis
arcanis / gist:2724085
Created May 18, 2012
Classes en javascript
View gist:2724085
// Chaque fonction est un constructeur
var Foo = function ( ) { this.bar = 'hello world'; };
var instance = new Foo( );
console.log( instance.bar ); // "hello world"
// Chaque fonction possède un prototype
var Foo = function ( ) { };
Foo.prototype.bar = 'hello world';
var instance = new Foo( );
console.log( instance.bar ); // "hello world"
View set-python-version.sh
#!/usr/bin/env sh
# Usage :
# $> sudo set-python-version 2; python -V
# Python 2.7.2
# $> sudo set-python-version 3; python -V
# Python 3.2.2
python=$(which python)
pythonX=$(which python$1)
View gist:3285710
<?php
class StringRandomizer {
public function process( $text ) {
return preg_replace_callback('/\{(((?>[^\{\}]+)|(?R))*)\}/x', array( $this, 'replace' ), $text );
}
public function replace( $text ) {
$text = $this->process( $text[ 1 ] );
View gist:3676237

The Indentation Nightmare

If there is something that I have never fully understood during the last years of learning programming languages, it's the chaos around indentation. Some says that you should use spaces, some others says that you should use tabs. And even if you're willing to use spaces, there will be multiple schools, some people saying that you should use two spaces, instead of four for some other developers.

Why is it such a mess ? I don't even see why it is such a debatable topic : indentation is made by tabs. Alignment is made by spaces. Nothing more, nothing less. Want to know why ?

Spaces have a fixed length

Spaces are usefull because they have a fixed length. It means that it should be used when you have to align code. What's aligning ? Take this piece of code :

View gist:4047488
View 2013 April Fools
PonyOS
http://www.ponyos.org/
Blizzard - Starcraft : Warhound is back
https://us.battle.net/sc2/en/blog/9369235
Atlassian - JIRA Jr
http://www.atlassian.com/jirajr/
Lambda The Ultimate - Migration to Facebook
View Bad.js
MyEventManager.prototype.bootstrap = function ( ) {
var self = this;
this.listen( 'myEvent', function ( ) {
self.myEventListener( );
} );
};
// ---
var array = [ 1, 2, 3 ];
You can’t perform that action at this time.