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 order = await UsersDb.models.order.findOne({ where: { id: 1 } }); | |
await order.createProduct({ name: 'oathkeeper' }); | |
await order.createProduct({ name: 'longclaw' }); | |
await order.createProduct({ name: 'needle' }); | |
const products = await order.getProducts(); | |
console.log(products); | |
// output | |
[ { id: 1, order_id: 1, name: 'oathkeeper' }, | |
{ id: 2, order_id: 1, name: 'longclaw' }, |
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 = require("sequelize"); | |
const config = require("../config"); | |
const UsersDb = new Sequelize(config.usersDatabaseName, config.username, config.password, config.options); | |
UsersDb.import("models/user.js"); | |
UsersDb.import("models/order.js"); | |
const ProductsDb = new Sequelize(config.productsDatabaseName, config.username, config.password, config.options); |
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
mysql> show databases; | |
+ - - - - - - - - - - + | |
| Database | | |
+ - - - - - - - - - - + | |
| products | | |
| users_and_orders | | |
+ - - - - - - - - - - + | |
mysql> show tables in users_and_orders; | |
+----------------------------+ |
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
// models/user.js | |
module.exports = (sequelize, DataTypes) => | |
sequelize.define( | |
"user", | |
{ | |
id: { | |
type: DataTypes.INTEGER(11), | |
allowNull: false, | |
primaryKey: true, |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<system.diagnostics> | |
<trace autoflush="true" /> | |
<sources> | |
<source name="ArcGIS Web Adaptor" switchName="sourceSwitch" switchType="System.Diagnostics.SourceSwitch"> | |
<listeners> | |
<add name="ArcGISWebAdaptorListener" /> | |
<remove name="Default" /> | |
</listeners> |
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 a = [0,[[2,[3,3]],[[3,[4,4]],[3,[4,[[6,6],5]]]]]] | |
const findBranchSize = R.pipe(R.flatten, R.length) | |
const compareBranches = R.useWith(R.gte, [findBranchSize, findBranchSize]) | |
const findDeepestNode = (tree) => { | |
let i = 0; | |
let path = []; |
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
// applying spec of functions to initial passed object | |
const mergeSpec = R.curry(function mergeSpec(spec, value) { | |
return R.converge(R.merge, [R.identity, R.applySpec(spec)])(value) | |
}) | |
// now we can combine data from different props and apply it to the original object | |
const getFullName = R.pipe(R.pick(['first_name', 'last_name']), R.values, R.join(' ')) | |
const combineLikesAndComments = R.converge(R.concat, [ |
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
#include <iostream> | |
#include <vector> | |
#include <queue> | |
using namespace std; | |
struct Node{ | |
int i,j,h; | |
Node(int ii,int jj,int hh):i(ii),j(jj),h(hh){} |
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
#include <iostream> | |
int arrayLength = 3; | |
int findMatchingCollections(std::string inputString, std::string collections[]) { | |
int matchCounter = 0; | |
for(int i = 0; i < arrayLength; i++) { | |
int collectionLength = collections[i].length(); | |
int j = 0; | |
bool allMatching = true; |
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 polygonEvents = ['set_at', 'insert_at', 'remove_at']; | |
const circleEvents = ['center_changed', 'radius_changed']; | |
import turfCircle from '@turf/circle'; | |
import { polygon as turfPolygon } from '@turf/helpers'; | |
import { featureToWKT } from './map-utilities'; | |
import { cond, has, hasIn, pipe, path } from 'ramda'; | |
export const setShapeEventListener = (shape, action) => { | |
if (shape.radius) { | |
circleEvents.forEach(event => { |