Backbone.js is awesome, but sometimes you just don't need the full MVC stack.
This is just a random experiment to come up with something simple and familiar to Rails developers, to allow something like:
// create a Post model
var Post = jjj.Model({| <h1>Un Appello ai Blogger Italiani</h1> | |
| <p>Per favore: | |
| <ul> | |
| <li>Utilizzate una font di almeno 14 pixels, meglio 16</li> | |
| <li>Utilizzate un interlinea intorno al 150%</li> | |
| <li>Mantenete strette le colonne di testo</li> | |
| </ul> | |
| Grazie per non volerci procurare cecità. | |
| </p> |
| /* Placeholders plugin for jQuery | |
| * Use this to provide a graceful fallback for browsers not supporting the html5 placeholder attribute | |
| * | |
| * Usage: | |
| * jQuery('form').placeholders(); // if the user's browser do not support placeholder, it implements a fallback | |
| * | |
| * You can also specify some options: | |
| * jQuery('form').placeholders({ | |
| * placeholderAttr: "title", // specify the attribute to get placeholder value from (default: 'placeholder') | |
| * placeholderedClass: "custom-class" // the class added to the input element when its value is a placeholder (default 'placeholdered') |
Backbone.js is awesome, but sometimes you just don't need the full MVC stack.
This is just a random experiment to come up with something simple and familiar to Rails developers, to allow something like:
// create a Post model
var Post = jjj.Model({the $query (aliased with $q) object exposes two methods: first() and all(). Both take a selector string as the first argument and, optionally, a context element as the second.
$q.first(".foo"); // => first element of class `foo`
$q.all(".foo"); // => array (yes, not NodeList) of all elements of class `foo`
var elem = $q.first("p");| #! /usr/bin/env ruby | |
| require 'date' | |
| require 'fileutils' | |
| require 'optparse' | |
| def parse_cli_options | |
| options = {} | |
| OptionParser.new do |opts| |
| #! /usr/bin/env ruby | |
| require 'date' | |
| require 'fileutils' | |
| require 'optparse' | |
| def parse_cli_options | |
| options = {} | |
| OptionParser.new do |opts| |
| // ---- | |
| // Sass (v3.3.0.rc.4) | |
| // Compass (v1.0.0.alpha.18) | |
| // ---- | |
| // Start with a class .foo | |
| .foo { | |
| line-height: 150%; | |
| font-size: 2em; | |
| } |
| // ---- | |
| // Sass (v3.3.0.rc.4) | |
| // Compass (v1.0.0.alpha.18) | |
| // ---- | |
| // Start with a class .foo | |
| %foo { | |
| line-height: 150%; | |
| font-size: 2em; | |
| } |
A stupidly simple implementation of a kind of "sorta immutable" struct that can be instantiated as conveniently as an OpenStruct but after instantiation it doesn't let me (easily) add fields or mutate them:
guy = ClosedStruct.new( name: "John", age: 23 )
# readers:
guy.name #=> "John"
guy.age #=> 23| var LRUCache = (function() { | |
| function LRUCache(options) { | |
| this._options = options || {} | |
| this._map = {} | |
| this._queue = {} | |
| this._capacity = this._options.capacity || 10 | |
| this._size = 0 | |
| } | |
| var _detachFromQueue = function(node, queue) { |