Skip to content

Instantly share code, notes, and snippets.

@shazow
shazow / convert-gifs.sh
Last active January 22, 2024 10:13
Batch convert a directory of gifs into mp4
#!/usr/bin/bash
# Convert *.gif into *.mp4, skip if already exists.
outdir="."
for path in *.gif; do
out="${outdir}/${path/.gif/}.mp4"
[[ -f "$out" ]] && continue
ffmpeg -f gif -i "${path}" "${out}"
done
@shazow
shazow / role-models.md
Last active October 13, 2023 16:55
List of my role models

List of my role models

People I want to be more like at this point in my life, in ambition, style, or personality.

  • gaben
  • @BillNye
  • @snowden
  • @jessfraz
  • @vitalikbuterin
@shazow
shazow / meta.py
Created March 6, 2013 23:20
My latest SQLAlchemy model base class.
"""SQLAlchemy Metadata and Session object"""
import datetime
import json
import time
from sqlalchemy import MetaData
from sqlalchemy.orm import scoped_session, sessionmaker
__all__ = ['Session', 'metadata', 'Model', 'SchemaEncoder']
@shazow
shazow / flashbotnfts.ts
Last active May 26, 2023 01:20
WIP: Flashbot NFTs
import { BigNumber, providers, Wallet } from "https://esm.sh/ethers";
import { FlashbotsBundleProvider, FlashbotsBundleResolution } from "https://esm.sh/@flashbots/ethers-provider-bundle";
const FLASHBOTS_AUTH_KEY = Deno.env.get('FLASHBOTS_AUTH_KEY');
const WALLET_PRIVATE_KEY = Deno.env.get('WALLET_PRIVATE_KEY');
const GWEI = BigNumber.from(10).pow(9);
const PRIORITY_FEE = GWEI.mul(3);
const LEGACY_GAS_PRICE = GWEI.mul(12);
const BLOCKS_IN_THE_FUTURE = 2;
@shazow
shazow / flake.nix
Created March 2, 2023 02:10
Flake for tree-sitter with source grammars available to it.
{
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "/home/shazow/local/src/github.com/NixOS/nixpkgs";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p jq curl
set -e
prefix() {
declare token="${1}"
while read line; do
echo "${token}${line}"
done
@shazow
shazow / secp256k1.rb
Last active January 24, 2023 01:21
Homebrew recipe for secp256k, put it into /usr/local/Library/Formula/secp256k1.rb or run: brew install https://gist.github.com/shazow/c71c652409015479a7e6/raw/secp256k1.rb
class Secp256k1 < Formula
desc "Optimized C library for EC operations on curve secp256k1"
homepage "https://github.com/bitcoin/secp256k1"
url "https://github.com/bitcoin/secp256k1.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
def install
@shazow
shazow / gist:3928595
Last active November 18, 2022 14:24
Makefile which handles Python requirements.txt and *.egg-info (with optional virtualenv checking).
REQUIREMENTS_FILE=requirements.txt
REQUIREMENTS_OUT=requirements.txt.log
SETUP_OUT=*.egg-info
all: setup requirements
requirements: $(REQUIREMENTS_OUT)
$(REQUIREMENTS_OUT): $(REQUIREMENTS_FILE)
pip install -r $(REQUIREMENTS_FILE) | tee $(REQUIREMENTS_OUT)
@shazow
shazow / sa_enum_type.py
Created April 28, 2013 22:20
SQLAlchemy custom Enum type that uses Integer-based indexing.
from sqlalchemy import types
class Enum(types.TypeDecorator):
impl = types.Integer
def __init__(self, value_map, strict=True, *args, **kw):
"""Emulate Enum type with integer-based indexing.
value_map:
@shazow
shazow / ThinkpadX1Carbon6thgen.md
Last active September 15, 2022 15:38
Thinkpad X1 Carbon 6th gen configs

Configs

/etc/conf.d/*: ...

Modules

/etc/modprobe.d/i915.conf:

options i915 enable_guc_loading=1 enable_guc_submission=1 enable_fbc=1 enable_psr=1