Skip to content

Instantly share code, notes, and snippets.

@carlosmaniero
carlosmaniero / arrow.js
Created October 24, 2017 16:52
Arrow functions is not a syntax sugar for functions
const withFunction = {
myOwnProp: 42,
myOwnFunc: function () {
return this.myOwnProp
}
}
const withArrow = {
myOwnProp: 42,
myOwnFunc: () => {
@carlosmaniero
carlosmaniero / Elm.hs
Last active October 30, 2017 13:19
Elm architecture in Haskell: A study case
data Model = Model
{ name :: String
, gender :: String
, loading :: Bool
, homeworld :: String
} deriving (Show)
data PersonResponse = PersonResponse
{ personName :: String
@carlosmaniero
carlosmaniero / updateStatus.js
Created February 19, 2019 03:51
It shows how orders without status are treated by the application: It is part of the "Agile practices on Legacy code"
const updateStatus = (order, newStatus) => {
if (order.status === undefined) {
order.status = 'ORDERED'
}
//...
}
app.post('/customers/:customerId/orders/', (req, res) => {
if (req.body.items.length === 0) {
res.status(400).end()
} else {
MongoClient.connect(url, function (err, client) {
if (err) {
console.error(err)
}
const db = client.db(dbName)
const collection = db.collection('orders')