#monkeypatching — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #monkeypatching, aggregated by home.social.
-
Modshim – a new alternative to monkey-patching in Python
https://github.com/joouha/modshim
#HackerNews #Modshim #monkeypatching #Python #alternatives #PythonDevelopment #GitHub #OpenSource
-
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: https://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.
-
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.
-
I *LOVE* this resource (https://workingwithruby.com/wwrt/) on threading in Ruby.
However, I find the suggestion to monkey patch Enumerable here (https://workingwithruby.com/wwrt/low_level_api/) evokes anxiety.
It suggests something like this:
module Enumerable
def concurrent_each
# impl
end
endWe 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
endUsing 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!" 😂
-
…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:
https://codeberg.org/kitten/app/src/branch/logs/src/Logs.js#L47
And here’s the actual monkeypatching code:
https://codeberg.org/kitten/app/src/branch/logs/src/Logs.js#L140
#monkeyPatching #JavaScript #console #NodeJS #web #dev #Proxy #Streams #mocking
-
Monkey patching в Go, или грабли от Apple
Все началось с того, что я в очередной раз немного поменял структуры БД, и в некоторых SQL-запросах добавилась новая колонка. Нормальная ситуация - взять и легким движением руки сломать половину unit test’ов, потому что БДшные моки ожидают определенный текст запроса.
-
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.
https://mastodon.social/@python_discussions/111417590351768628
-
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
-
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.
-
This is probably useless but, with a bit of #monkeyPatching, one can make Py5Image objects picklable... https://gist.github.com/villares/3e00c5c4e3366b18ebadb9073e46c6d1