Skip to content

Instantly share code, notes, and snippets.

View lfreneda's full-sized avatar
💙
Always deliver more than expected.

Luiz Freneda lfreneda

💙
Always deliver more than expected.
View GitHub Profile
@dmfay
dmfay / collapse.js
Last active September 6, 2017 17:56
Collapse JOIN query result sets into a hierarchical object graph
'use strict';
/**
* Collapses tabular result sets into a (hierarchical) object graph based on
* column nomenclature. Given a query that selects parent and child columns as
* parent__id, parent__val, children__id, children__val, this will return an
* array of objects in the form
*
* {id: 1, val: 'parent val', children: [{id: 11, val: 'child val'}]}
*
@neotreat
neotreat / http-security-headers-lambda-cloudfront.js
Last active August 28, 2018 22:58
Add HTTP Security Headers to Cloudfront with Lambda@Edge.
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
// Add security headers
const securityHeaders = [
[{
@louischatriot
louischatriot / nodejs-app.conf
Created August 18, 2012 07:47
Upstart script to launch a nodejs application as a service
description "Upstart script to run a nodejs app as a service"
author "Louis Chatriot"
env NODE_BIN=/usr/local/bin/node
env APP_DIR=/path/to/app/dir
env SCRIPT_FILE="scriptfile.js" # Entry point for the nodejs app
env LOG_FILE=/path/to/logfile.log
env RUN_AS="anyuser" # Upstart can only be run nicely as root, need to drop privileges
env SERVER_ENV="anything" # Usual apps can be run in different environments (development, test, production ...)
# I typically use the environment variable NODE_ENV (see below)
@enricop89
enricop89 / cloudformation-role.json
Created September 27, 2019 13:59
Serverless IAM Permission
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"lambda:CreateFunction",
"lambda:ListVersionsByFunction",
"dynamodb:DeleteItem",
@leommoore
leommoore / ionic_publish_android_app.md
Last active June 8, 2021 10:46
Ionic Publish Android App

#Ionic Publish Android App

This is the process to publish an ionic android app.

  1. Make sure you set/increment the version number in config.xml ie 0.0.3.

  2. Make sure the android platform has been added

@ippeiukai
ippeiukai / cron.conf
Last active July 31, 2021 21:00
Running cron in AWS ElasticBeanstalk web tier.
files:
"/tmp/crontab":
mode: "000777"
owner: 'ec2-user'
group: 'ec2-user'
content: |
30 02 * * * sudo /usr/sbin/execute-in-eb-node-app 'node bin/is-eb-master.js' && sudo /usr/sbin/execute-in-eb-node-app 'npm run daily-maintenance'
encoding: plain
container_commands:
01-copy_eb_bin:
/*
* © 2016 - Julián Acosta
* License: CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)
*
* Print your own logo in developer tools!
*
* Step 1: Convert your logo to ASCII text here: http://picascii.com (I used color output)
* Note: Is possible that you'll have to resize your photo in order to retain aspect ratio
* Step 2: Remove the <pre></pre> tag that is surrounding the generated code, replace with "[" and "]"
* Step 3: Run the following regexes (*DON'T ALTER THE ORDER*) in order to convert to JSON (Works in PHPStorm and Sublime Text 2):
@listochkin
listochkin / javascript-static-analysis-tools.md
Created August 16, 2013 13:52
JavaScript Static Analysis Tools

JavaScript Static Analysis Tools

Most people are familiar with these three tools:

  1. [JSHint][1]
  2. [JSLint][2]
  3. [Google Closure Linter][3]

The first one is more popular among developers because it is style-agnostic. The other two enforce rules of [Crockford Style][4] and [Google Code Style][5] respectively.

// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@mplatts
mplatts / 0firebase_functions_cheatsheet.js
Last active October 31, 2023 22:15
Firebase functions cheatsheet
// Core
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const db = admin.database();
admin.auth().createUser({
uid: uid,
displayName: displayName,
photoURL: photoURL