Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Coding

Miguel Mota miguelmota

:octocat:
Coding
View GitHub Profile
@miguelmota
miguelmota / spellcheck_files.sh
Created Jan 23, 2021
Bash spellcheck list of files using aspell
View spellcheck_files.sh
for f in *.txt ; do echo $f ; aspell list < $f | sort | uniq -c ; done
@miguelmota
miguelmota / estimate_gas.go
Created Jan 23, 2021
Go estimate ethereum transaction gas limit and add 30% percent
View estimate_gas.go
package main
import (
"context"
"fmt"
"log"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
@miguelmota
miguelmota / external_link_arrow.txt
Created Jan 20, 2021
Unicode external link arrow symbol (closest thing to it)
@miguelmota
miguelmota / nginx.conf
Last active Jan 19, 2021
NGINX rewrite with no redirect by using proxy_pass and use custom path
View nginx.conf
if ($http_user_agent ~* 'curl') {
rewrite ^(.*)$ /curl_rewrite/$1;
}
location /curl_rewrite/ {
rewrite ^/curl_rewrite/(.*)$ /some-path/$1?$query_string break;
proxy_pass http://localhost:8080;
}
@miguelmota
miguelmota / nginx.conf
Created Jan 19, 2021
NGINX rewrite based on user agent example (eg. curl, wget)
View nginx.conf
if ($http_user_agent ~* 'curl|wget') {
rewrite ^ http://localhost:8080 permanent;
}
@miguelmota
miguelmota / wget_stdout.sh
Created Jan 19, 2021
wget print response to stdout like cURL
View wget_stdout.sh
wget -qO- https://example.com
@miguelmota
miguelmota / decode_example.js
Last active Jan 11, 2021
JavaScript decode RLP encoded Ethereum transaction (raw transaction) examples
View decode_example.js
// RLP encoded transaction
const rawTxHex = '0xed8205fc843b9aca00825208944592d8f8d7b001e72cb26a73e4fa1806a51ac79d88016345785d8a000080808080'
// using rlp package to decode values
const rlp = require('rlp')
const decoded = rlp.decode(rawTxHex)
console.log(decoded)
/*
[ <Buffer 05 fc>,
<Buffer 3b 9a ca 00>,
@miguelmota
miguelmota / example.go
Last active Jan 11, 2021
Go encode unsigned transaction, decode transaction, sign and broadcast examples
View example.go
package main
import (
"context"
"encoding/hex"
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
@miguelmota
miguelmota / docker-compose.yml
Last active Jan 8, 2021
Docker log to AWS CloudWatch using awslogs logging driver
View docker-compose.yml
services:
image: postgres
web:
logging:
driver: awslogs
options:
awslogs-region: us-east-1
awslogs-group: MyGroup
awslogs-create-group: "true"
@miguelmota
miguelmota / submodules_example.sh
Last active Jan 4, 2021
git add submodules to repo and fetch submodules when cloning
View submodules_example.sh
# add submodule to `monorepo/packages/mypackage`
cd monorepo/packages
git submodule add git@github.com:myorg/mypackage.git
# fresh clone of monorepo and fetch submodules
git clone --recurse-submodules --remote-submodules git@github.com:myorg/monorepo.git
# if already cloned, then fetch submodules
git submodule update --init --recursive