defmodule Dataset do
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 OperationsTest do | |
use ExUnit.Case, async: true | |
def make_mod() do | |
String.to_atom("Elixir.Test#{System.unique_integer([:positive])}") | |
end | |
describe "operation/2" do | |
setup do | |
mod = make_mod() |
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 Main do | |
import TypedStruct | |
typedstruct do | |
field :id, integer(), enforced?: true | |
field :body, String.t(), default: "Foo" | |
field :count, integer() | |
field :metadata, map(), default: %{foo: :bar}, redacted?: true | |
end |
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
import { mapState as originalMapState } from "vuex"; | |
// Utilities to map the record fields to their function return types | |
// See https://github.com/microsoft/TypeScript/issues/15763#issuecomment-364205392 | |
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never; | |
type MappedOutputs<T> = { | |
[P in keyof T]: () => ReturnType<T[P]>; // This is a lambda so it fulfills vuex's contract | |
}; | |
type MapperRecord<S> = Record<string, (store: S) => any>; |
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
// ... | |
import { define, LiveElement } from "./live_element"; | |
define("foo", { | |
mounted() { | |
console.log("MOUNTED:", this.el); | |
}, | |
}); |
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
Part 1 | |
G|-11------------14---16--|-9-------9--------7---9----|-11--11--11--12--11---9----| | |
D|------------------------|---------------------------|---------------------------| | |
A|-----------14-----------|-9-------9-----------------|-10------------------------| | |
D|-9----------------------|---------------------------|---------------------------| | |
G|-9----7----9----7----|-11------------14---16--|-9-------9--------7---9----|-11--11--11--12--11---9----| | |
D|---------------------|------------------------|---------------------------|---------------------------| |
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
# Account settings | |
- put("/account/meta", MetaController, :update) | |
- post("/account/avatar", MetaController, :upload_avatar) | |
post("/account/cover", MetaController, :upload_cover) | |
+ put("/account/settings", SettingController, :update) | |
+ post("/account/reset_pass", UserController, :reset_pass) | |
# Mod specific routes | |
# TODO move to an admin protected scope | |
post("/moderation/ban", ModerationController, :ban_user) |
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
// @ts-check | |
import union from "./union.js" | |
const Option = union("Option", { | |
Some: ["value"], | |
None: [] | |
}); | |
const val = Option.Some(5) |
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
Limit (cost=1.28..2065.14 rows=51 width=648) (actual time=0.187..3411.776 rows=1 loops=1) | |
Output: f0.id, f0.user_id, f0.post_id, p1.id, p1.body, p1.user_id, p1.nesting_level, p1.replies_count, p1.shares_count, p1.parent_id, p1.related_to_id, p1.old_attachment, p1.deleted_at, p1.inserted_at, p1.updated_at, p2.id, p2.body, p2.user_id, p2.nesting_level, p2.replies_count, p2.shares_count, p2.parent_id, p2.related_to_id, p2.old_attachment, p2.deleted_at, p2.inserted_at, p2.updated_at | |
Buffers: shared hit=390937 read=186905 | |
-> Nested Loop Left Join (cost=1.28..780542.45 rows=19288 width=648) (actual time=0.186..3411.775 rows=1 loops=1) | |
Output: f0.id, f0.user_id, f0.post_id, p1.id, p1.body, p1.user_id, p1.nesting_level, p1.replies_count, p1.shares_count, p1.parent_id, p1.related_to_id, p1.old_attachment, p1.deleted_at, p1.inserted_at, p1.updated_at, p2.id, p2.body, p2.user_id, p2.nesting_level, p2.replies_count, p2.shares_count, p2.parent_id, p2.related_to_id, p2.old_attachment, p2.deleted_at, p2.ins |
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 MyApp.Repo do | |
use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.Postgres | |
import Ecto.Query | |
alias __MODULE__ | |
@doc """ | |
Preloads *n* items per entity for the given association, similar to an `INNER JOIN LATERAL`, | |
but using window functions. |