Skip to content

Instantly share code, notes, and snippets.

@rnarayana
rnarayana / SetupWSL.md
Last active February 1, 2022 05:24
Setting up docker and k8s on WSL
  1. Install docker, kubectl, helm, minikube and dapr using instructions here
  2. Update ~/.bashrc to include the below script to start docker and minikube if not running on startup.
# Start Docker daemon automatically when logging in if not running.
DOCKER_RUNNING=`ps aux | grep dockerd | grep -v grep`
if [ -z "$DOCKER_RUNNING" ]; then
    echo "Starting docker daemon..."
    sudo dockerd > /dev/null 2>&1 &
 disown
@rnarayana
rnarayana / $PROFILE
Last active March 28, 2024 03:57
Windows Terminal Configuration
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
Import-Module posh-git
$env:POSH_GIT_ENABLED = $true
Import-Module PSKubectlCompletion
Set-Alias k -Value kubectl
//From https://github.com/expressjs/express/issues/3308
function getRoutesOfLayer(path: string, layer: any): string[] {
if (layer.method) {
return [layer.method.toUpperCase() + " " + path];
} else if (layer.route) {
return getRoutesOfLayer(
path + split(layer.route.path),
layer.route.stack[0]
);
@rnarayana
rnarayana / xUnitTestMethodSnippet.snippet
Created October 7, 2018 06:20
XUnit.Net Unit Test Snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets
xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>xUnit test method template</Title>
<Author>Narayana Rengaswamy</Author>
<Description>Adds a xUnit Test method</Description>
<Shortcut>xut</Shortcut>
</Header>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<common>
@rnarayana
rnarayana / test.html
Created April 16, 2014 04:48
AngularJS: Log without injecting $log in all controllers
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.5/angular.min.js"></script>
<script src="testapp.js"></script>
</head>
<body ng-app="app">
<div ng-controller="LogCtrl">
<p>Reload this page with open console, enter text and hit the log button...</p>
@rnarayana
rnarayana / gist:8905229
Last active August 29, 2015 13:56
WebAPI - CORS from Angular - PUT method
2014-02-09 20:14:44.9341|Info|67| Method: OPTIONS;Operator: ;Operation: ;Message: http://localhost:63019/buildings/1105
2014-02-09 20:14:44.9341|Info|68| Method: OPTIONS;Operator: CorsMessageHandler;Operation: SendAsync;Message:
2014-02-09 20:14:44.9421|Info|69| Method: OPTIONS;Operator: AttributeBasedPolicyProviderFactory;Operation: GetCorsPolicyProvider;Message: CorsRequestContext: 'Origin: http://localhost:49595, HttpMethod: OPTIONS, IsPreflight: True, Host: localhost:63019, AccessControlRequestMethod: PUT, RequestUri: http://localhost:63019/buildings/1105, AccessControlRequestHeaders: {accept,content-type}'
2014-02-09 20:14:44.9421|Info|70| Method: PUT;Operator: DefaultHttpControllerSelector;Operation: SelectController;Message: Route='MS_SubRoutes:System.Web.Http.Routing.IHttpRouteData[]'
2014-02-09 20:14:44.9421|Info|71| Method: PUT;Operator: DefaultHttpControllerSelector;Operation: SelectController;Message: Building
2014-02-09 20:14:44.9421|Info|72| Method: PUT;Operator: HttpControllerDescriptor;Operat

Owin Authentication with Web API 2

Using Microsoft.Owin.Security along with .NET Web API 2 for authentication on Single Page Applications.

My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.

API > AccountController.cs

namespace API

{

@rnarayana
rnarayana / vagrant
Created October 13, 2013 13:27
Setting up linux dev box using vagrant
Get the linux virtualbox image URL from http://www.vagrantbox.es/
$ vagrant box add {title} {url}
$ vagrant init {title}
$ vagrant up
--Shutting down
$ vagrant halt
--List all vagrant boxes