Skip to content

Instantly share code, notes, and snippets.

View skeptomai's full-sized avatar
🐒
Monkeying around

Christopher Brown skeptomai

🐒
Monkeying around
View GitHub Profile
{ :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
}
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)
#
# Author:: Tim Dysinger (<tim@dysinger.net>)
# Author:: Benjamin Black (<bb@opscode.com>)
# Author:: Christopher Brown (<cb@opscode.com>)
# 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
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
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
(defun jira-get-projects ()
"Returns a list of projects available to the user"
(jira-call 'jira1.getProjectsNoSchemes))
(require 'chef)
(resource :file "/tmp/foo"
:owner "cb"
:action :create)
(resource :file (concatenate 'string
"/tmp/"
(node-attributes :hostname)
"-made-with-lisp")
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},
%% @author <cb@opscode.com>
%% @doc Simple hex to binary and back, taken from comments by Steve Vinoski and others
-module(hex).
-author('<cb@opscode.com>').
-export([bin_to_hexstr/1,hexstr_to_bin/1]).
%% External API
bin_to_hexstr(Bin) ->
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);