Skip to content

Instantly share code, notes, and snippets.

View elibroftw's full-sized avatar
😮‍💨

Elijah Lopez elibroftw

😮‍💨
View GitHub Profile
@elibroftw
elibroftw / resolve_known_folders.py
Last active November 17, 2021 07:05
A better way to resolve special or known folder names to their usable paths
"""
No Copyright. Public Domain.
Version: 1.0.4
Known Issues: Common home folders like Documents, Music, Videos, arem missing.
"""
from functools import lru_cache
from contextlib import suppress
import sys
from uuid import UUID
from pathlib import Path
@elibroftw
elibroftw / multiprocessing_ipc.py
Last active November 14, 2021 19:24
Interprocess Communication in Python using multiprocessing.connection's Listener, Client
"""
No Copyright by the way.
Usage:
0. Have two terminals
1. In the first terminal run `test.py`
2. In the second terminal run `test.py a`
3. Magic! If you don't see anything, the arbitrary port 12025 may be in use so use another port
Practical applications (requires more than just copy pasting this code):
- Simple message queueing:
@elibroftw
elibroftw / monero_wallet_decryption.py
Last active March 13, 2024 10:08
A script to decrypt MyMonero wallet files. Simply use decrypt_mymonero( WALLET_FOLDER_PATH ).
"""
Supports: MyMonero
Instructions (terminal, assuming you have python installed):
pip install cryptography
python[3] monero_wallet_decryption.py [path_to_wallet_dir]
License: Public Domain
You are permitted to run/edit/use any or all of this code without attribution.
Free implies that there are no warranties.
@elibroftw
elibroftw / monero_rpc_example.py
Last active January 13, 2022 02:56
How to use Monero RPC without headaches
import requests
import os
from contextlib import suppress
from subprocess import Popen, PIPE, DEVNULL, CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDOW
from requests import Session
import platform
from getpass import getpass
from pathlib import Path
from requests.auth import HTTPDigestAuth
from pprint import pprint
@elibroftw
elibroftw / concurrent_requests.py
Last active May 15, 2022 21:46
Concurrency and Parallel Requests
import requests
import concurrent.futures
def get_todo(i, optional_arg=None):
if i < 1: raise ValueError
r = requests.get(f'https://jsonplaceholder.typicode.com/todos/{i}')
return r.json()
@elibroftw
elibroftw / upload_addon.py
Last active October 8, 2020 22:58
A snippet of my addon build script that I use to automate publishing new versions.
from glob import glob
import io
import os
import time
import uuid
from zipfile import ZipFile
# third party libraries
import jwt # PyJWT
import requests
# get API keys from https://addons.mozilla.org/developers/addon/api/key/
@elibroftw
elibroftw / create_pdfs.py
Created September 1, 2020 23:46
Word to PDF Generater
import os
import pythoncom
import win32com
import win32com.client as client
from shutil import copyfile, rmtree
import threading
from contextlib import suppress
wdFormatPDF = 17
@elibroftw
elibroftw / javersGoodIgnore.java
Last active March 29, 2021 21:23
Javers Example 3
javers Javers = JaversBuilder.javers()
// ...
// ignore Entity/Key Object
.registerEntity(EntityDefinitionBuilder.entityDefiniition(Square.class)
.withIdPropertyName("key")
.withIgnoredProperties("lastUpdate", "comments")
.build())
// ignore Value Object
.registerValueObject(new ValueObjectDefinitioin(Vertex.class, Arrays.asList("lastUpdate", "comments"))
// you can use both multiple times
@elibroftw
elibroftw / javersBadIgnore.java
Last active July 13, 2020 15:47
Javers Example 2
// ...
Diff diff = differ.compare(left, right);
List<Change> changes = new ArrayList<>(diff.getChanges());
List<Change> ignoredChanges = diff.getPropertyChanges("comments");
for (Change ignoreChange : ignoredChanges) {
changes.remove(ignoreChange);
}
// ...
@elibroftw
elibroftw / Vertex.java
Last active February 26, 2022 16:23
Javers Example 1
package com.elijahlopez.examples;
import java.awt.Color;
import java.util.Date;
// e.g. Class Vertex - modifiable source code
public class Vertex {
@DiffIgnore
Date lastUpdated;