<commit_before>defmodule Blinker do
  use GenServer

  def start_link(pin, opts) do
    {:ok, pid} = Gpio.start_link(pin, :output)
    GenServer.start_link(__MODULE__, pid, opts)
    blink_forever(pid)
  end

  def handle_call(:on,  _from, pid), do: {:reply, Gpio.write(pid, 1)}
  def handle_call(:off, _from, pid), do: {:reply, Gpio.write(pid, 0)}

  def blink_forever(pid) do
    # Turn on the green LED and sleep for 1000ms
    #Logger.debug "Turning ON green"
    Gpio.write(pid, 1)

    :timer.sleep 1000

    # Turn off the green LED and sleep for 1000ms
    #Logger.debug "Turning OFF green"
    Gpio.write(pid, 0)

    :timer.sleep 1000

    # Blink again
    blink_forever(pid)
  end

end

defmodule Neopixel.Supervisor do
  use Supervisor

  def start_link do
    Supervisor.start_link(__MODULE__, [])
  end

  def init([]) do
    children = [
      worker(Blinker, [18, [name: :blinker]])
    ]
    supervise(children, strategy: :one_for_one)
  end
end

defmodule Neopixel do
  use Application
  require Logger
  require Gpio

  def start(_type, _args) do<commit_msg>Simplify the code a little<commit_after>defmodule Blinker do
  require Gpio
  use GenServer

  def start_link(pin, opts) do
    {:ok, pid} = Gpio.start_link(pin, :output)
    GenServer.start_link(__MODULE__, pid, opts)
  end

  def handle_call(:on,  _from, pid), do: {:reply, Gpio.write(pid, 1)}
  def handle_call(:off, _from, pid), do: {:reply, Gpio.write(pid, 0)}

  def blink_forever(pid) do
    Gpio.write(pid, 1)

    :timer.sleep 1000

    Gpio.write(pid, 0)

    :timer.sleep 1000

    blink_forever(pid)
  end

end

defmodule Neopixel.Supervisor do
  use Supervisor

  def start_link do
    Supervisor.start_link(__MODULE__, [])
  end

  def init([]) do
    children = [
      worker(Blinker, [18, [name: :blinker]])
    ]
    supervise(children, strategy: :one_for_one)
  end
end

defmodule Neopixel do
  use Application
  require Logger

  def start(_type, _args) do
{'fraction_non_alphanumeric': 0.10798362333674513, 'fraction_numerical': 0.01842374616171955, 'mean_word_length': 3.354120267260579, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2681338', 'n_tokens_mistral': 762, 'n_tokens_neox': 714, 'n_words': 198}