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 AppWeb.Controller do | |
| use AppWeb, :controller | |
| # sending bytes | |
| def show(conn, %{"id" => id}) do | |
| data = Storage.get_data_for_file_id(id) | |
| conn | |
| |> put_resp_header( | |
| "content-disposition", |
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 Someapp.FileStore do | |
| @type key :: String.t() | |
| @type data :: binary | |
| @type options :: keyword | |
| @callback put(key, data, options) :: :ok | {:error, atom} | |
| @callback get(key) :: {:ok, data} | {:error, atom} | |
| @callback download(key, Path.t()) :: :ok | {:error, atom} | |
| @callback upload(key, Path.t(), options) :: :ok | {:error, atom} | |
| @callback stream_down(Plug.Conn.t(), key, options) :: Plug.Conn.t() | no_return |
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
| exports.files = { | |
| javascripts: { | |
| joinTo: 'js/app.js' | |
| }, | |
| stylesheets: { | |
| joinTo: 'css/app.css' | |
| } | |
| } | |
| exports.conventions = { |
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
| {{ define "main" }} | |
| <div id="wrapper"> | |
| <div id="sidebar"> | |
| {{ partial "sidebar-sections-list.html" .Site.Sections }} | |
| </div> | |
| <div id="content"> | |
| <!-- ... --> | |
| </div> | |
| </div> | |
| {{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
| "abcdefghijklmnopqrstuvwxyzäüößABCDEFGHIJKLMNOPQRSTUVWXYZÄÜÖ" |> String.codepoints() |
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 ExampleChecker do | |
| use Hound.Helpers | |
| use GenStage | |
| def start_link(arg \\ []), | |
| do: GenStage.start_link(__MODULE__, arg, []) | |
| def init(_) do | |
| try do | |
| session_id = Hound.start_session() |
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
| import Foundation | |
| import PlaygroundSupport | |
| PlaygroundPage.current.needsIndefiniteExecution = true | |
| // either throws an Error or returns a String result | |
| typealias ThrowsCallback = () throws -> (String) | |
| enum AsyncError: Error { | |
| case kaboom | |
| } |
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
| import Foundation | |
| // either throws an Error or returns a String result | |
| typealias ThrowsCallback = () throws -> (String) | |
| enum AsyncError: Error { | |
| case kaboom | |
| } | |
| func asyncActionWithCallback(_ someData: String, callback: @escaping (ThrowsCallback) -> Void) { |
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 App do | |
| defmacro protect(do: block) do | |
| quote do | |
| try | |
| unquote(block) | |
| rescue | |
| error -> {:error, error} | |
| end | |
| end | |
| end |