All posts by Juan Lebrijo

Rubymine overloads all CPU cores

Historically I found that Rubymine indexings breaking other processes running in your machine, included itself. All computer stopped.

A solution would be opening the file `~/.config/JetBrains/RubyMine2023.1/rubymine64.vmoptions` and adding the following line depending number of CPUs you want Rubymine should use to not to overload the computer (in my case I have 8, so I will leave 4 for JVM):


I am using Rubymine, but probably all Jetbrains products have a similar `.vmoptions` file.

Hope it helps!

Turbo Streams

Actions and Targets

An example on how turbo_stream is rendered:

= turbo_stream.append :messages, @message

Where :messsages is the target and @message renders the partial _message.html.haml. Then it is rendered to:

<turbo-stream action="append" target="messages">
    <div id="message_23">
      // This div will be append to element with id="messages"

7 possible Actions

  • APPEND: Appends template to target
  • PREPEND: Preppends template to target
  • REPLACE: Replaces the full target with template
  • UPDATE: Replaces the content of target with template
  • REMOVE: Removes target
  • BEFORE: Adding template before target element
  • AFTER: Adding template after target

Streaming from HTTP responses

In rails controller streams will be rendered like:

def create
  @message = Message.find(....)
  respond_to do |format|
    format.turbo_stream # renders template in: create.turbo_stream.haml
    format.html { redirect_to messages_url }

Reusing server side templates inline:

  format.turbo_stream do
    render turbo_stream: turbo_stream.append(:messages, 
                partial: "messages/message", locals: { message: @message})

Both “partial:” and “locals:” can be replaced by @message (Great Rails code!!!).

Some notes

RECOMENDATION: Good practice is design without Streams, then in poor connections or server issues, when web sockets are broken, it will run anyway. Like a browser without JavaScript.
NOTE FOR BROWSER CACHE: Attribute “data-turbo-permanent” makes element alwaiys the samen in browser cache.

Defining a Smart Contract Lifecycle in Solidity

address owner;
bool public paused;
constructor() public {
  owner = msg.sender;
function setPaused(bool _paused) public {
  require(msg.sender == owner, "you are not authorized for this action");
  pause = _paused;

First on DEPLOYMENT you want to be sure that the owner is the only who interacts with the contract for concrete actions:

  • Address of deployer is the owner
  • constructor(): initializes contract class
  • setPaused(): pause control of contract
  • require(): basic owner authorization
function withdrawAll(address payable _to) public {
  require(msg.sender == owner, "you are not authorized for this action");
  require(!paused, "Contract is paused!");

Second during the LIFECYCLE, you can make any actions on contract balance:

  • require(sender): checks auth
  • require(paused): checks if contract is suspended
  • address(this): gets address of this contract
  function destroy (address payable _to) public {
    require(msg.sender == owner, "you are not authorized for this action");

Last, you can disable a contract by selfdestructing and sending balance to any address the owner wants.