Ask HN: What small library or tool do you want that doesn’t exist?

69 points by shakezula ↗ HN
The smaller the better! What small, sharp tool do you wish existed but doesn’t or does but isn’t up to the quality you’d expect?

144 comments

[ 3.4 ms ] story [ 219 ms ] thread
I sometimes find myself wanting a Unix timestamp, or to convert one into a human-readable date, and usually it's simpler to go to an online tool than use time(1).

It might be nice to have a command line tool which can guess from the arguments what you want it to do. For example, if you run it with no arguments, it would output the current timestamp (to multiple levels of precision, listing the languages/platforms that typically use each one).

I always forget how to get a unixtime so I either load a repl or the manpage for date, but FreeBSD date -r 123 works to go to human time. date -u -r 123 if you want UTC.
Get print the current time as as Unix timestamp.

    date +%s
To convert a Unix timestamp to local time with GNU date, e.g.

    date -d @1651483224
With BSD date, e.g.

    date -r 1651483224
Yes, I can never remember that. It's faster to just go to some online tool than to look up how to convert timestamps with `date`. Especially since I often switch between Linux and "BSD" (macOS). Something like this would be nice:

    $ datez 1651483224
    human-readable-timestamp
    $ datez human-readable-timestamp
    1651483224
> Yes, I can never remember that.

Create aliases?

Had never thought of building such a tool, but now that you mention it, there were cases where I had Unix sitmestamps in log/debug files for instance. I ended up using the web browser console to do a quick conversion.

I just gave it a try now, as a shell script:

    #!/bin/sh
    # https://news.ycombinator.com/item?id=31233092
    
    case "$1" in
        -*|"")
            echo "Usage: datez <unix-timestamp>"
            ;;
        *)
            if date -r "$1" 2>/dev/null; then date -r "$1"; else date -d "@$1"; fi
    esac
Edit: tried to add the reverse, from human-readable-timestamp to Unix timestamp, and got a problem when the locale does not use the English language: the human-readable form is not understood by date as input!

So the round-tripping version of the script has to set the locale to C:

    #!/bin/sh
    # https://news.ycombinator.com/item?id=31233092
    
    # Needed for round-tripping:
    export LANG=C
    
    case "${1}" in
        -*|"")
            echo "Usage: datez <unix-timestamp|human-readable-timestamp>"
            ;;
        *)
            case "${1}" in
                (*[!0-9]*)
                    date -d "${1}" +"%s"
                    ;;
                (*)
                    if date -r "${1}" 2>/dev/null; then
                        date -r  "${1}"
                    else
                        date -d "@${1}"
                    fi
            esac
    esac
Edit 2: it does round-trip by using a locale-independent format like "%Y-%m-%d %H:%M:%S %Z", which is anyhow the format I prefer:

    #!/bin/sh
    # https://news.ycombinator.com/item?id=31233092
    
    # Needed for round-tripping if you use a locale-dependant format:
    #export LANG=C
    FORMAT="%Y-%m-%d %H:%M:%S %Z"
    
    case "${1}" in
        -*|"")
            echo "Usage: datez <unix-timestamp|human-readable-timestamp>"
            ;;
        *)
            case "${1}" in
                (*[!0-9]*)
                    date -d "${1}" +"%s"
                    ;;
                (*)
                    if date -r "${1}" 2>/dev/null; then
                        date -r  "${1}" +"'${FORMAT}'"
                    else
                        date -d "@${1}" +"'${FORMAT}'"
                    fi
            esac
    esac
I'd love to be able to append to a mdb file with mdbtools.
I wish VLC, plex, video players in general had the ability to automatically sync subs to audio. (automatically, not manually)

We have the technology; everything we need to do this exists. It's just not done automatically, and when using slightly off-sync subs, you have to fiddle with sub timing for ages until you find the right sync. Even more so when the subtitles have different off-sync issues for the whole movie/episode.

I've used https://github.com/kaegi/alass and sometimes it works, sometimes it doesn't. It's not an easy problem to address automatically...

Video players wouldn't want that in their codebase, maybe if it was available as a C library.

I can vouch for alass working quite well about 70% of the time.

It's very convenient when it does.

