Skip to content

Instantly share code, notes, and snippets.

@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 multiFilter = arr => filters => Object.entries(filters).reduce(
(a, b) => a.filter(
e => e[b[0]] === b[1]
), arr)
var filtros = {
"at1": 1,
"at2": "dois"
}
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]
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]) {
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
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) {
#include <stdio.h>
#include <stdlib.h>
void main() {
int* vet = NULL;
int i = 0;
int soma = 0;
vet = (int*) malloc (1 * sizeof(int));
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
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
@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})`,