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
| version: 2 | |
| jobs: | |
| build: | |
| docker: | |
| - image: circleci/python:3.6.2-stretch-browsers | |
| environment: | |
| FLASK_CONFIG: testing | |
| TEST_DATABASE_URL: postgresql://ubuntu@localhost/circle_test?sslmode=disable | |
| - image: circleci/postgres:9.6.5-alpine-ram | |
| environment: |
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
| # em.rb | |
| EM.run do | |
| EM.add_timer(1) do | |
| puts 'sleeping...' | |
| EM.system('sleep 1') { puts "woke up!" } | |
| puts 'continuing...' | |
| end | |
| EM.add_timer(3) { EM.stop } | |
| end | |
| $ ruby em.rb |
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
| puts "Iniciando deploy..." | |
| tasks = [] | |
| tasks << Thread.new do | |
| sleep(3) | |
| puts "> Executar tarefa de IO intenso" | |
| puts "= Tarefa inicial finalizada \n" | |
| 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
| # 256 colors for vim | |
| set -g default-terminal "screen-256color" | |
| # Start window numbering at 1 | |
| set-option -g base-index 1 | |
| set-window-option -g pane-base-index 1 | |
| # Cycle panes with C-b C-b | |
| unbind ^B | |
| bind ^B select-pane -t :.+ |
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
| # 256 colors for vim | |
| set -g default-terminal "screen-256color" | |
| # Start window numbering at 1 | |
| set-option -g base-index 1 | |
| set-window-option -g pane-base-index 1 | |
| # Cycle panes with C-b C-b | |
| unbind ^B | |
| bind ^B select-pane -t :.+ |
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
| # Quote an expression (turn it into an AST) | |
| foobar = quote do | |
| _ * _ = 42 | |
| end | |
| IO.inspect(foobar) | |
| # Define the function to be used when traversing the AST | |
| answers = [2, 21] | |
| put_awnsers = fn |
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 Protobuf do | |
| # alias Protobuf.Parser | |
| # alias Protobuf.Builder | |
| # alias Protobuf.Config | |
| # alias Protobuf.ConfigError | |
| # alias Protobuf.Field | |
| # alias Protobuf.OneOfField | |
| # alias Protobuf.Utils | |
| alias Mix.Compilers.Erlang |
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
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| type ErrNegativeSqrt float64 | |
| func (e ErrNegativeSqrt) Error() string { | |
| return fmt.Sprintf("cannot Sqrt negative number: %f", float64(e)) |
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 Quicksort do | |
| def sort(list) when length(list) < 2, do: list | |
| def sort(list) do | |
| pivot = Enum.random(list) | |
| less = Enum.filter(list, &(&1 < pivot)) | |
| greater = list -- (less ++ [pivot]) | |
| sort(less) ++ [pivot] ++ sort(greater) | |
| 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 Account do | |
| defstruct name: nil, amount: 0 | |
| def start(%Account{} = account) do | |
| spawn fn -> run(account) end | |
| end | |
| defp run(account) do | |
| account = receive do | |
| {:debit, value} -> %{account | amount: account.amount - value} |