Skip to content

Instantly share code, notes, and snippets.

View a75c6's full-sized avatar
💭
Eating tuna

[]\ a75c6

💭
Eating tuna
View GitHub Profile
@a75c6
a75c6 / gist:c1a68c7a4297f4fc24a5
Created June 17, 2015 07:34
sample data model 061715
NEED TO ORDER COMPOSITE PRIMARY KEYS BY ORDER OF QUERY IN WHERE CLAUSE
ORDERING COMPOSITE PRIMARY KEYS WILL LET YOU QUERY ACCORDING TO ORDER
*********YOU CAN SELECT ANY NON PRIMARY KEY VALUE AS LONG AS YOU USE
COMPOSITE PRIMARY KEY SELECTIONS IN ORDER*******************
ALL DELETE QUERIES USING WHERE USE AND AND NOT , BETWEEN ALL THE PARTS OF THE COMPOSITE KEY
UPDATE IS AN UPSERT; YOU WILL BE WRITING OVER UNLESS YOU ARE USING COMPOSITE PRIMARY KEY TO DIFFERENTIATE
select * from system.schema_keyspaces;
create keyspace sample1
@a75c6
a75c6 / cassandra default options
Last active November 6, 2019 06:11
cassandra default options
//table properties
with bloom_filter_fp_chance=0.01 //size tiered (default) and date tiered compaction strategy
with bloom_filter_fp_chance=0.1 //leveled compaction strategy
and caching = {'keys' : 'ALL', 'rows_per_partition' : 'NONE'}
//and caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
@a75c6
a75c6 / size tiered properties
Last active November 6, 2019 06:11
basic cassandra table properties size tiered
with bloom_filter_fp_chance=0.01
and caching = {'keys' : 'ALL', 'rows_per_partition' : 'NONE'}
and compaction = {'class' : 'SizeTieredCompactionStrategy', 'bucket_high' : '1.5', 'bucket_low' : '0.5', 'cold_reads_to_omit' : '0.05', 'enabled' : 'true', 'max_threshold' : '32', 'min_threshold' : '4', 'min_sstable_size' : '50', 'tombstone_compaction_interval' : '86400', 'tombstone_threshold' : '0.2', 'unchecked_tombstone_compaction' : 'false'}
and compression = {'sstable_compression' : 'LZ4Compressor', 'chunk_length_kb': 64, 'crc_check_chance': 1.0}
and dclocal_read_repair_chance = 0.1
and default_time_to_live = 0
and gc_grace_seconds = 864000
and memtable_flush_period_in_ms = 0
and read_repair_chance = 0.0;
@a75c6
a75c6 / date tiered properties
Last active November 6, 2019 06:11
cassandra date tiered compaction properties
with bloom_filter_fp_chance=0.01
and caching = {'keys' : 'ALL', 'rows_per_partition' : 'NONE'}
and compaction = {'class' : 'DateTieredCompactionStrategy', 'base_time_seconds' : '3600', 'enabled' : 'true', 'max_sstable_age_days' : '365', 'max_threshold' : '32', 'min_threshold' : '4', 'timestamp_resolution' : 'MICROSECONDS', 'tombstone_compaction_interval' : '86400', 'tombstone_threshold' : '0.2', 'unchecked_tombstone_compaction' : 'false'}
and compression = {'sstable_compression' : 'LZ4Compressor', 'chunk_length_kb': 64, 'crc_check_chance': 1.0}
and dclocal_read_repair_chance = 0.1
and default_time_to_live = 0
and gc_grace_seconds = 864000
and memtable_flush_period_in_ms = 0
and read_repair_chance = 0.0;
http://docs.datastax.com/en/cql/3.3/cql/cql_reference/create_keyspace_r.html
CREATE KEYSPACE NTSkeyspace WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1' : 1 };
//gcp uses data center value
CREATE KEYSPACE something WITH replication = {'class': 'NetworkTopologyStrategy', 'us-central1': '3'} AND durable_writes = true;
define data center and rack names in the cassandra-topology.properties file
create table users_by_userid (
user_id timeuuid primary key,
username varchar,
hash varchar,
email varchar,
birthdate bigint) with bloom_filter_fp_chance=0.01
and caching = {'keys' : 'ALL', 'rows_per_partition' : 'NONE'}
and compaction = {'class' : 'SizeTieredCompactionStrategy', 'bucket_high' : '1.5', 'bucket_low' : '0.5', 'cold_reads_to_omit' : '0.05', 'enabled' : 'true', 'max_threshold' : '32', 'min_threshold' : '4', 'min_sstable_size' : '50', 'tombstone_compaction_interval' : '86400', 'tombstone_threshold' : '0.2', 'unchecked_tombstone_compaction' : 'false'}
and compression = {'sstable_compression' : 'LZ4Compressor', 'chunk_length_kb': 64, 'crc_check_chance': 1.0}
and dclocal_read_repair_chance = 0.1
appdelegate.swift
if Digits.sharedInstance().session() == nil {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let signInViewController: UIViewController = storyboard.instantiateViewControllerWithIdentifier("SignInViewController")
let navigationController = UINavigationController(rootViewController: signInViewController)
self.window?.rootViewController = navigationController
navigationController.setNavigationBarHidden(true, animated: false)
self.window!.backgroundColor = UIColor.whiteColor()
//
// UserViewController.swift
//
import UIKit
import DigitsKit
class UserViewController: UIViewController, DGTCompletionViewController {
//
// UserViewController.swift
//
import UIKit
import DigitsKit
class UserViewController: UIViewController {
#import "Helloworld.pbrpc.h"
#import <ProtoRPC/ProtoRPC.h>
#import <RxLibrary/GRXWriter+Immediate.h>
static NSString *const kPackageName = @"helloworld";
static NSString *const kServiceName = @"Greeter";
@implementation HLWGreeter