Skip to content

Instantly share code, notes, and snippets.

View shamil614's full-sized avatar

scott hamilton shamil614

View GitHub Profile
@aanari
aanari / install_pg11_al2.sh
Last active May 9, 2023 14:00
Install Postgres 11 on Amazon Linux 2
sudo yum update
sudo amazon-linux-extras enable postgresql11
sudo yum install postgresql postgresql-devel
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

@sukima
sukima / Makefile
Last active December 14, 2018 17:45
Makefile for compiling PlantUML diagrams
# 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
@brianshumate
brianshumate / docker-macos-terraform.md
Last active April 16, 2024 02:18
The Simplest Terraform with Docker on macOS

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:

1. Install Docker

Install Docker for Mac if you have not already.

@mmartinson
mmartinson / gist:79ac288f4233202f2e7c12d9a4a7a397
Created December 27, 2016 22:33
Elixir Task async/await example
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) ->
@jamtur01
jamtur01 / pre-commit
Created October 18, 2016 21:54
A Terraform validation and formatting pre-commit hook
#!/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
@ahmadshah
ahmadshah / README.md
Last active January 6, 2021 15:21
Ecto Soft Delete

Soft Delete Ecto Repo

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.

Example

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