Skip to content

Instantly share code, notes, and snippets.

View russiann's full-sized avatar
🎧
Focusing

Russian Rebouças russiann

🎧
Focusing
  • Digibee
  • Fortaleza, CE
View GitHub Profile
@russiann
russiann / patient.controler.js
Created March 20, 2016 16:10
Controller de Pacientes
'use strict';
var _ = require('lodash');
var Patient = require('./patient.model');
var jwt = require('../../auth/jwt');
var Hash = require('hashids');
var hashids = new Hash('666');
function handleError (res, err) {
return res.status(500).send(err);
@russiann
russiann / router.js
Created April 24, 2016 00:09
Router.js
/*!
* hash-router v1.2.3
* https://github.com/michaelsogos/Hash-Router
*
* Developed by Michael Sogos
* Copyright 2014
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
* Date: 2014-10-19
let foo = { val: 10 };
let bar = { val: 20 };
function magic(a, b) {
let first = a;
let second = b;
first.val = 30;
second.val = 10;
this.$rootScope.$on('f7:pageBeforeInit', (e, data) => {
const pageData = data.detail.pageData;
this.$F7Router.findRouteByUrl(pageData.url)
.then((route) => {
const config = route.config;
const navbar = data.detail.pageData.navbarInnerContainer;
const $scope = this.$rootScope.$new();
this.$controller(config.controller, {$scope}, null, config.controllerAs);
this.$timeout(() => {
var template = angular.element(pageData.container);
class AdminLogin {
setup(app) {
this.app = app;
}
create(data) {
return new Promise((resolve, reject) => {
this.app.authenticate({
type: 'loca',
email: data.email,
@russiann
russiann / dotNotationPopulate.js
Last active July 21, 2016 02:47
dotNotationPopulate
// Ecmascript 5
function dotNotationPopulate(text) {
function findPopulate(obj, level, index) {
var index = index || 1;
if (level === index || !obj.populate) {
return obj;
}
return findPopulate(obj.populate, level, index + 1);
@russiann
russiann / promiseWithMap.js
Last active September 10, 2016 21:52
Promise.all with Map
const ids = [1,2,3,4,5,6];
const fetchData = (id) => {
httpLib.get(`http://whatever.com/api/${id}`, (res) => {
resolve(id)
});
}
Promise.all(ids.map(fecthData))
.then(responses => {
@russiann
russiann / sequencialPromises.js
Created September 10, 2016 20:33
Sequencial Promises
const promises = [promise1, promise2, promise3];
promises.reduce((previousPromise, currentPromise) => {
previousPromise.then(currentPromise)
}, Promise.resolve());
var fs = require('fs');
var http = require('http'),
httpProxy = require('http-proxy');
httpProxy.createProxyServer(
{
target:'http://localhost:8081',
ssl: {
key: fs.readFileSync('key.pem', 'utf8'),
cert: fs.readFileSync('cert.pem', 'utf8'),
@russiann
russiann / android_instructions.md
Created August 26, 2017 22:26 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"