Skip to content

Instantly share code, notes, and snippets.

@codemem
codemem / runDevBrowser.mjs
Created April 19, 2024 14:41 — forked from SomeHats/runDevBrowser.mjs
A hacky local version of cloudflare's browser rendering API. To use this, copy either runDevBrowser.ts or runDevBrowser.mjs and install the puppeteer and ws packages from npm. Run the dev server alongside wranger with `node runDevServer.mjs` or `tsx runDevServer.ts`
/* eslint-disable no-console */
/***
* This is a little server that emulates the protocol used by cloudflare's browser rendering API. In
* local development, you can run this server, and connect to it instead of cloudflare's (strictly
* limited) API. e.g. in your worker you might use a function like this:
*
* ```ts
* import { Browser, launch as launchPuppeteer } from '@cloudflare/puppeteer'
* function launchBrowser(env: Environment) {
* if (env.LOCAL_BROWSER_ORIGIN) {
import { Hono } from 'hono'
import { streamText } from 'hono/streaming'
import { Ai } from '@cloudflare/ai'
import { events } from 'fetch-event-stream'
type Bindings = {
AI: any
}
const app = new Hono<{ Bindings: Bindings }>()
@codemem
codemem / useParsedSearchParams.tsx
Created April 4, 2024 09:32 — forked from Temzasse/useParsedSearchParams.tsx
A utility hook to parse and type URL search params based on a configuration object. This hook is useful when you want to access URL search params in a typesafe way and with proper casting.
import { useMemo } from "react";
import { useSearchParams } from "react-router-dom";
type ParseConfig = Record<
string,
| { type: "string"; defaultValue?: string }
| { type: "number"; defaultValue?: number }
| { parse: (value: URLSearchParams) => unknown }
>;
@codemem
codemem / .eslintignore
Created April 4, 2023 15:47 — forked from vdelacou/.eslintignore
React Vite Typescript Eslint
vite.config.ts
src/vite-env.d.ts
dist
/**
* Unpivot a pivot table of any size.
*
* @param {A1:D30} data The pivot table.
* @param {1} fixColumns Number of columns, after which pivoted values begin. Default 1.
* @param {1} fixRows Number of rows (1 or 2), after which pivoted values begin. Default 1.
* @param {"city"} titlePivot The title of horizontal pivot values. Default "column".
* @param {"distance"[,...]} titleValue The title of pivot table values. Default "value".
* @return The unpivoted table
* @customfunction
@codemem
codemem / Android ci-cd-workflow.yml
Created February 26, 2022 21:16 — forked from shafayathossain/Android ci-cd-workflow.yml
Complete workflow file to getting started with CI/CD for Android project
name: CI/CD workflow
on: push
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
fetch-depth: 0
@codemem
codemem / build-and-publish.yml
Created August 28, 2021 09:42 — forked from tannermares/build-and-publish.yml
Build and Publish React Native Project to Testflight and Google Play
# Sources:
# https://blog.usejournal.com/automate-react-native-builds-with-github-actions-af54212d26dc
# https://zach.codes/ios-builds-using-github-actions-without-fastlane/
# https://stackoverflow.com/questions/16550594/jenkins-xcode-build-works-codesign-fails/19550453#19550453
# https://www.valueof.io/blog/deploying-to-google-play-using-github-actions
name: Build and Publish Test Builds
on:
push:
@codemem
codemem / debugger pause beforeunload
Created August 16, 2021 19:59 — forked from carcinocron/debugger pause beforeunload
Chrome: pause before redirect
// Run this in the F12 javascript console in chrome
// if a redirect happens, the page will pause
// this helps because chrome's network tab's
// "preserve log" seems to technically preserve the log
// but you can't actually LOOK at it...
// also the "replay xhr" feature does not work after reload
// even if you "preserve log".
window.addEventListener("beforeunload", function() { debugger; }, false)
@codemem
codemem / docker-compose.yml
Created April 17, 2021 01:21 — forked from gladius882/docker-compose.yml
Complete docker-compose file for PrestaShop module development
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=presta
- MYSQL_DATABASE=presta