Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Bivalent Capital
  • /dev/null
View GitHub Profile
@ahmedali8
ahmedali8 / liquidityAmounts.ts
Created March 9, 2025 12:11
Amounts from Liquidity & Swap Calculations - Uniswap V4
import { SqrtPriceMath, TickMath } from "@uniswap/v3-sdk";
import Decimal from "decimal.js";
import { ethers } from "ethers";
import JSBI from "jsbi";
export const JSBI_ZERO = JSBI.BigInt(0);
export function getSqrtPriceAtTick(tick: string): string {
return new Decimal(1.0001).pow(tick).sqrt().mul(new Decimal(2).pow(96)).toFixed(0);
}
@sts10
sts10 / rust-command-line-utilities.markdown
Last active April 27, 2026 13:36
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@RxDx
RxDx / MacOSLogoutHook.txt
Last active July 18, 2024 02:23
MacOS: Run script before shutdown
Create a file:
$ pico /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set exuction permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
@Glamdring
Glamdring / EthereumService.java
Last active August 1, 2018 15:36
Sample EthereumJ transaction sending
package com.mypackage.ethereumsync;
import java.io.File;
import java.math.BigInteger;
import java.util.Base64;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
@tomw1808
tomw1808 / send_transfer_call.sol
Last active December 6, 2018 08:46
This is an example of the difference between "address.send()", "address.call.value()()" and "address.transfer()" in Solidity. If you like this example, then checkout my courses I do on Udemy (https://vomtom.at/tag/course/)
pragma solidity ^0.4.13;
contract someContract {
mapping(address => uint) balances;
function deposit() payable {
balances[msg.sender] += msg.value;
}
@bitnenfer
bitnenfer / index.html
Last active September 1, 2022 16:18
wasm binary loader with fallback to asm.js
<!DOCTYPE html>
<html>
<head>
<title>LOADING...</title>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
extern crate futures;
extern crate futures_cpupool;
extern crate rand;
use futures::{Future, Sink, Stream};
/// Sleep for a random time between 0 and 1 second.
fn sleep_random() {
let sleep_time_ms = rand::random::<u8>() as f64 / 255.0 * 1000.0;
std::thread::sleep(std::time::Duration::from_millis(sleep_time_ms as u64));
@KodrAus
KodrAus / Profile Rust on Linux.md
Last active March 12, 2026 22:23
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

Revisiting Tagless Final Interpreters

Tageless Final interpreters are an alternative to the traditional Algebraic Data Type (and generalized ADT) based implementation of the interpreter pattern. This document presents the Tageless Final approach with Scala, and shows how Dotty with it's recently added implicits functions makes the approach even more appealing. All examples are direct translations of their Haskell version presented in the Typed Tagless Final Interpreters: Lecture Notes (section 2).

The interpreter pattern has recently received a lot of attention in the Scala community. A lot of efforts have been invested in trying to address the biggest shortcomings of ADT/GADT based solutions: extensibility. One can first look at cats' Inject typeclass for an implementation of [Data Type à la Carte](http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesA

@oliver-batchelor
oliver-batchelor / Tensor.hs
Last active October 2, 2016 23:55
Attempts at static tensor dimensioning
{-# LANGUAGE TemplateHaskell, FlexibleContexts, FlexibleInstances, GADTs, DataKinds,
TypeInType, KindSignatures, InstanceSigs, TypeOperators,
ConstraintKinds, RankNTypes, ScopedTypeVariables, TypeFamilies,
UndecidableInstances, MultiParamTypeClasses, TypeApplications, PartialTypeSignatures #-}
--{-# OPTIONS_GHC -fplugin GHC.TypeLits.Normalise -fplugin GHC.TypeLits.KnownNat.Solver #-}
-- Three attempts at implementing a 'concat' operation for arbitrary dimension tensors,
-- concat dim xs ys is valid only if tensor xs and tensor ys share the same shape
-- (except for the dimension being joined)