View Dockerfile.phoenix.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elixir:1.10.4 | |
## | |
# Install system dependencies & tooling | |
## | |
RUN apt-get update | |
RUN apt-get -y upgrade | |
RUN apt-get install -y bash curl apt-utils build-essential inotify-tools |
View fetching_bookings_with_wall_clock_time.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 1. Create a sample table to store our bookings: | |
*/ | |
> CREATE TABLE bookings (id INT, scheduled_date DATE, start_time TIMESTAMP, end_time TIMESTAMP, timezone_id VARCHAR(40)) | |
> \d bookings | |
-- +----------------+-----------------------------+-------------+ | |
-- | Column | Type | Modifiers | | |
-- |----------------+-----------------------------+-------------| |
View inject_dependency_as_adapter.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Implementation | |
## | |
# config/config.exs | |
config :my_app, :kv_store_adapter, KVStore | |
defmodule KVStore do | |
#... | |
end |
View alacritty.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration for Alacritty, the GPU enhanced terminal emulator. | |
# Any items in the `env` entry below will be added as | |
# environment variables. Some entries may override variables | |
# set by alacritty itself. | |
# env: | |
# TERM variable | |
# | |
# This value is used to set the `$TERM` environment variable for | |
# each instance of Alacritty. If it is not present, alacritty will |
View classes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An usual class is a subclass of object | |
class Human(object): | |
# Defining class variables | |
species = "H. Sapiens" | |
def __init__(self, first_name, last_name): | |
# Assign instance variables (also called attributes): | |
self.__internal = "secret" # Private attribute (externally accessed via: human._Human_internal) | |
self.first_name = first_name # Public attribute (externally accessed via human.first_name) | |
self.last_name = last_name # Since last_name has not a getter/setter below |
View sample_api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
allPersons(last: Int): [Person!]! | |
} | |
type Mutation { | |
createPerson(name: String!, age: Int!): Person! | |
} | |
type Subscription { | |
newPerson: Person! |
View 20180711220702_create_foos.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateFoo < ActiveRecord::Migration[5.0] | |
def change | |
create_table(:foos, force: true) do |t| | |
t.text :message, null: false | |
t.datetime :created_at, null: false | |
end | |
end | |
end |
View fibonacci.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Body-recursive | |
# | |
# Note: "+" is actually the last call, not calculate/1. | |
defmodule Fibonacci do | |
def calculate(x) when x <= 2, do: 1 | |
def calculate(x), do: calculate(x - 1) + calculate(x - 2) | |
end | |
# Tail-recursive (Tail Call Optimization) | |
# |
View Dockerfile.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elixir:1.4.2 | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV HOME=/opt/app/ TERM=xterm | |
# Install Hex+Rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
WORKDIR /opt/app |
View resource.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Iugu.Resource do | |
@moduledoc """ | |
Mixin module to easily include all the common functionality across the resources. | |
""" | |
defmacro __using__([name: resource, actions: actions]) do | |
quote do | |
@derive [Poison.Encoder] | |
@resource unquote(resource) | |
defstruct unquote(fields(resource)) |
NewerOlder