Skip to content

Instantly share code, notes, and snippets.

@brunobord
brunobord / roliste.py
Created December 17, 2012 21:44
rôliste bot : a bot that can roll dice.
#-*- coding: utf8 -*-
import random
import logging
from cmdbot.core import Bot
from cmdbot.decorators import no_verb, regex
from cmdbot.core import logger
from cmdbot.configs import ArgumentConfiguration
logger.setLevel(logging.DEBUG)
@brunobord
brunobord / kill.js
Created January 30, 2013 23:21
Casper Script: restart Alwaysdata processes.
/**
* Casper script to restart Alwaysdata processes.
*
* Usage:
* $ casperjs kill.js email@example.com mysecretpassword
*/
var casper = require('casper').create();
casper.start("https://admin.alwaysdata.com/login/");
$ git init Stardrifter-gh-pages
$ cd Stardrifter-gh-pages
$ git remote add origin git@github.com:brunobord/stardrifter.git
$ git fetch git@github.com:brunobord/stardrifter.git gh-pages:refs/remotes/origin/gh-pages
$ git pull
$ git checkout gh-pages
@brunobord
brunobord / .gitignore
Last active June 8, 2023 21:50
Yet another Python-based RPN calculator
*.pyc
.pytest_cache/
.coverage
.tox/
@brunobord
brunobord / Usage.md
Last active December 14, 2015 23:58
JQuery FNU

Usage:

  • open any website using jQuery.
  • in the URL type
    javascript:$('*').each(function() { $(this).css({background: "#"+((1<<24)*Math.random()|0).toString(16)});});

Yes! it's ugly!

@brunobord
brunobord / boolean.js
Created March 22, 2013 16:43
JS Boolean - WAT
var my_true = Boolean("true"); // == true
var my_false = Boolean("false"); // == true // WTF?
var my_question = Boolean("what's the bloody point of the Boolean() function?"); // == true // WAT
//Solution:
var ok = JSON.parse("true"); // == true
var ko = JSON.parse("false"); // == false
@brunobord
brunobord / gist:5681346
Created May 30, 2013 21:22
localStorage (de)serialization via loads and dumps prototype functions
Object.getPrototypeOf(localStorage).dumps = function() {
return JSON.stringify(this);
};
Object.getPrototypeOf(localStorage).loads = function(str, clear) {
if (clear == true)
this.clear();
var doc = JSON.parse(str);
for (var i = 0; i < Object.keys(doc).length; i++) {
key = Object.keys(doc)[i];
this.setItem(key, doc[key]);
@brunobord
brunobord / gist:5695039
Last active May 29, 2019 16:20
localStorage migration mechanism. please, help me make it better if possible.
// -------- Database section
// current version
var __version__ = '1.0.0';
var __versions__ = {
'1.0.1': migrate_1_0_1,
'1.0.2': migrate_1_0_2,
'1.0.3': migrate_1_0_3,
}
function migrate_1_0_1() {
console.log('going into migrate_1_0_1');
@brunobord
brunobord / gist:5916751
Created July 3, 2013 09:57
trollish pep8 small rant
# If I had one PEP8 rule to wipe off, that would be the "argument indentation" thing
# isn't this PEP8-compliant code a bit against the "Flat is better than Nested" zen of Python?
my_superb_variable = MyBloodyClass(arg1='here is an argument',
label=_(u'What a beautiful label'),
argument2='sorry',
argument3=False)
# And in this case, I'm lucky. I'm not *inside* a class method or worse: inside a loop or a condition inside a class method.
# I really hate this indentation.
"""
I've been thinking lately about how perfect Redis would be for storing a
simple social graph. I posited that it would be relatively few lines of code,
and that it'd be clean code too. So here it is: a basic social graph built on Redis.
"""
class FriendGraph(object):
def __init__(self, ring):
self.ring = ring