Skip to content

Instantly share code, notes, and snippets.

@mbenatti
mbenatti / 0-font-awesome-bootstap-phoenix.md
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
mbenatti / deploy_dokku.md
Last active May 24, 2021 12:53 — forked from nhu313/deploy_dokku.md
Deploying phoenix on Dokku through Digital ocean
@mbenatti
mbenatti / Description.md
Created June 29, 2017 20:08 — forked from juanje/Description.md
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@mbenatti
mbenatti / install-opencv-2.4.13-in-ubuntu.sh
Last active July 4, 2017 04:03 — forked from arthurbeggs/install_opencv2_ubuntu.sh
Install opencv-2.4.13 in Ubuntu 16.04/Mint 18.1
# install dependencies
sudo apt-get update
sudo apt-get install -y build-essential
sudo apt-get install -y cmake
sudo apt-get install -y libgtk2.0-dev
sudo apt-get install -y pkg-config
sudo apt-get install -y python-numpy python-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install -y libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev
@mbenatti
mbenatti / vpn-auto-reconnect.sh
Created August 1, 2017 22:30 — forked from numericOverflow/vpn-auto-reconnect.sh
Auto reconnect to OpenVPN via NetworkManager
#!/bin/bash +x
# Source: http://www.gabsoftware.com/tips/automatically-reconnect-to-your-vpn-on-linux/
# Description:
# Make the script executable "chmod +x /path/to/the/script.sh
# Put the script in .profile or .bashrc so it can be run on user login:
# Example: echo "/path/to/the/script.sh start &" >> .bashrc
# The script can be bound to shortcut keys with these commands:
# /path/to/the/script.sh start # starts and monitors VPN connection
@mbenatti
mbenatti / install.sh
Created October 7, 2017 22:55 — forked from djudd/install.sh
Install Poppler from source on Heroku
cd /app/
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.10.91.tar.gz
cd fontconfig-2.10.91
tar -xzf fontconfig-2.10.91.tar.gz
./configure
make
cd /app/
wget http://poppler.freedesktop.org/poppler-0.22.1.tar.gz
tar -xzf poppler-0.22.1.tar.gz
@mbenatti
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
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@mbenatti
mbenatti / up-and-running-with-edeliver-on-do.md
Created February 20, 2018 05:56 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
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
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
end
list_1 = [[1,2,[3]],4]
list_2 = [[1,5,[3]],4,[[[1,2,[3]],4]]]
@mbenatti
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}}
end
def start_link(game_id) do
GenServer.start_link(__MODULE__, game_id, name: {:global, "game:#{game_id}"})
end