Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennys dennysfredericci

View GitHub Profile
View XmlFormatter.java
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 Apr 21, 2014
A simple html page to read informations from facebook
View application.html.erb
<html>
<head>
<title>Fluid Canvas HTML Example </title>
</head>
<body>
<div id="allContent" class="span12">
<form class="form-horizontal">
@dennysfredericci
dennysfredericci / machine_learning.rb
Created Jul 21, 2014
Machine Learning example using libsvm
View machine_learning.rb
#gem install rb-libsvm
require 'libsvm'
class Predictor
def initialize
parameter = Libsvm::SvmParameter.new
parameter.cache_size = 3 # in megabytes
View FIX41.xml
<fix major="4" minor="1">
<header>
<field name="BeginString" required="Y"/>
<field name="BodyLength" required="Y"/>
<field name="MsgType" required="Y"/>
<field name="SenderCompID" required="Y"/>
<field name="TargetCompID" required="Y"/>
<field name="OnBehalfOfCompID" required="N"/>
<field name="DeliverToCompID" required="N"/>
<field name="SecureDataLen" required="N"/>
@dennysfredericci
dennysfredericci / Validator.java
Created Jan 12, 2012
Alternativa para o Validator no VRaptor, este incluir um mapa dos erros no request e não uma lista como é feito no DefaultValidator.
View Validator.java
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 Apr 10, 2012
Download de boleto com vraptor e bopepo(jrimum.org)
View gist:2351936
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 Jun 12, 2012
ruby script to serial port
View serial.rb
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 / change_password.sql
Created Sep 3, 2012
Just change mysql password for any user...
View change_password.sql
USE mysql;
UPDATE user SET password=PASSWORD("root") WHERE user = 'root';
FLUSH PRIVILEGES;
@dennysfredericci
dennysfredericci / PedidoAspect
Created Apr 17, 2013
A simple way to "build" a proxy for aspectj applications
View PedidoAspect
@Aspect
public class PedidoAspect {
public interface Customer {
String getNome();
};
@DeclareParents("br.com.test.Cliente")
public static Customer customer;
@dennysfredericci
dennysfredericci / web.xml
Created Jul 2, 2013
web.xml spec 3.0 sample
View web.xml
<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>