Live data from Hacker News

Ask HN: What are some small scripts you use daily?

news.ycombinator.com

11–20 of 59 posts

Re: Ask HN: What are some small scripts you use daily?

#11
post #10

I have a small perl script I wrote called helpme by default it shows a list of topics. Then if you run it with the topic, it displays the details about the topic. I use it to remember how to do less frequent stuff at my day job.

I was using a blog for this, but I hate maintaining a blog.

I'm going to use this instead!

Re: Ask HN: What are some small scripts you use daily?

#13
I created a Perl script called anyconnector which allows me to jump around between different Cisco Anyconnect VPN's using details stored in KeePass entries.

e.g.

  To connect: anyconnector -c env-name
  Disconnect: anyconnector -d
  Get status: anyconnector -s
It gets used by my team all day, every day.

Re: Ask HN: What are some small scripts you use daily?

#14

I have letters like r and b aliased in my bash profile to check for and run a bash script, if it exists, in each project directory (r = ./run.sh, b = ./build.sh). In each of those scripts, I typically have a one liner depending on what the project requires. A simple build one is: #!/usr/bin/env bash make build And run: #!/usr/bin/env bash docker run foo/bar Or maybe: #!/usr/bin/env bash python manage.py runserver I m…

This is brilliant; I think I'll start doing this.

One slight modification: name the build and run scripts something that you will never expect to be in that repo (maybe like run-xyz.sh where xyz are my initials, 10 random characters, etc.).

Then, the filename can be excluded in a global gitignore file.

Re: Ask HN: What are some small scripts you use daily?

#17
I wind up making lots of interim files when importing/exporting/munging/analyzing data–to help keep track of these things (CSVs, scripts and miscellany that I may or may not want to revisit in the future) I have a function I call today to auto-create daily scratch directories:

    TODAY_DIR="$HOME/today/"
    DATE_DIR=$(date +'%Y-%m-%d')
    
    if [ ! -d  $TODAY_DIR$DATE_DIR ];
    then
        mkdir -p $TODAY_DIR$DATE_DIR
    fi;
    
    echo $TODAY_DIR$DATE_DIR
So you can do stuff like this with less thinking/typing:

    cp somefile.csv $(today)
I've been using this for a few years and continually find it handy, both at the command line and in keeping files clustered when I want to dig something up later. It is slightly less helpful if you regularly work past midnight, though!

Re: Ask HN: What are some small scripts you use daily?

#18
post #15

I run an AHK script with a little over 2000 abbreviations (e.g. typing 'abbn' expands to 'abbreviation'). It helps me type 100+ WPM without too much strain.

That's a cool idea. Do you have your file posted anywhere? If not I may cook something up on my own, I'm curious to try it out.

Re: Ask HN: What are some small scripts you use daily?

#19

I have letters like r and b aliased in my bash profile to check for and run a bash script, if it exists, in each project directory (r = ./run.sh, b = ./build.sh). In each of those scripts, I typically have a one liner depending on what the project requires. A simple build one is: #!/usr/bin/env bash make build And run: #!/usr/bin/env bash docker run foo/bar Or maybe: #!/usr/bin/env bash python manage.py runserver I m…

This is brilliant; I think I'll start doing this. One slight modification: name the build and run scripts something that you will never expect to be in that repo (maybe like run-xyz.sh where xyz are my initials, 10 random characters, etc.). Then, the filename can be excluded in a global gitignore file.

Really to do this right you should make it function like direnv and create a whitelist of scripts you trust (bonus points for including hashes of the script). On first run it'll ask you to review and trust the script, and then just work on subsequent runs.

I'd love to have something like that as a utility

Re: Ask HN: What are some small scripts you use daily?

#20
Not exactly a script, but I work at home and sometimes I need to drown out the kids (or the wife!). I have this in my .bashrc:

alias whitenoise='play -q -c 2 -n synth brownnoise band -n 1600 1500 tremolo .1 30'

It plays some fuzzy whitenoise, which drowns them out and lets me keep focused (music is often distracting to me).

Post reply on HN