Live data from Hacker News

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

news.ycombinator.com

41–50 of 340 posts

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

#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 make the batch file chimeric so it can run in a linux shell as well. Maybe that'll to be my lazy Sunday afternoon?

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

#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 private location tracking service to my iPhone, or is my only hope to pay Apple the annual fee and do it myself?

(Yes: I wrote "secure and private location tracking" with a straight face - I'm hoping there's a solution out there)

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

#43
post #7

All of my favorite things are little AutoHotkey shortcuts. I have several that basically just execute a Regex replace on whatever text is currently highlighted. It's ridiculously convenient to just have those functions ready to go any time. But I started accumulating so many of them, it got to be a problem just remembering all the ones I had and how to trigger them. I had to start finding new ways of keeping them all…

Another interesting trick is to have a capslock layer (or any other "useless" key you may have, but capslock is much easier to reach obviously) with something like:

    ; ahk v1 code
    CapsLock::
      KeyWait, CapsLock
      If (A_PriorKey="CapsLock")
        SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On"
    Return
    #If, GetKeyState("CapsLock", "P") 
      u:: ; convert selection to code in markdown by pressing CapsLock+u
        SendRaw, ````
        SendInput {Left}
      Return
      ; ...
    #If

I also find myself with way too many obscure Mouse button {1|2}, Ctrl, Alt, Capslock, F{1|12}, etc. incantations I never remember and end up opening the script to search them. I thought about adding pie menus based on context but never got to it. Would you mind sharing a minimal example of your right click menu? Sounds much simpler and accessible. The keyboard hook à la vscode chords also seems pretty useful, will definitely implement that

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

#45
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/voicemails. He was rather expressive to say the least over something that cost $0.

I could go in more detail but there are a few NDAs I signed.

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

#46
Short little scripts and applications I am quite proud of (most available on github, most have videos on youtube): A Python script that would go through a bunch of PDFs submitted to a conference and slap on the copyright, current year, and conference name so my wife didn't have to hand-edit the fifty or sixty papers submitted, which regularly happened about 10 times per year before the pandemic.

A couple of PowerShell scripts that moves multi-gigabyte files from the computer that generates it to an intermediate server, and then another computer picks those up and puts them on to whatever storage space is available, squeezing them in via a naive backpack algorithm. It shaved about two hours per day off my workload, instead of manually copying files around the network and then monitoring them to make sure they got where they meant to go.

A couple of Python scripts that tell a number of SONY video cameras to wake up, pull in the video and audio over USB, verify the files transferred correctly, then erase them from the camera to make space on the SD card.

A simple voice-controlled personal assistant that can start & stop multiple video cameras, perform the "mechanical clapper" effect for each scene and take, label the video files, and read out the prompt for the scene about to be shot.

A simple C# stopwatch timer for Windows that logs my daily walks via a touch screen computer located near the front door, calculating speed & distance for that walk, total daily time, etc. Hooks in to a couple of security cameras to track me as I walk past the house on my laps, recognize that it is me, and time stamp my passing (by the camera).

A simple Python script that pulled a whole bunch of data out of PDFs for a research project. It saved the small research team multiple thousands of dollars that they couldn't get a research grant for, and was able to then save the department multiple tens of thousands of dollars each year from that point onward. I got paid a large pizza (toppings of my choice). And made a couple of friends of some librarians.

A home point touch off position script for my CNC.

There are dozens more I'm proud of that I am forgetting. These are the kinds of interesting little projects that take an afternoon or an evening and often have a huge impact on quality-of-life.

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

#47

I have a script listed in package.json for my site. Often I don't really care about commit messages here, not because I don't find them valuable, but because so often its from editing and publishing articles. I don't really want to think of messages all the time so often end up typing random crap. I use this now: import { execSync } from 'child_process'; execSync('git add -A'); const modifiedFiles = execSync('git sta…

Ooo that's nasty... I love it!

Much better than "Changes", "Update" or "WIP".

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

#48
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…

Home Assistant will give you a good path to easily access this data by using Owntracks or GPSLogger.

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

#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.

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

#50
post #25

Earlier quoted context omitted.

This seems really nice! Makes me want to build my own with Gum filters, TBH.

is it this? https://github.com/charmbracelet/gum If so, you just introduced me to an incredible looking project ahah.

Yeah, that's it! Makes cobbling together shell scripts way easier. They have some other projects based around terminal UIs too. Take a look at their site it's gorgeous:

https://charm.sh/

Post reply on HN