Skip to content

Instantly share code, notes, and snippets.

View lancepioch's full-sized avatar
💨
Swishing in some good code

Lance Pioch lancepioch

💨
Swishing in some good code
View GitHub Profile
import os, subprocess, json
directory = "Z:\plex\movies"
if not directory:
directory = input("Enter directory: ")
for filename in os.listdir(directory):
path = os.path.join(directory, filename)
cmd = ['ffprobe', '-v', 'quiet', '-print_format', 'json', '-show_format', '-show_streams', path]
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
@lancepioch
lancepioch / BaseInvoiceState.php
Created January 13, 2024 03:36
State Machines
<?php
use Exception;
class BaseInvoiceState
{
function __construct(public Invoice $invoice) { }
function finalize() { throw new Exception(); }
import os, re
pattern = re.compile(r'https:..www\d+.zippyshare.com/v/\w+/file.html')
directory = 'gogs'
urls = []
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
if not os.path.isfile(f):
@lancepioch
lancepioch / tacobell.py
Last active October 5, 2021 05:31
Plays a sound when a user joins a voice channel
import os
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()
@client.event
@lancepioch
lancepioch / best-practices.md
Last active January 8, 2022 05:42
Best Programming Practices and Rules
  1. Never use snake_case for naming anything (ref: see PSR-2)
  2. Don't use else except in rare appropriate circumstances (ref)
  3. Never use elseif, probably want switch (ref)
  4. Always PSR-2 format the PHP code (ref), see Styleci for automatic help
  5. Don't use "company name" anywhere, it's implied already, like saying "ATM Machine", it's redundant
  6. No unused variables (ref)
  7. Don't commit commented out code, just remove it (ref) (regular comments are fine)
  8. Never use backticks, they can be executed (ref)
  9. Don't commit dev tool usage such as `consol
@lancepioch
lancepioch / encode_media.py
Last active April 11, 2021 23:15
Encoder for Media
import os, subprocess, json
codec = 'h264' # codec to re-encode video to
acceptable = ['hevc', 'h264', 'h265', 'libx264']
skipExtensions = ['jpg', 'png', 'gif', 'txt', 'nfo', 'ds_store']
directory = ""
# Make sure a directory is chosen
if not directory:
directory = input("Enter directory: ")
from PIL import Image
from icrawler.builtin import BingImageCrawler
import pygame
import os
def choose(keyword):
for num in range(1, 11):
path = "imgs/" + str(num).zfill(6) + ".jpg"
try:
@lancepioch
lancepioch / modern-warfare-priorities.py
Created December 9, 2019 06:35
Adjust priorities for MW and Discord to fix voice issues and lag
import wmi, win32api, win32process, win32con
priorityclasses = [win32process.IDLE_PRIORITY_CLASS,
win32process.BELOW_NORMAL_PRIORITY_CLASS,
win32process.NORMAL_PRIORITY_CLASS,
win32process.ABOVE_NORMAL_PRIORITY_CLASS,
win32process.HIGH_PRIORITY_CLASS,
win32process.REALTIME_PRIORITY_CLASS]
# "Recipe 496767: Set Process Priority In Windows" on ActiveState - http://code.activestate.com/recipes/496767/
net stop iphlpsvc
net stop wscsvc
net stop Winmgmt
net start Winmgmt
net start wscsvc
net start iphlpsvc
{
"http_status":200,
"stats":{
"responses":{
"showing":2,
"total":2,
"completed":2
}
},
"questions":[