``` mkcd() { if [ $# != 1 ]; then echo "Usage: mkcd " else mkdir -p $1 && cd $1 fi } ```
Ask HN: Small scripts, hacks and automations you're proud of?
61–70 of 340 posts
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#62If 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…
You've probably already seen them, but redbean and APE take a similar idea further:
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#63Re: Ask HN: Small scripts, hacks and automations you're proud of?
#64If 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…
Re: Ask HN: Small scripts, hacks and automations you're proud of?
#65I 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?
#66 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?
#67Re: Ask HN: Small scripts, hacks and automations you're proud of?
#68To 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?
#69my 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?
#70I'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.