Skip to content

Instantly share code, notes, and snippets.

A ghost

Nathan myobie

A ghost
View GitHub Profile
myobie / ci.yml
Last active Jan 27, 2023
Don't run GitHub Actions for pull requests that are drafts
View ci.yml
- master
- opened
- reopened
- synchronize
- ready_for_review
myobie / expand-all-files-on-github-diff-page.js
Created Oct 6, 2022
I couldn't find an "expand all" button, so I just made my own
View expand-all-files-on-github-diff-page.js
document.querySelectorAll('button[aria-label="Toggle diff contents"]').forEach(b =>
myobie / application.ex
Last active Sep 20, 2022
Using Finch with ExAws
View application.ex
defmodule Example.Application do
@moduledoc false
use Application
def start(_type, _args) do
children = [
{Phoenix.PubSub, name: Example.PubSub},
myobie / generate-importable-blob.ts
Created Mar 25, 2022
Generate Blob import from file on disk with deno
View generate-importable-blob.ts
const bytes = await Deno.readFile(new URL('./thumbnail.png', import.meta.url))
const encoder = new TextEncoder()
const contents = encoder.encode(
`export const thumbnail = new Blob(new Uint8Array(${
}), { type: 'image/png' })`
await Deno.writeFile(new URL('./hardcoded-thumbnail.ts', import.meta.url), contents)
myobie / remove-www.js
Created Mar 15, 2022
A cloudflare worker to remove the www subdomain and redirect
View remove-www.js
const status = 301
addEventListener('fetch', event => {
const url = new URL(event.request.url)
url.hostname = url.hostname.replace(/^www\./, '')
event.respondWith(Response.redirect(url.toString(), status))
myobie / async_iterators_throw_catch_test.ts
Last active Feb 10, 2022
I was testing to see if the next() in an async iterator worked how I suspected, where throws are really Promise.reject() which throws at the for await point.
View async_iterators_throw_catch_test.ts
import { assertEquals } from ''
Deno.test('async iterator throw in next should throw in for scope', async () => {
const results: number[] = []
const numbers = (() => {
let counter = 0
const iterator: AsyncIterator<number> = {
// deno-lint-ignore require-await
myobie / service-worker.ts
Last active Nov 17, 2021
A small example of a service worker in typescript along with the tsconfig.json that allows tsserver and IDEs to understand what's going on
View service-worker.ts
// NOTE: We must export or import at least one thing so we are not in
// the "global" scope, but in a module scope which is re-declarable.
// The error from tsserver is: 2451: Cannot redeclare block-scoped
// variable 'self'.
// Even tho this is not really a module and cannot be: ServiceWorkers
// cannot be modules.
export type Version = number
myobie / mountain-lion-brew-setup.markdown
Created Feb 18, 2012
Get Mountain Lion and Homebrew to Be Happy
View mountain-lion-brew-setup.markdown

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

myobie / deferred.ts
Created Aug 2, 2021
My own promise-like object where I can type the rejection and I can resolve from the outside
View deferred.ts
export class Deferred<T = void, E = Error> {
#promise: Promise<T>
// deno-lint-ignore ban-ts-comment
// @ts-ignore
resolve: (arg: T) => void
// deno-lint-ignore ban-ts-comment
// @ts-ignore
reject: (arg: E) => void
constructor() {
myobie / task.ts
Created Jul 30, 2021
Very simple deno script to test that deno works
View task.ts
const res = await fetch('')
const body = new Uint8Array(await res.arrayBuffer())
await Deno.stdout.write(body)