Skip to content

Instantly share code, notes, and snippets.

View playerjamesbattleground's full-sized avatar

james jiang playerjamesbattleground

View GitHub Profile
@playerjamesbattleground
playerjamesbattleground / geocoder.rb
Created September 22, 2014 11:46
Try to make a custom geokit logstash filter
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require "logstash/util/geolookup"
class LogStash::Filters::Geocoder < LogStash::Filters::Base
# Setting the config_name here is required. This is how you
# configure this filter from your logstash config.
#
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<!-- access -->
<property name="driverClass" value="${db.driverclass}" />
<property name="jdbcUrl" value="${db.url}" />
<property name="user" value="${db.user}" />
<property name="password" value="${db.password}" />
<!-- pool sizing -->
<property name="initialPoolSize" value="3" />
<property name="minPoolSize" value="6" />
<property name="maxPoolSize" value="25" />
/*
Class Subject
id
Map<String,Participant> participants
Class Participant
Map<String,List<String>>attributes
*/
//This method is within a DAO class and under Spring context
@playerjamesbattleground
playerjamesbattleground / xml2json.groovy
Created May 12, 2014 03:24
groovy xml 2 json, exact match
xml ='''
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.directconnect.com.au/">
<soapenv:Header/>
<soapenv:Body>
<api:addCase soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<newCase xsi:type="api:CaseData">
<!--You may enter the following 38 items in any order-->
<DcamApiUserId xsi:type="xsd:string">123</DcamApiUserId>
<DcamApiToken xsi:type="xsd:string">111</DcamApiToken>
<TitleApplicant1 xsi:type="xsd:string">111</TitleApplicant1>
@playerjamesbattleground
playerjamesbattleground / gist:9719355
Created March 23, 2014 06:03
logstash for mule.log
input {
file {
path => "D:/dev/mule35ce/logs/mule.log"
}
}
filter {
multiline {
pattern => "^%{LOGLEVEL}"
negate => true
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans">
<xsl:output method="xml" indent="yes" />
<xsl:param name="service.op.name.capitalcase"/>
<xsl:param name="service.op.name.lowercase"/>
<xsl:template match="*[local-name() = 'mule' and namespace-uri() = 'http://www.mulesoft.org/schema/mule/core']">
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd ">
@playerjamesbattleground
playerjamesbattleground / build.xml
Created February 5, 2014 02:42
java task in build.xml
...
<!--Generate sample request / response xml from given xsd with JLibs
for example, we generate an request xml from a schema called getOrder.xsd
-->
<java classname="com.sixtree.xs2xml.XMLGenerator" classpathref="classpath">
<arg value="${schema.repo.dir}/getOrder.xsd" />
<arg value="getOrder-request.xml" />
<arg value="getOrderRequest" />
@playerjamesbattleground
playerjamesbattleground / XmlGenerator.java
Created February 5, 2014 02:38
Generate xml from xsd
package com.sixtree.xs2xml;
import java.io.File;
import javax.xml.namespace.QName;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.stream.StreamResult;
import jlibs.xml.Namespaces;
import jlibs.xml.sax.XMLDocument;