HNHacker News
TopNewBestAskShowJobs

mg

7,565 karma · joined August 19, 2011

I like to build web projects and to meet like-minded people.

www.gibney.org

submissionscomments
mg··on Python types have an expectations problem
Same. I don't like that the meta stuff inside the function. I prefer to have the function be pure code.
mg··on Python types have an expectations problem
I don't really like types on the function declaration line.

Instead of this:

    def check_permission(user: User, perm: str, obj: BaseModel | None) -> bool:
I find it much nicer to read something this:

    """
    Check if user is allowed to drive a car
    :user: User             # The application's User model
    :perm: str              # Our magic permission string. Tab seperated.
    :obj : Basemodel | None # Base model of all our objects since 2017
    :returns bool           # True if the user is allowed to drive
    """
    def check_permission(user, perm, obj):
This way I can grok the code much faster and only have to look into the type declaration when I want to. Due to syntax highlighting, it will look really nice. Because the whole type part can be styled in a dimmer color which puts it into the background. And I can define a key combo to show/hide the whole type part.
mg··on Tell HN: Hacker News now supports IPv6
In Chromium, you can click on the request in the Network panel and it will show the IP.

I see:

    Remote Address: [2606:7100:1:67::26]:443
When I put that into the url bar:

    https://[2606:7100:1:67::26]/
I also see Hacker News.
mg··on Why isn't Bluesky a peer-to-peer network?
What I like about Bluesky is that your identity is a hostname.

So you can just use your own domain for example.

What I don't understand is why the bsky.social service (which holds most user accounts at the moment) doesn't redirect http requests to ones profile. Then you could just say "I'm https://gnod.bsky.social on bluesky". Instead of "I'm https://bsky.app/profile/gnod.bsky.social on bluesky".

Maybe they don't want to make bsky.social very convenient so people have more incentive to use their own domain. Or there is some other thought behind it. I don't know.

mg··on Crystal 1.11.0 Is Released
That lacks a few things:

    1: The comment

    2: Printing the status message ("Listening on ...")

    3: Outputting "Hello world, got {request.path}!"
       Aka http request parsing and string extrapolation.
mg··on Crystal 1.11.0 Is Released
I like the first code example on https://crystal-lang.org

    # A very basic HTTP server
    require "http/server"

    server = HTTP::Server.new do |context|
        context.response.content_type = "text/plain"
        context.response.print "Hello world, got #{context.request.path}!"
    end

    puts "Listening on http://127.0.0.1:8080"
    server.listen(8080)
Nicely concise!

This would be the Python equivalent:

    # A very basic HTTP server
    from http.server import BaseHTTPRequestHandler, HTTPServer

    class RequestHandler(BaseHTTPRequestHandler):
       def do_GET(self):
           self.send_response(200)
           self.send_header('Content-type', 'text/plain')
           self.end_headers()
           self.wfile.write(bytes(f"Hello world, got {self.path}!", 'utf8'))

    httpd = HTTPServer(('', 8080), RequestHandler)
    print("Listening on http://127.0.0.1:8080")
    httpd.serve_forever()
Would like to see it in more languages.
mg··on Creator is hoping to raise at least €1k for basic living expense
Compare that to Plausible: Over $2M in revenue last year.

Plausible started in 2019. Not sure when [name redacted] started. Clicking on "blame" for the readme file in the repo, I see a commit from 5 years ago.

I can very much empathize that adding a "buy" button is a hump to get over when you just wanna build something cool and share it with like-minded people. I have the same issue with every project I build. I guess one should train to jump over one's shadow in this regard.

mg··on Python 3.13 Gets a JIT
The thing is, I don't run my applications locally with a "local run command".

I prefer to have a local system set up just like the production server, but in a container.

Maybe using WSGI with MaxConnectionsPerChild=1 could be a solution? But that would start a new (for example) Django instance for every request. Not sure how fast Django starts.

Another option might be to send a HUP signal to Apache:

    apachectl -k restart
That will only kill the worker threats. And when there are none (because another file save triggered it already), this operation might be almost free in terms of resource usage. This also would require WSGI or similar. Not sure if that is the standard approach for Django+Apache.
mg··on Python 3.13 Gets a JIT
I love Python and use it for everything other than web development.

One reason is performance. So if Python has a faster future ahead of it: Hurray!

The other reason is that the Python ecosystem moved away from stateless requests like CGI or mod_php use and now is completely set on long running processes.

Does this still mean you have to restart your local web application after any change you made to it? I heard that some developers automate that, so that everytime they save a file, the web application is restarted. That seems pretty expensive in terms of resource consumption. And complex as you would have to run some kind of watcher process which handles watching your files and restarting the application?

mg··on End of an Era: Google Groups to Drop Usenet Support
Is Lemmy the new Usenet?

Looks like there is quite some action already:

https://lemmyverse.net

mg··on Emacs-copilot: Large language model code completion for Emacs
"some queries"?

Show them, so we can discuss?

mg··on Emacs-copilot: Large language model code completion for Emacs
Without a browser, I can't think of a solution that is as lean as just putting a line into your vimrc.

I guess you have to decide on an LLM that provides an API and write a command line tool that talks to the API. There probably also are open source tools that do this.

mg··on Emacs-copilot: Large language model code completion for Emacs
What did you try?
mg··on Emacs-copilot: Large language model code completion for Emacs
That could be. If so, it would be interesting to know how Copilot does that.

For me, just asking LLMs "Can the following function be improved" for a function I just wrote is already pretty useful. The LLM often comes up with a way to make it shorter or more performant.

mg··on Emacs-copilot: Large language model code completion for Emacs
For vim, I use a custom command which takes the currently selected code and opens a browser window like this:

https://www.gnod.com/search/ai#q=Can%20this%20Python%20funct...

So I can comfortably ask different AI engines to improve it.

The command I use in my vimrc:

    command! -range AskAI '<,'>y|call system('chromium gnod.com/search/ai#q='.substitute(iconv(@*, 'latin1', 'utf-8'),'[^A-Za-z0-9_.~-]','\="%".printf("%02X",char2nr(submatch(0)))','g'))
So my workflow when I have a question about some part of my code is to highlight it, hit the : key, that will put :'<,'> on the command line, then I type AskAI<enter>.

All a matter of a second as it already is in my muscle memory.

mg··on Custom firmware for MI fitness band
Is there a good fitness band to measure sleep quality that lets you download the data from a Linux machine, or at least lets you see the data on screen?

With "see the data on screen", I mean at least some quality index, not just the number of hours you slept.

mg··on SQL as API

    products below 200 euros and brands speedo or quicksilver
That is what I expected you could mean. Yes, that is a popular pattern. But it is not customizable like the "bicycles that are (made of steel AND weigh from 10 to 20kg) OR (made of carbon AND weigh from 5 to 10kg)" given in the article. When you select two brands on Amazon, they are always connected via OR and when you select the 200 euros, that is always connected to the rest via AND. So the typical

search?brands=speedo,quicksilver&priceMax=200

works.

The point of the article is that this does not work for customizable AND OR constructs, and therefore one should use SQL. And then it gives the bicycles example, stating that this feature request comes up "faster than you can imagine". But no, it almost never comes up in product search. I have not seen it even once in the last 9 years among the thousands of feature requests I looked at.

mg··on SQL as API
Outside of product search, there certainly are user customizable OR functions in search. That's why I said that the product search example the article gave is probably not a good example. Because in product search it is very, very unusual and not something users expect.

I'm not sure exactly what you mean with the Amazon search, but I have the feeling that what you refer to is not the type of user customizable OR that the article used as an example.

Can you link to such an Amazon search with "OR" and "AND"?

mg··on SQL as API
Can you link to a product search where OR is supported?
mg··on SQL as API

    But faster than you can imagine, the next requirement comes in: OR filters!

    bicycles that are (made of steel AND weigh from 10 to 20kg) OR
    (made of carbon AND weigh from 5 to 10kg)
Hmm.. I don't know if this is a good example. I have been in the product search space for almost 10 years now and that feature request never came up. And I cataloged thousands of feature requests users had about product search interfaces.

In the rare case users do something like this, they usually use two tabs. One, where they compare steel bikes and one where they compare carbon bikes.

It makes sense, when you think about the frontend implications. Users are very used to checkboxes and range sliders. The user would check "steel" and set the range slider to "10-20". Now how do they expect to duplicate the sliders and the checkboxes to construct the alternative configuration? They open the page in a new tab and use the alternative settings in that tab.

mg··on Apple wants AI to run directly on its hardware instead of in the cloud
This brings up the question how efficient the human brain is.

As AI keeps catching up more and more with human intelligence, will it also need more and more hardware? Can it achieve human and superhuman intelligence and still run on a device like the iPhone, which weights about 170g? The human brain is 8 times heavier.

mg··on Spotify's push into audiobooks sparks concern among authors
How far away are we from AI reading books so well that everybody who has the book in text form automatically has it in audio form, because they can just turn it into audio via a multitude of AI text to speech networks?

