Skip to content

Instantly share code, notes, and snippets.

View anglinb's full-sized avatar

Brian Anglin anglinb

View GitHub Profile
@anglinb
anglinb / runAwaitingScopeClose.ts
Created February 28, 2025 21:38
Shows how to invoke a scoped effect in a cloudflare worker and return the result while keeping it alive for the scope to close.
import { Duration, Effect, Either, Scope, Cause } from 'effect';
// This function allows you call to a scoped effect, return the response
// then use the ctx.waitUntil api to ensure the worker continues
// to run until the scope is done closing. It handles, success,
// failures and defects.
const runAwaitingScopeClose =
<Input, S extends Response, E>(effect: (input: Input, env: Env, ctx: ExecutionContext) => Effect.Effect<S, E, Scope.Scope>) =>
(input: Input, env: Env, ctx: ExecutionContext): Promise<Response> => {
@anglinb
anglinb / gist:8c2b43833f3791fa69a92249d77f4cfb
Created October 14, 2021 07:44
Hacky VPN-like setup to quickly start a browsing session with an different IP
#!/bin/bash
cd "$(dirname "$0")/.."
set +ex
# Setup tunnel
ssh -D 9090 -N -f <user>@somehostintheus.com
# Open chrome
@anglinb
anglinb / shouldTryToRestore
Created September 30, 2021 16:29
Example implementation of shouldTryToRestore
class PaywallHelper: PaywallDelegate {
func shouldTryToRestore() {
Purchases.shared.restoreTransactions { (purchaserInfo, error) in
if let purchaserInfo = purchaserInfo {
if let entitlement = purchaserInfo.entitlements["membership"] {
if entitlement.isActive {
@anglinb
anglinb / certifcate.yml
Last active September 29, 2021 00:41
Issue wildcard certificate for Heroku & Cloudflare
name: Issue Certificate
on:
schedule:
- cron: 32 4 * * 3
workflow_dispatch:
jobs:
request_certificate:
runs-on: ubuntu-latest
@anglinb
anglinb / ContextReducer.tsx
Last active August 30, 2021 16:49
Boilerplate for a context & reducer, basically mini redux
import { createContext, FC, useReducer } from 'react';
/**
* Context hook
*
*/
type ExampleContextType = {
value: string ,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anglinb
anglinb / winner.svg
Last active March 27, 2019 21:58
My new gist
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anglinb
anglinb / 1aREADME.md
Last active September 12, 2017 04:12
Update glitch app flow

Update Flow

  1. Open the Glitch project
  2. Open the Advanced Options and click Open Console 1.png 2.png
  3. Run this command: git fetch --all && git reset --hard origin/master && refresh 3.png
@anglinb
anglinb / .env
Last active September 8, 2017 02:12
Simple slapp app
# This setup assumes a single team install
PORT=3000
SLACK_VERIFY_TOKEN="PUT YOUR SLACK VERIFY TOKEN HERE"
APP_TOKEN="PUT YOUR APP TOKEN HERE"
BOT_TOKEN="PUT YOUR BOT TOKEN HERE"
BOT_USER_ID="PUT YOUR BOT USER ID HERE"
# Note: There can be no spaces between the variable name, the equal sign and the value.
@anglinb
anglinb / Autocomplete.gif
Last active September 3, 2017 17:56
Quickly access GitHub repos by leveraging Chrome's search engine settings
Autocomplete.gif