Skip to content

Instantly share code, notes, and snippets.

View alexott's full-sized avatar
🏠
Working from home

Alex Ott alexott

🏠
Working from home
View GitHub Profile
@alexott
alexott / App.java
Created January 10, 2018 09:29
java.util.LocalDate mapping in Cassandra
package jdtest1;
import java.util.UUID;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
public class App {
@alexott
alexott / generate-dse-topology.py
Last active January 7, 2019 13:52
Scripts for generation DSE service discovery JSON files for Prometheus
from dse.cluster import Cluster
import sys
import json
if (len(sys.argv) < 3):
print("Usage: generate.py contact_point file_name")
exit(1)
cluster = Cluster([sys.argv[1]])
session = cluster.connect()
@alexott
alexott / index.md
Last active June 14, 2018 12:44
Draft of documentation about Java driver's Built statements

Built statements

Built statements are generated via [QueryBuilder]'s Fluent API. Use of Fluent API allows easier build of the complex queries, comparing with hardcoding the CQL statements into the source code.

Note: The provider builders perform very little validation of the built query. There is thus no guarantee that a built query is valid, and it is definitively possible to create invalid queries.

@alexott
alexott / find-corrupted-jar.sh
Last active March 13, 2018 05:32
Snippet to find corrupted JAR in Maven repository
for i in `find ~/.m2/repository/ -name \*.jar`; do unzip -l $i 2> /dev/null > /dev/null ; RES=$?; if [ $RES -ne 0 ]; then echo "$i: $RES" ; fi ; done
@alexott
alexott / App.java
Last active March 10, 2018 18:31
UDT + Object mapper in DataStax Java Driver
package com.datastax.demos.alexott.product;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.Session;
import com.datastax.driver.mapping.Mapper;
import com.datastax.driver.mapping.MappingManager;
public class App {
cqlsh:test> DESCRIBE table log;
CREATE TABLE test.log (
module text,
yyyymmdd text,
created timeuuid,
logmessage text,
PRIMARY KEY ((module, yyyymmdd), created)
) WITH CLUSTERING ORDER BY (created ASC)
AND bloom_filter_fp_chance = 0.01
@alexott
alexott / ResultSetSerializer.java
Created February 3, 2018 15:29
JSON serialization of Java's ResultSet returned by DataStax Java Driver
package com.datastax.alexott.demos.jdtest1;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
@alexott
alexott / build-confluent-packages.sh
Last active September 1, 2017 14:28
Rebuild C/C++ packages provided by Confluent
#!/bin/bash
# By default, Confluent provides Debian versions of their packages via APT - as result, they are linked
# to other versions of the libraries than in Ubuntu, ...
# This small script rebuilds them on Ubuntu, or Debian versions different from provided by default.
MY_BUILD_DIR="build-$$"
mkdir $MY_BUILD_DIR
cd $MY_BUILD_DIR
apt-get source librdkafka libavro-cpp-dev libavro-c-dev confluent-libserdes-dev
@alexott
alexott / cedet-1.1-startup.el
Created October 28, 2012 13:42
Working configuration for CEDET 1.1 & below (only separate releases, not included into GNU Emacs)
;;; cedet-1.1-startup.el --- Working configuration for CEDET 1.1 & below
;; Copyright (C) Alex Ott
;;
;; Author: Alex Ott <alexott@gmail.com>
;; Keywords: CEDET 1.1,
;; Requirements: CEDET 1.1 or below
(load-file "~/tmp/cedet-1.1/common/cedet.el")
(require 'semantic-decorate-include)
@alexott
alexott / test.clj
Created August 13, 2012 12:20
Example to reproduce thread leak in ring-core (when parsing multipart uploads)
(ns rtest.core
(:gen-class)
(:use [ring.middleware params multipart-params keyword-params]
ring.adapter.jetty
)
)
(defn handler [request]
{:status 200