Skip to content

Instantly share code, notes, and snippets.

View elgervb's full-sized avatar

Elger van Boxtel elgervb

View GitHub Profile
@elgervb
elgervb / stencil.directive.ts
Created June 18, 2020 22:09
StencilJS Angular ControlValueAccessor
import { Directive, forwardRef, ElementRef, Provider, OnDestroy } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
export const STENCIL_VALUE_ACCESSOR: Provider = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => StencilDirective),
multi: true
};
@elgervb
elgervb / mocking.ts
Created January 22, 2020 15:21
testing / mocking TS
function getMock<T>(partial: Partial<T>): T {
return { ...partial } as T;
}
import { Injectable } from "@angular/core";
/**
* Angular scroll service
*/
@Injectable({
providedIn: "root"
})
export class ScrollService {
@elgervb
elgervb / debug.pipe.ts
Last active November 8, 2023 19:35
Angular debug pipe to debug values in templates
import { Pipe, PipeTransform } from '@angular/core';
/**
* Debug pipe to debug template statements.
* It will always return the value it gets passed, so we can pipe it along with other pipes.
*
* @example
* ```
<!-- only log to console -->
<compA [binding]= "someObj | smtDebug"></compA>
@elgervb
elgervb / networkspace2-ssh
Created December 7, 2018 20:44
Networkspace2 ssh access through php script
// source: http://lacie.nas-central.org/wiki/Enabling_ssh_through_uploading_a_PHP_script_(Network_space_2)
<?php
/******************************************************
* Enable SSH root access on Lacie Network Space 2 (v1.0.2 & v1.2.5)
*
* - Use puttygen to create a public/private key pair
* - Save the public and private key to your computer
* - Copy the key from the puttygen box "Public key for pasting into OpenSSH authorized_keys file"
* - Paste the key into this script in the $sshkey variable below.
@elgervb
elgervb / snippets.css
Last active December 12, 2018 09:46
css snippets
.rainbow {
background-image: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
width: 100%;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
}
// draws a grid
@elgervb
elgervb / launch.json
Last active January 8, 2019 07:33
VSCode launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200/",
"runtimeArgs": [
"--user-data-dir=c:\\temp\\ngx-components",
@elgervb
elgervb / try-catch-stringify.js
Created April 9, 2018 10:29
JSON.stringigy with try...catch
const stringify = JSON.stringify;
JSON.stringify = (data) => {
try {
return stringify(data);
} catch(ex) {
debugger;
}
};
@elgervb
elgervb / core.module.ts
Last active April 5, 2018 11:05
Angular CoreModule
@NgModule({
imports: [
...
],
providers: [
...
],
exports: [
...
]