Skip to content

Instantly share code, notes, and snippets.

View kanthvallampati's full-sized avatar

Lakshmikanth Vallampati kanthvallampati

View GitHub Profile
@kanthvallampati
kanthvallampati / Dockerfile
Last active September 6, 2022 04:27
Sample Dockerfile to build and deploy an Angular app in Kubernetes
### STAGE 1: Build ###
FROM node:14.19.3 AS build
# Create app directory
WORKDIR /usr/src/app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install app dependencies
@kanthvallampati
kanthvallampati / detectOS.js
Last active October 25, 2021 04:39
JavaScript snippet to detect the user operating system
function detectOs() {
let userAgt = navigator.userAgent;
let os = '';
let version = '';
let regOsVersion = '';
let osMap = [
{ s : 'Windows', r:/(Windows 10.0|Windows NT 10.0|Windows 8.1|Windows NT 6.3|Windows 8|Windows NT 6.2|Windows 7|Windows NT 6.1)/},
{ s : 'Linux', r:/(Linux|X11(?!.*CrOS))/},
{ s : 'Mac OS X', r:/Mac OS X/},
{ s : 'Mac OS', r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/}
@kanthvallampati
kanthvallampati / detectBrowser.js
Last active October 20, 2021 10:59
JavaScript snippet to detect the user browser with version
function detectBrowser() {
let ua = window.navigator.userAgent;
if (ua.indexOf('Edg') > -1) {
let M = ua.match(/(Edg)\/?\s*(\.?\d+(\.\d+)*)/i);
return 'Edge '+ M[2];
} else if (ua.indexOf('OPR') > -1) {
let M = ua.match(/(OPR)\/?\s*(\.?\d+(\.\d+)*)/i);
return 'Opera '+ M[2];
} else {
let tem;
@kanthvallampati
kanthvallampati / getFiles.js
Created September 9, 2020 08:27
Get the code files in your angular application
const fs = require('fs');
const { join } = require('path');
const dir = './src/app';
const excludeExtns = [
'.html',
'.scss',
'.css',
'.sass',
'.spec.ts',