Ask HN: Small scripts, hacks and automations you are happy with?
|
You summed up what dragged me from “Sure I’ll learn to program a notepad or todo app so I can learn, but I won’t” to “I can do anything if I think about what I want first, then how to get it!”
|
|
This is more in the “hack” category, but here is a solution for bookmarking directories[1] that I am quite fond of:
Then:
It can list bookmarks, auto-complete, jump to sub-directories within bookmarks, all without introducing any new commands – just `cd`. [1]: http://karolis.koncevicius.lt/posts/fast_navigation_in_the_c… |
|
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 noticed my submit and determined to generalize the thought; he created Greasemonkey, which was a single browser extension that would mixture site-specific JS customizations. Within the years since, this concept of “person scripts” has additional developed, and I believe some browsers even assist the idea natively. |
|
Ah, that reminds me of how I modified sites using https://www.proxomitron.info/ , it is a Home windows program that may begin a neighborhood HTTP proxy and you’ll configure browsers to make use of this proxy, and it might block adverts. This labored very well earlier than the net turned HTTPS-crazy.
The best way it might block adverts is to research the recordsdata it was fetching for the browser and modifying discovered key phrases, for a crude instance all IMG tags with SRC containing the string advert.* would get replaced by grey pictures. I additionally keep in mind utilizing it to “repair” a redesign of a website. |
|
I made a script that checks CPU load of a remote machine and modulates a looping fan noise on my laptop to give that authentic heavy load experience when running remote builds 😀
|
|
in 1995, I thought that it would be good if advertisements could be served from hubs to large numbers of web sites. That would mean that advertisers wouldn’t have to hire ad space salespeople, which was far too expensive for most sites. But then there was the problem of how to decide which ads to show to which visitors to those sites. To do that, it seemed like it would be a good idea to base that decision on the sites people tend to visit, which seemed like it would maximize the probability that they’d actually be interested in the ads.
I looked for a way to do that. Browser cookies seemed like a possibility, until I learned that one site couldn’t read another site’s cookies. When I asked people if there was any workaround I was told that there wasn’t. But then I figured out how to use them to track people anyway. That hack is my answer to the OP. I filed a patent in 1995 that showed how to do it. The patent tied that technique to my specific mathematical technique for selecting the ads the user would most likely be interested in, so it could not be used to restrict other people from using cookies that way as long as they didn’t also use my specific math. The patent also contained a lot of features about how to give users complete control over their information and that protected their privacy. (That part didn’t get implemented much!) I eventually sold the patent to DoubleClick, and DoubleClick was eventually sold to Google for an amount I recall to be in excess of $1 billion. By then I’d seen a marketing site recommend that Google buy DoubleClick, with my patent listed as one of the reasons they should. DoubleClick had their own patent describing the tracking cookie, but their priority date was a couple months later than mine. And it didn’t have the privacy features mine did, or the same degree of tech about how to actually select ads. In defending against a patent troll in 2021, Google and Twitter together filed a joint brief calling the tracking cookie “Robinson’s Cookie”. My name is Gary Robinson. (In case anyone is curious there’s more info at https://www.garyrobinson.net/2021/07/did-i-invent-browser-co….) |
|
I’m not sure I understand. You submitted one year of late parcel requests in one go (presumably with the script), and then you had to manually select to ‘get money back’ or ‘prepaid satchel’?
|
|
One of my servers is an older Supermicro X11, and I’ve flashed its BIOS to be able to boot from an NVMe drive in a PCIe adapter. While this normally works fine (I had another identical board it worked flawlessly on), this particular one for some reason doesn’t always see the drive. Since the server is off most of the time, but wakes up daily to ingest ZFS snapshots from the NAS, the ability to turn on and off reliably is important.
I didn’t feel like doing that deep of a dive to determine why it sometimes sees the NVMe drive, so instead I wrote a script [0] that uses IPMI to power cycle it until it can get an ssh connection. Originally I was sending a magic packet, but realized that was only a one-shot, so I switched to calling the IPMI executable via subprocess. No idea why I left the other stuff in there. Anyway, this has reliably worked for well over a year at this point, dutifully restarting the server until it comes up. Some days it takes 1 attempt, some days it takes 5, but it always comes up. [0]: https://gist.github.com/stephanGarland/93c02385e344d8b338aab… |
|
Here are two scripts I now can’t imagine living without:
[1] is the reason I no longer need a taskbar/dock. It’s a sort of framework you can use to build a muscle-memory-friendly window switcher in Linux, similar to pinning windows to the taskbar in Windows — map Win+1 to terminal, Win+2 to vs code, etc. If the app isn’t running then it launches it; else, switch to it. (I wrote this because couldn’t find a consistent and foolproof way to do this in Linux, and if you switch window managers you have to start from scratch)
(For better ergonomics, if the keyboard I’m using doesn’t have a win/meta key on the right, I rebind right control to win/meta) [2] is a timestamped log file for you, a human. Set up a cron job to launch it every hour to note what you were working on, or append lines from the terminal whenever you’re chewing on a hard problem. Then, use the data to build an accurate picture of what you worked on during the last week, or grep last quarter’s log to find out why you decided to use library A instead of library B. I have used this since 2018 and frequently go back to gain insight into the reasons for old decisions.1: https://gist.github.com/cbd32/cbec9a32b32bd9e93b0d2696c71b5f… 2: https://gist.github.com/cbd32/f1ee2967ec0181b934639c30f4e68f… |
|
I used to run a site for tutorial screencasts. My “video workflow” involved recording, adding an intro and outro, transcoding to multiple formats and finally uploading the videos to the Internet Archive.
I automated everything except the actual recording using a Makefile that’s over here https://gist.github.com/nibrahim/2466292. I believe I added some sox instructions to scrub up audio too in a later model however misplaced the file. One other one I did was a small script to create ruling sheets for calligraphy. It is a tedious course of by hand and having a script create a PDF based mostly on nib width is a good time saver https://github.com/nibrahim/Calligraphic-Rulings |
|
Right now I’m just using the PowerShell part to move the cursor up and to the left and delete it. You can still see the PK$#@($!!!1 for a nanosecond, but that just gives it character in my opinion.
|
|
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 naked minimal of:
my sleep schedule was f-ed as much as say the least. these scripts helped me keep my attendance 🙂 |
|
Maybe this already exists somewhere and I don’t know about it …
Anyway, when working on feature branches I wanted a quick way to switch to master, pull, switch back and finally rebase. So I made a little script (https://gist.github.com/lelanthran/6c9bd1125f89e7621364878d1…) that pushes the present department title onto a stack earlier than switching to a brand new department, and permits me to modify again to the topmost department on the stack.
I take advantage of this now very regularly; after I want to modify to branches I take advantage of `xgit <department>`, as a result of then I can change again simply utilizing `xgit pop`. |
|
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?
|
|
I’m not sure this qualifies as small since I’ve been working on it since last summer and has grown to over a few thousand lines of code, but it is definitely automation and something I’m quite proud of.
https://github.com/TorbFoundry/torb “Torb is a software for shortly organising greatest apply growth infrastructure on Kubernetes together with growth stacks which have fairly sane defaults. As an alternative of taking a pair hours to get a mission began after which every week to get your infrastructure right, do all of that in a pair minutes.” My ambition is to fill the house of Heroku and proper now I can get one thing like a React App and a Flask API or a full Elixir Phoenix mission began and working in lower than 5 minutes on Kube, with a full infrastructure as code surroundings, reproducibility and extra. It is undoubtedly not assembly my ambition but, however it’s undoubtedly in a spot the place I believe individuals can use it and get a whole lot of worth from it. I have been testing it with some buddies over a number of months and have been canine fooding it on my different tasks. I simply completed including a file system watcher to it over the previous couple of days so you possibly can iterate and adjustments will shortly be mirrored onto your cluster. Subsequent I’ll extract this out right into a library from the CLI software, construct an API over it and supply a hosted answer and an internet app. I have been that means to share it with individuals however I have been heads down constructing for perhaps just a little longer than I ought to have been. |
|
I modified the multitouch code for Karabiner Elements to support a palm activated action that can be used to add another layer of keys to my MacBook’s built in keyboard
|
|
When I worked at IBM circa ~2006 you’d get a written warning called a clean desk violation if you left your workstation unlocked.
I wrote a little daemon that’d l2ping my Nokia brick phone; if it didn’t get a response for 30 seconds it’d invoke xscreensaver. Saved me a lot of paperwork. I currently work at a Call of Duty studio. My favorite hacks ( not super high tech, but the ones that had the most impact for the least code, and the ones I feel I can talk about.. ): * Put together a little box that polls varied knobs on a USB midi device to mangle the traffic going across its two interfaces. Allows for real time latency / jitter / packet loss testing https://twitter.com/ultrahax/status/1200902654882242562 * Studio LAN sport browser did not work throughout subnet boundaries ( studio is a few class B’s ). Wrote just a little daemon that’d take sport discovery packets from one subnet, mangle the src addr, and ship it on its merry method. Everybody can see everybody’s video games, blissful producers. |
|
I’ve done three worth mentioning.
One is GenFortune: https://github.com/EternityForest/GenFortune One is a candle flicker simulation algorithm. I didn’t make this demo, I wrote the unique for the PIC, they tailored a model of it for JS: http://blackdice.github.io/Candle/ On the time low-cost LED candles weren’t superb, however it appears many are loads higher now. I used a mannequin assuming that the flickering was wind pushed, that the flame all the time needs to rise in the direction of it is most at a sure price, however that relying on the present wind velocity at any time it could possibly get randomly “toppled” to a decrease worth, whereas then wind settles right down to a baseline however can randomly bounce up in a gust to the next velocity. In fact, now we’ve got multicolor multipixel flame algorithms that do method higher, however that is fairly good on a single pixel gentle. I nonetheless use principally the identical algorithm for DMX flame results in Python, however I apply then impact much less to the crimson channel so it will get redder when the sunshine goes down for just a little added selection. The opposite is that this RNG. It doesn’t actually have a full interval for it is 32 bits of state however it’s very quick on PIC10 sort chips. I am unable to consider any cause I might use it. I used to be like 15. However of every part I’ve ever made, this will get probably the most consideration, and I am not fully positive why. It does not even move all statistical exams. I might in all probability use it over LCG although. “` |
|
I write a ton of CSS and could not find a command line stylesheet checker. I did find the NuHTML checker from W3C, which also checks the file’s CSS: https://github.com/validator/validator/releases/tag/20.6.30
AFAIK it doesn’t have an choice to verify a standalone CSS file. I wrote a script to insert a CSS file right into a dummy one-line HTML file, in order that I can move a CSS file to the script, and when errors are generated from the CSS, they’re given utilizing the proper line quantity. I’ve written many extra complicated and maybe extra fascinating Scripps, however that is the one I’m, by far probably the most happy with. |
|
Script which parses my calendar and creates tasks in my GTD-like system in Todoist – so all my tasks are in one place and I should not jump between apps to get full picture of a day
|
|
I wrote a quick integration to the GPT-3 API to Emacs [0]. Although it’s a very simple implementation, it’s made many small things I would’ve previously done manually much quicker (ie – one-off calls to convert a hyperlink in X format to markdown; abbreviate first names of author lists of papers; convert some “text message speak” messages into a paragraph).
[0] https://github.com/samrawal/gpt-emacs-macro
|
|
Back around 2013 I needed trello for a project.. I couldn’t seem to get the UI right and decided to use gmail as the front end. It worked perfectly, and was easy for everyone to understand.
|
|
I made a fzf-powered tool that makes cd’ing into deep directory trees quite fast and easy. It’s somewhat reminiscent of ranger/nnn/broot, but in my mind, it eliminates the mental context switch of entering/exiting those tools.
Some gifs (with speed comparisons) here: https://github.com/dp12/probe |
|
I wrote SimplifyRecipe.com as a means of getting rid of the extra fluff of recipe websites, and it runs via a shortcut in iOS. Overall it works remarkably well!
|
|
Bunch of ansible that runs against proxmox. Makes setting up a quick VM or LXC a 30 second task
About same as GUI interface but with IAC advantages |
|
This little script in my i3 keybindings opens a new terminal with the same working directory as the currently focused terminal, pretty useful for my workflow:
https://github.com/pkos98/Dotfiles/blob/master/config/i3/con… I in all probability scratched some components collectively from the web a few years in the past. |
|
I made a small script to get weekly recipes with certain macronutrient composition from chatgpt, then i linked the ingredient list with my supermarket’s api so every monday I get delivered everything
|
|
I usually check weather on forecast.gov website, with these bookmarked urls:
https://forecast.weather.gov/MapClick.php?lat=40.7983&lon=-1… The problem I had with these have been that, these pages are all the time in desktop mode even on cellular. So i made a one web page static web site which takes & shops these urls in native storage, & fetches the one I click on upon. On subsequent pageload, it remebers the final loaded metropolis & it hundreds it once more. All of the web page is in mobile-first view mode in css. https://spa.bydav.in/weather/index.html You would possibly see nothing as it’s good to preload/populate the native storage with both manually copied urls or just paste this json.
|
|
I’m nursing a small fleet of CentOS 7 servers while we finish up migrations and upgrades this year. Most of these servers need certificates, but the built-in certbot package is really brittle (if not actually broken) depending on what plugins you might need to use. So I wrote a short wrapper script that handles everything for me:
https://gist.github.com/xenophonf/893b323b99644290fad420a54c… It retains the customized certbot set up up to date, and if something goes improper—and provided that one thing goes improper—I am going to get an electronic mail because of persistent. Identical goes for the set up command outputs when working the wrapper/certbot interactively. You may solely see error messages when one thing breaks. In any other case, it seems precisely like certbot was invoked straight, simply with a brief delay whereas the script does the set up/replace within the background. |