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 / 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 / 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 / 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 / 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 / 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 / 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 / budda
Last active January 5, 2019 19:33
Buddha Bless
/*! =========================================================
*
* _oo0oo_
* o8888888o
* 88" . "88
* (| -_- |)
* 0\ = /0
* ___/`---'\___
* .' \| |// '.
@mariano-aguero
mariano-aguero / truncateStringInTheMiddle.js
Created January 10, 2019 17:39
Truncate address in the middle, 3 dots
const truncateStringInTheMiddle = (
str,
strLength = 50,
strPositionStart = 24,
strPositionEnd = 25
) => {
if (typeof str === 'string' && str.length > strLength) {
return `${str.substr(0, strPositionStart)}...${str.substr(
str.length - strPositionEnd,
str.length
const useAsyncDerivedValue = (value, f) => {
const [derivedValue, setDerivedValue] = useState(null)
const [debouncedValue] = useDebounce(value, 500)
useEffect(() => {
let cancelled = false
f(debouncedValue).then(result => {
if (!cancelled) setDerivedValue (result)
})
@mariano-aguero
mariano-aguero / protoletter-3.md
Last active November 3, 2023 10:22
IPFS/ENS/IPNS

IPFS

Trabajando en un proyecto de Gnosis, nos surgio a partir de un requerimiento la necesidad de alojar y servir nuestra aplicacion de una forma totalmente descentralizada.

Usando IPFS(interplanetary file system) y ENS(ethereum name service) pudimos resolver este problema.

Para recordar un poco la definicion de IPFS es un sistema de archivos distribuidos punto a punto que busca conectar todos los dispositivos informáticos con el mismo sistema de archivos , por lo cual los archivos de la aplicacion van a estar descentralizados, alojados en diferentes nodos que pueden estar siendo ejecutados en cualquier lugar del mundo.

Asi como HTTP busca los recursos basandose en la URL, IPFS usa hashes para buscar recursos en su red, por ejemplo un hash es QmbgxQP34EtizTFQ7hEZKCvysQjgpei1hM5w4d2QnrVRQj, y podemos acceder al mismo a traves de un gateway como Pinata https://gateway.pinata.cloud/ipfs/QmbgxQP34EtizTFQ7hEZKCvysQjgpei1hM5w4d2QnrVRQj , u otro gateway como [IPFS.io](https:/