Skip to content

Instantly share code, notes, and snippets.

View tsloughter's full-sized avatar

Tristan Sloughter tsloughter

View GitHub Profile
{
packageOverrides = pkgs : with pkgs; {
erlangHerokuEnv = pkgs.myEnvFun {
name = "erlangHeroku";
buildInputs = [ stdenv heroku_crashdumps ];
};
};
}
@tsloughter
tsloughter / gist:9173507
Last active August 29, 2015 13:56
Erlang Package Manager Components
[{application,erlastic_search,
"git://github.com/tsloughter/erlastic_search.git",git,
[{description,"An Erlang app for communicating with Elastic Search's rest interface."},
{publisher,[]},
{tags,["0.2.0"]},
{branches,["master","helllamer_changes","gh-pages"]}]}].
-- Function:
(<=>) :: (Show a) => B.ByteString -> a -> (B.ByteString, B.ByteString)
(<=>) x y = (x, showBS y)
-- Example usage:
infoLog ["handler" <=> "indexHandler", "handler" <=> 1]
-- Warnings:
src/Site.hs:43:22: Warning:
Defaulting the following constraint(s) to type `String'
(<=>) :: (Show a) => B.ByteString -> a -> (B.ByteString, B.ByteString)
(<=>) x y = (x, showBS y)
infoLog :: (MonadSnap m) => [(B.ByteString, B.ByteString)] -> m()
infoLog l = logError $ B.append ("[INFO] ") $
B.intercalate " " $ map (\(x,y) -> B.concat [x, "=", y]) l
showBS :: (Show a) => a -> B.ByteString
showBS = B.pack . show
Python:
>>> urlsafe_b64encode(hmac.new("secret", "message", sha256).digest())
'i19IcCmVwVmMVz2x4hhmqbgl1KeU0WnXBgoDYFeWNgs='
Haskell:
> B64.encode . B.pack . showDigest $ hmacSha256 "secret" "message"
"OGI1ZjQ4NzAyOTk1YzE1OThjNTczZGIxZTIxODY2YTliODI1ZDRhNzk0ZDE2OWQ3MDYwYTAzNjA1Nzk2MzYwYg=="
encryptedSubscribeSink c i =
awaitForever $ (\x ->
case decode (L.fromStrict x) of
Just (EncryptedSubscribeResponse (resp, _)) -> do
_ <- liftIO $ mapM (onMsg subOpts . decodeEncrypted c i) resp
return ()
Nothing ->
return ())
subscribeSink =
#[no_mangle]
extern "C" fn foo(env: *mut ErlNifEnv, argc: i32, argv: *ERL_NIF_TERM) -> ERL_NIF_TERM {
print!("Hello Foo from Rust\n");
unsafe {
let a = enif_make_atom(env, ("foo".to_c_str()).unwrap());
return a;
}
}
#[no_mangle]
#[no_mangle]
extern "C" fn foo(env: *mut ErlNifEnv, argc: i32, argv: *ERL_NIF_TERM) -> ERL_NIF_TERM {
print!("Hello Foo from Rust\n");
unsafe {
let a = enif_make_atom(env, ("foo".to_c_str()).unwrap());
return a;
}
}
#[no_mangle]
#!/bin/sh
set -e
SCRIPT_DIR="$(dirname "$0")"
RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
REL_NAME="recon_demo"
REL_VSN="1.0.0"
ERTS_VSN="6.0"
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"