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 What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
What I love about Django is that you can create a Django project with just one file.

You can turn a fresh Debian machine into a running Django web app by just doing:

    apt install -y python3-django apache2 libapache2-mod-wsgi-py3
And then creating the one file Django needs:

/var/www/mysite/mysite/wsgi.py:

    import os
    import django
    from django.core.wsgi import get_wsgi_application
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.wsgi')
    application = get_wsgi_application()

    ROOT_URLCONF = 'mysite.wsgi'
    SECRET_KEY = 'hello'

    def index(request):
        return django.http.HttpResponse('This is the homepage')

    def cats(request):
        return django.http.HttpResponse('This is the cats page')

    urlpatterns = [
        django.urls.path('', index),
        django.urls.path('cats', cats),
    ]
And then telling Apache where to look for it:

/etc/apache2/sites-enabled/000-default.conf:

    ServerName 127.0.0.1
    WSGIPythonPath /var/www/mysite
    <VirtualHost *:80>
        WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
        <Directory /var/www/mysite/mysite>
            <Files wsgi.py>
                Require all granted
            </Files>
        </Directory>
    </VirtualHost>
And voilá, you have a running Django application, which you can expand upon to any size and complexity.

If you want to try it in a docker container, you can run

    docker run -it --rm -p80:80 debian:12
perform the steps above and then access the Django application at 127.0.0.1
mg··on ChatGPT Fails to Understand Causation
Surprisingly, none of the replies here in the HN thread pass the test either. They all confuse correlation with causation.

A reply that would pass the test:

The siblings Ana, Berta and Charles live together and get random calls from mom and dad. Ana and Berta get angry when mom calls. So their anger is correlated. Berta and Charles get angry when dad calls. So their anger is correlated. The anger of Ana and Charles is not correlated though.

mg··on Meta is tagging real photos as 'Made with AI'
Maybe they should tag tags they create with AI as 'Tagged with AI'.
mg··on Fuzz Map
True, if you rewrite the code, then that would even work via a simple injection of

    _cover(123);
after each line, where 123 is the line number.

Could be a fun project to write a bookmarklet that does this to the current page, then lets you use it and then tells you which parts of the code have not been used.

mg··on Ask HN: Could AI be a dot com sized bubble?
Yes, typo. I meant non-finance.

QQQ is a good indicator for how tech performed since the so-called "dot com bubble". And it performed pretty well. That's why I tend to not call it a bubble.

mg··on Fuzz Map
How is it able to test code coverage in the browser?

Can JavaScript step through JavaScript?

mg··on Ask HN: Could AI be a dot com sized bubble?
I often wonder if there really was a dot com bubble. Some companies failed, but shouldn't we look at the software market as a whole?

Look at the performance of th qqq certificate, which invests in the largest 100 non-tech companies in the Nasdaq:

https://www.google.com/search?q=qqq

And click on "max". It goes from $52.97 in May 1999 to $485.51 today.

That is an annualized ROI of 9.21%. A better performance than many other market indices had over the same time.

mg··on Even Apple cannot explain why we need AI in our lives
AI is already so woven into my life. I use it all the time and wouldn't want to go back.

For example I made a bookmarklet that summarizes articles linked from HN. So the way I have skimmed this article is by reading this:

    Apple's new AI offering, Apple Intelligence,
    seems unoriginal and derivative compared to
    competitors.

    Apple is partnering with OpenAI to integrate
    ChatGPT, but the integration appears
    halfhearted.

    The article questions if Apple's approach can
    truly unlock the potential of generative AI.
The prompt I use is:

    Make up to three short bullet points about what
    the following page is about. Under no circumstances
    make any of the bullet points longer than 40 words.
    The page:
And then I append the text content of the page.

It is a very crude approach. Not sure how well it really covers the most important points. But I already like these summaries to decide if I dive deeper. And over time the summaries will only get better.

I think AI will be part of most UIs in a few years.

mg··on What Is ChatGPT Doing and Why Does It Work? (2023)
You mean a prompt in the form of "A happened, then B happened, then C happened" activates the word "inconsistency"?

We can test that by slightly altering the text so that there is no inconsistency anymore and see if the model still claims there is one. We can do so by adding the word "mother" after the word "her":

    What do you think about the following text?

    Joe drove Sue to university. Afterwards he drove home again
    and drank a tea with her mother in the kitchen.
In my experiments, the model now no longer claims there is an inconsistency.

If it is only based on sentence structure, what makes the model output "inconsistency" for the first prompt but not for the second?

mg··on What Is ChatGPT Doing and Why Does It Work? (2023)
The better the models get, the harder it is for me to form a mental model of what goes on inside of them.

An example of a prompt for which I don't have a good mental model why it works:

    What do you think about the following text?

    Joe drove Sue to university. Afterwards he drove home again
    and drank a tea with her in the kitchen.
