Skip to content

Instantly share code, notes, and snippets.

View rahulkumar-aws's full-sized avatar

Rahul Kumar rahulkumar-aws

View GitHub Profile
@rahulkumar-aws
rahulkumar-aws / 0_reuse_code.js
Created April 13, 2014 15:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
* Install Java8
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
** Install SBT
echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823
@rahulkumar-aws
rahulkumar-aws / kafka.md
Last active September 6, 2017 21:31
Kafka-Distributed

Kafka Broker setting (If you are running multile broker on same machine.)

config/server.properties

broker.id = 1
listeners=PLAINTEXT://:9093
log.dirs=/tmp/broker1_logs

Start Zookeeper

@rahulkumar-aws
rahulkumar-aws / Application.scala
Last active September 1, 2015 12:02 — forked from jeantil/Application.scala
Playframework 2.2 configurable cors filter
/**
The MIT License (MIT)
Copyright (c) 2013 Jean Helou
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
1) install boost
brew install boost
it will ask to create link. just follow the instruction
2) install libevent
brew install libevent
@rahulkumar-aws
rahulkumar-aws / gist:2ac98e913941295f7191
Created September 21, 2015 09:19
Javascript flatMap implementation
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
Example
[0, 1, 2, 3, 4, 5].flatMap(function(x) {
return [x, x + 1];
});
@rahulkumar-aws
rahulkumar-aws / CorsSupport.scala
Last active September 21, 2015 22:27 — forked from joseraya/CorsSupport.scala
CORS directive for Spray
package com.agilogy.spray.cors
import spray.http.{HttpMethods, HttpMethod, HttpResponse, AllOrigins}
import spray.http.HttpHeaders._
import spray.http.HttpMethods._
import spray.routing._
// see also https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
trait CORSSupport {
this: HttpService =>
{"help": "https://catalog.data.gov/api/3/action/help_show?name=package_search", "success": true, "result": {"count": 48, "sort": "views_recent desc", "facets": {}, "results": [{"license_title": "License not specified", "maintainer": "New Media", "relationships_as_object": [], "private": false, "maintainer_email": "[email protected]", "num_tags": 5, "id": "59694770-b6b6-4ae0-a4b9-4ae69c0be2f6", "metadata_created": "2016-07-02T10:06:26.199575", "metadata_modified": "2016-07-02T10:06:26.199575", "author": null, "author_email": null, "state": "active", "version": null, "creator_user_id": "47303a9e-1187-4290-85a3-1fc02dc49e4a", "type": "dataset", "resources": [{"cache_last_updated": null, "package_id": "59694770-b6b6-4ae0-a4b9-4ae69c0be2f6", "webstore_last_updated": null, "id": "3a8a0ad1-19e7-4153-bb2f-d70cf88aaaf8", "size": null, "state": "active", "hash": "", "description": "", "format": "CSV", "tracking_summary": {"total": 32, "recent": 1}, "last_modified": null, "url_type": null, "no_real_name": "True",
var hexcase = 0;
var b64pad = "";
var chrsz = 8;
function hex_md5(A) {
return binl2hex(core_md5(str2binl(A), A.length * chrsz))
}
function b64_md5(A) {
return binl2b64(core_md5(str2binl(A), A.length * chrsz))
}
function str_md5(A) {
@rahulkumar-aws
rahulkumar-aws / ReadCSV Java 8
Created December 17, 2017 13:27
Java 8 Read csv file
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ReadCSV {