Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastián Estévez phact

View GitHub Profile
View gocql_astra_sni.go
package main
import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"fmt"
. "github.com/gocql/gocql"
"io/ioutil"
"log"
View peering.sh
#!/bin/bash
PEERING_CONNECTION_ID=
REGION=
RECEIVER_VPC_ROUTE_TABLE_ID=
aws ec2 accept-vpc-peering-connection --vpc-peering-connection-id "$PEERING_CONNECTION_ID" --region "$REGION"
DEST_CIDR=$(aws ec2 describe-vpc-peering-connections --vpc-peering-connection-ids "$PEERING_CONNECTION_ID" --region "$REGION" | jq -r ".VpcPeeringConnections[].RequesterVpcInfo.CidrBlock")
aws ec2 create-route --route-table-id "$RECEIVER_VPC_ROUTE_TABLE_ID" --destination-cidr-block "$DEST_CIDR" --vpc-peering-connection-id "$PEERING_CONNECTION_ID" --region "$REGION"
View devops.sh
#!/bin/bash
CLIENT_NAME=
CLIENT_SECRET=
CLIENT_ID=
DB_ID=
TOKEN=$(curl --request POST \
  --url https://api.astra.datastax.com/v2/authenticateServiceAccount \
  --header 'accept: application/json' \
View akka-persistence-cassandra-astra.md

application.conf

# Configuration for akka-persistence-cassandra
akka.persistence.cassandra {
  events-by-tag {
    bucket-size = "Day"
    # for reduced latency
    eventual-consistency-delay = 200ms
    flush-interval = 50ms
@phact
phact / user-defined-compaction.sh
Last active Jun 21, 2019
surgical script that kicks off user defined compactions to purge tombstones in c*
View user-defined-compaction.sh
#!/bin/bash
#set -x
DATA_DIRECTORY="/var/lib/cassandra/data"
CASS_TOOLS_BIN_DIRECTORY="/DSE_DIR_HERE/resources/cassandra/tools/bin/"
KEYSPACE_NAME="assethub"
TABLE_NAME="clusters"
View dump_cassandra_keyspace.sh
#!/bin/bash
#this gnarly one liner will download dsbulk and download an entire keyspace worth of data into your local machine (assuming it fits!)
if [ -z "$CAS_HOST" ]; then
echo "Comma separated contact points (or set CAS_HOST environment variable):"
read CAS_HOST
fi
if [ -z "$KEYSPACE" ]; then
echo "Keyspace (or set KEYSPACE environment variable):"
read KEYSPACE
View dse-graph-geo.gremlin
system.graph('geo1').create()
:remote config alias g geo1.g
:remote config timeout max
//create the geo schema elements for this graph
graph.schema().propertyKey("point").Point().create();
graph.schema().propertyKey("line").Linestring().create();
graph.schema().propertyKey("polygon").Polygon().create();
graph.tx().commit();
View spark-cassandra-udts.md

Table definition:

CREATE TYPE physician(
    physician_first_name text,
    physician_last_name text,
    physician_license_state_code1 text,
    physician_license_state_code2 text,
    physician_license_state_code3 text,
    physician_license_state_code4 text,
@phact
phact / pi.yaml
Created Feb 17, 2016
cassandra.yaml for tiny boxes
View pi.yaml
# Cassandra storage config YAML
# NOTE:
# See http://wiki.apache.org/cassandra/StorageConfiguration for
# full explanations of configuration directives
# /NOTE
# The name of the cluster. This is mainly used to prevent machines in
# one logical cluster from joining another.
cluster_name: SmallCluster
View disk-over-time.sh
#!/bin/bash
dt=`date +%D`
log="du.log"
df > /tmp/du$$
while read line
do
fields=`echo $line | awk '{print NF}'`