Skip to content

Instantly share code, notes, and snippets.

View geovanisouza92's full-sized avatar
🏠
Working from home

Geo geovanisouza92

🏠
Working from home
View GitHub Profile
@geovanisouza92
geovanisouza92 / context.js
Last active October 6, 2017 16:00
Golang net/context equivalent for JS
function background() {
const m = {}
function create(p) {
return {
withValue(prop, value) {
// Create a new "memory"
const p1 = Object.assign({}, p)
m[prop] = m[prop] || []
p1[prop] = m[prop].push(value) - 1
@geovanisouza92
geovanisouza92 / lambda-with-worker-pool.js
Last active September 14, 2017 12:35
A Lambda function that spawns workers to process data faster
const os = require('os')
const cp = require('child_process')
const Rx = require('rxjs')
// https://github.com/coopernurse/node-pool
const pool = require('generic-pool')
const MAX_WORKERS = os.cpus().length
const createWorkerPool = () => {
const factory = {
@geovanisouza92
geovanisouza92 / esnextbin.md
Created April 6, 2017 20:25
esnextbin sketch
@geovanisouza92
geovanisouza92 / db.json
Created December 3, 2016 17:29
Produtos
{
"products": [
{
"id": "1",
"name": "Ohrensessel Josslyn",
"price": 499.99,
"currency": "EUR",
"image": "images/01.jpg",
"url": "http://www.home24.de/m-rteens/mit-hocker-917965"
},
@geovanisouza92
geovanisouza92 / esnextbin.md
Created December 2, 2016 10:24
esnextbin sketch
@geovanisouza92
geovanisouza92 / esnextbin.md
Last active November 25, 2016 18:59
esnextbin sketch
@geovanisouza92
geovanisouza92 / Readme.md
Created November 25, 2016 12:28
Lists generation problem
  • There are two kinds of items: A and B
  • Each item B could be replaced by A' and A"
  • Given a list with items A and B (the order is not important), generate the most quantity of target-lists only with items A, A' and A" below the time limit t
  • Each target-list is sorted after generation, so there isn't necessary to generate each permutation (only replacements are sufficient)
  • The source list have an arbitrary size
  • The number of unique possibilities is where n is the number of B items
  • A items doesn't need to be modified, so it could be reused

Given the source list:

  • Há dois tipos de itens: A e B
  • Os items do tipo B podem ser convertidos para A' e A"
  • Dado uma lista com itens A e B (ordem dos itens não é relevante), é necessário gerar o maior número possível de listas-alvo somente com A, A' e A" (substituindo o itens B em A' ou A") dentro do tempo limite t
  • O número de possibilidades únicas é on n é o número de itens B
  • Os itens A não precisam ser modificados, podendo ser reutilizados como lista-alvo inicial (concatenado-se as substituições de B)

Dado a lista inicial (pode ter tamanho arbitrário):

[A, A, B, A, B]

@geovanisouza92
geovanisouza92 / app.js
Created October 18, 2016 23:00
Shared state between components
import {div, input} from '@cycle/dom'
import isolate from '@cycle/isolate'
import xs from 'xstream'
import {assoc} from 'ramda'
function Form (sources) {
const billingAddressChange$ = sources.DOM
.select('.billing-address').events('input')
.map(ev => ev.target.value)
.startWith('')
@geovanisouza92
geovanisouza92 / flavors.json
Last active October 15, 2016 21:40
create-cycle-app's flavors
[
{
"name": "ES6 (babel) + Browserify",
"value": "cycle-scripts-es-browserify"
},
{
"name": "TypeScript + Browserify",
"value": "cycle-scripts-ts-browserify"
},
{