Skip to content

Instantly share code, notes, and snippets.

View adrien2p's full-sized avatar
🍷
Just coding some stuff

Adrien de Peretti adrien2p

🍷
Just coding some stuff
View GitHub Profile
@adrien2p
adrien2p / dynamically-generated-mikro-entity.ts
Last active June 6, 2024 16:25
This is a quick and dirty POC to show how it can be achieve to create dynamically generated entity. The end code will not look at all like this
function buildEntity(entityName: string, properties: [{ name: string, type: string, columnType: string, index?: boolean }]) {
class DMLEntity {
[key: string]: any
constructor() {
for (const property of properties) {
this[property.name] = undefined
}
}
}
@adrien2p
adrien2p / DML-poc.ts
Last active June 6, 2024 16:26
quick and dirty DML poc to show the feasibility. The end code will not look this at all
type Ref<T> = T
type Factory<TModel> = () => Ref<TModel>
type PropertyType = 'string' | 'number' | 'boolean' | 'manyToOne' | 'oneToMany'
type PropertyMetadata<Type = PropertyType> = {
type: Type
default?: any
optional?: boolean
@adrien2p
adrien2p / wordsContainsInPhoneNumberSolver.js
Last active May 22, 2022 00:07
Find the words contained into a phone number
const numberToCharMap = new Map([
["+", 0],
["", 1],
["a", 2],
["b", 2],
["c", 2],
["d", 3],
["e", 3],
["f", 3],
["g", 4],
@adrien2p
adrien2p / set-heroku-env.sh
Last active March 1, 2022 09:41
🔧 Add your env variables to your Heroku app smoothly 🚀
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
NC='\033[0m'
usage="
A quick script to add env variables to your heroku application. Following options are required: