Wednesday, 26 February 2014

How to change extension of multiple files in Linux?

When files are in same folder:

rename 's/.abc$/.edefg/' *.abc

Recursively rename files:

# Bash
# Also requires GNU or BSD find(1)
# Recursively change all *.foo files to *.bar

find . -type f -name '*.foo' -print0 | while IFS= read -r -d '' f; do
mv -- "$f" "${}.bar"


Also see:

Wednesday, 12 February 2014

@RetryOnFailure annotation using Aspect from JCABI library

Use this annotation to make repeated calls on failure for an idempotent method

Validate user-inputted URLs using Google Safe Browsing API

Use this API to get a database of URLs from Google and verify them
locally. They also have an earlier version of the API but you need to
make a remote call. This is better as the client is the only one that
knows about the URLs it is verifying.

Thursday, 6 February 2014

Notes: Example of image data embedded in HTML

This is a div that appears on the Onion above an article when you've
reached 5 articles already, asking you to subscribe. The image
information is embedded in base64 on the div itself.

<div style="background-image:
z-index: 99998; position: absolute; top: 0px; left: 0px; width: 100%;
height: 3198px;"></div>

Tuesday, 4 February 2014

Java: (Spring) Getting subset of a list for paged display

PagedListHolder - one of those Spring classes that you wish you've
been using for the past 10 years

Given a
1. list of items
2. page number and
3. number of items per page

Return the part of the list to be displayed on the page

PagedListHolder<PopularSearch> pagedListHolder = new

List<PopularSearch> tmp = pagedListHolder.getPageList();