Skip to content

Instantly share code, notes, and snippets.

COUAILLIER Paul PCouaillier

Block or report user

Report or block PCouaillier

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View regex_not_string.js
const notString = s => `^(?:[^${s[0]}]|${s[0]}(?!${s.substring(1)}))*$`;
View show_exception_tree.php
<?php
if (!function_exists('interface_exists')) {
die('PHP version too old');
}
$throwables = listThrowableClasses();
$throwablesPerParent = splitInParents($throwables);
printTree($throwablesPerParent);
if (count($throwablesPerParent) !== 0) {
die('ERROR!!!');
View currencies.json
[
{
"code": "AED",
"symbol": "د.إ",
"name": "UAE dirham"
},
{
"code": "AFN",
"symbol": "؋",
"name": "Afghan afghani"
View npm commands.md

npm commands

npm install

npm install save

Save

npm i -S
View spy.ts
import {inspect} from 'util';
/**
* This show arguments and output of a function / a method
*
* @param {Function} thisArg
* @param {Function} func
*/
export function spy<T, A extends any[], R, F extends (this: T, ...args: A) => R>(thisArg: T, func: F): F {
return function() {
View exportVar.js
function exportVar(varToExport, filename) {
if (varToExport === undefined) { throw new Error('undefined var'); }
if (!filename) {
filename = 'exportedVar.json';
}
const fileBlob = new File([JSON.stringify(varToExport)], filename);
const dowloader = document.createElement('a');
dowloader.setAttribute('download', filename);
const url = URL.createObjectURL(fileBlob);
@PCouaillier
PCouaillier / get enum.sql
Last active Jul 15, 2019
Postgresql get enum
View get enum.sql
-- Fetch enum values
SELECT e.enumlabel
FROM pg_type t
INNER JOIN pg_enum e ON t.oid = e.enumtypid
WHERE t.typname = :enumtypname;
-- export enums
SELECT 'CREATE TYPE ' ||t.typname || ' AS ENUM (' || string_agg('''' || e.enumlabel || '''', ', ') || ');' AS sql
You can’t perform that action at this time.