Live data from Hacker News

Ask HN: Small scripts, hacks and automations you're proud of?

news.ycombinator.com

241–250 of 340 posts

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#241
post #240

Earlier quoted context omitted.

Definitely Kopia. I was skeptical at first, it's a relatively new tool and not much is known about it (at least on HN) but it's uber-fast and compresses extremely well. Detection of duplicate blocks seems both more aggressive and faster compared to Borg and Restic. It's honestly a win on all fronts. It can sync to remote places -- which I don't care about as I have a local directory where it does its stuff and I then…

What's your opinion on bupstash?

Tried it again about two months ago. Even though it definitely progressed feature-wise since my last try (>1 year ago), it compresses poorly and is fairly slow. I'd definitely rank it last if you put it next to Borg, Restic and Kopia.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#242
I have a small Perl script that has been useful for the last 20 years.

It uses OLE to open Word documents and print them to PDF. Nowadays Word has a save to pdf option, but initially the script would print to postscript and then convert to PDF with Ghost.

It runs from IIS, but over the years it has been used as a CLI tool or with Apache.

So far nothing has shown to be as reliable as this script at converting to PDF. It would be great not to depend on Word or even Windows, but there's nothing that can convert with the same level of fidelity.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#243

This is more in the "hack" category, but here is a solution for bookmarking directories[1] that I am quite fond of: mkdir ~/.marks/ export CDPATH=.:~/.marks/ function mark { ln -sr "$(pwd)" ~/.marks/"$1"; } Then: mark @name # add bookmark called @name for the current directory cd @name # jump to the bookmarked location cd @ # list all available bookmarks It can list bookmarks, auto-complete, jump to sub-directories w…

Nice!

I gave up on bookmarking so I now use an alias to quickly find what I am looking for with fzf and fd:

  p () { cd $(fd $1 $HOME -d 4 -i -E Pictures -E Desktop | fzf) }

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#244

On Windows: - Created a folder called "shortcuts" - Copy the folder URL into the system path (Control Panel, Environment variables something something) - Create a shortcut of anything I want to hyperlink to and put in there, with descriptive names - In IE, I think the setting was to enable autocomplete. For some reason that was linked to the autocomplete of the run menu item in Windows. - For extra bonus points, add…

This shortcut tip combined with a short power shell scripts save me what feels like hours a month. Super quick access to certain things, dynamically, as the script takes input after it's name versus navigating guis.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#245

Easily my highest utility script so far was to get an edge while picking classes. At my university there were some classes which were very competitive and there was also system where tranches of students would get access to those classes earlier (e.g. groups of honors students -> groups of seniors -> juniors, etc). I was a lowly sophomore at the time, so I basically got what was left over. Before I could register I c…

It reminds me of my time as an undergrad in a quantum chemistry lab. I had something like 150 calculations to run (about 4h each) and therefore could only submit them to the "small" calculation queue (for jobs less than a day).

The problem was that it was essentially always used at the maximum because most people had such small jobs to run + other queues were not as efficient. Because of the inner "fighting", the HPC admin essentially blocked the possibility to have jobs pending. So first come first serve.

So basically I've set up a cron job to look prepare my jobs and look for empty slots during the night. I remember looking at results in the morning while sipping on coffee and the head of the lab congratulating me for my "dedication" as she saw I submitted jobs at 3AM!! :)

At the end of the internship, I basically had a script "assistant" that I would use to prepare the calculation jobs, unite them so I could use them on "bigger" queues, do most of the post-calculation analysis (essentially producing CSVs and graph for me).

And I am too, chasing that high to this day.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#247

I made a CLI tool for quickly starting new branches with draft PRs, asking for reviews, etc: https://github.com/dbalatero/work-cli Made a bunch of Hammerspoon plugins for macOS: - https://github.com/dbalatero/SkyRocket.spoon - mod+click to resize/drag windows - https://github.com/dbalatero/VimMode.spoon - Vim mode everywhere - https://github.com/dbalatero/HyperKey.spoon - pop-up menu for when you forget your keybinds…

oh I've been down the "I can just fix macOS" road. The sooner you move away the better. so much time wasted on plugins like these. you effort will just be null the second apple change the usability apis enabling hammerspoon, like they did countless times before. I don't even rename the name of the fallen apps before it. instead now I contribute things as long lived proper features on KDE and hopefully advance humanit…

I am down as soon as we can use the full M machines with Asahi Linux

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#248
JSONBin: https://github.com/theowenyoung/blog/tree/main/scripts/jsonb...

CronBin: https://github.com/theowenyoung/blog/tree/main/scripts/cronb...

Both scripts are deployed as single file js in the free tier of Cloudflare's Workers, and my personal workflow relies on these two simple services for all persistent data storage and scheduled tasks.

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#249
post #122

A useful hack I've implemented in several projects is to accept the stored password hash as a valid password. It is generally possible to impersonate a user but there are always subtle differences in the way those sessions work. Accepting the hash lets people with database access perform a real login if needed.

> Accepting the hash lets people with database access perform a real login if needed. ... and if anyone managed to say do an SQL injection and retrieve said hashes, then that then would give them access to your users accounts, right?

Yes it would and might be a reason you would not want to do this, although nobody would try to login using hashes unless they also have access to your source code (or read that comment I guess? :D).

Re: Ask HN: Small scripts, hacks and automations you're proud of?

#250
post #196

I use the following tiny script to make PDFs look like they have been scanned. There are still entities that require you to physically sign a document and scan it. So far, everyone accepted PDFs like these: #!/bin/sh ROTATION=$(shuf -n 1 -e '-' '')$(shuf -n 1 -e $(seq 0.05 .5)) convert -density 150 $1 \ -linear-stretch '1.5%x2%' \ -rotate ${ROTATION} \ -attenuate '0.01' \ +noise Multiplicative \ -colorspace 'gray' $2

this surprise me, I don't know pdf can work on this way haha.
Post reply on HN