Skip to content

Instantly share code, notes, and snippets.

View AravindaM's full-sized avatar
🏠
Working from home

Aravinda Liyanage AravindaM

🏠
Working from home
View GitHub Profile
@AravindaM
AravindaM / auto-scaling.md
Created May 30, 2017 17:10 — forked from tpai/auto-scaling.md
cheatsheet for aws ecs

Auto Scaling Launch Config

  • Amazon ECS Optimized AMI: ami-b4ae1dd7
  • Instance Type: t2.small

Config Details

  • Name: [CONFIG_NAME]
  • IAM role: fever_ecs
  • User data: As text
@AravindaM
AravindaM / Sorting_Lists_In_Scala
Created March 18, 2017 04:45 — forked from gsluthra/Sorting_Lists_In_Scala
Sorting lists in scala using sorted(), sortWith() and sortBy()
// Sequence of numbers
val xs = Seq(1, 5, 3, 4, 6, 2)
// Sort using Natural ordering as defined for Integers in Scala Library
xs.sorted //1,2,3,4,5,6
// Sort 'with' a comparator function
xs.sortWith(_<_) //1,2,3,4,5,6
xs.sortWith(_>_) //6,5,4,3,2,1
xs.sortWith((left,right) => left > right) //6,5,4,3,2,1
@AravindaM
AravindaM / basic-auth.js
Created March 17, 2017 14:20 — forked from flesch/basic-auth.js
HTTP Basic Authentication with Express, without express.basicAuth.
var express = require("express");
var app = express();
app.get("/restricted", function(req, res, next){
// Grab the "Authorization" header.
var auth = req.get("authorization");
// On the first request, the "Authorization" header won't exist, so we'll set a Response
// header that prompts the browser to ask for a username and password.
@AravindaM
AravindaM / gist:b0e02023a81dff4ca4533ae759574bba
Created September 27, 2016 05:44 — forked from suruja/gist:10241312
Mongo dump and restore on Heroku
require 'uri'
namespace :mongo do
desc "Dump the production database and restore to development and staging databases."
task :dump_and_restore => :environment do
dev = URI.parse(ENV["MONGO_URI"])
prod = URI.parse(`heroku config:get MONGO_URI --remote production`)
prod_username, prod_password = prod.userinfo.split(':')
@AravindaM
AravindaM / LocalBroadcastExampleActivity.java
Created May 13, 2016 06:27 — forked from Antarix/LocalBroadcastExampleActivity.java
Simple Example of using LocalBroadcastManager in Android
import android.app.Activity;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.content.LocalBroadcastManager;