Skip to content

Instantly share code, notes, and snippets.

@Slavenin
Slavenin / fields.ex
Last active October 20, 2022 06:52
Implementation protocol Jason.Encoder with a group of fields support
defmodule MyApp.Serializer.Fields do
defmacro __using__(fields) do
quote do
@json_group_fields unquote(fields)
def get_fields_for_group(group) do
group = MapSet.new(group)
Enum.reduce(@json_group_fields, [], fn {f, g}, acc ->
g = MapSet.new(g)
@Slavenin
Slavenin / GraphController.php
Last active February 16, 2021 12:38
class dependency graph visualization in 3d space with threejs
<?php
namespace App\Http\Controller\Graph;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\ManyToMany;
use Doctrine\ORM\Mapping\ManyToOne;
@Slavenin
Slavenin / mix.ex
Created November 2, 2023 14:28
lesson 7 snippets
defmodule Test.MixProject do
use Mix.Project
def project do
[
app: :test,
version: "0.1.0",
elixir: "~> 1.15",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,