Skip to content

Instantly share code, notes, and snippets.

View mngyuan's full-sized avatar

Kevin Lee mngyuan

View GitHub Profile
@mngyuan
mngyuan / open_random_film_photo.sh
Created February 16, 2022 02:18
Open a random photo from my film photos
#!/bin/zsh
FILELIST=$( find *film -maxdepth 2 -mindepth 2 -type f -print )
RANDOMFILE=$( echo $FILELIST | sort --random-sort | head -n 1 )
echo $RANDOMFILE
open $RANDOMFILE
@mngyuan
mngyuan / make-slippi-replay-mp4.sh
Last active November 9, 2021 22:47
ffmpeg command to make an mp4 from a dolphin emulator dump from slippi
#!/bin/zsh
# requires ffmpeg
#
# you may need to change "framedump1.avi" to "framedump0.avi" or similar, but it's always "framedump1.avi" for me
cd ~/Library/Application\ Support/Slippi\ Launcher/playback/Slippi\ Dolphin.app/Contents/Resources/User/Dump
ffmpeg -i Frames/framedump1.avi -i Audio/dspdump.wav -map 0:v -map 1:a -c:v copy -shortest output.mp4
# add a bottom part so it's vertical aspect ratio so it can be uploaded to YouTube shorts
ffmpeg -i output.mp4 -i ~/Desktop/overlay.png -filter_complex vstack=inputs=2 -r 60 output-vertical.mp4
@mngyuan
mngyuan / gist:12bdf1990333495813e1c6188a6a542d
Created October 18, 2020 22:27
Download video and transcode to macOS friendly HEVC h265 mp4
# usage: ./download.sh example-file.m3u8 output-name
# credit @brandur see https://brandur.org/fragments/ffmpeg-h265
ffmpeg -i "$1" -c:v libx265 -crf 35 -preset fast -tag:v hvc1 -c:a eac3 -b:a 224k $2.mp4
@mngyuan
mngyuan / 夢.txt
Last active September 26, 2020 22:18
大家好!我是李梦远。我在找机会练习我的中文。要是你想跟我谈一谈一起练,请送我个短信!@mngyuan
d | | i
r ------|------|------ n
e ___|______|___ g
a | | | |
m |___|____|___| d
/-----------------/ r
d / /________ / e
r _/ / a
@mngyuan
mngyuan / basic-site-with-router.js
Created June 20, 2020 01:35
Vanilla react site with redux style router
import React from 'react';
const Home = ({dispatch, currentRoute}) => {
<span>
You're at Home {currentRoute}.
<a onClick={() => dispatch({type: 'PUSH', path: '/about'})}>
About
</a>
</span>
};
@mngyuan
mngyuan / dribbble_gif_creation.md
Last active May 28, 2020 01:01
Create nice GIFs of screen recordings, for dribbble or otherwise

Convert a screen recording into a GIF using ffmpeg

Record the screen

on MacOS:

  • ⇧⌘5 to record part of the screen
  • record with intended final aspect ratio if not padding
  • trim recording appropriately
@mngyuan
mngyuan / uninstall-zoom.sh
Last active April 4, 2020 22:39
Fully uninstall Zoom for Mac
# context:
# list of privacy and security concerns:
# https://techcrunch.com/2020/03/31/zoom-at-your-own-risk/
# july 2019 exploit:
# https://www.theverge.com/2019/7/9/20688113/zoom-apple-mac-patch-vulnerability-emergency-fix-web-server-remove
# open zoom -> click zoom.us next to File -> Uninstall Zoom
# then:
# delete application
sudo rm -rf /Applications/zoom.us.app
@mngyuan
mngyuan / .gitlab-ci.yml
Created February 6, 2020 21:01
Gitlab CI config for nextjs
image: node:alpine
# Cache node modules - speeds up future builds
cache:
paths:
- node_modules
pages:
stage: deploy
script:
Process: tic80 [73213]
Path: /Applications/tic80.app/Contents/MacOS/tic80
Identifier: com.nesbox.tic
Version: 0.70.6 (0.70.6)
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: tic80 [73213]
User ID: 501
Date/Time: 2020-01-30 10:10:31.161 -0800
@mngyuan
mngyuan / ScrollableArea.react.js
Created June 19, 2019 01:44
Reset scroll on page transitions for wrapper components with React Router
import React, {useEffect, useRef} from 'react';
import {withRouter} from 'react-router-dom';
const ScrollableArea = ({children, location: {pathname}, resetOnPage}) => {
const scrollableElem = useRef(null);
useEffect(
() => {
resetOnPage ? (scrollableElem.current.scrollTop = 0) : null;
},
[pathname],