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
@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
require 'yaml'
YAML::ENGINE.yamler= 'syck'
@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.
@dcrec1
dcrec1 / centos
Last active March 24, 2017 11:52
ubuntu/centos nginx
cd /tmp
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release*.rf.i386.rpm
yum install readline-dev htop
@kdabir
kdabir / validate_positive.md
Created December 12, 2012 05:49
rspec/shoulda validate only positive values (numericality)

for something like this in rails model

...  
validates :points, :numericality => {:greater_than_or_equal_to => 0}, :allow_nil => true
...

test can be :

it { should validate_numericality_of(:points) }

it { should_not allow_value(-1).for(:points) }

@luk3thomas
luk3thomas / _readme.md
Last active August 7, 2018 21:27
A config wrapper for Elixir
@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

@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.

@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)
@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