Skip to content

Instantly share code, notes, and snippets.

A ghost

Nathan myobie

A ghost
View GitHub Profile
myobie / .eslintrc.js
Created Jul 17, 2020
My eslint config for typescript projects
View .eslintrc.js
module.exports = {
root: true,
env: {
browser: true,
mocha: true
globals: {
expect: true
parser: '@typescript-eslint/parser',
myobie / AppDelegate.swift
Last active Jul 11, 2020
How to setup a custom UIWindow, UICollectionViewController, UICollectionView, and UICollectionViewCell in a iOS9 swift project
View AppDelegate.swift
import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var controller = Controller()
override init() {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
myobie / service-worker.ts
Last active Jul 3, 2020
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 / socket.ts
Created Jul 2, 2020
An example of how I seem to always end up wrapping the phoenix socket client
View socket.ts
import { Socket, Channel } from 'phoenix'
import { encode, decode } from './serializer'
import createState, { UpdateCallback } from './create-state'
import { enableMapSet } from 'immer'
type MessageCallback = (payload?: unknown) => void
type ChannelState = {
myobie / create-state.ts
Last active Jul 2, 2020
Make a little state object which can be updated through Immer's produce
View create-state.ts
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 / 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 / .gitignore
Last active Jun 5, 2020
Download and compile libsodium to wasm using wasi-sdk
View .gitignore
myobie / .gitignore
Last active Jun 3, 2020
wasi-sdk release binaries example
View .gitignore
myobie / ci.yml
Created May 27, 2020
Extremely satisfying to have playwright running on all OS's for all browsers
View ci.yml
on: [push]
runs-on: ${{ matrix.os }}
- ubuntu-latest
- macos-latest
myobie / next-tick.ts
Last active May 6, 2020
Do some work next time the event loop is free
View next-tick.ts
export function nextTick<O> (cb: () => O | Promise<O>): Promise<O> {
return new Promise((resolve, reject) => {
requestAnimationFrame(() => {
.then(value => resolve(value))
.catch(e => reject(e))
You can’t perform that action at this time.