Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
@jmcph4
jmcph4 / urls.py
Created August 20, 2023 12:53
Grab URLs
#!/bin/python3
from sys import argv
from typing import Optional
from dataclasses import dataclass
from datetime import datetime
from bs4 import BeautifulSoup
from urllib import request
use std::mem;
#[repr(C)]
pub struct Foo {
a: u128,
b: u128,
}
fn main() {
let xs: [Foo; 8] = [
curl -H "0x-api-key: 5377b882-05cf-4814-a66d-102a86974012" "https://api.0x.org/swap/v1/quote?sellAmount=1000000000&buyToken=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48&sellToken=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" | jq
SELECT
blockchain,
project,
version,
SUM(amount_usd) AS cumvol
FROM dex.trades
WHERE
block_date > CURRENT_TIMESTAMP - INTERVAL '12' month
GROUP BY
blockchain,
#!/bin/python3
from sys import argv
N = 5
def f(xs):
return list(filter(lambda x: x < N, xs))
def main():
$ cast --version
cast 0.2.0 (8f20631 2023-07-10T00:04:29.812703538Z)
$ cast 4bd 0x128acb08
Error: 
No signatures found
$ cast si "function swap(address,bool,int256,uint160,bytes) returns (int256,int256)"
0x128acb08
$ cast ups "function swap(address,bool,int256,uint160,bytes) returns (int256,int256)"
Duplicated: Function swap(address,bool,int256,uint160,bytes): 0x128acb08
#!/bin/bash
BUILD_DIR=_site
REMOTE_HOST=example.com
TAG_LEN=7
TAG=$(git rev-parse HEAD | head -c "$TAG_LEN")
tar -cvf "$TAG".tar "$BUILD_DIR"/*
gzip "$TAG".tar "$TAG".tar.gz
digraph backfill_sync_fsa {
fontname="Helvetica,Arial,sans-serif"
node [fontname="Helvetica,Arial,sans-serif"]
edge [fontname="Helvetica,Arial,sans-serif"]
node [shape = doublecircle]; Completed Failed NotRequired;
node [shape = circle];
Syncing -> Syncing [label = "BackFillSync::start"];
Paused -> Paused [label = "BackFillSync::start, no peers"];
Failed -> Completed [label = "BackFillSync::start, ResetEpochError::SyncCompleted"];
Failed -> NotRequired [label = "BackFillSync::start, ResetEpochError::NotRequired"];
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "src/CoinFlip.sol";
contract Frontend {
uint256 FACTOR = 57896044618658097711785492504343953926634992332820282019728792003956564819968;
function step(CoinFlip flipper) public returns (uint256) {
require(
/// This test checks that a block that is valid from both a gossip and consensus perspective but that equivocates **late** is rejected when using `broadcast_validation=consensus_and_equivocation`.
///
/// This test is unique in that we can't actually test the HTTP API directly, but instead have to hook into the `publish_blocks` code manually. This is in order to handle the late equivocation case.
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
pub async fn blinded_equivocation_consensus_late_equivocation() {
/* this test targets gossip-level validation */
let validation_level: Option<BroadcastValidation> = Some(BroadcastValidation::Consensus);
// Validator count needs to be at least 32 or proposer boost gets set to 0 when computing
// `validator_count // 32`.