Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
void main() {
int* vet = NULL;
int i = 0;
int soma = 0;
vet = (int*) malloc (1 * sizeof(int));
const mockFetch = url => new Promise(
res => setTimeout(
x => res(`url:${url} mockFetched`)
, 300
)
)
var arr = ["a", "e", "i", "o", "u"]
const serial_____Gen = fn => async function* serial (arr) {
let i = 0
self.addEventListener('install', console.dir)
// https://developer.mozilla.org/en-US/docs/Web/API/Clients/claim
self.addEventListener('activate', e => {
console.dir(e)
e.waitUntil(clients.claim())
})
// https://bugs.chromium.org/p/chromium/issues/detail?id=823392
var alturas = []
var nomes = []
var menor = 0
var i
for (i = 0; i < 3; i++) {
nomes.push(prompt("nome da " + (i + 1) + "º pessoa"))
alturas.push(prompt("qual a altuda da " + nomes[i] + "?"))
document.write("<p>" + nomes[i] + " tem " + alturas[i] + "cm de altura.</p>")
if (alturas[i] < alturas[menor]) {
var e = [
[["0a"],["0e"],["0i"],["0o"],["0u"]],
[["1a"],["1e"],["1i"],["1o"],["1u"]],
[["2a"],["2e"],["2i"],["2o"],["2u"]],
[["3a"],["3e"],["3i"],["3o"],["3u"]],
[["4a"],["4e"],["4i"],["4o"],["4u"]]
]
const yZip = e.reduce((a, b, i) => {
lst = a.slice(-1)[0]
const multiFilter = arr => filters => Object.entries(filters).reduce(
(a, b) => a.filter(
e => e[b[0]] === b[1]
), arr)
var filtros = {
"at1": 1,
"at2": "dois"
}
@itacirgabral
itacirgabral / folder2csv.js
Created August 7, 2018 03:17
generate csv with hash ,path, name from directory
const fs = require('fs')
const crypto = require('crypto')
const path2hash = p => crypto.createHash('sha256').update(p).digest('base64')
const basedir = process.argv.length > 2 ? process.argv[2] : process.env.PWD
const printout = x => process.stdout.write(x)
let csv = '\"hash\"\t\"path\"\t\"name\"'
const reduce = iterable => function* reducerable (fn, s0) {
let acc = s0
for (const i of iterable) {
yield acc = fn(i, acc)
}
}
export default reduce
/*
https://www.youtube.com/watch?v=k7-N8R0-KY4&list=PL0zVEGEvSaeEd9hlmCXrk5yUyqUag-n84
@Gegeg
Could you do this with reduce?
*/
const categories = [
{ id: 'a', parent: '0'},
{ id: 'b', parent: '0'},
{ id: 'c', parent: 'a'},
@itacirgabral
itacirgabral / asyncAnimationFrame.js
Last active December 22, 2022 20:39
async await generator loop for requestAnimationFrame
async function* asyncAnimationFrame () {
const h = {}
h.promise = new Promise(r => h.resolve = r)
h.flipFrame = () => {
h.resolve()
h.promise = new Promise(r => h.resolve = r)
}
try {
while (true) {
h.idAF = requestAnimationFrame(h.flipFrame)