Skip to content

Instantly share code, notes, and snippets.

View rponte's full-sized avatar
🏠
Working from home

Rafael Ponte rponte

🏠
Working from home
View GitHub Profile
import static java.util.Collections.list;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Specializes;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
@rponte
rponte / input.txt
Last active August 29, 2015 14:09 — forked from peczenyj/input.txt
lala
begin
sddasdas
asdasdasd
asdasd
end
lolo
@rponte
rponte / MyRepositoryImpl.java
Last active January 29, 2021 19:16 — forked from jelies/MyRepositoryImpl.java
A Spring FactoryBean to create a Hibernate's StatelessSession to be injected in your custom repository implementation when using Spring Data JPA.
package com.jelies.spring3tomcat7.repository;
import org.hibernate.Criteria;
import org.hibernate.ScrollableResults;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.*;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
import java.io.IOException;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
@WebFilter (value="/*",
initParams=({
@WebInitParam(name="duration", value="1")
@rponte
rponte / TaskRunnerTest.java
Created December 13, 2017 12:52 — forked from jpukg/TaskRunnerTest.java
Using CountDownLatch to Test Asynchronous Code
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
@rponte
rponte / ADFBeanValidator.java
Created June 17, 2019 17:00 — forked from donatasnicequestion/ADFBeanValidator.java
ADF Bean Validator for JSF303 integration with Oracle ADF
package com.nicequestion.donatas.adf.validate;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.BeanValidator;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.ValidatorException;
@rponte
rponte / robust-bash.sh
Created August 29, 2019 13:48 — forked from TimothyJones/robust-bash.sh
These are (currently) the only functions I recommend porting around when writing bash scripts
#!/bin/bash -eu
if [ -z "${LIB_ROBUST_BASH_SH:-}" ]; then
LIB_ROBUST_BASH_SH=included
function error {
echo "Error: ${1:-}"
}
# Check to see that we have a required binary on the path
function require_binary {
@rponte
rponte / things-i-believe.md
Created March 6, 2020 20:51 — forked from stettix/things-i-believe.md
Things I believe

Things I believe

This is a collection of the things I believe about software development. I have worked for years building backend and data processing systems, so read the below within that context.

Agree? Disagree? Feel free to let me know at @JanStette. See also my blog at www.janvsmachine.net.

Fundamentals

Keep it simple, stupid. You ain't gonna need it.

@rponte
rponte / PinblockTool.java
Created March 13, 2020 16:29 — forked from Gilmor/PinblockTool.java
Pinblock ISO 9564 format 0
package cz.monetplus.mnsp.tools.misc;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang.StringUtils;
/**
* Tools for encoding a decoding pinblock
*
* @author Tomas Jacko <tomas.jacko [at] monetplus.cz>
@rponte
rponte / taskqueues.sql
Created April 26, 2020 00:40 — forked from purcell/taskqueues.sql
Easy task queues using PostgreSQL
-- Let's say you have a table full of work:
CREATE TABLE tasks (
id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
status TEXT NOT NULL DEFAULT 'pending',
payload JSON NOT NULL, -- or just have meaningful columns!
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);