Skip to content

Instantly share code, notes, and snippets.

View ptisserand's full-sized avatar
💭
Learning Rust

ptisserand

💭
Learning Rust
View GitHub Profile
@ptisserand
ptisserand / Scarb.toml
Created July 22, 2023 18:35
Contract declaration error
[package]
name = "splitter"
version = "0.1.0"
[dependencies]
starknet = ">=2.0.1"
[[target.starknet-contract]]
sierra = true
casm = true
@ptisserand
ptisserand / erc.sierra.dart
Last active July 15, 2023 07:28
Dart code generated from Cairo 1 contract
import 'package:starknet/starknet.dart';
import 'erc.sierra.g.dart';
void main() async {
Felt contractAddress = Felt.fromHexString(
"0x53813135446812b36f67e5b363813df086d88544ce17c742376082b8e997e29");
final account = account0;
final erc20 = Erc(account: account, address: contractAddress);
@ptisserand
ptisserand / Dockerfile
Last active January 6, 2023 14:56
Dockerfile for cairo environment development
FROM ubuntu:22.04
LABEL org.opencontainers.image.authors="p.tisserand@gmail.com"
ARG USER=rob
ARG USER_ID=1000
ARG GROUP=starknet
ARG GROUP_ID=1000
# Create new user
RUN \
@ptisserand
ptisserand / str_to_felt
Last active July 21, 2022 06:54
starknet edu utils
#!/bin/bash
#
# Copy in the same directory as utils.py
# Set executable rights:
# $ chmod uog+x ./str_to_felt
# Run:
# $ ./str_to_felt HENRI
# 310400406089
#
@ptisserand
ptisserand / main.mo
Last active June 10, 2022 20:45
blog post
import HashMap "mo:base/HashMap";
import Iter "mo:base/Iter";
import Nat "mo:base/Nat";
import Hash "mo:base/Hash";
import Principal "mo:base/Principal";
import Result "mo:base/Result";
import Text "mo:base/Text";
import Time "mo:base/Time";
import TrieMap "mo:base/TrieMap";
import TrieSet "mo:base/TrieSet";
@ptisserand
ptisserand / extract_private.py
Created May 2, 2022 18:16
Extract private key from Terra Station Wallet export
#!/usr/bin/env python
#
# Extract private key from Terra Station Wallet exported private key
#
# python ./extract_private.py "DATA FROM 'Export Wallet' - 'Private Key'" "your password"
#
# Your private key base64 encoded will be print on stdout
#
import sys
@ptisserand
ptisserand / getit.py
Last active May 5, 2021 08:57
Python code to retrieve gateway IP
def get_default_gateway():
try:
hip = None
with open("/proc/self/net/route") as routes:
for line in routes:
parts = line.split('\t')
if '00000000' == parts[1]:
hip = parts[2]
if hip is not None and len(hip) == 8:
@ptisserand
ptisserand / add_timestamp.sh
Created April 10, 2020 08:22
Add timestamp with ffmpeg
ffmpeg -i INPUT.mp4 -vf "drawtext=fontfile=/usr/share/fonts/TTF/Roboto-Medium.ttf:fontsize=22:fontcolor=yellow:box=1:boxcolor=black:x=(W-tw)/2:y=H-th-10:text='%{pts\:hms} %{frame_num}'" OUTPUT.mp4
@ptisserand
ptisserand / Vagrantfile
Created April 8, 2020 11:46
Using HTTP proxy for vagrant
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://192.168.0.110:3128/"
# config.proxy.https = "http://192.168.0.2:3128/"
# config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
end
# ... rest of the configurations
end
@ptisserand
ptisserand / start-docker-cache.bash
Created March 26, 2020 16:33
Start a proxy to speed up docker build
#!/bin/bash
CACHE_DIR=/srv/squid/cache
echo "Starting squid container"
docker run --rm --net host -v ${CACHE_DIR}:/var/cache/squid3 -d jpetazzo/squid-in-a-can
echo "Setup iptables"
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to 3129 -w