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 | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
$database = 'db'; | |
$user = 'user'; | |
$pass = 'pass'; | |
$host = 'localhost'; |
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
/** | |
* Use the browser's local storage to store the data. | |
* You can optionally give an expiration date in seconds or timestamp. | |
**/ | |
let cookies = { | |
get: (key) => { | |
if (!localStorage.getItem(key) || key === null) { | |
return null; | |
} |
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
// Source : https://lowrey.me/encoding-decoding-base-62-in-es6-javascript/ | |
const base62 = { | |
charset: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''), | |
encode: integer => { | |
if (integer === 0) { | |
return 0; | |
} | |
let s = []; | |
while (integer > 0) { |
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
const randomizer = { | |
chars : [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789"], | |
getString : length => [...Array(length)].map(_ => randomizer.chars[Math.random() * randomizer.chars.length|0]).join('') | |
}; | |
/* How to use | |
========================================================= | |
| Code | Example of result | | |
| randomizer.getString(10) | SeEmxH6haF | |
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
/* | |
========================================================= | |
Here is how to use the code | |
========================================================= */ | |
const jsonApi = api("https://jsonplaceholder.typicode.com/"); | |
// GET, request to "https://jsonplaceholder.typicode.com/todos/1" | |
jsonApi.get('todos/1', json => console.log(json)); | |
// POST, request to "https://jsonplaceholder.typicode.com/posts" |
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
/* | |
* Backend implementation: express middleware which checks the firebase user token and execute the request only when the token is verified | |
*/ | |
import * as express from "express"; | |
import * as admin from "firebase-admin"; | |
import * as functions from "firebase-functions"; | |
admin.initializeApp({ | |
credential: admin.credential.applicationDefault(), | |
}); |
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 | |
/* | |
* The `fix_serialized` function fixes serialized data which has been corrupted by an incorrect byte count length, | |
* especially in the case of a search & replace done on a dump of a wordpress database. | |
*/ | |
$corruptedSerialization = 'a:3:{i:0;s:150:".DS_Store";i:1;s:100:".git";i:2;s:190:"node_modules";}'; | |
if (is_serialized($corruptedSerialization)) { | |
$fixed = fix_serialized($corruptedSerialization); | |
print_r(unserialize($fixed)); | |
} |
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
/** | |
* Support filename= and filename*= with the priority given to filename*= | |
* Encoding and locale can optionaly be provided with filename*= | |
* Return undefined if the content-disposition doesn't contain filename= or filename*= | |
*/ | |
const { TextDecoder } = require("util"); | |
function getFilenameFromContentDisposition(contentDisposition: string) { | |
if (!contentDisposition) { | |
return undefined |
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
[ripple] { | |
position: relative; | |
.ripple-container { | |
top: 0; left:0; right: 0; bottom: 0; | |
position: absolute; | |
overflow: hidden; | |
border-radius: inherit; | |
} |