Skip to content

Instantly share code, notes, and snippets.

View hsaputra's full-sized avatar

Henry Saputra hsaputra

View GitHub Profile
@hsaputra
hsaputra / gist:b78fd3a3320b88dd1b29
Last active August 29, 2015 14:08
Find words in patter of ${keyword}. So in "This is a small ${world}" the function will find and replace ${word} with "foundone"
def lookup(base: String, found: Map[String, String]): String = {
var resolved = base
val pattern = Pattern.compile("(\\$\\{([^{}]*)\\})")
val matcher = pattern.matcher(base)
while (matcher.find()) {
val a = matcher.group(2)
if (!found.containsKey(a)) {
val b = lookup("foundone", found)
found.put(a, b)
print("Found " + b)
@hsaputra
hsaputra / gist:1112a33c68dd895c52c6
Created November 12, 2014 18:23
Reverse Linked List
public class Node {
public Node next;
public Object data;
}
public static void reverseList ( Node head) {
if (head == null || head.next == null) {
return;
}
@hsaputra
hsaputra / gist:98a8c6c57b7733082d2f
Last active August 29, 2015 14:09
Every possible permutation of a string or combination including repeated character use java
public static String[] getAllLists(String[] elements, int lengthOfList)
{
//initialize our returned list with the number of elements calculated above
String[] allLists = new String[(int)Math.pow(elements.length, lengthOfList)];
//lists of length 1 are just the original elements
if (lengthOfList == 1) {
return elements;
}
else {
@hsaputra
hsaputra / gist:96997ab2f50b0a454986
Last active January 26, 2021 06:25
Apache Flink Job execution Flow Sequence
Apache Flink Job Flow from client API to JobGraph
https://cwiki.apache.org/confluence/display/FLINK/Data+exchange+between+tasks
=============================================
WordCount
ExecutionEnvironment#getExecutionEnvironment
ExecutionEnvironment#readTextFile => DataSet<String>
DataSet#flatMap(FlatMapFunction) => FlatMapOperator<T, R>
@hsaputra
hsaputra / gist:329669ddf72827db3fd2
Last active August 29, 2015 14:18
Apache Flink Execution Local Stack
Apache Flink Execution Messages (local)
========================
Executing WordCount example with built-in default data.
Provide parameters to read input data from a file.
Usage: WordCount <text path> <result path>
16:46:47,454 INFO org.apache.flink.api.java.ExecutionEnvironment - The job has 0 registered types and 0 default Kryo serializers
16:46:48,042 INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:46:48,060 INFO org.apache.flink.runtime.blob.BlobServer - Created BLOB server storage directory /var/folders/nv/nsr_3ysj0wgfq93fqp0rdt3w0000gp/T/blobStore-e2b96f68-ebdd-450a-b385-759f70f1b33e
16:46:48,061 INFO org.apache.flink.runtime.blob.BlobServer - Started BLOB server at 0.0.0.0:58364 - max concurrent requests: 50 - max backlog: 1000
@hsaputra
hsaputra / gist:b47a91597001ae43c4eb
Created April 16, 2015 21:46
Apache Flink YARN Session Flow
flink-0.9-SNAPSHOT/bin ./yarn-session.sh -n 4 -tm 1024 -jm 1024 -s 5
14:26:49,187 WARN org.apache.hadoop.util.NativeCodeLoader - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
14:26:49,346 INFO org.apache.hadoop.yarn.client.RMProxy - Connecting to ResourceManager at /0.0.0.0:8032
14:26:49,370 INFO org.apache.flink.yarn.FlinkYarnClient - Using values:
14:26:49,371 INFO org.apache.flink.yarn.FlinkYarnClient - TaskManager count = 4
14:26:49,372 INFO org.apache.flink.yarn.FlinkYarnClient - JobManager memory = 1024
14:26:49,372 INFO org.apache.flink.yarn.FlinkYarnClient - TaskManager memory = 1024
14:26:49,715 INFO org.apache.flink.yarn.Utils - Copying from file:/Users/henrysaputra/flink-installs/flink-0.9-SNAPSHOT/lib/flink-dist-0.9-SNAPSHOT.jar to hdfs://localhost:9000/user/h
@hsaputra
hsaputra / gist:a3a291719b1a8a7380f4
Created July 19, 2015 17:55
Nearly All Binary Searches and Mergesorts are Broken
http://googleresearch.blogspot.de/2006/06/extra-extra-read-all-about-it-nearly.html
@hsaputra
hsaputra / gist:d147ffa76c509eecf3a2
Created July 27, 2015 05:35
Find lowest common ancestor in binary tree
http://www.fusu.us/2013/06/p2-lowest-common-ancestor-in-binary-tree.html
http://www.freedomlayer.org/articles/dht_intro.html
http://www.idryman.org/blog/2013/09/22/process-small-files-on-hadoop-using-combinefileinputformat-1/
http://www.ibm.com/developerworks/library/bd-hadoopcombine/