Skip to content

Instantly share code, notes, and snippets.

@molexx
molexx / RepositoryPaginater.kt
Created September 10, 2021 16:36
Kotlin functional wrapper for Spring-data repository's pagination
/**
* Extension function for Spring-Data's CrudRepository providing a convenient wrapper to handle pagination in a Kotlin-idiomatic way.
*
* Creates a Sequence using Page and Pageable to iterate calls to a paginated Spring-Data function call.
*
* Example usage:
*
* myPagingAndSortingRepository.paginate(50) { pageable ->
* // directly call any function on the repository that returns a Page
* findAll(pageable)
@molexx
molexx / index.js
Created August 26, 2015 17:48
cls-mongoose index.js addition for Models
var wrapLastParamInCLSBind = function(clsns, container, functionName) {
shimmer.wrap(container, functionName, function (original) {
return function() {
var lastArg = arguments[arguments.length - 1];
if (lastArg && ('function' == typeof lastArg)) {
var clsBoundLastArg = clsns.bind(lastArg);
arguments[arguments.length - 1] = clsBoundLastArg;
}