Skip to content

Instantly share code, notes, and snippets.

View sampathsris's full-sized avatar

Sampath Sitinamaluwa sampathsris

View GitHub Profile
@sampathsris
sampathsris / package.json
Created October 31, 2023 03:22
JSON Echo Server in Node.js with no NPM installs
{
"name": "json-echo-server",
"version": "0.1.0",
"description": "Echos the request payload as JSON",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sampath Sitinamaluwa",
"license": "ISC"
@sampathsris
sampathsris / React Experimental Sandbox.md
Last active January 15, 2019 03:46
React Sandbox with Alpha Features

Are you looking to make a quick prototype with React, but missing the alpha features like React Hooks?

Look no further. Check out my sandbox and fork it to do whatever you wish.

Happy coding!

/Sampath

@sampathsris
sampathsris / Composer.cs
Created November 8, 2018 02:27
A function composer in C#
using System;
using System.Linq;
namespace IntObjectTest
{
public class Composer
{
static void Main()
{
Func<string, Func<string, string>> createAdder = s => x => x + s;
@sampathsris
sampathsris / passport-ntlm-ad.js
Created August 16, 2018 04:12
Windows integrated authentication with Passport.js in pure JavaScript (without using IISNode or mod_auth_sspi).
const express = require('express');
const session = require('express-session');
const passport = require('passport');
const ntlm = require('express-ntlm');
const ActiveDirectory = require('activedirectory');
const CustomStrategy = require('passport-custom');
const PORT = process.env.PORT || 8080;
const adconfig = {
@sampathsris
sampathsris / aurena.js
Last active September 18, 2018 03:44
Authenticate an IFS Aurena endpoint with DB Provider in Node.js and retrieve a projection
/**
* This is a crude hack to connect to an IFS Aurena endpoint using IFS Database
* Identity Provider, and then query for projections from Node.js. Not sure the
* purpose of this, but feeling it would come handy for something. You can do
* the same in Postman, but I'm feeling the stateful client (read: with cookies)
* will be helpful in chaining requests.
*
* Tested with:
* "dom-parser": "^0.1.5",
* "request": "^2.87.0",
@sampathsris
sampathsris / nodecmd.bat
Created June 22, 2015 19:17
How to resolve the error The node identifier for {My Machine Name} is {Some random letters}
@echo off
:: Harvest path is C:\Program Files (x86)\CA\SharedComponents\PEC\bin
:: Node.js path is C:\Program Files (x86)\nodejs
:: Let's replace Harvest's path with Node.js's path
set PATH=%PATH:C:\Program Files (x86)\CA\SharedComponents\PEC\bin;=%;C:\Program Files (x86)\nodejs;
:: Start a command prompt. But the environment variable change in previous
:: line will make sure that this new command prompt will run Node.js's node.exe
:: rather than Harvest SCM's node.exe.