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" "${f%.foo}.bar"
done
From:
http://askubuntu.com/questions/35922/how-to-change-extension-of-multiple-files-from-command-line
Also see:
http://mywiki.wooledge.org/BashFAQ/030
Wednesday, 26 February 2014
Wednesday, 12 February 2014
@RetryOnFailure annotation using Aspect from JCABI library
Use this annotation to make repeated calls on failure for an idempotent method
http://www.jcabi.com/jcabi-aspects/annotation-retryonfailure.html
http://www.jcabi.com/jcabi-aspects/annotation-retryonfailure.html
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.
https://developers.google.com/safe-browsing/developers_guide_v2
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.
https://developers.google.com/safe-browsing/developers_guide_v2
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:
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RDhCQzBDREZCQ0ZGMTFFMEIxQkFCQ0MxOEQzMzc5NTEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RDhCQzBDRTBCQ0ZGMTFFMEIxQkFCQ0MxOEQzMzc5NTEiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDpEOEJDMENEREJDRkYxMUUwQjFCQUJDQzE4RDMzNzk1MSIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpEOEJDMENERUJDRkYxMUUwQjFCQUJDQzE4RDMzNzk1MSIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PoOauxEAAAALSURBVAgdYzA+AwABNQEAGVbmvQAAAABJRU5ErkJggg%3D%3D);
z-index: 99998; position: absolute; top: 0px; left: 0px; width: 100%;
height: 3198px;"></div>
reached 5 articles already, asking you to subscribe. The image
information is embedded in base64 on the div itself.
<div style="background-image:
url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0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ja2V0IGVuZD0iciI/PoOauxEAAAALSURBVAgdYzA+AwABNQEAGVbmvQAAAABJRU5ErkJggg%3D%3D);
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
PagedListHolder<PopularSearch>(sourceList);
pagedListHolder.setPage(pageNumber);
pagedListHolder.setPageSize(itemCountPerPage);
List<PopularSearch> tmp = pagedListHolder.getPageList();
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
PagedListHolder<PopularSearch>(sourceList);
pagedListHolder.setPage(pageNumber);
pagedListHolder.setPageSize(itemCountPerPage);
List<PopularSearch> tmp = pagedListHolder.getPageList();
Subscribe to:
Posts (Atom)