Skip to content

Instantly share code, notes, and snippets.

View myobie's full-sized avatar

Nathan myobie

View GitHub Profile
@myobie
myobie / application.ex
Last active November 19, 2020 14:48
Gentle request task in elixir
defmodule Gentle.Application do
use Application
def start(_type, _args) do
children = [
{Task.Supervisor, name: Gentle.TaskSupervisor}
]
opts = [strategy: :one_for_one, name: Gentle.Supervisor]
Supervisor.start_link(children, opts)
@myobie
myobie / ci.yml
Last active September 20, 2023 09:26
Don't run GitHub Actions for pull requests that are drafts
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
@myobie
myobie / .eslintrc.js
Last active August 10, 2020 14:01
How to setup a hugo repo (or any static website) with eslint and the standard config
module.exports = {
root: true,
env: {
browser: true,
mocha: true
},
globals: {
expect: true
},
plugins: [],
@myobie
myobie / .eslintrc.js
Created July 17, 2020 15:23
My eslint config for typescript projects
module.exports = {
root: true,
env: {
browser: true,
mocha: true
},
globals: {
expect: true
},
parser: '@typescript-eslint/parser',
@myobie
myobie / service-worker.ts
Last active April 21, 2024 06:51
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
// 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
myobie / socket.ts
Created July 2, 2020 16:13
An example of how I seem to always end up wrapping the phoenix socket client
import { Socket, Channel } from 'phoenix'
import { encode, decode } from './serializer'
import createState, { UpdateCallback } from './create-state'
import { enableMapSet } from 'immer'
enableMapSet()
type MessageCallback = (payload?: unknown) => void
type ChannelState = {
@myobie
myobie / create-state.ts
Last active July 2, 2020 11:20
Make a little state object which can be updated through Immer's produce
import produce, { Draft, Immutable } from 'immer'
type Updater<S> = (state: Draft<S>) => void | S
type UpdateCallback<S> = (state: Immutable<S>) => void
type State<T> = {
current: Immutable<T>;
update: (updater: Updater<T>) => void;
onUpdate: (cb: UpdateCallback<T>) => void;
}
@myobie
myobie / .gitignore
Last active June 5, 2020 07:13
Download and compile libsodium to wasm using wasi-sdk
/tmp/
/lib/
@myobie
myobie / .gitignore
Last active June 3, 2020 11:33
wasi-sdk release binaries example
/src/
/tmp/
@myobie
myobie / ci.yml
Created May 27, 2020 15:31
Extremely satisfying to have playwright running on all OS's for all browsers
on: [push]
jobs:
lint-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest