Skip to content

Instantly share code, notes, and snippets.

View wesleyit's full-sized avatar

Wesley Rodrigues wesleyit

View GitHub Profile
@wesleyit
wesleyit / library_path.c
Last active April 9, 2022 17:08
A Hijack module to cheat LD_stuff
/*
Compile with gcc -o /tmp/libcrypt.so.1 -shared -fPIC /home/user/tools/sudo/library_path.c
Use with sudo LD_LIBRARY_PATH=/tmp apache2
When compiling, find any dependency of target binary and compile with the same name
*/
#include <stdio.h>
#include <stdlib.h>
static void hijack() __attribute__((constructor));
@wesleyit
wesleyit / Fundamentus - Automação.ipynb
Last active January 23, 2024 14:13
Get and Analyse stocks prices and health indicators. To get the CSV, go to https://www.fundamentus.com.br/resultado.php?setor= and copy the table.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wesleyit
wesleyit / magic_default_method.py
Created June 23, 2020 02:54
This snippet of code demonstrates how to create a class which runs any method you want. Using metaprogramming, a generic method is defined, and this method can call other methods or give a default answer.
'''
This snippet of code demonstrates how to create a class which
runs any method you want. Using metaprogramming, a generic method
is defined, and this method can call other methods or give a
default answer.
'''
class StrangeDog:
'''
I am not going to define a builder method here, as I want to
@wesleyit
wesleyit / open_vscode_here.py
Created June 22, 2020 18:02
This is a Nautilus Extension which opens a VSCode window with the current folder as parameter.
import os
import gi
from urllib import unquote
gi.require_version('Nautilus', '3.0')
from gi.repository import Nautilus, GObject
class OpenVSCodeHere(GObject.GObject, Nautilus.MenuProvider):
def __init__(self):
@wesleyit
wesleyit / install.sh
Created May 10, 2020 21:22
This will install some very useful python packages on a Ubuntu Linux
sudo apt update -y
clear
sudo apt install -y \
libmysqlclient-dev \
libmysql++-dev \
libmysqlcppconn-dev \
postgresql-server-dev-all \
libpq-dev \
unixodbc-dev \
@wesleyit
wesleyit / python_chime.py
Created May 10, 2020 02:25
This code will post a message to an Amazon Chime chat
import json
import requests
import sys
bot_id = ''
token = ''
base_url = f'https://hooks.chime.aws/incomingwebhooks/{bot_id}?token={token}'
def post_message(msg):
@wesleyit
wesleyit / athena_query_covid19.sql
Created April 7, 2020 17:29
AWS Athena query for preparing a dataset using SQL instead Python
with dataset as (
select
rc.country,
rc."date",
rc.cases,
lag(rc.cases,1) over(partition by rc.country order by rc."date") as yesterday_cases,
sum(rc.cases) over(partition by rc.country order by rc."date") as acc_cases,
rc.deaths,
lag(rc.deaths,1) over(partition by rc.country order by rc."date") as yesterday_deaths,
sum(rc.deaths) over(partition by rc.country order by rc."date") as acc_deaths
@wesleyit
wesleyit / read_rdm6300.py
Created November 22, 2019 19:47
Read tags from RDM6300 on UART @ Linux
import time
import serial
s = serial.Serial('/dev/ttyUSB0', 9600)
latest_tag = 0
while True:
tag_bytes = s.read(14)
print(tag_bytes)
tag = int(tag_bytes.decode()[4:11], base=16)
@wesleyit
wesleyit / kms.py
Created November 19, 2019 21:20
Easy functions to encrypt and decrypt using Boto3
import base64
import boto3
KEY = '12345678-abcd-efgh-ijkl-1234567890'
PROFILE = 'my-security-profile'
session = boto3.session.Session(profile_name=PROFILE)
def encrypt(secret, session=session, alias=KEY):