Skip to content

Instantly share code, notes, and snippets.

View peterbsmyth's full-sized avatar

Peter B Smith peterbsmyth

View GitHub Profile
export async function search(term: string) {
const response = await fetch(
'https://services6.arcgis.com/bdPqSfflsdgFRVVM/arcgis/rest/services/Trash_Day_Schedule/FeatureServer/2/query?where=StName%20%3D%20%27' +
term +
'%27&outFields=*&outSR=4326&f=json'
);
const data = await response.json()
return data;
}

Why should you have a Browser Application behind a VPN?

Intro

Your company runs on a private network. Your employees access that network from home using a VPN. Every day your company relies on that connection to keep your data safe.

Definitions

Web: The public web is the collection of sites that start have a www prefix.
VPN: The private network that your company firewalls it's sensitive data behind.
Browser Application: Any application that runs in a web browser such as Chrome, Internet Explorer, Edge, and Firefox.

@peterbsmyth
peterbsmyth / build.sh
Last active July 14, 2023 05:03
Using Environment Variables at Build for NativeScript
tns build ios --release --bundle --env.launch
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
import { ActivatedRoute, Router } from '@angular/router';
import {
BoardCardData,
loadDescendantsFromProgramPage,
openWorkoutModal,
ProgramsFacade,
selectProgramFromPage,
@peterbsmyth
peterbsmyth / recipe.example.md
Last active May 21, 2020 13:39
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@Injectable()
export class Effects {
getPending$ = createEffect(() =>
this.actions$.pipe(
ofType(ApprovalActions.getAllPendingApprovals),
switchMap(res =>
this.apiService.getAllPendingApprovals()
),
map((approvals) => ApprovalActions.getAllPendingApprovalsComplete({ approvals }))
)
function reqListener() {
var data = JSON.parse(this.responseText);
console.log(data);
}
function reqError(err) {
console.log('Fetch Error :-S', err);
}
var request = new XMLHttpRequest();
@peterbsmyth
peterbsmyth / api.base-service.ts
Created October 29, 2019 14:59
Sharing API Services on Web and Mobile
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Dashboard } from '~/app/models';
@Injectable({
providedIn: 'root'
})
export abstract class ApiBaseService {
@peterbsmyth
peterbsmyth / actions.ts
Created June 1, 2019 23:32
ngrx 8 createEffect
import { createAction, props } from '@ngrx/store';
export const get = createAction(
'[Job] get'
);
export const getComplete = createAction(
'[Job] getComplete',
props<{ job: any }>()
);
@peterbsmyth
peterbsmyth / actions.ts
Last active June 1, 2019 23:23
ngrx 8 `on` function
import { createAction, props } from '@ngrx/store';
export const get = createAction(
'[Job] get'
);
export const getComplete = createAction(
'[Job] getComplete',
props<{ job: any }>()
);