Skip to content

Instantly share code, notes, and snippets.

View joshbarrass's full-sized avatar
🎓
Working towards Physics PhD

Joshua Barrass joshbarrass

🎓
Working towards Physics PhD
View GitHub Profile
@joshbarrass
joshbarrass / Readme.txt
Last active July 17, 2023 12:03 — forked from endolith/Readme.txt
Gnome to Wine color scraper
This is a Python script to extract GNOME/GTK's color scheme and apply it to Wine, so that the themes (approximately) match.
Instructions:
1. Set your Gnome theme as you would like it
2. Run with a command like "python wine_colors_from_gtk.py" If made executable you can run it in bash as-is
3. Open winecfg, go to Desktop Integration and install the new .theme file created
4. Hit apply and restart any apps running in Wine. They should match the Gnome theme colors now.
Better description with screenshots here: http://www.endolith.com/wordpress/2008/08/03/wine-colors/
@joshbarrass
joshbarrass / olmerge.py
Created June 10, 2018 21:11
One-line merge sort in Python
olmerge = lambda l:l if len(l)==1 else (lambda l1,l2: ( lambda half,l1,l2: half+l1 if not len(l2) else half+l2 if not len(l1) else half+l1+l2 )([[l1.pop,l2.pop][l1[0]>l2[0]](0) for x in range([len(l1),len(l2)][len(l1)>len(l2)]*2) if (len(l1)>0 and len(l2)>0)],l1,l2) )(olmerge(l[:len(l)//2]),olmerge(l[len(l)//2:]))
@joshbarrass
joshbarrass / folder_size.py
Last active September 21, 2018 16:20
Old utility I wrote for getting and sorting folders by size.
#!/usr/bin/env python2
import os
from docopt import docopt
def get_size(start_path = '.'):
"""Gets the size of the path in bytes."""
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
@joshbarrass
joshbarrass / parse_pbzx.py
Created September 4, 2018 16:39 — forked from Lekensteyn/parse_pbzx.py
Pure python reimplementation of .cpio.xz content extraction from pbzx file payload for OS X packages
#!/usr/bin/env python
# Extract .cpio file from a pbzx Payload file.
#
# Based on https://gist.github.com/pudquick/ac29c8c19432f2d200d4,
# this version adds a command-line interface, improves efficiency (1 MiB chunks
# instead of a full copy in memory), adds Python 3 compatibility and
# automatically decompresses stuff (some blocks may not be compressed).
#
# Example usage (from Python):
#
@joshbarrass
joshbarrass / cuemaker.py
Last active July 20, 2022 02:23
Python code to generate cue sheets (.cue files) from YouTube timestamps
import re
def pad_number(number,length=2,padding="0"):
str_number = str(number)
if len(str_number) < length:
str_number = padding+str_number
return str_number
def make_cue_tracks(inp,pattern="((\\d{1,2}):)?(\\d{1,2}):(\\d{1,2}) - (.*)",
hr=1,m=2,s=3,title=4,artist=None):
@joshbarrass
joshbarrass / qt5base.py
Created February 25, 2019 16:22
Simple PyQt5 program to serve as an example/base for future programs.
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtWidgets import QPushButton, QWidget, QLabel
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout
class MyMainWindow(QMainWindow):
''' the main window potentially with menus, statusbar, ... '''
def __init__(self):
super().__init__() # calls __init__ of the parent class, QMainWindow
@joshbarrass
joshbarrass / matplotlibqt5base.py
Created February 25, 2019 16:46
PyQt5 application that displays a matplotlib plot, to be used as a base for future stuff
import sys
import numpy as np
import matplotlib.pyplot as plt
# import relevant classes from PyQt
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel
from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QSizePolicy
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
class MyMainWindow(QMainWindow):