Skip to content

Instantly share code, notes, and snippets.

@pcn
pcn / cassandra.json
Created July 30, 2013 18:10
Test sedeploy json for cassandra (1 of 3 - there should be 1 each for each ASG)
{
"instance": {
"image_id": "ami-cd6904a4",
"key_name": "1JEKQFK38J65W0R83602-staging-05",
"security_groups": ["Base", "PN_KCS", "Cassandra_PN_KCS"],
"instance_type": "m1.large",
"min_count": 2,
"max_count": 2,
"instance_profile_arn": "arn:aws:iam::957700444419:instance-profile/Cassandra"
},
@pcn
pcn / ssh_helper_aliases.sh
Created August 20, 2013 18:30
Proposal for "h": an alternative command for the ssh_helper
function h () {
arg1=pop
case $1 in
p*) the_env=production
;;
s*) the_env=staging
;;
ua*) the_env=uat
;;
u*) the_env=utility
@pcn
pcn / open_next_queue_file
Created September 6, 2013 17:42
An alternative open_next_queue_file for the spooling carbon
def open_next_queue_file(self):
"""While running this method contains the only operations that
will be run on the queue file. Opening the file this way will
close the old one and do whatever is necessary - either re-name
it if there is data, or remove it if there is no data.
"""
if self.queue_file:
size = self.queue_file.tell() # should be at the end of the file
self.queue_file.close()
if size == 0:
@pcn
pcn / cfhistograms
Created September 12, 2013 03:43
nodetool cfhistograms on a node
fake_keyspace/SmallKeyValue histograms
Offset SSTables Write Latency Read Latency Row Size Column Count
1 44655562 0 0 0 995193
2 2242969 101 0 0 6265
3 1684179 18702 37 0 12256
4 1061248 97878 403 0 5972
5 560443 427836 1616 0 6752
6 258567 1594598 6098 0 6423
7 105135 4124889 14619 0 5322
8 37038 7449003 27035 0 5422
@pcn
pcn / knewton_conf.rb
Created September 30, 2013 16:45
cookbook to set up knewton-specific conf files
# Cookbook Name:: kcb_cassandra
# Description:: Put platform-style config in the platform-style location
# Recipe:: knewton_conf
# Author:: Peter Norton
#
#
# XXX requires configuration from the chef-server to be there for the environment
%w{ aws environment }.each do |path|
directory "#{node["knewton"]["conf_dir"]}/#{path}" do
@pcn
pcn / recipe.rb
Last active December 25, 2015 12:39
Can't pass in vars from a recipe to a template and get them evaluated late enough.
ruby_block "set_read_and_write_limits" do
block do
raidable_disks = []
node["ec2"].each do |k, v|
if (k =~ /^block_device_mapping_ephemeral/)
dev_name = "/dev/" + v.sub('sd', "xvd")
if File.exist?(dev_name)
raidable_disks << dev_name
end
end
@pcn
pcn / gen_tokens.py
Last active December 27, 2015 14:29
Generating tokens the priam way
#!/usr/bin/env python
import sys
import decimal
from decimal import Decimal
# Translated from netflix/priam
# MINIMUM_TOKEN = Decimal(0)
# MAXIMUM_TOKEN = Decimal(2) ** Decimal(127)
@pcn
pcn / run_graphite_devel_server
Created November 22, 2013 17:22
Testing graphite-web
. /opt/graphite/bin/activate
export PYTHONPATH=$PYTHONPATH:/opt/graphite/webapp
cd /shared_space/graphite-web
pip install . -U
cp ~/app_settings.py /opt/graphite/webapp/graphite/app_settings.py
cp ~/local_settings.py /opt/graphite/webapp/graphite/local_settings.py
/opt/graphite/bin/run-graphite-devel-server.py --port 8081 /opt/graphite
@pcn
pcn / spit_vs_with-open
Last active December 31, 2015 04:49
Clojure devs recommend writing with spit. Which is really inefficient.
```
carbon-relaj.core=> (time
#_=> (doseq [c (range 10000)]
#_=> (spit "/tmp/spit-file" (str c "\n"))))
"Elapsed time: 8613.006 msecs"
nil
carbon-relaj.core=>
carbon-relaj.core=> (time
#_=> (let [fname "/tmp/with-open"]
@pcn
pcn / get_cert_one_liner
Created December 16, 2013 14:49
get a cert using openssl
openssl s_client -connect foo:443 </dev/null 2>/dev/null | sed -n '/^-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' | openssl x509 -text