Skip to content

Instantly share code, notes, and snippets.

View pdgonzalez872's full-sized avatar
❤️

Paulo Daniel Gonzalez pdgonzalez872

❤️
View GitHub Profile
@LostKobrakai
LostKobrakai / form_live.ex
Last active April 12, 2024 18:56
Phoenix LiveView form with nested embeds and add/delete buttons
defmodule NestedWeb.FormLive do
use NestedWeb, :live_view
require Logger
defmodule Form do
use Ecto.Schema
import Ecto.Changeset
embedded_schema do
field :name, :string
@pdgonzalez872
pdgonzalez872 / hire_elixir_devs.md
Last active November 9, 2023 16:39
Hire Elixir devs - Part of an email reply to a recruiter

I'm a member of the Erlang Ecosystem Foundation (https://erlef.org/) and part of that in my opinion is making sure folks know how to reach Elixir devs when they need to. I'm very interested in helping you showcase that your company is hiring so heavily for Elixir. Since you were kind in our email exchange, I'll return the kindness and hopefully help you find as many Elixir devs you can hire :). Just promise me to keep creating more Elixir jobs : ) :

Here are some interesting ways to find Elixir devs:

@wosephjeber
wosephjeber / instructions.md
Last active May 7, 2024 13:31
Ecto migration for renaming table with indexes and constraints

Renaming table in Ecto migration

I recently wanted to rename a model and its postgres table in a Phoenix app. Renaming the table was simple and documented, but the table also had constraints, sequences, and indexes that needed to be updated in order for the Ecto model to be able to rely on default naming conventions. I couldn't find any examples of what this would look like but was eventually able to figure it out. For anyone else in the same situation, hopefully this example helps.

In the example below, I'm renaming the Permission model to Membership. This model belongs to a User and an Account, so it has foreign key constraints that need to be renamed.

defmodule MyApp.Repo.Migrations.RenamePermissionsToMemberships do
  use Ecto.Migration
defmodule MyApp.Auth do
import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0]
alias MyApp.Accounts.User
alias MyApp.Repo
def login(conn, user) do
conn
|> Guardian.Plug.sign_in(user)
end
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 10, 2024 16:49
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname