Skip to content

Instantly share code, notes, and snippets.

Andy Till andytill

Block or report user

Report or block andytill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andytill
andytill / replace_process_state.md
Last active Mar 14, 2017
Replace or Modify Process State
View replace_process_state.md

Given a process state using the following record, how could we modify one of the record fields?

-record(state, {
          status :: init_in_progress | {init_failed, Reason::term()} | ready,
          qbufs = [] :: [{qbuf_ref(), #qbuf{}}],
          qbuf_serial_id = 0 :: non_neg_integer(),
          total_size = 0 :: non_neg_integer(),
          %% no new queries; accumulation allowed
          soft_watermark :: non_neg_integer(),
View 1001-error.sql
riak-shell(3)>INSERT INTO grouptab3 VALUES('x');
Error (1001): <<"Invalid date/time string">>
riak-shell(4)>INSERT INTO grouptab3 VALUES(NULL);
Error (1003): Invalid data found at row index(es) 1
riak-shell(5)>INSERT INTO grouptab3 VALUES(2.3);
Error (1003): Invalid data found at row index(es) 1
riak-shell(6)>INSERT INTO grouptab3 VALUES(2.3, 'hi');
Error (1018): too many values in row index(es) 1
riak-shell(7)>SHOW CREATE TABLE grouptab3;
CREATE TABLE grouptab3 (a TIMESTAMP NOT NULL,
@andytill
andytill / GuiceControllerFactory.java
Created Jul 1, 2012
Creating JavaFX Controllers using Guice
View GuiceControllerFactory.java
/**
* A JavaFX controller factory for constructing controllers via Guice DI. To
* install this in the {@link FXMLLoader}, pass it as a parameter to
* {@link FXMLLoader#setControllerFactory(Callback)}.
* <p>
* Once set, make sure you do <b>not</b> use the static methods on
* {@link FXMLLoader} when creating your JavaFX node.
*/
class GuiceControllerFactory implements Callback<Class<?>, Object> {
View gist:0ea161d304c139be2523d9289b5b5325
diff --git a/tests/ts_simple_blob.erl b/tests/ts_simple_blob.erl
index 7235a26..a9fdb42 100644
--- a/tests/ts_simple_blob.erl
+++ b/tests/ts_simple_blob.erl
@@ -52,10 +52,15 @@ confirm() ->
Expected =
{ok, {Headers, Data}},
- Cluster = ts_setup:start_cluster(1),
+ lager:info("FREAD OUTPUT ~p", [io:fread("Hi.", "\n")]),
View retry.erl
%%
retry_delayed(Fn, DelayMs, TotalElapsedMs) when is_function(Fn),
is_integer(DelayMs),
is_integer(TotalElapsedMs),
TotalElapsedMs > DelayMs ->
retry_delayed2(Fn, DelayMs, TotalElapsedMs, ordsets:new()).
retry_delayed2(Fn, DelayMs, TotalElapsedMs1, Errors1) ->
View connect to riak shell.sh
erl -remsh riak_test@127.0.0.1 -setcookie riak -name debug@127.0.0.1
@andytill
andytill / failure-diffs.md
Created Nov 16, 2016
Better eunit failure output with unite and `assertEqual`
View failure-diffs.md

Problem: an eunit test was using ?assertMatch over a large datastructure and the output was truncated and impossible to debug. The failure was:

**error:{assertMatch_failed,[{module,riak_kv_qry},
                    {line,428},
                    {expression,"Res"},
                    {pattern,"{ ok , { _ , _ , ExpectedRows } }"},
                    {value,{ok,{[<<"Subquery">>,<<"Coverage Plan">>,
                                 <<"Range Scan Start"...>>,
                                 <<"Is Start Inc"...>>,<<"Range Sc"...>>,
@andytill
andytill / Erlyberly-EUG.md
Last active Jul 27, 2016
Quick Start for the Erlyberly EUG demo using Riak TS and Erlyberly
View Erlyberly-EUG.md

Riak TS commands

for node in {1..3}; do ~/riak_ts/dev/dev$node/bin/riak stop; done
for node in {1..3}; do ~/riak_ts/dev/dev$node/bin/riak start; done

Build the cluster

View EUG demo setup.md

Please install VirtualBox 5.1.2 or compatible from https://www.virtualbox.org/wiki/Downloads, and Vagrant 1.8.5 or compatible from https://www.vagrantup.com/downloads.html. The virtual machine has been tested with these versions only.

Download the erlyberlydemo.box file from google docs, using the link https://drive.google.com/file/d/0B3ta2LL_LQZyTG8wQy1LRmJWSHM/view?usp=sharing and run the following commands. It assumes the downloaded box file is at ~/Downloads.

vagrant box add erlyberlydemo ~/Downloads/erlyberlydemo.box
mkdir erlyberlydemo
cd erlyberlydemo
vagrant init erlyberlydemo
@andytill
andytill / erlang_record_migrations.md
Last active Jun 15, 2016
erlang_record_migrations
View erlang_record_migrations.md

Erlang Record Migrations

A proposal for the syntax for migrations. Separate record definitions with the same name. Each definition has a version increment, each definition defines fields which are in addition to the previous versions.

%% the original definition for the project record, defined for an
%% old version of our application
-record(project, {
    version = 1,
    name :: binary()
You can’t perform that action at this time.