Skip to content

Instantly share code, notes, and snippets.

@bryanhuntesl
bryanhuntesl / dummy-web-server.py
Last active December 8, 2020 18:43 — forked from bradmontgomery/dummy-web-server.py
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class S(BaseHTTPRequestHandler):
def do_GET(self):
-module(example1).
-export([init/0, find_by_field/2, undefined_function/2]).
-author("kevin@hypotheticalabs.com").
init() ->
code:ensure_loaded(function_missing),
process_flag(error_handler, function_missing),
ok.
@bryanhuntesl
bryanhuntesl / is_primary.erl
Created February 2, 2018 16:09 — forked from sumerman/is_primary.erl
This snippet checks whether current riak node is a primary for the given key. (Works only for the N=1 case; use itr_pop for N > 1)
is_primary_for_doc(BKey) ->
{ok, CHBin} = riak_core_ring_manager:get_chash_bin(),
DocIdx = riak_core_util:chash_key(BKey),
Itr = chashbin:iterator(DocIdx, CHBin),
MyNode = node(),
case chashbin:itr_value(Itr) of
{Idx, Node} when Node == MyNode -> true;
{_Idx, _Node} -> false
end.
@bryanhuntesl
bryanhuntesl / utility.erl
Created February 5, 2018 14:14 — forked from binarytemple/utility.md
Erlang decompiler I found on the web, works for Elixir beam files too
%% Author: PCHAPIER
%% Created: 25 mai 2010
-module(utility).
%%
%% Include files
%%
%%
%% Exported Functions
@bryanhuntesl
bryanhuntesl / YOKOZUNA.md
Last active February 6, 2018 13:18 — forked from drewkerrigan/YOKOZUNA.md
Yokozuna Setup

Create a schema based on the default one

curl "https://raw.githubusercontent.com/basho/yokozuna/develop/priv/default_schema.xml" -O
vim default_schema.xml

Upload your schema

@bryanhuntesl
bryanhuntesl / README.md
Created February 6, 2018 13:19 — forked from drewkerrigan/README.md
Make Local Universe

Make Local Universe

Vagrant

Create a CentOS 7 VM:

mkdir centos7
cd centos7
vagrant init madorn/centos7
@bryanhuntesl
bryanhuntesl / README.md
Created February 6, 2018 13:19 — forked from drewkerrigan/README.md
Erlang / Elixir in 5 Minutes or Less

Learning Erlang / Elixir Basics

Primitives

Erlang only has a few primitives that you need to worry about. Here they are below with corresponding Elixir examples.

  1. integer: Erlang: 123, Elixir: 123
  2. float: Erlang: 123.5, Elixir: 123.5
  3. atom: Erlang: hello, Elixir: :hello
  4. binary: Erlang: <<"hello">> or <<10,20>>, Elixir: "hello" or <<10,20>>
@bryanhuntesl
bryanhuntesl / README.md
Created February 6, 2018 13:19 — forked from drewkerrigan/README.md
Setting open files limit in OSX 10.11.3

Download this gist, and then run:

chmod 755 open_files_limit_mac.sh
./open_files_limit_mac.sh

Restart the system, and then run:

@bryanhuntesl
bryanhuntesl / riakpbc.md
Created February 6, 2018 13:19 — forked from drewkerrigan/riakpbc.md
A few snippets describing how to use the riakpbc node.js library

Put

var riakObj = {mykey1: "myvalue1"};

var data    = {
    key: 'my_key',
    bucket: 'my_bucket', 
    type: 'my_bucket_type',
    content = { 
@bryanhuntesl
bryanhuntesl / setup.md
Created February 6, 2018 13:19 — forked from drewkerrigan/setup.md
simple Riak default schema search setup

Simple Search 2.0 Setup

Create an index
curl -i -XPUT http://localhost:8098/search/index/my_index
Link the index to a bucket