shakedown.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
A community for live music fans with roots in the jam scene. Shakedown Social is run by a team of volunteers (led by @clifff and @sethadam1) and funded by donations.

Administered by:

Server stats:

240
active users

#monkeypatching

0 posts0 participants0 posts today
Evan Light<p>That said, as the workingwithruby site advises, you probably don't want to use Thread directly an instead use a higher level abstraction like @bascule's Celluloid gem. </p><p> <a href="https://tenforward.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Ruby</span></a> <a href="https://tenforward.social/tags/monkeypatching" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>monkeypatching</span></a> <a href="https://tenforward.social/tags/composition" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>composition</span></a> <a href="https://tenforward.social/tags/actors" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>actors</span></a></p>
Evan Light<p>I *LOVE* this resource (<a href="https://workingwithruby.com/wwrt/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="">workingwithruby.com/wwrt/</span><span class="invisible"></span></a>) on threading in Ruby.</p><p>However, I find the suggestion to monkey patch Enumerable here (<a href="https://workingwithruby.com/wwrt/low_level_api/" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">workingwithruby.com/wwrt/low_l</span><span class="invisible">evel_api/</span></a>) evokes anxiety.</p><p>It suggests something like this:</p><p>module Enumerable<br> def concurrent_each<br> # impl<br> end<br>end</p><p>We Rubyists *LOVE* implicit over explicit relationships. We tend to think of this as convention over configuration. Thanks, DHH.</p><p>Yet this doesn't scale well.</p><p>For apps/gems of any significant complication, the accumulation of implicitness results in cognitive overload.</p><p>What if someone *else* gets the idea to add a concurrent_each to Enumerable. That is, Enumerable, as a built-in, is akin to a global namespace.</p><p>Instead, I recommend something more like a vaguely Java-esque approach (bear with me!) of:</p><p>class ConcurrentEach<br> def self.using(enumerable, &amp;block)<br> # use the impl supplied in the example linked above<br> end<br>end</p><p>Using this would look like:</p><p>ConcurrentEach.using(files).each { ... }</p><p>This way, we're composing instead of monkey patching or mixing in.</p><p>Try to avoid modifying code you don't own.</p><p>Or, as I've heard, second-hand, of Matz saying to a friend of mine, "Don't hurt Ruby!" 😂</p><p><a href="https://tenforward.social/tags/Ruby" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Ruby</span></a> <a href="https://tenforward.social/tags/monkeypatching" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>monkeypatching</span></a> <a href="https://tenforward.social/tags/composition" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>composition</span></a></p>
Aral Balkan<p>…but in case any of you want to do something similar, here’s me mocking a WritableStream using a Proxy to provide mock stdout and stderr streams to Console instances to capture the output and save them in my database:</p><p><a href="https://codeberg.org/kitten/app/src/branch/logs/src/Logs.js#L47" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">codeberg.org/kitten/app/src/br</span><span class="invisible">anch/logs/src/Logs.js#L47</span></a></p><p>And here’s the actual monkeypatching code:</p><p><a href="https://codeberg.org/kitten/app/src/branch/logs/src/Logs.js#L140" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">codeberg.org/kitten/app/src/br</span><span class="invisible">anch/logs/src/Logs.js#L140</span></a></p><p><a href="https://mastodon.ar.al/tags/monkeyPatching" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>monkeyPatching</span></a> <a href="https://mastodon.ar.al/tags/JavaScript" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>JavaScript</span></a> <a href="https://mastodon.ar.al/tags/console" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>console</span></a> <a href="https://mastodon.ar.al/tags/NodeJS" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>NodeJS</span></a> <a href="https://mastodon.ar.al/tags/web" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>web</span></a> <a href="https://mastodon.ar.al/tags/dev" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dev</span></a> <a href="https://mastodon.ar.al/tags/Proxy" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Proxy</span></a> <a href="https://mastodon.ar.al/tags/Streams" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Streams</span></a> <a href="https://mastodon.ar.al/tags/mocking" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>mocking</span></a></p>