Wiki is a command line tool to fetch summaries from any Mediawiki wiki. By default, it searches the English language version of Wikipedia.

To use wiki, you’ll need a working golang install

You can install wiki with go get, which will download and compile the go code.

go get

Once we have it installed, we can take a look at the help page for the tool. There’s lots of options available, allowing you to change language, show short summaries only and ignore HTTPS verification.

wiki --help
wiki is a tool used to fetch excerpts from wikipedia
Usage: wiki [options...] query

  -h=false: Print help information and exit.
  -l="en": The language to use
  -n=false: If the output should not be colorized
  -no-check-certificate=false: Skip verification of certificates
  -s=false: If simple output should be used
  -short=false: If short output should be used
  -u="": The api url
  -version=false: Print version information and exit.
[ Read More ]

Rename a git branch

I can't count the number of times that I've created a new feature branch only to notice that I've managed to add a typo to the branch name. Usually, it looks something like this:

$ git checkout -b feature/addign-login

Usually in this situation I'd create a new branch with the correct name from my current (incorrectly named) branch and delete the old one:

$ git checkout -b feature/adding-login

$ git branch -D feature/addign-login

It turns out that this happens enough for git to have an alias for it - git branch -m.

Instead of creating a new branch and deleting the old one, you can do the following:

$ git branch -m feature/adding-login

This will rename the branch that you're on in place.

[ Read More ]

Special cron entires

There are some special entries that can be used when creating a crontab entry (crontab -e), most of which are just shortcuts for the standard crontab entries that we all know and love.

You can use them in your crontab just like you would a normal entry:

# m h dom mon dow  command

# Say hello each time the machine boots up
@reboot echo 'Hello world. I just booted up'

# Say Happy new year, using both forms of entry
@yearly echo 'Happy new year'
0 0 1 1 * echo 'Happy new year from me too'

The @reboot entry could be useful for keeping track of when a machine is rebooted. Just add the crontab and each time the machine restarts you'll get an email with any output from the crontab (in this case, "Hello world. I just booted up")

Possible entries

There are nine possible aliases, some of which are just aliases for each other (such as @yearly and @annually)

Entry Description Equivalent entry
@reboot Run once, at startup None
@yearly Run once a year 0 0 1 1 *
@annually Same as @yearly 0 0 1 1 *
@monthly Run once a month 0 0 1 * *
@weekly Run once a week 0 0 * * 0
@daily Run once a day 0 0 * * *
@midnight Same as @daily 0 0 * * *
@hourly Run once an hour 0 * * * *

I'm not sure I'd recommend using any of these (except maybe @reboot) as the standard syntax is well known by anyone that should be editing a crontab, but it's interesting to know that there are aliases in there for common time periods.

(via mkaz (now offline))

[ Read More ]

git and diff-highlight

diff-highlight is a contrib script that ships with git. It's a better way to visualise a diff when the changes are small words, not entire lines/paragraphs. It's hard to explain, so here's an example (diff-highlight is the script):

[ Read More ]

git push

A nice quick tip to get the ball rolling again.

If you've ever deleted a branch on a remote system only to have it recreated when you git push, this one's for you. It will make git only push the current branch by default; other branches are not pushed to the server. This helps to ensure for example that deleted branches do not get re-pushed accidentally.

git config --global push.default current`

If you do want to push all branches you've got locally, you can use the --all flag like so:

git push --all
[ Read More ]