Skip to content

Instantly share code, notes, and snippets.

View gmelodie's full-sized avatar
🤟
Computing stuff

Gabriel Cruz gmelodie

🤟
Computing stuff
View GitHub Profile
@gmelodie
gmelodie / deadlock.rs
Last active February 16, 2024 22:28
Rust deadlock example with multiple threads
// help from https://gist.github.com/wuct/b98f42dba91a8c08cc6ba2d820d94c1c
//
use std::sync::{Arc, Mutex};
use std::thread;
fn acquire_lock(a: Arc<Mutex<i32>>, b: Arc<Mutex<i32>>) {
// note: if you do the commented out it doesn't deadlock, think about why that is
// let mut a_num = *a.lock().unwrap();
// a_num += 1;
let mut a_num = a.lock().unwrap();
@gmelodie
gmelodie / dec2bin-no-arrays.c
Created July 7, 2023 14:27
dec2bin in C without using arrays
#include <stdio.h>
#include <math.h>
int main(int argc, char *argv[]) {
int dec;
scanf("%d", &dec);
// figure out bits needed to represent number
// 1. you can log(dec) base 2 or...
@gmelodie
gmelodie / monitor-mode.sh
Last active May 26, 2023 19:04
Turns wireless monitor mode on/off
if [ $# -ne 2 ]; then
echo "usage: ./monitor-mode.sh INTERFACE [on|off]"
exit 1
fi
# if interface not exists
sudo iw dev $1 info > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "unable to find device '$1'"
exit 2
@gmelodie
gmelodie / hello-world.txt
Created May 22, 2023 15:17
Badusb scripts for linux
ID 1234:abcd Flipper Devices:Flipper Zero
REM run echo command
REM ---- open terminal (assuming shortcut is ctrl+alt+t)
DELAY 1000
HOLD CTRL
HOLD ALT
STRING t
RELEASE CTRL
RELEASE ALT
@gmelodie
gmelodie / estuary-metrics-graph.py
Created December 19, 2022 19:16
Estuary metrics graph experiment
import plotly.express as px
import pandas as pd
def variable_total_retrievals():
df = pd.DataFrame(columns=['Name', 'Total Retrievals', 'Success Rate', 'Reputation'])
points = 10_000
success_rates = 5
for total_retrievals in range(0, 100_000, 50):
for i in range(success_rates):
@gmelodie
gmelodie / estuary-api-v1.yaml
Last active November 21, 2022 14:34
Swagger docs for new estuary api (v1)
swagger: '2.0'
info:
description: This is the API for the Estuary application.
title: Estuary API
termsOfService: http://estuary.tech
contact:
name: API Support
url: https://docs.estuary.tech/feedback
license:
name: Apache 2.0 Apache-2.0 OR MIT
@gmelodie
gmelodie / estuary-bash.sh
Created September 29, 2022 18:51
Estuary bash utilities and shortcuts
estuary_set_auth() {
export APIKEY=$1
}
estuary_create_collection() {
coluuid=$(curl -X POST -H "Authorization: Bearer $APIKEY" "http://localhost:3004/collections/" -d '{ "name": "A new collection", "description": "A new collection test" }' -s | jq | grep uuid | cut -d '"' -f 4)
export LAST_COLLECTION=$coluuid
echo $coluuid
}
@gmelodie
gmelodie / ideas.txt
Created July 27, 2022 14:16
Estuary/Autoretrieve stat ideas
- announced CIDs to indexer
- CIDs queries from autoretrieve
- number of AR servers online
- how many heartbeats in the last day (kinda useless imo but...)
@gmelodie
gmelodie / gh-get-team-ssh-keys.sh
Created July 4, 2022 18:59
Get SSH keys for all the members of a github team
APITOKEN="" # TODO: add your token here (create one: https://github.com/settings/tokens)
# be sure to check if the token hasn't expired!
# for ORG and TEAM, you can get those by navigating to your team on github
# and seeing the url, which will be in the format:
# https://github.com/orgs/{ORG}/teams/{TEAM}/discussions
# e.g. https://github.com/orgs/application-research/teams/a-team/discussions
@gmelodie
gmelodie / estuary-boost-integration-setup.md
Created April 14, 2022 17:46
Instructions to locally setup and make deals through Boost using Estuary
  1. Clone boost, run make to compile boostd and the react app for the UI (you'll use them later), make devnet and ./devnet (might fail, if so just run again)

  2. Clone lotus and checkout boost/main, then make debug, sudo make install and finally sudo install -C ./lotus-seed /usr/local/bin/lotus-seed

  3. On a new window run this (note down the FULLNODE_API_INFO that this command outputs). If you had done this before already, make sure to clean up the directory rm -rf ~/.lotusmarkets && rm -rf ~/.lotus && rm -rf ~/.lotusminer && rm -rf ~/.genesis_sectors

unset MINER_API_INFO
unset FULLNODE_API_INFO
export ENV_MINER_API_INFO=`../lotus/lotus-miner auth api-info --perm=admin`
export ENV_FULLNODE_API_INFO=`../lotus/lotus auth api-info --perm=admin`