Skip to content

Instantly share code, notes, and snippets.

View dashmug's full-sized avatar
💭
Coding, of course...

Noel Martin Llevares dashmug

💭
Coding, of course...
View GitHub Profile
apt-get install python-software-properties
add-apt-repository ppa:keithw/mosh
apt-get update && apt-get upgrade -y
apt-get install -y \
python-dev \
python3-dev \
build-essential \
git \
#
# A simple theme that displays relevant, contextual information.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
# http://i.imgur.com/nrGV6pg.png
#
@dashmug
dashmug / inner-vs-outer-functions.js
Created January 23, 2017 23:51
Which is better inner or outer functions?
const oneBigFunction = () => {
const add = (x, y) => x + y
const subtract = (x, y) => x - y
const multiply = (x, y) => x * y
const divide = (x, y) => x / y
return divide(add(multiply(8, 1), 2), subtract(3, 1))
}
// or
class InventoryObject {
/**
* @param {string} name
* @param {number} price
*/
constructor(name, price) {
this.name = name;
this.price = price;
}
// Don't
function handler(event, context) {
const s3 = new AWS.S3()
return s3.upload({}).promise()
}
// Better - Init variables outside the handler
const s3 = new AWS.S3()
// Main API Lambda
async function (event) {
let input
let context
let response
try {
// input is simply the relevant input (not the whole
// AWS Lambda event which contains lots of unnecessary data)