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
let formData = new FormData(); | |
formData.append("name", "Tom"); | |
[...formData.keys()].reduce((acc, key) => ({ ...acc, [`${key}`]: formData.get(key) }), {}) |
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
create EXTENSION plv8; | |
create EXTENSION pltcl; | |
CREATE FUNCTION sql_max(integer, integer) RETURNS integer AS $$ | |
BEGIN | |
IF $1 > $2 THEN | |
RETURN $1; | |
END IF; | |
RETURN $2; | |
END; |
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
function computeTwoGreatestNumbersFromListOfNumbers(listOfNumbers) { | |
return listOfNumbers.reduce( | |
(currentlyKnownGreatestValues, currentValueWhileIterating) => { | |
if (currentValueWhileIterating > currentlyKnownGreatestValues[0]) { | |
return [currentValueWhileIterating, currentlyKnownGreatestValues[0]]; | |
} else if (currentValueWhileIterating > currentlyKnownGreatestValues[1]) { | |
return [currentlyKnownGreatestValues[0], currentValueWhileIterating]; | |
} else { | |
return currentlyKnownGreatestValues; | |
} |
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
let colors = [ | |
{ | |
hex: "#EFDECD", | |
name: "Almond", | |
rgb: "(239, 222, 205)" | |
}, | |
{ | |
hex: "#CD9575", | |
name: "Antique Brass", | |
rgb: "(205, 149, 117)" |
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
import React from "react"; | |
import { dispatch, createStore } from "xander"; | |
import Formula, { branch, filter, compile, isText, isArray } from "formula"; | |
import colors from "./colors"; | |
// Create a store to manage the value for key "name". | |
createStore("name", (state = "", { type, data }) => | |
branch(type == "SetName", data, state) | |
); |
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"); | |
var webpack = require("webpack"); | |
var fs = require("fs"); | |
var serverDir = path.dirname(fs.realpathSync(__filename)); | |
let load = module => [path.join(process.cwd(), "js", module)]; | |
console.log("configure webpack", serverDir); |
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"); | |
var webpack = require("webpack"); | |
var { version, vendor } = require(path.join(process.cwd(), "package.json")); | |
var fs = require("fs"); | |
var serverDir = path.dirname(fs.realpathSync(__filename)); | |
let load = module => [path.join(process.cwd(), "js", module)]; | |
module.exports = { | |
devtool: "source-map", | |
entry: { |
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
#!/usr/bin/env node | |
var koa = require("koa"); | |
var app = koa(); | |
var serveViews = require("koa-front-matter-views"); | |
var serve = require("koa-static"); | |
var accesslog = require("koa-accesslog"); | |
var moment = require("moment"); | |
var path = require("path"); | |
var cwd = process.cwd(); |
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
// import filter function from formula library | |
var { filter } = require('formula'); | |
// test data | |
let data = [ | |
{ id: 1, name: 'Joe', data: [1, 2, 3] }, | |
{ id: 2, name: 'Joe', data: [10, 20, 30], created: new Date() }, | |
{ age: 1 }, | |
{ age: 10 }, | |
{ age: 100 }, |
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'); | |
var webpack = require('webpack'); | |
var hotMiddlewareScript = 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000&reload=true'; | |
module.exports = { | |
devtool: 'source-map', | |
entry: { | |
app: ['webpack-hot-middleware/client', './client/App'] | |
}, | |
output: { |
NewerOlder