Older models behaved similar to Markov chains and completely missed that something is logically strange here. Newer models still sometimes do, but more often than not catch it.

GPT-4o for example:

    There is a slight inconsistency in the narrative.
    The text states that Joe drank tea with Sue in the
    kitchen after driving her to university, which
    implies that Sue is at home, contradicting the
    earlier statement that she was driven to university.
Surely nothing in the prompt directly triggered the word "inconsistency". Did the model form some kind of "world model" in its inner layers in which it knows about a person "Sue" who is at a location called "university" after the first sentence?
mg··on Every Way to Get Structured Output from LLMs
The baml config files look a lot like code. For example in baml:

    class Resume {
        name string
        education Education[] @description("Extract in the same order listed")
        skills string[] @description("Only include programming languages")
    }
Could be expressed in Python like this:

    class Resume:
        name: str
        education: List[Education] # Extract in the same order listed
        skills: List[str] # Only include programming languages
Two benefits I see are that it would make the file leaner (because Python is nicely lean) and provide free parsing and syntax highlighting.

Is there a benefit of rolling your own DSL?

mg··on Tesla's FSD – A Useless Technology Demo
I think a good indicator if it is useful or not is to look at how much it is actually used.

Tesla published a chart of cumulative miles driven over time on page 8 of their latest quarterly update:

https://digitalassets.tesla.com/tesla-contents/image/upload/...

So far, I'm not sure what to make of it. The chart looks somewhat exponential. But since they brought more and more cars onto the road, one would expect exponential growth in this chart even if no additional usage was caused by software improvements. So one would have to un-cumulate the chart and then divide the y-axis by number of cars on the road to get usage by car.

And then one would have to factor in price changes.

I think the spike at the right is from the free trial they pushed out shortly after the release of FSD 12. The way I read the chart, the release of FSD 12 itself has not caused an increase in usage.

Does anybody know what caused the increase in growth in March 2023?

mg··on Chinese yuan becomes Russia's main foreign currency, replacing dollar and euro
Interesting, how different the monetary base over time looks like in China compared to the US and Europe when you click on "max" on these charts:

https://tradingeconomics.com/china/money-supply-m0

USA:

https://tradingeconomics.com/united-states/money-supply-m0

Europe:

https://tradingeconomics.com/euro-area/money-supply-m0

mg··on YouTube experimenting with server-side ad injection
Online advertising is such a strange world.

Do I see it correctly, that half of the worlds' population (the ones without ad blockers) is paying the web for the other half (the ones with ad blockers)?

The amount of ads these days is so crazy that I think we might all be better off if there was a way to easily do micropayments instead.

mg··on Discussion on why SQLite is gaining popularity [audio]
One file in your project.

'apt install sqlite3' will install more than one file too. But the DB that is in your project is just one file.

mg··on Discussion on why SQLite is gaining popularity [audio]
You just need a wsgi.py file:

    import os
    import django
    from django.core.wsgi import get_wsgi_application
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.wsgi')
    application = get_wsgi_application()

    ROOT_URLCONF = 'mysite.wsgi'
    SECRET_KEY = 'hello'

    def index(request):
        return django.http.HttpResponse('This is the homepage')

    def cats(request):
        return django.http.HttpResponse('This is the cats page')

    urlpatterns = [
        django.urls.path('', index),
        django.urls.path('cats', cats),
    ]
Put that file in /var/www/mysite/mysite/wsgi.py, point your webserver to that file and you are good to go. In Apache you do it like this:

    ServerName mysite.local
    WSGIPythonPath /var/www/mysite
    <VirtualHost *:80>
        WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
        <Directory /var/www/mysite/mysite>
            <Files wsgi.py>
                Require all granted
            </Files>
        </Directory>
    </VirtualHost>
mg··on Discussion on why SQLite is gaining popularity [audio]
I wonder how much of a factor the "One DB, one file" concept is in SQLite's success.

I always loved that an SQLite DB is just a single file. People say "Who cares how many files the DB is?". But in practice, I always found it to be very convenient. It makes the concept of a project easy to grasp when the data store is simply a file.

I recently realized that a Django project can also be done in a single file. That made me like Django even more.

I have the feeling that this type of logic and simplicty is indeed a factor in the long term success of a software project.

mg··on Högertrafikomläggningen
I don't know enough about Mandarin to have an opinion on it.

The language has more characters than what fits on a keyboard, right? I wonder how typing on a keyboard feels. I guess only people who have experience in writing Mandarin and English can compare the feeling.

mg··on Högertrafikomläggningen
Maybe the world should standardize on:

    Driving on the right
    Speaking English
    The metric system
    The 2024-06-09 date format
    The Celsius scale
    The 24-hour clock
