Skip to content

Instantly share code, notes, and snippets.

View noctarius's full-sized avatar

noctarius aka Christoph Engelbert noctarius

View GitHub Profile
@noctarius
noctarius / .mk
Last active January 13, 2020 17:48
################################################################################
#
# tpm2-tss-engine
#
################################################################################
TPM2_TSS_ENGINE_VERSION = 1.0.1
TPM2_TSS_ENGINE_SOURCE = tpm2-tss-engine-$(TPM2_TSS_ENGINE_VERSION).tar.gz
TPM2_TSS_ENGINE_SITE = https://github.com/tpm2-software/tpm2-tss-engine/releases/download/v$(TPM2_TSS_ENGINE_VERSION)
TPM2_TSS_ENGINE_LICENSE = BSD-2-Clause
package mc;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.core.ITopic;
import java.util.UUID;
public class MCDemo {
person=336
going=313
country=222
great=168
american=147
job=111
good=100
america=95
thing=93
time=88
people=314
going=313
country=177
great=168
american=117
good=99
america=89
time=75
jobs=73
united=66
Dictionary [
ByteString{ historyId }=UInt{ 5060033 },
ByteString{ id }=ByteString{ 14dc2de0074cc817 },
ByteString{ internalDate }=UInt{ 1433493436000 },
ByteString{ labelIds }=Sequence [
ByteString{ INBOX },
ByteString{ IMPORTANT },
ByteString{ CATEGORY_FORUMS }
],
ByteString{ payload }=Dictionary [
Parser parser = Parser.newBuilder().build();
// extracts id into mid, internalDate into date, payload/headers into headers, returns the new object
// Query query = "(mid: #{'id'}, date: #{'internalDate'}, headers: #{'payload'}{'headers'})";
// alternative version to define it
Query query = parser.newQueryBuilder().asDictionary()
.putEntry("mid").stream(0).dictionary("id").endEntry()
.putEntry("date").stream(0).dictionary("internalDate").endEntry()
.putEntry("headers").stream(0).dictionary("payload").dictionary("headers").endEntry()
java:
import io.vertx.core.*;
import io.vertx.core.http.*;
import io.vertx.core.shareddata.AsyncMap;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager;
import java.util.Optional;
import java.util.function.Consumer;
@noctarius
noctarius / EvenOrOdd.js
Created December 29, 2016 16:33
I had the feeling I finally need to solve this issue! :)
// Found this awesome way in Java code once and had
// the strong feeling I need to port it to Javascript
// for the sake of all NodeJS developers!
var EvenOrOdd = function() {
function EvenOrOdd() {}
EvenOrOdd.prototype.isEven = function(value) {
var even = "02468";
var v = String(value);
var w = v.charAt(v.length - 1);
return even.indexOf(w) != -1;
@Test
public void test_exception_flow_control() {
Calendar calendar = Calendar.getInstance();
calendar.set(2003, 11, 13, 18, 30, 02);
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
calendar.set(Calendar.MILLISECOND, 250);
Instant expected = calendar.toInstant();
ZoneId UTC = ZoneId.of("UTC");
DateTimeFormatter fractionFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
StreamWriter streamWriter = StreamWriter.newBuilder().build();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamGraphBuilder graphBuilder = streamWriter.newStreamGraphBuilder(Output.toOutputStream(baos));
graphBuilder.putNumber(100).putNumber(101).putNumber(102).putNumber(103).putNumber(104).finishStream();
Parser parser = Parser.newBuilder().build();
Input input = Input.fromByteArray(baos.toByteArray());
// Dictionary, inner dictionary, inner sequence