Live data from Hacker News

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

news.ycombinator.com

101–110 of 340 posts

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

#101
post #9

In 2004, the website All Music Guide did a horrible redesign. I was so irritated that I created a Firefox extension that did only one thing — it made All Music Guide a bit more useable. To my knowledge, this was the first "site-specific" browser extension, so I wrote a blog post about it: https://www.holovaty.com/writing/all-music-guide/ Aaron Boodman saw my post and decided to generalize the idea; he created Greasem…

Ah, that reminds me of how I modified sites using https://www.proxomitron.info/ , it's a Windows program that would start a local HTTP proxy and you can configure browsers to use this proxy, and it would block ads. This worked really well before the web became HTTPS-crazy.

The way it would block ads is to analyze the files it was fetching for the browser and modifying found keywords, for a crude example all IMG tags with SRC containing the string ad.* would be replaced by gray images.

I also remember using it to "fix" a redesign of a site.

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

#102

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"…

https://github.com/ajeetdsouza/zoxide

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

#103
I made a small tool to automatically handle git/npm stuff without worries. Think of it as a automated tiny local CI, you just run "happy" and can rest easy knowing that in few seconds/minutes (depending on your build+tests+etc) the latest running version will be deployed in git/npm/etc:

    npm install happy -g

    $ happy

    // Basically does:
    - npm build (if package.json build available)
    - npm lint (if package.json lint available)
    - npm test (if package.json test available)
    - git add . && git commit -m $MESSAGE || "Saved on $DATE"
    - git pull
    - git push

    happy --now
    // Same but omit the build+lint+test steps, ideal for e.g. a documentation change

    happy --major | --minor | --patch | --publish 1.2.3
    // Same but use `np` (install separately) to bump the {publish} version and publish it in npm
It is built to maintain many small Git/npm projects, which fits my usecase and needs perfectly. But it has some limitations ofc, like it works assuming small projects working on a single git branch so if you have any kind of more advanced git setup it won't work properly.

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

#104
post #42

Getting transaction data from banks is hard. Especially timely data. Luckily both my banks have the option for a notification email being sent immediately after each Visa or checking account transaction. Using n8n I can parse those emails and put the data into a nice Airtable base (and a csv for backup). Next step, is to add GPS co-ordinates to each transaction. Does anyone know if there is a way to run a secure and…

There are a few open source ones:

https://www.traccar.org/ https://owntracks.org/ https://apps.nextcloud.com/apps/phonetrack (if you have a nextcloud)

The nextcloud one is by far the lightest on my phone battery, the other ones would often use very much battery. But i use android and YMMV.

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

#105
back in the covid period, i wrote a small set of scripts to automatically attend my university lectures on zoom:

https://github.com/WantGuns/auto_meet

it does the bare minimum of:

    - parsing calendar events (which have meet links)  
    - open zoom meets on lecture's starting time  
    - exit meet meets on lecture's ending time  
    - shutdown machine when all the meetings were over

my sleep schedule was f-ed up to say the least. these scripts helped me maintain my attendance :)

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

#106
post #83

One of my favorite spa/hotels for a weekend retreat for my wife and I has absurd waitlists — takes a few months typically to reserve 2 nights. However, they have a 7 day cancellation policy that leads to a U shaped availability curve for rooms. The hotel website itself is inordinately difficult to search more than 1-2 nights (each day takes 6-8 clicks to search), but it’s all queryable through an undocumented API, so…

> but it’s all queryable through an undocumented API How did you go about querying this?

My guess is the developer tools. Maybe the web page makes you open a date dropdown for "check-in" > select check-in date, same for checkout, hit "search", and then a pop-up would open saying "sorry, nothing available", which you'd have to dismiss before repeating the process, but in the developer tools you might be a able to see that there's an XHR query which is just something like /searchAvailability?checkIn=20230313&checkOut=20230315/&guests=2, and OP's script could just modify the dates and hit this request URL.

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

#107
imgopt - shell script for image optimizing — just a convenience / batch processing wrapper more or less. Nothing earth-shattering, just really handy for me over the past year.

https://gist.github.com/wittman/ab90f0eca5124233fa5163a32f89...

# Prerequisites: ImageOptim (desktop app) https://imageoptim.com/mac

## pngquant https://github.com/kornelski/pngquant

brew install pngquant

## oxipng https://github.com/shssoichiro/oxipng

brew install oxipng

## sips (utility provided by default in OS X)

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

#108
post #83

One of my favorite spa/hotels for a weekend retreat for my wife and I has absurd waitlists — takes a few months typically to reserve 2 nights. However, they have a 7 day cancellation policy that leads to a U shaped availability curve for rooms. The hotel website itself is inordinately difficult to search more than 1-2 nights (each day takes 6-8 clicks to search), but it’s all queryable through an undocumented API, so…

> but it’s all queryable through an undocumented API How did you go about querying this?

Mostly recording and replaying the network request logs through Chrome and comparing diffs as I clicked around, looking at headers and URL params generated from clicking to get a high level picture for how it all fit together.

They didn’t do anything fancy in terms of auth, etc, so the only thing that was challenging was guessing some additional parameters and formats for things like number of nights, etc., once I had the basic structure.

Once I had a basic search working, the rest of it was pretty straightforward. It works for other hotels that use this booking software as well, but I didn’t bother to go down that rabbit hole much further as I didn’t want to encourage adversarial techniques and I only need to use it a few times a year.

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

#109
post #49

I inadvertently caused a VERY VERY large corporation that is a household name to change its TOS through one of my little automation scripts. By little, I mean a few dozen lines of code and some ingenuity. The corp in question: Begins with V and ends with z and likes to screw customers. All above board, approved by several levels of various teams/depts. The head of a specific dept sent me several strongly worded texts…

if you really wanted to write about it, you could have just avoided referring to the corp name at all, tos and ndas, and just write about the technical details of this script. you could even have done so under a throwaway.

But the technical details would make him identifiable?

Although I agree with you, as it is, OP is just bragging about the effect while we're looking to be impressed by the technical details of the hack.

Post reply on HN