Skip to content

Instantly share code, notes, and snippets.

View cchandler's full-sized avatar

Chris Chandler cchandler

View GitHub Profile
module CassandraAccess
def self.included(mod)
mod.class_eval do
def cassandra
@@cassandra ||= Cassandra.new(@@keyspace, @@host)
end
def self.cassandra
@@cassandra ||= Cassandra.new(@@keyspace, @@host)
end
@cchandler
cchandler / gist:326173
Last active September 4, 2015 12:55
my 100 things
Kitchen island
red vase
wallet
fleece beanie
Vibram five fingers (2x)
sneakers
santoni shoes
iPhone
belt
MissionWorkshop backpack
//Play with context
#define _XOPEN_SOURCE
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<ucontext.h>
require './hbase'
require './hbase_constants'
require './hbase_types'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("hbase_server", "9090"))
transport.open
client = Apache::Hadoop::Hbase::Thrift::Hbase::Client.new(Thrift::BinaryProtocol.new(transport))
## Get Table meta data
require './cassandra'
require './cassandra_constants'
require './cassandra_types'
transport = Thrift::BufferedTransport.new(Thrift::Socket.new("127.0.0.1", "9160"))
transport.open
client = CassandraThrift::Cassandra::Client.new(Thrift::BinaryProtocol.new(transport))
columnPath = CassandraThrift::ColumnPath.new(:column_family => "Places", :column => "test")
#!/usr/bin/ruby
## Configured against AMI 5f46a736 e146a788
APP_NAME = "app_name"
SERVER_NAME = "app_name.somewhere.com"
DEPLOY_KEY_LOCATION="http://s3.amazonaws.com/bucket"
DEPLOY_KEY_FILE="deploy_key.tar.gz"
AUTHORIZED_KEYS_LOCATION="http://s3.amazonaws.com/bucket"
AUTHORIZED_KEYS_FILE="authorized_keys.tar.gz"
ENVIRONMENT="staging"
mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653));
+----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+------------------------+------------+---------+----------------------------------------------+------+--------------------------+
| 1 | SIMPLE | memberships | ref | test_index,test_index1 | test_index | 5 | const | 1 | Using where; Using index |
| 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | |
+----+--
mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653));
+----+-------------+-------------+--------+---------------+------------+---------+----------------------------------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+---------------+------------+---------+----------------------------------------------+------+--------------------------+
| 1 | SIMPLE | memberships | ref | test_index | test_index | 5 | const | 1 | Using where; Using index |
| 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | |
+----+-------------+-------------+--------+----------
mysql> explain SELECT `groups`.* FROM `groups` INNER JOIN `memberships` ON `groups`.id = `memberships`.group_id WHERE ((`memberships`.user_id = 653));
+----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+-------------+
| 1 | SIMPLE | memberships | ALL | NULL | NULL | NULL | NULL | 100 | Using where |
| 1 | SIMPLE | groups | eq_ref | PRIMARY | PRIMARY | 4 | simplewants_development.memberships.group_id | 1 | |
+----+-------------+-------------+--------+---------------+---------+---------+----------------------------------------------+------+
class User < ActiveRecord::Base
has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :group
end