This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
export const useLocalStorage = <ValueType>( | |
keyName: string, | |
defaultValue?: ValueType, | |
deserialize = JSON.parse, | |
serialize = JSON.stringify | |
): [ValueType | undefined, (newValue: ValueType) => void] => { | |
const [storedValue, setStoredValue] = useState<ValueType | undefined>(() => { | |
const value = globalThis.localStorage?.getItem(keyName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// lets assume we have an error object | |
// from a laravel API like the following: | |
$errorResponse = [ | |
'errors' => [ | |
'bike.name' => ['required']. | |
'locks.0.rrp' => ['min:49'], | |
'cancel_url' => ['required] | |
] | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Client } from '@notionhq/client'; | |
import { Block, User } from '@notionhq/client/build/src/api-types'; | |
export type ITodo = { | |
id: string; | |
title: string; | |
assignedTo: User[]; | |
dateCreated: Date; | |
dueDate: Date[]; | |
priority: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ElementRef, HostListener, Output, EventEmitter } from '@angular/core'; | |
import { NgControl } from '@angular/forms'; | |
@Directive({ | |
selector: '[numeric]' | |
}) | |
export class NumericDirective { | |
@Output() ngModelChange: EventEmitter<any> = new EventEmitter<any>(false); | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Directive, ElementRef, HostListener, Output, EventEmitter } from '@angular/core'; | |
import { NgControl } from '@angular/forms'; | |
@Directive({ | |
selector: '[numeric]' | |
}) | |
export class NumericDirective { | |
@Output() ngModelChange: EventEmitter<any> = new EventEmitter<any>(false); | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* extend the localStorageService (https://github.com/grevory/angular-local-storage) | |
* | |
* - now its possible that data stored in localStorage can expire and will be deleted automagically | |
* - usage localStorageService.set(key, val, expire) | |
* - expire is an integer defininig after how many hours the value expires | |
* - when it expires, it is deleted from the localStorage | |
*/ | |
app.config(($provide) => { | |
$provide.decorator('localStorageService', ($delegate) => { |