Skip to content

Instantly share code, notes, and snippets.

@norbajunior
norbajunior / Flexible Dockerized Phoenix Deployments.md
Created November 16, 2022 00:57 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
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

@norbajunior
norbajunior / markdown-details-collapsible.md
Created June 27, 2020 14:03 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@norbajunior
norbajunior / unfold.rb
Created February 25, 2018 06:19 — forked from havenwood/unfold.rb
Imitating Elixir's Stream.unfold/2 in Ruby
class Enumerator
def self.unfold tuple
new do |yielder|
loop do
current, tuple = yield tuple
yielder << current
end
end
end
end
@norbajunior
norbajunior / form_steps.rb
Created July 28, 2016 10:32 — forked from emk/form_steps.rb
Fill in multiline forms with Cucumber and Webrat
# Fill in multiple form fields using a table. Use it as follows:
#
# When I fill in the fields
# | Field 1 | Value 1 |
# | Field 2 | Value 2 |
When /^I fill in the fields$/ do |table|
table.rows_hash.each {|field, value| fill_in field, :with => value }
end
class RadioOption extends React.Component {
static propTypes = {
label: React.PropTypes.string.isRequired,
inputHtml: React.PropTypes.object,
wrapperHtml: React.PropTypes.object,
labelHtml: React.PropTypes.object,
labelAttribute: React.PropTypes.string,
idAttribute: React.PropTypes.string,
disableOptions: React.PropTypes.array,
options: React.PropTypes.array
@norbajunior
norbajunior / doc.md
Created July 15, 2016 16:57 — forked from oelmekki/doc.md
Rails + Browserify + React + es7

1. Gemfile

gem 'browserify-rails', '1.5.0' # until fix: https://github.com/browserify-rails/browserify-rails/issues/101
gem 'react-rails'

Browserify-rails allows to use browserify within assets pipeline. React-rails is here only to allow to use #react_component (and thus, prerendering).

Note that jquery-rails can be removed from Gemfile, the npm version of jquery and jquery-ujs will be used instead.

class Patient::Entrance < Salus::Model
# ja tinha no model
has_many :medical_cares, foreign_key: :patient_entrance_id
# ja tinha no model
has_one :first_medical_care,
class_name: 'MedicalCare',
foreign_key: :patient_entrance_id,
order: MedicalCare.arel_table[:id].asc
MedicalCare
.select([
MedicalCare.arel_table[:created_at],
MedicalCare.arel_table[:triage_entrance_id],
Sigtap::Occupation.arel_table[:name],
Person.arel_table[:name].as('person_name'),
Person.arel_table[:mother].as('person_mother'),
Person.arel_table[:birthdate].as('person_birthdate'),
])
.joins(:occupation, patient: :person)
@norbajunior
norbajunior / 0_user_account.rb
Last active August 29, 2015 14:26
Estrutura de Serviço de Conta de Usuário
class UserAccount
include LinkWithFacebook
include LinkWithTwitter
include SignUpWithFacebook
include SignUpWithTwitter
def initialize(params)
@user_params = params[:user]
@social_params = params[:social]
end
@norbajunior
norbajunior / .bash_profile
Last active August 29, 2015 14:26 — forked from cajun-code/.bash_profile
bash profile for rails development
source /usr/local/git/contrib/completion/git-completion.bash
complete -C "/usr/bin/gemedit --complete" gemedit
export WORKON_HOME=~/.env
export JAVA7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home
export JAVA6_HOME=/Library/Java/Home
export JAVA_HOME=$JAVA6_HOME
export PATH=$JAVA_HOME/bin:$PATH
export SBT_OPTS="-XX:MaxPermSize=256M"