Skip to content

Instantly share code, notes, and snippets.

View willywongi's full-sized avatar

Francesco Pongiluppi willywongi

View GitHub Profile
@willywongi
willywongi / entity.js
Created October 26, 2011 08:04
My own way of playing with the Y.App framework.
/* global YUI=true */
/* Note: the "png" prefix you're seeing through this file is just my own
namespace. No reference to the Portable Network Graphic intended. */
YUI.add('png-entity', function(Y) {
/**
The ContainmentUnit's purposes are: creating Entity extensions, store them and handle
the relations between them.
@class ContainmentUnit
@constructor
@willywongi
willywongi / conan.js
Created March 29, 2011 13:36
arbitrary arguments length object constructor, in Javascript
function CONAN(cls) {
/* Arbitrary Number of Arguments Object Constructor,
ANAOC
but everyone calls him
CONAN
CONAN takes a Object Constructor and adds a static method named "build", whose only
argument is an array that get passed to the Constructor with an apply.
*/
var _helper = function(s) {
cls.apply(this, s);
/* Python(ish) string formatting:
* >>> format('{0}', ['zzz'])
* "zzz"
* >>> format('{x}', {x: 1})
* "1"
*/
var format = (function() {
var re = /\{([^}]+)\}/g;
return function(s, args) {
return s.replace(re, function(_, match){ return args[match]; });
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Checkbox personalizzate</title>
<style>
#custom_checkbox input[type=checkbox] { display: none; }
#custom_checkbox label { padding-left: 20px; background-position: 0px center;
background-repeat: no-repeat; cursor: pointer; }