This file contains 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 path = require('path'); | |
/** | |
* Your configuration may look like: | |
* | |
* { | |
* "name": "my-app", | |
* "static": { | |
* "path": "/public" | |
* } |
This file contains 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 string = 'colors:red, colors:blue, sizes:42, sizes:44'; | |
var obj = string.split(', ') | |
.map(function(entry) { | |
return entry.split(':').reduce(function(prev, curr) { | |
if (!prev.name) { | |
prev.name = curr; | |
prev.value = ''; | |
} else { | |
prev.value += curr; |
This file contains 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 string = 'name:stock, vars:colors:red, vars:colors:blue,vars:sizes:44, really:nasty:nested'; | |
function parse(array) { | |
return array | |
.map(function(item) { | |
var parts = item.split(':'); | |
return { | |
key: parts.shift(), | |
value: parts.join(':') |
This file contains 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 fs = require('fs'); | |
var path = require('path'); | |
var util = require('util'); | |
var jade = require('builder-jade'); | |
var bundler = require('component-bundler'); | |
var builder = require('component-builder'); | |
var resolver = require('component-resolver'); | |
var runtime = builder.scripts.require + jade.runtime; |
This file contains 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
// in this case we inject the database as argument to another package | |
package httpd | |
import ( | |
"net/http" | |
"path/to/db" | |
) | |
var db *db.Database |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>WebSocket Benchmark</title> | |
</head> | |
<body> | |
<h1>WS Bench</h1> | |
<form> | |
<input placeholder="Type a message or drag file." /> | |
</form> |
This file contains 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
package main | |
import ( | |
"bytes" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
"net/http/httptest" | |
) |
This file contains 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
package parser | |
type Parser interface { | |
io.Reader | |
io.Writer | |
} | |
type EmailParser struct { | |
results [][]byte | |
} |
This file contains 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"time" | |
) |
This file contains 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
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Result interface { | |
Value() string | |
} |