Skip to content

Instantly share code, notes, and snippets.

View ruofeidu's full-sized avatar

Ruofei Du ruofeidu

View GitHub Profile
@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])
@ruofeidu
ruofeidu / taiwanip.php
Created May 24, 2018 18:00
Test if the IP address comes from Taiwan haha
/**
* @desc 判断ip是否为台湾IP
* @param string $ip 字符串格式的ip
* @return boolean 是台湾IP的话返回true,否则返回false
*/
public static function isTaiwanIp($ip) {
$longip = sprintf("%u", ip2long($ip));
switch ($longip % 100000000) {
case 0:
if (($longip>=19005440 AND $longip<=19136511)
@ruofeidu
ruofeidu / bilinear_get_color.py
Created April 10, 2018 17:29
Obtain color with bilinear filtering on the CPU, equivalent to the default bilinear filtering on the GPU
# type: (list, float, float) -> list
# img: the input image
# cx, cy: image coordinates in floats
def bilinear_get_color(img, cx, cy):
x, y = [int(floor(cx)), int(ceil(cx))], [int(floor(cy)), int(ceil(cy))]
u, v = cx - x[0], cy - y[0]
r = np.zeros((2, 2, 3), np.uint8)
w, h = len(img[0]), len(img)
for i in range(2):
for j in range(2):