Skip to content

Instantly share code, notes, and snippets.

View azanebrain's full-sized avatar
🤖
Jamming with the console cowboys in cyberspace

AJ Zane azanebrain

🤖
Jamming with the console cowboys in cyberspace
View GitHub Profile
@azanebrain
azanebrain / load-once.ts
Created December 10, 2017 20:08
Defers subsequent calls to an endpoint until the original call has resolved
export class LoadAThing {
private loadingTheThing = null
constructor() {}
/**
* Triggers a call to retrieve something only once
* Subsequent calls will be given the existing promise
*/
public loadThingAsync(): Promise<Environment> {
// Only attempts the call if it is not currently loading
public myForm: FormGroup
constructor(private formBuilder: FormBuilder) { }
ngOnInit() {
this.myForm = this.formBuilder.group({
enabledControl: ['hello'],
disabledControl: [{
value: 'world',
disabled: true
export interface MyFormValues {
captcha: number;
password: string;
username: string;
}
export interface MyForm extends FormGroup {
value: MyFormValues;
controls: {
captcha: AbstractControl;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MyComponentModule],
providers: [
{ provide: SomeSingletonService, useValue: new SomeSingletonServiceMock() }
]
})
.overrideComponent(MyCompComponent, {
set: {
providers: [
@azanebrain
azanebrain / class-awesome-plugin.php
Last active March 20, 2018 04:58
Adds a link to plugin documentation in the plugin description ~ http://azanebrain.github.io/news/adding-plugin-doc-link
/**
...
* Plugin Name: AJ's Amazing Things Plugin
* Plugin URI: mysite.com
* Description: This plugin does amazing things! Visit the <a href="https://mysite.com/amazing-things/docs" target="_blank">documentation site</a> for usage instructions.
...
*/
<form [formGroup]="myForm">
<select formControlName="meal">
<option [value]="'dinoburger-special'">Dinoburger Special</option>
<option [value]="'caveman-classic'">Caveman Classic</option>
</select>
<input type="number" formControlName="quantity">
<div formGroupName="extras">
Pickup:
<input type="checkbox" formControlName="pickup">
<select multiple formControlName="sides">