Skip to content

Instantly share code, notes, and snippets.

@PCouaillier
PCouaillier / fish_prompt.fish
Last active Apr 24, 2021
fish prompt base on my-aws to a look like zsh candy shell
View fish_prompt.fish
function fish_prompt --description 'Write out the prompt'
# Cache exit status
set -l last_status $status
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_user
if test (id -u) -eq 0
set -g __fish_user '#'
else
set -g __fish_user '&'
View i3 - config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
View monstercat_current.js
({name: player.currentItem.label + '.mpga', source: player.currentItem.source})
View cleanUtf8Regex.js
const cleanUtf8Regex = str => {
let i = 0;
let res = '';
let code;
while(code = str.charCodeAt(i)) {
res += 0x7E < code && code <= 0xFF ? `\\x{${code.toString(16)}}` : str[i];
i += 1;
}
return res;
}
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 const 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);