Skip to content

Instantly share code, notes, and snippets.

View lucasmenendez's full-sized avatar
Reinventing the wheel

Lucas Menéndez lucasmenendez

Reinventing the wheel
View GitHub Profile
@lucasmenendez
lucasmenendez / listener.go
Created June 20, 2024 14:57
Dummy ERC20 listerner
package listener
import (
"context"
"fmt"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
@lucasmenendez
lucasmenendez / csv_to_json.py
Last active December 22, 2023 09:25
census3 ipfs census explorer
import argparse, json, csv, decimal
parser = argparse.ArgumentParser(description="Convert Etherscan holders csv to json")
parser.add_argument('-i', '--csv', help="Etherscan holders csv")
parser.add_argument('-o', '--json', help="Output json file")
args = parser.parse_args()
with open(args.csv) as f:
reader = csv.DictReader(f)
@lucasmenendez
lucasmenendez / conf.json
Last active August 20, 2023 17:18
Simple go script to send my remote IP via email
{
"from": "from@email.com",
"to": "to@email.com",
"server": {
"host": "smtp.emailserver.com",
"port": 587,
"password": "super-secret-password"
},
"extService": "public-ip-api-url",
"ip_updater": {
@lucasmenendez
lucasmenendez / main.ts
Last active May 2, 2023 20:37
[Vocdoni] Script to generate the zkAddress and circuit inputs with the correct encoding on TypeScript.
import { ZkAddress } from "./zkAddress.js";
import { CensusGenProofZk } from "./zkCensus.js";
(async function() {
// Create a ZkAddress instance from a provided string
const accountPrivateKey = "6430ab787ad5130942369901498a118fade013ebab5450efbfb6acac66d8fb88";
const electionId = "c5d2460186f760d51371516148fd334b4199052f01538553aa9a020200000000";
const censusRoot = "21f20a61be6bb9415b777367989313a2640109990d187e397fa74256361f0e11";
const zkAddr = await ZkAddress.FromString(accountPrivateKey);
@lucasmenendez
lucasmenendez / generate_datasets.py
Created August 12, 2022 19:53
Python script to generate 2 uuid's datasets with the 2.5% of records in common to test lucasmenendez/goPSI project. Usage: python generate_datasets.py <number_of_records>
import sys
import random
import uuid
numOfUUIDS = int(sys.argv[1])
def main():
numCommons = int(numOfUUIDS * 0.025)
numRandom = numOfUUIDS - numCommons
@lucasmenendez
lucasmenendez / SVGDownloader.js
Created February 27, 2020 15:50
Simple class to download SVG inline graphics directly from the browser in PNG format
class SVGDownloader {
constructor(source, filename = "download") {
this.filename = filename;
this.createCanvas(source.clientWidth, source.clientHeight);
this.createImage(source);
}
createCanvas(width, height) {
this.canvas = document.createElement("canvas");
@lucasmenendez
lucasmenendez / index.html
Created October 31, 2019 17:52
Test umd Webpack compilation
<!DOCTYPE html>
<html>
<body>
<h1>Test umd</h1>
<script type="module">
import Test from './main.js';
Test();
</script>
@lucasmenendez
lucasmenendez / deep-object-watcher.js
Last active July 14, 2018 11:15
Deep watcher over objects
if (!Object.prototype.deepWatch) {
Object.prototype.deepWatch = function(f) {
let res = {};
Object.keys(this).forEach(k => {
let src = this[k];
if (Array.isArray(src)) {
res[k] = new Proxy(src, {
set(src, i, val) {
if (i !== "length") f.call(this, src, [...src, val]);
return Reflect.set(...arguments);
const base = 5;
function *sum(num) {
let result = num + base;
num = yield(result);
return (result + num);
}
let it = sum(16);
let carsArray = [
["Ford", "Focus", 2.0],
["Seat", "Ibiza", 1.4],
["Seat", "Leon", 2.2]
];
let carsObject = carsArray.map(([ brand, model, engine ]) => { // destructuring split array in single vars
return { brand, model, engine } // compact notation save as attribute vars with same name
});
console.log(carsObject); // [ Object{brand: "Ford", model: "Focus", engine: 2.2}, ... ]