This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createNode = function(data){ | |
return $.ajax({ | |
type: 'POST', | |
url: 'http://localhost:7474/db/data/index/node/people?unique', | |
data: data, | |
contentType: 'application/json', | |
dataType: 'json' | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static final int COUNT = 1000000; | |
private static void testAdd(Set<String> set) { | |
final long start = System.nanoTime(); | |
for (int i = 0; i < COUNT; ++i) { | |
set.add("test" + Math.random()); | |
} | |
final long elapsed = System.nanoTime() - start; | |
System.out.println("testAdd: " + elapsed / 1000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Producer extends UntypedActor { | |
private static final Gson gson = new GsonBuilder().create(); | |
private final String[] keys = {"user1", "user2", "user3", "user4", "user5", "user6"}; | |
@Override | |
public void onReceive(Object message) throws Exception { | |
if (message instanceof Integer) { | |
Integer opCount = (Integer) message; | |
final Random random = new Random(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Application extends Controller { | |
public static void index() throws Throwable { | |
Either<User, Throwable> result = await(Client.createUser("testuser", | |
"Foo", | |
"Bar")); | |
if (result._1.isDefined()) { | |
result = await(Client.getUser("testuser")); | |
if (result._1.isDefined()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package concurrency; | |
import com.hazelcast.client.ClientConfig; | |
import com.hazelcast.client.HazelcastClient; | |
import com.hazelcast.core.HazelcastInstance; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.ExecutorService; | |
import java.util.concurrent.Executors; | |
import org.junit.Test; | |
import workers.HazelcastWorker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void stats() { | |
Long userCount = CacheManager.get(CacheKey.USER_COUNT); | |
Long roleCount = CacheManager.get(CacheKey.ROLE_COUNT); | |
Long eventCount = CacheManager.get(CacheKey.EVENT_COUNT); | |
Long cumleCount = CacheManager.get(CacheKey.CUMLE_COUNT); | |
Long cumleEnabledCount = CacheManager.get(CacheKey.CUMLE_ENABLED_COUNT); | |
render(userCount, roleCount, eventCount, cumleCount, cumleEnabledCount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Hanoi</title> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<style type="text/css"> | |
#hanoi-table { | |
width: 345px; | |
height: 18px; | |
background-color: #eee; | |
border: 4px solid #ccc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void downloadFile(final Long fileId) throws IOException { | |
response.setHeader("Accept-Ranges", "bytes"); | |
notFoundIfNull(fileId); | |
File underlyingFile = ... //load file | |
String fileName = ...//name of the file | |
Header rangeHeader = request.headers.get("range"); | |
if (rangeHeader != null) { | |
throw new PartialContent(underlyingFile, fileName); |
NewerOlder