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
@rponte
rponte / eclipse.desktop
Created February 1, 2014 16:27
Ubuntu Eclipse shortcut
[Desktop Entry]
Version=4.3.1
Name=Eclipse
Comment=IDE for all seasons
Exec=env UBUNTU_MENUPROXY=0 /home/joop1/eclipse/eclipse
Icon=/home/joop1/Área de Trabalho/TriadWorks/cursos/joop/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=Utility;Application
@rponte
rponte / forwarding_ip_on_macosx.sh
Last active August 29, 2015 13:56
Forwarding an ip address to localhost on MacOSX
sudo ifconfig lo0 172.16.50.5 alias
#sudo ipfw add fwd 127.0.0.1,9790 tcp from me to 172.16.50.5 dst-port 80
## removing alias
sudo ifconfig lo0 -alias 172.16.50.5
@rponte
rponte / server.xml
Created February 27, 2014 11:07
Turning on resources compression on Tomcat
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="1024"
compressableMimeType="text/css,application/javascript" />
@rponte
rponte / firefox_bfcache.js
Created March 27, 2014 22:21
Dealing with Firefox Internal Cache (bfcache)
/**
* Just cleans up the loading bar element when user clicks back/forward button on browser.
* This kind of issue is related with Firefox Internal Cache only.
* https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
*/
window.addEventListener('pageshow', function(){
$("#loading-bar").hide();
}, false);
@rponte
rponte / README.md
Last active August 29, 2015 13:57
Ivy configuration used in a real project (just for reference)

Configurando o projeto no Eclipse

Após baixar/clonar o projeto do Github, será necessário baixar o restante das libs (dependências) do projeto. Para isso basta executar a target bundle:install do Ant, como pode ser vista logo abaixo:

ant bundle:install

Todas as libs serão baixadas e colocadas no diretório lib/bundle do projeto. Por não utilizarmos nem o Maven nem o Gradle o projeto já vem com os arquivos de configuração do Eclipse, como .project, .classpath entre outros.

@rponte
rponte / CategoriaController.java
Created April 4, 2014 15:14
Example of a VRaptor controller and its unit tests
@Resource
public class CategoriaController {
private final Result result;
private final CategoriaService service;
private final Validator validator;
public CategoriaController(CategoriaService service, Result result,
Validator validator) {
this.service = service;
@rponte
rponte / CadastroDeProduto.java
Last active August 29, 2015 13:59
Simple example of a DAO using JDBC
import java.sql.Connection;
import java.sql.SQLException;
public class CadastroDeProduto {
public static void main(String[] args) throws SQLException {
Produto produto = new Produto();
produto.setNome("Ipad Mini");
produto.setDescricao("Ipad Mini 16g");
@rponte
rponte / AutoUpdateMessagesListener.java
Created April 25, 2014 19:28
Simple JSF 2 PhaseListener for auto-uptating the h:messages component (simulates p:messages with autoUpdate=true)
public class AutoUpdateMessagesListener implements PhaseListener {
@Override
public void afterPhase(PhaseEvent event) {
FacesContext.getCurrentInstance().getPartialViewContext()
.getRenderIds().add("header:messages"); // add id of h:messages component
}
@Override
public void beforePhase(PhaseEvent event) {
@rponte
rponte / rerender-component.xhtml
Created May 15, 2014 18:29
Getting the component id via EL
<h:panelGroup>
<h:dataTable>
<h:column>
<h:commandButton id="removeTaskButton" value="X" action="#{tasksMgr.removeTask(task)}">
<!-- pay attention to ":" at the beginning of string -->
<f:ajax render=":#{component.parent.parent.parent.clientId}" />
</h:commandButton>
</h:column>
</h:dataTable>
</h:panelGroup>
@rponte
rponte / web.xml
Created May 19, 2014 01:40
Configuring security key on JSF client-side viewstate
<env-entry>
<env-entry-name>jsf/ClientSideSecretKey</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Y3Vyc29zdHJpYWR3b3Jrcw==</env-entry-value> <!-- cursostriadworks -->
</env-entry>