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 {

Keybase proof

I hereby claim:

  • I am openam on github.
  • I am openam (https://keybase.io/openam) on keybase.
  • I have a public key ASB6PCk7-1_Qo8LqHABHiWGB3ollnif5gYem9RO_TNbdKAo

To claim this, I am signing this object:

@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 / compare-branches.sh
Created February 24, 2015 16:27
Check for commits on one branch that are not in another branch, and export them to the desktop.
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "
Usage: compare-branches baseBranch compareBranch
Shows what commits exist in the second branch that are not in the first"
exit
fi
@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 '-';

Setup

General

# setup and install protractor for testing
npm install -g protractor
npm install -g karma-cli
webdriver-manager update

# prepare local application
@openam
openam / less.sh
Created April 28, 2014 16:38
Compile Less with Source Map
#!/bin/sh
lessc css/styles.less > css/styles.css --source-map=css/styles.css.map --source-map-basepath=css/
NOW=$(date)
echo "Recompiling less completed $NOW"
@openam
openam / get_directories.php
Created February 26, 2014 17:27
Returns a list of sub-directories given a starting path. Uses DirectoryIterator class.
<?php
/**
* get_directories description
*
* @param string $path the path to start from
* @param string $regex that the directories must match, use empty string '' for all
* @return array of directories in the path
*/
function get_directories($path = '.', $regex = '') {
$list = array();
@openam
openam / debug.php
Created February 26, 2014 17:25
A simple PHP debug function, similar to CakePHP
<?php
/**
* debug is a simple function to show which line and file a debug call came from
* including the contents of print_r() wrapped in a <pre> tag
*
* @param string $value
* @return void
*/
function debug($value = '') {
$backtrace = debug_backtrace();
@openam
openam / directoryIterator.php
Created February 26, 2014 17:22
Directory Iterator class for PHP 4
<?php
/**
* @category PHP4 DirectoryIterator class
* @version 0.0.1
* @author Adrian Rotea <[email protected]>
* @copyright Copyright © 2005, Adrian Rotea <[email protected]>
* @link http://www.weberdev.com/get_example.php3?ExampleID=4180
*
* This class implements the SPL DirectoryIterator in PHP4.
* Very usefull if wanting to traverse directories in an OO style