Skip to content

Instantly share code, notes, and snippets.

View nkpremices's full-sized avatar
🎯
Focusing

Prémices Kamasuwa nkpremices

🎯
Focusing
View GitHub Profile
@nkpremices
nkpremices / jwt.php
Created January 14, 2022 18:20
Generate you own jwt library with plain PHP. Prerequesites PHP 7.3.5 – 7.4.23
<?php
/*
To generate JWT you need mainly header, payload and secret.
Next you create a signature from the encoded header, the encoded payload, a secret,
the algorithm specified in the header.
The header is a JSON object with the following properties:
{
"alg": "HS256",
"typ": "JWT"
@nkpremices
nkpremices / switch.ts
Last active May 19, 2021 15:57
switch statement with regexp
const getAdminTitle = (locationPathname: string) => {
switch (locationPathname) {
case '/admin':
return 'admin';
case (
locationPathname.match(
'/admin/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/offers',
) || {}
).input: