Skip to content

Instantly share code, notes, and snippets.

View ruofeidu's full-sized avatar

Ruofei Du ruofeidu

View GitHub Profile
"""Module to recursively delete Sony RAW (.ARW) files from a directory."""
import logging
from pathlib import Path
def delete_arw_files(target_dir: str = "."):
"""Recursively finds and removes all files with the .arw extension.
Args:
@ruofeidu
ruofeidu / renamer.py
Created December 30, 2025 00:05
rename photos by EXIF / file creation date
import os
import re
from datetime import datetime
from pathlib import Path
from PIL import Image
# Tag IDs for EXIF data
# 36867: DateTimeOriginal (Shutter click)
# 306: DateTime (Last metadata change)
EXIF_DATE_TAGS = (36867, 306)
@ruofeidu
ruofeidu / hide_badge_from_settings.sh
Created June 12, 2021 15:48
Hide red badge / bubble from Mac Settings
defaults write com.apple.systempreferences AttentionPrefBundleIDs 0 && killall Dock
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <numeric>
#include <algorithm>
#include <vector>
#include <set>
#include <sstream>
#include <random>
@ruofeidu
ruofeidu / gifit.sh
Last active May 25, 2021 03:57
gifit.sh
start_time=0:0
duration=10
# Windows Bash
palette="/c/python3/scripts/palette.png"
# Linux / Mac Bash
# palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
@ruofeidu
ruofeidu / cats_list.txt
Created August 13, 2020 18:37
List of cats
Abyssinian
Aegean
American Curl
American Bobtail
American Shorthair
American Wirehair
Arabian Mau
Australian Mist
Asian
Asian Semi-longhair
@ruofeidu
ruofeidu / opengl_formats.txt
Last active February 23, 2020 22:15 — forked from Kos/formats.txt
OpenGL image formats along with their unsized variants and preferred formats for pixel transfer (Written by hand, needs verification) Pixel store for compressed textures not provided because there are glCompressedTexImage and family for them. EXT_texture_compression_s3tc formats not included.
| Image format (sized) | Unsized | Compr | Pixel format | Pixel type |
|---------------------------------------|--------------------|-------|--------------------|-----------------------------------|
| GL_R8 | GL_RED | False | GL_RED | GL_UNSIGNED_BYTE |
| GL_R8_SNORM | GL_RED | False | GL_RED | GL_BYTE |
| GL_R16 | GL_RED | False | GL_RED | GL_UNSIGNED_SHORT |
| GL_R16_SNORM | GL_RED | False | GL_RED | GL_SHORT |
| GL_R32F | GL_RED | False | GL_RED | GL_FLOAT |
| GL_R8I | GL_RED | False | GL_RED_INTEGER | GL_INT |
@ruofeidu
ruofeidu / turbo_colormap.glsl
Created August 21, 2019 21:35 — forked from mikhailov-work/turbo_colormap.glsl
Turbo Colormap Polynomial Approximation in GLSL
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
// Polynomial approximation in GLSL for the Turbo colormap
// Original LUT: https://gist.github.com/mikhailov-work/ee72ba4191942acecc03fe6da94fc73f
// Authors:
// Colormap Design: Anton Mikhailov (mikhailov@google.com)
// GLSL Approximation: Ruofei Du (ruofei@google.com)
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA
@ruofeidu
ruofeidu / trie.py
Last active July 12, 2018 18:58 — forked from crlane/trie.py
An implementation of a trie in python using defaultdict and recursion
from collections import defaultdict
def node():
return defaultdict(node)
def word_exists(word, node):
if not word:
return None in node
return word_exists(word[1:], node[word[0])