Skip to content

Instantly share code, notes, and snippets.

View imetallica's full-sized avatar

Iuri L. Machado imetallica

View GitHub Profile
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
namespace Macaw.Server.Internal
open System
open System.Threading
open System.Collections.Generic
open System.Net.Sockets
open System.Net
module SocketConnectionListener2 =
let internal createSocket (endpoint : IPEndPoint) =
defp refresh_graph(%{graph: g}) do
g =
if is_nil(g) do
:digraph.new()
else
:digraph.delete(g)
:digraph.new()
end
GraphDocument
@imetallica
imetallica / docker-cmd-for-fun-and-profit.sh
Last active March 20, 2018 21:52
Docker commands for fun and profit
# Elastic Search
docker run --rm -d -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.0.1
case DateTime.from_iso8601(Map.get(element, "createdTime")) do
{:error, reason} ->
IO.inspect(reason)
{:ok, parsed_datetime, 0} ->
IO.inspect(parsed_datetime) # Verifica o resultado daqui
# Manda pro ElasticSearch...
end
defmodule App.AccountCtx do
alias __MODULE__.User
alias Ecto.Multi
def create_account(params) do
user_changeset = User.changeset(%User{}, params)
Multi.new()
|> Multi.insert(:create_account_on_acc_ctx, user_changeset)
|> Multi.run(:send_email, &App.Emailer.send_mail/1) # Logic to send e-mail
end
with
{:ok, width} <- Map.fetch(opts, :width),
{:ok, height} <- Map.fetch(opts, :height)
do
{:ok, width * height}
else
{:error, :wrong_data} -> ...
{:error, :wrong_data_2} -> ...
end
module FunPizzas
type Pizza = Calabreza | Chicken
// Pizza -> int -> int
let timeToReady pizza deliveryDelay =
let pizzaDelay =
match pizza with
| Calabreza -> 30
| Chicken -> 25
def is_empty(state) do
result = :queue.is_empty(state.queue)
Logger.debug "#{inspect __MODULE__}: Empty? #{inspect result}."
{result, state}
end
def delete(state) do
Logger.debug "#{inspect __MODULE__}: Deleting #{inspect state}."
{:ok, state}
end
module MetroUi exposing (..)
import Html exposing (Html, text, div, h1)
import Html.App as App
import MetroUi.Widgets.Accordion as Accordion
import MetroUi.Widgets.Frame as Frame
type alias MetroUiModel =
{ accordion : Accordion.Model
, bigAccordion : Accordion.Model }