Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
@binarytemple
binarytemple / yokozuna.solr.reindex.just.change.the.schema.file.markdown
Last active August 29, 2015 14:23
Exploring Riak/Yokozuna/Solr sharing and communication of search index schema files.

Question

Can I change Yokozuna schema just be editing the schema files in the data/yz/.. directory?

Answer

No. On upload, data is broadcast to all nodes by riak_core_metadata:put and also stored to a DETS database in the data/metadata directory on each node.

I know from previous research that such files can be located/read using the following code.

@binarytemple
binarytemple / convert.ring.file.to.plain.text.markdown
Last active August 29, 2015 14:23
convert ring file to plain text

RingToFile = fun(InputFile,OutputFile) -> 
   {ok,Data} = file:read_file(InputFile),
   T = binary_to_term(Data),
   {ok,Handle} = file:open(OutputFile,[write,append]),
   Line = io_lib:format("~p", [T]),
   file:write(Handle, Line), 
   file:close(Handle)
end.
@binarytemple
binarytemple / Convert.bread.trace.to.plain.text.markdown
Created June 24, 2015 16:36
Convert bread trace to plain text

Convert bread trace to plain text


RedbugToFile = fun(InputFile,OutputFile) -> 
{ok,Handle} = file:open(OutputFile,[write,append]),
bread:trc(InputFile,
   fun(X, A) ->
     Line = io_lib:format("trace:~p~n", [X]),
 file:write(Handle, Line), 

for i in {0..60}
    do 
    if [[ $i == 0 ]]
        then print "tick 12 : $(( $i % 60 ))"
    elif [[ $i == 30 ]]
 then print "tick $(($i /5 )) : $i : half past"
%% These are shell functions that can be used to output a keylist from a bitcask file in terms of Riak {Bucket,Key} tuples
%% They should be run from `riak attach`. Paste in the contents and run ListAll("filename.txt"). Profit.
ListCask = fun(Vnode,OutFile) ->
Fold_data = fun(Handle) ->
FoldFun = fun(Bytes, X, Y, {ok, Acc}) ->
case Bytes of
<<1:7, 0:1,Sz:16/integer,Bucket:Sz/bytes, Key/binary>> ->
io:format(OutFile, "~s/~s~n", [binary_to_list(Bucket),binary_to_list(Key)]), {ok, Acc + 1};

Rather than redirect, replay?

Hi,

I'm working away on my first Chicagoboss demo application, and I'm trying to implement an identification, authorization, access workflow.


I started by implementing a controller_filter:

Streaming binary data from /dev/urandom as input to curl and storing the data in Riak.

dd if=/dev/urandom bs=1 count=128 2>/dev/null | curl -vvv -s 127.0.0.1:10018/types/default/buckets/foo/keys/bar -X PUT -H "content-type: application/octet-stream" --data-binary @- | tr -cd '\11\12\15\40-\176' 2>/dev/null
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 10018 (#0)
> PUT /types/default/buckets/foo/keys/bar HTTP/1.1
> User-Agent: curl/7.37.1
> Host: 127.0.0.1:10018
% dev/dev1/erts-5.10.3/bin/nodetool -name dev1@127.0.0.1 -setcookie riak rpcterms application get_env "riak_kv. foo."
{ok,undefined}
% dev/dev1/erts-5.10.3/bin/nodetool -name dev1@127.0.0.1 -setcookie riak rpcterms application set_env "riak_kv. foo. <<\"bar\">>."
ok
% dev/dev1/erts-5.10.3/bin/nodetool -name dev1@127.0.0.1 -setcookie riak rpcterms application get_env "riak_kv. foo."
{ok,<<"bar">>}
package com.vbrick.riak;
import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@binarytemple
binarytemple / remotemd.rb
Created June 5, 2015 08:36
modified jekyl remote_markdown plugin to strip out deckset annotations, so presentations can also be used in blog posts, for example
# deploy to _plugins/remotemd.rb
# use like so
# {% remotemd https://gist.githubusercontent.com/binarytemple/31ce133fb703e620c592/raw/73bbb0012b467e37e145247ecaf2ec3326ae4ffb/query.riak.realtime.queue.markdown %}
#
# "THE BEER-WARE LICENSE" (Revision 42):
# <robin.hahling@gw-computing.net> wrote this file. As long as you retain this
# notice you can do whatever you want with this stuff. If we meet some day, and
# you think this stuff is worth it, you can buy me a beer in return.
# Robin Hahling