Skip to content

Instantly share code, notes, and snippets.

View pjlamb12's full-sized avatar
🏠
Working from home

Preston Lamb pjlamb12

🏠
Working from home
View GitHub Profile
@pjlamb12
pjlamb12 / demo.component.spec.ts
Created May 18, 2023 21:13
Unit Test for Component
import { FormBuilder } from '@angular/forms';
import { of } from 'rxjs';
import { DemoComponent } from './demo.component';
describe('DemoComponent', () => {
let component: DemoComponent;
let mockDeviceFulfillmentService;
const mockFormBuilder = new FormBuilder();
let mockActivatedRoute;
let mockAlertToasterService;
@pjlamb12
pjlamb12 / Dockerfile
Created December 6, 2022 15:29
Dockerfile for running the Node app with puppeteer
FROM node:18 as node-build
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
# Install Google Chrome Stable and fonts
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
@pjlamb12
pjlamb12 / data-table.component.html
Created November 26, 2022 23:49
Angular Data Table Component
<content-section
[csTitle]="title"
[collapsible]="collapsible"
[state]="state"
[locked]="locked"
[noButtons]="noButtons"
[buttons]="_buttons"
>
<!-- Custom controls -->
<ng-content></ng-content>
@pjlamb12
pjlamb12 / nx-ci.yml
Created October 26, 2022 15:43
Nx CI GitHub Actions Workflow
name: Nx Affected CI Linting/Tests/Build
on:
pull_request:
branches: [master]
env:
NX_BRANCH: ${{ github.event.number }}
NX_RUN_GROUP: ${{ github.run_id }}
@pjlamb12
pjlamb12 / button-styles.util.ts
Created February 2, 2021 04:13
Custom Tailwind Button Directive
export const DEFAULT_BUTTON_STYLES =
'px-5 py-3 text-white text-sm text-center uppercase font-semibold tracking-wide rounded-lg hover:shadow-md focus:outline-none focus:shadow-outline transition duration-300';
export const BUTTON_COLOR_STYLES = {
orange: 'bg-orange-500 hover:bg-orange-600 active:bg-orange-600',
green: 'bg-green-500 hover:bg-green-600 active:bg-green-600',
red: 'bg-red-500 hover:bg-red-600 active:bg-red-600',
blue: 'bg-blue-500 hover:bg-blue-600 active:bg-blue-600',
};
@pjlamb12
pjlamb12 / tailwind-theme.service.spec.ts
Last active January 21, 2021 20:19
Tailwind Theme Service and test
import { waitForAsync } from '@angular/core/testing';
import { TailwindThemeService } from './tailwind-theme.service';
import { of, throwError } from 'rxjs';
import { TailwindThemeConfig } from '../tailwind-theme-config.class';
import * as mockTailwindUtilFunctions from '@workspace/shared/util';
describe('Shared Tailwind Theme Service', () => {
let tailwindThemeService: TailwindThemeService;
let mockConfig: TailwindThemeConfig = {
@pjlamb12
pjlamb12 / app.module.ts
Last active July 11, 2023 22:23
Tailwind Theme Loader Service
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TailwindThemeModule } from './tailwind-theme';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
@NgModule({
declarations: [AppComponent],
imports: [
@pjlamb12
pjlamb12 / app.module.ts
Last active December 7, 2020 23:06
SVG Icon Manager Module for Angular using the angular-svg-icon library
@NgModule({
imports: [
IconManagerModule.forRoot({ configUrl: './assets/icons/heroicons.json' }),
]
})
export class AppModule {}
pdf_book:
pandoc_args: --listings
includes:
in_header: preamble.tex
@pjlamb12
pjlamb12 / google-analytics.service.ts
Created August 21, 2020 22:33
Example Google Analytics service for Angular apps
import { Injectable, Renderer2, Inject, RendererFactory2 } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { RuntimeConfigLoaderService } from 'runtime-config-loader';
import { Router, RouterEvent, NavigationEnd } from '@angular/router';
import { filter, tap } from 'rxjs/operators';
declare let gtag: Function;
@Injectable({
providedIn: 'root',