Skip to content

Instantly share code, notes, and snippets.

View larry0x's full-sized avatar
🇵🇹
PT

Larry larry0x

🇵🇹
PT
View GitHub Profile
@orzklv
orzklv / readme.md
Last active September 21, 2024 13:53
How to migrate from homebrew to Nix package manager by Orzklv!

How to migrate from Homebrew to Nix

#homebrew #brew #nix #nixos

I'll be honest with ya'll, you don't wanna get away from Homebrew completely, yes, I'll explain!

I've been using Nix package manager in all my MacOS machines about 3-4 months and I always kept Homebrew installed. You see, Nix is a very good package manager and with its home-manager, it becomes a good config farm as well. However, installing & managing GUI & unfree apps via Nix has been a quite painful experience for me. Sometimes, it wouldn't run properly, crash or wouldn't even start. Also, Nix doesn't have most of GUI packages that Homebrew has. Therefore, I keep homebrew and use it only for its "casks" registry to install GUI & unfree apps whereas having nix to manage dot file configurations and cli apps.

@OrionReed
OrionReed / dom3d.js
Last active September 19, 2024 20:10
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@0xekez
0xekez / cw-future-map.md
Last active August 29, 2024 22:40
CosmWasm key value store that allows incrementing and decrementing values at a times in the future

Here I describe a CosmWasm key value store that allows incrementing and decrementing values at a times in the future. For example, using this map a staking contract may increment claimable balances at time $now + unbondingDuration$ during an unstake transaction. I analyze its runtime and show that the complexity of a load is $O(1)$ and the complexity of a store scales with the number of times the unbonding duration has changed.


Let $snapshots$ be a map where $snapshots[key, time]$ holds the value of a key at a given time. If a $(key, time)$ pair does not have a value, its value is the most recently stored value for that key.

$$ times(k) = \{t \mid \forall (k', t) \in snapshots,k=k'\} $$

@0xekez
0xekez / gas-efficient ranked choice voting.md
Last active February 7, 2023 02:35
a gas-efficent, ranked-choice voting system

here i describe a design of a gas-efficent, ranked-choice voting system.

the problem

the most common form of ranked choice voting, instant run off, works like this:

  1. voters submit a list of candidates sorted by their preference.
  2. if there is an option with the majority of first-preference votes, that option is the winner.
  3. otherwise, remove the option with the fewest first-preference votes from all preference lists and repeat.
@prestwich
prestwich / monorepo.md
Last active November 25, 2022 17:15
How to break up a monorepo :)

How to break up a monorepo using git subtree:

  1. Set up some basic stuff:
    • These should be independent, not nested
$ NEW_REPO_PATH=
$ OLD_REPO_PATH=
@blockpane
blockpane / bashrc.sh
Created August 18, 2022 00:03
tendermint cli autocompletions
# add this to your .bashrc (and edit the list of chains to your liking
# it will enable tab completion on the command line for each :)
while read autocomplete; do
hash $autocomplete 2>/dev/null && . <($autocomplete completion)
done << EOF
junod
kava
osmosisd
secretcli
@faddat
faddat / pebble-with-mev.bash
Last active March 8, 2023 02:40
use pebbledb and mev-tendermint on any cosmos chain
go mod edit -replace github.com/tendermint/tm-db=github.com/baabeetaa/tm-db@pebble
go mod tidy
go mod edit -replace github.com/tendermint/tendermint=github.com/notional-labs/mev-tendermint@0db69e64a2e87bb29b4417780da30630df97cadd
go mod tidy
go install -ldflags '-w -s -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb -X github.com/tendermint/tm-db.ForceSync=1' -tags pebbledb ./...
@faddat
faddat / fastdb.bash
Created July 25, 2022 12:10
Use notional's fancy db on any cosmos chain
#you'd run these commands in the folder with the chain's source code. It will replace tm-db with a tricked out version that Notional, Terra, and others contributed to over time.
# Specifically, I am looking to gather evidence around this and move forward with it.
go mod edit -replace github.com/tendermint/tm-db=github.com/notional-labs/tm-db@a6ddc62
go install./...
@joeabbey
joeabbey / README.md
Last active February 28, 2022 20:25
Measuring Osmosis Epoch

Introduction

Osmosis is an automated market maker for interchain assets. Over the past 7 months, the adoption has continued to accelerate with nearly $1.5B in TVL as of the time of writing. Additionally, the AMM supports 33 unique assets and continues to add new assets as new chains join IBC.

Osmosis is unique from other Cosmos Chains with the implementation of an epochs module. The epochs module hooks the incentives and mint keepers to distribute various rewards once a day. With the growth of the network, increase in incentivized pools, the time to compute the epoch block and produce a NewHeight has increased to roughly 20 minutes.

New users are coming to Osmosis everyday and stay for its ease-of-use, access to many new assets, and incredible speed. The epoch block takes new users by surprise, and can be a negative experience. With more AMMs arriving in the IBC ecosystem, giving us

@0xdef1
0xdef1 / astro-lockdrop.js
Last active December 17, 2021 21:31
ASTRO Lockdrop Stats
import { LCDClient } from '@terra-money/terra.js';
const terra = new LCDClient({
URL: 'https://lcd.terra.dev',
chainID: 'columbus-5',
});
const pools = [
{
name: 'bLUNA-LUNA',