Skip to content

Instantly share code, notes, and snippets.

View vanjikumaran's full-sized avatar

Vanjikumaran vanjikumaran

View GitHub Profile
<enrich>
<source type="inline" clone="true"/>
<target action="child" xpath="//jsonObject" />
</enrich>
<enrich>
<source clone="true" xpath="//jsonObject" />
<target type="body" />
</enrich>
<log level="full"/>
-Dlog4j.configurationFile="$CARBON_HOME/repository/conf/log4j2.xml" \
-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector \
@vanjikumaran
vanjikumaran / log4j2.xml
Created March 30, 2020 21:42
log4j 2 configuration
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Kafka name="Kafka" topic="WSO2APIMTOPIC">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n"/>
<Property name="bootstrap.servers">localhost:9092</Property>
</Kafka>
<Async name="Async" bufferSize="1054" blocking="false">
<AppenderRef ref="Kafka"/>
</Async>
@vanjikumaran
vanjikumaran / RegexBasedTest.java
Created April 25, 2019 06:33
Regex based Char replacement.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexBasedTest {
private static final Pattern PASSWORD_PATTERN = Pattern.compile("[a-zA-z0-9]{3}");
private static final String uuid = "b02fb649-797b-440b-9aa9-f3294ed0ce73";
public static void main(String[] args) {
for (int i = 0; i < Integer.MAX_VALUE; ++i) {
String masked = replaceChar(uuid);
}
int pintarray[] = {1,2,3,4,5,6,7,8,9,10};
int counter =0;
int timer=1000;
int sensorPin =A0;
void setup() {
counter=0;
pinMode(sensorPin,INPUT);
while(counter<10){
@vanjikumaran
vanjikumaran / KnightRider.ino
Created April 25, 2018 01:35
Knight Rider LED on Ardino
# Copyright 2018 Vanji
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@vanjikumaran
vanjikumaran / TcpConnectionAsAPI.xml
Last active October 16, 2017 22:53
Synapse configuration to connect with tcp socket via scripting
<api xmlns="http://ws.apache.org/ns/synapse" name="TcpConnectionAsAPI" context="/tcp">
<resource methods="POST GET" url-mapping="/connection">
<inSequence>
<script language="groovy">def myValue='value';def socket = new Socket('localhost', 4444); myValue = socket.withStreams { input, output -&gt; buffer = input.newReader().readLine(); return buffer;}; mc.setProperty('ValueInGroovyScript',myValue);</script>
<log>
<property name="Value from TCP Server" expression="$ctx:ValueInGroovyScript" />
</log>
<script language="js">var resp = String(mc.getProperty("ValueInGroovyScript")).split(','); var payloadXML = new XML(&lt;response/&gt;); var resp = String(mc.getProperty("ValueInGroovyScript")).split(','); payloadXML.appendChild(new XML(&lt;resp&gt;{resp[0]}&lt;/resp&gt;)); payloadXML.appendChild(new XML(&lt;company&gt;{resp[1]}&lt;/company&gt;)); payloadXML.appendChild(new XML(&lt;itemnbr&gt;{resp[2]}&lt;/i
@vanjikumaran
vanjikumaran / MockServer.py
Created October 2, 2017 22:52
very simple TCP server made out of Python | To run $ python MockServer.py
# Copyright 2017 Vanji
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@vanjikumaran
vanjikumaran / _auth_failure_handler_.xml
Created July 22, 2016 21:07
Auth Failure Handler Sequence Synapse Configuration
<sequence name="_auth_failure_handler_" xmlns="http://ws.apache.org/ns/synapse">
<switch source="$trp:Accept">
<case regex="application/json">
<property name="error_message_type" value="application/json"/>
</case>
<default>
<property name="error_message_type" value="application/xml"/>
</default>
</switch>
<sequence key="_build_"/>
Verifying that +vanjikumaran is my blockchain ID. https://onename.com/vanjikumaran