Skip to content

Instantly share code, notes, and snippets.

View zacky1972's full-sized avatar

Susumu Yamazaki zacky1972

View GitHub Profile
@zacky1972
zacky1972 / README.md
Created September 9, 2022 21:53
Custom exception in Elixir
  1. mix new example_error
  2. cd example_error
  3. Edit lib/example_error.ex
  4. iex -S mix
  5. Enter the following command:
try do
  raise ExampleError
rescue
@zacky1972
zacky1972 / README.md
Last active September 7, 2022 14:04
Distributed Image Processing by Node

DistributedImageProcessing

Distributed Image Processing by Node.

Installation and Usage

  1. mix new distributed_image_processing
  2. cd distributed_image_processing
  3. edit the following files:
  • mix.exs
@zacky1972
zacky1972 / horizontal_image_concat.exs
Last active April 19, 2023 10:33
Horizontal Image Concatenation
System.put_env("EVISION_PREFER_PRECOMPILED", "true") # Remove if you use a platform on which Evision does not provide a pre-compiled library.
System.put_env("EVISION_PRECOMPILED_CACHE_DIR", "#{System.user_home!()}/.cache")
Mix.install(
[
{:nx, "~> 0.3"},
{:exla, "~> 0.3"},
{:evision, "~> 0.1.2", github: "cocoa-xu/evision", tag: "v0.1.2"}
],
@zacky1972
zacky1972 / parallel_image_processing.exs
Last active August 31, 2022 07:34
Parallel Image Processing by Flow
System.put_env("EVISION_PREFER_PRECOMPILED", "true") # Remove if you use a platform on which Evision does not provide a pre-compiled library.
System.put_env("EVISION_PRECOMPILED_CACHE_DIR", "#{System.user_home!()}/.cache")
Mix.install(
[
{:nx, "~> 0.3"},
{:exla, "~> 0.3"},
{:evision, "~> 0.1.2", github: "cocoa-xu/evision", tag: "v0.1.2"},
{:flow, "~> 1.2"} # Add Flow
@zacky1972
zacky1972 / tiled_image_division.exs
Last active August 31, 2022 07:32
Tiled Image Division
System.put_env("EVISION_PREFER_PRECOMPILED", "true") # Remove if you use a platform on which Evision does not provide a pre-compiled library.
System.put_env("EVISION_PRECOMPILED_CACHE_DIR", "#{System.user_home!()}/.cache")
Mix.install(
[
{:nx, "~> 0.3"},
{:exla, "~> 0.3"},
{:evision, "~> 0.1.2", github: "cocoa-xu/evision", tag: "v0.1.2"}
],
@zacky1972
zacky1972 / vertical_image_division.exs
Last active August 31, 2022 07:30
Vertical Image Division
System.put_env("EVISION_PREFER_PRECOMPILED", "true") # Remove if you use a platform on which Evision does not provide a pre-compiled library.
System.put_env("EVISION_PRECOMPILED_CACHE_DIR", "#{System.user_home!()}/.cache")
Mix.install(
[
{:nx, "~> 0.3"},
{:exla, "~> 0.3"},
{:evision, "~> 0.1.2", github: "cocoa-xu/evision", tag: "v0.1.2"}
],
@zacky1972
zacky1972 / horizontal_image_division.exs
Last active December 18, 2023 07:02
Horizontal image division
# Setting for Evision to use precompiled version
System.put_env("EVISION_PREFER_PRECOMPILED", "true") # Remove if you use a platform on which Evision does not provide a pre-compiled library.
System.put_env("EVISION_PRECOMPILED_CACHE_DIR", "#{System.user_home!()}/.cache")
# Setting integration of Nx, EXLA and Evision
Mix.install(
[
@zacky1972
zacky1972 / Makefile
Last active November 9, 2023 03:04
HtPipe prevents the entire Elixir from terminating abnormaly by NIFs.
.phony: all clean
PRIV = $(MIX_APP_PATH)/priv
BUILD = $(MIX_APP_PATH)/obj
NIF = $(PRIV)/libnif.so
ifeq ($(CROSSCOMPILE),)
ifeq ($(shell uname -s),Linux)
LDFLAGS += -fPIC -shared
CFLAFGS += -fPIC
@zacky1972
zacky1972 / Makefile
Last active August 30, 2022 20:19
A fact given by experiments: When a NIF aborted, it will terminate the entire Elixir abnormally, even if a supervisor monitors it.
.phony: all clean
PRIV = $(MIX_APP_PATH)/priv
BUILD = $(MIX_APP_PATH)/obj
NIF = $(PRIV)/libnif.so
ifeq ($(CROSSCOMPILE),)
ifeq ($(shell uname -s),Linux)
LDFLAGS += -fPIC -shared
CFLAFGS += -fPIC
NSLog("increment")
NSLog("Testing")