Skip to content

Instantly share code, notes, and snippets.

View MarcoWorms's full-sized avatar
:shipit:
undefined

Marco Guaspari Worms MarcoWorms

:shipit:
undefined
View GitHub Profile
@MarcoWorms
MarcoWorms / la-ramda.js
Created June 29, 2017 03:51 — forked from mrosata/la-ramda.js
A subset of the Ramda library written using arrow functions, "lamda-ramda". The purpose of this is fun and to use in environments where importing 3rd party libs isn't allowed. Feel free to add to this.
const R = new LaRamda()
/**
* A subset of custom implementations of functions from
* the Ramda library. (all in Lamda form)
* - thanks to @xgrommx for uniq, intersection, where, evolve,
* applySpec, defaultTo, both, either, cond, zipWith
*/
function LaRamda () {
const I = x => x

Imutabilide

Marco Guaspari Worms - Pagar.me & Catnigiri

// Jupyter notebook é massa
{
 var obj = {
@MarcoWorms
MarcoWorms / explode-docker
Last active October 31, 2017 19:35
Alias to explode docker on fish
alias fuck-docker docker-compose down --remove-orphans; and docker rm $(docker ps -a -q) -f; and docker containers prune; and docker system prune
@MarcoWorms
MarcoWorms / a-deck.js
Created April 5, 2018 06:04
Isolating the impurity of randomness in card games - Examples
const thisIsADeck = [
'this is a card',
3464562456, // this is also a card,
{ attack: `i'm a property of a card!` }, // another card
[
`I'm an element inside a card.`,
`I'm not a card because I'm not in the root level`,
`The card in this case is the whole array containing these phrases`,
],
]
const thisIsADeck = [
'this is a card',
3464562456, // this is also a card,
{ attack: `i'm a property of a card!` }, // another card
[
`I'm an element inside a card.`,
`I'm not a card because I'm not in the root level`,
`The card in this case is the whole array containing these phrases`,
],
]
const deck = [
{ name: 'Fireball', damage: 6, cost: 2 },
{ name: 'Thunderstorm', damage: 10, cost: 3 },
{ name: 'Ice Razors', damage: 30, cost: 7 },
]
const { without } = require('ramda')
const card = deck[0] // 1. Card
const newDeck = without([card], deck) // 2. Remaining deck
const without = (element, array) => array.filter(e => e !== element)
// Watch out because on this one the "element" is not an array like the Ramda function.
const draw = (cardPicker, deck) => {
// 1. We want to know what card we drew
const card = cardPicker(deck)
// 2. We want the new deck without the drawn card
const newDeck = without(card, deck)
return { card, newDeck }
}