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
// This package demonstrates a technique for (very nearly) adding methods | |
// to an interface. The code works and runs as is. | |
package main | |
import "fmt" | |
// A simple custom type | |
type Cell int | |
// CellSetMinimal is a (very) minimal interface to be easily implemented |
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 $ = require('jquery'); | |
function chunkify(rawHtml, chunks) { | |
var woven = $(rawHtml).find("code[title!='']"); | |
for (var i = 0; i < woven.length; ++i) { | |
var element = $(woven[i]); | |
var content = element.text(); | |
var name = element.attr("title"); | |
if (chunks[name]) | |
chunks[name] = chunks[name].concat(content); |
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
$ cat <<EOF > sample.txt | |
> title: Sample! | |
> | |
> = {{ title }} = | |
> EOF | |
$ yaml-assemble sample.txt | mustache | creole2html | |
<h1>Sample!</h1> |
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
<dl> | |
<dt>selector</dt> | |
<dd>dl</dd> | |
<dt>apply</dt> | |
<dd> | |
<ul> | |
<li> | |
<dl> | |
<dt>selector</dt> | |
<dd>> dt</dd> |
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
// Given a prototype-like object, create a class based on that object's | |
// properties. | |
function buildClass(spec) { | |
// Throw an exception of the argument is inappropriate: | |
if (typeof(spec) != 'object' || spec === null) | |
throw 'expected an object.'; | |
var empty = true; | |
for (var name in spec) { empty = false; break; } | |
if (empty) | |
throw 'expected a non-empty object.'; |
NewerOlder