Skip to content

Instantly share code, notes, and snippets.

View Brayden's full-sized avatar

Brayden Wilmoth Brayden

View GitHub Profile
import { DurableObject } from "cloudflare:workers";
export class MyDurableObject extends DurableObject<Env> {
public sql: SqlStorage
constructor(ctx: DurableObjectState, env: Env) {
super(ctx, env);
this.sql = ctx.storage.sql
}
@Brayden
Brayden / card.tsx
Created November 21, 2024 14:13
Shiny Card with Movement
export function Card({
height
}: {
height: number
}) {
const scale = height / 390;
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
const card = e.currentTarget;
const rect = card.getBoundingClientRect();
@Brayden
Brayden / install.sh
Last active October 4, 2024 11:57
Install script for deploying a Starbase instance to Cloudflare
#!/bin/bash
# Function to check for jq and install if necessary
check_and_install_jq() {
if ! command -v jq &> /dev/null; then
# Try to install jq based on the system package manager
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update && sudo apt-get install -y jq > /dev/null
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install jq > /dev/null
@Brayden
Brayden / use-lifecycle.tsx
Last active August 15, 2024 13:18
React useLifecycle Hook
import { useEffect } from 'react'
export enum LifecycleVisibilityChange {
Visible = 'visible',
Hidden = 'hidden',
Prerender = 'prerender',
Unloaded = 'unloaded',
}
export const useLifecycle = ({
@Brayden
Brayden / P2P Detecting & Fixing Memory Issues (Part 1)
Created March 13, 2014 19:54
P2P Detecting & Fixing Memory Issues (Part 1)
@interface ViewController ()
/**
atomic
------
- is default behavior
- only one thread accesses the variable at a time
- is thread safe (read/write safe)
- slower in performance (than nonatomic)
@Brayden
Brayden / BBStandardAPI.h
Last active December 18, 2015 10:39
BB Standard iOS App API Wrapper. Direct questions to Brayden.
@class MBProgressHUD;
typedef NS_ENUM(NSUInteger, kAPIMethod) {
GET,
POST,
PUT,
DELETE
};
typedef NS_ENUM(NSUInteger, kAPIEndpoint) {