By the way, I would love a service where I could listen to HN. Play the first title and then wait for me to hit the space bar to play the next. Highlight the one I just heard, so when I'm interested int a submission, I have it right in front of me.

mg··on Why are things expensive?
When you lend money from a bank, you will not spend it on fancy restaurant visits. Because you know you will have to pay it back.

When you own a house and there is a cafe in that house which pays rent even though it is closed, because it gets the money from some governmental covid assistance program, then you do not have to pay the money back and can spend it consumer goods and drive prices up.

mg··on Why are things expensive?
No. That is exactly my point: That the change in M0 is the source of increased prices, not changes to M2 (apart from the changes that are in M2 because M0 is in M2).

Think about it this way: How can M2 increase without M0 also increasing? Then we can look at those mechanisms and determine if they are to "blame" for the recent price increases. I think they are not.

mg··on Why are things expensive?
The amount of money was increased by a factor of 6 since 2008:

https://fred.stlouisfed.org/series/BOGMBASE

The amount of products and service we produce probably did not.

Most people think that M0 is only a small factor in price increase and other factors like credit given by banks, the speed at which money moves and spending/saving behavior play a bigger role. But I doubt that. To me, it seems those are all indirect, delayed outcomes of the money supply. So we don't see the prices increase linearly and instantly with the increase of the monetary base. But we see it eventually.

mg··on Continue will generate, refactor, and explain entire sections of code
How would ed help?

Say one of the files is talk.py and there is a function inside of it at line 17 which the LLM wants to change:

    17 def hello():
    18     print ("Hello!")
My approach would be to provide the LLM with a swap command, which takes filename, first line and last line and then treats the rest of the standard input as the new content:

    swap talk.py 17 18
    def hello(name):
        print(f"Hello {name}!")
My feeling is that this is the most efficient way for an LLM to code.
mg··on Continue will generate, refactor, and explain entire sections of code
Why attach this to an IDE? I would think that simply letting an LLM control a terminal and make a commit would be the better approach.

I recently tried it with "You are in a directory with a web app that does ... and you want to implement feature .... In each step, you can use ls or any other bash command and I will give you the output".

It was pretty hillarious how the LLM found its way around the codebase with ls, cat, find, grep awk and actually even managed to edit the code that way and do a commit.

Giving the LLM a bit better tools, like a version of "cat" that prefixes the lines with numbers, and a "swap" command that can do "swap 179 250 ..." to swap out the lines 179 to 250 with "..." would probably be enough to empower the LLM to be pretty efficient.

The next step might be to let the LLM manage its context window by allowing it to remove the last output with a command like "forget". So when the LLM does "cat somefile" and realizes that the output is not interesting, it can follow up with "forget" so the output will be replaced with "You deemed the output to be not interesting".

Those tools would probably evolve to make coding and managing the context window more and more efficient. Like "nicecat 100 200" to see the lines 100 to 200 with numbers prefixed. "keep 200 300" to forget the last output except lines 200 to 300 etc.

mg··on Are electric cars too expensive to tempt motorists away from petrol vehicles?
I wasn't comparing energy in a battery to energy in the atmosphere.

I was comparing a car in city A with a car moved to city B. Both in warm atmosphere. You can heat the atmosphere AND move the car, without creating more entropy than by just heating the atmosphere. So it looks like moving the car does not create entropy / does not use energy.

With the gold, you cannot buy an apartment with it if you sprinkle it in the ocean. You have to decide: Buy an apartment OR sprinkle it in the ocean. You can't get the apartment AND an ocean with gold sprinkles. So you can't get the apartment for free.

mg··on Are electric cars too expensive to tempt motorists away from petrol vehicles?
Isn't that "waste" heat still warming the planet? Isn't turning a cold planet into a warm planet a good thing and therefore the "waste" heat is still "used" for something useful?
mg··on Are electric cars too expensive to tempt motorists away from petrol vehicles?
Let me try to wrap my head around this:

Say there is a completely static, black planet. All sunlight that hits it is turned into heat which is dissipated into the universe. Nothing moves on that planet.

The static black inhabitants of the planet are very thankful for the sun that it makes their planet nicely warm and cozy.

Now one day, one of them is allowed to travel to planet earth and read Hacker News. He reads this very thread.

Are you telling him that they are wasting half of the benefits they could get from the sun? They could have a nice warm planet AND drive around in electric cars all day? For free? Everything else would stay the same?

If so, doesn't that make driving a car "free" in that it not even increased the amount of entropy? Since the sunlight would have turned into high entropy heat anyhow?

← PreviousPage 18 of 34Next →