Live data from Hacker News

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

news.ycombinator.com

81–90 of 340 posts

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

#81
post #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, ````…

Here's some Gists that show a simple example of each concept:

- Key chords: https://gist.github.com/CFiggers/ccb6bc911ee87f423f558368128...

- Right-click menus: https://gist.github.com/CFiggers/96bc37ca468909c9ec83252144c...

Let me know if you have questions. Enjoy!

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

#82
I made a CLI tool for quickly starting new branches with draft PRs, asking for reviews, etc: https://github.com/dbalatero/work-cli

Made a bunch of Hammerspoon plugins for macOS:

- https://github.com/dbalatero/SkyRocket.spoon - mod+click to resize/drag windows

- https://github.com/dbalatero/VimMode.spoon - Vim mode everywhere

- https://github.com/dbalatero/HyperKey.spoon - pop-up menu for when you forget your keybinds (like neovim's which-key or spacemacs)

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

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

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

#85
My first non-trivial bash script was a CLI frontend for an MPV daemon that used regex to manipulate the playlist. It also had all the basic controls you'd expect from a music player. Kind of like a CLI quod-libet. That thing was awesome.

Sadly it was lost in a when the HDD crashed and I never got around to remaking it because reasons.

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

#86
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 number of libraries on Github that appear to interact with "Find My" somehow -- reasonably sure you don't have to pay for that.

You might also consider something like https://www.tillerhq.com (or even just integrate with Plaid directly).

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

#89
This is a set of alias/functions that I use to setup tmux and my ssh connections, I'm always in tmux be it locally or in ssh, it survive session disconnections.

  # full terminal page of \n
  pgdown () {
    printf '\n%.0s' $(eval echo {1..$(( $(tput lines) - 1 ))})
  }
  
  # clear teminal and TMUX history and get to the bottom line
  c () {
    echo -en "\ec"; pgdown
    if [[ -n $TMUX_PANE ]]; then
      tmux clear-history -t $TMUX_PANE
    fi
  }
  
  # force MOTD display in a new ssh session
  alias sshmotd='ssh -o SetEnv=SSH_MOTD=1'
  
  if command -v tmux 1> /dev/null; then
    # open a new tmux session named default or attach to it
    tmuxa () {
      systemd-run -q --scope --user tmux new-session -A -s default "$@"
      exit
    }
    
    # open a new tmux session named ssh_tmux or attach to it
    alias tmuxs='tmux new-session -A -s ssh_tmux && exit'
    
    # run tmux if TMUX variable is null locally or in an ssh session
    if [[ "${TERM-}" != tmux* ]] && [[ -z "${TMUX}" ]] && [[ -z "${SSH_CONNECTION}" ]]; then
      tmuxa
    elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]]; then
      tmuxs
    fi
  fi
  
  # run MOTD at login only in an ssh session
  if [[ -n "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && [[ "${SSH_MOTD-}" == 1 ]] && [[ -f "/etc/update-motd.d/00-motdfetch" ]]; then
    motd
  else
    pgdown
  fi
Post reply on HN