Skip to content

Instantly share code, notes, and snippets.

View ydm's full-sized avatar

Йордан Миладинов ydm

  • Sofia, Bulgaria
View GitHub Profile
| File                                 | Class                                 | Prefix                    | Base? |
|--------------------------------------+---------------------------------------+---------------------------+-------|
| src/ape/api/config.py                | ApeConfig(BaseSettings)               | APE_API_                  | no    |
| src/ape/api/config.py                | DeploymentConfig(PluginConfig)        | APE_API_                  | no    |
| src/ape/api/config.py                | PluginConfig(BaseSettings)            | APE_API_                  | yes   |
| src/ape_cache/config.py              | CacheConfig(PluginConfig)             | APE_CACHE_                | no    |
| src/ape_compile/config.py            | Config(PluginConfig)                  | APE_COMPILE_              | no    |
| src/ape_console/config.py            | ConsoleConfig(PluginConfig)           | APE_CONSOLE_              | no    |
| src/ape_ethereum/ecosystem.py        | BaseEthereumConfig(PluginConfig)      | APE
@ydm
ydm / divide.ts
Created January 7, 2025 02:27
divide :: biging -> bigint -> number
function divide(a: bigint, b: bigint): number {
const PRECISION: bigint = 18n;
const EXP: bigint = 10n**PRECISION;
if (b === 0n) {
return 0;
}
const integer: bigint = a/b;
const remainder: bigint = a%b;
const fractional: bigint = (remainder * EXP) / b;
const result: bigint = integer * EXP + fractional;
```
$ python
Python 3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print(int(1e6) * int(1e18))
1000000000000000000000000
>>> print(int(1e6 * 1e18))
999999999999999983222784
>>>
```
@ydm
ydm / Test.sol.md
Last active December 17, 2024 01:10
DIagram of forge-std/Test.sol
---
title: github.com/ydm/mermaider
---
classDiagram
class `CommonBase` {
    <<abstract>>
    -address VM_ADDRESS
    -address CONSOLE
    -address CREATE2_FACTORY
@ydm
ydm / secom.py
Last active October 22, 2024 21:21
Secure communication using asymmetric cryptography
#!/usr/bin/env python
from pathlib import Path
from base64 import b64encode, b64decode
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.serialization.ssh import (
SSHPrivateKeyTypes,
@ydm
ydm / slots.go
Created August 6, 2024 08:32
A clever way to limit the number of goroutine workers.
package main
import (
"context"
"fmt"
"sync"
"time"
)
func f(ctx context.Context, xs []int) {
@ydm
ydm / .tmux.conf
Created August 4, 2024 01:30
~/.tmux.conf
unbind C-b
set-option -g prefix C-\\
bind-key C-\\ send-prefix
@ydm
ydm / magic.sh
Last active January 16, 2025 12:28
Multiprocessing with Bash
#!/bin/bash
# URL prefix
url_prefix='http://testing.mainnet.beacon-api.nimbus.team/eth/v2/beacon/blocks'
# Range of numbers to loop over
start=6209538
end=9453725
# Number of workers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ydm
ydm / gist:0c9e2fe20fbd41ffe7ffd0cd9e3830bf
Last active January 16, 2025 12:32
If I want to play Warcraft 3 ...
xbindkeys
openrazer-daemon
polychromatic
~/.xbindkeysrc
```
"xdotool key KP_1"
b:9