Skip to content

Instantly share code, notes, and snippets.

@haileyok
haileyok / prefetch.ts
Created December 11, 2023 22:44
bsky feed prefetch
export const usePrefetchFeedImages = (): UsePrefetchFeedImages => {
const feedItems = useRef<any[]>([])
const highestPrefetchedIndex = useRef(0)
const previousLength = useRef(0)
/**
* As we scroll down, we want to prefetch images that are about to appear in the feed.
* 1. As new items come into view, we get the last viewable item's index
* 2. We then prefetch the next 4 items in the data. This includes:
@haileyok
haileyok / ZeegoWrapper.tsx
Last active February 19, 2024 21:34
Zeego Wrapper
import * as DropdownMenu from 'zeego/dropdown-menu';
import Ellipsis from './Ellipsis';
import { Pressable } from 'react-native';
interface IProps {
actions: ContextMenuActionGroup[];
size?: number;
children?: React.ReactElement;
}
@haileyok
haileyok / migrate.js
Last active June 2, 2024 19:59
Migrate PDS script
import AtpAgent from '@atproto/api'
import { Secp256k1Keypair } from '@atproto/crypto'
import * as ui8 from 'uint8arrays'
const OLD_PDS_URL = 'https://bsky.social'
const NEW_PDS_URL = 'https://pds.haileyok.com'
const CURRENT_HANDLE = 'haileyok.com'
const CURRENT_PASSWORD = ''
const NEW_HANDLE = 'newphone.pds.haileyok.com'
const NEW_ACCOUNT_EMAIL = ''
"feed": [
{
"post": {
"uri": "at://did:plc:oisofpd7lj26yvgiivf3lxsi/app.bsky.feed.post/3kmgmxn5omk2g",
"cid": "bafyreigwb5pgppijhpywi7pyyq57ardgpwo3qc6fx4mi2j5alzilwoy7je",
"author": {
"did": "did:plc:oisofpd7lj26yvgiivf3lxsi",
"handle": "haileyok.com",
"displayName": "Hailey (internected)",
"avatar": "https://cdn.bsky.app/img/avatar/plain/did:plc:oisofpd7lj26yvgiivf3lxsi/bafkreidw3hckh7obhp25wev2htzcpwtzvvwymc6oyfii6w3h2q2e2ofqwe@jpeg",
{
"feed": [
{
"post": {
"uri": "at://did:plc:oisofpd7lj26yvgiivf3lxsi/app.bsky.feed.post/3kmgmxn5omk2g",
"cid": "bafyreigwb5pgppijhpywi7pyyq57ardgpwo3qc6fx4mi2j5alzilwoy7je",
"author": {
"did": "did:plc:oisofpd7lj26yvgiivf3lxsi",
"handle": "haileyok.com",
"displayName": "Hailey (internected)",
libc++abi: terminating due to uncaught exception of type std::__1::bad_function_call: std::exception
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x000000010612c9ec libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001063d71d0 libsystem_pthread.dylib`pthread_kill + 256
frame #2: 0x00000001801605cc libsystem_c.dylib`abort + 104
frame #3: 0x000000018028ec78 libc++abi.dylib`abort_message + 128
frame #4: 0x000000018028017c libc++abi.dylib`demangling_terminate_handler() + 272
frame #5: 0x000000018005fc00 libobjc.A.dylib`_objc_terminate() + 140
frame #6: 0x000000018028e150 libc++abi.dylib`std::__terminate(void (*)()) + 12
{
"version": 0,
"bundler": "metro",
"fileMetadata": {
"ios": {
"bundle": "_expo/static/js/ios/index-b89220236b2baeffabcb4ebc36b2c018.hbc",
"assets": [
{
"path": "assets/7d40544b395c5949f4646f5e150fe020",
"ext": "png"
Example: https://github.com/expo/custom-expo-updates-server/blob/468b7182abe2c888a5d605e902cbca37eaf42bc1/expo-updates-server/pages/api/manifest.ts#L131
id: Unique string, uuid.v4() maybe
createdAt: unix timestamp of the deployment
runtimeVersion: passed in through a header (or url param, whatever works) when sending from github action to server
launchAsset: metadata.json -> fileMetadata -> ios/android -> bundle. This should probably only be the file name,
not the entire path.
assets: metadata.json -> fileMetadata -> ios/android -> assets. The distinction between platforms seems important,
since not all assets are used on either platform.
metadata: empty object
{
"version": 0,
"bundler": "metro",
"clientVersion": "1.72",
"fileMetadata": {
"ios": {
"bundle": "bundles/e66baa6dc08188f2648433eac3e8820a.bundle",
"assets": [
"assets/7d40544b395c5949f4646f5e150fe020.png",
"assets/cdd04e13d4ec83ff0cd13ec8dabdc341.png",
@haileyok
haileyok / bean-labeler.ts
Last active March 16, 2024 20:09
Bean Auto Labeler
import {
AppBskyEmbedImages,
AppBskyFeedPost,
BskyAgent,
} from '@atproto/api'
import * as dotenv from 'dotenv'
import {ComAtprotoSyncSubscribeRepos, subscribeRepos, SubscribeReposMessage} from 'atproto-firehose'
import Anthropic from '@anthropic-ai/sdk'
import axios from 'axios'