This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Raspberry Pi Zero | |
| // Use pins like this | |
| // - GND (9) -> black | |
| // - 3v3 Power (1) -> red | |
| // - GPIO 23 (16) -> green | |
| from gpiozero import Buzzer | |
| from time import sleep | |
| buzzer = Buzzer(23) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Raspberry Pi Zero | |
| // Use pins like this | |
| // - 3v3 Power (1) -> + | |
| // - GPIO 23 (16) -> - | |
| from gpiozero import PWMOutputDevice | |
| from time import sleep | |
| buzzer = PWMOutputDevice(23, frequency=1000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Raspberry Pi Zero | |
| // Use pins like this | |
| // - black -> Ground (6) | |
| // - R -> GPIO14 (11) | |
| // - G -> GPIO15 (13) | |
| // - B -> GPIO18 (15) | |
| from gpiozero import RGBLED | |
| from time import sleep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const style = document.createElement("style"); | |
| document.head.appendChild(style); | |
| let hidden = false; | |
| window.addEventListener("keydown", (e) => { | |
| if (e.key.toLowerCase() === "c") { | |
| hidden = !hidden; | |
| style.textContent = hidden |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const TEMPLATE = { | |
| init() { | |
| this.cacheDom(); | |
| this.bindEvents(); | |
| this.render(); | |
| }, | |
| cacheDom() { | |
| // cache selectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect } from "react"; | |
| import { StyleSheet, View } from "react-native"; | |
| import Animated, { | |
| useAnimatedStyle, | |
| useSharedValue | |
| } from "react-native-reanimated"; | |
| import { viewPort } from "@project/utils"; | |
| const BALL_SIZE = 20; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useRef, useEffect } from 'react'; | |
| import { Animated, Easing } from 'react-native'; | |
| import { useIsMounted } from '@t/utils/hooks/useIsMounted'; | |
| export const useEyesAnimation = () => { | |
| const offsetX = useRef(new Animated.Value(0)).current; | |
| const isMounted = useIsMounted(); | |
| useEffect(() => { | |
| animate(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function insertAt(string, subString, position) { | |
| const before = string.substr(0, position); | |
| const after = string.substr(position); | |
| return `${before}${subString}${after}`; | |
| } | |
| /** | |
| * Crude, but reliable way to do a substring with unicode chars. We tried other | |
| * solutions but they don't work with the flags which are 4 code points! | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useRef, useEffect, useCallback } from 'react'; | |
| import { Animated, Easing } from 'react-native'; | |
| import { pickOne } from '@t/utils/pickOne'; | |
| import { MelonHalf, MelonQuarter } from '@t/components/Icons'; | |
| const MelonEmitter = ({ runAnimation }) => { | |
| const numberOfMelons = 20; | |
| const driver = useRef(new Animated.Value(0)).current; | |
| const colors = useRef(['#FFA0B4', '#F1DBDF', '#FFE4E9', '#BCFF4F']).current; | |
| const svgs = [MelonQuarter, MelonHalf]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Quicker bi-directional onViewableItemsChanged | |
| const [activeIndex, setActiveIndex] = useState(0); | |
| const onViewableItemsChanged = useRef(({ viewableItems, changed }) => { | |
| if (viewableItems?.length >= 2 && changed?.[0]?.isViewable) { | |
| setActiveIndex(changed?.[0].index); | |
| } else { | |
| if (viewableItems?.[0]) setActiveIndex(viewableItems[0].index); | |
| } |
NewerOlder