Skip to content

Instantly share code, notes, and snippets.

View al3mart's full-sized avatar
👨‍💻

Alejandro Martinez Andres al3mart

👨‍💻
View GitHub Profile
@evilrobot-01
evilrobot-01 / test.rs
Created September 28, 2023 16:31
Test: Weight Validation
// Simple test to validate weights resulting from weight functions, generated by benchmarking, against various known limits.
//
// NOTE: this is simply to provide a rough indication of dispatchable weights in relation to block limits, which can be useful for:
// - ensuring a dispatchable does not exceed block, max extrinsic limits and regression testing
// - evaluating if some optimisation results in net reduction in weight usage
// - getting a feel for weights early during pallet development and monitoring through optimisation
//
// Is only as good as the corresponding runtime configuration (i.e. test placed within pallet with mock runtime vs placed within runtime with actual runtime config).
// Also ensure the limits are relevant to your implementation, they may have changed with newer versions and will definitely change with async backing.
// Finally, it uses the generated weight functions directly and therefore does not cater to any post-dispatch weight adjustment resulting from a dispatchable.
@nuke-web3
nuke-web3 / pdf-invoices-from-photos.md
Created April 6, 2023 23:04
How to take a load of huge photos and make a tiny PDF for invoicing via a could CLI commands

PDF invocing with a ton of photos

For invoice reimbursements, use imagemagick CLI tools to help us make invoice PDF compliance easy!

# Use whatever package manager you need, likely:
sudo apt install imagemagick
@sts10
sts10 / rust-command-line-utilities.markdown
Last active June 11, 2024 23:45
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
@kianenigma
kianenigma / staking-updates.md
Last active October 5, 2022 00:58
Polkadot's Monthly Staking Update

DEPRECATED: Polkadot Staking Progress Report

I started this gist as an index for all of the staking reports. Almost a year in, we migrated everything to https://polkadot.network/tag/staking-updates/. This page will no longer be updated:

@lovelaced
lovelaced / parachain_devops.md
Last active April 8, 2024 11:54
Best practices: administrate a Substrate-based chain

Best practices for maintaining & running substrate-based (para)chain (wip)

  • Ensure all of your systems are kept up-to-date, especially with security updates.
  • Ensure you can fully bootstrap a new system from scratch easily if needed.
  • Upload archive chain backups frequently. Potentially make these available to the community down the road.
  • Have database recovery methods in place.
  • Use infrastructure as code. Never modify anything manually on your servers.
  • Ensure you have a monitoring stack set up WITH alerts (alertmanager/grafana alerts/bots etc).
  • Keep alerts actionable, otherwise they become noise.
  • If a service crashes, make sure it automatically restarts in some way (via systemd or kubernetes).
@rootkea
rootkea / spectre.c
Created January 4, 2018 15:36
PoC from Spectre Attacks: Exploiting Speculative Execution (https://spectreattack.com/spectre.pdf)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@Zearin
Zearin / python_decorator_guide.md
Last active June 5, 2024 20:26
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].