Skip to content

Instantly share code, notes, and snippets.

@yuchunc
yuchunc / median_sorted_tuple.ex
Last active August 3, 2019 06:06
Leetcode Alogorithm #4 Median of Two Sorted Arrays https://leetcode.com/problems/median-of-two-sorted-arrays/
defmodule MedianSortedTuple do
# NOTE Alogorithm 4
def attempt2(tup1, tup2) do
size1 = tuple_size(tup1)
size2 = tuple_size(tup2)
half_size = (size1 + size2 + 1) |> div(2)
if size1 > size2 do
@yuchunc
yuchunc / config
Last active April 7, 2020 04:23
Surfingkeys Config
// an example to create a new mapping `ctrl-y`
mapkey('<Ctrl-y>', 'Show me the money', function() {
Front.showPopup('a well-known phrase uttered by characters in the 1996 film Jerry Maguire (Escape to close).');
});
// an example to replace `T` with `gt`, click `Default mappings` to see how `T` works.
map("K", "R");
map("J", "E");
map("H", "S");
map("L", "D");
defmodule EctoQueryMaker do
@moduledoc """
Query builder to abstract away boilerplate queries.
"""
import Ecto.Query
alias Ecto.{Query, Queryable}
@callback apply_filter(filter :: atom | {atom, any}, query :: Query.t()) :: Query.t()