Skip to content

Instantly share code, notes, and snippets.

View brunoguerra's full-sized avatar
🌌
Growing online businesses 🥇

Bruno Guerra brunoguerra

🌌
Growing online businesses 🥇
  • Blumenau, SC
View GitHub Profile
@brunoguerra
brunoguerra / firebase.js
Created September 16, 2016 02:01
Learning firebase
import firebase from 'firebase';
firebase.initializeApp({
serviceAccount: `${__dirname}/../../server/config/firebase.json`,
databaseURL: 'https://pontuali-dev.firebaseio.com/',
});
const db = firebase.database();
const dataRef = db.ref('/data');
dataRef.on('child_added', (snapshot) => {
console.log('addedded, child', snapshot.val());
});
@brunoguerra
brunoguerra / backend.js
Last active September 12, 2016 05:56
Angular 1.5 :~
import angular from 'angular';
// fn
const normaliz = ( entities ) => ( {
entities: entities.reduce( (r, e) => Object.assign( r, { [e._id]: e } ), {} ),
ids: entities.map( d => d._id )
} );
const storeItem = ( item ) => ( value ) =>
@brunoguerra
brunoguerra / build-heroku
Created September 9, 2016 23:24
nodejs build heroku testinho
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): >=4.2.0
engines.npm (package.json): ^3.0.0
@brunoguerra
brunoguerra / android-ubuntu-16-requirements
Created August 28, 2016 16:55
Android Ubuntu 16 requirements
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1
@brunoguerra
brunoguerra / elasticsearch.md
Created December 30, 2015 06:51 — forked from nicolashery/elasticsearch.md
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
input {
tcp {
'port' => "9998"
codec => json
}
udp {
'port' => "9999"
codec => json
}
@brunoguerra
brunoguerra / pm2.js
Created November 30, 2015 21:52
PM2 Configuration
var pmx = require('pmx').init({
http : true,
network : true,
ports : true
});
var pm2 = require('pm2');
var path = require('path');
var MACHINE_NAME = process.env.APP_NAME;
@brunoguerra
brunoguerra / simulate koa controller
Created October 30, 2015 13:35
simulate koa controller
// /modules/console/utils
import co from 'co';
import { returnAsPromise } from '../../lib/commons';
export default {
koaReq: (params, next) => {
console.log('koaReq: starting');
function* chain(next) {
this.params = params;

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var paths = {