Skip to content

Instantly share code, notes, and snippets.

View programisti's full-sized avatar

Zaali Kavelashvili programisti

  • Tbilisi, Georgia
View GitHub Profile
```elixir
defmodule Riptreaver.API.TargetGroupController do
use Riptreaver.Web, :controller
plug PolicyWonk.Enforce, roles: [:admin, :advertiser]
plug :load_target_groups when action in [:index]
plug :load_target_group when action in [:show, :update, :delete, :create_target]
plug PolicyWonk.Enforce, :target_group when action in [:show, :update, :delete]
alias Riptreaver.{Account, ErrorView}
def index(conn, _params) do
-- FUNCTION: api.search_job(character varying, integer, integer, integer)
-- DROP FUNCTION api.search_job(character varying, integer, integer, integer);
CREATE OR REPLACE FUNCTION api.search_job(
keyword character varying,
rategt integer,
ratelt integer,
session integer)
defmodule Context do
@moduledoc false
defmacro __using__(opts) do
repo = Keyword.fetch!(opts, :repo)
quote do
import Context, only: [context: 1, context: 2]
Module.put_attribute(__MODULE__, :__repo__, unquote(repo))
# frozen_string_literal: true
# rubocop:disable Style/Documentation
class FlightManager
def add_new_flight(flight_number, origin, destination)
@flights ||= []
flight = {flight_number: flight_number, origin: origin, destination: destination}
already_added = @flights.include?(flight)
@flights.push(flight) unless already_added