Skip to content

Instantly share code, notes, and snippets.

Mario Flach redrabbit

Block or report user

Report or block redrabbit

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View zlib_infate.c
ERL_NIF_TERM
geef_object_zlib_inflate(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
ErlNifBinary bin;
char chunk[1024];
int error;
z_stream z;
z.zalloc = Z_NULL;
z.zfree = Z_NULL;
z.opaque = Z_NULL;
View pack-delta.hs
readCopyInstruction :: (Integral a) => Word8 -> Get (a, a)
readCopyInstruction opcode = do
-- off -> offset in the source buffer where the copy will start
-- this will read the correct subsequent bytes and shift them based on
-- the set bit
offset <- foldM readIfBitSet 0 $ zip [0x01, 0x02, 0x04, 0x08] [0,8..]
-- bytes to copy
len' <- foldM readIfBitSet 0 $ zip [0x10, 0x20, 0x40] [0,8..]
let len = if coerce len' == 0 then 0x10000 else len'
-- FIXME add guard condition from `patch-delta.c`: if (unsigned_add_overflows(cp_off, cp_size) || ...
@redrabbit
redrabbit / recursive_path_iterator.ex
Created Jul 26, 2017
Lazy path iterator in Elixir
View recursive_path_iterator.ex
defmodule RecursivePathIterator do
@moduledoc """
This module provides a simple interface for iterating over filesystem directories.
"""
@doc """
Walks the given `path` recursively.
"""
@spec walk(Path.t) :: Enumerable.t
def walk(path) do
@redrabbit
redrabbit / geometry.rs
Created Jun 29, 2017
Rust implementation of a Geometry trait (area, perimeter)
View geometry.rs
use std::fmt;
trait Geometry: fmt::Display {
fn perimeter(&self) -> f32;
fn area(&self) -> f32;
}
//
// Point
//
@redrabbit
redrabbit / mutable_bucket.ex
Last active Jun 29, 2017
Elixir mutable bucket via :ets
View mutable_bucket.ex
defmodule Bucket do
@moduledoc """
A mutable "bucket" implementing the `Access` behaviour.
"""
@behaviour Access
defstruct [:ets]
@type t :: %__MODULE__{ets: term}
@redrabbit
redrabbit / absinthe_ecto_resolution_schema.ex
Last active Jul 26, 2018
Absinthe.Ecto.Resolution.Schema
View absinthe_ecto_resolution_schema.ex
defmodule Absinthe.Ecto.Resolution.Schema do
@moduledoc """
This module provides helper functions to resolve a GraphQL query into `Ecto.Query`.
"""
import Absinthe.Resolution.Helpers
import Ecto.Query
alias Absinthe.Resolution
alias Absinthe.Blueprint.Document.Field
View keybase.md

Keybase proof

I hereby claim:

  • I am redrabbit on github.
  • I am marioflach (https://keybase.io/marioflach) on keybase.
  • I have a public key ASAtsbkNpV5OCHoVw7r6FNG8j9qz_93f2bAmBmXffE14wgo

To claim this, I am signing this object:

@redrabbit
redrabbit / notification.cpp
Last active Jun 29, 2017
Generic C++ notification dispatcher with boost::signal2
View notification.cpp
#include <map>
#include <queue>
#include <typeinfo>
#include <iostream>
#include <boost/signals2/signal.hpp>
#include <boost/type_traits/is_base_of.hpp>
class notification_interface
@redrabbit
redrabbit / opencv_threshold.c
Last active Jun 29, 2017
OpenCV thresholding
View opencv_threshold.c
IplImage* createThresholding( IplImage* source, const CvScalar& min, const CvScalar& max )
{
const CvSize imgSize = cvSize( source->width, source->height );
IplImage* hsv = cvCreateImage( imgSize, 8, 3 );
cvCvtColor( source, hsv, CV_BGR2HSV );
IplImage* mask = cvCreateImage( imgSize, 8, 1 );
cvInRangeS( hsv, min, max, mask );
You can’t perform that action at this time.