Skip to content

Instantly share code, notes, and snippets.

View iwan's full-sized avatar

Iwan Buetti iwan

  • Milano, Italy
View GitHub Profile

Elixir Cheat Sheet

See the Official Guides.

Getting Started

Command Line

Start a REPL: iex

@carlosramireziii
carlosramireziii / attached_validator.rb
Last active April 10, 2024 11:11
A validator and RSpec matcher for requiring an attachment using Active Storage
class AttachedValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :attached, options) unless value.attached?
end
end
@Ryanb58
Ryanb58 / install.md
Last active April 19, 2024 08:38
How to install telnet into a alpine docker container. This is useful when using the celery remote debugger in a dev environment.
>>> docker exec -it CONTAINERID /bin/sh
/app # telnet
/bin/sh: telnet: not found

/app # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-243-gf26e75a186 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-229-g087f28e29d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
@aashish
aashish / insert_image_on_pdf.rb
Last active February 21, 2024 17:18
Insert image on a existing PDF having content with hexapdf gem
require 'hexapdf'
doc = HexaPDF::Document.open("/home/xxxx/Downloads/OoPdfFormExample.pdf")
page = doc.pages[0]
canvas = page.canvas(type: :overlay)
canvas.translate(0, 20) do
canvas.fill_color(0.3, 0.7, 0.7)
canvas.rectangle(50, 0, 80, 80, radius: 80)
@mbenatti
mbenatti / up-and-running-with-edeliver-on-do.md
Created February 20, 2018 05:56 — forked from mattweldon/up-and-running-with-edeliver-on-do.md
Getting Elixir / Phoenix running on Digital Ocean with edeliver

Build Server

  • Go to Digital Ocean
  • Create new droplet
  • London
  • Ubuntu
  • No apps
  • Add SSH keys
@satendra02
satendra02 / app.DockerFile
Last active March 3, 2024 10:13
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran:
@mbenatti
mbenatti / 0-font-awesome-bootstap-phoenix.md
Last active February 2, 2024 14:59
Installing Bootstrap 4 + Font Awesome from NPM in Phoenix Framework using sass
  • Tested with Phoenix 1.3

1) Installing sass, font-awesome and bootstrap package's using Brunch

First, install the Sass, Font Awesome, bootstrap(and deps) package:

cd assets

  • npm install --save-dev sass-brunch
  • npm install --save font-awesome
@slavikdev
slavikdev / cheatsheet.md
Created March 16, 2017 17:54
Rails request path cheatsheet

Rails request path cheatsheet

Full path with query string

>>  request.url
=> "http://localhost:3000/ask-help.amp?hui=pizda"

Virtual path without query string

>>  request.path
=&gt; "/ask-help.amp"
@hmans
hmans / elixir_phoenix_notes.md
Last active April 4, 2018 12:33
Notes on learning Elixir and Phoenix

Notes on learning Elixir and Phoenix

Just some assorted notes I've made while digging into Phoenix, Elixir and friends. I'm coming from a strong Rails background, so many of these will refer to features from that framework.

Views / Templates

Biggest difference from Rails?

Unlike Rails, where rendering is almost always performed by a template file, the responsibility of rendering a response in Phoenix lies with a view module (that typically corresponds to the current controller module.) This view module will typically offer a whole bunch of render functions (matching different parameters, first and foremost the template name.) Templates (found in web/templates/) will directly compile into such functions.

@PieterScheffers
PieterScheffers / start_docker_registry.bash
Last active October 29, 2023 18:26
Start docker registry with letsencrypt certificates (Linux Ubuntu)
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04