7,565 karma · joined August 19, 2011
www.gibney.org
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.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.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.
1: The comment
2: Printing the status message ("Listening on ...")
3: Outputting "Hello world, got {request.path}!"
Aka http request parsing and string extrapolation. # 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.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.
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.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?
Looks like there is quite some action already:
Show them, so we can discuss?
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.
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.
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.
With "see the data on screen", I mean at least some quality index, not just the number of hours you slept.
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 typicalsearch?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.
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"?
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.
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.
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.
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.
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.
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.
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.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.
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.
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?