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

0x2bfa3a690b88f51c03ddf63e16d9ce55818ca417e6f52adb4b0ab326572bb9e3

@mariano-aguero
mariano-aguero / revert.ts
Created September 30, 2020 17:01 — forked from spalladino/revert.ts
Get the revert reason before sending an Ethereum transaction if the transaction would fail
export async function tryGetRevertReason(to: string, from: string, data: string): Promise<string | undefined> {
const provider = ethers.getDefaultProvider();
const tx = { to, from, data };
try {
await provider.estimateGas(tx);
} catch {
const value = await provider.call(tx);
return hexDataLength(value) % 32 === 4 && hexDataSlice(value, 0, 4) === '0x08c379a0'
? defaultAbiCoder.decode(['string'], hexDataSlice(value, 4))
: undefined;
@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 / 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+)/
@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

@mariano-aguero
mariano-aguero / KeystoneApiExample.md
Created January 10, 2017 18:14 — forked from JedWatson/KeystoneApiExample.md
Example of how to scaffold API endpoints for Posts in a Keystone project (based on the yo keystone example).

This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.

It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)

Gists don't let you specify full paths, so in the project structure the files would be:

routes-index.js        -->    /routes/index.js         // modified to add the api endpoints
routes-api-posts.js    -->    /routes/api/posts.js     // new file containing the Post API route controllers
@mariano-aguero
mariano-aguero / homestead_extras.sh
Created September 18, 2016 13:09 — forked from kuroski/homestead_extras.sh
Script for the installation of MSSQL in Laravel Homestead (read the comments)
#!/bin/bash
#Install Laravel Homestead (http://laravel.com/docs/5.0/homestead)
#ssh into Homestead "homestead ssh"
#Run the script using "sudo bash homestead_extras.sh"
#Leave all the default options sugested during the installation, and do not modify any files!!
apt-get update
#Additional Packages
apt-get install -y php5-ldap php5-mssql
@mariano-aguero
mariano-aguero / remove-accents.js
Created June 6, 2016 19:36 — forked from monkeymonk/remove-accents.js
AngularJS `removeAccents` filter
angular.module('utils.filters', [])
.filter('removeAccents', removeAccents);
function removeAccents() {
return function (source) {
var accent = [
/[\300-\306]/g, /[\340-\346]/g, // A, a
/[\310-\313]/g, /[\350-\353]/g, // E, e
/[\314-\317]/g, /[\354-\357]/g, // I, i
/[\322-\330]/g, /[\362-\370]/g, // O, o