Skip to content

Instantly share code, notes, and snippets.

@dimitrilahaye
dimitrilahaye / index.ts
Last active February 7, 2023 07:04
[Typescript] Usage of Dependency Injection with tsrynge
// example taken from https://blog.logrocket.com/dependency-inversion-principle-typescript
// all in one file
/**
* "reflect-metadata"
* This is a [Polyfill](https://developer.mozilla.org/fr/docs/Glossary/Polyfill) allowing
* to add the system of [reflection](https://fr.wikipedia.org/wiki/R%C3%A9flexion_(informatique))
* to javascript.
* This is a necessary lib for all dependency injection questions (with "tsrynge")
@dimitrilahaye
dimitrilahaye / test.sql
Created March 12, 2020 14:32
PostgresSQL => Some CRUD operations with JSONB
--------------------------------------------------------
-- Add key into a nested object and hard code its value
--------------------------------------------------------
UPDATE my.table
SET data = jsonb_set(data::jsonb, '{"user","config","application"}', '"GOOGLE"');
/*
-- before
{
"user": {
"fullname": "Barney Stinson",
@dimitrilahaye
dimitrilahaye / README.md
Last active January 17, 2020 13:44
Use a date string from a specific timezone and return a converted date object in local timezone

Jetlag function

This function takes a date string and its specific timezone and return a converted date object in client's local timezone

Example with a server based in Berlin:

// the string date "2020-01-15 15:25:55" is based on Berlin timezone
// jetLag will give us a Date instance in the right client's local timezone.
const localDate = jetLag("2020-01-15 15:25:55", "Berlin");
@dimitrilahaye
dimitrilahaye / README.md
Last active February 27, 2024 20:28
Mapbox Geocoding API TypeScript/Angular wrapper (documentation here https://docs.mapbox.com/api/search/#geocoding)

Mapbox Geocoding API TypeScript/Angular wrapper

This is a wrapper for Mapbox Geocoding API.

It uses Angular, Mapbox GL, RxJS and lodash.

Original documentation here: https://docs.mapbox.com/api/search/#geocoding

Get coordinates from an address:

@dimitrilahaye
dimitrilahaye / README.md
Last active June 5, 2018 07:55
Simple webpack configuration for export / import

Launch commands :

npm install
npm run webpack