Skip to content

Instantly share code, notes, and snippets.

View dennysfredericci's full-sized avatar

Dennys dennysfredericci

View GitHub Profile
@dennysfredericci
dennysfredericci / Validator.java
Created January 12, 2012 00:05
Alternativa para o Validator no VRaptor, este incluir um mapa dos erros no request e não uma lista como é feito no DefaultValidator.
package br.com.fredericci.validation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@dennysfredericci
dennysfredericci / gist:2351936
Created April 10, 2012 14:51
Download de boleto com vraptor e bopepo(jrimum.org)
No controller:
@Get("/cobrancas/{cobranca.id}/boleto")
public Download gerarBoleto(@Load Cobranca cobranca) {
Boleto boleto = cobranca.gerarBoleto();
BoletoDownload download = new BoletoDownload(boleto);
return download;
}
Classe para auxiliar o download:
@dennysfredericci
dennysfredericci / serial.rb
Created June 12, 2012 13:58
ruby script to serial port
require 'rubygems'
require 'serialport'
begin
parameters = {"baud" => 19200, "data_bits" => 8, "stop_bits"=>1,"parity"=>SerialPort::NONE}
comm_port = '/dev/tty.usbmodem411'
sp = SerialPort.new(comm_port, parameters)
@dennysfredericci
dennysfredericci / validator
Created July 2, 2012 03:56
An easy way to use JQuery Validation with Twitter Bootstrap Popover
$('form').validate(
{
rules: {
numero: {
required: true
},
descricao: {
minlength: 3,
email: true,
required: true
@dennysfredericci
dennysfredericci / jquery-validation-messages.js
Created July 2, 2012 04:16
JQuery Validation Messages for pt_BR
/*
* Translated default messages for the jQuery validation plugin.
* Locale: PT_BR
*/
jQuery.extend(jQuery.validator.messages, {
required: "Campo obrigatório!",
remote: "Por favor, corrija este campo.",
email: "Por favor, forneça um endereço eletrônico válido.",
url: "Por favor, forneça uma URL válida.",
date: "Por favor, forneça uma data válida.",
@dennysfredericci
dennysfredericci / change_password.sql
Created September 3, 2012 02:36
Just change mysql password for any user...
USE mysql;
UPDATE user SET password=PASSWORD("root") WHERE user = 'root';
FLUSH PRIVILEGES;
@dennysfredericci
dennysfredericci / PedidoAspect
Created April 17, 2013 02:47
A simple way to "build" a proxy for aspectj applications
@Aspect
public class PedidoAspect {
public interface Customer {
String getNome();
};
@DeclareParents("br.com.test.Cliente")
public static Customer customer;
@dennysfredericci
dennysfredericci / web.xml
Created July 2, 2013 01:01
web.xml spec 3.0 sample
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">
       
  <servlet>
   <display-name>Servlet1</display-name>
   <servlet-name>Servlet1</servlet-name>
   <servlet-class>test.Servlet1</servlet-class>
   <init-param>
@dennysfredericci
dennysfredericci / XmlFormatter.java
Created April 10, 2014 20:56
A simple XML Formatter
import java.io.File;
import java.io.FileWriter;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
public class XmlFormatter
@dennysfredericci
dennysfredericci / application.html.erb
Created April 21, 2014 13:57
A simple html page to read informations from facebook
<html>
<head>
<title>Fluid Canvas HTML Example </title>
</head>
<body>
<div id="allContent" class="span12">
<form class="form-horizontal">