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
// 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)
// 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()
class InventoryObject {
/**
* @param {string} name
* @param {number} price
*/
constructor(name, price) {
this.name = name;
this.price = price;
}
@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
#
# A simple theme that displays relevant, contextual information.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
# http://i.imgur.com/nrGV6pg.png
#
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 \
@dashmug
dashmug / update_toolset.sh
Last active August 29, 2015 14:02
a simple script I use for updating my Homebrew, composer, pip, npm, and gem packages
set -e
set -x
sudo aptitude update
sudo aptitude upgrade -y
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f2)
do
sudo npm -g install "$package"
@dashmug
dashmug / dashmug.zsh-theme
Created June 2, 2014 20:58
My custom oh-my-zsh theme. Place inside custom.
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%} git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}⚡"
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_PREFIX="%{$fg[green]%} hg:"
ZSH_THEME_HG_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_HG_PROMPT_DIRTY=" %{$fg[red]%}⚡"
ZSH_THEME_HG_PROMPT_CLEAN=""
@dashmug
dashmug / osx_tools.md
Last active August 29, 2015 14:02
Essential tools I need when working on OS X

Essential Apps

  • SublimeText
  • Skype
  • Chrome
  • Firefox
  • Alfred
  • iTerm
  • Clipmenu
  • SizeUp
@dashmug
dashmug / .nanorc
Created June 1, 2014 06:59
Nano configuration
set autoindent
set const
set fill 80
unset nonewlines
set smooth
set tabsize 4
set tabstospaces
set smarthome
include ~/.nano/apacheconf.nanorc