Skip to content

Instantly share code, notes, and snippets.

View metanet's full-sized avatar

Ensar Basri Kahveci metanet

View GitHub Profile
@metanet
metanet / JMM_Memory_Barriers.md
Created February 10, 2017 17:03 — forked from serkan-ozal/JMM_Memory_Barriers.md
JMM Memory Barriers
[StoreStore]
<volatile_store>
[StoreLoad]
<volatile_load>
[LoadLoad|LoadStore]
@metanet
metanet / kmeans.scala
Created May 3, 2015 18:16
K-Means clustering with Scala
import java.io.File
import java.lang.Math.{pow, sqrt}
import scala.annotation.tailrec
import scala.util.Random
case class Point(x: Double, y: Double, z: Double) {
def distanceTo(that: Point) = sqrt(pow(this.x - that.x, 2) + pow(this.y - that.y, 2) + pow(this.z - that.z, 2))
def sum(that: Point) = Point(this.x + that.x, this.y + that.y, this.z + that.z)
@metanet
metanet / gist:5bcf232bcb260f7047b5
Created April 16, 2015 12:03
hz-log4j config 2
#
# Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@metanet
metanet / gist:148d56b5f4f461d78d19
Created April 14, 2015 13:46
hz-log4j.properties
#
# Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@metanet
metanet / HashMapThreadSafetyTest
Created December 29, 2014 07:59
A unit test that proves java.util.HashMap is not thread-safe
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertTrue;
public class HashMapThreadSafetyTest {