Skip to content

Instantly share code, notes, and snippets.

View pnutmath's full-sized avatar
🌏
Focusing

Abhay pnutmath

🌏
Focusing
View GitHub Profile
@pnutmath
pnutmath / readme.md
Last active March 5, 2019 06:25
Angular Deployment on IIS

Deploy Angular Application on IIS

To work PathLocationStrategy we need to provide rewrite rules

If the app uses the Angular router, you must configure the server to return the application's host page (index.html) when asked for a file that it does not have.

  • Add web.config file in src/ folder
  • add web.config file name in assets of angular.json file so it will available in output folder after build

Must be set `` in index.html

@pnutmath
pnutmath / check-for-update.service.ts
Created March 7, 2019 09:23
Check for PWA application updates in Angular
import { ApplicationRef, Injectable } from '@angular/core';
import { SwUpdate } from '@angular/service-worker';
import { concat } from 'rxjs/observable/concat';
import { interval } from 'rxjs/observable/interval';
import { first } from 'rxjs/operators';
import { NGXLogger } from 'ngx-logger';
import { environment } from 'environments/environment';
import { DialogService } from './dialog.service';
@Injectable()
@pnutmath
pnutmath / angular-add-to-home-screen.component.ts
Last active March 12, 2021 20:15
Angular - Add to home screen POC (app.component.ts)
import { Component, HostListener } from '@angular/core';
@Component({
selector: 'app-root',
template: '<button (click)="addToHomeScreen()" *ngIf="showButton">Add to Home Scree</button>',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
deferredPrompt: any;
@pnutmath
pnutmath / scrape-and-post-to-discourse.js
Last active July 27, 2023 10:18
Scrape documentation and post to QnAs discourse
import fetch from 'node-fetch';
import cheerio from 'cheerio';
import { Configuration, OpenAIApi } from 'openai';
const OPENAI_API_KEY = '<YOUR_OPENAI_API_KEY>';
const DISCOURSE_SERVER_URL = '<YOUR_DISCOURSE_SERVER_URL>';
const DISCOURSE_API_KEY = '<YOUR_DISCOURSE_API_KEY>';
const DISCOURSE_POST_CREATORS = ['<CREATOR1>', '<CREATOR2>'];
const DISCOURSE_PRODUCT_MODERATORS = ['<MODERATOR1>', '<MODERATOR2>'];
const CATEGORY_ID = 1;