Skip to content

Instantly share code, notes, and snippets.

View elvanja's full-sized avatar

Vanja Radovanović elvanja

View GitHub Profile
@elvanja
elvanja / boolean_query.ex
Last active November 27, 2023 14:45
Boolean query lexer (not AST unfortunately)
defmodule BooleanQuery do
use Ecto.Type
import Gettext
def type, do: :string
@operator_expressions %{
"AND" => {:operator, "+"},
"UND" => {:operator, "+"},
50 4f 53 54 20 2f 61 70 P O S T / a p
69 2f 61 70 70 6c 69 63 i / a p p l i c
61 74 69 6f 6e 73 2f 62 a t i o n s / b
34 30 62 64 36 66 61 2d 4 0 b d 6 f a -
36 39 33 63 2d 34 39 34 6 9 3 c - 4 9 4
36 2d 39 63 38 35 2d 34 6 - 9 c 8 5 - 4
62 61 66 66 39 63 61 62 b a f f 9 c a b
36 63 63 2f 64 6f 63 75 6 c c / d o c u
6d 65 6e 74 73 20 48 54 m e n t s H T
54 50 2f 31 2e 31 0d 0a T P / 1 . 1 . .
@elvanja
elvanja / build_elastic_search_mapping.ex
Created September 10, 2020 13:16
Build Elasticsearch mapping schema from given Elixir struct's typespec
defmodule DataKiosk.Utils.BuildElasticsearchMapping do
@moduledoc """
██╗ ██╗███████╗██████╗ ███████╗ ██████╗ ███████╗ ██████╗ ██████╗ █████╗ ██████╗ ██████╗ ███╗ ██╗███████╗
██║ ██║██╔════╝██╔══██╗██╔════╝ ██╔══██╗██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██╔════╝ ██╔═══██╗████╗ ██║██╔════╝
███████║█████╗ ██████╔╝█████╗ ██████╔╝█████╗ ██║ ██║██████╔╝███████║██║ ███╗██║ ██║██╔██╗ ██║███████╗
██╔══██║██╔══╝ ██╔══██╗██╔══╝ ██╔══██╗██╔══╝ ██║ ██║██╔══██╗██╔══██║██║ ██║██║ ██║██║╚██╗██║╚════██║
██║ ██║███████╗██║ ██║███████╗ ██████╔╝███████╗ ██████╔╝██║ ██║██║ ██║╚██████╔╝╚██████╔╝██║ ╚████║███████║
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
Builds Elasticsearch mapping for given module.

Keybase proof

I hereby claim:

  • I am elvanja on github.
  • I am elvanja (https://keybase.io/elvanja) on keybase.
  • I have a public key whose fingerprint is 59E2 B0F6 C04F 68AF 1220 84B4 3C92 4F81 C91B B39A

To claim this, I am signing this object:

@elvanja
elvanja / Dockerfile
Last active January 8, 2016 10:11
Docker images to help recreate https://github.com/npm/npm/pull/10582 situation
# =====================================
# CentOS version
# =====================================
FROM centos
RUN yum install -y \
gcc-c++ \
make \
vim
@elvanja
elvanja / bare_repository.rb
Created February 19, 2015 20:43
Repository template
# https://github.com/mikeebert/repository_template/blob/master/lib/base_repository.rb
module InMemory
class BaseRepository
class RecordNotFound < StandardError
def initialize(id)
@id = id
end
def to_s
@elvanja
elvanja / jQuery-UI-slider-for-dynamic-content.markdown
Last active August 29, 2015 14:08
A Pen by Vanja Radovanović.
@elvanja
elvanja / dynamicSlider.js
Created November 4, 2014 21:48
A take on jQuery UI Slider with slide handle adapting to dynamically generated content. See it in action @ http://codepen.io/elvanja/pen/pqrFG
var DynamicSlider = function() {
var config = {
wrapperSelector: '#slider-bar-wrap',
barSelector: '#slider-bar',
paneSelector: '#slider-pane',
contentSelector: '#slider-content',
paddingRight: 0,
focus: true
};
@elvanja
elvanja / multiple_curies_for_hal_links.md
Last active August 29, 2015 14:06
Proposal to support multiple curies for links
@elvanja
elvanja / angular_rails_testing.md
Last active April 18, 2018 09:19
Angular JS and Rails testing