Skip to content

Instantly share code, notes, and snippets.

View mariano-aguero's full-sized avatar
:octocat:
Focusing

Mariano Aguero mariano-aguero

:octocat:
Focusing
View GitHub Profile
@mariano-aguero
mariano-aguero / utils.js
Created November 26, 2018 13:18
toBigNumber
/**
* Converts the value passed to a BigNumber instance
* @param {*} value - A number representation
* @param {boolean} [force=true] - If set to false will return 'undefined' when value is not a number or a string
* representation of a number.
* @returns {BigNumber|undefined}
*/
export const toBigNumber = (value, force = true) => {
BigNumber.set({ DECIMAL_PLACES: 18 })
@mariano-aguero
mariano-aguero / command.txt
Last active July 6, 2018 11:28
letsencryt ssl
certbot certonly --agree-tos --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory -d example.com -d "*.example.com"
@mariano-aguero
mariano-aguero / letsencrypt_2017.md
Created April 29, 2018 20:16 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@mariano-aguero
mariano-aguero / logger.js
Last active February 28, 2018 14:00
Papertrail Winston
'use strict';
/* global __base */
let winston = require('winston'),
path = require('path'),
utils = require(__base + 'app/helpers/utils'),
util = require('util');
//winston logging for papertrail
require('winston-papertrail').Papertrail;
@mariano-aguero
mariano-aguero / message-bus.service.ts
Created November 16, 2017 18:23 — forked from GFoley83/message-bus.service.ts
Angular 2 Message Bus / PubSub ex.
import { Injectable } from "@angular/core";
import { ReplaySubject, Observable } from "rxjs/Rx";
interface Message {
channel: string;
data: any;
}
@Injectable()
export class MessageBus {
@mariano-aguero
mariano-aguero / gist:06cd906605bfcbea6a7d88f43593956f
Created October 31, 2017 17:18 — forked from elamperti/gist:3111691
RegEx para teléfonos de Argentina
/(?<=\s|:)\(?(?:(0?[1-3]\d{1,2})\)?(?:\s|-)?)?((?:\d[\d-]{5}|15[\s\d-]{7})\d+)/
@mariano-aguero
mariano-aguero / gist:cf4be684d86e843071957598eaaac922
Created October 31, 2017 17:18 — forked from elamperti/gist:3111691
RegEx para teléfonos de Argentina
/(?<=\s|:)\(?(?:(0?[1-3]\d{1,2})\)?(?:\s|-)?)?((?:\d[\d-]{5}|15[\s\d-]{7})\d+)/
0x8F08C3C24107F2dBDe78D44cB9262012166b99b0
@mariano-aguero
mariano-aguero / event_bus.js
Created September 13, 2017 12:42
Event bus
// Definition
const EventEmitter = require('events');
const emitter = new EventEmitter();
emitter.on('uncaughtException', function (err) {
console.error(err);
});
module.exports = emitter;
@mariano-aguero
mariano-aguero / better-nodejs-require-paths.md
Created January 11, 2017 16:34 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions