Skip to content

Instantly share code, notes, and snippets.

View darionyaphet's full-sized avatar
🫐
On vacation

yaphet darionyaphet

🫐
On vacation
View GitHub Profile
@darionyaphet
darionyaphet / gist:aef88104c7704c65e1c8
Created June 19, 2014 03:32
ProducerMultPartition.java
import java.util.Properties;
import kafka.javaapi.producer.Producer;
import kafka.producer.KeyedMessage;
import kafka.producer.ProducerConfig;
public class ProducerMultPartition {
public static void main(String[] args) {
Properties properties = new Properties();
@darionyaphet
darionyaphet / gist:ab9586c31cf158b6e958
Last active August 29, 2015 14:02
ComsumerMultPartitionExamples.java
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import kafka.api.FetchRequest;
import kafka.api.FetchRequestBuilder;
import kafka.javaapi.FetchResponse;
import kafka.javaapi.consumer.SimpleConsumer;
import kafka.message.MessageAndOffset;
public class ComsumerMultPartitionExamples {
@darionyaphet
darionyaphet / gist:5eb51cbcff147b0ff57a
Created June 27, 2014 08:37
Netty HashedWheelTimerExamples.java
package netty.examples;
import java.util.concurrent.TimeUnit;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;
public class HashedWheelTimerExamples {
@darionyaphet
darionyaphet / StringTemplateExample
Created December 3, 2015 13:55
Simple StringTemplate Example
package org.darion.yaphet;
import org.stringtemplate.v4.ST;
public class StringTemplateExample {
public static void main(String[] args) {
ST hello = new ST("Hello, <name>");
hello.add("name", "World");
System.out.println(hello.render());
@darionyaphet
darionyaphet / System Design.md
Created April 18, 2016 05:39 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Interview Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.io.ImmutableBytesWritable
import org.apache.hadoop.hbase.client.Result
import org.apache.hadoop.hbase.mapreduce.TableInputFormat
val conf = HBaseConfiguration.create()
conf.set("zookeeper.znode.parent", "/hbase")
conf.set("hbase.zookeeper.property.clientPort", "2181")
conf.set("hbase.zookeeper.quorum", "zk0,zk1,zk2,zk3,zk4")
@darionyaphet
darionyaphet / KafkaConsumer.java
Last active May 11, 2016 13:31
Kafka Producer & Consumer
package org.darion.yaphet.kafka;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import java.util.Arrays;
import java.util.Properties;
public class Consumer {
@darionyaphet
darionyaphet / Parquet ReadFileExample
Last active May 15, 2017 03:07
Parquet Example
package org.darion.yaphet.parquet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.parquet.example.data.Group;
import org.apache.parquet.hadoop.ParquetReader;
import org.apache.parquet.hadoop.example.GroupReadSupport;
import java.io.IOException;
@darionyaphet
darionyaphet / Examples
Last active July 2, 2016 03:57
KryoExample
package org.darion.yaphet.kryo;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
val m = Map("k0"->"v0","k1"->"v1","k2"->"v2")
val n = m.map{case (k,v) => (v,k)}.toMap
println(n)