And you need to do the manual thing so rarely, that you always forget that does the delay need to be positive or negative if the subtitles are fast. =)
And then VLC does this weird freeze thing to catch up that can't be aborted, so if you accidentally type an extra zero into delay, good luck waiting for that to stop haha. Usually faster to just restart the damn thing.
I don't know about 'automatic', but in mpv[1] you have this:

> Ctrl+Shift+Left and Ctrl+Shift+Right

> Adjust subtitle delay so that the next or previous subtitle is displayed now. This is especially useful to sync subtitles to audio.

This works in 9/10 cases. :)

----

[1]https://mpv.io/

I think this is what the OP refers to with "fiddle around for ages". I know the problem not with subs, but when audio is off related to the image. And of course the problem is rare enough that I am never "in training", and have to find a remarkable spot first (e.g. door slam shut or a suitable spot in dialogue), then think about going backwards or forwards, guess the amount, etc. etc. :)
If the whole subtitle file is out of sync (e.g. every line is late 2s), one shortcut is all it takes. In that 1/10 case, you do need to 'fiddle around for ages', but given that all other options (e.g. SubtitleEdit[1]) are way more complicated and time consuming, mpv is all I could suggest. For the problem with audio and image being out-of-sync, I have no idea :)

---

[1] https://www.nikse.dk/subtitleedit

For AV sync you can do this in the receiver (and some devices with e.g. Bluetooth support for speakers) because it's not really a problem with the source material (typically anyway) it's just something that does need tuning to the room & hardware.
Try SubSync, open source movie subtitle synchronization app. Build in feature like this in VLC would be awesome.

https://subsync.online/

Discussion on HN (4 months ago): https://news.ycombinator.com/item?id=29794153

Yes I was in that thread hehe :)

Given our capabilities, it's really a straightforward thing to do. YouTube does it automatically (you drop in your script with the video, it auto-syncs everything).

It could even be done for when the language doesn't match, given an auto-translation pass and some heuristics.

But that's the "job" of releasers? I have had to manually sync subs to audio maybe a few times over the past two decades...
I use Bazarr to automate downloading of subtitles for my movies and TV shows, and it integrates subsync. Works 99% of the time, if it doesn't I find the subs for that particular series are consistently offsync by 1.0s which is easy to fix with decent media players.
It's 2022, I just want to make a website that runs everywhere. some input boxes| some video| some whoosh
What issues with plain old HTML are you running into?
If you develop on Chrome given that it's the largest, then you have the following issues:

- Firefox will render stuff wrong

- Safari will render stuff wrong and something will break

Generally browsers these days are pretty good.

There are some dark corners where there are still differences but these are not in the "I just want to build a website"-level of complexity IME, and are more in the "I am building a large XXX,XXX lines-of-code enterprise SPA used for hours at a time for thousands of users as their primary job across varied OS and browser combinations" level of complexity. E.g. I recently had to debug how different browsers handle cookie eviction for more than 100 cookies under the same top-level domain. This is not the sort of issue you you face with a "I just want to build a website" problem.

I unknowingly relied on undefined behaviour in JavaScript Array.sort; worked fine/as expected in Firefox but then got bug reports that turned out to be Chrome/Safari.

Not just dark corners IMO.

Interesting - what were the details? I've never heard of this and rely on this feature all the time so please do share the reproduction so we can all benefit?

    > [2,1,3].sort((a,b) => a < b)
Sorts in Firefox (gecko), but not in V8. (resp. `a > b`.)

FF:

    Array(3) [ 3, 2, 1 ]
Node:

    [ 2, 1, 3 ]
