Skip to content

Instantly share code, notes, and snippets.

View t0mm4rx's full-sized avatar
📈

Tom Marx t0mm4rx

📈
View GitHub Profile
@t0mm4rx
t0mm4rx / capsa_demo.py
Created September 9, 2022 13:16
Example on how to swap CAPSA tokens automatically
"""
This is an example how to swap CAPSA tokens for USDC automatically.
The flow is simple:
1. allow USDC to be spent by our contract
2. call buyCAPSA to exchenge USDC for CAPSA
3. call sellCAPSA to exchange CASPA for USDC
Note:
You need to multiply by 10 ** 6 both USDC allowance and CAPSA operations.
@t0mm4rx
t0mm4rx / btc-bba.csv
Created September 7, 2022 08:17
Tick-by-tick data of BTC during the flash crash of 07/09/2022.
We can't make this file beautiful and searchable because it's too large.
,timestamp,bb,ba
0,1662482691.43856,19767.0,19770.0
1,1662482691.484459,19770.0,19773.0
2,1662482691.6621041,19773.0,19774.0
3,1662482691.710656,19773.0,19774.0
4,1662482691.7550368,19773.0,19774.0
5,1662482691.769418,19773.0,19774.0
6,1662482691.8808682,19773.0,19774.0
7,1662482691.882221,19773.0,19774.0
8,1662482691.899898,19773.0,19774.0
@t0mm4rx
t0mm4rx / impermax.py
Created January 20, 2022 11:02
Python script to fetch Impermax.finance position total collateral and debt
"""Impermax related functions.
imxc = Impermax collateral token, given in exchange of the actual LP pair.
slp = staked LP token.
"""
from providers import polygon
from chain_data import get_lp_pair_holdings, get_token_decimals
import json
imxc_abi = json.load(open("./abis/imxc.json", "rb"))
id indexChannel rate date
28145 .ETHFR8H 0.01 2021-07-10 08:00:00
28106 .ETHFR8H 0.01 2021-07-10 00:00:00
28068 .ETHFR8H 0.01 2021-07-09 16:00:00
28030 .ETHFR8H 0.01 2021-07-09 08:00:00
27990 .ETHFR8H 0.01 2021-07-09 00:00:00
27915 .ETHFR8H 0.01 2021-07-08 16:00:00
27873 .ETHFR8H 0.01 2021-07-08 08:00:00
27821 .ETHFR8H 0.01 2021-07-08 00:00:00
27783 .ETHFR8H 0.01 2021-07-07 16:00:00
id indexChannel date rate
28144 .BTCFR8H 2021-07-10 08:00:00 -0.004272
28105 .BTCFR8H 2021-07-10 00:00:00 0.01
28067 .BTCFR8H 2021-07-09 16:00:00 0.01
28029 .BTCFR8H 2021-07-09 08:00:00 0.01
27989 .BTCFR8H 2021-07-09 00:00:00 0.000568
27914 .BTCFR8H 2021-07-08 16:00:00 -0.008789
27872 .BTCFR8H 2021-07-08 08:00:00 0.01
27820 .BTCFR8H 2021-07-08 00:00:00 0.01
27782 .BTCFR8H 2021-07-07 16:00:00 0.01
@t0mm4rx
t0mm4rx / deploy_functions.py
Last active July 6, 2021 16:19
Automatically deploy appwrite Python functions
"""Deploy API functions to Appwrite.
This script will loop though your ./api folder, get all .py files, then:
- check if this function version has been deployed
- if not, will create or update the function
Functions name will be the name of the file, without ".py".
By default functions have no execution permission, you need to change
it manually.
@t0mm4rx
t0mm4rx / defi_2.py
Created June 4, 2019 08:33
Defi 2 - ribt.fr
"""
Bon la c'est simple et sale j'utilise tesseract pour faire du OCR.
"""
import requests
import json
import shutil
try:
from PIL import Image
except ImportError:
@t0mm4rx
t0mm4rx / defi_6.py
Created June 4, 2019 08:30
Défi 6 ribt.fr
"""
Petite explication :
je sais que tes messages sont des Lorem ipsum, donc du latin.
Ma stratégie est de me constituer un dictionnaire de mots latins, puis de déchiffrer le texte
avec chacun des mots.
Pour savoir si le texte a correctement été déchiffré, je caclcul un score qui correspond au
nombre de mots qui sont dans mon dictionnaire. Je récupère le texte avec le plus grand score.
Dernière étape, je met les majuscules la ou elles sont dans le texte d'origine.
"""
$count = 0;
$targetY = 5;
for ($i = 0; $i < count($inputs); $i++) {
$first = $inputs[$i];
$second = $inputs[$i + 1];
if ($targetY >= $first && $targetY <= $second) {
$count++;
}
}