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
| // Available variables: | |
| // - Machine | |
| // - interpret | |
| // - assign | |
| // - send | |
| // - sendParent | |
| // - spawn | |
| // - raise | |
| // - actions |
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
| const sequelize = new Sequelize('database', 'username', 'password', { | |
| dialect: 'mysql', | |
| host: "my.server.tld", | |
| port: 9821, | |
| }) | |
| const Project = sequelize.define('project', { | |
| title: Sequelize.STRING, | |
| description: Sequelize.TEXT, | |
| }); |
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
| const Express = require('express'); | |
| const Liana = require('forest-express-sequelize'); | |
| const config = require('./config'); | |
| const models = require('./models'); | |
| const smartCollections = require('./smart-collections'); | |
| const app = Express(); | |
| const {Schemas} = Liana; | |
| // - Hijack Schemas.perform to load Liana collections ourselves |
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
| import React from 'react'; | |
| import Places from './places.components.jsx'; | |
| export default class Example extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = {address: {}}; | |
| this.handleChange = this.handleChange.bind(this); |
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
| houseWindsor = Object.assign({}, houseWindsor, { | |
| "William": Object.assign({}, houseWindsor["William"], { | |
| life: houseWindsor["William"].life.concat(2016) | |
| } | |
| })); |
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
| houseWindsor = { | |
| "Elizabeth II": { | |
| name: "Elizabeth II", | |
| life: [1926], | |
| marriages: [{ | |
| partner: "Philip", | |
| children: [ "Charles", "Anne", ... ] | |
| }] | |
| }, | |
| "Philip": { ... }, |
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
| function LRU(limit) { | |
| this.limit = limit || 1000; | |
| this.map = new Map(); | |
| } | |
| LRU.prototype.has = function(key) { | |
| return this.map.has(key); | |
| } | |
| LRU.prototype.set = function(key, value) { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>Caching strategies</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
| <script src="./suite.js"></script> | |
| </head> | |
| <body> | |
| <h1>Open the console to view the results</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
| // a memoizer that works with functions that receive two arguments | |
| // of any type (can be generalized to accept more arguments) | |
| function memoize(fn) { | |
| // The first level of our nested-cache | |
| var cacheLevel1 = new Map(); | |
| return function(arg1, arg2) { | |
| // Let's check the cache, using one argument at each level | |
| if ( !cacheLevel1.has(arg1) ) { | |
| // and create nested maps as we need them |
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 key = {a:1}; | |
| var value = 123456; | |
| var map = new Map(); | |
| map.set(key, value); | |
| map.get(key); // === 123456 |
NewerOlder