Skip to content

Instantly share code, notes, and snippets.

View ChristopheBelpaire's full-sized avatar

Christophe Belpaire ChristopheBelpaire

View GitHub Profile
I have :
Router.map(function() {
this.resource('dashboards', { path: '/' }, function() {
this.resource('dashboardsEdit', {path: ':id'}, function() {
this.route('newWidget', {path: 'new'});
});
});
});
@ChristopheBelpaire
ChristopheBelpaire / sublist.exs
Created December 12, 2014 12:17
My 'sublist' solution for exercism.io
defmodule Sublist do
defp count(l) do
count(l,0)
end
defp count([], size) do
size
end
@ChristopheBelpaire
ChristopheBelpaire / gist:d4c259c13ff6199fe0b6
Last active August 29, 2015 14:24
Spiral with logo DSL
class Turtle
DIRECTIONS = [:UP, :RIGHT, :DOWN, :LEFT]
def initialize(size)
@size = size
@array = Array.new(size)
@array.map! {|line| line = Array.new(size, " ")}
@direction = :RIGHT
@x = 0
@y = 0
@ChristopheBelpaire
ChristopheBelpaire / gist:3c94a7ec58ff57b2f3a219aca5d15830
Last active April 11, 2017 17:24
And example of genserver using ElixirAle with set_int interruptions
defmodule GpioInput do
use GenServer
@item_in_pin 17
def start_link() do
GenServer.start_link(__MODULE__, [], [])
end
def init(_) do
Mix.install([{:axon, "~> 0.6"}, {:nx, "~> 0.7"}, {:exla, "~> 0.7"}, {:stb_image, "0.6.6"}, {:kino, "~> 0.8"}])
defmodule CatsAndDogs do
def pipeline(paths, batch_size, target_height, target_width) do
paths
|> Enum.shuffle()
|> Task.async_stream(&parse_image/1)
|> Stream.filter(fn
{:ok, {%StbImage{shape: {_, _, 3}}, _}} -> true