Skip to content

Instantly share code, notes, and snippets.

mbenatti /
Last active February 2, 2024 14:59
Installing Bootstrap 4 + Font Awesome from NPM in Phoenix Framework using sass
  • Tested with Phoenix 1.3

1) Installing sass, font-awesome and bootstrap package's using Brunch

First, install the Sass, Font Awesome, bootstrap(and deps) package:

cd assets

  • npm install --save-dev sass-brunch
  • npm install --save font-awesome
mbenatti /
Last active May 24, 2021 12:53 — forked from nhu313/
Deploying phoenix on Dokku through Digital ocean
mbenatti / ecto_batch_stream.ex
Created January 24, 2020 18:10 — forked from maxim/ecto_batch_stream.ex
Similar to Rails `find_each`, but for Elixir's Ecto, using Stream
defmodule EctoBatchStream do
import Ecto.Query, only: [from: 1, from: 2]
@batch_size 1000
# Example:
# query = from u in MyApp.User, select:
# stream =, query)
# stream |> Stream.take(3) |> Enum.to_list # => […]
mbenatti / postgres_queries_and_commands.sql
Created December 30, 2019 14:38 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
mbenatti /
Created June 14, 2019 18:50 — forked from subfuzion/
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.


git config --global core.excludesfile ~/.gitignore


git config --global core.excludesfile %USERPROFILE%\.gitignore
mbenatti / game.ex
Created December 1, 2018 23:00 — forked from andrewhao/game.ex
Dynamic Supervisors in Elixir
defmodule Game do
use GenServer
def init(game_id) do
{:ok, %{game_id: game_id}}
def start_link(game_id) do
GenServer.start_link(__MODULE__, game_id, name: {:global, "game:#{game_id}"})
mbenatti /
Created February 20, 2018 05:56 — forked from mattweldon/
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys
mbenatti /
Created October 7, 2017 22:55 — forked from djudd/
Install Poppler from source on Heroku
cd /app/
cd fontconfig-2.10.91
tar -xzf fontconfig-2.10.91.tar.gz
cd /app/
tar -xzf poppler-0.22.1.tar.gz
defmodule ListFlatten do
def flatten(list), do: flatten(list, []) |> Enum.reverse
def flatten([h | t], acc) when h == [], do: flatten(t, acc)
def flatten([h | t], acc) when is_list(h), do: flatten(t, flatten(h, acc))
def flatten([h | t], acc), do: flatten(t, [h | acc])
def flatten([], acc), do: acc
list_1 = [[1,2,[3]],4]
list_2 = [[1,5,[3]],4,[[[1,2,[3]],4]]]
mbenatti / task1.exs
Created November 29, 2017 05:21 — forked from moklett/task1.exs
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
def bad(message) do
IO.puts message
raise "I'm BAD!"