Skip to content

Instantly share code, notes, and snippets.

View tsloughter's full-sized avatar

Tristan Sloughter tsloughter

View GitHub Profile
@tsloughter
tsloughter / erl_nif.rs
Created September 28, 2014 03:58
Erlang Nif Rust Bindings
/* automatically generated by rust-bindgen */
extern crate libc;
use libc::size_t;
use libc::ssize_t;
#[repr(C)]
pub struct ErlDrvSysInfo {
pub driver_major_version: ::libc::c_int,
pub driver_minor_version: ::libc::c_int,
pub erts_version: *mut ::libc::c_char,
#[no_mangle]
pub fn foo(env: *mut ErlNifEnv, argc: int, argv: *ERL_NIF_TERM) -> ERL_NIF_TERM {
print!("Hello World from Rust\n");
unsafe {
let a = enif_make_atom(env, ("foo".to_c_str()).unwrap());
return a;
}
}
@tsloughter
tsloughter / gist:1e16d70268182db1415a
Last active May 22, 2023 22:08
Rebar3 Profiles

Rebar3 Profiles

Motivation

Often you want to build the same project in different ways depending on context, whether it be development or preparing for production deployment. Or you want some dependencies only for use in certain contexts such as running tests and don't want them conflicting with regular dependencies or bother to be fetched and built when not needed.

Those are some of the reasons we've introduced profiles.

Directory Structure

Install makeself:

apt-get install makeself

or

brew install makeself
@tsloughter
tsloughter / git_remove_remote.sh
Created July 25, 2011 18:29
Remove all remote branches by pattern
for x in `git branch -r | grep "origin/reviewable-" `; do git push ${x%/*} :${x#*/}; done
@tsloughter
tsloughter / gist:2344451
Created April 9, 2012 16:05
cowboy rest example
%% @private
-spec init(list()) -> {ok, {SupFlags::any(), [ChildSpec::any()]}} |
ignore | {error, Reason::any()}.
init([]) ->
Dispatch = [
%% {Host, list({Path, Handler, Opts})}
{'_', [{[<<"graphs">>, graph], kw_handler, []}]}
],
RestartStrategy = one_for_one,
@tsloughter
tsloughter / erl_nif.rs
Created September 28, 2014 02:18
Erlang Nif Rust Bindings
/* automatically generated by rust-bindgen */
pub type ErlNifUInt64 = ::libc::c_ulong;
pub type ErlNifSInt64 = ::libc::c_long;
pub type ERL_NIF_TERM = ::libc::c_ulong;
pub type ERL_NIF_UINT = ERL_NIF_TERM;
pub enum Struct_enif_environment_t { }
pub type ErlNifEnv = Struct_enif_environment_t;
#[repr(C)]
pub struct ErlNifFunc {
{deps, [
{eleveldb, {git, "https://github.com/basho/eleveldb.git", {branch, "master"}}}
]}.
{overrides,
[{override, eleveldb, [
{pre_hooks, [{compile, "c_src/build_deps.sh get-deps"},
{compile, "c_src/build_deps.sh"}]},
{post_hooks, [{clean, "c_src/build_deps.sh clean"}]},
12> compile:file("test.erl", [nowarn_export_all,warnings_as_errors,{outdir, "."}]).
{ok,test}
13> beam_lib:chunks("test.beam", [compile_info]).
{ok,{test,[{compile_info,[{options,[nowarn_export_all]},
{version,"7.1"},
{source,"/home/tristan/Devel/vonnegut/test.erl"}]}]}}
> compile:file("test.erl", [nowarn_export_all,warnings_as_errors]).
{ok,test}
> beam_lib:chunks("test.beam", [compile_info]).
{ok,{test,[{compile_info,[{options,[nowarn_export_all]},
{version,"7.1"},
{source,"/home/tristan/Devel/vonnegut/test.erl"}]}]}}