Skip to content

Instantly share code, notes, and snippets.

const dificuldadeCasas = [
50,
55,
60,
70,
75,
80,
85,
90,
95,
function liga(x,y){
x.proximos.push(y)
y.proximos.push(x)
}
function geraNo(id, tamanho){
return {
id,
tamanho,
caminho: '',
const hadChanged = list => obj => Object.keys(list)
.filter(k => obj[k] !== list[k])
.reduce((a, b) => {
list[b] = obj[b]
return a || !!b
}, false)
export default hadChanged
/*
var list = { a: 'a', b: 'b'}
const cavaleiro = [1.5, 1.4, 1.3, 1.2, 1.1]
const casas = [
[cavaleiro[0]],
[cavaleiro[1]],
[cavaleiro[2]],
[cavaleiro[3]],
[cavaleiro[4]],
[cavaleiro[0]],
[cavaleiro[1]],
[cavaleiro[2]],
const proto = Object.create(Array.prototype)
Object.defineProperty(proto, 'sew', {
value: function sew (a) {
(a || a === 0) && this.push(a)
return this
}
})
function extendArray (a) {
funtion download (obj) {
const a = document.createElement('a')
document.body.appendChild(a)
a.style = 'display: none'
const str = JSON.stringify(obj, null, 4)
const blob = new window.Blob([str], {type: 'application/json'})
const url = window.URL.createObjectURL(blob)
a.href = url
a.download = 'obj.json'
function serial(obj, i, farr) {
if (i === farr.length) {
console.log(obj)
} else {
farr[i](obj, e => {
serial(e, i + 1, farr)
})
}
}
const reduce = iterable => function* reducerable (fn, s0) {
let acc = s0
for (const i of iterable) {
yield acc = fn(i, acc)
}
}
export default reduce
@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\"'
/*
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'},