Skip to content

Instantly share code, notes, and snippets.

View prasann's full-sized avatar
💬
Living by the code

Prasanna V Nagarajan prasann

💬
Living by the code
View GitHub Profile

An h1 header

Paragraphs are separated by a blank line.

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

  • this one
  • that one
alert('Injected!');
@prasann
prasann / migration.clj
Last active January 31, 2018 20:33
Clojure utility to run database migration with flyway
(ns app.migration
(:require [environ.core :refer [env]])
(:import org.flywaydb.core.Flyway
org.flywaydb.core.internal.info.MigrationInfoDumper))
;; 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)))
<OrderSection>
<SearchTile
orderId={this.props.orderId} />
</OrderSection>
.panel--1UaEBftHJ4F {
margin-top: 10px;
font-size: 150%;
}
@prasann
prasann / webpack.config.js
Created June 11, 2018 11:09
A sample webpack config to have multiple html generated using HTMLWebpackPlugin
const templateFileMapper = [{template: "temp1.hbs", file: "temp1.html"},
{template: "temp2.hbs", file: "temp2.html"},
{template: "temp3.hbs", file: "temp3.html"}];
const htmlPlugins = () => {
return templateFileMapper.map(entry => {
return new HtmlWebpackPlugin({
template: entry.template,
filename: entry.file,
});
@prasann
prasann / error_handler.ts
Created May 25, 2020 19:44
Centralized error handler - Express application
import logger from './logger';
export class AppError extends Error {
statusCode: number;
message: string;
constructor(statusCode, message) {
super(message);
this.statusCode = statusCode;
this.message = message;
@prasann
prasann / leave-updater.gs
Last active November 13, 2021 15:28
Updates the calendar with a day long event when someone applies leave in leave planner
const leaveTag = "label-to-which-the-emails-are-marked";
const calendarId = "new-calendar-id";
const nameRegEx = /Leave plan for (?<name>.*) is as below/;
const leaveTypeRegEx = /Leave Type:\s*(?<type>(.)*)?/;
const startDateRegEx = /Start Date:\s*(?<leave>(?:.*)202.)(?:,\s)*(?:(Half-Day:\s*(.*)))?/;
const endDateRegEx = /End Date:\s*(?<leave>(?:.*)202.)(?:,\s)*(?:(Half-Day:\s*(.*)))?/;
function applyRegEx(regEx, key, messageBody){
const matches = regEx.exec(messageBody);
return matches?.groups && matches.groups[key] ? matches.groups[key] : undefined;