Skip to content

Instantly share code, notes, and snippets.

@nanom1t
nanom1t / parseTransaction.go
Created June 19, 2024 08:56 — forked from crazygit/parseTransaction.go
Parse Ethereum Transaction, Decode input data, Decode output data
package main
import (
"context"
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
@nanom1t
nanom1t / getConfirmations.js
Created December 24, 2023 18:31 — forked from dsemenovsky/getConfirmations.js
Get Ethereum transaction confirmations count
async function getConfirmations(txHash) {
try {
// Instantiate web3 with HttpProvider
const web3 = new Web3('https://rinkeby.infura.io/')
// Get transaction details
const trx = await web3.eth.getTransaction(txHash)
// Get current block number
const currentBlock = await web3.eth.getBlockNumber()
@nanom1t
nanom1t / gist:e136e3ca33a32b8ceddbfec8b562ae7f
Created August 24, 2023 18:25 — forked from ingramchen/gist:e2af352bf8b40bb88890fba4f47eccd0
ffmpeg convert gif to mp4, for best cross browser compatibility
### Full command line options
```
ffmpeg -f gif -i FOO.gif -pix_fmt yuv420p -c:v libx264 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' BAR.mp4
```
### Notie
* output mp4 is encoded with h264, support Firefox/Chrome/Safari in Windows, Mac OSX, Android, and iOS.
@nanom1t
nanom1t / mobile.video.encoding.md
Created August 24, 2023 08:34 — forked from pinge/mobile.video.encoding.md
Video and audio encoding for playback in Android and iOS devices

Video and audio encoding for playback in Android and iOS devices

This document aims to provide an easy way encode video optimized for playback in mobile devices that use the Android or the iOS operating systems.

libx264 is used for (single or two-pass) video encoding and libfdk_aac for audio encoding.

ffmpeg, libx264 and libfdk_aac settings are optimized for playback quality and compatibility on Android and iOS. There is extensive documentation and references for each of the settings used and contributions are very welcome :)

Loading variables from .env files in Ansible

Ansible has various ways of looking up data from outside sources, including plain text password files, CSV files and INI files. But it doesn't seem to have a lookup for .env files, as used in Laravel projects, also available for PHP, Ruby, Node.js, Python and others.

One option is to launch Ansible with the Ruby dotenv command line script... But that requires Ruby, which seems like overkill to me.

So here is a simpler solution that I use. It consists of:

  1. The .env file itself
  2. A small shell script that loads the .env file into environment variables - ansible-playbook.sh
@nanom1t
nanom1t / erc20.go
Created October 28, 2022 08:27 — forked from miguelmota/erc20.go
Go go-ethereum watch ERC-20 token transfer events
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package token
import (
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
@nanom1t
nanom1t / nginx.conf
Created October 25, 2022 07:31 — forked from CSRaghunandan/nginx.conf
Nginx configuration for serving mp4 videos
#user nobody;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@nanom1t
nanom1t / main.go
Created October 21, 2022 06:49 — forked from manishtpatel/main.go
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@nanom1t
nanom1t / tron_address_generate.go
Created September 5, 2022 12:33 — forked from motopig/tron_address_generate.go
tron address generate
package main
import (
"crypto/ecdsa"
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
"github.com/mr-tron/base58"
@nanom1t
nanom1t / trc20.js
Created August 9, 2022 08:05 — forked from andelf/trc20.js
Get TRC20 balance and transfer USDT tokens
const TronWeb = require('tronweb');
const HttpProvider = TronWeb.providers.HttpProvider;
const fullNode = new HttpProvider("https://api.trongrid.io");
// const fullNode = new HttpProvider("http://192.168.1.162:8090");
const solidityNode = new HttpProvider("https://api.trongrid.io");
const eventServer = new HttpProvider("https://api.trongrid.io");
const privateKey = "3481E79956D4BD95F358AC96D151C976392FC4E3FC132F78A847906DE588C145";
const tronWeb = new TronWeb(fullNode, solidityNode, eventServer, privateKey);