Skip to content

Instantly share code, notes, and snippets.

View gustavopinto's full-sized avatar
🌴
On vacation

Gustavo Pinto gustavopinto

🌴
On vacation
View GitHub Profile
@gustavopinto
gustavopinto / lucene-v2.9
Created July 28, 2011 01:26
lucene-concurrent
private int doParallelTasks() throws Exception {
initTasksArray();
final int count [] = {0};
Thread t[] = new Thread [repetitions * tasks.size()];
// prepare threads
int indx = 0;
for (int k=0; k<repetitions; k++) {
for (int i = 0; i < tasksArray.length; i++) {
final PerfTask task = (PerfTask) tasksArray[i].clone();
t[indx++] = new Thread() {
@gustavopinto
gustavopinto / datetools-v2.9
Created July 28, 2011 02:03
lucene-date-tools
public class DateTools {
private final static TimeZone GMT = TimeZone.getTimeZone("GMT");
private static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy", Locale.US);
private static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyyMM", Locale.US);
private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd", Locale.US);
private static final SimpleDateFormat HOUR_FORMAT = new SimpleDateFormat("yyyyMMddHH", Locale.US);
private static final SimpleDateFormat MINUTE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.US);
private static final SimpleDateFormat SECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
@gustavopinto
gustavopinto / antes
Created July 28, 2011 02:53
jme: sync-juc -> com.jme.util.GameTask
public synchronized V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
if ((result == null) && (exc == null)) {
unit.timedWait(this, timeout);
}
if (exc != null) throw exc;
if (result == null) throw new TimeoutException("Object not returned in time allocated.");
return result;
}
@gustavopinto
gustavopinto / stacktrace-gae
Created August 15, 2011 14:23
stack ao levantar no gae
/produto/novo
java.lang.RuntimeException: java.io.NotSerializableException: com.google.apphosting.runtime.jetty.SessionManager
at com.google.apphosting.runtime.jetty.SessionManager.serialize(SessionManager.java:358)
at com.google.apphosting.runtime.jetty.DatastoreSessionStore.createEntityForSession(DatastoreSessionStore.java:71)
at com.google.apphosting.runtime.jetty.DatastoreSessionStore.saveSession(DatastoreSessionStore.java:93)
at com.google.apphosting.runtime.jetty.SessionManager$AppEngineSession.save(SessionManager.java:153)
at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:41)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
@gustavopinto
gustavopinto / palestra
Created September 28, 2011 01:14
Problem accessing /palestra. Reason:
HTTP ERROR 500
Problem accessing /palestra. Reason:
exception raised, check root cause for details: java.lang.NoClassDefFoundError: sun.reflect.ReflectionFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
Caused by:
br.com.caelum.vraptor.InterceptionException: exception raised, check root cause for details: java.lang.NoClassDefFoundError: sun.reflect.ReflectionFactory is a restricted class. Please see the Google App Engine developer's guide for more details.
at br.com.caelum.vraptor.interceptor.ExecuteMethodInterceptor.intercept(ExecuteMethodInterceptor.java:96)
at br.com.caelum.vraptor.core.ToInstantiateInterceptorHandler.execute(ToInstantiateInterceptorHandler.java:54)
interpreter.hs:22:15:
`StateTransformer' is not applied to enough type arguments
The first argument of `Show' should have kind `*',
but `StateTransformer' has kind `* -> *'
In the instance declaration for `Show (StateTransformer)'
Failed, modules loaded: none.
@gustavopinto
gustavopinto / primosEntreSi
Created November 2, 2011 23:04
questão curso haskell
primosEntreSi :: [Integer] -> Integer -> [Integer]
primosEntreSi [] _ = []
primosEntreSi (n:ns) m = if (mod n m) == 0
then primosEntreSi ns m
else (n) : primosEntreSi ns m
@gustavopinto
gustavopinto / gist:1343004
Created November 6, 2011 15:10
search list
input = [1,4,1,4,6,5,5,5,4,2,3]
predicate = [1,3,5]
output = []
def init():
for i in predicate:
if input.count(i) > 0:
output.append([getandpop(i) for row in range (0, input.count(i))])
print output
@gustavopinto
gustavopinto / gist:1602377
Created January 12, 2012 18:56
exception no demoiselle
root cause
java.util.NoSuchElementException
com.google.common.collect.Iterators$1.next(Iterators.java:65)
br.gov.frameworkdemoiselle.util.Beans.getReference(Beans.java:76)
@gustavopinto
gustavopinto / gist:1684699
Created January 26, 2012 19:52
filtroPaginas
@WebFilter(filterName = "/FiltroPaginas", urlPatterns = {
"/private/pages/primeiroAcessoServidor.jsf",
"/private/pages/principal.jsf",
"/private/pages/selecaoVinculo.jsf",
"/private/pages/alterarSenha.jsf"
}, dispatcherTypes = {
DispatcherType.REQUEST,
DispatcherType.FORWARD,
DispatcherType.INCLUDE
})