Skip to content

Instantly share code, notes, and snippets.

View bhathiya's full-sized avatar

Bhathiya Jayasekara bhathiya

View GitHub Profile
<Include-Resource>
@openjpa-2.2.0.jar!/META-INF/services/javax.annotation.processing.Processor,
@openjpa-2.2.0.jar!/META-INF/services/javax.persistence.spi.PersistenceProvider,
@openjpa-2.2.0.jar!/META-INF/org.apache.openjpa.revision.properties
</Include-Resource>
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of replicas
DataMemory=80M # How much memory to allocate for data storage
IndexMemory=18M # How much memory to allocate for index storage
# For DataMemory and IndexMemory, we have used the
# default values. Since the "world" database takes up
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for MySQL Cluster processes:
ndb-connectstring=1.1.1.5 # location of management server
public class Magic {
public static void main(String[] args) {
for (long l = 145425873831778797l; l > 0; l >>= 5){
System.out.print((char) (((l & 31 | 64) % 95) + 32));
}
}
}
@bhathiya
bhathiya / SimpleOauthHandler.java
Created February 8, 2014 14:13
Simple OAuth Handler for WSO2 ESB
package org.wso2.handler;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.apache.http.HttpHeaders;
import org.apache.synapse.core.axis2.Axis2MessageContext;
<api name="YoutubeSearch" context="/search">
<resource methods="GET">
<inSequence>
<header name="Authorization" scope="transport" action="remove"/>
<send>
<endpoint>
<address uri="https://gdata.youtube.com/feeds/api/videos?q=wso2"/>
</endpoint>
</send>
</inSequence>
<!-- OAuth2 Token Validation Service -->
<parameter name="oauth2TokenValidationService">https://10.100.0.65:9443/services/OAuth2TokenValidationService</parameter>
<!-- Server Admin credentials -->
<parameter name="identityServerUserName">admin</parameter>
<parameter name="identityServerPw">admin</parameter>
{
"users":[
{"name":"X", "age":"10"},
{"name":"Y", "age":"12"},
{"name":"Z","age":"15"}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonSplitterBlog"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<payloadFactory media-type="json">
<property name="xmlfile" expression="get-property('registry', 'gov:/xml/body.xml')" type="OM" />
<enrich>
<source clone="true" xpath="get-property('xmlfile')" />
<target type="body" />
</enrich>