Skip to content

Instantly share code, notes, and snippets.

View BrianPugh's full-sized avatar
💭
⭐️ PRO

Brian Pugh BrianPugh

💭
⭐️ PRO
  • Arlington, VA
  • 22:35 (UTC -04:00)
View GitHub Profile
@anderssonjohan
anderssonjohan / build-pendulum-wheels.yml
Created March 31, 2023 11:27
Fix arm wheels created with x86_64 platform tag based on https://github.com/pypa/cibuildwheel/pull/1416
name: Build
on: [push, pull_request]
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
@guillermogotre
guillermogotre / unnormalize.py
Created March 20, 2022 15:44
PyTorch Torchvision UnNormalize (reverse Normalize)
import torchvision
class UnNormalize(torchvision.transforms.Normalize):
def __init__(self,mean,std,*args,**kwargs):
new_mean = [-m/s for m,s in zip(mean,std)]
new_std = [1/s for s in std]
super().__init__(new_mean, new_std, *args, **kwargs)
# imagenet_norm = dict(mean=[0.485, 0.456, 0.406],std=[0.229, 0.224, 0.225])
# UnNormalize(**imagenet_norm)
@DNA64
DNA64 / LCD-Game-Shrinker-Guide.md
Last active April 24, 2023 06:43
LCD-Game-Shrinker-Guide

LCD-Game-Shrinker

LCD-Game-Shrinker is a program that shrinks MAME high-resolution artwork and graphics for portable devices running LCD-Game-Emulator. You can read more on the projects GitHub page: https://github.com/bzhxx/LCD-Game-Shrinker

When creating this guide I used the FREE Oracle VM VirtualBox with Ubuntu 20.0.4.2 LTS running under Windows 10. This is a great way to get a build environment set up quickly.

Speaking of which, I've made a script called lcdsetup.sh that automates upto and including Step 6 if you prefer which you can download here

Before we continue it's important that you make sure Ubuntu is updated or you'll be installing old outdated packages and get errors.

@Eugeny
Eugeny / readme.md
Last active March 7, 2023 11:40
Frame accurate video reader - OpenCV VideoCapture replacement

OpenCV's VideoCapture is broken and hasn't been fixed for the last 5 years: opencv/opencv#9053

This is a PyAV based replacement. Unlike other implementations it can seek at any time.

How to use:

reader = VideoReader('video.mp4')
reader.seek(reader.total_frames - 100)  # frame number 
while True:
@DNA64
DNA64 / gnw_flash_menu.sh
Last active February 4, 2023 09:01
Command line tool to patch game-and-watch-flashloader and game-and-watch-retro-go to support 32bit addressing.
#!/bin/bash
# THIS SCRIPT IS NO LONGER REQUIRED. PLEASE DO NOT USE IT.
# This script will modify your game-and-watch-flashloader and game-and-watch-retro-go installations
# to allow flashing of flash memory chips exceeding 128Mb (16MB).
# Useage: Place this file in the same directory as both the 'game-and-watch-flashloader' and
# 'game-and-watch-retro-go folders', then run the script and follow the instructions.
# After patching, make sure to rebuild 'game-and-watch-flashloader'.
@dankkom
dankkom / cubic_interpolation_1d.py
Created July 16, 2020 16:42
1D Cubic Interpolation in Python w/o SciPy
from math import sqrt
import numpy
# https://stackoverflow.com/a/48085583
def cubic_interp1d(x0, x, y):
"""
Interpolate a 1-D function using cubic splines.
x0 : a float or an 1d-array
x : (N,) array_like
@amir-saniyan
amir-saniyan / EmbedResource.cmake
Last active February 1, 2024 14:17
Pure CMake function to convert any file into C/C++ source code, implemented with only CMake commands.
####################################################################################################
# This function converts any file into C/C++ source code.
# Example:
# - input file: data.dat
# - output file: data.h
# - variable name declared in output file: DATA
# - data length: sizeof(DATA)
# embed_resource("data.dat" "data.h" "DATA")
####################################################################################################
@treuille
treuille / pagination.py
Created October 2, 2019 19:05
Answer: A simple paginator in Streamlit
import streamlit as st
import numpy as np
def paginator(label, items, items_per_page=10, on_sidebar=True):
"""Lets the user paginate a set of items.
Parameters
----------
label : str
The label to display over the pagination widget.
@tvst
tvst / SessionState.py
Last active April 14, 2024 20:24
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
@jannismain
jannismain / CompactJSONEncoder.py
Last active July 4, 2024 14:59
A JSON Encoder in Python, that puts small lists on single lines.
#!/usr/bin/env python3
from __future__ import annotations
import json
class CompactJSONEncoder(json.JSONEncoder):
"""A JSON Encoder that puts small containers on single lines."""
CONTAINER_TYPES = (list, tuple, dict)