Skip to content

Instantly share code, notes, and snippets.

Avatar

Jony Santos jonyfs

View GitHub Profile
@ggtools
ggtools / TestMongoConfig.java
Created Oct 7, 2014
A Spring configuration to use an embedded MongoDB during tests
View TestMongoConfig.java
@Configuration
public class TestMongoConfig {
private static final MongodStarter starter = MongodStarter.getDefaultInstance();
@SuppressWarnings("SpringJavaAutowiringInspection")
@Autowired
private MongoProperties properties;
@Autowired(required = false)
private MongoClientOptions options;
View gist:4df7e2257d7e10c50a30
Obs: http://tinyurl.com/raml-file
-----
#%RAML 0.8
baseUri: http://mocksvc.mulesoft.com/mocks/a296cd19-32ae-4c10-ba8a-ffb527bd4f24
title: pagamentos
version: 1.0
mediaType: application/json
@sergiolopes
sergiolopes / Periodo.java
Created Oct 19, 2009
exemplo de classe imutável usando flyweight
View Periodo.java
import java.util.Calendar;
public final class Periodo {
private final Calendar inicio;
private final Calendar fim;
public Periodo(Calendar inicio, Calendar fim) {
this((Calendar) inicio.clone(), (Calendar) fim.clone(), false);
}
@runeflobakk
runeflobakk / EqualsAndHashCodeTemplate.java
Created Aug 23, 2011
equals() and hashCode() template for Eclipse. It uses EqualsBuilder and HashCodeBuilder in Apache Commons Lang.
View EqualsAndHashCodeTemplate.java
${e:import(org.apache.commons.lang3.builder.EqualsBuilder)}
${h:import(org.apache.commons.lang3.builder.HashCodeBuilder)}
@Override
public boolean equals(Object object) {
if (object instanceof ${enclosing_type}) {
${enclosing_type} another = (${enclosing_type}) object;
return new EqualsBuilder().append(${replaceWithFieldName}, another.${replaceWithFieldName}).isEquals();
}
@legzo
legzo / log4jAdmin.jsp
Created Oct 17, 2011 — forked from anonymous/log4jAdmin.jsp
Change log4j log levels runtime from a jsp
View log4jAdmin.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="org.apache.log4j.Level" %>
<%@ page import="org.apache.log4j.LogManager" %>
<%@ page import="org.apache.log4j.Logger" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.Arrays" %>
<% long beginPageLoadTime = System.currentTimeMillis();%>
@ghusta
ghusta / LocalDateTimeAdapter.java
Created Jan 15, 2014
LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0. Can be used when customizing XML Schema to Java Representation Binding (XJC).
View LocalDateTimeAdapter.java
package xml.adapters.jodatime;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.joda.time.LocalDateTime;
/**
* LocalDateTimeAdapter, useful to convert String to Joda Time's LocalDateTime and conversely, for use with JAXB 2.0.
* <br>
* Can be used when customizing XML Schema to Java Representation Binding (XJC).
@jamesmorgan
jamesmorgan / CopyFromOneServerToAnother.groovy
Created Oct 15, 2011
Copy Messages from one ActiveMQ instance to another with Apache Camel and Groovy
View CopyFromOneServerToAnother.groovy
import org.apache.activemq.camel.component.ActiveMQComponent
import org.apache.camel.CamelContext
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
class CopyFromOneServerToAnother extends RouteBuilder{
public static void main(String[] args) {
@carlcantprogram
carlcantprogram / gist:42fbecb399af7e8ce4c0
Last active Jun 29, 2018
Oracle JDK7 Download Install powershell
View gist:42fbecb399af7e8ce4c0
$url = 'http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-windows-x64.exe'
$filename = $url.Substring($url.LastIndexOf("/") + 1);
$client = new-object System.Net.WebClient;
$client.Headers.Add("Cookie", "oraclelicense=accept-securebackup-cookie");
$client.DownloadFile( $url, $filename );
$result = (Start-Process -FilePath $filename -ArgumentList "/quiet /qn /norestart /l* jdk7_install.log" -Wait -Passthru).ExitCode;
echo $result;
Get-WmiObject -Class Win32_Product -Filter "Name LIKE '%java%SE Development Kit 7%'";
# IdentifyingNumber : {64A3A4F4-B792-11D6-A78A-00B0D0170600}
@facundofarias
facundofarias / WebSocketResource.java
Last active Jan 28, 2019
Enabling WebSockets on Jersey (Tyrus)
View WebSocketResource.java
import java.io.IOException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
@bcalmac
bcalmac / CaseInsensitiveSetMultimap.java
Created Mar 10, 2015
Case insensitive SetMultimap using Guava
View CaseInsensitiveSetMultimap.java
import com.google.common.collect.ForwardingSetMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
/** SetMultimap decorator that coverts keys to lower case before delegation */
public class CaseInsensitiveSetMultimap<V> extends ForwardingSetMultimap<String, V> {