Skip to content

Instantly share code, notes, and snippets.

View andreafspeziale's full-sized avatar

Andrea Francesco Speziale andreafspeziale

View GitHub Profile
@andreafspeziale
andreafspeziale / design_patterns.md
Last active June 5, 2023 15:48
Some design patterns ins Python

Design patterns refresh

Creational pattern

Factory

Class Burger:
  def __init__(self, ingredients):
    self.ingredients = ingredients
@andreafspeziale
andreafspeziale / result.md
Created March 1, 2023 15:29
k6 result example
checks.........................: 100.00% ✓ 26999      ✗ 0
data_received..................: 6.0 MB  100 kB/s
data_sent......................: 1.2 MB  20 kB/s
dropped_iterations.............: 2       0.033328/s
http_req_blocked...............: avg=170.51µs min=0s     med=1µs     max=111.75ms p(90)=1µs     p(95)=1µs
http_req_connecting............: avg=43.64µs  min=0s     med=0s      max=21.82ms  p(90)=0s      p(95)=0s
http_req_duration..............: avg=18.37ms  min=6.92ms med=9.59ms  max=298.36ms p(90)=34.27ms p(95)=79.65ms
  { expected_response:true }...: avg=18.37ms  min=6.92ms med=9.59ms  max=298.36ms p(90)=34.27ms p(95)=79.65ms
http_req_failed................: 0.00%   ✓ 0          ✗ 26999
@andreafspeziale
andreafspeziale / k6.md
Created March 1, 2023 15:25
k6 script example
import { get } from "k6/http";
import { check } from "k6";

export const options = {
  scenarios: {
    constant_request_rate: {
      executor: "constant-arrival-rate",
      rate: 450,
 timeUnit: "1s",
@andreafspeziale
andreafspeziale / Kubernetes.md
Last active January 19, 2022 15:11
Some Kubernetes notes

Kubernetes

Basic Actors

| Your local machine | Kubernetes Master Node / Control Plane | Kubernets Nodes / Workers |
|--------------------|----------------------------------------|---------------------------|
| You CLI            | api-server                             | kublet                    |
|                    | etcd database                          |                           |
| | scheduler | |
const ENS = require('ethereum-ens')
const Web3 = require('web3')

const web3 = new Web3('https://mainnet.infura.io/v3/eedd5af85a6d4029934132713f40e6fd')
const ens = new ENS(web3);

(async () => {
    console.log('start')
 const address = await ens.resolver('megan.eth').addr();
@andreafspeziale
andreafspeziale / payTransactionFeeInERC20.md
Created December 18, 2019 14:40
Test case for the atomic proxy SC
/* eslint-env node, mocha */
/* global artifacts, contract, expect, web3 */
/* eslint no-underscore-dangle: 1 */
const Tx = require('ethereumjs-tx').Transaction
const ethereumUtil = require('ethereumjs-util')
const moment = require('moment')

const BigNumber = web3.utils.BN
@andreafspeziale
andreafspeziale / ETHSender.md
Created December 18, 2019 14:36
Contract for ETH transfer
pragma solidity ^0.5.10;

import "./Interfaces/IETHSender.sol";
import "./Utils/Withdrawable.sol";

import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "openzeppelin-solidity/contracts/access/roles/SignerRole.sol";

/**
@andreafspeziale
andreafspeziale / Proxy.md
Created December 18, 2019 14:33
The atomic proxy SC
pragma solidity ^0.5.10;

import "./Utils/Withdrawable.sol";

import "openzeppelin-solidity/contracts/lifecycle/Pausable.sol";
import "solidity-bytes-utils/contracts/BytesLib.sol";

/**
 * @title Proxy.
@andreafspeziale
andreafspeziale / sendETH.md
Last active December 18, 2019 11:20
The sendETH method of the ETH sender smart contract
/**
 * @dev Send ETH.
 * This function can be call only from the owner of the smart contract.
 * @param signer    The signer of the operation.
 * @param recipient The ETH recipient.
 * @param amount    The amount to be received.
 */
function sendETH(
 address signer,
@andreafspeziale
andreafspeziale / getAddressFromData.md
Created December 18, 2019 09:55
Get the sender/signer from the first argument of the transaction data field
/**
 * @dev Return the first param of the meta tx data field which must be an address.
 * E.g: in transferFrom(sender, to, amount) sender address is returned.
 * @param dataField The meta transactions data field.
 */
function getAddressFromData(bytes memory dataField)
  public
  pure
  returns (address)