Live data from Hacker News

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

news.ycombinator.com

61–70 of 340 posts

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

#62
post #41

If you add a .CMD file as the first entry in a .ZIP, with compression set to "none", you can rename and run the .ZIP as a .CMD, because the PK header will be treated as a nonexistent command and execution will continue after that. With a little imagination and some PowerShell I've made that into a self-extracting archive. It's a dirty hack, but I've had it working in production for years now. I want to see if I can m…

Really neat.

You've probably already seen them, but redbean and APE take a similar idea further:

https://redbean.dev/

https://justine.lol/ape.html

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

#63
I created a small script that runs every time I log into my work notebook. It starts VPN, Teams, Firefox, Windows Terminal and my other development tools. Huge time saver as I'm usually getting something to drink or brushing my teeth in the morning when I log in.

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

#64
post #41

If you add a .CMD file as the first entry in a .ZIP, with compression set to "none", you can rename and run the .ZIP as a .CMD, because the PK header will be treated as a nonexistent command and execution will continue after that. With a little imagination and some PowerShell I've made that into a self-extracting archive. It's a dirty hack, but I've had it working in production for years now. I want to see if I can m…

If you run a "cls" as first command in the batch file no one would notice the invalid command of the PK header either (and not get possibly confused).

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

#65
post #63

I created a small script that runs every time I log into my work notebook. It starts VPN, Teams, Firefox, Windows Terminal and my other development tools. Huge time saver as I'm usually getting something to drink or brushing my teeth in the morning when I log in.

You're missing out on a billable hour per week! Two hours if you time all your updates correctly.

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

#66
This bash config allows you to cd directly to the most commonly used directory with a specific name. It also has tab autocomplete. It does require logging all used directories though.

  tabChar=$'\t'
  function prompt_command {
      echo "$(date +%Y-%m-%d--%H-%M-%S)$tabChar$(hostname)$tabChar$PWD$tabChar$(history 1)" >> ~/.full_history
  }
  export PROMPT_COMMAND=prompt_command
  
  function c {
      while read -r _ dir
      do
          if [[ -e "$dir" ]]
          then
              echo "$dir"
              cd "$dir"
              break
          fi
      done 

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

#68
I ran an e-commerce business that used Australia Post for shipping. A few years ago, I was responsible for 90% of Australia Post's lost parcel/SLA refund customer service volume in one day. Before COVID, Australia Post had a "Next Day Guarantee" for parcels sent through their Express Post network. If the parcels didn't arrive the next day, customers could choose to get a prepaid satchel or their money back.

To take advantage of this, I wrote a script that tracked our shipments from the previous 12-months and identified which parcels were late. It then lodged a new inquiry through Australia Post's website. I received a call from the head of Australia Post's customer service team, telling me I was responsible for 90% of their volume. Apparently, what was causing delays was the need to wait for us to select "get money back" or "prepaid satchel", and she asked if they could do one or the other for all inquiries. This would have impacted the queue size (guessing one of their KPIs).

In the end, we received several thousand dollars' worth of postage refunds.

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

#69
all my public gists[1].

my favorite is hypothesis die hard[2]. i need a sequence of actions that accomplishes a goal. assert there is no such sequence. error, here is such a sequence. ok thanks!

1. https://gist.github.com/nathants

2. https://gist.github.com/nathants/3dc397270d73fee57c86f246243...

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

#70
I wrote a wrapper around brscan and my brother printer with a feeder but no duplex scan or save to network folder capability to get double sided deskewed ocr'd pdfs into paperless-ngx with the touch of a physical scan to PC button.

I'm medical and a hobbyist, not technical, so I was happy to figure this out in bash with some trial and error. I scan the fronts, it gives me 15 seconds to put the backs in the way they came out and it deinterlaces after with deskew, ocr, etc. I used it to shred most of my filing cabinet and now scan bills/letters/receipts/etc. A cron job banks up paperless-ngx offsite using borg. For me it's just slick, my spouse uses it independently (!), and helped my bookkeeping a lot.

Post reply on HN