Skip to content

Instantly share code, notes, and snippets.

View yamanyar's full-sized avatar

Kaan Yamanyar yamanyar

View GitHub Profile
@yamanyar
yamanyar / java
Created December 15, 2020 16:43
ReentrantReadWriteLock performance check
package samples;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Threads;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
_dictionary = new TstDictionary ();
TextAsset text = null;
float t = Time.realtimeSinceStartup;
try {
text = Resources.Load ("z") as TextAsset;
using (var reader = new StringReader (text.text)) {
string key;
while ((key = reader.ReadLine ()) != null) {
key = key.Trim ();
_dictionary.Add (key, null);
#!/bin/bash
# Pre recieve tests
NOREV=0000000000000000000000000000000000000000
while read oldsha newsha refname ; do
# deleting is always safe
if [[ $newsha == $NOREV ]]; then
continue
fi
@yamanyar
yamanyar / gist:95a2f42b5c984aef9860
Last active November 20, 2021 13:47
Unity: Creating a Thread and Making Callback Called by UI Thread
delegate void JobResultHandler(bool result);
public static void DoJobAsync (string someParameter, JobResultHandler jobResultHandler = null)
{
//If callback is null; we do not need unity adapter, otherwise we need to create it in ui thread.
ThreadAdapter adapter = jobResultHandler == null ? null : CreateUnityAdapter ();
@yamanyar
yamanyar / add_missing_soap_header.xsl
Created December 3, 2013 13:05
Adds Soap header if it is missing
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*[not(//soapenv:Header)]">
<xsl:copy>
@yamanyar
yamanyar / gist:6881592
Created October 8, 2013 08:40
add jsonx conent's checksum to http response
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx"
xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable
name="theMasterNode"
select="/json:object">
</xsl:variable>
@Override
public void run() {
ExecutorService executorService = Executors.newFixedThreadPool(10);
while (true) {
final long start = System.currentTimeMillis();
for (final AsyncContext aync : rateWatchers) {
executorService.submit(new Runnable() {
@Override
public void run() {
@yamanyar
yamanyar / server.xml
Created September 24, 2013 06:37
nio connector with executor for async servlets
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="10" minSpareThreads="4"/>
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" selectorTimeout="500" executor="tomcatThreadPool" />
@yamanyar
yamanyar / sample.xml
Created September 12, 2013 14:31
Messagesender configuration for NTLM
<int-ws:outbound-gateway
uri="${services.exchange.service}" request-channel="exchangeServiceEnriched"
message-sender="exchangeMessageSender">
</int-ws:outbound-gateway>
<bean id="exchangeMessageSender" class="com.ykb.esb.util.exchange.BasicToNTLMHttpComponentsMessageSender" />
@yamanyar
yamanyar / BasicToNTLMHttpComponentsMessageSender.java
Created September 12, 2013 14:20
A simple HttpComponentsMessageSender to use in spring integration with out bound ws gateway to authenticate with NTLM
package com.secretcompany.esb.util.exchange;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.xml.security.utils.Base64;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.ws.transport.WebServiceConnection;