Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Frad LEE FradSer

🎯
Focusing
View GitHub Profile
@FradSer
FradSer / iterm2_switch_automatic.md
Last active Sep 15, 2022
Switch iTerm2 color preset automatic base on macOS dark mode.
View iterm2_switch_automatic.md

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm 2 homepage to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
View pre-upgrade-oculus-integration.sh
# /bin/bash
echo "Removing Oculus folder..."
rm -rf ./Assets/Oculus ./Assets/Oculus.meta
echo "Removing files named with oculus, OVR, AndroidManifest, vrapi, vrlib, vrplatlib..."
find . -name "oculus" -exec rm -rf {} \;
find . -name "OVR" -exec rm -rf {} \;
find . -name "AndroidManifest" -exec rm -rf {} \;
find . -name "vrapi" -exec rm -rf {} \;
find . -name "vrlib" -exec rm -rf {} \;
View .gitignore
# Created by https://www.toptal.com/developers/gitignore/api/macos,unity
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,unity
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
@FradSer
FradSer / pre-upgrade.sh
Last active Apr 28, 2022
Remove old Oculus Integration
View pre-upgrade.sh
# /bin/bash
echo "Removing Oculus folder..."
rm -rf ./Assets/Oculus ./Assets/Oculus.meta
echo "Removing files named with oculus, OVR, AndroidManifest, vrapi, vrlib, vrplatlib..."
find . -name "oculus" -exec rm -rf {} \;
find . -name "OVR" -exec rm -rf {} \;
find . -name "AndroidManifest" -exec rm -rf {} \;
find . -name "vrapi" -exec rm -rf {} \;
find . -name "vrlib" -exec rm -rf {} \;
@FradSer
FradSer / vc.py
Created Jan 6, 2022
Vision Center
View vc.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import matplotlib.patches as patches
import matplotlib.text as text
def rgb2gray(rgb):
return np.dot(rgb[...,:3], [0.2989, 0.5870, 0.1140])
@FradSer
FradSer / LongPressButton.swift
Created Nov 28, 2021
A iOS flashlight like button in SwiftUI.
View LongPressButton.swift
//
// LongPressButton.swift
// Pachino
//
// Created by Frad LEE on 6/28/21.
//
import SwiftUI
// MARK: - LongPressButton
@FradSer
FradSer / gifify.zsh
Last active Jul 26, 2021
Video to gif with ffmpeg.
View gifify.zsh
function gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 1200x1200\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -vf scale=1200:-1 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
View TrackableScrollView.swift
//
// TrackableScrollView.swift
// ToutiaoARDemo
//
// Created by Frad LEE on 2020/6/21.
// Copyright © 2020 Frad LEE. All rights reserved.
//
import SwiftUI
@FradSer
FradSer / SketchSystems.spec
Last active Jul 9, 2020
Nippon Colors Game
View SketchSystems.spec
Nippon Colors Game
is color hited -> Color Display
Color Mixer
Color Display
is color changed -> Color Mixer
View gifify.sh
# Usage: gifify foobar [--good]
gifify () {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 1200x1200\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -vf scale=1200:-1 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif