I have a shell alias that creates a temp directory labeled with the current time stamp and suffixed tag then changes to it. Makes it very quick get a new scratch area for shell fu.
Plus all the scratch dirs are in one place so cleanup is a breeze to free up space.
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 might also add (source) environment variable settings, etc. Sort of like my own personal decentralized makefile.
Then I add each script to my .git/info/exclude for each project. It saves so much time switching between projects to not have to remember any particular one's build or run commands.
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.
Yeah, good points. Maybe putting the script(s) inside a .whatever directory inside the project root like some other dev tools do is worth consideration. What do you think?
There's a gui app on top of the script, so not sure if it counts, but I find SelfControl (selfcontrolapp.com) indispensible for staying focused each day.
I've installed it recently but some sites are hard. For example, I'd block YouTube in the blink of an eye, but what if I really need to look up a video tutorial or something in the middle of a work session?
I start projects very often and find myself using my scaffolding [tool](https://github.com/vutran/zel) for minimal dotfiles (which are downloaded from a repo) very often.
Also use it a lot for syncing dotfiles in my user directory between my work and home computers.
This Bash function rebases and pushes all my feature branches on the upstream "develop" branch:
rebase-all ()
{
old=`git rev-parse --abbrev-ref HEAD`;
stashed=`git stash`;
for b in $(git branch --format '%(authorname) %(refname:short)' | sed -ne "s/^`git config --get user.name` //p" | grep -- -);
do
git checkout $b && git rebase origin/develop && git push --force || ( git rebase --abort && echo Could not rebase $b );
echo;
done;
git checkout $old;
if [ "$stashed" != "No local changes to save" ]; then
git stash pop;
fi
}
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 wrote a Docker helper script, which resets it to a baseline state when I need to clear out cruft post-restart. I call it harpoon, so I can harpoon the whale when I go to restart my dev machine.
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
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.
AHK has been working great for me over the years. My addresses, snippets of emails, expansions are all stored in an ahk file. I use various email addresses for different sites; so a@a would become aj(at)ajonit(dot)com or a@l would become admin(at)learnqtp(dot)com. The possibilities are endless.
Few year's back I created a video for my blog readers and published an AHK template. You may download it here http://www.learnqtp.com/get-productive-with-automation-autoh...
I typically have a script that prints out my local IP, instead of if/ipconfig or some OS UI. If I'm hosting a static page with an HTML5 game, it's then pretty easy to access it on another computer or my phone.
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!
Classify digital photographs that I need to review by its content. Import/export data from/to a DB, analyze it statistically and show graphically the info. Pretty standard.
# Helper function for running command in each subdirectory under current one.
function each {
if [ -z $1 ]; then
: # If no command is given, then this is a no-op.
else
find . -maxdepth 1 -mindepth 1 -not -path '*/\.*' -type d -exec sh -c "(echo {} && cd {} && $* && echo)" \;
fi
}
zsh functions:
# Helper function for navigating tmux sessions
export WORKSPACE_ROOT=$HOME/workspace
ws() {
if [ -z $1 ]; then
if [ -z $TMUX ]; then
tmux attach-session
else
cd $WORKSPACE_ROOT
fi
elif [[ $1 == 'ls' ]]; then
tmux list-sessions
else
tmux attach -t $1 || cd $WORKSPACE_ROOT/$1/src; tmux new-session -s $1
fi
}
# Helper function for running command in each subdirectory under current one.
each() {
if [ -z $1 ]; then
# If no command is given, just exit
else
find . -maxdepth 1 -mindepth 1 -not -path '*/\.*' -type d -exec sh -c "(echo {} && cd {} && $* && echo)" \;
fi
}
This is awk which emits the stream of unique things, as they are seen. it doesn't require sorted input. It runs at the cost of building the obvious hash in memory so can drive you to swap over large inputs, but its portable, does not require post-install s/w typically not on small systems and it delivers outcomes fast.
I use it all the time when I have some UNIX pipe emitting things and I want to "see" the uniques before I do sort | uniq -c type things.
I'm in sales for a surveying/feedback SaaS co. Before demos I brand the survey/account with the prospect's company's colors & logo. During the demo I send custom branded, inline email surveys to a test gmail account to help my prospect understand the survey respondent POV. I also have to delete that test-survey email every hour so that the next prospect I demo isn't privy to who is exploring us. I often have to do 4-8 demos a day so as you can imagine that got old fast.
I wipe the inbox for my test gmail account every hour at the :45 minute mark using a ruby script. I don't automate the sending because it's part of the education of the prospect.
I call this blingle. I call it after any long running operation that I want to be notified of. It pops a desktop notification and sends a push message to my phone.
I have a deployment script that is part of my one-click deployment to the customer's webserver. It's kind of a legacy to having really crap interwebs though, as my upload used to be in the 700-900 kbit/sec range, so it strips out anything from the deploy package that isn't absolutely essential to create sort of a delta of changes.
Makes deployments blistering fast now that I've got 30 Megabit/sec up though... :)
I wrote a docker-wrapped script to create keys and certificates for use with HTTPS for development. These are configured with algorithms which modern browsers won't complain about. It also allows alternate domains.
58 comments
[ 3.8 ms ] story [ 115 ms ] threadPlus all the scratch dirs are in one place so cleanup is a breeze to free up space.
In each of those scripts, I typically have a one liner depending on what the project requires. A simple build one is:
And run: Or maybe: I might also add (source) environment variable settings, etc. Sort of like my own personal decentralized makefile.Then I add each script to my .git/info/exclude for each project. It saves so much time switching between projects to not have to remember any particular one's build or run commands.
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.
I'd love to have something like that as a utility
Also use it a lot for syncing dotfiles in my user directory between my work and home computers.
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'm going to use this instead!
I have a topics hash/dictionary.
If the helpme command is run without a topic argument, it prints out all the topic keys to the dictionary one per line.
If it is run with a topic argument, it just prints out the value for that topic.
e.g.
It gets used by my team all day, every day.Here's a copy of the script itself: https://gist.github.com/kjbweb/38508fd92669101ec1fca4bea62bc...
It works on Mac's too, so I've been told.
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).
ahk scripts:
- Easy Window Dragging (KDE style)
- Rocker (click left-right mouse button to go forward in explorer etc, right-left to go back)
- hidedesk (hides desktop icons unless I click on the desktop, sadly a bit buggy)
- some custom script to unify hotkeys for the brightness of my external dell monitor and my laptop screen.
browser fixes:
- some drag to scroll js for greasmonkey
- shortcut for bookmarking to pocket with keyboard only (with tags)
I use it all the time when I have some UNIX pipe emitting things and I want to "see" the uniques before I do sort | uniq -c type things.
#!/bin/sh awk '{ if (!h[$0]) { print $0; h[$0]=1 } }'
So, without the scrubbing:
tail -f somefile | perl -ne '!$SEEN{$_}++ and print'
Scrubbing off leading timestamps:
tail -f somefile | perl -ne 's/^[0-9:]//;!$SEEN{$_}++ and print'
I wipe the inbox for my test gmail account every hour at the :45 minute mark using a ruby script. I don't automate the sending because it's part of the education of the prospect.
eg: make deploy; blingle
#!/bin/bash
MSG=${@:-"Job complete"}
notify-send "$MSG"
curl -s \
rsync -rlptvDC --progress --rsh="ssh -l username" * myserver.com
Makes deployments blistering fast now that I've got 30 Megabit/sec up though... :)
It’s transformed the office. It’s the little things ya know.
https://hub.docker.com/r/qubyte/cert-creator/