Skip to content

Instantly share code, notes, and snippets.

View pedroassumpcao's full-sized avatar
🌎
Being blessed

Pedro Assumpcao pedroassumpcao

🌎
Being blessed
View GitHub Profile
@luk3thomas
luk3thomas / _readme.md
Last active August 7, 2018 21:27
A config wrapper for Elixir
@jswny
jswny / Flexible Dockerized Phoenix Deployments.md
Last active July 3, 2023 05:25
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

@pmarreck
pmarreck / ecto_postgres_fulltext_search_querying_example.ex
Last active June 6, 2022 11:54
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
@mjason
mjason / Dockerfile
Last active February 25, 2024 21:51
build phoenix in docker
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y git wget curl build-essential
RUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb
RUN apt-get update
RUN apt-get install erlang -y
RUN apt-get install -y elixir
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
@somebox
somebox / domain-driven-desire-resources.md
Last active February 10, 2022 14:55
Domain-Driven Desire: Further Reading

Domain-Driven Desire: The Talk from Øredev 2016

🎥 https://vimeo.com/191051851

Links and References

Thanks for watching my talk, Domain-Driven Desire at Øredev 2016. Here's a list of resources that inspired me, and will hopefully inspire you:

Videos

@faizaanshamsi
faizaanshamsi / Attribute
Last active January 11, 2016 17:38
Circle CI for Elixir
Taken and modified from: https://gist.github.com/joakimk/48ed80f1a7adb5f5ea27
* line 4 and 13 of circle.yml reference a script/ci structure. Modify to suit.
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active March 31, 2024 11:57
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@pricees
pricees / Ruby Basic
Last active August 29, 2015 13:56
My Ruby Litmus Test.rb
# Integer vs Float div by zero gotchas
#
#
1 / 0 = [answer]
1.0 / 0 = [answer]
1 / 0.0 = [answer]
0 / 0.0 = [answer]
# String concatenation vs interpolation
x = 5
@pricees
pricees / Splitting a Ruby on a Rail
Last active August 1, 2023 18:21
How I split a fat rails model
Background
Raise.com is built on top of Spree. We have in-lined spree, and have decorators
on the models to beat the band. We want to move away from Spree altogeher.
This involves taking the models from Spree, moving them to the Raise
base app. This merge has the potential to create lots of big classes. Big classes
are difficult to maintain. One of the first steps towards returning classes/models to
being "right sized." is splitting the business logic and the persistence.
What I did
@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.