mg··on Stable Audio Open
When they released Stable Audio 2.0, I tried to create "unusual" songs with prompts like "roaring dragon tumbling rocks stormy morning". The results are quite interesting:

https://www.youtube.com/@MarekGibney/videos

I find it fascinating that you can put all information needed to recreate a whole complex song into a string like

     rough stormy morning car rocks hammering
     drum solo roaring dragon downtempo
     audiosparx-v2-0 seed 5
This means a whole album of these songs could easily fit into a single TCP/IP packet.

If a music genre evolves in which each song is completely defined by its title, maybe it will be called "promptmusic".

I will try the new model with the same prompts and upload the results.

mg··on ChatGPT Is Down
All public alternatives I know about:

https://www.gnod.com/search/ai

DevvAI, FastGPT, Perplexity, Phind and YouChat all seem to be up.

mg··on FrankenPHP: Modern PHP App Server
To support SSL you would add a virtual host section like this:

    <VirtualHost *:443>
        ServerName mysite.local
        SSLEngine on
        SSLCertificateFile    /path/to/cert
        SSLCertificateKeyFile /path/to/key
        DocumentRoot /app/public
    </VirtualHost>
And either use a real cert or add a command to create a self signed one:

    openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key -out cert
mg··on FrankenPHP: Modern PHP App Server

    docker run -v $PWD:/app/public -p 443:443 \
      dunglas/frankenphp
If you want to build a docker container yourself that you can use to serve your app, then running these commands should do the trick to turn a fresh Debian into the container you need:

    apt install -y apache2 libapache2-mod-php
    cat << 'EOF' > /etc/apache2/sites-enabled/000-default.conf
    ServerName mysite.local
    <Directory /app/public>
        AllowOverride All
    </Directory>
    <VirtualHost *:80>
        DocumentRoot /app/public
    </VirtualHost>
    EOF
Friends and I maintain a repo which shows how to go from zero to a running web application via popular languages and frameworks here:

https://github.com/no-gravity/web_app_from_scratch

mg··on Fractal Geometry
From a single image, one cannot get a good grasp.

If you want to show the world a new fractal, I think the best way is to write a js+webgl program and put it online, so people can explore it themselfes.

mg··on Fractal Geometry
A way to colorize the two-dimensional plane.

Nothing compares to the complexity of the Mandelbrot formula when it comes to colorizing the two-dimensional plane.

With complexity I mean the human impression of complexity. The reaction of "Oh, there is a lot of stuff going on in there" after looking at some parts of it.

mg··on Fractal Geometry
I'm still surprised that only one mathematical form has been found with the beauty and depth of the Mandelbrot set.

One would think that like in the physical world, there should be many "species" with different types of appearances. Each a beautiful system on its own, but in comparable complexity.

Maybe the complexity of the Mandelbrot set is to the mathematical universe what is the complexity of life in the physical universe. Something that is very rare. For some unknown reason.

mg··on Nostr is not decentralized nor censorship-resistant
I don't know much about Nostr, but would like to learn more.

The author says they usually publish their messages to the relay at wss://pyramid.fiatjaf.com

Does that mean when I use a Nostr client, I can instruct it to pull from that relay and as long as that relay relays them, I will receive all their messages?

If so, I would call that decentralized.

The fact that a relay can decide to drop a message seems hard to change.

I guess one could put an incentive into the protocol for relays to not drop messages. Like having them stake a certain amount of value and slash it when it can be proven that they refused to relay a message. But that might be pretty complicated. For example: How would you know the relay received the message? Maybe with a web of witnesses which each have a certain amount of earned trust? Tricky.

My feeling is that the easiest way is to just accept the fact that relays can decide to drop messages. And for publishers to post to trustworthy relays, and for readers to pull from trustworthy relays.

mg··on Firefox bug gets fixed after 25 years
The one long term open bug that irks me the most is that you cannot properly date-format the x-axis of scatter plots in LibreOffice:

https://bugs.documentfoundation.org/show_bug.cgi?id=54132

12 years old. According to the comments, fixing it is discouraged as the code is so "horribly complicated", it would likely cause regressions.

mg··on Windows Returns

    developers can add “breadcrumbs” to
    their apps so that you can not just
    return to a specific app but also the
    exact context you wanted to Recall
Similar to what the back button does on many web apps?

Some people say the web is not made for applications but for pages of content. But I often have the feeling that it is even more suitable for apps than the desktop. You can do so many things with "state in the url" - traverse it, bookmark it, share it, have multiple tabs with the app in multiple states ...

mg··on Bento3D
The headline says

    Bento3D is a web tool that allows
    you to create 3D printable dividers
    and toolboxes with millimeter precision.
Is the "millimeter" precision noteworthy? This is kind of a CAD program, right? Why would it have trouble with any precision? Isn't it just juggling numbers?
← PreviousPage 14 of 34Next →