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 / initial-scans.sh
Created April 1, 2022 20:46
Initial nmap scans to do in a machine
#!/bin/bash
if [ $# -ne 1 ]
then
echo "usage: sudo ./$0 TARGET_IP"
exit 1
fi
mkdir nmap
nmap -p- -sU -n --max-retries 3 --max-scan-delay 1 $1 -oN nmap/all-udp.txt &
@gmelodie
gmelodie / example-index-advertisement.go
Last active March 28, 2022 22:09
Example code to advertise content to storetheindex
package main
import (
"context"
"fmt"
"log"
"github.com/filecoin-project/index-provider/engine"
"github.com/filecoin-project/index-provider/metadata"
"github.com/filecoin-project/storetheindex/api/v0/ingest/schema"
@gmelodie
gmelodie / pin-dir-est.sh
Created February 7, 2022 19:40
Pin directory CID in estuary bug PoC
testdir="/tmp/testfs"
esturl="http://localhost:3004"
# create a collection on estuary first with: curl -X POST http://localhost:3004/collections/create -d '{ "name": "A new collection", "description": "A new collection test" }' -H "Content-Type: application/json" -H "Authorization: Bearer $APIKEY"
# then paste the collection's UUID below
coluuid="YOUR-COLLECTION-UUID"
# make sure it's empty
rm -rf $testdir
@gmelodie
gmelodie / lazy-commit.sh
Created July 10, 2021 23:11
Lazy commit (random message from http://whatthecommit.com/)
message=$(curl http://whatthecommit.com | grep \<p\> | cut -d ">" -f 2)
git add .
git commit -m "$message"
git push
@gmelodie
gmelodie / Makefile
Created July 1, 2021 19:54
Buffer Overflows (MLH show and tell)
all: clean stack1 bof1
stack1: clean
gcc stack1.c -o stack1
bof1: clean
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
gcc bof1.c -fno-stack-protector -o bof1
bof2: clean
@gmelodie
gmelodie / ddclient.conf
Created January 2, 2021 01:29
My ddclient configuration file (cuz I always spend 100 hours looking for it)
# /etc/ddclient.conf
cache=/var/cache/ddclient/ddclient.cache
pid=/var/run/ddclient.pid
daemon=300
syslog=yes
ssl=yes
protocol=cloudflare
ttl=1
use=web
web=bot.whatismyipaddress.com
@gmelodie
gmelodie / conn_nmcli_no_dhcp.sh
Last active October 15, 2020 02:09
NetworkManager connection workflow to when a network doesn't have DHCP enabled
nmcli dev status # show devices connected and not connected
nmcli con show # show active and old connections
nmcli con mod CONNECTION_NAME ipv4.method manual # modify a connection from DHCP to static IP connect
nmcli con mod CONNECTION_NAME ipv4.addresses 192.168.0.X/24 # set the static IP to use in a connection
nmcli con mod CONNECTION_NAME ipv4.gateway 192.168.0.Y # set the default gateway of a connection
# Finally, revert changes after DHCP is setup
nmcli con mod CONNECTION_NAME ipv4.method auto ipv4.addresses "" ipv4.gateway ""
@gmelodie
gmelodie / hdd-python-optimization.py
Last active October 17, 2020 13:13
Prints access times of HDD vs RAM
# Tests whether python optimizes file reads or not
# Spoiler: apparently it does but it doesn't make much of a difference for this experiment
import time
def count_time(func):
def wrapper(*args, **kwargs):
start = time.time()
func(*args, **kwargs)
end = time.time()
print(f"Time: \t{format(end - start, '.9f')}s")
@gmelodie
gmelodie / term-dif-lang.sh
Last active January 29, 2020 21:48
Script to open terminal with different language than system language using keyboard shortcuts
# I use French as the default system language but wanted my terminal to use en_US
# Change 'en_US' to the language you want your terminal to be
# Change 'gnome-terminal' to the command that calls your terminal emulator (e.g. konsole, xterm,...)
LANG=en_US gnome-terminal
# After that, create the shortcut (e.g. Ctrl+Alt+T) and name the action:
# /bin/bash /path/to/term-dif-lang.sh
@gmelodie
gmelodie / xcreep.sh
Last active August 6, 2020 23:29
Copy the contents of a file to X's clipboard (wrapping for "xclip -selection c")
# example: ./xcreep.sh somefile.txt
if [ $# -ne 1 ]
then
echo "usage: $0 <INPUTFILE>"
exit 1
fi
INPUTFILE=$1
cat $INPUTFILE | xclip -selection c