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
{ | |
title: "Bread Sticks", | |
category: "Appetizer", | |
elements: [ | |
{ | |
title: "garlic butter", | |
ingredients: [ | |
{ | |
count: 1.5, | |
title: "butter" |
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
#set($elements = []) | |
#set($ingredients = []) | |
#foreach($item in $ctx.result.items) | |
#if($item['dbtype']=="info") | |
#set($title = $item['title']) | |
#set($status = $item['status']) | |
#set($id = $item['id']) | |
#set($type = $item['type']) | |
#set($category = $item['category']) |
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
{ | |
"id": "87971", | |
"category": "breakfast", | |
"elements": [ | |
{ | |
"title": "dough", | |
"ingredients": [ | |
{ | |
"title": "flour", | |
"count": 1, |
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
{ | |
"version" : "2017-02-28", | |
"operation" : "Query", | |
"query" : { | |
"expression": "id = :id", | |
"expressionValues" : { | |
":id" : { | |
"S" : "${ctx.args.id}" | |
} | |
} |
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
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:DeleteItem", | |
"dynamodb:GetItem", | |
"dynamodb:PutItem", | |
"dynamodb:Query", | |
"dynamodb:Scan", |
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
#set($recipedata = []) | |
#foreach($recipe in ${ctx.args.recipes}) | |
$util.qr($recipe.put("author", $ctx.identity.username )) | |
$util.qr($recipedata.add($util.dynamodb.toMapValues($recipe))) | |
#end | |
#set($elementsdata = []) | |
#foreach($element in ${ctx.args.elements}) | |
$util.qr($elementsdata.add($util.dynamodb.toMapValues($element))) | |
#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 findHighestValues(arr, numberOfValues) { | |
return Object.assign(...arr.map((val, i) => [i, val]) | |
.sort((a, b) => b[1] - a[1]) | |
.filter((keyVal, i) => i <= numberOfValues) | |
.map(([i, val]) => ({[i]: val}))); | |
} |
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
// this function is rather long for doing something simple. | |
function getSustainedPeriods(arr) { | |
let life = []; | |
let lifeCount = 0; | |
let death = []; | |
let deathCount = 0; | |
for (var i = 0; i < arr.length; i++) { | |
if (arr[i] === 1) { | |
life[lifeCount] === undefined ? life[lifeCount] = [1] : life[lifeCount] = [...life[lifeCount], 1]; |
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 array of objects to use in testing | |
function generateExamples() { | |
const genExample = [ | |
[0, 0, 0, 0, 0], | |
[0, 1, 1, 0, 0], | |
[0, 0, 0, 1, 0], | |
[0, 1, 1, 1, 0], | |
[1, 0, 0, 0, 0] | |
]; |
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 nouveau(Constructor){ | |
let args = Array.prototype.slice.call(arguments); | |
function createNew(func){ | |
const newObj = Object.create(func.prototype); | |
return function() { | |
func.apply(newObj, arguments) | |
return newObj; | |
}; | |
}; | |
return createNew(args[0])(...args.slice(1)) |
NewerOlder