Skip to content

Instantly share code, notes, and snippets.

View radzserg's full-sized avatar

Sergey Radzishevskii radzserg

View GitHub Profile
defmodule App.Es.EsQueryDsl do
defstruct query: [], _source: %{include: ["id"]}
def get_param(map, key) do
val = Map.get(map, key)
val = if val != "", do: val, else: nil
if is_list(val) && length(val) == 0, do: nil, else: val
end
defmodule App.EsDocument.EsAdvAccount do
@behaviour App.Es.DocumentBehavior
alias App.Repo
alias App.AdvAccount
alias App.Es.EsQuery
alias App.Es.EsDocument
use EsDocument
@radzserg
radzserg / es_adv_account_search.ex
Last active February 1, 2017 16:07
An example of building search ES query
defmodule App.EsDocument.EsAdvAccount do
@behaviour App.Es.DocumentBehavior
alias App.Repo
alias App.AdvAccount
alias App.Es.EsQuery
alias App.Es.EsDocument
use EsDocument
@radzserg
radzserg / es_document.ex
Created January 30, 2017 19:25
EsDocument encapsulates some reusable functionality for other ES document modules.
defmodule App.Es.EsDocument do
alias App.Es.EsClient
alias App.Es.EsQuery
defmacro __using__(_) do
quote do
@doc """
Re-create index for document - delete and create with specified mapping
"""
@radzserg
radzserg / app.sync_es.ex
Created February 1, 2017 16:15
sync elasticsearch and PostgreSQL
defmodule Mix.Tasks.App.SyncEs do
use Mix.Task
import App.Cli.Task
import Ecto.Query, only: [from: 1, from: 2, limit: 2, offset: 2]
alias App.Repo
alias App.AdvAccount
alias App.HashTag
alias App.EsSearch
test "get one user", %{conn: conn} do
query = "
{
users {
id
}
}
"
opts = Absinthe.Plug.GraphiQL.init(schema: Tendsup.GraphQl.Schema)
$(settings.dropZoneId).on('click', function () {
$("#file_upload").trigger("click");
return false;
});
// so far limit extension only for images
var extensionsByTypes = extensionsByTypes[appConstants.DOCUMENT.TYPE_IMAGE];
var allAllowedExtensions = extensionsByTypes;
//$.each(extensionsByTypes, function (key, value) {
<?php
namespace vendori\helpers;
use Yii;
use CJSON;
class S3DirectUpload
{
defmodule Rsed.EventDispatcher do
use GenServer
def start_link() do
GenServer.start_link(__MODULE__, :ok, name: my_name())
end
def init(:ok) do
{:ok, %{}}
end
defmodule Rsed.Test.EventDispatcher do
use ExUnit.Case, async: true
alias Rsed.EventDispatcher
setup do
dispatcher = start_supervised!(EventDispatcher)
%{dispatcher: dispatcher}
end