This file contains hidden or 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
export const blank = <T>( | |
value: T, | |
): value is Extract<T, null | undefined | '' | [] | Record<string, never>> => { | |
if (value === undefined || value === null) { | |
return true | |
} | |
if (typeof value === 'boolean') { | |
return value === false | |
} |
This file contains hidden or 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
export type Either<A, B> = { result: A, error: undefined? } | { result: undefined, error: B }; | |
export const either = async <R, L>(getter: () => Promise<R>): Promise<Either<R, L>> => { | |
try { | |
return { result: await getter() }; | |
} catch (error) { | |
return { error }; | |
} | |
}; | |
This file contains hidden or 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
// new Date(Date.now() - Duration({ minutes: 5 }).toMilliseconds()) | |
// redis.set('key', Duration({ hours: 6 }).toMinutes('round'), 'value') | |
type Options = { days?: number; minutes?: number; hours?: number; seconds?: number; milliseconds?: number }; | |
const multiplies: Record<keyof Options, number> = { | |
days: 24 * 60 * 60_000, | |
hours: 60 * 60_000, | |
minutes: 60_000, | |
seconds: 1_000, |
This file contains hidden or 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 IgApiClient = require('instagram-private-api').IgApiClient; | |
const ig = new IgApiClient(); | |
// Suas credenciais (para algumas ações, inclusive buscar imagens, é obrigatório) | |
const userName = 'papalardo'; | |
const userPassword = ''; | |
// Para buscar o id do usuário acesse: https://codeofaninja.com/tools/find-instagram-user-id/ | |
const userId = '40266287952'; | |
// Gera estado - Obrigatório |
This file contains hidden or 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
class Crunker { | |
constructor({ sampleRate = 44100 } = {}) { | |
this._sampleRate = sampleRate; | |
this._context = this._createContext(); | |
} | |
_createContext() { | |
window.AudioContext = | |
window.AudioContext || | |
window.webkitAudioContext || |
This file contains hidden or 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 | |
use Carbon\CarbonPeriod; | |
// On user model | |
public function scopeBirthdayBetween($query, $dateBegin, $dateEnd) | |
{ | |
$period = CarbonPeriod::create($dateBegin, $dateEnd); | |
foreach ($period as $key => $date) { |
This file contains hidden or 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
// https://github.com/sindresorhus/is-regexp | |
const isRegex = input => Object.prototype.toString.call(input) === '[object RegExp]'; | |
// https://github.com/sindresorhus/clone-regexp | |
const cloneRegexp = (e,n={}) =>{if(!isRegexp(e))throw new TypeError("Expected a RegExp instance");const t=Object.keys({ global: 'g', ignoreCase: 'i', multiline: 'm', dotAll: 's', sticky: 'y', unicode: 'u' }).map(t=>("boolean"==typeof n[t]?n[t]:e[t])?{ global: 'g', ignoreCase: 'i', multiline: 'm', dotAll: 's', sticky: 'y', unicode: 'u' }[t]:"").join(""),a=new RegExp(n.source||e.source,t);return a.lastIndex="number"==typeof n.lastIndex?n.lastIndex:e.lastIndex,a}; | |
// https://github.com/andrewrk/node-diacritics | |
let replacementList = [{ base: ' ', chars: "\u00A0", }, { base: '0', chars: "\u07C0", }, { base: 'A', chars: "\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F", }, { base: 'AA', c |
This file contains hidden or 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 normalize = str => str.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); | |
let text = "Lorem Ipsum íís simply dummy tééxt of the printing and typesetting industry."; | |
let termSearch = 'lorem iss'; | |
text = normalize(text).toLowerCase(); | |
termSearch = normalize(termSearch).toLowerCase(); | |
multiSearchAnd: | |
(text, searchWords) => |
This file contains hidden or 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
<template> | |
<div class="callout calendar-day"> | |
<div class="grid-x align-middle align-middle"> | |
<div class="shrink cell"> | |
<h1>{{ this.momentInstance.format('DD') }}</h1> | |
</div> | |
<div class="auto cell"> | |
<h6>{{ this.momentInstance.format('[de] MMMM [de] YYYY') }}</h6> | |
<h6 class="light">{{ this.momentInstance.format('dddd[.] HH:mm:ss') }} </h6> | |
</div> |
This file contains hidden or 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
$path = './api'; | |
$filename = 'estados.json'; | |
$filePath = $path .'/'. $filename; | |
if(file_exists($filePath)) { | |
$content = json_decode(file_get_contents($filePath), true); | |
return $content; | |
} | |
$somenteEssesEstados = ['RJ', 'SP']; |
NewerOlder