Skip to content

Instantly share code, notes, and snippets.

@adrianojlt
adrianojlt / mongoTemplatePagination.java
Created September 23, 2025 14:31
mongoTemplate with pagination
Pageable pageable = PageRequest.of(0, 10);
// Build query without pagination first
Query query = new Query();
// Add criteria's here
long total = mongoTemplate.count(query, Patient.class);
query.with(pageable); // Apply pagination only for the find operation
List<Patient> filteredPatients = mongoTemplate.find(query, Patient.class, "patient");
@adrianojlt
adrianojlt / diretiva
Last active August 29, 2015 14:14
infinite scroll
angular.module('myApp', ['smart-table'])
.controller('mainCtrl', ['$scope', '$timeout',
function ($scope, $timeout) {
var nameList = ['Pierre', 'Pol', 'Jacques', 'Robert', 'Elisa'];
var familyName = ['Dupont', 'Germain', 'Delcourt', 'bjip', 'Menez'];
$scope.isLoading = false;
$scope.rowCollection = [];
@adrianojlt
adrianojlt / example-user.js
Created May 10, 2012 16:36 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);