Skip to content

Instantly share code, notes, and snippets.

View afsardo's full-sized avatar

André Sardo afsardo

View GitHub Profile
import {
AccountMeta,
ComputeBudgetProgram,
Connection,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionMessage,
VersionedTransaction,
@afsardo
afsardo / local.ts
Last active February 13, 2024 13:06
Generate asset list
export type Token = {
protocol: string;
symbol: string;
token: string;
icon?: string;
chain?: string;
decimals?: number;
chainId?: string;
priceUsd?: number;
isBlocked?: boolean;
@afsardo
afsardo / LoadTestingAPI.md
Created October 8, 2023 11:54
Stress testing API endpoint

Stress test with 50 requests per second

autocannon -r 50 --renderStatusCodes [ENDPOINT]
@afsardo
afsardo / main.ts
Last active May 31, 2023 17:44
Simulate multisig txs on any chain with Terra.js
import { LCDClient, MsgExecuteContract } from "@terra-money/terra.js";
const LCD_URL = "[LCD-ENDPOINT-HERE]";
const CHAIN_ID = "neutron-1";
const DEFAULT_GAS_PRICE = "0.02uatom";
const DEFAULT_GAS_MULTIPLIER = 1.3;
(async function () {
const multisig = "[MS-ADDRESS-HERE]";
console.log("Neutron: Simulating tx with address", multisig);
@afsardo
afsardo / main.ts
Last active February 15, 2023 22:41
Sign and Broadcast Tx w/ PrivateKey - Injective
import Mnemonic from "bitcore-mnemonic"
import {
BaseAccount,
ChainRestAuthApi,
createTransactionAndCosmosSignDoc,
PrivateKey,
TxRestApi,
InjectiveDirectEthSecp256k1Wallet,
hexToBuff,
createTxRawFromSigResponse,
@afsardo
afsardo / timezones.json
Created July 13, 2020 22:02
Timezones Simplified
[
{
"label": "American Samoa",
"default": "Pacific/Pago_Pago",
"timezones": ["Pacific/Pago_Pago"]
},
{
"label": "Coordinated Universal Time-11",
"default": "Pacific/Midway",
"timezones": ["Pacific/Midway", "Pacific/Niue"]
@afsardo
afsardo / DeleteOldBranches.md
Last active January 30, 2018 22:23
Delete old branches

When you are working in a team, you often make branches for features/bugs. After the branch gets merged into master, you end up with an old reference in your own git history.

If you are like me, that although knowing git in the command line, use the Github Desktop app, you end up with an infinite list of old branches.

Heres the one single command solution:

$ git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d

@afsardo
afsardo / UsedSpace.md
Last active July 29, 2017 11:42
This will give you the used space for all child folders.

Check used space dirs Ubuntu

Last week there was a disk space problem on an AWS instance, we couldn't figure out where space was being used.

The good old ls / ll wasn't going to cut it, had to search a way to discover what folder was taking up so much space.

Starting from the root $ cd / I used the command below:

$ du -hcsx .[!.]* * | sort -rh | head
@afsardo
afsardo / mysqldump.sh
Last active July 9, 2017 14:14
MySQL Backup w/ mysqldump
# If for some reason you need to make a backup of your database here's how you dump and restore it.
# Backup
$ mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
# Restore
$ mysql -u root -p[root_password] [database_name] < dumpfilename.sql
@afsardo
afsardo / str_pad.php
Created July 8, 2017 15:54
String always constant number of characters
// Append 0 to the left of the number if needed so the number always has 4 digits
$number = 10;
echo str_pad($number, 4, "0", STR_PAD_LEFT);
// Output: 0010