Skip to content

Instantly share code, notes, and snippets.

Avatar
👻
A ghost

Nathan myobie

👻
A ghost
View GitHub Profile
@myobie
myobie / tests.ts
Created Jan 7, 2021
Build tests with esbuild, serve them with vercel's serve-handler, then use playwright to open a browser and stream the console back to the node console
View tests.ts
// NOTE: we are just assuming _tests is an alright place to render to
export async function buildAndRunTests (cwd: string): Promise<void> {
const [{ once }] = cliopts.parse(
['o, once', 'run the tests and then exit']
)
await file.mkdirs(join(cwd, '_tests'))
await buildBrowserTests(cwd)
@myobie
myobie / estrella-utils.cjs
Created Jan 4, 2021
Build a project with estrella by convention using the settings in package.json
View estrella-utils.cjs
/* eslint-disable @typescript-eslint/no-var-requires */
const { join } = require('path')
const { build, file, cliopts } = require('estrella')
module.exports = {
buildPackage,
buildBrowserAndNodeModule,
buildBrowserModule,
buildNodeModule
@myobie
myobie / tsc-build.cjs
Created Jan 4, 2021
Alternative to estrella's tslint; instead use tsc --build so we can choose to produce declaration files (.d.ts)
View tsc-build.cjs
/* eslint-disable @typescript-eslint/no-var-requires */
const perf = require('perf_hooks')
const { spawn } = require('child_process')
const { cliopts, fmtDuration, findInPATH, log, stdoutStyle } = require('estrella')
module.exports = {
clock,
tscBuild
}
@myobie
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
myobie / clone.sh
Created Nov 23, 2020
Keep things organized with a clone bash function which always puts repos into the correct place
View clone.sh
clone() {
org=$(echo $1 | awk -F/ '{ print $1 }')
mkdir -p ~/src/github.com/$org
path=~/src/github.com/$1
git clone $@ $path
cd $path
}
# Examples:
# $ clone myobie/dot-files
@myobie
myobie / application.ex
Last active Nov 19, 2020
Gentle request task in elixir
View application.ex
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 / example-template-usage.html
Last active Aug 30, 2020
Recursively list out sections and pages for a nice hugo navigation for a section or site
View example-template-usage.html
{{ define "main" }}
<div id="wrapper">
<div id="sidebar">
{{ partial "sidebar-sections-list.html" .Site.Sections }}
</div>
<div id="content">
<!-- ... -->
</div>
</div>
{{end}}
@myobie
myobie / ci.yml
Last active Aug 26, 2020
Don't run GitHub Actions for pull requests that are drafts
View ci.yml
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
@myobie
myobie / timer.swift
Last active Aug 21, 2020
GCD Timer using DispatchSourceTimer
View timer.swift
import Cocoa
import Combine
class Timer: Cancellable, Publisher {
enum Error: Swift.Error {
case cancelled
}
typealias Output = Never
typealias Failure = Error
@myobie
myobie / .eslintrc.js
Last active Aug 10, 2020
How to setup a hugo repo (or any static website) with eslint and the standard config
View .eslintrc.js
module.exports = {
root: true,
env: {
browser: true,
mocha: true
},
globals: {
expect: true
},
plugins: [],