Skip to content

Instantly share code, notes, and snippets.

View eduardocl's full-sized avatar

Eduardo eduardocl

View GitHub Profile
@eduardocl
eduardocl / Log Programatico
Last active December 3, 2018 19:22
Classe para Criar um Log programaticamente
Adicionar no pom:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
mvn install:install-file -Dfile=./lib/axis.jar -DgroupId=local-deps -DartifactId=axis -Dversion=local -Dpackaging=jar -DlocalRepositoryPath=./lib/repo
mvn install:install-file -Dfile=./lib/commons-logging-1.0.2.jar -DgroupId=local-deps -DartifactId=commons-logging -Dversion=local -Dpackaging=jar -DlocalRepositoryPath=./lib/repo
mvn install:install-file -Dfile=./lib/ejb3-persistence.jar -DgroupId=local-deps -DartifactId=ejb3-persistence -Dversion=local -Dpackaging=jar -DlocalRepositoryPath=./lib/repo
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
public class ECLRunner extends BlockJUnit4ClassRunner {
private Integer testsLeft;
@eduardocl
eduardocl / xml.rb
Last active April 20, 2016 17:53
Saving documents in xml
desc "Salva arquivos em xml"
task :export => :environment do
require 'builder'
docs = Document.all
index = 1
docsarray = []
docs.each do |doc|
docsarray.push(doc)
if docsarray.size % 1000 == 0
save_xml("documents-rkb-" + index.to_s, docsarray)
# -*- coding: utf-8 -*-
__author__ = "Eduardo Lopes"
__copyright__ = "Copyright 2014, Planeta Terra"
__license__ = "Use por conta e risco"
__version__ = "0.1-beta-bem-beta"
__status__ = "mais ou menos em Production"
import os
import sys
from xml.dom import minidom
xmldoc = minidom.parse('.classpath')
itemlist = xmldoc.getElementsByTagName('classpathentry')
for s in itemlist :
print s.attributes['path'].value
import os
import subprocess
def executar(str):
''' Executa um comendo no shell retornando o stdout '''
args = str.split(' ')
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
return out
@eduardocl
eduardocl / gist:7007046
Last active December 25, 2015 16:39
Executando expressões lógicas criadas dinamicamente em java através da execução de um código javascript dentro do código java.
ScriptEngineManager mgr = new ScriptEngineManager();
String expression = "if( (((((4 == 1) && 'USER_ID' != '1') && 'ON_GOING' == 'ON_GOING') || 1381374000000 != 1381374000000)){ resut = true ; } else { result = false; }"
ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
boolean result = false;
try {
result = (Boolean) jsEngine.eval(expression);
describe "#list" do
it "list attribute as ruby object" do
attrs = @controller.list_attributes
attrs.each do |a|
a.should be_an_instance_of Attribute
end
end
it "list attribute in xml format" do
xml = @controller.list_attributes(:xml)
capacidade.turma=10
usuario=secretaria
senha=segredo
papel=admin