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
| // Impelentation Counter as a class | |
| class Counter { | |
| private var x: Int | |
| init(number: Int) { | |
| x = number | |
| } | |
| func setNumber(_ number: Int) { | |
| x = number |
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
| #!/bin/sh | |
| # Create a custom keychain | |
| security create-keychain -p travis ios-build.keychain | |
| # Make the custom keychain default, so xcodebuild will use it for signing | |
| security default-keychain -s ios-build.keychain | |
| # Unlock the keychain | |
| security unlock-keychain -p travis ios-build.keychain |
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 Storage do | |
| def start(initial) do | |
| process = spawn_link(fn -> execute(initial) end) | |
| Process.register(process, Storage) | |
| process | |
| end | |
| def execute(state) do | |
| receive do |
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
| > Storage.start([0]) | |
| > Storage.put(1) | |
| > Storage.put(2) | |
| > Storage.get() |> IO.inspect | |
| [0, 1, 2] |
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
| # Creating | |
| Agent.start_link(fn -> [0] end, name: Storage) | |
| # Update | |
| Agent.update(Storage, fn state -> state ++ [1] end) | |
| Agent.update(Storage, fn state -> state ++ [2] end) | |
| # Retreive | |
| Agent.get(Storage, fn state -> state end) |> IO.inspect |
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 Utilities do | |
| def write(content, file) do | |
| # write stuff to disk | |
| # takes long time | |
| end | |
| end | |
| defmodule Website do | |
| def index(conn, content) do | |
| # some calculations |
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 Utilities do | |
| def write(content, file) do | |
| spawn(fn -> | |
| # write stuff to disk | |
| # takes long time | |
| end) | |
| 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
| > Utilities.write(content, file) |> IO.inspect | |
| #PID<0.256.0> |
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 Utilities do | |
| def write(content, file) do | |
| # get th target process | |
| target = self() | |
| spawn(fn -> | |
| # write stuff to disk | |
| # takes long time | |
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 Website do | |
| def index(conn, content) do | |
| # some calculations | |
| Utilities.write(content, "/etc/some/secret/location") | |
| # Receving the sent message | |
| receive do | |
| result -> # use the result | |
| end | |