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 / 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;
@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 / 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 / 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 / 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 / http-client-example.scala
Created June 1, 2017 15:48 — forked from semperos/http-client-example.scala
Scala - HTTPComponents client example
package com.semperos.example
import org.apache.http.impl.client.{BasicResponseHandler, DefaultHttpClient}
import org.apache.http.{HttpRequest, HttpRequestInterceptor}
import org.apache.http.client.methods.HttpGet
import org.apache.http.protocol.HttpContext
import org.apache.log4j.Logger
/**
@AravindaM
AravindaM / WSWithoutPlayApp.scala
Created June 1, 2017 16:16 — forked from ScalaWilliam/WSWithoutPlayApp.scala
Running Play WS standalone, without a Play App. Works with Maven builds nicely. The top way to make REST calls in Scala, in my opinion.
package com.scalawilliam.example.play
import play.api.libs.ws._
/**
* Play's Scala WS library is very very cool. Provides you with plenty niceties.
* See more: https://www.playframework.com/documentation/2.3.x/ScalaWS
*
* Unfortunately it by default requires a Play application context.
* But you do not necessarily always want that.
@AravindaM
AravindaM / play-ws-standalone.scala
Created June 2, 2017 01:35 — forked from jarek-przygodzki/play-ws-standalone.scala
Play 2.5.x - example of simple standalone WSClient
import play.api.libs.ws.ahc.AhcWSClient
import akka.stream.ActorMaterializer
import akka.actor.ActorSystem
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val ws = AhcWSClient()
val req = ws.url("http://example.com").get().map{
resp => resp.body
# Inspired from http://blog.akquinet.de/2010/05/26/mastering-the-maven-command-line-%E2%80%93-reactor-options/
# Build only specific modules:
mvn clean install -pl sub-module-name2
mvn clean install -pl sub-module-name2,sub-module-name3
# Build only starting from specific sub-module (resume from)
mvn clean install -rf sub-module-name2
# Build dependencies (also make)
@AravindaM
AravindaM / sysctl.conf
Created May 21, 2018 08:14 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2