Skip to content

Instantly share code, notes, and snippets.

View beccam's full-sized avatar

Rebecca Mills beccam

View GitHub Profile
@beccam
beccam / GettingStarted.java
Created June 27, 2014 19:54
Getting Started with Apache Cassandra and Java
import com.datastax.driver.core.*;
public class GettingStarted {
public static void main(String[] args) {
Cluster cluster;
Session session;
@beccam
beccam / GettingStarted.go
Created June 30, 2014 16:14
Getting Started with Apace Cassandra and Go
package main
import (
"fmt"
"log"
"github.com/gocql/gocql"
)
func main() {
@beccam
beccam / 0_reuse_code.js
Created July 3, 2014 14:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@beccam
beccam / GettingStarted.rb
Created July 3, 2014 16:39
Getting Started with Apache Cassandra and Ruby
require 'cql'
# connect to the cluster
client = Cql::Client.connect(hosts: ['127.0.0.1'])
client.use('demo')
# insert a user
client.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', '[email protected]', 'Bob')")
# Use select to get the user we just entered
@beccam
beccam / GettingStartedTwo.java
Last active July 21, 2017 21:02
Getting Started with Apache Cassandra and Java Part II
import com.datastax.driver.core.*;
public class GettingStartedTwo {
public static void main(String[] args) {
Cluster cluster;
Session session;
ResultSet results;
Row rows;
from cassandra.cluster import Cluster
from cassandra.policies import (TokenAwarePolicy, DCAwareRoundRobinPolicy, RetryPolicy)
from cassandra.query import (PreparedStatement, BoundStatement)
cluster = Cluster(
contact_points=['127.0.0.1'],
load_balancing_policy= TokenAwarePolicy(DCAwareRoundRobinPolicy(local_dc='datacenter1')),
default_retry_policy = RetryPolicy()
)
session = cluster.connect('demo')
@beccam
beccam / GettingStartedThree.py
Last active February 4, 2016 18:34
Getting Started with Apache Cassandra Part III (cqlengine)
from cqlengine import columns
from cqlengine.models import Model
class Users(Model):
firstname = columns.Text()
age = columns.Integer()
city = columns.Text()
email = columns.Text()
lastname = columns.Text(primary_key=True)
def __repr__(self):
@beccam
beccam / GettingStartedDatastaxRubyDriver.rb
Last active August 29, 2015 14:06
GettingStartedDatastaxRubyDriver
require 'cassandra'
cluster = Cassandra.connect
#cluster.each_host do |host|
# puts "Host #{"127.0.0.1"}: id=#{"6123e2c1-e3ca-4d08-a544-1315b2f399f1"} datacenter=#{"datacenter1"} rack=#{"rack1"}"
#end
keyspace = 'demo'
session = cluster.connect(keyspace)
@beccam
beccam / GettingStarted.rb
Created September 5, 2014 13:17
Getting Started with the Datastax Ruby Driver
require 'cassandra'
cluster = Cassandra.connect
keyspace = 'demo'
session = cluster.connect(keyspace)
session.execute("INSERT INTO users (lastname, age, city, email, firstname) VALUES ('Jones', 35, 'Austin', '[email protected]', 'Bob')")
session.execute("SELECT firstname, age FROM users WHERE lastname='Jones'").each do |row|
@beccam
beccam / getting_started.rb
Created September 20, 2014 01:00
Getting Started with Apache Cassandra and the DS Ruby Driver
require 'cassandra'
cluster = Cassandra.connect
#cluster.each_host do |host|
# puts "Host #{"127.0.0.1"}: id=#{"6123e2c1-e3ca-4d08-a544-1315b2f399f1"} datacenter=#{"datacenter1"} rack=#{"rack1"}"
#end
keyspace = 'demo'
session = cluster.connect(keyspace)