Skip to content

Instantly share code, notes, and snippets.

View ralt's full-sized avatar

Florian Margaine ralt

View GitHub Profile
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '--link' ]
2 info using npm@1.2.15
3 info using node@v0.10.1
4 verbose read json /home/florian/tmp/package.json
5 warn package.json npm-test2@1.0.0 No README.md file found!
6 verbose readDependencies using package.json deps
@ralt
ralt / local.js
Created March 23, 2013 21:56
LocalStorage bug?
localStorage.setItem('getItem', 4)
undefined
localStorage.getItem
function getItem() { [native code] }
localStorage['getItem'] = 'user'
"user"
localStorage.getItem
"user"
@ralt
ralt / gist:5484237
Last active December 16, 2015 19:19
MD to HTML

The tokenizer

First, the markdown goes through the tokenizer.

The tokenizer splits by paragraphs, which gives this kind of structure:

(("text of paragraph 1") ("text of paragraph 2"))

Then, the tokenizer finds the special characters to split up words. There is then this kind of structure:

@ralt
ralt / gist:5543525
Created May 8, 2013 20:46
My programming books
Code Complete 2
@ralt
ralt / gist:5543578
Last active December 17, 2015 03:29
List of list of books
List of list of books so that we can do book exchanges.
Florian Margaine: https://gist.github.com/Ralt/5543525
@ralt
ralt / gist:5561744
Last active December 17, 2015 05:59
Example of bind usage
var obj = {
clickHandler: function() {
console.log(this); // "el"
}
};
el.addEventListener('click', obj.clickHandler.bind(el));
// Without "bind", we need something like this:
var obj = {
@ralt
ralt / gist:5574170
Last active December 17, 2015 07:39
function serialize(form) {
return [].reduce.call(form.elements, function(r, element) {
return r + (r === '' ? '' : '&') + (function() {
switch (element.type) {
case 'checkbox':
return name(element.checked);
case 'radio':
return element.checked ? name(element.value) : '';
@ralt
ralt / gist:5644131
Last active December 17, 2015 17:09 — forked from Zirak/gist:5644118

Current situation: A small amount of users annoy the lot of us, we have no power to ban them, mods are annoyed.

Official solution: Go into Gallery mode, so all users can view, only users with explicit write permissions can write. This has the problem of approving users. We don't want to manually approve nearly everyone just to disapprove a small number.

Wayward solution: Use Gallery mode with the bot. When a user enters the room, the bot grants him write access automatically. If the user already has the access, the write access request will just send back a 400 error. No biggie. As it's automatic, the transition is nearly seamless. If a user is banned, the bot won't grant him write access.

// module.js
module.exports = function() {
var not = 'shared',
between = 'objects';
return {
an: ['array'],
some: method() {}
};
@ralt
ralt / gist:5705968
Last active December 18, 2015 01:48
oOOoOoOoo is annoying
http://chat.stackoverflow.com/messages/9801864/history
http://chat.stackoverflow.com/messages/9802972/history
http://chat.stackoverflow.com/messages/9803139/history
http://chat.stackoverflow.com/messages/9901384/history
http://chat.stackoverflow.com/messages/9902279/history
http://chat.stackoverflow.com/messages/10055261/history
http://chat.stackoverflow.com/messages/10160974/history
http://chat.stackoverflow.com/messages/10177459/history
http://chat.stackoverflow.com/messages/10590194/history
http://chat.stackoverflow.com/messages/10590195/history