Skip to content

Instantly share code, notes, and snippets.

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

Noel 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()
#
# A simple theme that displays relevant, contextual information.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Screenshots:
# http://i.imgur.com/nrGV6pg.png
#
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
@dashmug
dashmug / .inputrc
Created August 27, 2013 17:48
.inputrc for improved working on bash I forgot where I got this.
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
set show-all-if-ambiguous on
set completion-ignore-case on
@dashmug
dashmug / .bash_profile
Created August 27, 2013 17:46
My Mac OS X `.bash_profile`.
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
export PATH=/usr/local/sbin:$PATH
#export PS1="\W \$ "
PS1="\[\e[1;96m\]\u@\h:\[\e[1;93m\] \w \[\e[1;96m\]\@\n\$\[\e[0m\] "
export LANG="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
@dashmug
dashmug / remove_duplicates.sql
Created June 24, 2013 20:07
To remove duplicates in a MySQL table.
ALTER IGNORE TABLE table ORDER BY address ASC ADD UNIQUE KEY 'address' (`address`);
@dashmug
dashmug / search_and_replace.pl
Created June 24, 2013 19:33
Search and replace text in a directory
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt
@dashmug
dashmug / combinations.php
Created June 17, 2013 20:58
A package that returns all the combinations and permutations, without repitition, of a given set and subset size. Associative arrays are preserved. Download from: http://pear.php.net/package/Math_Combinatorics/download
require_once 'Math/Combinatorics.php';
$combinatorics = new Math_Combinatorics;
var_dump($combinatorics->combinations(array(
'one' => 'a',
'two' => 'b',
'three' => 'c',
'four' => 'd',
), 3));