Skip to content

Instantly share code, notes, and snippets.

View k33g's full-sized avatar
💭
Read my code at https://gitlab.com/k33g

Philippe Charrière k33g

💭
Read my code at https://gitlab.com/k33g
View GitHub Profile
@k33g
k33g / gist:1096826
Created July 21, 2011 09:07
Species.MVC à la Papa, dédicace à @loic_d
(function () {
var Customer = Species.Class({
Extends : Species.Model,
Name : {
get : function() { return this.name; },
set : function(value) { this.name = value; }
},
Budget : {
@k33g
k33g / gist:1129087
Created August 6, 2011 06:41
add Properties (get set) to BackBone Models
window.BBExtModel = Backbone.Model.extend({
initialize : function() {
function defineProperty(o,p) {
Object.defineProperty(o,p,{
get : function() { return o.get(p);},
set : function(value) {
var v = {}; v[p] = value;
o.set(v);
},
enumerable: true,
@k33g
k33g / lexer.coffee
Created October 2, 2011 18:51
Coffeescript version of @ariyahidayat's lexer and parser
#lexical analysis
#http://ariya.ofilabs.com/2011/08/math-evaluator-in-javascript-part1.html
class Lexer
constructor:->
@expression = ''
@length = 0
@index = 0
@marker = 0
@k33g
k33g / private.coffee
Created October 11, 2011 14:29
Creating A Private Scope By Extending The Public THIS Scope In JavaScript
#from @bennadel experiment : http://www.bennadel.com/blog/2269-Creating-A-Private-Scope-By-Extending-The-Public-THIS-Scope-In-JavaScript.htm
class Human
constructor:(name)->
@name = name
privateScope = Object.create @
privateScope.nickName = "???"
@getNickName = ->
@k33g
k33g / gettingStarted.coffee
Created October 12, 2011 04:51
Coffeescript version of "Getting Started with Sencha Touch 2"
# see http://docs.sencha.com/touch/2-0/#!/guide/getting_started
class TabPanel extends Ext.TabPanel
constructor:->
super
fullscreen : true
tabBarPosition: 'bottom'
items : [
{
title : 'Home'
@k33g
k33g / make-manifest.js
Created October 23, 2011 14:41
Nodejs script -> create manifest (cache)
var lib = require("./manifest.js");
lib.mkmanifest({
filename : "cache"
,path : "../coffee"
,version : "02"
,exclude : ['/.DS_Store', '/.htaccess', '/cache.manifest']
/*
,network : ['/connect.php','/read.php']
,fallback : ['/offline.html']
@k33g
k33g / annotations.coffee
Created November 11, 2011 20:18
kind of annotations with CoffeeScript
__ = (from,name,member,annotation)->
if not from.annotations then from.annotations = {}
if not from.annotations[name] then from.annotations[name] = {}
from.annotations[name][member] = annotation
class Human
__ @, "Model", "constructor", "localStorage"
__ @, "gui", "name", "name:input type = text"
__ @, "gui", "weight", "weight:input type = text"
#--- MODEL ---
class Task extends bob.Model
@storage : "Tasks_Storage"
constructor:(label)->
@label = label
@numericalId = 0
#--- CONTROLLER ---
class window.Tasks extends bob.Controller
@k33g
k33g / bob.html
Created December 8, 2011 17:04
Bob ...
<body>
<h1>TODO LIST</h1>
<!-- MESSAGE VIEW -->
<script type="text/template" id="message_template">
<h2>#{message}</h2>
</script>
<div id="message_view"></div>

par exemple tu fais :

function q(selector){ return  [].slice.apply(document.querySelectorAll(selector)); }

ensuite si tu as une page web avec :

<ul><li>un</li><li>deux</li><li>trois</li></ul>

et que tu fais :