Skip to content

Instantly share code, notes, and snippets.

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

Sukhpinder Singh ssukhpinder

🏠
Working from home
View GitHub Profile
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info"
internalLogFile="c:\temp\internal-nlog.txt">
<!-- enable asp.net core layout renderers -->
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(LogLevel.Trace);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace FileLoggingNlog
{
interval(1000) // run every 1 second
.pipe(
startWith(0),
switchMap(() => /* API or Function call */)
)
.subscribe(
res => {},
error=>{}
);
import flask
from flask import request, jsonify
def main():
query_parameters = request.args
number1 = int(request.args.get(‘number1’))
number2 = int(request.args.get(‘number2’))
return jsonify({‘total’: number1+number2}), 200
import flask
from flask import request, jsonify
import json
def main():
if not request.json:
abort(400)
jsonBody =request.json[“numbers”]
number1=int(jsonBody[0][‘number1’])
number2=int(jsonBody[1][‘number2’])
return jsonify({‘total’:number1+number2}), 200
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import {AuthGuardService} from './auth-guard.service';
import { HomeComponent } from './home/home.component'
@NgModule({
declarations: [
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AuthenticationGuard } from './authentication.guard';
const routes: Routes = [
{ path: '*', pathMatch: 'full', redirectTo: 'home' },
{ path: 'home', component: HomeComponent, canActivate: [AuthenticationGuard] }
];
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class AuthGuardService {
constructor() {
}
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthGuardService } from './auth-guard.service';
@Injectable({
providedIn: 'root'
})
export class AuthenticationGuard implements CanActivate {
constructor(private authService: AuthGuardService) { }