Skip to content

Instantly share code, notes, and snippets.

View TaylorAckley's full-sized avatar

Taylor Ackley TaylorAckley

View GitHub Profile
@TaylorAckley
TaylorAckley / curried-search.ts
Created August 20, 2021 16:01
Search with Curry
export class GithubSearchCurryService extends BaseGithubSearch {
searchClient!: (term: string) => Observable<any>;
constructor(http: HttpClient) {
super(http)
}
/**
* Execute a search - calling this consecutively will page through results
*/
search(term: string) {
import { HttpClient } from '@angular/common/http';
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
selector: 'hello',
template: `<h1>Hello!</h1>`,
styles: [`h1 { font-family: Lato; }`]
})
@TaylorAckley
TaylorAckley / nested-observable-switchmap.ts
Created February 22, 2021 20:24
Return from nested observable
import { Observable, of } from "rxjs";
import { switchMap, map } from "rxjs/operators";
class DataFactory {
static getSetupData() {
return of({ param1: "someparam" });
}
static getUsefulData(setupData: any) {
// pretend we use setupData in some fancy way
@TaylorAckley
TaylorAckley / nested-observable-create.ts
Created February 22, 2021 20:23
Return value from nested observable using Observable.create
import { Observable, of, Subject } from "rxjs";
class DataFactory {
static getSetupData() {
return of({ param1: "someparam" });
}
static getUsefulData(setupData: any) {
// pretend we use setupData in some fancy way
return of({ datapoint: "x" });
@TaylorAckley
TaylorAckley / nested-observable.ts
Last active February 22, 2021 20:23
Nested Observable
// returns the outermost subscription, which is not what we want.
someMethod(): Observable<string> {
return this.someService.getSetupData().subscribe(setupData => {
this.someOtherService.getUsefulData(setupData).subscribe(usefulData => {
return of(usefulData.someString);
})
});
}
-- psuedo code, example.
INSERT INTO LocaleKeys (LocaleKey, LocaleKeyValue, Locale, Templates) VALUES N'TITLE_LOGIN', N'Login to your account', N'en-us', N'LOGIN_PAGE, SIDE_MENU'
INSERT INTO LocaleKeys (LocaleKey, LocaleKeyValue, Locale, Templates) VALUES N'TEXT_LOGIN', N'Already have an account? <a href="/login">Login Here</a>', N'en-us', N'LOGIN_PAGE'
INSERT INTO LocaleKeys (LocaleKey, LocaleKeyValue, Locale, Templates) VALUES N'APIERROR_UNKOWN', N'An unkown error happened processing your request.', N'en-us', N'*''
@TaylorAckley
TaylorAckley / prereq.script.js
Created December 11, 2018 18:15
Postman Pre-Request Script
// For usage in Postman as Pre-Request Script to get token.
// Requires a environment file with 'client', 'secret', 'url' and 'authorization' key/value pairs. (leave the authorization key blank)
pm.sendRequest({
url: pm.environment.get("url") + '/auth/token',
method: 'POST',
header: {
"content-type": "application/x-www-form-urlencoded"
},
body: {
@TaylorAckley
TaylorAckley / link.ts
Created November 8, 2018 19:01
HATEOS Pipe
@TaylorAckley
TaylorAckley / hateos.link.js
Created November 8, 2018 18:42
HATEOS PIPE
@TaylorAckley
TaylorAckley / account.store.js
Last active October 8, 2018 01:04
MVC Store
const User = require('../models/user.model');
const moment = require('moment');
class AccountStore {
static async register(req) {
let user = new User(req);
try {
return await user.save();
} catch(exception) {