Skip to content

Instantly share code, notes, and snippets.

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

Tanmay Dharmaraj TanmayDharmaraj

🏠
Working from home
View GitHub Profile
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
if ($host.Name -eq 'ConsoleHost') {
Import-Module PSReadLine
}
<#
Install Commands - Commented out for faster execution.
If this is the first time you are running this - uncomment the below to automate installation
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#ff479c",
"foreground": "#ffffff",
"leading_diamond": "\ue0b6",
@TanmayDharmaraj
TanmayDharmaraj / ng-interceptor.js
Created January 31, 2018 14:09
http interceptor
(function (angular) {
angular.module('my')
.factory('customHttpInterceptor', ['HTML', function (html) {
return {
request: function (config) {
if (config.url.indexOf('views/') > 0) {
if(config.url.indexOf('deployments-history/history.html') > 0){
console.log("called history");
}
var key = config.url.replace("Scripts/dist/", "")
@TanmayDharmaraj
TanmayDharmaraj / rev-manifest-html.js
Created January 31, 2018 14:05
Angular config constant.
(function () {
return angular.module("my.constants").constant("HTML", {
"views/modules/applications/applications.html": "views/modules/applications/applications.html",
"views/modules/home/home.html": "views/modules/home/home.html"
});
})();
@TanmayDharmaraj
TanmayDharmaraj / gulp-html-revision-task.js
Created January 31, 2018 13:47
A gulp task to create revisions for angular tempaltes
const gulp = require('gulp');
const rev = require('gulp-rev');
const b2v = require('buffer-to-vinyl');
const ngConfig = require('gulp-ng-config');
gulp.task("revision-html", function () {
return gulp.src(["./Scripts/dist/**/*.html"])
.pipe(rev())
.pipe(gulp.dest("./Scripts/dist"))
.pipe(rev.manifest("rev-manifest-html.json"))
@TanmayDharmaraj
TanmayDharmaraj / ApiExceptionFilter.cs
Created December 20, 2017 06:29
Exception filter
public class ApiExceptionFilter : ExceptionFilterAttribute
{
private IGlobalStore _gStore { get; set; }
public override void OnException(HttpActionExecutedContext actionExecutedContext)
{
var scope = actionExecutedContext.Request.GetDependencyScope();
var _gStoreFactory = scope.GetService(typeof(IGlobalStore)) as IGlobalStore;
string correlationId = "";
//Good to check if _gStore is null to avoid null exception.
@TanmayDharmaraj
TanmayDharmaraj / Startup.DI.cs
Created December 20, 2017 06:28
Sample DI setup
var builder = new ContainerBuilder();
var config = GlobalConfiguration.Configuration;
//This provides HTTPContext
builder.RegisterModule(new AutofacWebTypesModule());
//..
//Other registrations
//..
builder.RegisterType&amp;lt;GlobalStore&amp;gt;()
@TanmayDharmaraj
TanmayDharmaraj / GlobalStore.cs
Created December 20, 2017 06:26
Implementation of IGlobalStore
public class GlobalStore : IGlobalStore
{
private string CorrelationId { get; set; }
private string RequestId { get; set; }
public GlobalStore() { }
public GlobalStore(CorrelationContext correlation_context)
{
if (correlation_context != null)
@TanmayDharmaraj
TanmayDharmaraj / IGlobalStore.cs
Created December 20, 2017 06:26
Global store interface
public interface IGlobalStore
{
string GetCorrelationId();
string GetRequestId();
}
@TanmayDharmaraj
TanmayDharmaraj / gulp-revision.task.js
Created December 20, 2017 06:18
Sample gulp task to create revisioned file
const gulp = require('gulp');
const rev = require('gulp-rev');
gulp.task("revision", function () {
return gulp.src(["./Scripts/dist/**/*.js", "./Scripts/dist/**/*.css"])
.pipe(rev())
.pipe(gulp.dest("./Scripts/dist"))
.pipe(rev.manifest())
.pipe(gulp.dest("./Scripts"));
});