Skip to content

Instantly share code, notes, and snippets.

View openam's full-sized avatar
💭
...

Michael Tuttle openam

💭
...
  • Vivint Solar
  • Utah, United States
View GitHub Profile
@openam
openam / try-catch.ts
Last active March 24, 2025 19:11 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = [T, null]
type Failure<E> = [null, E]
type Result<T, E = Error> = Success<T> | Failure<E>;
// Main wrapper function
export async function tryCatch<T, E = Error>(
promise: Promise<T>,
): Promise<Result<T, E>> {
try {
@openam
openam / zsh.md
Last active August 29, 2015 14:18 — forked from tsabat/zsh.md

Prereq:

apt-get install zsh
apt-get install git-core

Install oh-my-zsh.

@openam
openam / gist:3c46586001bef21f1e0f
Last active August 29, 2015 14:13 — forked from thomseddon/gist:3511330
AngularJS byte format filter
app.filter( 'bytes', function bytesFilter () {
'use strict';
return function bytesReturn ( bytes, precision ) {
if ( bytes === 0 ) {
return '0 bytes';
}
if ( isNaN( parseFloat( bytes ) ) || !isFinite( bytes ) ) {
return '-';
@openam
openam / Default (Linux).sublime-keymap
Created November 10, 2012 19:00 — forked from coldnebo/Default (Linux).sublime-keymap
simple scripts to prettify your xml and json in sublime text 2
[
{ "keys": ["ctrl+shift+x"], "command": "tidy_xml" },
{ "keys": ["ctrl+shift+j"], "command": "prettify_json" }
]