Skip to content

Instantly share code, notes, and snippets.

View dimitrisnl's full-sized avatar
🆗
Computer

Dimitrios Lytras dimitrisnl

🆗
Computer
View GitHub Profile
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
@tridungle
tridungle / multi-tenancy-adonis.md
Last active May 23, 2023 23:00
multi tenancy implementation with adonis

I thought I'd add my multi tenancy implementation here as it might prove useful for others. We currently have to separate our customer data into their own databases, but not for everything. Our microservices need to know where to store their data with our many IoT devices reporting in.

I choose to only perform model actions on a tenant database via callbacks and proxies. We get a Tenant object from the tenant manager which allows us to perform actions on the tenant in a manner similar to a transaction callback.

 const User = use('App/Models/User');
 const Device = use('App/Models/Device');
 const TenantManager = use ('App/Services/TenantManager');

 const tenant = TenantManager.tenant('adonis');
@JamieMason
JamieMason / es6-partial-application.md
Last active September 19, 2020 20:41
ES6 Partial Application in 3 Lines

ES6 Partial Application in 3 Lines

const pApply = (fn, ...cache) => (...args) => {
  const all = cache.concat(args);
  return all.length >= fn.length ? fn(...all) : pApply(fn, ...all);
};

Example

@forest
forest / git-workflow.md
Created February 22, 2016 18:15
Git Feature Branch Workflow

We subscribe to the Git Featrue Branch workflow, briefly described in that link.

In practice, it works as follows:

FEATURE DEVELOPMENT

Steps to Follow:

  1. Start with an updated local development branch -- by checking out the dev branch and pulling changes:
    git checkout development
    git pull origin development
@bendc
bendc / functional-utils.js
Last active December 25, 2025 22:31
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)