#!/usr/bin/env ruby
# frozen_string_literal: true
#
# MiniGPT client v1.0
#
# gem install --user-install ruby-openai
#
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
# Criando uma rede vazia | |
library(bnlearn) | |
dag = empty.graph(c("P", "N")) | |
class(dag) | |
dag | |
# Criando a estrutura da rede | |
arc.set = matrix(c("P", "N"), ncol = 2, byrow = TRUE, dimnames = list(NULL, c("de", "para"))) | |
arc.set | |
arcs(dag) = arc.set |
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
[2] (pry) main: 0> g = Rails::Generators::ScaffoldControllerGenerator.new | |
ArgumentError: wrong number of arguments (given 0, expected 1+) | |
from /home/kadu/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/railties-4.2.11.1/lib/rails/generators/model_helpers.rb:14:in `initialize' | |
[3] (pry) main: 0> g = Rails::Generators::ScaffoldControllerGenerator.new('user') | |
NoMethodError: undefined method `shift' for "user":String | |
from /home/kadu/.asdf/installs/ruby/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.19.4/lib/thor/parser/arguments.rb:73:in `shift' | |
[4] (pry) main: 0> g = Rails::Generators::ScaffoldControllerGenerator.new(['user']) | |
=> #<Rails::Generators::ScaffoldControllerGenerator:0x000055b1970a8680 | |
@_initializer=[["user"], {}, {}], | |
@_invocations={}, |
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
require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator' | |
g = Rails::Generators::ScaffoldControllerGenerator.new(['user', '--skip-collision-check']) | |
g.shell.instance_variable_set(:@always_force, true) | |
g.destination_root = '/tmp/rails' | |
g.invoke_all |
It's relatively easy to scale out stateless web applications. You often only need a reverse proxy. But for those stateful web applications, especially those applications that embeds websocket services in them, it's always a pain to distribute them in a cluster. The traditional way is introducing some external services like Redis to handle pubsub, however, in such way, you often need to change your code. Can Erlang/Elixir, the "concurrency oriented programming languages", best other languages in this use case? Has Phoenix framework already integrated the solution of horizontally scaling websocket? I'll do an experiment to prove (or disprove) that.
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
def find_or_create_upload(find_fields, create_attrs \\ %{}) do | |
filters = Map.take(create_attrs, find_fields) |> Map.to_list() | |
query = from(u in Upload, where: ^filters) | |
upload = Repo.one(query) | |
if upload == nil do | |
create_upload(create_attrs) | |
else | |
upload | |
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
def changeset(model, params \\ %{}) do | |
model | |
|> cast(params, [:name, :email] ++ coherence_fields()) | |
|> enforce_api_token | |
|> validate_required([:name, :email]) | |
|> validate_format(:email, ~r/@/) | |
|> unique_constraint(:email) | |
|> unique_constraint(:api_token) | |
|> validate_coherence_assent(params) | |
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 Pumpbits.Coherence.User do | |
@moduledoc false | |
use Ecto.Schema | |
use Coherence.Schema | |
use CoherenceAssent.Schema | |
alias Pumpbits.Repo | |
schema "users" do | |
field :name, :string | |
field :email, :string |
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
AWS Lambda (NodeJS) | Heroku (RoR) | ||
---|---|---|---|
Concurrecy | 1000 req/s | 1000 req/s | |
Total time | 6.076s | 7.212s | |
Failed requests | 3.935 | 49.465 | |
Requests per second | 164/s | 138/s | |
Mean time per request | 6.076 | 7.212ms |
NewerOlder