Readit News logoReadit News
johnnymellor commented on Linking to text fragments with a bookmarklet   alexwlchan.net/2025/text-... · Posted by u/Bogdanp
johnnymellor · 6 months ago
This would be useful in Chrome for Android (which doesn't yet have this feature built-in), but activating bookmarklets on Android (via https://paul.kinlan.me/use-bookmarklets-on-chrome-on-android...) clears the text selection. So instead I've put together an alternative bookmarklet that lets you select the text to link to after activating the bookmarklet: https://gist.github.com/johnmellor/ef5ecf555f28b324b045e0c93...
johnnymellor commented on Show HN: Transductive regular expressions for text editing   github.com/c0stya/trre... · Posted by u/c0nstantine
layer8 · a year ago
This doesn’t seem sufficient as soon as you want to perform some kind of structural substitution, for example doing the equivalent of s/"([^"]*)"/'$1'/. If it could do that and also somehow be able to replace any of the [^"] that match ['] by \', that would seem more useful.

More generally speaking, since regular expressions effectively define a parse tree on their matches, being able to perform more general transformations of those trees would be useful.

johnnymellor · a year ago
If I understand correctly the following ttre expression does what you're asking for:

  ":'(':(\\')|[^"'])*":'

johnnymellor commented on Show HN: Radius – A Meetup.com alternative   radius.to... · Posted by u/radius89
johnnymellor · 2 years ago
Many communities would like to have a page/ical that lists all the events going on in that community. But event organisers are often busy, and by the time they've posted on WhatsApp and Facebook and Meetup they won't necessarily bother to post here too, especially when there are multiple organisers within a community, and due to the chicken and egg problem of it only being worth posting here if all of the community's other events are also listed here.

What would help is if engaged community members can collaboratively list events that event organisers have posted elsewhere, so that community members can find all the community's events in one place (here) even if the event organisers don't bother to post them here themselves. This raises a few auth complications, e.g. if the event organiser wants to post their event ideally they'd be able to take ownership of the placeholder event uploaded by the community member. But if you can solve those, seeing all their events in one place might be a compelling reason for communities to organically switch over to your platform (at which point event organisers might well also follow).

johnnymellor commented on Lumiere: A space-time diffusion model for realistic video generation   lumiere-video.github.io/... · Posted by u/jonbaer
pmontra · 2 years ago
> Hover over the video to see the input prompt

That doesn't work on a phone. I hoped they added an event handler for touching the animations. Instead they forgot they have a mobile OS and that they sell phones.

johnnymellor · 2 years ago
At least on Chrome for Android, you can long-press to trigger the hover effect. Works on many websites. (There are inconvenient side-effects like selecting text, but it's better than nothing.)
johnnymellor commented on CLI tools hidden in the Python standard library   til.simonwillison.net/pyt... · Posted by u/swyx
johnnymellor · 3 years ago
Not supporting multi-line statements is just because pdb doesn't bother to parse the statement to work out if it is an incomplete multi-line statement. That could be easily fixed (I have a prototype patch for that using `code.compile_command`).

The scope problems are more fundamental:

The pdb REPL calls[1] the exec builtin as `exec(code, frame.f_globals, frame.f_locals)`, which https://docs.python.org/3/library/functions.html#exec documents as:

"If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition."

And https://docs.python.org/3/reference/executionmodel.html#reso... documents that:

"The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods - this includes comprehensions and generator expressions since they are implemented using a function scope."

This is a fundamental limitation of `exec`. You can workaround it by only passing a single namespace dictionary to exec instead of passing separate globals and locals, which is what pdb's interact command does[2], but then it's ambiguous how to map changes to that dictionary back to the separate globals and locals dictionaries (pdb's interact command just discards any changes you make to the namespace). This too could be solved, but requires either brittle ast parsing or probably a PEP to add new functionality to exec. I'll file a bug against Python soon.

[1]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...

[2]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...

johnnymellor · 3 years ago
Oh, and multi-line statements will be supported from Python 3.13 (https://github.com/python/cpython/issues/103124)
johnnymellor commented on CLI tools hidden in the Python standard library   til.simonwillison.net/pyt... · Posted by u/swyx
sharikous · 3 years ago
Speaking of pdb.. maybe someone knows why pdb has some issues with scope in its REPL that are resolved in VSCode's debugger and PyCharm?

Multiline statements are not accepted, nor things like if/for

Even list comprehensions and lambda expressions have trouble loading local variables defined via the REPL

Are there workarounds? It would reduce the need for using IDEs. People who have experience with Julia and Matlab are very used to a trial and error programming style in a console and bare python does not address this need

johnnymellor · 3 years ago
Not supporting multi-line statements is just because pdb doesn't bother to parse the statement to work out if it is an incomplete multi-line statement. That could be easily fixed (I have a prototype patch for that using `code.compile_command`).

The scope problems are more fundamental:

The pdb REPL calls[1] the exec builtin as `exec(code, frame.f_globals, frame.f_locals)`, which https://docs.python.org/3/library/functions.html#exec documents as:

"If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition."

And https://docs.python.org/3/reference/executionmodel.html#reso... documents that:

"The scope of names defined in a class block is limited to the class block; it does not extend to the code blocks of methods - this includes comprehensions and generator expressions since they are implemented using a function scope."

This is a fundamental limitation of `exec`. You can workaround it by only passing a single namespace dictionary to exec instead of passing separate globals and locals, which is what pdb's interact command does[2], but then it's ambiguous how to map changes to that dictionary back to the separate globals and locals dictionaries (pdb's interact command just discards any changes you make to the namespace). This too could be solved, but requires either brittle ast parsing or probably a PEP to add new functionality to exec. I'll file a bug against Python soon.

[1]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...

[2]: https://github.com/python/cpython/blob/25a64fd28aaaaf2d21fae...

johnnymellor commented on Why do recipe writers lie about how long it takes to caramelize onions? (2012)   slate.com/human-interest/... · Posted by u/pmoriarty
groestl · 3 years ago
Never been tested once:

Bacon-Wrapped Mozzarella Sticks

Ingredients:

  - 12 slices of bacon
  - 12 mozzarella sticks
  - 1/2 cup all-purpose flour
  - 2 eggs, beaten
  - 1 cup breadcrumbs
  - 1/2 teaspoon garlic powder
  - 1/2 teaspoon paprika
  - Vegetable oil, for frying
  - Marinara sauce, for serving
Instructions:

Preheat your oven to 400°F (200°C). Line a baking sheet with parchment paper.

Wrap each mozzarella stick with a slice of bacon, starting from one end and wrapping it tightly. Place the bacon-wrapped mozzarella sticks on the prepared baking sheet.

Bake the bacon-wrapped mozzarella sticks in the preheated oven for about 12-15 minutes, or until the bacon is crispy and the cheese is melted. Remove from the oven and set aside.

In three separate shallow bowls, set up a breading station. Place flour in the first bowl, beaten eggs in the second bowl, and breadcrumbs mixed with garlic powder and paprika in the third bowl.

Heat vegetable oil in a deep skillet or pot over medium heat until it reaches 350°F (180°C).

Take each bacon-wrapped mozzarella stick and dredge it in flour, then dip it into the beaten eggs, and finally coat it with the breadcrumb mixture, pressing gently to adhere. Repeat this process for each mozzarella stick.

Carefully place the coated mozzarella sticks into the hot oil, a few at a time, and fry for about 2-3 minutes, or until golden brown and crispy. Use a slotted spoon to transfer the fried mozzarella sticks to a paper towel-lined plate to drain excess oil.

Serve the bacon-wrapped mozzarella sticks warm with marinara sauce for dipping. Enjoy!

These bacon-wrapped mozzarella sticks make for a delicious appetizer or snack that combines the gooeyness of melted mozzarella with the savory crunch of bacon.

Looking forward to the Stable Diffusion based Illustration.

johnnymellor · 3 years ago
Midjourney's rendering looks pretty tasty: https://pasteboard.co/NBhdMl3AsAAR.png
johnnymellor commented on HN is up again    · Posted by u/tpmx
smcl · 4 years ago
This happened last couple of times I switched laptops - my old habit to visit "guardian.co.uk" by typing "guar" and hitting enter no longer works because I've now accidentally searched too many times for "guar" :D
johnnymellor · 4 years ago
You can make the omnibox forget about URLs and search terms you've used a lot by selecting them with the down key then pressing Shift+Delete (https://superuser.com/a/189334).
johnnymellor commented on We think this cool study we found is flawed. Help us reproduce it   pudding.cool/2022/04/rand... · Posted by u/colinprince
macksd · 4 years ago
And funnily enough, you'll often hear this trait as being desirable in a pseudo-random number generator. People often want something that will jump around fairly unpredictably but that will come close to outputting all possible numbers once before getting into re-runs.
johnnymellor · 4 years ago
Yes, it's a very desirable trait in https://en.m.wikipedia.org/wiki/Quasi-Monte_Carlo_method

Quasi-Monte Carlo has a rate of convergence close to O(1/N), whereas the rate for the Monte Carlo method is O(N^(−0.5))

For such applications it's best to use quasi-random numbers (a.k.a. low-discrepancy sequences) such as the Halton sequence or the Sobol sequence instead of pseudorandom numbers.

johnnymellor commented on A basic introduction to NumPy's einsum   ajcr.net/Basic-guide-to-e... · Posted by u/s1291
teddykoker · 4 years ago
Also see Einops: https://github.com/arogozhnikov/einops, which uses a einsum-like notation for various tensor operations used in deep learning.

https://einops.rocks/pytorch-examples.html shows how it can be used to implement various neural network architectures in a more simplified manor.

johnnymellor · 4 years ago
Einops looks nice! It reminds me of https://github.com/deepmind/einshape which is another attempt at unifying reshape, squeeze, expand_dims, transpose, tile, flatten, etc under an einsum-inspired DSL.

u/johnnymellor

KarmaCake day26December 13, 2013View Original