Skip to content

Instantly share code, notes, and snippets.

View PhillippOhlandt's full-sized avatar

Phillipp Ohlandt PhillippOhlandt

  • Cisco Systems
  • Hamburg, Germany
  • 14:32 (UTC +02:00)
View GitHub Profile
@evadne
evadne / lecture.md
Last active October 4, 2023 23:24
How to Sell Elixir (2023)

How to Sell Elixir AGAIN (2023)

Presented by Evadne Wu at Code BEAM Lite in Stockholm, Sweden on 12 May 2023

Synopsis

We have celebrated 10 years of Elixir and also nearly 25 years of Erlang since the open source release in December 1998.

Most of the libraries that were needed to make the ecosystem viable have been built, talks given, books written, conferences held and training sessions provided. A new generation of companies have been built on top of the Elixir / Erlang ecosystem. In all measures, we have achieved further reach and maturity than 5 years ago.

@mcrumm
mcrumm / intl.ex
Created July 11, 2022 21:41
Intl data via LiveView connect params
defmodule MyAppWeb.Intl do
@moduledoc """
Loads internationalization info from socket.
"""
import Phoenix.LiveView
def on_mount(:default, _params, _session, socket) do
cparams = get_connect_params(socket)
{:cont,
@djcoin
djcoin / diagrams_kroki_api.livemd
Created February 17, 2022 13:29
Generate many types of diagrams in Livebook w/ Kroki API

Neural network from scratch in ... Elixir

Pure Elixir initial version test

inputs = [1, 2, 3, 2.5]
weights = [0.2, 0.8, -0.5, 1.0]
bias = 2.0
@cblavier
cblavier / application.ex
Last active April 30, 2023 08:33
Cowboy 2.5 proxy, used to bind a single port (on Heroku) for umbrella Phoenix applications. It supports HTTPS and websockets properly.
defmodule MasterProxy.Application do
alias MyApp.Endpoint, as: MyAppEndpoint
alias MyApp.UserSocket, as: MyAppUserSocket
alias MyOtherApp.Endpoint, as: MyOtherAppEndpoint
alias MyOtherApp.UserSocket, as: MyOtherAppUserSocket
alias Phoenix.LiveReloader.Socket, as: LiveReloadSocket
alias Plug.Cowboy
@h4cc
h4cc / helper.ex
Created April 11, 2018 12:18
Helper function for put_in for populating data in deep maps.
defmodule Helper do
# Helper function for setting values deep in a map.
# Thanks @michalmuskala!
# https://elixirforum.com/t/put-update-deep-inside-nested-maps-and-auto-create-intermediate-keys/7993/8
@doc """
Will set value at for keys deep inside data.
iex> Helper.put_in_deep(%{a: %{}}, [:a, :b, :c], 42)
@jswny
jswny / Flexible Dockerized Phoenix Deployments.md
Last active August 25, 2024 06:09
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@boydm
boydm / map_difference.ex
Last active December 21, 2019 12:14
Elixir meyers_difference for Maps
defmodule Boydm.Utilities.Map do
#============================================================================
# similar to List.meyers_difference, the below code compares two maps
# and generates a list of actions that can be applied to the first map
# to transform it into the second map.
#--------------------------------------------------------
def difference(map_1, map_2) when is_map(map_1) and is_map(map_2) do
# remove any keys from map_1 that are simply not present (at all) in map_2
@florinpatrascu
florinpatrascu / Sublime3, LSP and Elixir - notes.md
Last active March 16, 2019 11:45
Experimenting with the Universal Language Server support for Sublime Text 3 plugin and Elixir, using the Language Server Protocol.

Sublime3, LSP and Elixir - notes

Experimenting with the Universal Language Server support for Sublime Text 3 plugin, available here and Elixir, using the Language Server Protocol.

Right now, and sadly, the LSP plugin doesn't include Elixir out of the box. A bit of copying some files around and editing, is still required. I am focusing on OSX only, in this note.

Prerequisites

Install the following:

@h4cc
h4cc / with_example.exs
Created June 12, 2017 06:31
Elixir example for using "with" for a "unhappy path" lol.
#
# Checkout: WithExample.inverse_with
#
defmodule WithExample do
# Helper functions
def ok(result), do: {:ok, result}
def error(error), do: {:error, error}