This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yes i can do this in sed, why you say? becouse i want to :) | |
# s/^[^a-z \t].*//;/^$/d # Remove non-parsed lines | |
# /\[/ { :r # Start loop looking for end ] | |
# /\]/!N; s/,?\n/,/; tr; # If ending ] is not found, append and repeat | |
# } | |
# s/\s+/ /g; # Normalize spaces | |
# p # Print the pattern space | |
sed -nE 's/^[^a-z \t].*//;/^$/d; /\[/ { :r; /\]/!N; s/,?\n/,/; tr; }; s/\s+/ /g; p' $conffile | |
# Will parse: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule DBL.Message.Channel do | |
def subscribe([]), do: :ok | |
def subscribe([chan | rest]) do | |
case :pg2.join "stream/" <> chan, self do | |
{:error, {:no_such_group, _}} -> | |
:ok = :pg2.create "stream/" <> chan | |
:ok = :pg2.join "stream/" <> chan, self | |
:ok -> | |
:ok |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Lens do | |
@moduledoc """ | |
Utility to dynamically put nested keys into maps | |
``` | |
import Lens, stringkeys?: false | |
a = %{} | |
a.b.c.d <- "i'm a dddddd" | |
IO.inspect a # => %{b: %{c: %{d: "i'm a dddddd}}} | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule IP6 do | |
def parse(rest), do: parse(String.downcase(rest), "", []) | |
def parse("", "", acc), do: Enum.reverse(acc) |> Enum.map(fn(val) -> | |
case String.contains? val, "." do | |
true -> | |
val | |
false -> | |
val = "0000" <> val | |
String.slice val, byte_size(val)-4, byte_size(val) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Snippets do | |
@doc """ | |
## Example: | |
expr |> either [:ok, {:ok, _}] | |
""" | |
defmacro either(match, conds) do | |
basecond = quote do res -> res end | |
matches = Enum.reduce conds, basecond, fn(c, acc) -> | |
[quote do unquote(c) -> :ok end | acc] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Reports some basic LXC container stats to Riemann | |
require File.expand_path('../../lib/riemann/tools', __FILE__) | |
class Riemann::Tools::LXC | |
include Riemann::Tools | |
def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test MQTT sync | |
// | |
// usage: | |
// - npm install mqtt request lodash | |
// - set `networks` to array of networks you want to scan | |
// - set `auth` to (user,pw) combo | |
// - set `broker` to something like mqtt://test.mosquitto.org | |
// - don't be to eager on `reloadInterval` as node fails?? seems to keep sockets open for to long | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Happy case-insensitive hex decoder which supports optional | |
* byte separators. | |
* | |
* `out` is a pointer to zero filled memory | |
* | |
* `size` is the size of `out` | |
* | |
* `in` MUST be null-terminated string. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
, tinysix_g_addr#include "path.h" | |
#include <sqlite3.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdint.h> | |
#include <unistd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDS5rnv8BtfAUhki3sRYzH2SLk6qo9aSAACNNEFijTyUMf1bjR4cFsFMcVxelpgFZym3J8eaIv+3Dfe6Fc0FyogCBaBa7YXXtmC26GiLnZI8ApeGZ5qZyLEIQm5NOjnUJXZmvVunjObusuNWF2EoaK+JftmwvdpF3A+ZMmtecon8Y6u6po2ngLn1FJ0rjiegCxcSvT3YvzCfbgL6U13qULVX32YpvQjdLroBdFZuOXnQ4fkrwoiFiXrc43k352gPDxQJHWsXSfZctC09Jv4HGqwBPTqBMf3hmghPIFYVyLTFU/J2lvyCfDz+23L9WybP8XY4MTmPZSAVpvgJ0Oxn2gg+I8lb2TrnHqY/9HqdOxyo8qWgLMjQIwg6GabpWUVBzujh6xKjp1skyVSzIL14MWIyjdBd0deYdqGzRU+jHrgVl7+b5gOKxZIKSj2TmjHoEkuGp7obYVBqssU/UCyrUYLHjRvsoQaOoogJFDS2addXjVbxHn5i/GE3ZsoNeIKiLCBV8gaRq5W7yRBuTVvsqZQNXsICmkJFeXLVR5X1GLgJQFbHaticoua7wDQx/sGV0FPYlR9UVud90FPbBfoC3dJx5jb6Cs1WWNPDVc+sdCMhb206X7svMcafYfbdCDSd2iuujXzYnbkF0XWvk5tqn3MAJcwh4eKxJvH02EN2R48USZgq2jzhgTbGjo5wHB7aEMMaGOsMSPUq4y4HBIxO/wYDHerhyyOdcV6agsB6kC6Q/nnzwi092yNbWseoeFQPF1f91S4IaNc7Q+IGBdy/QSf7s+6dtkyNGenGv/6y91hU1f0d7Ti8WPqQJMxIEJkdeKp8d1xf175LzlS78L+ltGzGcWRuUrxQ/jxR/GLLHORcMj+hcUhRrQpvUulvyR7zxfM05ZnVeVCflMmW+/3vhWwLq/lTOYVOqNkvB5MTo4EhQYvgt/cdbHZapdl1OErl7Bt//frJYmwxAgmipCt8P4IpxI+ |