This file contains hidden or 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
| { | |
| "mode": "post", | |
| "tokenPresent": false, | |
| "collapsedFlyout": { | |
| "navigatedPathname": "/order/status" | |
| }, | |
| "lightTheme": { | |
| "pathname": "/home" | |
| }, | |
| "routes": { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| # Pin variable from previous match | |
| with %{account_id: account_id} <- conn.assigns.current_user, | |
| customer = %{account_id: ^account_id} <- | |
| Customers.get_customer!(id, preloads) do | |
| assign(conn, :current_customer, customer) | |
| else | |
| _ -> ChatApiWeb.FallbackController.call(conn, {:error, :not_found}) |> halt() | |
| end | |
| # Match on same value |
This file contains hidden or 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
| // How to extract components to HOC | |
| // Think of HoC as vue slots, we leverage it to makeing views mostly | |
| // identical to each other except few things like text on bottom or extra images | |
| // or swapping some children components | |
| // https://www.patterns.dev/posts/hoc-pattern/ | |
| // step 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| schema = Joi.array().items( | |
| Joi.object({ | |
| status: Joi.any().valid("ACTIVE").strip(), | |
| id: Joi.string(), | |
| }), | |
| Joi.object({ | |
| status: Joi.any().valid("DEACTIVATED"), | |
| id: Joi.string(), | |
| }).strip() | |
| ) |
This file contains hidden or 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
| defmacro is_uuid(value) do | |
| quote do | |
| is_binary(unquote(value)) and byte_size(unquote(value)) == 36 and | |
| binary_part(unquote(value), 8, 1) == "-" and binary_part(unquote(value), 13, 1) == "-" and | |
| binary_part(unquote(value), 18, 1) == "-" and | |
| binary_part(unquote(value), 23, 1) == "-" | |
| end | |
| end |
This file contains hidden or 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 YourApp.Repo.Schema do | |
| @moduledoc """ | |
| Example: | |
| def YourApp.Blog do | |
| use YourApp.Repo.Schema | |
| end | |
| iex> %YourApp{} |> Jason.encode!() | |
| """ |
This file contains hidden or 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
| Print a linked list reverse | |
| - Using recursive loop to reach the end, then print value | |
| <?php | |
| function print_node($node) { | |
| if ($node->next) { | |
| print_node($node->next); | |
| } | |
| var_dump($node->value); | |
| } |
This file contains hidden or 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
| Given a list of people [A,B,C,D,E] | |
| - with an average speed to cross a bridge [1,3,5,7,9] | |
| - only 2 people can go at a same time | |
| - they have to take a flashlight when crossing the bridge(which mean after crossing, one must run back) | |
| Calculate the shortest time it takes for the whole group to go to other side of the bridge | |
| <?php | |
| /** |