Skip to content

Instantly share code, notes, and snippets.

View yiyingzz's full-sized avatar

y i y i n g yiyingzz

View GitHub Profile
@yiyingzz
yiyingzz / useFocusEffect example.ts
Created June 13, 2025 13:48 — forked from d-johnston/useFocusEffect example.ts
React Navigation (for React Native) showing their useFocusEffect which stops a counting mechanism when the page focus is lost
const [count, setCount] = useState(0)
const [slowCount, setSlowCount] = useState(0)
const [isToggled, setIsToggled] = useState(false)
useFocusEffect(
useCallback(() => {
console.log('slowCount useEffect ran')
const interval = setInterval(() => {
console.log('slow count incremented')
@yiyingzz
yiyingzz / effect snippet.ts
Created June 13, 2025 13:47 — forked from d-johnston/effect snippet.ts
Example of how useEffects still run when you switch away from a screen
const [count, setCount] = useState(0)
const [slowCount, setSlowCount] = useState(0)
const [isToggled, setIsToggled] = useState(false)
useEffect(() => {
console.log('slowCount useEffect ran')
const interval = setInterval(() => {
console.log('slow count incremented')
setSlowCount((prevState) => prevState + 1)
@yiyingzz
yiyingzz / StraightQuotes2CurlyQuotes.bas
Created May 27, 2025 00:47 — forked from dajare/StraightQuotes2CurlyQuotes.bas
LibreOffice Macro - straight quotes to curly
sub StraightQuotes2CurlyQuotes
' Thanks to Tintazul for refinements
' https://gist.github.com/Tintazul/deb5e137cabf86ddf4c2
' Now updated to work with LibreOffice Writer Version: 5.0.x
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
dim undo as object