This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Use Markdown, sometimes, in your HTML. | |
// @author Paul Irish <http://paulirish.com/> | |
// @link http://git.io/data-markdown | |
// @match * | |
// ==/UserScript== | |
// If you're not using this as a userscript just delete from this line up. It's cool, homey. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Here is an implementation of an NPM module I recently wrote, done with ES6 classes. | |
* Is it a "betrayal" of the prototypal nature of JavaScript to use classes? Come on. | |
* Classes are a very common design pattern that's easy to implement with prototypes. | |
* And for some use cases, they're a good fit. Node's EventEmitter abstraction is a | |
* perfectly reasonable use of classes and inheritance: it's an abstract datatype that's | |
* user-extensible. So the 'events' module provides a base class with some built-in | |
* functionality that you can extend. | |
* | |
* And yes, it's a "class." Just check the docs: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----- Example code: | |
// Class declarations: | |
// - No data properties allowed | |
// - Future: support mixins | |
// - Optional: call the initialization method `new` instead of `constructor` | |
// Superclass | |
class Person { | |
constructor(name) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var originalNodeListProto = NodeList.prototype; | |
var temporaryNodeListProto = Object.create(NodeList.prototype); | |
temporaryNodeListProto.a = 1; | |
NodeList.prototype = temporaryNodeListProto; | |
var l = document.querySelectorAll('a'); | |
console.log(l.a); // inherited from which prototype? | |
NodeList.prototype = originalNodeListProto; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Object.prototype, 'forIn', { | |
value: function(iterator, thisValue) { | |
Object.keys(this).forEach(function(key) { | |
iterator.call(thisValue, this[key], key, this); | |
}.bind(this)); | |
} | |
}); | |
var obj = {a: 1, b: 2}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A Dict class that works in ES6 using Map. Basically it's identical to Map, but | |
// only expected to be used on string keys. | |
function Dict() { | |
this.elts = new Map(); | |
} | |
// (string) -> any | |
Dict.prototype.get = function get(key) { | |
return this.elts.get(key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Airplane - "Apertem os cintos, o piloto sumiu" - Fasten your seatbelts, the pilot disappeared | |
Giant (George Stevens) - "Assim Caminha a Humanidade" - "This way walk humanity" | |
Mystic River - "Sobre meninos e lobos" - "About boys and wolves" | |
The Hangover - Se beber, não case - If you drink, don't drive | |
The Godfather - O Poderoso Chefão - The Great Boss | |
The Good Son - O Anjo Malvado - The Evil Angel | |
The Sound of Music - A Noviça Rebelde - The Rebel Nun | |
The Transporter - Carga Explosiva - Explosive Cargo | |
The Tuxedo - O Terno de 2 Bilhões de Dólares - The 2 billion dollars suit | |
Be Cool - O Outro Nome do Jogo - The other name of the game |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var five = require("johnny-five"), | |
board; | |
board = new five.Board(); | |
board.on("ready", function() { | |
(new five.Led(13)).on(); | |
var dataPin = 2; | |
var clockPin = 3; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var Function = hasOwnProperty.constructor; | |
function isIdentifier(s) { | |
return /[a-zA-Z_$][a-zA-Z_$0-9]*/.test(s); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wire up LCD as described here: | |
// http://learn.adafruit.com/character-lcds/overview | |
var five = require("johnny-five"), | |
board, lcd; | |
board = new five.Board(); | |
board.on("ready", function() { |