Skip to content

Instantly share code, notes, and snippets.

@brianmhess
brianmhess / CLOneHealthCheck.java
Created April 6, 2020 22:02
Cassandra Health Checks
package hessian.ambien;
import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.config.DefaultDriverOption;
import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
import com.datastax.oss.driver.api.core.metadata.*;
import com.datastax.oss.driver.api.core.metadata.schema.KeyspaceMetadata;
import com.datastax.oss.driver.api.core.metadata.token.TokenRange;
@brianmhess
brianmhess / DeleteInsert.java
Created January 14, 2019 22:10
Delete-Insert Trigger
/*
javac -cp "/home/digger/dse/resources/cassandra/lib/*" -d target/ src/hessian/invest/DeleteInsert.java
jar cf DeleteInsert.jar -C target/ hessian
cp DeleteInsert.jar ~/dse/resources/cassandra/conf/triggers/
nodetool reloadtriggers
CREATE TRIGGER deleteInsert ON ks.tbl USING 'hessian.invest.DeleteInsert';
*/
package hessian.invest;
@brianmhess
brianmhess / lww_timetravel.cql
Last active October 16, 2018 18:42
LWW and Time Travel
CREATE KEYSPACE lab WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};
use lab;
CREATE OR REPLACE FUNCTION lww_accumulate(state MAP<INT,INT>, mutid INT, val INT)
CALLED ON NULL INPUT
RETURNS MAP<INT,INT>
LANGUAGE java
AS '
state.put(mutid, val);
return state;
@brianmhess
brianmhess / __Data Samples
Last active March 21, 2019 14:30
Data Samples
Here are some data samples for demonstrating loading.
CQL for tables:
cqlsh -e "CREATE KEYSPACE dsbulkblog WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};"
cqlsh -e "CREATE TABLE dsbulkblog.iris_with_id (id int PRIMARY KEY, petal_length double, petal_width double, sepal_length double, sepal_width double, species text)"
cqlsh -e "CREATE TABLE dsbulkblog.categories_set(category TEXT PRIMARY KEY, examples SET<TEXT>);"
cqlsh -e "CREATE TABLE dsbulkblog.categories_list(category TEXT PRIMARY KEY, examples LIST<TEXT>);"
cqlsh -e "CREATE TABLE dsbulkblog.president_birthdates(president TEXT PRIMARY KEY, birthdate_string TEXT, birthdate DATE);"
Examples:
@brianmhess
brianmhess / ghettoLog.java
Last active June 5, 2018 21:30
ghettoLog
private void ghettoLog(String fname, String msg) {
try {
Files.write(Paths.get("/tmp/logit"), Arrays.asList(s), StandardOpenOption.APPEND);
}
catch (Exception e) { }
}
setup-disks.sh
==============
#!/bin/bash
set -vx
# Execute this file dirctly (don't source it) if you want to use the `$(dirname $0)` construct
function maybe_skip_drive {
local drive=$1
if ! [ -b $drive ]; then
#!/bin/bash
for i in {1..30000}; do ./survey.sh; sleep 0.2; done;
5.1 3.5 1.4 0.2 Iris-setosa
4.9 3.0 1.4 0.2 Iris-setosa
4.7 3.2 1.3 0.2 Iris-setosa
4.6 3.1 1.5 0.2 Iris-setosa
5.0 3.6 1.4 0.2 Iris-setosa
5.4 3.9 1.7 0.4 Iris-setosa
4.6 3.4 1.4 0.3 Iris-setosa
5.0 3.4 1.5 0.2 Iris-setosa
4.4 2.9 1.4 0.2 Iris-setosa
4.9 3.1 1.5 0.1 Iris-setosa
@brianmhess
brianmhess / do.sh
Last active January 13, 2017 21:24
DSEFS FieldInputTransformer
#!/bin/bash
cqlsh -e "CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}"
cqlsh -e "CREATE TABLE test.dtest(pkey INT, info TEXT, link TEXT, dsefs_contents TEXT, PRIMARY KEY ((pkey)))"
echo This is a test > /tmp/test1.txt
echo This is another test > /tmp/test2.txt
echo Hello World > /tmp/test3.txt
echo Thank You > /tmp/test4.txt
dse fs "mkdir /fittest"
dse fs "put /tmp/test1.txt /fittest/test1.txt"
dse fs "put /tmp/test2.txt /fittest/test2.txt"
#!/usr/bin/python
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#|R|a|s|p|b|e|r|r|y|P|i|-|S|p|y|.|c|o|.|u|k|
#+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#
# ultrasonic_1.py
# Measure distance using an ultrasonic module
#
# Author : Matt Hawkins
# Date : 09/01/2013