Skip to content

Instantly share code, notes, and snippets.

View voith's full-sized avatar
👨‍🎓
Building on top of Ethereum

Voith voith

👨‍🎓
Building on top of Ethereum
View GitHub Profile
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract ChainlinkTCAPAggregatorV3 {
struct RoundData {
uint80 roundId;
uint80 answeredInRound;
int256 answer;
uint256 startedAt;
uint256 updatedAt;
@voith
voith / redbeat_run_tasks.py
Created June 6, 2023 12:16
Script to run redbeat tasks
from collections import namedtuple
from rebate_program.celery import app # get the celery app object from your project
from redbeat.schedulers import RedBeatScheduler, acquire_distributed_beat_lock
beat = RedBeatScheduler(app)
Sender = namedtuple('sender', ['scheduler'])
sender = Sender(beat)
acquire_distributed_beat_lock(sender)
print(beat.schedule)
@voith
voith / Deploy.s.sol
Created January 3, 2023 16:20
Pre compute address while deploying contracts with foundry
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.5;
import "forge-std/Script.sol";
import "forge-std/console.sol";
contract Greeter {
string greeting;
constructor(string memory _greeting) {
@voith
voith / ComputeAddress.t.sol
Last active January 3, 2023 16:04
Pre compute contract address using foundry.
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
import "forge-std/Test.sol";
contract Greeter {
string greeting;
constructor(string memory _greeting) {
@voith
voith / TestUpgradeable.sol
Created December 20, 2022 20:59
Upgradeable Pattern in solidity using OZ
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
import "forge-std/Test.sol";
import "forge-std/console.sol";
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol";
contract Greeter is Ownable {
@voith
voith / prime_reciprocals.py
Created May 13, 2022 19:45
The Reciprocals of Primes
def repeating_digit(num: int) -> int:
"""
code inspired by
The Reciprocals of Primes - Numberphile
on youtube: https://www.youtube.com/watch?v=DmfxIhmGPP4&ab_channel=Numberphile
Parameter
num: a prime number
returns: The number of repeating digits of reciprocal of a prime number
def ones(n):
return sum(10 ** i for i in range(n))
def print_pattern(n):
for i in range(1, n+1):
num = ones(i)
print(" " * (2*(n-i)), end='')
print(f"{num} x {num} = {num * num}", end="\n\n")
@voith
voith / marketcap_share.py
Created January 24, 2022 10:02
Crypto MarketCap stats on of 24 Jan 2022
# below is the list of top 100 crypto by marketcap
# The data was fetched from coinmarketcap using the following xpath: `//td[7]`
top_100_crypto_marketcap = [
658219848892, # BTC
280749726821, # ETH
78325902003, # USDT
58926965670, # and so on...
47738008009,
34138378623,
28006007353,
@voith
voith / triangle_pattern.py
Created January 13, 2022 19:24
Triangle pattern using python
# Been a while since I made one of these.
# The last time I made one, I was in college.
def print_triangle(n: int):
for i in range(1, n + 1):
digits = len(str(n))
print((" " * (digits + 1)) * (n - i) , end="")
for j in range(i):
print(" %s" % str(j + 1).rjust(digits, "0"), end="")
for j in range(i - 1):
@voith
voith / eth_tester_pv_key.py
Created September 22, 2021 18:34
Eth-Tester Private Key Workaround
from eth_account import Account
from eth_tester.backends.pyevm.main import get_default_account_keys
acc = Account.from_key(get_default_account_keys()[0])
print(acc.key)