Skip to content

Instantly share code, notes, and snippets.

View kdiogenes's full-sized avatar

Kadu Diógenes kdiogenes

View GitHub Profile
@kdiogenes
kdiogenes / scale-out-phoenix-with-websocket.md
Created June 16, 2019 20:56 — forked from Aetherus/scale-out-phoenix-with-websocket.md
How to scale out a Phoenix application with websocket

How to scale out a Phoenix application with websocket

Foreword

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.

Resources

@kdiogenes
kdiogenes / programming_generators.rb
Last active October 6, 2019 22:21
rails: programmable generators on rails
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
@kdiogenes
kdiogenes / programming_generators.txt
Created August 2, 2019 01:23
rails: programmable generators on rails
[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={},
# 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

MiniGPT client v1.0

#!/usr/bin/env ruby
# frozen_string_literal: true
#
# MiniGPT client v1.0
#
# gem install --user-install ruby-openai
#
@kdiogenes
kdiogenes / decrypt_cookie.rb
Created May 3, 2024 19:36 — forked from goropikari/decrypt_cookie.rb
Decrypt a Rails 5 session cookie