BEM is a methodology for naming and classifying CSS selectors in a way to make them a lot more strict, transparent and informative.
The naming convention follows this pattern:
.block{}
.block__element{}
.block--modifier{}| // all this `toJSON()` does is filter out any circular refs. all other values/refs, | |
| // it passes through untouched, so it should be totally safe. see the test examples. | |
| // only extend the prototype if `toJSON` isn't yet defined | |
| if (!Object.prototype.toJSON) { | |
| Object.prototype.toJSON = function() { | |
| function findCircularRef(obj) { | |
| for (var i=0; i<refs.length; i++) { | |
| if (refs[i] === obj) return true; | |
| } |
| sum . takeWhile (<10000) . filter odd . map (^2) $ [1..] |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.(tl;dr DOM builders like [domo][domo] trump HTML templates on the client.)
Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].
The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.
John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.
But I can't really see the value in client-side HTML templates anymore.
| /* | |
| Grep.js | |
| Author : Nic da Costa ( @nic_daCosta ) | |
| Created : 2012/11/14 | |
| Version : 0.2 | |
| (c) Nic da Costa | |
| License : MIT, GPL licenses | |
| Overview: | |
| Basic function that searches / filters any object or function and returns matched properties. |
| # lol redhat | |
| su | |
| # Install deps | |
| yum install libyaml libyaml-devel openssl libxml2-devel bison libxslt-devel openssl-devel tcl tk libffi tcl-devel tk-devel libffi-devel | |
| # Download Ruby | |
| cd /usr/local/src/ | |
| wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz | |
| tar -xvzf ruby-1.9.3-p392.tar.gz |
| #!/usr/bin/env ruby | |
| require 'tempfile' | |
| require 'fileutils' | |
| # Signals | |
| trap("SIGINT") { exit } | |
| # Setup | |
| TARGET_FOLDER = ARGV[0] | |
| TARGET_URL = ARGV[1] |
| function MyObject() {} | |
| MyObject.prototype.doSomething = function() { | |
| console.log('MyObject.doSomething()'); | |
| } | |
| // ----- | |
| var parent = MyObject; |