View 0-index.js
// Middleware function creates a `ctx.render('homepage', { title, foo })`
// function on the koa context.
const reactRenderware = (root, _opts = {}) => {
const defaultOpts = () => ({ locals: {} })
const { locals: globals, opts } = { ...defaultOpts(), ..._opts }
const { extname } = require('path')
const React = require('react')
const ReactDOMServer = require('react-dom/server')
const Master = require(path.join(root, 'master.jsx'))
return async (ctx, next) => {
View .js
{
console.log('=== body validation')
const body = {
uname: 'foo',
email: 'me@example.com',
pass1: 'secret',
pass2: 'secret',
}
const v = Validator.succeed(body)
.andThen(() => {
View .js
import { v, validate } from '.'
async function run() {
const body = {
uname: ' foo ',
pass1: 'secret',
pass2: 'secret',
nums: [1, 2, 3],
users: [{ uname: 'foo' }, { uname: 'bar' }],
a: { b: 42 },
View .js
const fs = require('fs')
const { join } = require('path')
module.exports = { crawlSync, crawlAsync }
function crawlSync(path) {
let cache = new Map()
const stats = fs.statSync(path) // <-- A
if (stats.isFile()) {
View .js
import { v, validate } from '.'
async function run() {
const body = {
uname: ' foo ',
pass1: 'secret',
pass2: 'secret',
nums: [1, 2, 3],
users: [{ uname: 'foo' }, { uname: 'bar' }],
a: { b: 42 },
View .vimiumrc
map <c-p> previousTab
map <c-n> nextTab
map d removeTab
map u restoreTab
map <c-o> goBack
map <c-i> goForward
map <c-d> scrollPageDown
map <c-u> scrollPageUp
View .elm
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onInput, onClick)
main =
Html.beginnerProgram { model = Model "" "", view = view, update = update }
type alias Model =
View Json.scala
// WARNING! totally untested, I have only compiled the code! :)
package json
import collection.immutable.Map
import scalaz.{\/, MonadPlus}
import scalaz.\/._
import scalaz.std.vector._
import scalaz.std.map._
import scalaz.std.list._
View .kt
package com.danneu.result
class State <T> (var target: T, var tip: String? = null) {
override fun toString() = "[State tip=$tip]"
}
typealias ResultState <T> = Result<State<T>, String>
View main.kt
package com.danneu.msgpack
import org.msgpack.core.MessagePack
import org.msgpack.core.MessagePacker
import org.msgpack.core.MessageUnpacker
import org.msgpack.value.ValueType
import java.math.BigInteger
// DEMO: Encode <-> Decode roundtrip