Live data from Hacker News

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

news.ycombinator.com

201–210 of 340 posts

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

#202

I got annoyed with unlocking my ebike with an app every day, so I created a car key enclosure with a Bluetooth chip to unlock it. So much work! Creating a custom PCB, writing software for the nRF52 chip, learning about BLE, security levels, GATT. Deep sleep and ultra low power usage. I use it every day and am really happy with it.

Sounds really cool, do you have a write-up of it anywhere?

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

#203
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 could see most classes I wanted to take had plenty of availability except for one which was almost full. That class would make my schedule perfect (no classes before 10am, everything ending before 4PM, good teachers), so I was ready the moment my group got access. I logged into the janky Java applet and saw that my desired class was full. Dismayed, but not giving up, I refreshed the class list to see if someone might drop during the drop-add week. Nope, still full, but there was still time for someone to change their mind and for me to slip in. I was going to need an edge.

Another peculiarity of this system was that it was definitely a weird Java app based on some type of main frame. It must have been around for a decade at least. One of the signs of its age was that you had a limited amount of time per day during which you could be logged into the system, something like 90 minutes a day.

So I did what any good hacker would: I made _really_ good use of that limited time. I wrote an AutoHotkey script which would automatically log in, traverse all the menus and attempt to sign me up for that class. It was much faster than a human, so each run barely put a dent in my logged-in time allotment. As a cherry on top, I wired it up to a python script to push notify me if it succeeded.

After letting it run for two days, some false alarms, and tweaking, I got a delightful "You're registered!" notification on my phone and found that it had successfully gotten me the class I wanted. I'm still chasing that high to this day.

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

#204
One of the simplest piece of code, to help a colleague from a non IT department. Excel VBA hash count to show duplicates. Their management instructed them to use a copy/paste nested formula trick which was exponentially slower. It was 1 second now. Turned her week of dread (thousands of rows) into 1h of simple work. 8 Lines of code, 6 minutes.

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

#205
post #172

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…

Re: Mac — Hammerspoon?

Looks very interesting, thanks! Apple noob here.

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

#206

my favorite is a little command line helper called “o”. it’s a helper for copy and rename commands. If I want to edit a misspelled filename I can just type o mv mispelled.txt and it will make an interactive prompt that looks like: mv mispelled.txt mispelled.txt_ but the last word is editable, so I can use the arrow keys to alter it in place https://github.com/jes5199/o

btw there is a bash feature that you can use for this

touch a_tset_file.txt mv a_t{se,es}t_file.txt

it works for changing file extensions:

touch foo.txt mv foo.{txt,json}

or for adding or removing characters, just leave the other side of the comma empty

touch foo.txt mv foo{,bar}.txt mv foo{bar,}.txt

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

#207
I used to have a script that would turn my desktop into a "whiteboard for temporary files". Every file older than 2 days would get copied to some temporary trash folder, and would then be deleted after 90 days of inactivity. I had no shortcuts on my desktop, only files and downloads. Everything there was meant to be temporary, quick sketches. Was super happy with that workflow and it was all a couple dozen lines of bash/powershell (as I migrated between OSes).

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

#208
post #195

I run a clipboard logger + Window Title Logger in the background. I am able to find stuff from 10 years back. Works across all apps. Want to remember something just copy it. It might not be secure practice. I regularly encrypt the rolled over logs using 7z.

Would you mind sharing which tools you use or share the scripts? That sounds like a fantastic, no brainer way of saving stuff. I'm guessing there's a lot of noise too, like when you're editing code?

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

#209
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?

And also access to those users’ other accounts if they reuse passwords (most people probably do)

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

#210
I wrote a shitty shell + python script to get me music to DJ. It would:

* Load a playlist from spotify (including fetching the API token programatically from bash... shudder) * Search youtube for the song + artist * Download the MP3 of the song from youtube * Set up the directory structure for Rekordbox DJ * I could then manually import the song

When I was too broke to buy music for DJ'ing this satisfied my craving for new music to play.

Post reply on HN