Skip to content

Instantly share code, notes, and snippets.

View pradeepn's full-sized avatar

Pradeep Nagendiran pradeepn

  • Chennai, IN
View GitHub Profile
@pradeepn
pradeepn / google-cloud-pubsub-example.cs
Created December 16, 2022 13:56 — forked from yetanotherchris/google-cloud-pubsub-example.cs
Google Cloud Pub/Sub C# example
//
// Google Cloud Pub/Sub C# example
// NOTE: This is a .NET Core 1.1 console app.
// Use "dotnet run" to run it, run setup.ps1 first.
//
using System;
using System.Collections.Generic;
using Google.Cloud.PubSub.V1;
using Google.Protobuf;
@pradeepn
pradeepn / MinifyHtmlAttribute.cs
Created May 7, 2020 07:22 — forked from herman1vdb/MinifyHtmlAttribute.cs
Minify HTML with inline css/javascript for MVC C# as a ActionFilterAttribute
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using ZetaProducerHtmlCompressor.Internal;
namespace PmdWebsite.Helpers.ActionFilters
@pradeepn
pradeepn / AsyncMediatorPipeline.cs
Created January 3, 2017 11:05
AsyncMediatorPipeline and Autofac Registration
public class AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
private readonly IAsyncRequestHandler<TRequest, TResponse> inner;
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers;
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers;
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers)
{
this.inner = inner;
@pradeepn
pradeepn / gist:639bfe6f690956998a0140ecb33027e9
Created January 3, 2017 10:51
MediatR MediatorPipeline
public class MediatRInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store) {
container.Register(Classes.FromAssemblyContaining<IMediator>().Pick().WithServiceAllInterfaces());
container.Kernel.AddHandlersFilter(new ContravariantFilter());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IRequestHandler<,>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IPreRequestHandler<>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (IPostRequestHandler<,>)).WithService.AllInterfaces().LifestyleTransient());
container.Register(Classes.FromThisAssembly().BasedOn(typeof (INotificationHandler<>)).WithService.AllInterfaces().LifestyleTransient());
@pradeepn
pradeepn / usb-credit-card-reader.js
Created December 16, 2016 07:32 — forked from stracqan/usb-credit-card-reader.js
Very simple jQuery implementation that reads card data from a USB Magnetic Strip Credit Card Reader.
/**
*
* Simple jQuery Script to parse credit card data
* that was collected via a USB Magnetic Stripe
* Credit Card Reader.
*
* To get this to work, focus your cursor (either
* programmatically or via a click, it's your choice) on an input field #credit-card-number
* and then with the card reader plugged in, swipe
* the card and it will take over from there
@pradeepn
pradeepn / GetWeather.cs
Created December 9, 2016 12:37 — forked from syed-afraz-ali/GetWeather.cs
Simple CQRS using MediatR
using System;
using MediatR;
namespace MediatR_101
{
// The Query GetWeather that we will use to get weather status of any city
public class GetWeather : IRequest<Weather>
{
public GetWeather(String city)
{

AngularJS + RequireJS done right

Since AngularJS 2.x is not here yet, many applications are still being written using Angular 1.x. When the application that is more complex than the trivial examples you may found out there, it may end up having many modules, services, controllers, view templates and so on. In those real world cases, the main entry point of the application index.html may become a mess like this:

<!DOCTYPE html>
<html ng-app="myApp">
	<head>
        <!-- Angular and modules -->
		<script src="path-to/angular.js"></script>