Created
March 12, 2018 14:03
-
-
Save g-andrade/0f5692daa3d7993da506a3cd8138a911 to your computer and use it in GitHub Desktop.
Erlang big binary blob generator
This file contains 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
-module(fatbin). | |
-export([generate/1]). | |
generate(Size) -> | |
generate(Size, 1024). | |
generate(Size, BlockSize) -> | |
NumOfBlocks = | |
case Size rem BlockSize of | |
0 -> Size div BlockSize; | |
_ -> (Size div BlockSize) + 1 | |
end, | |
Block = << <<0>> || _ <- lists:seq(1, BlockSize) >>, | |
Blocks = [Block || _ <- lists:seq(1, NumOfBlocks)], | |
iolist_to_binary(Blocks). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment