Skip to content

Instantly share code, notes, and snippets.

View MCOfficer's full-sized avatar

M*C*O MCOfficer

View GitHub Profile
@MCOfficer
MCOfficer / Vadim's Batch.py
Last active January 21, 2023 13:11
[Python-fu/Gimp] Vadim's Batch - written for https://stackoverflow.com/a/42933365/7653274
#!/usr/bin/env python
from gimpfu import *
import glob
import os
pdb = gimp.pdb
def vadimsbatch(loadfolder, fileextension, frame):
@MCOfficer
MCOfficer / landscapecounter.py
Last active January 16, 2019 10:40
[ES][Python] Landscapecounter
import os
import requests
import json
from os import listdir
import urllib
urllib.urlretrieve("https://raw.githubusercontent.com/endless-sky/endless-sky/master/data/map.txt", "map.txt")
images = requests.get("http://api.github.com/repos/endless-sky/endless-sky/contents/images/land")
@MCOfficer
MCOfficer / javaTranslator.py
Last active October 29, 2017 21:10
Translates Java Code in the working directory and all subdirectories to a specific language (e.g. German). The results are usually hilarious.
from translate_api.translate_api import api
import re
import glob
import os
cache = dict()
def camelCaseSplit(identifier):
matches = re.finditer('.+?(?:(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', identifier)
return [m.group(0) for m in matches]
@MCOfficer
MCOfficer / camelCase.py
Created November 3, 2017 14:25
[Python] camelCaseFilenames_to_underscore_filenames_(uncapitalized) - recursive, and renames itself ¯\_(ツ)_/¯
import re
import glob
import os
import os.path
def camelCaseSplit(identifier):
matches = [m.group(0) for m in re.finditer('.+?(?:(?<=[a-z])(?=[_A-Z])|(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|$)', identifier)]
s = matches[0]
for i in range(1, len(matches)):
if matches[i][0] == "_":
@MCOfficer
MCOfficer / ffmpeg_chaptersplit.py
Last active January 16, 2019 10:39
[Python] Simple Script that Splits an audio file by it's metadata chapters using ffmpeg. Supports reading chapters from one file and splitting a different one. Useful for audio book conversion. No modules required, only ffmpeg/ffprobe binaries in your PATH
from subprocess import check_output, call, DEVNULL
from json import loads
from os import makedirs
from os.path import join, exists, splitext
from string import ascii_letters, digits
# if your ffmpeg commands are different, change them here
FFMPEG = "ffmpeg"
FFPROBE = "ffprobe"
@MCOfficer
MCOfficer / gdrive_sync.py
Created April 25, 2018 02:27
[Python] Crude script that i use to mirror the endless sky assets on my server.
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import os
import time
import datetime
mirror_dir = "PUT SOMETHING HERE"
gauth = GoogleAuth()
gauth.LoadCredentialsFile("credentials")
@MCOfficer
MCOfficer / spotify-recorder.py
Last active July 29, 2018 19:25
[Python] Script that automatically records tracks played by the linux spotify client.
from subprocess import run, PIPE, Popen
import shutil
import string
try:
import psutil
except ModuleNotFoundError:
print("psutil not found, please install it.\n$pip install psutil\n$python3 -m pip install psutil")
exit(1)
@MCOfficer
MCOfficer / run_working_dir.cmd
Created December 6, 2018 07:21
tiny script that changes to a directory (relative to its location) and executes a command. useful for executables that need to be executed from their directory.
@echo off
set origin=%cd%
cd %~dp0%1
%2
cd %origin%
@MCOfficer
MCOfficer / ESUpdate.bat
Last active March 23, 2020 17:20
InstallNightly - Automate the Installation of Endless Sky Windows Nightlies
@Echo off
setlocal
set GIT=mingit\cmd\git.exe
set NIGHTLY_URL=https://ci.mcofficer.me/job/endless-sky-win64/lastSuccessfulBuild/artifact/EndlessSky.exe
echo Switching working directory
cd %~dp0
echo Checking if MinGit is available...
@MCOfficer
MCOfficer / trydown
Created July 6, 2020 10:58
A bash script that tries to download a file with multiple programs, for use in makepkg.conf.
#!/bin/bash
# arg 0: URL
# arg 1: Output
url="$1"
output="$2"
url_key="%u"
output_key="%o"
order=(