Skip to content

Instantly share code, notes, and snippets.

View pascaldekloe's full-sized avatar

Pascal S. de Kloe pascaldekloe

View GitHub Profile
@floooh
floooh / zig_test_debugging_vscode.md
Last active June 22, 2024 18:52
How to debug Zig tests in VSCode

Tested on macOS:

  1. Install the CodeLLDB VSCode extension. Unlike the debugger in the C/C++ extension, this allows to set breakpoints inside Zig "test" blocks (in the MS C/C++ extension debugger, breakpoints inside test blocks will be disabled once the debugger starts for unknown reasons.
  2. When compiling the test, tell it to also emit a binary: zig test -femit-bin=zig-out/bin/my-test src/bla.zig, otherwise there will be no executable to debug.
  3. The compiled test executable expects the path to the Zig executable as first command line argument, the launch.json file needs to be setup accordingly (note the args item):

How to calculate depth from events

Keeping a running total of RUNE depth per pool requires the handling of several events: stakes, swaps, adds, rewards, errata, gas, emissions (?).

Here I will go through the events one by one and describe how to update the pool depths based on their values.

Stake event

Stake events are fired when an LP adds stake to a pool.

@reyk
reyk / vmctl start ubuntu -d ubuntu-16.10-server-cloudimg-amd64.raw -n nat -c
Last active July 8, 2021 04:09
OpenBSD vmm and meta-data running ubuntu-16.10-server-cloudimg-amd64.raw
- Get OpenBSD from http://www.openbsd.org/ ;)
- Find an Ubuntu cloud image on https://cloud-images.ubuntu.com/
- Get https://github.com/reyk/meta-data and configure it for cloud-init
- Run the VM ...
Script started on Thu Mar 30 01:53:50 2017
# qemu-img convert ubuntu-16.10-server-cloudimg-amd64.img ubuntu-16.10-server-cloudimg-amd64.raw
# vmctl start ubuntu -d ubuntu-16.10-server-cloudimg-amd64.raw -n nat -c
Connected to /dev/ttyp6 (speed 9600)
Changing serial settings was 0/0 now 3/0
@D-Nice
D-Nice / hexStringToBytes32.sol
Created December 25, 2016 20:41
Solidity inline assembly code for converting a hex string into the same bytes32
/* Converts a hexadecimal string, whose bytes equivalent length
can be up to 32 bytes (at least only tested and meant for up to 32 bytes)
into a bytes32 type.
EXAMPLE I/O
I: "a0c3689df9ce9c3aee5c1ba34dd1649098e2a10f6b2b337bf26695318cc0b958"
O: bytes32: 0xa0c3689df9ce9c3aee5c1ba34dd1649098e2a10f6b2b337bf26695318cc0b958
Currently assumes the 0x prefix is omitted from the string.
@joepie91
joepie91 / vpn.md
Last active June 29, 2024 17:36
Don't use VPN services.

Don't use VPN services.

No, seriously, don't. You're probably reading this because you've asked what VPN service to use, and this is the answer.

Note: The content in this post does not apply to using VPN for their intended purpose; that is, as a virtual private (internal) network. It only applies to using it as a glorified proxy, which is what every third-party "VPN provider" does.

  • A Russian translation of this article can be found here, contributed by Timur Demin.
  • A Turkish translation can be found here, contributed by agyild.
  • There's also this article about VPN services, which is honestly better written (and has more cat pictures!) than my article.
@mfuerstenau
mfuerstenau / zigzag-encoding.README
Last active February 22, 2024 03:40
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation