Skip to content

Instantly share code, notes, and snippets.

Avatar
💙
Always deliver more than expected.

Luiz Freneda lfreneda

💙
Always deliver more than expected.
View GitHub Profile
@dmfay
dmfay / collapse.js
Last active Sep 6, 2017
Collapse JOIN query result sets into a hierarchical object graph
View collapse.js
'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'}]}
*
@leommoore
leommoore / ionic_publish_android_app.md
Last active Apr 23, 2018
Ionic Publish Android App
View ionic_publish_android_app.md

#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

@neotreat
neotreat / http-security-headers-lambda-cloudfront.js
Last active Aug 28, 2018
Add HTTP Security Headers to Cloudfront with Lambda@Edge.
View http-security-headers-lambda-cloudfront.js
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
// Add security headers
const securityHeaders = [
[{
@ippeiukai
ippeiukai / cron.conf
Last active Apr 30, 2019
Running cron in AWS ElasticBeanstalk web tier.
View cron.conf
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:
@mplatts
mplatts / 0firebase_functions_cheatsheet.js
Last active Feb 7, 2020
Firebase functions cheatsheet
View 0firebase_functions_cheatsheet.js
// 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
@louischatriot
louischatriot / nodejs-app.conf
Created Aug 18, 2012
Upstart script to launch a nodejs application as a service
View nodejs-app.conf
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)
View javascript-static-analysis-tools.md

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.

View 1-restify-server-cheatsheet.js
// 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');
@aemonge
aemonge / prepare-commit-msg
Last active Aug 3, 2020
Angular Commit Message Conventions git hook, so you got your commit prepared to with the messages they expect ;)
View prepare-commit-msg
#!/bin/bash
firstLine=`head -2 $1 | tail -1`
if [[ $firstLine == \#* ]]; then # Testing that the file starts with a comment, not yet a real commit ;)
echo '<type>(<component>): <subject>' > .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '<body>' >> .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '# types: feat, fix, docs, style, refactor, test, chore(mantean)' >> .prepare-commit-msg-temp
@mooniker
mooniker / roles_investigation.md
Last active Aug 16, 2020 — forked from facultymatt/roles_invesitgation.md
Roles and permissions system for Nodejs
View roles_investigation.md

ACL / Roles + Permissions

Virgen-ACL (virgen-acl)

  • https://github.com/djvirgen/virgen-acl
  • "Simple in-memory ACL for node.js apps. Supports arbitrary roles and resources, including role/resource detection using a simple interface. Additionally supports custom assertions for more complex rules."
  • Comments: "Simple and elegant, create your own checks. No middleware?"

Node ACL (acl) BuildStatusDependency StatusdevDependency Status

You can’t perform that action at this time.