News for hackers. Stuff that matters.
Re:“This project will only take 2 hours” by chmod775 on Wednesday November 10, 2021 @08:46AM (#29174551)
You can do feature creep for a long time. If you just want a basic working version (that will probably drain your battery), that can be done really quickly.

This took me ~10 minutes:

    #!/bin/sh
    set -e
    while true; do
        URLS="$(xsel | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*")" &&
        if [[ ! "${URLS}" = "${OLD_URLS}" ]]; then
            echo "${URLS}" >> urls.txt
            OLD_URLS="${URLS}"
        fi
        sleep 1
    done;
Re:“This project will only take 2 hours” by dugmartin on Wednesday November 10, 2021 @09:47AM (#29175144)
Isn't the >> going to cause urls.txt to grow geometrically?

eg, copying http://example.com/foo and then http://example.com/bar and then http://example.com/baz I think urls.txt would look like:

    http://example.com/foo
    http://example.com/foo
    http://example.com/bar
    http://example.com/foo
    http://example.com/bar
    http://example.com/baz
EDIT: I stand corrected. I should have run the code instead of mentally executing it.

One issue I did find when I ran it. The shebang should be:

    #!/bin/bash
as [[ is a bash built-in. I'm on Ubuntu - maybe this works on Mac as /bin/sh is an alias to /bin/bash?
Re:“This project will only take 2 hours” by ktpsns on Wednesday November 10, 2021 @10:07AM (#29175362)
Re:“This project will only take 2 hours” by BenjiWiebe on Wednesday November 10, 2021 @10:04AM (#29175330)
Doesn't look like it. The URLS variable could more appropriately be named CURRENT_URL. Singular, not plural.
Re:“This project will only take 2 hours” by stevelosh on Wednesday November 10, 2021 @10:25AM (#29175602)
The user might copy a block of text with multiple URLs, all of which get pulled out by the grep.
Re:“This project will only take 2 hours” by sporedro on Wednesday November 10, 2021 @09:55AM (#29175233)
Nice example, the problem with the article is the client(teacher) doesn’t know what they want in this case. It’s a good example of how feature creep and project scoping is important but if all you really want is a script to log urls that’s simple. Building a url logger with top notch security practices, cross platform, simple enough for my mom to use would be entirely different.
Re:“This project will only take 2 hours” by thewakalix on Wednesday November 10, 2021 @09:17AM (#29174859)
Using clipnotify[0], one could fix the busy-wait issue pretty easily.

[0] https://github.com/cdown/clipnotify

Re:“This project will only take 2 hours” by barnabee on Wednesday November 10, 2021 @11:38AM (#29176709)
Agree! Furthermore the reason we have such bloated and garbage software is a combination of this kind of feature creep and a complete lack of modularity.

Want pause functionality: write a small utility to provide an easy way to start and kill any program.

Want notifications: write a program to monitor any file and provide notifications when something it added to it.

Searching: grep or a GUI equivalent

Syncing: rsync/syncthing/Dropbox…

Someone will complain most people can’t use these tools. Firstly that wasn’t the initial question, and secondly that’s something I’d love to see tackled in a GUI tool. I don’t think it’s impossible, just misaligned with the incentives of people who make and overcharge for proprietary software.