(Obviously that's a silly example because you'd just `.sort()`, I think I was doing `a.id < b.id` or something, but it's not a significant detail.)

You can even reduce the reproduction to `[1,2].sort((a,b) => 1)`. Have fun..!

I use MS SQL Server a lot at work. I interact with instances via SSMS usually. I'd love a tool that would log to file every query that I execute. Including a customisable comment line with info including when it was run and the server/db it was run against.

I'd move to a command line tool, e.g. a sqlcmd variant or shell voodoo, if it could do that.

AWS has their own crontab syntax, slightly different from regular Cron. But there is no validation tool before you submit something. It just rejects it. I want something like crontab.guru but for cloudwatch syntax. It's such a small usecase but it'd be great.
NAME

  swizel - takes csv input, selects columns and arbitrarily selects output order
OPTIONS

  change the field delimiter (default comma)

  handle trimming whitespace per field (or an arbitrary set of chars, e.g. quotes)

  ignore or transform a prefixed one-line header or comment (default #)

  [bonus points] handle numeric fields (e.g. precision or float/int conversion)
OBLIGATORY

  while all of this can already be done with a combination of cut, sed, tr and/or awk, it's a common task when working with columnar data and could be made more intuitive and less error prone. transforming columnar data mostly boils down to clean up and basic sanity checks. good karma on this one.
Reading this, I'd like a neural net trained on man pages as input, with C code as output :D
A library of person-to-person communication snippets for those of us on the spectrum like this tool https://news.ycombinator.com/item?id=31224996 but curated by well intentioned community.
This is a great idea!
I would suggest not using those ones by the way - most of them sound pretty passive aggressive to me (British) and no better (worse in some cases/contexts) than just being forthright.
A faster way to bulk delete or upload S3 files. The cli given by AWS is awfully slow for static sites with 100k files.
"Geometry as a service". An API endpoint that takes a compact description of various 3d shapes and returns a GLTF file. I'd start by maybe wrapping the various tools from https://www.antiprism.com/ but there's scope to create a more friendly set of tools for generating generally useful simple meshes.
A cross-platform command-line tool + C library with permissive license that makes compressed file-deduplicated snapshots of directories with accompanying indexed metadata. It should be foolproof, use a fast compression algorithm like snappy or LZO, and be optimized for fast multicore creation and extraction (but with optional CPU-limiting). Metadata could be stored in an sqlite database.
To what end? I think borg or restic would both match these criteria. Maybe you're hoping for something that does this more online and continuously?
I'm looking for something in-between a version control system and an archiver, with simple file-based deduplication and as fast and robust as possible. Maybe you can explain whether restic and borg fit my needs. Desired functionality:

- Main inputs are an input directory or a list of files, the location of a file repository (1 file), the location of a metadata DB, and some indexed and searchable metadata like original path, modification date, semantic version number, arbitrary title, and other strings.

- If an input file has been changed or is not yet stored, it is archived in the file repository compressed with very fast compression like snappy or LZO with corresponding metadata and version in the metadata DB. Otherwise only the metadata information is stored. Support for deltas / storing incremental changes in the file repository would also be nice but is not required.

- The metadata is stored in the metadata DB so later a file can be retrieved based on version information, it's original modification data, it's original path, and/or metadata regexp searches.

- Snapshots of an input directory or list of files can be extracted based on version information and any other metadata. Extraction needs to be very fast.

- The library needs to work on common file systems and at least on Linux, Windows, and MacOS.

- Archiving should be ACID-compliant. Either a file is stored with all of its metadata so that it is retrievable, or nothing is stored and an error is returned. Likewise for whole input directories and for extraction.

I would love a small conversion tool to read in medical imaging dicom files and output a volumetric vdb dataset. I've nearly written this on several occasions. Most, but not all, dicom files encode a 2d or a 3d scalar field and vdb files are the graphical effects industry standard format for those, usually used for fog, fire, or similar effects. They can also usually be converted to polygon meshes through a variety of algorithms.

The reason why I want to do this is because 3d tools for artists -- blender, cinema 4d and the like -- have a large amount of easy-to-use and highly complex tools for subsetting volumes and making things look pretty.

Most medical imaging software is the opposite of this. You cannot change the data and the tooling is intentionally limited. Mostly this is a very good thing. Sometimes, however, and particularly for complex anatomy or pathology from a patient, you really just want to make a beautiful image for a paper with an anatomical structure manually removed, highlighted, or coloured differently -- something that would be very easy in e.g. Blender. The fact that Blender is python-scriptable is also frankly amazing and it's natively cross-platform too.

The reason I have written a tool like this is entirely because both file formats are very complex with lots of edge cases -- e.g. most ultrasound dicoms are little more then a screenshot with a lot of metadata, UI overlay and all. It's a lot of work and fundamentally isn't my job (I'm a medical physicist and should be making images with novel physics, not making images look pretty for presentation purposes).

Can you link a VDB spec?
Sure! The details are on OpenVDB's website [1] and technical guide [2] and githup repo [3].

It's not as mature as the dicom standard (which is very...mature) and they do change it occasionally, but it is stable.

[1] https://www.openvdb.org/documentation/ [2] https://academysoftwarefoundation.github.io/openvdb/ [3] https://github.com/AcademySoftwareFoundation/openvdb

Thanks! It seems like a very simple problem, is there a python library for vdb file IO? If so, I can probably whip something up (in python) with relative ease.

I work in the medical software field by the way. I know all about the pains of dicom...

Would love to schedule whatsapp messages using some cli/web based tool
There are good APIs for doing that like messagebird.com
- In Visual Studio (not VSCode) I want to be able to go through all changed lines like I can go through all bookmarks.

- In Visual Studio I want a tool that shows me show many "hops (calls)" a C# method is away from another method.

A tool that checks your broken python/pip install and fixes it properly.

https://xkcd.com/1987/

I was just setting up a new Mac the other day, only to be surprised that this is _still_ an issue. All I had was XCode and Homebrew - everything fell apart when I tried to install ansible.
There’s no solution. You gotta have a separate environment (e.g. a docker container) for each project. Each env has its own python version and requirements.txt
Not practical when you need something like ROS with rospy that needs to be global.

Python is putting its fingers in its ears singing "LALALALA USE A VENV" instead of fixing the damn ecosystem. Node and npm proved that a solution exists and it's doable.

There's a PEP for adding support for a __pythonpackages__ directory, similar to node_modules.

https://peps.python.org/pep-0582/

Unfortunately the PEP is from 2018 and is still being discussed. The last post in the comment thread is from February.

https://discuss.python.org/t/pep-582-python-local-packages-d...

That's unfortunate; until I went looking for citations I thought it was further along and actually scheduled for the next Python release.

Looks like there is a pip-alternative that implements the PEP, but I haven't played around with it yet.

https://pdm.fming.dev/

Throwback to the time when I accidentally did a `sudo apt remove python` in hopes of cleaning the python mess in my PC and broke my LM installation.
Apt has the big brained move of uninstalling half your system if you try to reinstall a core dependency instead of just setting the dependant packages as disabled while it's missing or something, ffs.
Poetry is almost that. It also takes 99% of the trouble of solving dependencies in pip files

(though the usual way it breaks is your python interpreter gets updated and the venv becomes useless)

This sounds interesting. I'll check it out, thanks :)
I don't think it's possible if you use a global environment for everything, as different packages might have conflicting dependencies. The best way to solve it is to separate environments. I personally prefer conda as it's fairly easy to create environments of any python version.
The top of the list is an open-source library toolbox for higher-order spectral analysis including time-frequency in a compiled programming language (C, C++, D, Rust, etc) for real-time applications.

This is an example of an old third party higher-order spectral analysis toolbox in Matlab but now Matlab has built-in toolbox due to its increasing popularity in signal processing of communication, biosignal, etc [1],[2].

The next generation communication systems (e.g. WiFi 7, 6G) will probably utilize this form of signal analysis for higher bandwidth and efficient communication [3]. The modern biosignal analysis (ECG, EEG, etc) is already moving toward time-frequency analysis and to have an open-source real-time time-frequency toolbox will be a game changer [4].

[1]Higher-Order Spectral Analysis Toolbox for use with Matlab:

https://labcit.ligo.caltech.edu/~rana/mat/HOSA/HOSA.PDF

[2]Time-Frequency Foundations of Communications:Concepts and Tools:

https://www.mins.ee.ethz.ch/pubs/files/SPMAG2013.pdf

[3]The OTFS Interview – Implications of a 6G Candidate Technology:

https://www.6gworld.com/exclusives/the-otfs-interview-implic...

[4]Analyzing Neural Time Series Data: Theory and Practice:

https://mitpress.mit.edu/books/analyzing-neural-time-series-...

I want a VSCode extension that has some simple geometry features for obj files, like viewing, slicing etc.
I wish I had a tool which measures the trend of every line code in my codebase in production, and shows me on IDE on the background of each line of code which code is mostly used (dark green background or such) and which code is barely used (in light green), and in gray unused code in production (based on the trend of last few months.

The benefits :

- I will understand during development which code is mission critical, and I should be careful with it, as well as invest more time in optimizing this code and document it better.

- I will understand what the customers do, which flows they use and which flows they avoid, so seeing code which I've developed recently but not used yet - will help me understanding that I'm wasting my time on writing unused features or we did not really understood the customers expectations.

- I will be able to cleanup dead code easily on the go.

It's like a theme park manager walking around in the park and watches which rides has long lines of people and which rides have no lines.. helps the manager understand where to put effort and which rides to remove / replace.

This can be approximated by generating a lot of metrics and monitoring executions
What about code that is super important but rarely used like once a year - just when it fails you are in big trouble?
I would want something slightly different. I care a lot about how recently code has been changed. I usually don't care how much code is run in production, unless it isn't run at all, and then I care a lot. So:

Code that was changed within the last week: red

Code that was changed within the last month: yellow

Code that hasn't been changed in over a month: normal

Code that hasn't been touched in over a year: green

Dead code: blink tag, DOOM music plays

We've built an internal tool which does exactly this. Among a bunch of other correlations
ever thought on making this open-source?
It sounds like you want to combine git blame with performance data.
The tooling for this exits and is 100% usable.

All you have to do is run a build with coverage enabled and then load the coverage data files into your IDE. At least Eclipse (with EclEmma) shows the results in a way that are pretty close to what you described. I'm sure other IDEs can do the same.

The only thing is that nobody does this on production, because of the performance impact and potentially increased risk.

I was looking for a tool to post video tweet threads. I couldn't find any so I built my own https://clippost.io/. Currently, its very basic tool to convert YouTube, Instagram, TikTok videos to twitter video tweet thread. If I get some users i will definitely add more features to it.
Thanks for posting this. I'm gonna start using it for my Youtube channel: Better Sheets. Been meaning to post more on Twitter from the YT channel and this looks so great!
A simple app (e.g. a wordpress plugin) that would load some nice elements of a web page above the fold ... then load the rest of the web page after ... something that would lower time to first byte, first contentful paint and time to interactive.
I think best approach sounds like a theme given the specific nature of loading assets and unknown nature of content layout.
(comment deleted)
Something to convert from one date to other, but with timezone names used by humans. For example:

"today 17:00 Pacific in UTC" should be accepted.

There are other time zones too: I've seen "PDT", "Mountain", and so on. The `date` tool doesn't always understand what those are. That's a bummer because neither do I, and that's why I need this tool.

date(1) is very close to doing this.

/ You already mentioned it.

As I wrote, it doesn't understand the same things I don't, and that's why it's not directly useful here.
(rip)grep S3 super fast
Where would you like the compute to run?
A very simple tool for transferring files between two computers. Linux <-> Windows should just work, uPnP handling, etc - just a crazy simple way to transfer a file without setting up Dropbox, ftp servers or whatnot!
It is strange that most of these tools seem to involve sending your data half way around the world. Guess local doesn't pay?

I just use good old SMB/network sharing - it's not much harder than setting up some program on two devices. Works between Windows/Linux/Android, fast and good enough.

For files that are not private I use: https://btorrent.xyz/

People usually recommend https://file.pizza but it just doesn't work for me.

Now that I think about this it would be beautiful if there was something like stunnel but for NAT hole punching and what not. You would do:

  $ send-file FILE
  qk11c14pmq7maeod
  $
You would send the unique id (that could be also something that gives a QR code to scan or something like random words) over a separate channel. Then you would "receive-file qk11c14pmq7maeod" on the other end. It would be a simple binary that would be easy to embed and call through some pretty UI. Probably generation and scanning of those possible QR codes would have to be a part of the package. The problem would be who would finance servers needed for NAT traversal?
You're looking for croc or magic-wormhole.
Setup SCP on your windows box, everything else already "just works".
transfer.sh seems pretty close to what you’re looking for