Skip to content

Instantly share code, notes, and snippets.

View elibroftw's full-sized avatar
😮‍💨

Elijah Lopez elibroftw

😮‍💨
View GitHub Profile
@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;
@elibroftw
elibroftw / audio_player.py
Last active January 21, 2023 19:37
A script to play all audio formats. You only need the shared library files (*.so, *.dll) found at https://github.com/elibroftw/music-caster/tree/master/src/vlc_lib
"""
AudioPlayer v2.3.7
Author: Elijah Lopez
Make sure VLC .dll files are located in "vlc_lib/"
"""
import math
import os
import platform
import sys
import time
@elibroftw
elibroftw / UnityBuild.py
Last active April 3, 2023 18:01
A Python script to build Unity projects without the editor open.
import subprocess
import shutil
import os
import zipfile
import threading
print('Cleaning up build directory')
shutil.rmtree('Builds', ignore_errors=True)
@elibroftw
elibroftw / BuildScript.cs
Created May 24, 2020 18:07
A Unity Editor script that lets you build for all the necessary platforms at one go.
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class BuildScript
{
[MenuItem("File/Build All")]
static void BuildAll()
@elibroftw
elibroftw / process_instances.py
Last active February 22, 2022 18:56
A Python program to detect if an instance of a program/process is already running. [Windows]
import platform
from subprocess import Popen, PIPE, DEVNULL
def get_running_processes(look_for='', pid=None, add_exe=True):
# TODO: Linux implementation
cmd = f'tasklist /NH'
if look_for:
if not look_for.endswith('.exe') and add_exe:
look_for += '.exe'
cmd += f' /FI "IMAGENAME eq {look_for}"'
@elibroftw
elibroftw / threading_examples.py
Created April 25, 2020 02:13
Examples of threading
import threading
import time
# there's also a multiprocessing module which I haven't used because its easier to communicate between threads
# than it is to communicate between processes
# for each section uncomment the code and run it