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
{ :junglist => IPAddr.new("123.100.70.0/29"), :management => IPAddr.new("123.100.66.0/24") }.inject({}) { |memo, kv| | |
memo[kv[0]] = kv[1].to_s | |
memo | |
} |
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 'socket' | |
include Socket::Constants | |
def can_connect?(addr, port, timeout=2) | |
t = Socket.new(AF_INET, SOCK_STREAM, 0) | |
saddr = Socket.pack_sockaddr_in(port, addr) | |
connected = false | |
begin | |
t.connect_nonblock(saddr) |
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
# | |
# Author:: Tim Dysinger (<[email protected]>) | |
# Author:: Benjamin Black (<[email protected]>) | |
# Author:: Christopher Brown (<[email protected]>) | |
# Copyright:: Copyright (c) 2009 Opscode, Inc. | |
# License:: Apache License, Version 2.0 | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at |
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
define_cluster "ArgleBargle" do | |
dynomite_directory "/usr/local/dynomite" | |
data_directory "/tmp/data" | |
nodes 5 | |
thrift_base 9200 | |
text_base 11222 | |
web_base 8080 | |
blocksize 4096 | |
cache true | |
cache_size 128000 |
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
christopher-browns-macbook-pro:opscode-guid cb$ dynoctl --help | |
Usage: /usr/bin/dynoctl (options) | |
-c, --cluster CLUSTER_NAME Name of the Dynomite cluster | |
-b, --background Run in background (Detach from console) | |
-d, --directory DIRECTORY Data directory | |
-j, --join NODE_NAME Name of a Dynomite node to join to form a cluster | |
-n, --nodes NODES Number of nodes in the cluster | |
-o, --node NODE_NAME Name of this Dynomite node | |
-r, --readers READERS Number of readers | |
-a, --ascii-port ASCII_PORT Port for ASCII protocol |
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
(defun jira-get-projects () | |
"Returns a list of projects available to the user" | |
(jira-call 'jira1.getProjectsNoSchemes)) |
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 'chef) | |
(resource :file "/tmp/foo" | |
:owner "cb" | |
:action :create) | |
(resource :file (concatenate 'string | |
"/tmp/" | |
(node-attributes :hostname) | |
"-made-with-lisp") |
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
Test output: | |
command is erl -boot start_sasl +K true -smp enable -pa ./etest ./ebin ./deps/mochiweb/ebin ./deps/thrift/ebin -sname local_console_49068 -noshell -priv_dir "/Users/cb/Projects/dynomite/etest/log/49068" -config test -s eunit test bootstrap configuration dmerkle dmtree lib_misc mediator membership partitions rate storage_manager storage_server stream sync_manager vector_clock -run init stop | |
erl -boot start_sasl +K true -smp enable -pa ./etest ./ebin ./deps/mochiweb/ebin ./deps/thrift/ebin -sname local_console_49068 -noshell -priv_dir "/Users/cb/Projects/dynomite/etest/log/49068" -config test -s eunit test bootstrap configuration dmerkle dmtree lib_misc mediator membership partitions rate storage_manager storage_server stream sync_manager vector_clock -run init stop | |
bootstrap: relative_path_test...*skipped* | |
undefined | |
*unexpected termination of test process* | |
::{badarg,[{io,put_chars,[<0.50.0>,unicode,<<>>]}, | |
{eunit_proc,handle_test,2}, | |
{eunit_proc,tests_inorder,3}, |
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
%% @author <[email protected]> | |
%% @doc Simple hex to binary and back, taken from comments by Steve Vinoski and others | |
-module(hex). | |
-author('<[email protected]>'). | |
-export([bin_to_hexstr/1,hexstr_to_bin/1]). | |
%% External API | |
bin_to_hexstr(Bin) -> |
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
remove_field_from_collection(FieldValue, FieldCollectionName, ObjectId) when is_binary(FieldValue) -> | |
case fetch_document(ObjectId) of | |
{true, Document} -> | |
case doc_field(FieldCollectionName, Document) of | |
undefined -> undefined; | |
FieldCollection -> | |
case lists:member(FieldValue, FieldCollection) of | |
true -> | |
UpdatedDocument = erlang_couchdb:set_value(FieldCollectionName, lists:delete(FieldValue, DocFiel), Document), | |
erlang_couchdb:update_document(?OPSCODE_COUCH, ?AUTH_DATABASE, ObjectId, UpdatedDocument); |
OlderNewer