A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord
sudo yum update | |
sudo amazon-linux-extras enable postgresql11 | |
sudo yum install postgresql postgresql-devel |
# Makefile for PlantUML | |
# Author: Devin Weaver (@sukima) <suki@tritarget.org> | |
# GistID: 52eacde54bf7861b19ee66a07b864583 | |
# | |
# This handles SVGs PNGs and ASCII outputs. | |
# It handles included files with the .iuml extension: !include foo.iuml | |
# All diagrams have the .uml extension and reside in the diagrams directory | |
# All output is saved to the output directory | |
# | |
# make svg - (default) build all diagrams as SVGs |
Here I wanted to share my own configuration of Visual Studio Code that I currently use when programming in Elixir. The section about Tasks and Shortcut is taken from this post: Running Elixir Tests in Visual Studio Code/ElixirLS.
If you'd like to experiment with Terraform on macOS locally, a great provider for doing so is the Docker provider. You can get set up in a few simple steps, like so:
Install Docker for Mac if you have not already.
t = [1,1,2,2,3] | |
f = fn(n) -> | |
IO.puts("starting #{n}") | |
:timer.sleep(n * 1000) | |
IO.puts("finishing #{n}") | |
n | |
end | |
tasks = Enum.map(t, fn(n) -> |
#!/usr/bin/env bash | |
set -e | |
# Formats any *.tf files according to the hashicorp convention | |
files=$(git diff --cached --name-only) | |
for f in $files | |
do | |
if [ -e "$f" ] && [[ $f == *.tf ]]; then | |
#terraform validate `dirname $f` | |
terraform fmt $f |
The goal is to support soft delete functionality in Ecto.Repo
. With the suggestion by @imranismail, another repo is created and the remaining functionalities are delegate to the original MyApp.Repo
.
The new repo get/2
and all/1
functions will exclude the soft deleted record by default. delete/1
and delete_all/1
will update the delete_at
column by default instead of deleting.
MyApp.Repo.get(MyApp.User, 1) //will return nil if record is in soft delete state
#!/bin/bash | |
SOURCE=/tmp/int.erl | |
COMPILED=/tmp/int.beam | |
test -e $SOURCE || curl https://raw.githubusercontent.com/josevalim/otp/c7e82c6b406b632a191c791a1bd2162bde08f692/lib/debugger/src/int.erl > $SOURCE | |
erlc -o ${COMPILED%int.beam} $SOURCE | |
chmod 444 $COMPILED | |
chgrp admin $COMPILED |