Skip to content

Instantly share code, notes, and snippets.

View NickBolles's full-sized avatar

Nick Bolles NickBolles

View GitHub Profile
export class ResolvablePromise<T = any> implements Promise<T> {
[Symbol.toStringTag]: string;
__promise: Promise<T>;
resolve!: (value: T) => void;
reject!: (reason: T) => void;
constructor() {
this.__promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
/*
Ahoy Matey!
Welcome to the seven seas.
You are the captain of a pirate ship.
You are in battle against the royal navy.
You have cannons at the ready.... or are they?
@NickBolles
NickBolles / onLoginMixin.ts
Created February 25, 2019 15:30
Nuxt On Login mixin
import { Component, Vue } from "vue-property-decorator";
const DEFAULT_REDIRECT = "home";
type redirectFn = () => string;
// You can declare a mixin as the same style as components.
@Component
export default class OnLoginMixin extends Vue {
protected redirect?: string | redirectFn = DEFAULT_REDIRECT;
protected watchLogin?: boolean = true;
@NickBolles
NickBolles / auth-management-notifier.ts
Created December 6, 2018 19:14
Authentication-local-management notifier
import { Application } from "@feathersjs/feathers";
import { join } from "path";
import pug from "pug";
import sender from "./notifier";
import { isString, isFunction } from "util";
import { stringify } from "querystring";
const isProd = process.env.NODE_ENV === 'production'
const encodeOpt = { encodeURIComponent: (str) => str }
@NickBolles
NickBolles / seed-data.ts
Last active November 20, 2018 22:25
Feathers seed-data modifications
/* tslint:disable:no-console */
import { join } from 'path';
import { readJsonFileSync } from '@feathers-plus/test-utils';
import { App } from './app.interface'
// !code: imports // !end
// Determine if command line argument exists for seeding data
let ifSeedServices = ['--seed', '-s'].some(str => process.argv.slice(2).includes(str));
@NickBolles
NickBolles / getDeepProperty.js
Created February 17, 2016 04:13
Get a deep property of a javascript object. Accepts a property in the form 'foo.bar.deepProp.reallyDeepProp'
/**
* Get the value of a property that is nested in several objects given a string of properties in the form
* 'foo.bar.deepProp.reallyDeepProp' would return the value 'whew that was deep' from the object
* { foo: {
* bar: {
* deepProp:{
* reallyDeepProp: 'whew that was deep'
* }
* }
* }
@NickBolles
NickBolles / designer.html
Last active August 29, 2015 14:13
designer
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icons/core-icons.html">
<script>
PolymerExpressions.prototype.json = function(object) {
return JSON.stringify(object);
}
</script>
@NickBolles
NickBolles / designer.html
Created January 14, 2015 03:16
designer
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icons/core-icons.html">
<script>
PolymerExpressions.prototype.json = function(object) {
return JSON.stringify(object);
}
</script>
@NickBolles
NickBolles / designer.html
Last active August 29, 2015 14:13
designer
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icons/core-icons.html">
<script>
PolymerExpressions.prototype.json = function(object) {
return JSON.stringify(object);
}
</script>
@NickBolles
NickBolles / designer.html
Created January 14, 2015 02:51
designer
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-selector/core-selector.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icons/core-icons.html">
<script>
PolymerExpressions.prototype.json = function(object) {
return JSON.stringify(object);
}