Skip to content

Instantly share code, notes, and snippets.

@sbarratt
sbarratt / wormhole.py
Last active April 6, 2024 03:28
Wormhole bulk eligibility checker
import argparse
import requests
def get_allocation(address, blockchain):
id = {
"sol": 1,
"eth": 2,
"sui": 21,
"aptos": 22,
"inj": 19,
@sbarratt
sbarratt / rpc_multiplexer.py
Created December 12, 2022 22:21
RPC Multiplexer
from flask import Flask, request
from flask_restful import Resource, Api
import requests
app = Flask(__name__)
api = Api(app)
default_rpc = "https://rpc.builder0x69.io/"
rpcs = [
@sbarratt
sbarratt / scrape_ftx.py
Last active July 10, 2023 03:35
A script to export all FTX history
import pandas as pd
import time
import requests
import time
import hmac
from requests import Request
import sys
import json
import os
@sbarratt
sbarratt / erc20.py
Created September 26, 2022 17:47
ERC-20 Transfers as a Sparse Matrix
from ctc import evm
from scipy import sparse
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
transfers = await evm.async_get_erc20_transfers(
token='0x956f47f50a910163d8bf957cf5846d573e7f87ca',
event_name='Transfer',
)
@sbarratt
sbarratt / flash.go
Created April 11, 2021 23:58
flashbots http attempt
package main
import (
"fmt"
"log"
"bytes"
"math/big"
"encoding/json"
"io/ioutil"
"net/http"
@sbarratt
sbarratt / torch_jacobian.py
Created May 9, 2019 19:40
Get the jacobian of a vector-valued function that takes batch inputs, in pytorch.
def get_jacobian(net, x, noutputs):
x = x.squeeze()
n = x.size()[0]
x = x.repeat(noutputs, 1)
x.requires_grad_(True)
y = net(x)
y.backward(torch.eye(noutputs))
return x.grad.data
@sbarratt
sbarratt / kmeans_missing.py
Created November 3, 2017 00:21
K-means script that works with NaN entries.
"""
Author: Shane Barratt
Email: sbarratt@stanford.edu
K-means script that works with NaN entries.
"""
import numpy as np
import IPython as ipy
import matplotlib.pyplot as plt
@sbarratt
sbarratt / geo.py
Last active January 26, 2024 12:55
This script provides coordinate transformations between geodetic, ecef and enu in python. Based on https://gist.github.com/govert/1b373696c9a27ff4c72a.
"""
This script provides coordinate transformations from Geodetic -> ECEF, ECEF -> ENU
and Geodetic -> ENU (the composition of the two previous functions). Running the script
by itself runs tests.
based on https://gist.github.com/govert/1b373696c9a27ff4c72a.
"""
import math
a = 6378137
b = 6356752.3142
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""CNN from https://www.microsoft.com/en-us/research/wp-content/uploads/2003/08/icdar03.pdf"""
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets('MNIST_data', one_hot=True)
import tensorflow as tf
def weight_variable(shape):
initial = tf.random_normal(shape, stddev=0.05)
return tf.Variable(initial)