Skip to content

Instantly share code, notes, and snippets.

const delay = (delta) =>
new Promise((resolve, reject) => {
setTimeout(() => resolve(), delta)
})
const d1 = delay(300).then(() => {
console.log('1')
return delay(300)
})
const { Telegraf } = require("telegraf");
const mk_bot = (dao, secretPath, hostname, botToken) => {
const bot = new Telegraf(botToken);
bot.telegram.setWebhook(`https://${hostname}/${secretPath}`);
bot.start(async ctx => {
ctx.reply(`Olá ${ctx.from.username}, eu sou um caixa eletrônico`)
});
// https://t.me/javascriptbrasil/284366
alert("Responda as próximas perguntas com um número"
" ou com a letra maiúscula X uma única vez")
const na = prompt("valor n(A)")
const nb = prompt("valor n(B)");
const nc = prompt("valor n(C)");
const nab = prompt("valor n(A^B)");
const nac = prompt("valor n(A^C)");
const nbc = prompt("valor n(B^C)");
var arrayzao = [
'a',
'e',
'i',
'o',
'u',
'æ'
]
const delay = x => new Promise(res => {
@itacirgabral
itacirgabral / index.js
Created April 2, 2020 22:11
svgojstest
import { s10000 } from '@iswa/svgojs'
console.log(s10000)
// npm install
// npm start
@itacirgabral
itacirgabral / cedulasMatcher.ts
Created March 31, 2020 13:19
typescript pattern matching
type Dois = { tipo: 'Dois' }
type Cinco = { tipo: 'Cinco' }
type Dez = { tipo: 'Dez' }
type Vinte = { tipo: 'Vinte' }
type Cinquenta = { tipo: 'Cinquenta' }
type Cem = { tipo: 'Cem' }
export type Cedulas = Dois | Cinco | Dez | Vinte | Cinquenta | Cem
type CedulasTipo = Cedulas['tipo']
module.exports = {
name: "produto",
actions: {
criarNovo: {
cache: false,
$$strict: true,
params: {
nome: {
type: "string",
min: 8,
@itacirgabral
itacirgabral / task.js
Last active July 21, 2019 14:17
capturing side effects in a task
const P = f => {
const LazyRight = h => ({
map: f => LazyRight(() => f(h())),
then: (f, g) => g(h()),
toString: () => `Resolve(${h})`,
})
const LazyLeft = h => ({
map: f => LazyLeft(h),
then: (f, g) => f(h()),
toString: () => `Reject(${h})`,
var vogal = ['a', 'e', 'i', 'o', 'u']
var impar = ['1', '3', '5', '7', '9']
var par = ['0', '2', '4', '6', '8']
var range = [par, vogal, impar]
function* combi(range) {
const total = range.reduce((a, b) => a * b.length, 1) - 1
let idx = range.map(arr => 0)
lasti = idx.length - 1
const partitions = arr => arr.reduce((map, obj) => Object.keys(obj).reduce((map, key) =>{
if (map.has(key)) {
map.set(key, map.get(key) + 1)
} else {
map.set(key, 1)
}
return map
}, map), new Map())
export default partitions