This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
printf "creating database\n" | |
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb" | |
printf "creating retention policy\n" | |
curl -G http://localhost:8086/query --data-urlencode "q=CREATE RETENTION POLICY myrp ON mydb DURATION 365d REPLICATION 1 DEFAULT" | |
printf "inserting data\n" | |
curl -d '{"database" : "mydb", "retentionPolicy" : "myrp", "points": [{"name":"cpu","tags":{"region":"useast","host":"server_1","service":"redis"},"fields":{"value":61}},{"name":"cpu","tags":{"region":"useast","host":"server_2","service":"mysql"},"fields":{"value":53}},{"name":"cpu","tags":{"region":"useast","host":"server_3","service":"apache"},"fields":{"value":80}},{"name":"cpu","tags":{"region":"useast","host":"server_4","service":"nginx"},"fields":{"value":86}},{"name":"cpu","tags":{"region":"useast","host":"server_5","service":"paulapp"},"fields":{"value":87}},{"name":"cpu","tags":{"region":"japan","host":"server_6","service":"redis"},"fields":{"value":10}},{"name":"cpu","tags":{"region":"japan","host":"s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this shows how to use the update functionality for a single feed with feedzirra | |
require 'rubygems' | |
require 'feedzirra' | |
# I'm using Atom here, but it could be anything. You don't need to know ahead of time. | |
# It will parse out to the correct format when it updates. | |
feed_to_update = Feedzirra::Parser::Atom.new | |
feed_to_udpate.feed_url = some_stored_feed_url | |
feed_to_update.etag = some_stored_feed_etag | |
feed_to_update.last_modified = some_stored_feed_last_modified |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a code example for the Ruby HTTP library Typhoeus | |
# here's an example for twitter search | |
# Including Typhoeus adds http methods like get, put, post, and delete. | |
# What's more interesting though is the stuff to build up what I call | |
# remote_methods. | |
class Twitter | |
include Typhoeus | |
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)}, | |
:on_failure => lambda {|response| puts "error code: #{response.code}"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Optimized for writes, sort on read | |
# LVC | |
redis.hset("bonds|1", "bid_price", 96.01) | |
redis.hset("bonds|1", "ask_price", 97.53) | |
redis.hset("bonds|2", "bid_price", 95.50) | |
redis.hset("bonds|2", "ask_price", 98.25) | |
redis.sadd("bond_ids", 1) | |
redis.sadd("bond_ids", 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"github.com/influxdata/influxdb/client" | |
"math/rand" | |
"net/url" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'rubygems' | |
require 'json' | |
require 'yaml' | |
include Benchmark | |
benchmark_iterations = 1 | |
large_single_dimension_array = [42, 123.123] * 5000 | |
large_single_dimension_hash = {} | |
10000.times do |i| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Errplane.configure do |config| | |
config.define_custom_exception_data do |black_box| | |
if black_box.exception.class == ZeroDivisionError | |
Errplane.report("important_exceptions/#{black_box.exception.class.to_s}") | |
end | |
# or just report on all of them and sort it out in the errplane web app | |
Errplane.report("exception_classes/#{black_box.exception.class.to_s}", | |
:message => "{Rails.env} - #{black_box.exception.class.to_s} - #{black_box.request_data.to_json}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set the thread pool size and the timeout in seconds. | |
fetcher = Feedzirra::Fetcher.new({:thread_pool_size => 100, :timeout => 5}) | |
# some feed data objects. also include feed_entry data objects | |
feeds = [Feed.new({:entries => [], etag => "..", :last_modified => "...", :url => "...", :feed_url => "...", :title => ""})] | |
# async style | |
fetcher.get(feeds, :on_success => lambda {|feed, updated_feed| ...}, :on_failure => lambda {|feed, failure_object| ...}) | |
# that returns before finishing fetching the feeds. just adds them to a thread-safe queue to be processed by a worker pool. | |
# the failure condition could actually call fetcher.get on the failed feed again if you wanted to retry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# here's the dealer socket in one process | |
require 'ffi-rzmq' | |
@context = ZMQ::Context.new(1) | |
@sock = @context.socket(ZMQ::XREQ) | |
@sock.bind("tcp://*:5550") | |
count = 0 | |
while true do | |
count += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Keyspace: system | |
Read Count: 11 | |
Read Latency: 1.8718181818181818 ms. | |
Write Count: 3 | |
Write Latency: 0.021 ms. | |
Pending Tasks: 0 | |
Column Family: NodeIdInfo | |
SSTable count: 0 | |
Space used (live): 0 | |
Space used (total): 0 |
NewerOlder