Skip to content

Instantly share code, notes, and snippets.

View gustavohenrique's full-sized avatar

Gustavo Henrique gustavohenrique

View GitHub Profile
@gustavohenrique
gustavohenrique / win-usb-installer.sh
Created April 27, 2020 11:07
Create a Windows USB install stick using Linux machine
#!/usr/bin/bash
# uses (modified) WoeUSB's "listUsb" to get all USB devices
# WoeUSB, listUsb: Copyright © 2013 Colin GILLE / congelli501
# WoeUSB, listUsb: Copyright © 2017 slacka et. al.
# uses (modified) Janne Korhonen's installer script
# https://ypcs.fi/howto/2018/12/01/windowsiso/
#
#
# Dependencies: apt-get install wimtools parted rsync wimtools
declare -a USB_DEVICES=()
@gustavohenrique
gustavohenrique / webcam-wifi-ffmpeg.sh
Last active April 27, 2020 10:43
Share a webcam over network/wifi almost latency free using v4l2loopback and ffmpeg
#!/bin/bash
set -euo pipefail
SENDER=192.168.178.25
RECEIVER=192.168.178.59
PORT=8445
#on receiver
nc -l $PORT | ffmpeg -f rawvideo -pix_fmt yuyv422 -s:v 640x480 -i - -f v4l2 /dev/video0 2> /dev/null &
#on sender
@gustavohenrique
gustavohenrique / setup-vpn-netns.sh
Created April 27, 2020 10:29
Create a namespace for running applications which are only allowed to use certain network connections
#!/bin/bash
set -Eeuo pipefail
if [ "$#" != 2 ]
then
(
echo "Usage: $0 <vpn-interface> <nameserver>"
echo ""
echo "For example: $0 tun0 8.8.8.8"
echo ""
@gustavohenrique
gustavohenrique / reverse-shell.md
Created December 17, 2019 16:45
Reverse shell Cheat Sheet
@gustavohenrique
gustavohenrique / lambdas-python.md
Created November 11, 2019 16:37
Lambdas Python

ImageResize

import boto3
import uuid


from PIL import Image

S3 = boto3.client("s3")

Run via Docker

docker run -d \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -e POSTGRES_USER=root \
    -e POSTGRES_DB=mydb \
    -e PGDATA=/var/lib/postgresql/data/pgdata \
    -v ${HOME}/pgdata:/var/lib/postgresql/data \
    --name postgres \

Mac:

sudo killall -HUP mDNSResponder; say dns cleared successfully

Linux:

sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/nscd restart
@gustavohenrique
gustavohenrique / parallel-python.py
Created August 13, 2019 12:30
Example using parallel in Python
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# https://github.com/uchidalab/book-dataset/blob/master/scripts/download_images.py
import os
import codecs
import pandas as pd
from argparse import ArgumentParser
from urllib import request
from tqdm import trange
from joblib import Parallel, delayed

Generate self signed wildcard certificate

cat <<EOF | tee certificate.cfg
[ req ]
req_extensions     = req_ext
distinguished_name = req_distinguished_name
prompt             = no

[req_distinguished_name]
@gustavohenrique
gustavohenrique / journalctl-and-systemd.md
Last active December 8, 2020 11:16
journalctl cheat sheet and systemd

general

journalctl --utc
journalctl /usr/bin/bash  # by binary
journalctl _UID=1000 -n   # by user
journalctl -k             # kernel messages
journalctl --no-full      # display some information
journalctl -a             # display all information
journalclt --no-pager     # good for read