Skip to content

Instantly share code, notes, and snippets.


Prasanna prasann

View GitHub Profile
prasann / error_handler.ts
Created May 25, 2020
Centralized error handler - Express application
View error_handler.ts
import logger from './logger';
export class AppError extends Error {
statusCode: number;
message: string;
constructor(statusCode, message) {
this.statusCode = statusCode;
this.message = message;
prasann / webpack.config.js
Created Jun 11, 2018
A sample webpack config to have multiple html generated using HTMLWebpackPlugin
View webpack.config.js
const templateFileMapper = [{template: "temp1.hbs", file: "temp1.html"},
{template: "temp2.hbs", file: "temp2.html"},
{template: "temp3.hbs", file: "temp3.html"}];
const htmlPlugins = () => {
return => {
return new HtmlWebpackPlugin({
template: entry.template,
filename: entry.file,
View test1.css
.panel--1UaEBftHJ4F {
margin-top: 10px;
font-size: 150%;
View test1.js
orderId={this.props.orderId} />
prasann / migration.clj
Last active Jan 31, 2018
Clojure utility to run database migration with flyway
View migration.clj
(ns app.migration
(:require [environ.core :refer [env]])
(:import org.flywaydb.core.Flyway
;; Build DB String from the Environment Variables
(def db-url (str "jdbc:postgresql://"
(env :pg-db-host) ":"
(env :pg-db-port) "/" (env :pg-db-name)))

An h1 header

Paragraphs are separated by a blank line.

2nd paragraph. Italic, bold, and monospace. Itemized lists look like:

  • this one
  • that one

Keybase proof

I hereby claim:

  • I am prasann on github.
  • I am prasann ( on keybase.
  • I have a public key ASAQVtwyhQ1XUFYNoIpqxm2JG32G_B_yMdt5oVARSQCYpAo

To claim this, I am signing this object:

prasann / mock-jest-locale.js
Created Sep 17, 2017
Sample Jest test to mock localeString
View mock-jest-locale.js
import * as helpers from '../src/helpers';
describe('formatDate', () => {
it('should invoke localString implementation to format date ', () => {
const localStringMock = jest.fn();
const mockDate = { toLocaleString: localStringMock };
expect(localStringMock).toHaveBeenCalledWith('de-DE', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
prasann /
Last active Jun 17, 2017
Dynamically set session expiry based on the user type
public class DynamicSessionIdentifierStrategy implements HttpSessionStrategy {
private static CookieHttpSessionStrategy cookieHttpSessionStrategy =
new CookieHttpSessionStrategy();
/* Code redacted */
public void onNewSession(Session session, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
if (!principalManager.isLoggedIn()) {
You can’t perform that action at this time.