Skip to content

Instantly share code, notes, and snippets.

View idodekerobo's full-sized avatar
👨‍💻
learning...👨🏾‍💻

Idode idodekerobo

👨‍💻
learning...👨🏾‍💻
View GitHub Profile
@alancasagrande
alancasagrande / multitenant_server_multi_db.js
Last active June 9, 2024 21:02
Multi-tenant app example with multiple databases. It will create 40 databases, use this gist to the delete them afterwards: https://gist.github.com/alancasagrande/4aa8b4a45ff7c8829ff5
var express = require('express');
var mongoose = require('mongoose');
var dbs = {};
for (var i = 0; i < 40; i++) {
dbs['t' + i] = mongoose.createConnection('mongodb://localhost/t' + i + '__multitenant', { server: { poolSize: 5 } });
}
var app = express();
@netgfx
netgfx / addObservers.swift
Last active June 8, 2024 04:59
Add observers to AVPlayer
// listening for current item change
self.audioQueueObserver = self.playerQueue?.observe(\.currentItem, options: [.new]) {
[weak self] (player, _) in
print("media item changed...")
}
// listening for current item status change
self.audioQueueStatusObserver = self.playerQueue?.currentItem?.observe(\.status, options: [.new, .old], changeHandler: {
(playerItem, change) in
if playerItem.status == .readyToPlay {
@jskod
jskod / multi-tenant.js
Created September 13, 2019 07:44
Multi-Tenant Mongoose Model Wrapper For NodeJS Based Applications
import mongoose, { Schema } from 'mongoose'
import { getCurrentTenantId } from './storage'
/**
Function will return another function, which will further return a mongoose discriminator.
The only difference here is that everytime you use the mongoose model, you will have to call a function,
but it will give you a freedom of passing tenant-based data.
*/
export function tenantModel(name, schema, options) {
return (props = {}) => {