Skip to content

Instantly share code, notes, and snippets.

View spruce-bruce's full-sized avatar
🦋
Very Cool

Aaron Bruce spruce-bruce

🦋
Very Cool
View GitHub Profile
@spruce-bruce
spruce-bruce / CustomError.ts
Created November 5, 2022 23:49
Custom errors in typescript
/**
 * This CustomError type can safely be extened and your custom errors
 * will show up nicely in logs and anywhere else for that matter.
 *
 * Javascript errors break the prototype chain so if you want nice
 * errors that you can extend you need to do some work to restore it.
 *
 * shamelessly stolen from https://stackoverflow.com/a/48342359
 *****************/
export abstract class CustomError extends Error {
@spruce-bruce
spruce-bruce / ChangeMonitor.js
Created June 25, 2019 03:08
Proposed api for ChangeMonitor
import ChangeMonitor from 'ChangeMonitor';
ChangeMonitor.registerDiffEngine('bookshelf', (m1, m2) => {
/* diff the two objects */
return { field: [previousValue, currentValue] };
});
ChangeMonitor.registerHandler('user', 'name', (user, previousValue, currentValue) => {
console.log(`user name is now ${steve}`);
}, { diffEngine: 'bookshelf|objection|javascript|custom' });
@spruce-bruce
spruce-bruce / react-native-sqlite-migrations.js
Last active November 22, 2022 13:27
Sqlite migrations for react native for use with react-native-sqlite-storage and react-native-sqlite-2
/**
* this class decides what migrations to run and runs them
*/
class RNSqliteMigrator {
constructor(db) {
this._db = db;
this.initialize();
this._migrationsMap = {};
@spruce-bruce
spruce-bruce / js-vim-config.md
Last active February 8, 2017 22:08
Setting up vim for javascript development

Setting up vim for javascript development

Even though most of this stuff has nothing to do with javascript

Install vim 8

The newest version of vim won't necessarily be the version you have installed. Run vim --version to check your version. brew install vim --override-system-vim is the easiest way to install the latest version on mac.

Plugins

TODO

Colors