RSS Feed Subscribe to RSS Feed

 

GPG

I use GPG (Gnu Privacy Guard) for email encryption. GPG is an OpenPGP implementation. If you would like to send me an encrypted email, my public key can be found at https://keybase.io/shaunabram. I also have some keybase invites available, if you are interested.

(more…)

Tags: , , ,

Git rebase

Git rebase can be intimidating for newcomers, but it’s a powerful and versatile tool when you understand it.

Like git merge, rebase allows you to bring the changes from one branch into another. However instead of all those noisy commit merges you get with the merge command, rebase allows a tidier, linear commit history.

Technically, rebasing is the process of moving a branch to a new base commit, but if that isn’t clear, hopefully the diagrams and explanations below will illuminate.

Before we even start looking at rebase though, we will start with a quick review of merging.

(more…)

Tags: , ,

alternative to tail -f that allows scrolling: less +F

You can use less +F to start less in its “forward forever” mode. In this mode, less will behave like tail -f, ignoring the ends of files and providing a steady stream of text.

When you want to scroll, press Ctrl-c. To re-enter forward forever mode, press F.

From http://unix.stackexchange.com/questions/81628/is-there-an-alternative-to-tail-f-that-has-convenient-scrolling

Tags: , , ,

sed

sed (stream editor) is an simple but incredibly versatile command line tool that parses and transforms text. It is line-oriented in that it reads the text line by line, transforms it, and outputs the result.

For example, this sed command would replace all occurrences of the text “white” with “black”:

sed s/white/black/g

sed reads text on a line by line basis and performs an operation on it, usually extracting or replacing text snippets. In this case, the s prefix means substitute, and the g suffix means global. Other example usages include:

(more…)

Tags: , , ,

find

“find” is a unix command-line tool for locating files. The results can be displayed, passed to another command (e.g. grep, ls etc, see more below), or the find command has its own limited set of actions that can be performed too, such as delete.

Find allows you to specify all manner of search criteria such as name, location, size, permissions, modify date etc. Using regex expressions with those criteria makes it more flexible still.

See the full find manual here.

(more…)

Tags: , , , ,

awk

I think of awk as a tool for searching, manipulating and reporting on text files, but it is in fact an entire programming language. Its basic function is to search files for lines that contain certain patterns, and perform specified actions on that line.

The name awk comes simply from the initials of its designers Aho, Weinberger and Kernighan.

The basic format of an awk command is:

awk pattern { action } file

Every line in ‘file’ matching the ‘pattern’ will have the ‘action’ performed.  Either the pattern or action are optional, but not both.
No pattern means every line is actioned.
No action defaults to print.

(more…)

Tags: , , , ,

grep

“grep” is a unix command line tool to search a file (or files) for lines containing a match to the given pattern (often a regular expression). Its name comes from the ed command g/re/p for globally search a regular expression and print (1). See the grep manual.

The basic syntax is:

grep [option(s)] pattern [file(s)]

Options can be omitted and ‘file’ will default to standard input if omitted.

(more…)

Tags: , , ,

AssertJ > Fest > Hamcrest

I have previously blogged about Hamcrest, and using its assertThat methods in preference to JUnit’s Assert.

However, I quickly after discovered FEST Assertions, and happily switched to it. It provides the same improved test readability and failure messages as Hamcrest, but has the extra benefit of enabling IDE auto completion, rather than having to search through package and class docs to find the right matcher.

Unfortunately, Fest seems to not longer be actively developed. The last stable release of the 1.x branch, 1.4, was released way back in 2011, and the new 2.x branch never made it to a stable release and hasn’t had a commit since June 2013.

Enter AssertJ

(more…)

Tags: , , , ,

Web frameworks

There is no right answer to the question of what is the best Java web framework. Still I end up asking it to myself every time a new project crops up.  I did a post on a related talk I saw at JavaOne last year, which provoked a lot of debate and some really interesting responses. More recently, this report from Zero Turnaround is useful and this comparison from Matt Raible is also well written.

I have also been swayed in the past by the Thoughtworks technology radar in which component based frameworks (which, I think, in the Java world includes JSF, Wicket and Tapestry) get a thumbs down e.g. see the May 2013 radar.  GWT has also in the past (see July 2011 radar) been singled out as something to avoid.  Presumably Vaadin falls in to the same ‘hold’ category.  Full disclosure, I’ve had limited exposure to these types of frameworks personally though.

My own preference remains Spring MVC. It is relatively easy to setup (especially with Spring Boot), provides decent testing support, and obviously integrates well with the rest of the Spring ecosystem.  I am admittedly biased due to already knowing Spring core, but so be it.

My recent, albeit limited, experience with Struts2 is that I have been fairly pleasantly surprised.  It wasn’t as bad I was expecting! The Action classes, which are instantiated for each request, and hence threadsafe, are fairly easy to use and test.  I am not so fond of the xml mappings and the variable passing that gets done there though.  It seems kind of clunky, although there may be a better way I am not aware off.

Still, I am not likely to start using Struts by choice on my own projects anytime soon. Spring MVC remains my go-to web framework.

 

 

 

Tags: , , ,

How to add a project to GitHub

Although the GitHub docs contains good info on how to add an existing GitHub project to your local machine, how to add an existing (unversioned) project from your local machine to GitHub was a little less clear to me. Here are the steps I use.

(more…)

Tags: , , , ,