Skip to content

Instantly share code, notes, and snippets.

View zbarbuto's full-sized avatar

zbarbuto

View GitHub Profile
@zbarbuto
zbarbuto / cascade.js
Last active April 3, 2021 22:20 — forked from CjS77/cascade.js
Loopback cascade mixin gist
// Cascade delete for loopback
// https://gist.github.com/CjS77/44b2f75c0ec468f590d0
/* jshint node:true */
'use strict';
/**
* There is an incubating feature to cascade the deletes to the relational tables. see
* https://github.com/strongloop/loopback-datasource-juggler/issues/88
*/
@zbarbuto
zbarbuto / app.module.ts
Last active December 14, 2017 00:55
Ionic ngrx/store Remote Devtools
import { NgModule } from '@angular/core';
import { RemoteDevToolsProxy } from './remote-devtools-proxy';
// ...
// Register our remote devtools if we're on-device and not in a browser
if (!window['devToolsExtension'] && !window['__REDUX_DEVTOOLS_EXTENSION__']) {
let remoteDevToolsProxy = new RemoteDevToolsProxy({
connectTimeout: 300000, // extend for pauses during debugging
ackTimeout: 120000, // extend for pauses during debugging
secure: false // dev only
import { ReduxDevtoolsExtensionConnection } from '@ngrx/store-devtools/src/extension';
export class RemoteDevToolsConnectionProxy
implements ReduxDevtoolsExtensionConnection {
constructor(public remotedev: any, public instanceId: string) {}
subscribe(listener: (change: any) => void): any {
const listenerWrapper = (change: any) => {
listener(change);
};
import { ReduxDevtoolsExtension, ReduxDevtoolsExtensionConnection } from '@ngrx/store-devtools/src/extension';
import { RemoteDevToolsConnectionProxy } from './remote-devtools-connection-proxy'
import { connect } from 'remotedev/lib/devTools';
export class RemoteDevToolsProxy implements ReduxDevtoolsExtension {
remotedev: any = null;
defaultOptions = {
realtime: true,
// Needs to match what you run `remotedev` command with and
// what you setup in remote devtools local connection settings
const join = require('path').join;
module.exports = {
'loopback-component-explorer': {
mountPath: '/explorer',
apiInfo: {
title: 'My App',
description: 'Test Explorer'
},
uiDirs: [
join(__dirname, '../explorer'),
module.exports = function(app) {
app.models().forEach(Model => {
const original = Model.sharedClass.methods;
// Iterate over each model remote method
Model.sharedClass.methods = () =>
original.call(Model.sharedClass).map(overwriteMethodProperties);
});
app.emit('modelRemoted');
};
const loopback = require('loopback');
module.exports = function(app) {
app.model(
loopback.Model.extend(
'LoginCredentials',
{
id: false,
username: 'string',
password: 'string'
@zbarbuto
zbarbuto / developer-function.ts
Created May 21, 2018 06:25
Basics of the DeveloperFunction decorator
export const DEV_FUN_KEY = `DEVELOPER_FUNCTIONS`;
export function DeveloperFunction(opts: any) {
return function(target: any, key: string) {
const metaTarget = target.constructor;
const developerFunctions = getOwnMetadata(DEV_FUN_KEY, metaTarget) || [];
if (Array.isArray(opts)) {
opts.forEach(opt => {
developerFunctions.push({
key,
...opt
@zbarbuto
zbarbuto / developer-functions-component.ts
Last active May 28, 2018 01:35
Developer function list
@Component({
template: `
<div *ngFor="let component of components">
<h4>{{ component.name }}</h4>
<button
*ngFor="let devFun of component.developerFunctions"
(click)="callMethod(component.componentInstance, devFun)">
{{ devFun.name }}
</button>
</div>
@zbarbuto
zbarbuto / tslint.json
Created November 15, 2018 08:26
Some TSLint rules that I like
{
"rulesDirectory": [
"tslint-no-focused-test"
],
"rules": {
"array-type": [true, "array"],
"arrow-return-shorthand": [true, "multiline"],
"class-name": true,
"comment-format": [true, "check-space"],
"indent": [true, "spaces"],