Skip to content

Instantly share code, notes, and snippets.

View nadeesha's full-sized avatar

Nadeesha Cabral nadeesha

View GitHub Profile
@nadeesha
nadeesha / web-server.js
Created September 2, 2013 19:41
Angular Seed's (https://github.com/angular/angular-seed) node web server updated to have: 1. Directory browsing disabled. 2. Serving a default file (index.html) for a directory root. 3. In absence of a index.html, a dir root URL to return a 404.
#!/usr/bin/env node
var util = require('util'),
http = require('http'),
fs = require('fs'),
url = require('url'),
events = require('events');
var DEFAULT_PORT = 8000;
var DEFAULT_FILE = 'index.html'; // default file for the dir root
private double FuzzyStringComparison(string source, string target)
{
// if both of the strings are empty, return 0
// else if the source is empty but not the target, the distance is the target length
// else if the target is empty and not the source, the the distance is the source length.
if (string.IsNullOrEmpty(source))
{
if (string.IsNullOrEmpty(target))
{
return 0;
@nadeesha
nadeesha / proxy.js
Last active July 28, 2017 06:15
Node-based http/https proxy to forego the pain of configuring iptables for one-off dev tasks. Not recommended to be used in prod environments.
var fs = require('fs'),
http = require('http'),
https = require('https'),
httpProxy = require('http-proxy');
var isHttps = true; // do you want a https proxy?
var options = {
https: {
key: fs.readFileSync('key.pem'),
@nadeesha
nadeesha / gist:9543408
Created March 14, 2014 07:23
Git submodule ops
# pull latest commits of the submodules (not the ones your parent is pointing to)
git pull --recurse-submodules
# pull all submodules and get the proper commits as pointed by parent
git pull --recurse-submodules && git submodule update
@nadeesha
nadeesha / walkthrough.html
Created June 26, 2014 21:09
hirewire.lk - a walkthough
<h1 id="hirewirelk-a-walkthough">hirewire.lk - a walkthough</h1>
<p>We are in the business of connecting employers and job seekers. We may not be a replacement to a total HR solution or a recruitment management solution.</p>
<p>Rather, we help you sail past the most excruiciating step of the process - acquiring and pre-screening candidates.</p>
<p>This guide is supposed to be a walkthrough for a recruiter to go from 0-60 in our platform within 10 minutes. If you have further questions, we would be happy to help you from hello@hirewire.lk.</p>
<h2 id="campaigns">Campaigns</h2>
@nadeesha
nadeesha / max_produce_of_three.js
Last active August 29, 2015 14:03
Codility Answers in Javascript
// you can use console.log for debugging purposes, i.e.
// console.log('this is a debug message');
function solution(A) {
A.sort(function(a,b) {
if (a < b) {
return 1;
} else if (a > b) {
return -1;
} else {
@nadeesha
nadeesha / gist:ac2a392ec96d3ba2d034
Created September 26, 2014 16:04
ceresi API spec
Check status
GET http://192.168.59.103:8080/api/status
Get all the users' packages
GET http://192.168.59.103:8080/api/v1/npm/packages
Install a package in the app
PUT http://192.168.59.103:8080/api/v1/npm/install/:package
Issue a request to a pakcage
I need to see my #ec2/ec2publicips
recent wso2 blogposts #rss/wso2
jehanr shit sri lankan mothers say #youtube/search
twitter bootstrap with rails #github/search
i'm gonna pop some tags i got $20 in my pocket #twitter/do
@nadeesha
nadeesha / gist:20539ba8eae4cc6ba4d1
Created October 30, 2014 07:00
my sublime packages
"All Autocomplete",
"Bootstrap 3 Snippets"
"BracketHighlighter"
"DocBlockr"
"Dracula Color Scheme"
"GitGutter"
"HTML-CSS-JS Prettify"
"JavaScript Snippets"
"JavaScriptNext - ES6 Syntax"
"JSHint"
@nadeesha
nadeesha / add.js
Last active August 29, 2015 14:14
function (args) {
function addArray(arr) {
if (arr.length === 1) {
return Number(arr[0]);
}
return Number(arr[0]) + addArray(arr.slice(1));
}
this.exec = function (cb) {