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
<!-- | |
* Copyright (c) 2021 GraphQL Contributors | |
* All rights reserved. | |
* | |
* This code is licensed under the MIT license. | |
* Use it however you wish. | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> |
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
let a = [null, {status: 'OK'}]; | |
switch_( | |
(err, _) => console.log('error', err), | |
(_, resp) => console.log('response', resp) | |
)(a); | |
// logs 'response' { "status": "OK" } | |
let b = [{err: 401}, null]; |
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
module Editable exposing (..) | |
type Editable ofType | |
= NotEditing { value : ofType } | |
| Editing { originalValue : ofType, buffer : ofType } | |
value : Editable ofType -> ofType | |
value editable = |
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
# You will need fswatch installed (available in homebrew and friends) | |
# The command below will run tests and wait until fswatch writes something. | |
# The --stale flag will only run stale entries, it requires Elixir v1.3. | |
fswatch lib/ test/ | mix test --stale --listen-on-stdin |
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 ast | |
import inspect | |
import os | |
def get_short_lambda_source(lambda_func): | |
"""Return the source of a (short) lambda function. | |
If it's impossible to obtain, returns None. | |
""" | |
try: |
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 DBTransactions do | |
use ExUnit.CaseTemplate | |
setup_all do | |
Ecto.Adapters.SQL.begin_test_transaction(Repo) | |
on_exit fn -> | |
Ecto.Adapters.SQL.rollback_test_transaction(Repo) | |
end | |
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
defmodule Lab do | |
defmacro say({:when, _, [message, condition]}) do | |
{result, _} = Code.eval_quoted(quote do | |
case true do | |
true when unquote(condition) -> true | |
true -> false | |
end | |
end) | |
if result 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 Lab do | |
defmacro say({:when, _, [message, condition]}) do | |
{result, _} = Code.eval_quoted(condition) | |
if result do | |
quote do | |
IO.puts unquote(message) | |
end | |
end | |
end |
Based on tests on my machine (2013 MacBook Pro, 2.6 GHz i7, 16 GB RAM) generated by https://github.com/pragdave/map_performance
Elixir v1.0.4
NewerOlder