Skip to content

Instantly share code, notes, and snippets.

View david-mart's full-sized avatar
🍭

David Mart david-mart

🍭
View GitHub Profile
import React, { Component } from 'react';
import { DrawingManager } from 'react-google-maps/lib/components/drawing/DrawingManager';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { mapConfig } from '../../../../constants/component-configs';
import {
setShapeEventListener,
getShapeArea,
getFiltersFromGoogleMapsShape,
convertFromGoogleMapsShape
@david-mart
david-mart / gist:dda7b7ec303f70eed299074df9fb4da5
Created November 13, 2018 18:02
matchingCollections.cpp
#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;
@david-mart
david-mart / water-trapping.cpp
Created December 6, 2018 02:00
water trapping 3d problem
#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){}
@david-mart
david-mart / ramda.utils.js
Created December 19, 2018 06:01
Ramda utilities
// 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, [
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 = [];
<?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>
// models/user.js
module.exports = (sequelize, DataTypes) =>
sequelize.define(
"user",
{
id: {
type: DataTypes.INTEGER(11),
allowNull: false,
primaryKey: true,
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);
mysql> show databases;
+ - - - - - - - - - - +
| Database |
+ - - - - - - - - - - +
| products |
| users_and_orders |
+ - - - - - - - - - - +
mysql> show tables in users_and_orders;
+----------------------------+
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' },