Follow these steps to install graphite on OS X Mavericks.
- Homebrew
- Python 2.7
- Git
| // To discover empegs connected over Ethernet, we need to broadcast a '?', and listen for the response | |
| var dgram = new byte[] { 0x3F }; // ASCII '?' | |
| var client = new UdpClient(new IPEndPoint(IPAddress.Any, 8300)); | |
| client.EnableBroadcast = true; | |
| client.Client.ReceiveTimeout = 500; | |
| client.Send(dgram, dgram.Length, new IPEndPoint(IPAddress.Broadcast, 8300)); | |
| const int retryCount = 10; | |
| for (int i = 0; i < retryCount; ++i) | |
| { |
| -module(example_server). | |
| -export([start_link/0, start/0]). | |
| -behaviour(gen_server). | |
| -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). | |
| start_link() -> | |
| gen_server:start_link({local, ?MODULE}, ?MODULE, [], []). | |
| start() -> | |
| gen_server:start({local, ?MODULE}, ?MODULE, [], []). |
| -module(partitionzipwith). | |
| -export([partitionzipwith/3]). | |
| %% @doc A combination of lists:partition/2 and lists:zipwith/3. | |
| %% Given two lists of equal length, call Combine(X, Y) for each. | |
| %% If it returns {true, T}, then T is added to Satisfying. | |
| %% If it returns {false, F}, then F is added to NotSatisfying. | |
| -spec partitionzipwith(Combine, List1, List2) -> | |
| {Satisfying, NotSatisfying} | |
| when |
| %% from /usr/include/netinet/in.h (Linux and OS X) | |
| -define(IPPROTO_TCP, 6). | |
| %% from /usr/include/netinet/tcp.h (Linux) | |
| -define(TCP_MAXSEG, 2). | |
| -define(TCP_KEEPIDLE, 4). | |
| -define(TCP_KEEPINTVL, 5). | |
| -define(TCP_KEEPCNT, 6). | |
| %% @doc If you pass multiple raw options to ssl:listen, it appears to drop all |
| lists:sort(fun({_, X}, {_, Y}) -> X > Y end, | |
| dict:to_list(lists:foldl( | |
| fun(Pid, Dict) -> | |
| InitialCall = case erlang:process_info(Pid, initial_call) of | |
| {initial_call,{proc_lib,init_p,A}} -> | |
| case erlang:process_info(Pid, dictionary) of | |
| {dictionary, D} -> proplists:get_value('$initial_call', D, undefined); | |
| _ -> {proc_lib,init_p,A} | |
| end; | |
| {initial_call,{erlang,apply,A}} -> |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #include <netinet/tcp.h> | |
| #include <stdio.h> | |
| #include <memory.h> | |
| #include <unistd.h> | |
| int main(int argc, char *argv[]) | |
| { |
| #!/usr/bin/env escript | |
| %%! -pa deps/chef_authn/ebin deps/mochijson2/ebin | |
| % Deps: | |
| % https://github.com/chef/chef_authn | |
| % https://github.com/electricimp/mochijson2 | |
| -record(opts, { | |
| node_name, | |
| client_key, |
| % Using https://github.com/Feuerlabs/netlink | |
| {ok, _} = application:ensure_all_started(lager). | |
| {ok, _} = application:ensure_all_started(netlink). | |
| {ok, Ref} = netlink:subscribe("eth1", all, [flush]). | |
| % or | |
| {ok, Ref} = netlink:subscribe("eth1", [address, operstate], [flush]). | |
| flush(). |
| #!/usr/bin/env escript | |
| %%% This script converts an arbitrary binary file to an Erlang module with a | |
| %%% single exported 'bin/0' function that returns the original binary. | |
| %%% | |
| %%% See the end of the file for how I figured out the correct terms. | |
| main(["+debug_info" | Files]) -> | |
| io:format("Embedding binaries with debug_info...\n"), | |
| lists:foreach(fun(X) -> embed_file_in_beam(X, [debug_info]) end, Files); |