Saturday, March 12, 2016

Kill an ssh connection from the server side

So you don't like Bob today or maybe you want to test a failed connection.. Whatever your reason you need to kill the ssh connections for his user on your server.

Friday, March 11, 2016

Reverse SSH Forward with special user

We will create a user on our machine that the remote machine can connect as and initiate a reverse port forward. For this example, we'll allow the remote machine to connect with the user name "ssh-limited" and forward port 62222 back to themselves.

Tuesday, January 26, 2016

Make better bash scripts for yourself (and others)

When you write a bash script, there's a few things you can do to make your life (and anyone else who uses it) a lot better. Here's a few of the things that I (try) to do when I write scripts to make it easier to use and less error prone.

Sunday, January 17, 2016

Ditch capslock for escape in xwindows

Run this and your capslock will be changed to the escape key for the current session:
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'
Taken from this post on the vim wiki

Tuesday, March 17, 2015

Print the current tag OR commit in git

Here's the command to print the tag name of the current commit, or just the commit if there is no tag. It's useful for a script that builds or exports something and you always want to have some version reference..
# prints tag name or short revision
git name-rev --tags --name-only --no-undefined --always $(git rev-parse HEAD)

Monday, March 16, 2015

Multiple test programs, one makefile

I've been writing tests using glib's test framework. Some of them got quite large, so I split them up into multiple files with their own main()'s. Here's my makefile to build and test up to 10 test binaries in one go:

Friday, November 14, 2014

git lsd – For when you don't want to use gitk --all

If all you want is a quick look at your commit history with all the branches nicely laid out with their merges shown with pretty colored lines... Try this instead of one of the gui viewers:
git log --graph --boundary '--format=%C(yellow)%h%Creset%C(bold cyan)%d%Creset %s %C(dim normal)(%ar)%Creset' --all
This will output something like this (depending on your terminal color settings):
* 4b22a90 (HEAD, master) erases chip before programming (2 days ago)
*   ee107af Merge branch 'sysclk' (2 days ago)
|\  
| * e9df6f6 removes clk config to use defaults (2 days ago)
| * 66a1ea3 fixes clkout pin timing (2 days ago)
| * bcdda54 enables PLL @ 16MHz (internal 2MHz x 8) (2 days ago)
| * cd22bab enables the 32KHz rc for system clock (2 days ago)
| * cee8efd enables the internal 32MHz rc for sysclk (2 days ago)
| * aa10b4d enables 2MHz internal rc osc for sysclk (2 days ago)
| * 80cbade re-defines F_CPU (2 days ago)
|/  
*   0644c9d Merge branch 'diagnostics' (3 days ago)
|\  
| * b9e155d adds SYSCLK/10000 on pin A0 (3 days ago)
| * 57807ab adds blinky led (3 days ago)
|/  
* 5cfc996 basic skeleton (3 days ago)
Of course you can mess with the format and colors, but this is how I like it. Once you have it set the way you like it, alias it for later use!
git config --global alias.lsd "log --graph --boundary '--format=%C(yellow)%h%Creset%C(bold cyan)%d%Creset %s %C(dim normal)(%ar)%Creset' --all"
Now you can just type git lsd and have a quick overview of your commits.