#Monkeypatching

Christian Pietschchpietsch@fedifreu.de
2024-08-17

#Admintrivia:

Gestern Abend habe ich einen kleinen Bug in GlitchSoc auf fedifreu.de per #Monkeypatching (Bearbeiten von Quellcode auf dem Server) behoben. Der Bug hatte dafür gesorgt, dass ich Trends moderieren musste, obwohl ich eingestellt hatte, dass Trends sofort angezeigt werden sollen.

Jetzt könnt ihr wieder ohne Verzögerung sehen, was in unserer Bubble gerade Thema ist: fedifreu.de/explore

Ich will nicht klagen – wer #GlitchSoc einsetzt, will experimentelle Mastodon-Features nutzen und weiß, dass man bei der Behebung mithelfen soll, statt zu jammern. Was ich versuche durch Mitarbeit im Issue-Tracker. Aber es ist nicht einfach. Mir fehlt der Erfahrungsaustausch mit anderen GlitchSoc-Instanz-Admins. Gibt es dazu schon eine Matrixgruppe oder so? Die #Fedimins-Gruppe hat damit leider noch keine Erfahrungen. Wahrscheinlich muss ich es auf Englisch versuchen.

#GlitchSocAdmin #GlitchAdmin #TrendModeration

2024-08-01

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.

#Ruby #monkeypatching #composition #actors

2024-08-01

I *LOVE* this resource (workingwithruby.com/wwrt/) on threading in Ruby.

However, I find the suggestion to monkey patch Enumerable here (workingwithruby.com/wwrt/low_l) evokes anxiety.

It suggests something like this:

module Enumerable
def concurrent_each
# impl
end
end

We Rubyists *LOVE* implicit over explicit relationships. We tend to think of this as convention over configuration. Thanks, DHH.

Yet this doesn't scale well.

For apps/gems of any significant complication, the accumulation of implicitness results in cognitive overload.

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.

Instead, I recommend something more like a vaguely Java-esque approach (bear with me!) of:

class ConcurrentEach
def self.using(enumerable, &block)
# use the impl supplied in the example linked above
end
end

Using this would look like:

ConcurrentEach.using(files).each { ... }

This way, we're composing instead of monkey patching or mixing in.

Try to avoid modifying code you don't own.

Or, as I've heard, second-hand, of Matz saying to a friend of mine, "Don't hurt Ruby!" 😂

#Ruby #monkeypatching #composition

2024-06-28

…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:

codeberg.org/kitten/app/src/br

And here’s the actual monkeypatching code:

codeberg.org/kitten/app/src/br

#monkeyPatching #JavaScript #console #NodeJS #web #dev #Proxy #Streams #mocking

Nicolas Buduroibudu@ruby.social
2024-04-12

Will this get reverted on Monday? #LateCommitFriday #Ruby #MonkeyPatching 👿

2024-03-19

Monkey patching в Go, или грабли от Apple

Все началось с того, что я в очередной раз немного поменял структуры БД, и в некоторых SQL-запросах добавилась новая колонка. Нормальная ситуация - взять и легким движением руки сломать половину unit test’ов, потому что БДшные моки ожидают определенный текст запроса.

habr.com/ru/articles/801177/

#monkeypatching #unittesting #go #грабли_повсюду

2024-02-01

@orsinium monkey patching! Yes, familiar thing from unit tests. What's your opinion on APIs which use monkey patching? Or do you write code with monkey patching outside of testing purposes?

#python #monkeypatching

Bradbk1e
2023-11-16

I’m not sure which I dislike more: the premise of a Python decorator that redirects functions to an LLM, or the fact that they are co-opting the term “monkey patch”, which already has a well-defined meaning in Python.

mastodon.social/@python_discus

Alexandre B A Villares 🐍villares@ciberlandia.pt
2023-10-22

Sometimes #monkeyPatching gets a bad reputation, but I feel like adding draw methods for #pymunk shape-objects is such an elegant solution, it simplifies so many things... you don't need extra data structures to keep track of them, you don't need to check object types at the draw loop... #Python

Nicolas Fränkel 🇺🇦🇬🇪frankel@mastodon.top
2023-09-17

The #JVM is an excellent platform for #monkeypatching

I want to demo several approaches for monkey-patching in Java in this post.

As an example, I’ll use a sample for-loop. Imagine we have a class and a method. We want to call the method multiple times without doing it explicitly.

blog.frankel.ch/monkeypatching

#Java #AspectJ #ByteBuddy #instrumentation #JavaAgent

Alexandre B A Villares 🐍villares@ciberlandia.pt
2023-07-29

This is probably useless but, with a bit of #monkeyPatching, one can make Py5Image objects picklable... gist.github.com/villares/3e00c

#Processing #Python #numpy #py5 cc @py5coding

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst