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 / detrashify_acm.py
Created August 6, 2024 23:09
Remove entire publications from ACM Digital Library's exported .bib file
from pybtex.database.input import bibtex
from pybtex.database.output.bibtex import Writer
from pybtex.errors import set_strict_mode
import sys
if __name__ == '__main__':
if len(sys.argv) != 2:
print('usage: python3 detrashify_acm.py /path/to/acm.bib')
exit(1)
@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