text:
package com.github.neuralnetworks.calculation.operations.opencl;

import com.github.neuralnetworks.calculation.operations.opencl.OCL;
import com.github.neuralnetworks.test.AbstractTest;

/**
 * @author Tony
 * @author Vadim
 */
public class OCLTest extends AbstractTest
{

	public void testMain() throws Exception
	{
//        System.load("d:\\classes\\ExBJCL.dll");
		OCL GPU = new OCL();

		int WeightedSum_miniBatchSize = 1;

		int WeightedSum_inputColumnStep = 1;
		int WeightedSum_inputRowStep = 2;
		int WeightedSum_inputStartPosition = 0;

		int WeightedSum_weightsInitialStep = 1;
		int WeightedSum_weightsSize = 3;
		int WeightedSum_weightsStep = 2;
		int WeightedSum_weightsStartPosition = 0;

		int WeightedSum_outputColumnStep = 1;
		int WeightedSum_outputRowStep = 3;
		int WeightedSum_outputStartPosition = 0;

		int Sigmoid_startIndex = 0;
		int Tanh_startIndex = 0;
		int ReLU_startIndex = 0;
		int SoftReLU_startIndex = 0;

		int ReLUDerivative_activationsStartIndex = 0;
		int ReLUDerivative_resultStartIndex = 0;
		int TanhDerivative_activationsStartIndex = 0;
		int TanhDerivative_resultStartIndex = 0;
		int SigmoidDerivative_activationsStartIndex = 0;
		int SigmoidDerivative_resultStartIndex = 0;
		int SoftReLUDerivative_activationsStartIndex = 0;
		int SoftReLUDerivative_resultStartIndex = 0;

		int Noise_startIndex = 0;
		float Noise_corruptionLevel = 0.1f;
		float Noise_corruptedValue = 0.2f;

		int[] dimensions = { WeightedSum_inputStartPosition + WeightedSum_inputRowStep * WeightedSum_miniBatchSize };
		float[] input = new float[32]; // sizes * miniBatchSize];
		float[] output1 = new float[400]; // sizes * miniBatchSize];
		float[] output2 = new float[400]; // sizes * miniBatchSize];
		float[] output3 = new float[400]; // sizes * miniBatchSize];
		float[] activations = new float[400]; // sizes * miniBatchSize];
		float[] weights = new float[4 * 4]; // weightsSize * weightsSize];

		int[] dimensions2 = { 4, 4 }; // { weightsSize, weightsSize };

//		input[0] = 0;		input[1] = 0;		input[2] = 0;		input[3] = 0;
//		input[4] = 1.0f;	input[5] = 4.0f;	input[6] = 2.0f;	input[7] = 5.0f;
//		input[8] = 3.0f;	input[9] = 6.0f;

//		output1[0] = 0;		output1[1] = 0;		output1[2] = 0;		output1[3] = 0;
//		output1[4] = 1.0f;	output1[5] = 4.0f;	output1[6] = 2.0f;	output1[7] = 5.0f;
//		output1[8] = 3.0f;	output1[9] = 6.0f;

//		output2[0] = 0;		output2[1] = 0;		output2[2] = 0;		output2[3] = 0;
//		output2[4] = 1.0f;	output2[5] = 4.0f;	output2[6] = 2.0f;	output2[7] = 5.0f;
//		output2[8] = 3.0f;	output2[9] = 6.0f;

//		output3[0] = 0;		output3[1] = 0;		output3[2] = 0;		output3[3] = 0;
//		output3[4] = 1.0f;	output3[5] = 4.0f;	output3[6] = 2.0f;	output3[7] = 5.0f;
//		output3[8] = 3.0f;	output3[9] = 6.0f;

//		weights[0] = 1.0f;	weights[1] = 4.0f;	weights[2] = 2.0f;	weights[3] = 5.0f;
//		weights[4] = 3.0f;	weights[5] = 6.0f;	weights[6] = 1.0f;	weights[7] = 4.0f;
//		weights[8] = 2.0f;	weights[9] = 5.0f;	weights[10]= 3.0f;	weights[11]= 6.0f;

		for (int i = 0; i < input.length; i++)
		{
			input[i] = 0;
		}

		for (int i = 0; i < WeightedSum_inputRowStep; i++)
		{
			input[i] = 2.0f;
		}

		for (int i = 0; i < weights.length; i++)
		{
			weights[i] = 0.2f;
		}

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0;
			output2[i] = 0;
			output3[i] = 0;
		}

		String opts =
				"";
		// weightedSum options
//					  " -D WSinSP="   + WeightedSum_inputStartPosition +
//					  " -D WSinRS="   + WeightedSum_inputRowStep +
//					  " -D WSinCS="   + WeightedSum_inputColumnStep +
//					  " -D WSwSP="    + WeightedSum_weightsStartPosition +
//					  " -D WSwIS="    + WeightedSum_weightsInitialStep +
//					  " -D WSwS="     + WeightedSum_weightsStep +
//				      " -D WSwZ="     + WeightedSum_weightsSize +
//				      " -D WSoutSP="  + WeightedSum_outputStartPosition +
//				      " -D WSoutRS="  + WeightedSum_outputRowStep +
//				      " -D WSoutCS="  + WeightedSum_outputColumnStep +
//				      " -D WSminiBS=" + WeightedSum_miniBatchSize
		// Sigmoid options
//				     +" -D SigSI="+Sigmoid_startIndex
		// Tanh options
//				     +" -D TanhSI="+Tanh_startIndex
		// ReLU options
//				     +" -D ReLUSI="+ReLU_startIndex
		// SoftReLU options
//				     +" -D SoftReLUSI="+SoftReLU_startIndex
		// ReLUDerivative options
//				     +" -D DReLUaSI="+ReLUDerivative_activationsStartIndex
//				     +" -D DReLUrSI="+ReLUDerivative_resultStartIndex
		// TanhDerivative options
//				     +" -D DTanhaSI="+TanhDerivative_activationsStartIndex
//				     +" -D DTanhrSI="+TanhDerivative_resultStartIndex
		// SigmoidDerivative options
//				     +" -D DSigaSI="+SigmoidDerivative_activationsStartIndex
//				     +" -D DSigrSI="+SigmoidDerivative_resultStartIndex
		// SoftReLUDerivative options
//				     +" -D DSReLUaSI="+SoftReLUDerivative_activationsStartIndex
//				     +" -D DSReLUrSI="+SoftReLUDerivative_resultStartIndex
		// Noise options
//				     +" -D NoiseCL="+Noise_corruptionLevel
//				     +" -D NoiseCV="+Noise_corruptedValue
//				     +" -D NoiseSI="+Noise_startIndex
//	     			 								;

//		GPU.setOptionsMode();

//        checkError( GPU.pathSetToCL( "d:\\classes".toCharArray() ) );

		char[] options = opts.toCharArray();

//		System.out.println("Devices: " + GPU.getDevicesNumber() );

		int deviceID1 = GPU.getDeviceID(0); // init device1
		checkError(GPU.initDeviceID(deviceID1, options, true));

		int deviceID2 = GPU.getDeviceID(deviceID1); // init device2
		checkError(GPU.initDeviceID(deviceID2, options, true));

		/*
		 * ---------------------
		 * weightedSum section
		 * ---------------------
		 */

		/* prepare buffers */
		int iID1 = GPU.prepareFloatArray(deviceID1, input, 0);
		int wID1 = GPU.prepareFloatArray(deviceID1, weights, 0);
		int oID1 = GPU.prepareFloatArray(deviceID1, output1, 0);

		int iID2 = GPU.prepareFloatArray(deviceID2, input, 0);
		int wID2 = GPU.prepareFloatArray(deviceID2, weights, 0);
		int oID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		int inputID1 = GPU.prepareBuf(iID1, dimensions);
		int weightsID1 = GPU.prepareBuf(wID1, dimensions2);
		int outputID1 = GPU.prepareBuf(oID1, dimensions);

		int inputID2 = GPU.prepareBuf(iID2, dimensions);
		int weightsID2 = GPU.prepareBuf(wID2, dimensions2);
		int outputID2 = GPU.prepareBuf(oID2, dimensions);

		// int inputID1c = GPU.cloneFloatBuf(inputID1, deviceID1);
		// checkError( GPU.copyFloatBuf( inputID2, inputID1 ) );

		// checkError( GPU.logMessage( "Test message".toCharArray() ) );

		/* prepare kernels */
//		int kernelID1 = GPU.weightedSum( deviceID1, inputID1, weightsID1, outputID1, WeightedSum_inputRowStep );
//		int kernelID2 = GPU.weightedSum( deviceID2, inputID2, weightsID2, outputID2, WeightedSum_inputRowStep );

//		int kernelID1 = GPU.weightedSumN( deviceID1, inputID1, weightsID1, outputID1, WeightedSum_inputRowStep,
//		5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 );

		int kernelID1 = GPU.weightedSum(deviceID1, inputID1, weightsID1, outputID1, 3,
				WeightedSum_miniBatchSize, WeightedSum_inputStartPosition, WeightedSum_inputRowStep,
				WeightedSum_inputColumnStep, WeightedSum_outputStartPosition, WeightedSum_outputRowStep,
				WeightedSum_outputColumnStep, WeightedSum_weightsStartPosition, WeightedSum_weightsSize,
				WeightedSum_weightsInitialStep, WeightedSum_weightsStep, false);

		int kernelID2 = GPU.weightedSum(deviceID2, inputID2, weightsID2, outputID2, 3,
				WeightedSum_miniBatchSize, WeightedSum_inputStartPosition, WeightedSum_inputRowStep,
				WeightedSum_inputColumnStep, WeightedSum_outputStartPosition, WeightedSum_outputRowStep,
				WeightedSum_outputColumnStep, WeightedSum_weightsStartPosition, WeightedSum_weightsSize,
				WeightedSum_weightsInitialStep, WeightedSum_weightsStep, false);

		/* run kernels */
		String job = kernelID1 + "  " + kernelID2 + // async start 2 kernels
				" !" + kernelID1 + " !" + kernelID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		// checkError( GPU.kernelRunAsync( kernelID1 ) ); // push job to device1
		// checkError( GPU.kernelRunAsync( kernelID2 ) ); // push job to device2

		/* waiting for kernels' finishing */
		// do{} while ( ( GPU.kernelState( kernelID1 ) != 0 ) || ( GPU.kernelState( kernelID2 ) != 0 ));

		/* get results */
		checkError(GPU.getFloatBuf(outputID1, output1));
		checkError(GPU.getFloatBuf(outputID2, output2));

		System.out.println("");

		int indx = 1;
//		int id   = 0;
		float zr = 0;
		for (int id = 0; id < WeightedSum_outputRowStep; id++)
		{
			zr = 0;
			int inputStartIndex = 0;
			int outputStartIndex = WeightedSum_outputStartPosition + id * WeightedSum_outputColumnStep;
			int weightStartIndex = WeightedSum_weightsStartPosition + id * WeightedSum_weightsInitialStep;
			for (int i = 0; i < WeightedSum_miniBatchSize; i++)
			{
				// each connection (of the combined connections)
				zr = output3[outputStartIndex + i * WeightedSum_outputRowStep];
				// each element in the row/column

				inputStartIndex = WeightedSum_inputStartPosition + i * WeightedSum_inputRowStep;
				for (int j = 0; j < WeightedSum_weightsSize; j++)
				{
					zr += input[inputStartIndex + j * WeightedSum_inputColumnStep] *
							weights[weightStartIndex + j * WeightedSum_weightsStep];
				}

				output3[outputStartIndex + i * WeightedSum_outputRowStep] = zr;
			}
		}
		int id = 0;

		for (int i = 0; i < output1.length; i++)
		{
			System.out.print(output1[i] + " ");
		}
		System.out.println("");

		System.out.print("weightedSum         result[" + indx + "] device1: " + output1[indx] +
				"          device2: " + output2[indx] + "         CPU: " + output3[indx] +
				"         ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
		{
			System.out.println("[CORRECT!]");
		}
		else
		{
			System.out.println("[ERROR!]");
		}

		/*
		 * ---------------------
		 * Sigmoid section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
		}

		/* prepare buffers */
		int ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		int ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
//		int ioaID1   = GPU.prepareBuf( ioID1, dimensions  );
//		int ioaID2   = GPU.prepareBuf( ioID2, dimensions  );

		int ioaID1 = ioID1;
		int ioaID2 = ioID2;

		/* prepare kernels */
		// int SigmoidID1 = GPU.Sigmoid(deviceID1, ioaID1, 10);
		// int SigmoidID2 = GPU.Sigmoid(deviceID2, ioaID2, 10);

		int SigmoidID1 = GPU.Sigmoid(deviceID1, ioaID1, 10, Sigmoid_startIndex);
		int SigmoidID2 = GPU.Sigmoid(deviceID2, ioaID2, 10, Sigmoid_startIndex);

		job = SigmoidID1 + "  " + SigmoidID2 + // async start 2 kernels
				" !" + SigmoidID1 + " !" + SigmoidID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = Sigmoid_startIndex; i < output3.length; i++)
		{
			output3[i] = (1 / (1 + (float) Math.exp(-output3[i])));
		}

		System.out.print("Sigmod              result[" + indx + "] device1: " + output1[indx] +
				"   device2: " + output2[indx] + "  CPU: " + output3[indx] + "  ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * Tanh section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		// int tanhID1 = GPU.Tanh(deviceID1, ioaID1, 10);
		// int tanhID2 = GPU.Tanh(deviceID2, ioaID2, 10);

		int tanhID1 = GPU.Tanh(deviceID1, ioaID1, 10, Tanh_startIndex);
		int tanhID2 = GPU.Tanh(deviceID2, ioaID2, 10, Tanh_startIndex);

		job = tanhID1 + "  " + tanhID2 + // async start 2 kernels
				" !" + tanhID1 + " !" + tanhID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = Tanh_startIndex; i < output3.length; i++)
		{
			output3[i] = (float) Math.tan(output3[i]); /// Why Math.tan?
		}

		System.out.print("Tanh                result[" + indx + "] device1: " + output1[indx] +
				"    device2: " + output2[indx] + "   CPU: " + output3[indx] + "   ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * ReLU section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = -0.5f;
			output2[i] = -0.5f;
			output3[i] = -0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		// int ReLUID1 = GPU.ReLU(deviceID1, ioaID1, 10);
		// int ReLUID2 = GPU.ReLU(deviceID2, ioaID2, 10);

		int ReLUID1 = GPU.ReLU(deviceID1, ioaID1, 10, ReLU_startIndex);
		int ReLUID2 = GPU.ReLU(deviceID2, ioaID2, 10, ReLU_startIndex);

		job = ReLUID1 + "  " + ReLUID2 + // async start 2 kernels
				" !" + ReLUID1 + " !" + ReLUID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = ReLU_startIndex; i < output3.length; i++)
		{
			output3[i] = Math.max(0, output3[i]);
		}

		System.out.print("ReLU                result[" + indx + "] device1: " + output1[indx] +
				"          device2: " + output2[indx] + "         CPU: " + output3[indx] +
				"         ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * SoftReLU section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		// int SoftReLUID1 = GPU.SoftReLU(deviceID1, ioaID1, 10);
		// int SoftReLUID2 = GPU.SoftReLU(deviceID2, ioaID2, 10);

		int SoftReLUID1 = GPU.SoftReLU(deviceID1, ioaID1, output1.length, SoftReLU_startIndex);
		int SoftReLUID2 = GPU.SoftReLU(deviceID2, ioaID2, output2.length, SoftReLU_startIndex);

		job = SoftReLUID1 + "  " + SoftReLUID2 + // async start 2 kernels
				" !" + SoftReLUID1 + " !" + SoftReLUID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = SoftReLU_startIndex; i < output3.length; i++)
		{
			output3[i] = (float) Math.log(1 + Math.exp(output3[i]));
		}

		System.out.print("SoftReLU            result[" + indx + "] device1: " + output1[indx] +
				"     device2: " + output2[indx] + "    CPU: " + output3[indx] + "    ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * ReLUDerivative section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
			activations[i] = 0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);
		int acID1 = GPU.prepareFloatArray(deviceID1, activations, 0);
		int acID2 = GPU.prepareFloatArray(deviceID2, activations, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);
		int actID1 = GPU.prepareBuf(acID1, dimensions);
		int actID2 = GPU.prepareBuf(acID2, dimensions);

		/* prepare kernels */
		// int DReLUID1 = GPU.ReLUDerivative(deviceID1, ioaID1, actID1, 10);
		// int DReLUID2 = GPU.ReLUDerivative(deviceID2, ioaID2, actID2, 10);

		int DReLUID1 = GPU.ReLUDerivative(deviceID1, ioaID1, actID1, 10,
				ReLUDerivative_activationsStartIndex, ReLUDerivative_resultStartIndex);
		int DReLUID2 = GPU.ReLUDerivative(deviceID2, ioaID2, actID2, 10,
				ReLUDerivative_activationsStartIndex, ReLUDerivative_resultStartIndex);

		job = DReLUID1 + "  " + DReLUID2 + // async start 2 kernels
				" !" + DReLUID1 + " !" + DReLUID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = ReLUDerivative_resultStartIndex; i < output3.length; i++)
		{
			if (activations[ReLUDerivative_activationsStartIndex] <= 0)
			{
				output3[i] = 0;
			}
		}

		System.out.print("ReLUDerivative      result[" + indx + "] device1: " + output1[indx] +
				"          device2: " + output2[indx] + "         CPU: " + output3[indx] +
				"         ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * ReLUDerivative section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
			activations[i] = -0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);
		acID1 = GPU.prepareFloatArray(deviceID1, activations, 0);
		acID2 = GPU.prepareFloatArray(deviceID2, activations, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);
		actID1 = GPU.prepareBuf(acID1, dimensions);
		actID2 = GPU.prepareBuf(acID2, dimensions);

		/* prepare kernels */
		// int TanhDID1 = GPU.TanhDerivative(deviceID1, ioaID1, actID1, 10);
		// int TanhDID2 = GPU.TanhDerivative(deviceID2, ioaID2, actID2, 10);

		int TanhDID1 = GPU.TanhDerivative(deviceID1, ioaID1, actID1, 10,
				TanhDerivative_activationsStartIndex, TanhDerivative_resultStartIndex);
		int TanhDID2 = GPU.TanhDerivative(deviceID2, ioaID2, actID2, 10,
				TanhDerivative_activationsStartIndex, TanhDerivative_resultStartIndex);

		job = TanhDID1 + "  " + TanhDID2 + // async start 2 kernels
				" !" + TanhDID1 + " !" + TanhDID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = TanhDerivative_resultStartIndex; i < output3.length; i++)
		{
			float activation = activations[TanhDerivative_activationsStartIndex + id];
			output3[i] = output3[i] * (1 - activation * activation);
		}

		System.out.print("TanhDerivative      result[" + indx + "] device1: " + output1[indx] +
				"        device2: " + output2[indx] + "       CPU: " + output3[indx] +
				"       ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * SigmoidDerivative section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
			activations[i] = -0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);
		acID1 = GPU.prepareFloatArray(deviceID1, activations, 0);
		acID2 = GPU.prepareFloatArray(deviceID2, activations, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);
		actID1 = GPU.prepareBuf(acID1, dimensions);
		actID2 = GPU.prepareBuf(acID2, dimensions);

		/* prepare kernels */
		// int SigDID1 = GPU.SigmoidDerivative(deviceID1, ioaID1, actID1, 10);
		// int SigDID2 = GPU.SigmoidDerivative(deviceID2, ioaID2, actID2, 10);

		int SigDID1 = GPU.SigmoidDerivative(deviceID1, ioaID1, actID1, 10,
				SigmoidDerivative_activationsStartIndex, SigmoidDerivative_resultStartIndex);
		int SigDID2 = GPU.SigmoidDerivative(deviceID2, ioaID2, actID2, 10,
				SigmoidDerivative_activationsStartIndex, SigmoidDerivative_resultStartIndex);

		job = SigDID1 + "  " + SigDID2 + // async start 2 kernels
				" !" + SigDID1 + " !" + SigDID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = SigmoidDerivative_resultStartIndex; i < output3.length; i++)
		{
			float activation = activations[SigmoidDerivative_activationsStartIndex + id];
			output3[i] = output3[i] * activation * (1 - activation);
		}

		System.out.print("SigmoidDerivative   result[" + indx + "] device1: " + output1[indx] +
				"       device2: " + output2[indx] + "      CPU: " + output3[indx] +
				"      ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * SoftReLUDerivative section
		 * ---------------------
		 */

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
			activations[i] = -0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);
		acID1 = GPU.prepareFloatArray(deviceID1, activations, 0);
		acID2 = GPU.prepareFloatArray(deviceID2, activations, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);
		actID1 = GPU.prepareBuf(acID1, dimensions);
		actID2 = GPU.prepareBuf(acID2, dimensions);

		/* prepare kernels */
		// int SReLUDID1 = GPU.SoftReLUDerivative(deviceID1, ioaID1, actID1, 10);
		// int SReLUDID2 = GPU.SoftReLUDerivative(deviceID2, ioaID2, actID2, 10);

		int SReLUDID1 = GPU.SoftReLUDerivative(deviceID1, ioaID1, actID1, 10,
				SoftReLUDerivative_activationsStartIndex, SoftReLUDerivative_resultStartIndex);
		int SReLUDID2 = GPU.SoftReLUDerivative(deviceID2, ioaID2, actID2, 10,
				SoftReLUDerivative_activationsStartIndex, SoftReLUDerivative_resultStartIndex);

		job = SReLUDID1 + "  " + SReLUDID2 + // async start 2 kernels
				" !" + SReLUDID1 + " !" + SReLUDID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		for (int i = SoftReLUDerivative_resultStartIndex; i < output3.length; i++)
		{
			output3[i] = output3[i] * (1 / (1 +
					(float) Math.exp(-activations[i + SoftReLUDerivative_activationsStartIndex])));
		}

		System.out.print("SoftReLUDerivative  result[" + indx + "] device1: " + output1[indx] +
				"   device2: " + output2[indx] + "  CPU: " + output3[indx] +
				"  ");
		if ((output1[indx] == output3[indx]) && (output2[indx] == output3[indx]))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * prng section
		 * ---------------------
		 */

		checkError(GPU.initPRNG(deviceID1, 10, 7)); // prepare 10 PRNGs, series # 7
		checkError(GPU.initPRNG(deviceID2, 10, 7)); // prepare 10 PRNGs, series # 7

		/*
		 * ---------------------
		 * prng subsection
		 * ---------------------
		 */

		checkError(GPU.prngRestart(deviceID1)); // just restart the prng (actually do not required)
		checkError(GPU.prngRestart(deviceID2)); // just restart the prng (actually do not required)

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0;
			output2[i] = 0;
			output3[i] = 0;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		int prngID1 = GPU.prng(deviceID1, ioaID1, 10);
		int prngID2 = GPU.prng(deviceID2, ioaID2, 10);

		job = prngID1 + "  " + prngID2 + // async start 2 kernels
				" !" + prngID1 + " !" + prngID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		zr = 0.6806975f;
		System.out.print("prng                result[" + indx + "] device1: " + output1[indx] +
				"    device2: " + output2[indx] + "   CPU: " + zr +
				"   ");
		if ((output1[indx] == zr) && (output2[indx] == zr))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * prngGaussian section
		 * ---------------------
		 */

		/* prng initialization is performed in previous section */
		// checkError( GPU.initPRNG( deviceID1, 10, 7 ) ); // prepare 10 PRNGs, series # 7
		// checkError( GPU.initPRNG( deviceID2, 10, 7 ) ); // prepare 10 PRNGs, series # 7

		checkError(GPU.prngRestart(deviceID1)); // just restart the prng (actually do not required)
		checkError(GPU.prngRestart(deviceID2)); // just restart the prng (actually do not required)

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0;
			output2[i] = 0;
			output3[i] = 0;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		int prngGaussianID1 = GPU.prngGaussian(deviceID1, ioaID1, 10);
		int prngGaussianID2 = GPU.prngGaussian(deviceID2, ioaID2, 10);

		job = prngGaussianID1 + "  " + prngGaussianID2 + // async start 2 kernels
				" !" + prngGaussianID1 + " !" + prngGaussianID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		{ // calculate next prn with Gaussian distribution
			float v1 = 0.361395f; // 1st prn (0.053564638f)
			float v2 = 0.28899777f; // 2nd prn (0.93228686f)
			float s = v1 * v1 + v2 * v2;
			zr = v1 * (float) Math.sqrt(-2 * (float) Math.log(s) / s);
		}
		System.out.print("prngGaussian        result[" + indx + "] device1: " + output1[indx] +
				"    device2: " + output2[indx] + "   CPU: " + zr +
				"   ");
		if ((output1[indx] == zr) && (output2[indx] == zr))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * Noise section
		 * ---------------------
		 */

		/* prng initialization is performed in previous section */
		// checkError( GPU.initPRNG( deviceID1, 10, 7 ) ); // prepare 10 PRNGs, series # 7
		// checkError( GPU.initPRNG( deviceID2, 10, 7 ) ); // prepare 10 PRNGs, series # 7

		checkError(GPU.prngRestart(deviceID1)); // just restart the prng (actually do not required)
		checkError(GPU.prngRestart(deviceID2)); // just restart the prng (actually do not required)

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.1f;
			output2[i] = 0.1f;
			output3[i] = 0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.cloneFloatBuf(ioID1, deviceID2); // clone buffer from deviceID1 into deviceID2
//		ioID2 = GPU.prepareFloatArray( deviceID2, output2, 0 );

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		// int NoiseID1 = GPU.Noise(deviceID1, ioaID1, 10);
		// int NoiseID2 = GPU.Noise(deviceID2, ioaID2, 10);

		int NoiseID1 = GPU.Noise(deviceID1, ioaID1, 10, Noise_startIndex,
				Noise_corruptionLevel, Noise_corruptedValue);
		int NoiseID2 = GPU.Noise(deviceID2, ioaID2, 10, Noise_startIndex,
				Noise_corruptionLevel, Noise_corruptedValue);

		/* update values in the local arrays */
//		for ( int i = 0; i < output1.length; i++ )
//		{
//			output1[i] = 0.5f;
//			output2[i] = 0.5f;
//		}

		/* update buffers */
//		checkError( GPU.updateFloatBuf( ioaID1, output1 ) );
//		checkError( GPU.updateFloatBuf( ioaID2, output2 ) );

		job = NoiseID1 + "  " + NoiseID2 + // async start 2 kernels
				" !" + NoiseID1 + " !" + NoiseID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
// checkError( GPU.copyFloatBuf( ioaID1, ioaID2 ) ); // copy results from ioaID1 into ioaID2
		checkError(GPU.getFloatBuf(ioaID2, output2));

//		for( int i = 0; i < output1.length; i++ )
//		{
//			System.out.print( output1[i] + " " );
//		}
//		System.out.println("");

		zr = 0.1f; // here prng = 0.735259
		System.out.print("Noise               result[" + indx + "] device1: " + output1[indx] +
				"          device2: " + output2[indx] + "         CPU: " + zr +
				"         ");
		if ((output1[indx] == zr) && (output2[indx] == zr))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * BernoulliKernel section
		 * ---------------------
		 */

		/* prng initialization is performed in previous section */
		// checkError( GPU.initPRNG( deviceID1, 10, 7 ) ); // prepare 10 PRNGs, series # 7
		// checkError( GPU.initPRNG( deviceID2, 10, 7 ) ); // prepare 10 PRNGs, series # 7

		checkError(GPU.prngRestart(deviceID1)); // just restart the prng (actually do not required)
		checkError(GPU.prngRestart(deviceID2)); // just restart the prng (actually do not required)

		for (int i = 0; i < output1.length; i++)
		{
			output1[i] = 0.5f;
			output2[i] = 0.5f;
			output3[i] = 0.5f;
		}

		/* prepare buffers */
		ioID1 = GPU.prepareFloatArray(deviceID1, output1, 0);
		ioID2 = GPU.prepareFloatArray(deviceID2, output2, 0);

		/* prepare arrays */
		ioaID1 = GPU.prepareBuf(ioID1, dimensions);
		ioaID2 = GPU.prepareBuf(ioID2, dimensions);

		/* prepare kernels */
		int BKID1 = GPU.BernoulliKernel(deviceID1, ioaID1, 10);
		int BKID2 = GPU.BernoulliKernel(deviceID2, ioaID2, 10);

		job = BKID1 + "  " + BKID2 + // async start 2 kernels
				" !" + BKID1 + " !" + BKID2; // wait for kernels finish
		checkError(GPU.kernelRunJob(job.toCharArray())); // push jobs to devices

		/* get results */
		checkError(GPU.getFloatBuf(ioaID1, output1));
		checkError(GPU.getFloatBuf(ioaID2, output2));

		zr = (output3[indx] > 0.735259) ? 1 : 0; // here prng = 0.735259
		System.out.print("BernoulliKernel     result[" + indx + "] device1: " + output1[indx] +
				"          device2: " + output2[indx] + "         CPU: " + zr +
				"         ");
		if ((output1[indx] == zr) && (output2[indx] == zr))
			System.out.println("[CORRECT!]");
		else
			System.out.println("[ERROR!]");

		/*
		 * ---------------------
		 * conv2DFF section
		 * ---------------------
		 */

		for (int i = 0; i < 32; i++)
		{
			if (i < 19)
			{
				input[i] = (i + 1);
			}
			else
			{
				input[i] = 0;
			}
		}

//		weights[0]=1;	weights[1]=2;	weights[2]=3;	weights[3]=4;
//		weights[4]=1;	weights[5]=2;	weights[6]=3;	weights[7]=4;

//		int ciID1 = GPU.prepareFloatArray( deviceID1, input,   0 );
//		int cwID1 = GPU.prepareFloatArray( deviceID1, weights, 0 );
//		int coID1 = GPU.prepareFloatArray( deviceID1, output1, 0 );

//		int ciID2 = GPU.prepareFloatArray( deviceID2, input,   0 );
//		int cwID2 = GPU.prepareFloatArray( deviceID2, weights, 0 );
//		int coID2 = GPU.prepareFloatArray( deviceID2, output2, 0 );

//		int[] featureMapOffsets = new int[10];
//		int fID1 = GPU.prepareIntConstArray( deviceID1, featureMapOffsets, 0 );

		/*
		 * ---------------------
		 * Finalization section
		 * ---------------------
		 */

		checkError(GPU.finalizeDeviceAll());

		System.out.println("");
		System.out.println("_[DONE]_");
	}

	public static void checkError(int result)
	{
		if (result != 0)
		{
			System.out.println("[ERROR!] " + result);
		}
	}

	public static int getSize(int[] dimensions)
	{
		int inputSize = 1;
		for (int i = 0; i < dimensions.length; i++)
		{
			if (dimensions[i] > 0)
			{
				inputSize *= dimensions[i];
			}
		}

		return inputSize;
	}
}


text:
import datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models

class Migration(DataMigration):

    def forwards(self, orm):
        "Write your forwards methods here."
        # Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
        for enterprise in orm['enterprise.Enterprise'].objects.all():
            balance = 0
            for transaction in enterprise.transaction_set.order_by('when_irl').all():
                balance = balance + transaction.amount
                transaction.balance = balance
                transaction.save()

    def backwards(self, orm):
        "Write your backwards methods here."

    models = {
        u'auth.group': {
            'Meta': {'object_name': 'Group'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
        },
        u'auth.permission': {
            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
        },
        u'auth.user': {
            'Meta': {'object_name': 'User'},
            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
        },
        u'contenttypes.contenttype': {
            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
        },
        u'enterprise.actionrecord': {
            'Meta': {'ordering': "['-when_irl']", 'object_name': 'ActionRecord'},
            'description': ('django.db.models.fields.TextField', [], {}),
            'enterprise': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['enterprise.Enterprise']"}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'when_igt': ('django.db.models.fields.DateTimeField', [], {}),
            'when_irl': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
        },
        u'enterprise.enterprise': {
            'Meta': {'object_name': 'Enterprise'},
            'created_igt': ('django.db.models.fields.DateTimeField', [], {}),
            'created_irl': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'mode': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'owners': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.User']", 'symmetrical': 'False'}),
            'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '200'}),
            'start_cash': ('django.db.models.fields.IntegerField', [], {}),
            'universe': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['enterprise.Universe']"})
        },
        u'enterprise.transaction': {
            'Meta': {'ordering': "['-when_irl']", 'object_name': 'Transaction'},
            'acc_type': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'amount': ('django.db.models.fields.IntegerField', [], {}),
            'balance': ('django.db.models.fields.IntegerField', [], {}),
            'details': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
            'enterprise': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['enterprise.Enterprise']"}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'when_igt': ('django.db.models.fields.DateTimeField', [], {}),
            'when_irl': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'})
        },
        u'enterprise.universe': {
            'Meta': {'object_name': 'Universe'},
            'current_time': ('django.db.models.fields.DateTimeField', [], {}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'mode': ('django.db.models.fields.CharField', [], {'max_length': '50'})
        }
    }

    complete_apps = ['enterprise']
    symmetrical = True

redpajama_set_name: RedPajamaGithub


text:
package org.folio.okapi.discovery;

import io.vertx.core.Handler;
import io.vertx.core.Vertx;
import io.vertx.core.http.HttpClient;
import io.vertx.core.http.HttpClientRequest;
import io.vertx.core.json.Json;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.spi.cluster.ClusterManager;
import io.vertx.core.spi.cluster.NodeListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.folio.okapi.bean.DeploymentDescriptor;
import org.folio.okapi.bean.HealthDescriptor;
import org.folio.okapi.bean.NodeDescriptor;
import org.folio.okapi.bean.LaunchDescriptor;
import org.folio.okapi.bean.ModuleDescriptor;
import org.folio.okapi.service.ModuleManager;
import static org.folio.okapi.common.ErrorType.*;
import org.folio.okapi.common.ExtendedAsyncResult;
import org.folio.okapi.common.Failure;
import org.folio.okapi.util.LockedTypedMap;
import org.folio.okapi.common.Success;
import org.folio.okapi.common.OkapiClient;

/**
 * Keeps track of which modules are running where.
 * Uses a shared map to list running modules on the different nodes.
 * Maps a SrvcId to a DeploymentDescpriptor. Can also invoke deployment
 * and record the result in its map.
 */
public class DiscoveryManager implements NodeListener {

  private final Logger logger = LoggerFactory.getLogger("okapi");

  LockedTypedMap<DeploymentDescriptor> deployments = new LockedTypedMap<>(DeploymentDescriptor.class);
  LockedTypedMap<NodeDescriptor> nodes = new LockedTypedMap<>(NodeDescriptor.class);
  Vertx vertx;
  private ClusterManager clusterManager;
  private ModuleManager moduleManager;

  private final int delay = 10; // ms in recursing for retry of map
  private HttpClient httpClient;

  public void init(Vertx vertx, Handler<ExtendedAsyncResult<Void>> fut) {
    this.vertx = vertx;
    this.httpClient = vertx.createHttpClient();
    deployments.init(vertx, "discoveryList", res1 -> {
      if (res1.failed()) {
        fut.handle(new Failure<>(res1.getType(), res1.cause()));
      } else {
        nodes.init(vertx, "discoveryNodes", res2 -> {
          if (res2.failed()) {
            fut.handle(new Failure<>(res2.getType(), res2.cause()));
          } else {
            fut.handle(new Success<>());
          }
        });
      }
    });
  }

  public void setClusterManager(ClusterManager mgr) {
    this.clusterManager = mgr;
    mgr.nodeListener(this);
  }

  public void setModuleManager(ModuleManager mgr) {
    this.moduleManager = mgr;
  }

  public void add(DeploymentDescriptor md, Handler<ExtendedAsyncResult<Void>> fut) {
    final String srvcId = md.getSrvcId();
    if (srvcId == null) {
      fut.handle(new Failure<>(USER, "Needs srvc"));
      return;
    }
    final String instId = md.getInstId();
    if (instId == null) {
      fut.handle(new Failure<>(USER, "Needs instId"));
      return;
    }
    deployments.add(srvcId, instId, md, fut);
  }

  /**
   * Adds a service to the discovery, and optionally deploys it too.
   *
   *   1: We have launchDescriptor and NodeId: Deploy on that node.
   *   2: NodeId, but no launchDescriptor: Fetch the module, use its launchdesc, and deploy.
   *   3: No nodeId: Do not deploy at all, just record the existence (URL and instId) of the module.
   */
  public void addAndDeploy(DeploymentDescriptor dd, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut) {
    logger.info("addAndDeploy: " + Json.encodePrettily(dd));
    final String srvcId = dd.getSrvcId();
    if (srvcId == null) {
      fut.handle(new Failure<>(USER, "Needs srvcId"));
      return;
    }
    LaunchDescriptor launchDesc = dd.getDescriptor();
    final String nodeId = dd.getNodeId();
    if (launchDesc == null && nodeId == null) { // 3:already deployed
      final String instId = dd.getInstId();
      if (instId == null) {
        fut.handle(new Failure<>(USER, "Needs instId"));
        return;
      }
      deployments.add(srvcId, instId, dd, res -> { // just add it
        if (res.failed()) {
          fut.handle(new Failure<>(res.getType(), res.cause()));
        } else {
          fut.handle(new Success<>(dd));
        }
      });
    } else if (nodeId == null) {
      fut.handle(new Failure<>(USER, "missing nodeId"));
    } else {
      if ( launchDesc == null ) { // 2: get module
        if ( moduleManager == null) {
          fut.handle(new Failure<>(INTERNAL, "no module manager (should not happen)"));
          return;
        }
        String modId = dd.getSrvcId();
        if (modId == null || modId.isEmpty()) {
          fut.handle(new Failure<>(USER, "Needs srvcId"));
          return;
        }
        ModuleDescriptor md = moduleManager.get(modId);
        if (md == null) {
          fut.handle(new Failure<>(NOT_FOUND, "Module " + modId + " not found"));
          return;
        }
        launchDesc = md.getLaunchDescriptor();
        if (launchDesc == null) {
          fut.handle(new Failure<>(USER, "Module " + modId + " has no launchDescriptor"));
          return;
        }
        dd.setDescriptor(launchDesc);
      }
      getNode(nodeId, noderes -> {
        if (noderes.failed()) {
          fut.handle(new Failure<>(noderes.getType(), noderes.cause()));
        } else {
          OkapiClient ok = new OkapiClient(noderes.result().getUrl(), vertx, null);
          String reqdata = Json.encode(dd);
          logger.warn("Dm: about to POST " + reqdata);
          ok.post("/_/deployment/modules", reqdata, okres-> {
            if ( okres.failed()) {
              logger.warn("Dm: Failure: " + okres.getType() + " " + okres.cause().getMessage() );
              fut.handle(new Failure<>(okres.getType(),okres.cause().getMessage()));
            } else {
                DeploymentDescriptor pmd = Json.decodeValue(okres.result(),
                        DeploymentDescriptor.class);
                fut.handle(new Success<>(pmd));
            }
          });
        }
      });
    }
  }

  public void removeAndUndeploy(String srvcId, String instId, Handler<ExtendedAsyncResult<Void>> fut) {
    logger.info("removeAndUndeploy: srvcId " + srvcId + " instId " + instId);
    deployments.get(srvcId, instId, res -> {
      if (res.failed()) {
        logger.warn("deployment.get failed");
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        DeploymentDescriptor md = res.result();
        if (md.getDescriptor() == null) {
          remove(srvcId, instId, fut);
        } else {
          final String nodeId = md.getNodeId();
          getNode(nodeId, res1 -> {
            if (res1.failed()) {
              fut.handle(new Failure<>(res1.getType(), res1.cause()));
            } else {
              OkapiClient ok = new OkapiClient(res1.result().getUrl(), vertx, null);
              logger.warn("Dm: about to DELETE " + instId);
              ok.delete("/_/deployment/modules/" + instId, okres-> {
                if ( okres.failed()) {
                  logger.warn("Dm: Failure: " + okres.getType() + " " + okres.cause().getMessage() );
                  fut.handle(new Failure<>(okres.getType(),okres.cause().getMessage()));
                } else {
                    fut.handle(new Success<>());
                }
              });
            }
          });
        }
      }
    });
  }

  public void remove(String srvcId, String instId, Handler<ExtendedAsyncResult<Void>> fut) {
    deployments.remove(srvcId, instId, res -> {
      if (res.failed()) {
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        fut.handle(new Success<>());
      }
    });
  }

  void get(String srvcId, String instId, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut) {
    deployments.get(srvcId, instId, resGet -> {
      if (resGet.failed()) {
        fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
      } else {
        DeploymentDescriptor md = resGet.result();
        if (clusterManager != null) {
          if (!clusterManager.getNodes().contains(md.getNodeId())) {
            fut.handle(new Failure<>(NOT_FOUND, "gone"));
            return;
          }
        }
        fut.handle(new Success<>(md));
      }
    });
  }

  /**
   * Get the list for one srvcId. May return an empty list
   */
  public void get(String srvcId, Handler<ExtendedAsyncResult<List<DeploymentDescriptor>>> fut) {
    deployments.get(srvcId, res -> {
      if (res.failed()) {
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        List<DeploymentDescriptor> result = res.result();
        Iterator<DeploymentDescriptor> it = result.iterator();
        while (it.hasNext()) {
          DeploymentDescriptor md = it.next();
          if (clusterManager != null) {
            if (!clusterManager.getNodes().contains(md.getNodeId())) {
              it.remove();
            }
          }
        }
        fut.handle(new Success<>(result));
      }
    });
  }

  /**
   * Get all known DeploymentDescriptors (all services on all nodes).
   */
  public void get(Handler<ExtendedAsyncResult<List<DeploymentDescriptor>>> fut) {
    deployments.getKeys(resGet -> {
      if (resGet.failed()) {
        logger.warn("DiscoveryManager:get all: " + resGet.getType().name());
        fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
      } else {
        Collection<String> keys = resGet.result();
        List<DeploymentDescriptor> all = new LinkedList<>();
        if (keys == null || keys.isEmpty()) {
          fut.handle(new Success<>(all));
        } else {
          Iterator<String> it = keys.iterator();
          getAll_r(it, all, fut);
        }
      }
    });
  }

  void getAll_r(Iterator<String> it, List<DeploymentDescriptor> all,
          Handler<ExtendedAsyncResult<List<DeploymentDescriptor>>> fut) {
    if (!it.hasNext()) {
      fut.handle(new Success<>(all));
    } else {
      String srvcId = it.next();
      this.get(srvcId, resGet -> {
        if (resGet.failed()) {
          fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
        } else {
          List<DeploymentDescriptor> dpl = resGet.result();
          all.addAll(dpl);
          getAll_r(it, all, fut);
        }
      });
    }
  }
  private void health(DeploymentDescriptor md, Handler<ExtendedAsyncResult<HealthDescriptor>> fut) {
    HealthDescriptor hd = new HealthDescriptor();
    String url = md.getUrl();
    hd.setInstId(md.getInstId());
    hd.setSrvcId(md.getSrvcId());
    if (url == null || url.length() == 0) {
      hd.setHealthMessage("Unknown");
      hd.setHealthStatus(false);
      fut.handle(new Success<>(hd));
    } else {
      HttpClientRequest req = httpClient.getAbs(url, res -> {
        res.endHandler(res1 -> {
          hd.setHealthMessage("OK");
          hd.setHealthStatus(true);
          fut.handle(new Success<>(hd));
        });
        res.exceptionHandler(res1 -> {
          hd.setHealthMessage("Fail: " + res1.getMessage());
          hd.setHealthStatus(false);
          fut.handle(new Success<>(hd));
        });
      });
      req.exceptionHandler(res -> {
        hd.setHealthMessage("Fail: " + res.getMessage());
        hd.setHealthStatus(false);
        fut.handle(new Success<>(hd));
      });
      req.end();
    }
  }

  private void healthR(Iterator<DeploymentDescriptor> it, List<HealthDescriptor> all,
          Handler<ExtendedAsyncResult<List<HealthDescriptor>>> fut) {
    if (!it.hasNext()) {
      fut.handle(new Success<>(all));
    } else {
      DeploymentDescriptor md = it.next();
      health(md, res -> {
        if (res.failed()) {
          fut.handle(new Failure<>(res.getType(), res.cause()));
        } else {
          all.add(res.result());
          healthR(it, all, fut);
        }
      });
    }
  }

  public void health(Handler<ExtendedAsyncResult<List<HealthDescriptor>>> fut) {
    get(res -> {
      if (res.failed()) {
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        Iterator<DeploymentDescriptor> it = res.result().iterator();
        List<HealthDescriptor> all = new ArrayList<>();
        healthR(it, all, fut);
      }
    });
  }

  public void health(String srvcId, String instId, Handler<ExtendedAsyncResult<HealthDescriptor>> fut) {
    get(srvcId, instId, res -> {
      if (res.failed()) {
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        health(res.result(), fut);
      }
    });
  }

  public void health(String srvcId, Handler<ExtendedAsyncResult<List<HealthDescriptor>>> fut) {
    get(srvcId, res -> {
      if (res.failed()) {
        fut.handle(new Failure<>(res.getType(), res.cause()));
      } else {
        Iterator<DeploymentDescriptor> it = res.result().iterator();
        List<HealthDescriptor> all = new ArrayList<>();
        healthR(it, all, fut);
      }
    });
  }

  public void addNode(NodeDescriptor nd, Handler<ExtendedAsyncResult<Void>> fut) {
    if (clusterManager != null) {
      nd.setNodeId(clusterManager.getNodeID());
    }
    nodes.put(nd.getNodeId(), "a", nd, fut);
  }

  private void removeNode(NodeDescriptor nd, Handler<ExtendedAsyncResult<Boolean>> fut) {
    nodes.remove(nd.getNodeId(), "a", fut);
  }

  void getNodes_r(Iterator<String> it, List<NodeDescriptor> all,
          Handler<ExtendedAsyncResult<List<NodeDescriptor>>> fut) {
    if (!it.hasNext()) {
      fut.handle(new Success<>(all));
    } else {
      String srvcId = it.next();
      getNode(srvcId, resGet -> {
        if (resGet.failed()) {
          fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
        } else {
          NodeDescriptor dpl = resGet.result();
          all.add(dpl);
          getNodes_r(it, all, fut);
        }
      });
    }
  }

  public void getNode(String nodeId, Handler<ExtendedAsyncResult<NodeDescriptor>> fut) {
    if (clusterManager != null) {
      List<String> n = clusterManager.getNodes();
      if (!n.contains(nodeId)) {
        fut.handle(new Failure<>(NOT_FOUND, nodeId));
        return;
      }
    }
    nodes.get(nodeId, "a", fut);
  }

  public void getNodes(Handler<ExtendedAsyncResult<List<NodeDescriptor>>> fut) {
    nodes.getKeys(resGet -> {
      if (resGet.failed()) {
        logger.warn("DiscoveryManager:get all: " + resGet.getType().name());
        fut.handle(new Failure<>(resGet.getType(), resGet.cause()));
      } else {
        Collection<String> keys = resGet.result();
        if (clusterManager != null) {
          List<String> n = clusterManager.getNodes();
          keys.retainAll(n);
        }
        List<NodeDescriptor> all = new LinkedList<>();
        if (keys == null || keys.isEmpty()) {
          fut.handle(new Success<>(all));
        } else {
          getNodes_r(keys.iterator(), all, fut);
        }
      }
    });
  }

  @Override
  public void nodeAdded(String nodeID) {
  }

  @Override
  public void nodeLeft(String nodeID) {
    nodes.remove(nodeID, "a", res -> {
      logger.info("node.remove " + nodeID + " result=" + res.result());
    });
  }
}


text:
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateHostingTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('hosting', function(Blueprint $table)
		{
      $table->engine = 'InnoDB';
			$table->increments('id');
      $table->string('uid', 16);
      $table->string('server', 16);
      $table->string('label');
      $table->string('disk');       //used
      $table->string('bandwidth');  //used
      $table->string('domain');     //list
      $table->string('mysql');      //user or 0
      $table->string('ftp');        //user or 0
      $table->string('htaccess');   //htaccess id
      $table->string('phpver');     //php version
      $table->string('status');
			$table->timestamps();
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('hosting');
	}

}


text:
HGLRC opengl_wglCreateContext(HDC dc) {
   return wglCreateContext(dc);
   }

BOOL  opengl_wglDeleteContext(HGLRC hglrc) {
   return wglDeleteContext(hglrc);
   }

HGLRC opengl_wglGetCurrentContext(void) {
   return wglGetCurrentContext();
   }

BOOL  opengl_wglMakeCurrent(HDC dc,HGLRC hglrc) {
   return wglMakeCurrent(dc,hglrc);
   }

PROC  opengl_wglGetProcAddress(LPCSTR name){
   return wglGetProcAddress(name);
   }

BOOL opengl_wglShareLists(HGLRC hglrc1,HGLRC hglrc2) {
   return wglShareLists(hglrc1,hglrc2);
}

void  opengl_glReadBuffer(GLenum mode) {
   glReadBuffer(mode);
}

void opengl_glGetIntegerv(GLenum pname,GLint *params) {
   glGetIntegerv(pname,params);
}

void  opengl_glDrawBuffer(GLenum mode) {
   glDrawBuffer(mode);
}

void opengl_glReadPixels(GLint x,GLint y,GLsizei width,GLsizei height,GLenum format,GLenum type,GLvoid *pixels) {
   glReadPixels(x,y,width,height,format,type,pixels);
}

bool opengl_hasPixelBufferObject(){

   if(wglGetProcAddress("glGenBuffersARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glBindBufferARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glBufferDataARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glBufferSubDataARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glDeleteBuffersARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glGetBufferParameterivARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glMapBufferARB")==NULL)
    return FALSE;

   if(wglGetProcAddress("glUnmapBufferARB")==NULL)
    return FALSE;

   return TRUE;
}

void opengl_glGenBuffers(GLsizei n,GLuint *buffers) {
   PFNGLGENBUFFERSARBPROC function=(PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffersARB");
   function(n,buffers);
}

void opengl_glBindBuffer(GLenum target,GLuint buffer) {
   PFNGLBINDBUFFERARBPROC function=(PFNGLBINDBUFFERARBPROC)wglGetProcAddress("glBindBufferARB");
   function(target,buffer);
}

void opengl_glBufferData(GLenum target,GLsizeiptr size,const GLvoid *bytes,GLenum usage) {
   PFNGLBUFFERDATAARBPROC function=(PFNGLBUFFERDATAARBPROC)wglGetProcAddress("glBufferDataARB");
   function(target,size,bytes,usage);
}

void opengl_glBufferSubData(GLenum target,GLsizeiptr offset,GLsizeiptr size,const GLvoid *bytes) {
   PFNGLBUFFERSUBDATAARBPROC function=(PFNGLBUFFERSUBDATAARBPROC)wglGetProcAddress("glBufferSubDataARB");
   function(target,offset,size,bytes);
}

void opengl_glDeleteBuffers(GLsizei n,const GLuint *buffers) {
   PFNGLDELETEBUFFERSARBPROC function=(PFNGLDELETEBUFFERSARBPROC)wglGetProcAddress("glDeleteBuffersARB");
   function(n,buffers);
}

void opengl_glGetBufferParameteriv(GLenum target,GLenum value,GLint *data) {
   PFNGLGETBUFFERPARAMETERIVARBPROC function=(PFNGLGETBUFFERPARAMETERIVARBPROC)wglGetProcAddress("glGetBufferParameterivARB");
   function(target,value,data);
}

GLvoid *opengl_glMapBuffer(GLenum target,GLenum access) {
    PFNGLMAPBUFFERARBPROC function=(PFNGLMAPBUFFERARBPROC)wglGetProcAddress("glMapBufferARB");
   return function(target,access);
}

GLboolean opengl_glUnmapBuffer(GLenum target) {
   PFNGLUNMAPBUFFERARBPROC function=(PFNGLUNMAPBUFFERARBPROC)wglGetProcAddress("glUnmapBufferARB");
   return function(target);
}

const char *opengl_wglGetExtensionsStringARB(HDC hdc) {
   APIENTRY typeof(opengl_wglGetExtensionsStringARB) *function=(typeof(function))wglGetProcAddress("wglGetExtensionsStringARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglGetExtensionsStringARB) failed");
    return NULL;
   }

   return function(hdc);
}

const char *opengl_wglGetExtensionsStringEXT(HDC hdc) {
   APIENTRY typeof(opengl_wglGetExtensionsStringEXT) *function=(typeof(function))wglGetProcAddress("wglGetExtensionsStringEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglGetExtensionsStringEXT) failed");
    return NULL;
   }

   return function(hdc);
}

HPBUFFERARB opengl_wglCreatePbufferARB(HDC hDC,int iPixelFormat,int iWidth,int iHeight,const int *piAttribList) {
   APIENTRY typeof(opengl_wglCreatePbufferARB) *function=(typeof(function))wglGetProcAddress("wglCreatePbufferARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglCreatePbufferARB) failed");
    return NULL;
   }

   return function(hDC,iPixelFormat,iWidth,iHeight,piAttribList);
}

HDC  opengl_wglGetPbufferDCARB(HPBUFFERARB hPbuffer) {
   APIENTRY typeof(opengl_wglGetPbufferDCARB) *function=(typeof(function))wglGetProcAddress("wglGetPbufferDCARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglGetPbufferDCARB) failed");
    return NULL;
   }

   return function(hPbuffer);
}

int  opengl_wglReleasePbufferDCARB(HPBUFFERARB hPbuffer,HDC hDC) {
   APIENTRY typeof(opengl_wglReleasePbufferDCARB) *function=(typeof(function))wglGetProcAddress("wglReleasePbufferDCARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglReleasePbufferDCARB) failed");
    return 0;
   }

   return function(hPbuffer,hDC);
}

BOOL opengl_wglDestroyPbufferARB(HPBUFFERARB hPbuffer) {
   APIENTRY typeof(opengl_wglDestroyPbufferARB) *function=(typeof(function))wglGetProcAddress("wglDestroyPbufferARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglDestroyPbufferARB) failed");
    return NO;
   }

   return function(hPbuffer);
}

BOOL opengl_wglQueryPbufferARB(HPBUFFERARB hPbuffer,int iAttribute,int *piValue) {
   APIENTRY typeof(opengl_wglQueryPbufferARB) *function=(typeof(function))wglGetProcAddress("wglQueryPbufferARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglQueryPbufferARB) failed");
    return NO;
   }

   return function(hPbuffer,iAttribute,piValue);
}

BOOL opengl_wglGetPixelFormatAttribivARB(HDC hdc,int iPixelFormat,int iLayerPlane,UINT nAttributes,const int *piAttributes,int *piValues) {
   APIENTRY typeof(opengl_wglGetPixelFormatAttribivARB) *function=(typeof(function))wglGetProcAddress("wglGetPixelFormatAttribivARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglGetPixelFormatAttribivARB) failed");
    return NO;
   }

   return function(hdc,iPixelFormat,iLayerPlane,nAttributes,piAttributes,piValues);
}

BOOL opengl_wglGetPixelFormatAttribfvARB(HDC hdc,int iPixelFormat,int iLayerPlane,UINT nAttributes,const int *piAttributes,FLOAT *pfValues) {
   APIENTRY typeof(opengl_wglGetPixelFormatAttribfvARB) *function=(typeof(function))wglGetProcAddress("wglGetPixelFormatAttribfvARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglGetPixelFormatAttribfvARB) failed");
    return NO;
   }

   return function(hdc,iPixelFormat,iLayerPlane,nAttributes,piAttributes,pfValues);
}

BOOL opengl_wglChoosePixelFormatARB(HDC hdc,const int *piAttribIList,const FLOAT *pfAttribFList,UINT nMaxFormats,int *piFormats,UINT *nNumFormats) {
   APIENTRY typeof(opengl_wglChoosePixelFormatARB) *function=(typeof(function))wglGetProcAddress("wglChoosePixelFormatARB");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglChoosePixelFormatARB) failed");
    return NO;
   }

   return function(hdc,piAttribIList,pfAttribFList,nMaxFormats,piFormats,nNumFormats);
}

void opengl_glGenFramebuffersEXT(GLsizei count,GLuint *results) {
   APIENTRY typeof(opengl_glGenFramebuffersEXT) *function=(typeof(function))wglGetProcAddress("glGenFramebuffersEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glGenFramebuffersEXT) failed");
    return;
   }

   return function(count,results);
}

void opengl_glDeleteFramebuffersEXT (GLsizei count, const GLuint *idents) {
   APIENTRY typeof(opengl_glDeleteFramebuffersEXT) *function=(typeof(function))wglGetProcAddress("glDeleteFramebuffersEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glDeleteFramebuffersEXT) failed");
    return;
   }

   return function(count,idents);
}

void opengl_glBindFramebufferEXT (GLenum target, GLuint ident) {
   APIENTRY typeof(opengl_glBindFramebufferEXT) *function=(typeof(function))wglGetProcAddress("glBindFramebufferEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glBindFramebufferEXT) failed");
    return;
   }

   return function(target,ident);
}

void opengl_glGenRenderbuffersEXT (GLsizei count, GLuint *results) {
   APIENTRY typeof(opengl_glGenRenderbuffersEXT) *function=(typeof(function))wglGetProcAddress("glGenRenderbuffersEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glGenRenderbuffersEXT) failed");
    return;
   }

   return function(count,results);
}

void opengl_glDeleteRenderbuffersEXT (GLsizei count, const GLuint *idents) {
   APIENTRY typeof(opengl_glDeleteRenderbuffersEXT) *function=(typeof(function))wglGetProcAddress("glDeleteRenderbuffersEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glDeleteRenderbuffersEXT) failed");
    return;
   }

   return function(count,idents);
}

void opengl_glRenderbufferStorageEXT (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) {
   APIENTRY typeof(opengl_glRenderbufferStorageEXT) *function=(typeof(function))wglGetProcAddress("glRenderbufferStorageEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glRenderbufferStorageEXT) failed");
    return;
   }

   return function(target,internalFormat,width,height);
}

void opengl_glBindRenderbufferEXT (GLenum target, GLuint ident) {
   APIENTRY typeof(opengl_glBindRenderbufferEXT) *function=(typeof(function))wglGetProcAddress("glBindRenderbufferEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glBindRenderbufferEXT) failed");
    return;
   }

   function(target,ident);
}

void opengl_glFramebufferRenderbufferEXT (GLenum target, GLenum attachmentPoint, GLenum renderbufferTarget, GLuint renderbufferId) {
   APIENTRY typeof(opengl_glFramebufferRenderbufferEXT ) *function=(typeof(function))wglGetProcAddress("glFramebufferRenderbufferEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glFramebufferRenderbufferEXT ) failed");
    return;
   }

   function(target,attachmentPoint,renderbufferTarget,renderbufferId);
}

GLenum opengl_glCheckFramebufferStatusEXT(GLenum target) {
   APIENTRY typeof(opengl_glCheckFramebufferStatusEXT ) *function=(typeof(function))wglGetProcAddress("glCheckFramebufferStatusEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glCheckFramebufferStatusEXT ) failed");
    return GL_FRAMEBUFFER_UNSUPPORTED_EXT;
   }

   return function(target);
}

void opengl_glFramebufferTexture2DEXT(GLenum target, GLenum attachmentPoint,GLenum textureTarget,GLuint textureId,GLint level) {
   APIENTRY typeof(opengl_glFramebufferTexture2DEXT ) *function=(typeof(function))wglGetProcAddress("glFramebufferTexture2DEXT");

   if(function==NULL){
    if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(glFramebufferTexture2DEXT ) failed");
    return ;
   }

   function(target,attachmentPoint,textureTarget,textureId,level);
}

HGLRC opengl_wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext,const int *attribList) {
   APIENTRY typeof(opengl_wglCreateContextAttribsARB ) *function=(typeof(function))wglGetProcAddress("wglCreateContextAttribsARB");

   if(function==NULL){
 //   if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglCreateContextAttribsARB ) failed");
    return NO;
   }

   return function(hDC,hshareContext,attribList);
}

BOOL opengl_wglMakeContextCurrentARB(HDC hDrawDC,HDC hReadDC,HGLRC hglrc) {
   APIENTRY typeof(opengl_wglMakeContextCurrentARB ) *function=(typeof(function))wglGetProcAddress("wglMakeContextCurrentARB");

   if(function==NULL){
 //   if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglMakeContextCurrentARB ) failed");
    return NO;
   }

   return function(hDrawDC,hReadDC,hglrc);
}

BOOL opengl_wglBindTexImageARB(HPBUFFERARB hPbuffer,int iBuffer) {
   APIENTRY typeof(opengl_wglBindTexImageARB) *function=(typeof(function))wglGetProcAddress("wglBindTexImageARB");

   if(function==NULL){
 //   if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglBindTexImageARB) failed");
    return NO;
   }

   return function(hPbuffer,iBuffer);
}

BOOL opengl_wglReleaseTexImageARB(HPBUFFERARB hPbuffer,int iBuffer) {
   APIENTRY typeof(opengl_wglReleaseTexImageARB) *function=(typeof(function))wglGetProcAddress("wglReleaseTexImageARB");

   if(function==NULL){
 //   if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglReleaseTexImageARB) failed");
    return NO;
   }

   return function(hPbuffer,iBuffer);
}

BOOL opengl_wglSetPbufferAttribARB(HPBUFFERARB hPbuffer,const int *piAttribList) {
   APIENTRY typeof(opengl_wglSetPbufferAttribARB) *function=(typeof(function))wglGetProcAddress("wglSetPbufferAttribARB");

   if(function==NULL){
 //   if(NSDebugEnabled)
     NSLog(@"wglGetProcAddress(wglSetPbufferAttribARB) failed");
    return NO;
   }

   return function(hPbuffer,piAttribList);
}

BOOL opengl_wglSwapIntervalEXT (int interval) {
   APIENTRY typeof(opengl_wglSwapIntervalEXT) *function=(typeof(function))wglGetProcAddress("wglSwapIntervalEXT");

   if(function==NULL){
    NSLog(@"wglGetProcAddress(wglSwapIntervalEXT) failed");
    return NO;
   }

    return function(interval);
}

void opengl_glAddSwapHintRectWIN(GLint x,GLint y,GLsizei width,GLsizei height) {
   WINAPI typeof(opengl_glAddSwapHintRectWIN) *function=(typeof(function))wglGetProcAddress("glAddSwapHintRectWIN");

   if(function==NULL){
    NSLog(@"wglGetProcAddress(glAddSwapHintRectWIN) failed");
    return ;
   }

    return function(x,y,width,height);
}


text:
package org.openuap.cms.user.security.manager.support;

import java.util.List;

import org.openuap.cms.user.security.manager.IResourceReflection;
import org.openuap.cms.user.security.manager.PermissionResourceItem;
import org.openuap.cms.user.security.manager.PermissionResourceType;
import org.openuap.cms.user.security.manager.ResourcePermissionControlPanel;

/**
 *

 * 缺省资源权限控制面板
 *

 *
 *

 * $Id: DefaultResourcePermissionControlPanel.java 3939 2010-10-27 08:41:36Z orangeforjava $
 *

 *
 * @author Joseph
 * @version 1.0
 */
public class DefaultResourcePermissionControlPanel implements
		ResourcePermissionControlPanel {

	private List<PermissionResourceItem> permissionResourceItems;
	private PermissionResourceType permissionResourceType;
	private IResourceReflection resourceReflection;
	public List<PermissionResourceItem> getPermissionResourceItems() {
		return permissionResourceItems;
	}

	public PermissionResourceType getPermissionResourceType() {
		return permissionResourceType;
	}

	public void setPermissionResourceItems(
			List<PermissionResourceItem> permissionResourceItems) {
		this.permissionResourceItems = permissionResourceItems;
	}

	public void setPermissionResourceType(
			PermissionResourceType permissionResourceType) {
		this.permissionResourceType = permissionResourceType;
	}

	public IResourceReflection getResourceReflection() {
		return resourceReflection;
	}

	public void setResourceReflection(IResourceReflection resourceReflection) {
		this.resourceReflection = resourceReflection;
	}

}


text:
CREATE OR REPLACE PROCEDURE DROP_ALL AUTHID DEFINER IS
  CURSOR CURSOR_OBJECT IS
    SELECT object_type,'"'||object_name||'"'||decode(object_type, 'TABLE', ' CASCADE CONSTRAINTS', NULL) AS obj_name
    FROM user_objects
    WHERE object_type IN ('TRIGGER', 'TABLE', 'VIEW', 'SEQUENCE', 'PROCEDURE', 'FUNCTION', 'TYPE', 'PACKAGE')
    AND object_name != 'DROP_ALL';
BEGIN
  BEGIN
    FOR OBJECT in CURSOR_OBJECT LOOP
      EXECUTE IMMEDIATE ('DROP '||OBJECT.object_type||' ' ||OBJECT.obj_name);
    END LOOP;
  END;
END;
/
EXECUTE DROP_ALL;
DROP PROCEDURE DROP_ALL;

-- CREATE MIASTO
CREATE TABLE MIASTO (
  id NUMBER(10),
  nazwa VARCHAR2(100) NOT NULL
);
ALTER TABLE MIASTO ADD (
  CONSTRAINT MIASTO_PK PRIMARY KEY (id),
  CONSTRAINT MIASTO_NAZWA_UK UNIQUE (nazwa)
);

CREATE SEQUENCE MIASTO_SEQ;

CREATE OR REPLACE TRIGGER MIASTO_AUTOINCREMENT
BEFORE INSERT ON MIASTO
FOR EACH ROW
BEGIN
  SELECT MIASTO_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE ADRES
CREATE TABLE ADRES (
  id NUMBER(10),
  miasto_id NUMBER(10) NOT NULL,
  ulica VARCHAR2(100) NOT NULL,
  nr_domu VARCHAR2(100) NOT NULL,
  nr_mieszkania VARCHAR2(100)
);
ALTER TABLE ADRES ADD (
  CONSTRAINT ADRES_PK PRIMARY KEY (id),
  CONSTRAINT ADRES_MIASTO_FK FOREIGN KEY (miasto_id) REFERENCES MIASTO (id) ON DELETE CASCADE
);

CREATE INDEX ADRES_ULICA_IDX ON ADRES (ulica) COMPUTE STATISTICS;

CREATE SEQUENCE ADRES_SEQ;

CREATE OR REPLACE TRIGGER ADRES_AUTOINCREMENT
BEFORE INSERT ON ADRES
FOR EACH ROW
BEGIN
  SELECT ADRES_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE OSOBA
CREATE TABLE OSOBA (
  id NUMBER(10),
  adres_id NUMBER(10) NOT NULL,
  imie VARCHAR2(100) NOT NULL,
  nazwisko VARCHAR2(100) NOT NULL,
  wiek NUMBER(3) NOT NULL,
  stan_cywilny NUMBER(1) NOT NULL,
  telefon VARCHAR2(100),
  pesel NUMBER(11) NOT NULL
);
ALTER TABLE OSOBA ADD (
  CONSTRAINT OSOBA_PK PRIMARY KEY (id),
  CONSTRAINT OSOBA_ADRES_FK FOREIGN KEY (adres_id) REFERENCES ADRES (id) ON DELETE CASCADE,
  CONSTRAINT OSOBA_STAN_CYWILNY_CHK CHECK (stan_cywilny = 0 OR stan_cywilny = 1), -- Emulacja boolean
  CONSTRAINT OSOBA_PESEL_CHK CHECK ( --http://pl.wikipedia.org/wiki/PESEL#Metoda_r.C3.B3wnowa.C5.BCna
    CAST(SUBSTR(CAST((
    (1 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 1, 1) AS NUMBER)) +
    (3 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 2, 1) AS NUMBER)) +
    (7 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 3, 1) AS NUMBER)) +
    (9 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 4, 1) AS NUMBER)) +
    (1 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 5, 1) AS NUMBER)) +
    (3 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 6, 1) AS NUMBER)) +
    (7 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 7, 1) AS NUMBER)) +
    (9 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 8, 1) AS NUMBER)) +
    (1 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 9, 1) AS NUMBER)) +
    (3 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 10, 1) AS NUMBER)) +
    (1 * CAST(SUBSTR(CAST(pesel AS VARCHAR2(11)), 11, 1) AS NUMBER))) AS VARCHAR(3)), -1) AS NUMBER)
    = 0
  ),
  CONSTRAINT OSOBA_PESEL_UK UNIQUE (pesel)
);

CREATE SEQUENCE OSOBA_SEQ;

CREATE OR REPLACE TRIGGER OSOBA_AUTOINCREMENT
BEFORE INSERT ON OSOBA
FOR EACH ROW
BEGIN
  SELECT OSOBA_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE PRACOWNIK
CREATE TABLE PRACOWNIK (
  id NUMBER(10),
  osoba_id NUMBER(10) NOT NULL,
  stanowisko VARCHAR2(100) NOT NULL,
  staz_pracy NUMBER(3),
  wynagrodzenie_brutto NUMBER(12,2)
);
ALTER TABLE PRACOWNIK ADD (
  CONSTRAINT PRACOWNIK_PK PRIMARY KEY (id),
  CONSTRAINT PRACOWNIK_OSOBA_FK FOREIGN KEY (osoba_id) REFERENCES OSOBA (id) ON DELETE CASCADE,
  CONSTRAINT PRACOWNIK_OSOBA_ID_UK UNIQUE (osoba_id)
);

CREATE SEQUENCE PRACOWNIK_SEQ;

CREATE OR REPLACE TRIGGER PRACOWNIK_AUTOINCREMENT
BEFORE INSERT ON PRACOWNIK
FOR EACH ROW
BEGIN
  SELECT PRACOWNIK_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE KLIENT
CREATE TABLE KLIENT (
  id NUMBER(10),
  osoba_id NUMBER(10) NOT NULL,
  znizka NUMBER(3) DEFAULT 0 -- Wyra¿one procentowo (od 0 do 100 procent)
);
ALTER TABLE KLIENT ADD (
  CONSTRAINT KLIENT_PK PRIMARY KEY (id),
  CONSTRAINT KLIENT_OSOBA_FK FOREIGN KEY (osoba_id) REFERENCES OSOBA (id) ON DELETE CASCADE,
  CONSTRAINT KLIENT_ZNIZKA_CHK CHECK (znizka >= 0 AND znizka <= 100)
);

CREATE SEQUENCE KLIENT_SEQ;

CREATE OR REPLACE TRIGGER KLIENT_AUTOINCREMENT
BEFORE INSERT ON KLIENT
FOR EACH ROW
BEGIN
  SELECT KLIENT_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE USLUGA
CREATE TABLE USLUGA (
  id NUMBER(10),
  opis_uslugi VARCHAR2(100) NOT NULL,
  cena_podstawowa NUMBER(12,2) NOT NULL
);
ALTER TABLE USLUGA ADD (
  CONSTRAINT USLUGA_PK PRIMARY KEY (id),
  CONSTRAINT USLUGA_OPIS_USLUGI_UK UNIQUE (opis_uslugi)
);

CREATE SEQUENCE USLUGA_SEQ;

CREATE OR REPLACE TRIGGER USLUGA_AUTOINCREMENT
BEFORE INSERT ON USLUGA
FOR EACH ROW
BEGIN
  SELECT USLUGA_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- CREATE ZLECENIE
CREATE TABLE ZLECENIE (
  id NUMBER(10),
  usluga_id NUMBER(10) NOT NULL,
  klient_id NUMBER(10) NOT NULL,
  pracownik_id NUMBER(10) NOT NULL
);
ALTER TABLE ZLECENIE ADD (
  CONSTRAINT ZLECENIE_PK PRIMARY KEY (id),
  CONSTRAINT ZLECENIE_USLUGA_FK FOREIGN KEY (usluga_id) REFERENCES USLUGA (id) ON DELETE CASCADE,
  CONSTRAINT ZLECENIE_KLIENT_FK FOREIGN KEY (klient_id) REFERENCES KLIENT (id) ON DELETE CASCADE,
  CONSTRAINT ZLECENIE_PRACOWNIK_FK FOREIGN KEY (pracownik_id) REFERENCES PRACOWNIK (id) ON DELETE CASCADE
);

CREATE SEQUENCE ZLECENIE_SEQ;

CREATE OR REPLACE TRIGGER ZLECENIE_AUTOINCREMENT
BEFORE INSERT ON ZLECENIE
FOR EACH ROW
BEGIN
  SELECT ZLECENIE_SEQ.NEXTVAL
  INTO   :new.id
  FROM   dual;
END;
/

-- INSERT

-- INSERT ZLECENIE 1
DECLARE
  miasto_id NUMBER := NULL;
  adres_id NUMBER := NULL;
  osoba_id NUMBER := NULL;
  pracownik_id NUMBER := NULL;
  klient_id NUMBER := NULL;
  usluga_id NUMBER := NULL;
BEGIN
SET TRANSACTION ISOLATION LEVEL READ COMMITTED NAME 'CREATE_ZLECENIE1';
INSERT INTO MIASTO (nazwa) VALUES ('Kielce') RETURNING id INTO miasto_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto_id, 'Ulica 1', '1A', '2B') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie pracownik1', 'Nazwisko pracownik1', 35, 1, '523456234', 77100504448) RETURNING id INTO osoba_id;
INSERT INTO PRACOWNIK (osoba_id, stanowisko, staz_pracy, wynagrodzenie_brutto) VALUES (osoba_id, 'Sprzedawca', 1, 2200.00) RETURNING id INTO pracownik_id;

INSERT INTO MIASTO (nazwa) VALUES ('Warszawa') RETURNING id INTO miasto_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto_id, 'Ulica 2', '2A', '3B') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie klient1', 'Nazwisko klient1', 20, 0, '325654432', 54042719044) RETURNING id INTO osoba_id;
INSERT INTO KLIENT (osoba_id, znizka) VALUES (osoba_id, 10.00) RETURNING id INTO klient_id;

INSERT INTO USLUGA (opis_uslugi, cena_podstawowa) VALUES ('Us³uga1', 100.00) RETURNING id INTO usluga_id;

INSERT INTO ZLECENIE (usluga_id, klient_id, pracownik_id) VALUES (usluga_id, klient_id, pracownik_id);
COMMIT;
END;
/

-- INSERT ZLECENIE 2
DECLARE
  miasto1_id NUMBER := NULL;
  miasto2_id NUMBER := NULL;
  adres_id NUMBER := NULL;
  osoba_id NUMBER := NULL;
  pracownik_id NUMBER := NULL;
  klient_id NUMBER := NULL;
  usluga_id NUMBER := NULL;
  zlecenie_id NUMBER := NULL;
BEGIN
SET TRANSACTION ISOLATION LEVEL READ COMMITTED NAME 'CREATE_ZLECENIE2';
INSERT INTO MIASTO (nazwa) VALUES ('Kraków') RETURNING id INTO miasto1_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto1_id, 'Ulica 3', '3A', '5B') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie pracownik2', 'Nazwisko pracownik2', 36, 1, '526452834', 91031204121) RETURNING id INTO osoba_id;
INSERT INTO PRACOWNIK (osoba_id, stanowisko, staz_pracy, wynagrodzenie_brutto) VALUES (osoba_id, 'Sprzedawca', 1, 2200.00) RETURNING id INTO pracownik_id;

INSERT INTO MIASTO (nazwa) VALUES ('Gdañsk') RETURNING id INTO miasto2_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto2_id, 'Ulica 20', '4A', '9B') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie klient2', 'Nazwisko klient2', 22, 0, '325982932', 33092705122) RETURNING id INTO osoba_id;
INSERT INTO KLIENT (osoba_id, znizka) VALUES (osoba_id, 0) RETURNING id INTO klient_id;

INSERT INTO USLUGA (opis_uslugi, cena_podstawowa) VALUES ('Us³uga2', 200.10) RETURNING id INTO usluga_id;

INSERT INTO ZLECENIE (usluga_id, klient_id, pracownik_id) VALUES (usluga_id, klient_id, pracownik_id) RETURNING id INTO zlecenie_id;
COMMIT;
-- Bez sensu, ale jest dla dobra przyk³adu
DELETE MIASTO WHERE id IN (SELECT id FROM MIASTO WHERE id = miasto1_id);
DELETE MIASTO WHERE id IN (SELECT id FROM MIASTO WHERE id = miasto2_id);
DELETE USLUGA WHERE id IN (SELECT id FROM USLUGA WHERE id = usluga_id);
COMMIT;
END;
/

-- INSERT ZLECENIE 3
DECLARE
  miasto_id NUMBER := NULL;
  adres_id NUMBER := NULL;
  osoba_id NUMBER := NULL;
  pracownik_id NUMBER := NULL;
  klient_id NUMBER := NULL;
  usluga_id NUMBER := NULL;
BEGIN
SET TRANSACTION ISOLATION LEVEL READ COMMITTED NAME 'CREATE_ZLECENIE3';
INSERT INTO MIASTO (nazwa) VALUES ('Wroc³aw') RETURNING id INTO miasto_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto_id, 'Ulica 4', '12A', '23B') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie pracownik3', 'Nazwisko pracownik3', 39, 1, '526773434', 27121818237) RETURNING id INTO osoba_id;
INSERT INTO PRACOWNIK (osoba_id, stanowisko, staz_pracy, wynagrodzenie_brutto) VALUES (osoba_id, 'Kierownik', 4, 3200.00) RETURNING id INTO pracownik_id;

INSERT INTO MIASTO (nazwa) VALUES ('Poznañ') RETURNING id INTO miasto_id;
INSERT INTO ADRES (miasto_id, ulica, nr_domu, nr_mieszkania) VALUES (miasto_id, 'Ulica 8', '14A', '26') RETURNING id INTO adres_id;
INSERT INTO OSOBA (adres_id, imie, nazwisko, wiek, stan_cywilny, telefon, pesel) VALUES (adres_id, 'Imie klient3', 'Nazwisko klient3', 25, 0, '399482966', 31060716152) RETURNING id INTO osoba_id;
INSERT INTO KLIENT (osoba_id, znizka) VALUES (osoba_id, 0) RETURNING id INTO klient_id;

INSERT INTO USLUGA (opis_uslugi, cena_podstawowa) VALUES ('U³'uga3', 500.12) RETURNING id INTO usluga_id;

INSERT INTO ZLECENIE (usluga_id, klient_id, pracownik_id) VALUES (usluga_id, klient_id, pracownik_id);

COMMIT;
-- Bez sensu, ale jest dla dobra przyk³adu
UPDATE KLIENT SET znizka = 5 WHERE id = klient_id;
UPDATE KLIENT SET (znizka) = (
  SELECT znizka FROM (
    SELECT znizka
    FROM KLIENT
  ) WHERE ROWNUM = 1
) WHERE id = klient_id;
COMMIT;
END;
/

-- SELECT

-- SELECT (ten select jest bez sensu, ale chodzi³o o dobry przyk³ad)
CREATE OR REPLACE VIEW DATA_WAREHOUSE AS
SELECT
  id AS "Numer zlecenia",
  opis_uslugi AS "Us³uga",
  to_char(cena_podstawowa, 'fm9999999.90') AS "Cena us³ugi",
  to_char(cena_ze_znizka, 'fm9999999.90') AS "Cena ze zni¿k¹",

  imie_pracownika AS "Imiê pracownika",
  nazwisko_pracownika AS "Nazwisko pracownika",
  pesel_pracownika AS "Pesel pracownika",
  stanowisko AS "Stanowisko pracownika",
  CASE -- terminologia wg http://pl.wikipedia.org/wiki/Stan_cywilny
   WHEN stan_cywilny_pracownika = 0 THEN 'Stan wolny'
   WHEN stan_cywilny_pracownika = 1 THEN 'Ma³¿onek'
  END AS "Stan cywilny pracownika",
  miasto_pracownika || ', ' || ulica_pracownika || ' ' || nr_domu_pracownika ||
  CASE
   WHEN nr_mieszkania_pracownika IS NOT NULL THEN '/' || nr_mieszkania_pracownika
   ELSE ''
  END AS "Adres pracownika",

  imie_klienta AS "Imie klienta",
  nazwisko_klienta AS "Nazwisko klienta",
  pesel_klienta AS "Pesel klienta",
  miasto_klienta || ', ' || ulica_klienta || ' ' || nr_domu_klienta ||
  CASE
   WHEN nr_mieszkania_klienta IS NOT NULL THEN '/' || nr_mieszkania_klienta
   ELSE ''
  END AS "Adres klienta"
FROM (
SELECT * FROM (
  SELECT
    ZLECENIE.id,
    USLUGA.opis_uslugi,
    USLUGA.cena_podstawowa,
    ROUND((USLUGA.cena_podstawowa - ((KLIENT.znizka/100) * USLUGA.cena_podstawowa)), 2) AS cena_ze_znizka,

    PRACOWNIK_OSOBA.imie AS imie_pracownika,
    PRACOWNIK_OSOBA.nazwisko AS nazwisko_pracownika,
    PRACOWNIK_OSOBA.pesel AS pesel_pracownika,
    PRACOWNIK_OSOBA.stan_cywilny AS stan_cywilny_pracownika,
    PRACOWNIK.stanowisko,
    PRACOWNIK_ADRES.ulica AS ulica_pracownika,
    PRACOWNIK_ADRES.nr_domu AS nr_domu_pracownika,
    PRACOWNIK_ADRES.nr_mieszkania AS nr_mieszkania_pracownika,
    PRACOWNIK_MIASTO.nazwa AS miasto_pracownika,

    KLIENT_OSOBA.imie AS imie_klienta,
    KLIENT_OSOBA.nazwisko AS nazwisko_klienta,
    KLIENT_OSOBA.pesel AS pesel_klienta,
    KLIENT_ADRES.ulica AS ulica_klienta,
    KLIENT_ADRES.nr_domu AS nr_domu_klienta,
    KLIENT_ADRES.nr_mieszkania AS nr_mieszkania_klienta,
    KLIENT_MIASTO.nazwa AS miasto_klienta
  FROM ZLECENIE
  JOIN USLUGA ON (ZLECENIE.USLUGA_ID = USLUGA.ID)

  JOIN PRACOWNIK ON (ZLECENIE.PRACOWNIK_ID = PRACOWNIK.ID)
  JOIN OSOBA PRACOWNIK_OSOBA ON (PRACOWNIK.OSOBA_ID = PRACOWNIK_OSOBA.ID)
  JOIN ADRES PRACOWNIK_ADRES ON (PRACOWNIK_OSOBA.ADRES_ID = PRACOWNIK_ADRES.ID)
  JOIN MIASTO PRACOWNIK_MIASTO ON (PRACOWNIK_ADRES.MIASTO_ID = PRACOWNIK_MIASTO.ID)

  JOIN KLIENT ON (ZLECENIE.KLIENT_ID = KLIENT.ID)
  JOIN OSOBA KLIENT_OSOBA ON (KLIENT.OSOBA_ID = KLIENT_OSOBA.ID)
  JOIN ADRES KLIENT_ADRES ON (KLIENT_OSOBA.ADRES_ID = KLIENT_ADRES.ID)
  JOIN MIASTO KLIENT_MIASTO ON (KLIENT_ADRES.MIASTO_ID = KLIENT_MIASTO.ID)

  ORDER BY ZLECENIE.id ASC
) WHERE ROWNUM = 1

UNION ALL

SELECT * FROM (
  SELECT
    ZLECENIE.id,
    USLUGA.opis_uslugi,
    USLUGA.cena_podstawowa,
    ROUND((USLUGA.cena_podstawowa - ((KLIENT.znizka/100) * USLUGA.cena_podstawowa)), 2) AS cena_ze_znizka,

    PRACOWNIK_OSOBA.imie AS imie_pracownika,
    PRACOWNIK_OSOBA.nazwisko AS nazwisko_pracownika,
    PRACOWNIK_OSOBA.pesel AS pesel_pracownika,
    PRACOWNIK_OSOBA.stan_cywilny AS stan_cywilny_pracownika,
    PRACOWNIK.stanowisko,
    PRACOWNIK_ADRES.ulica AS ulica_pracownika,
    PRACOWNIK_ADRES.nr_domu AS nr_domu_pracownika,
    PRACOWNIK_ADRES.nr_mieszkania AS nr_mieszkania_pracownika,
    PRACOWNIK_MIASTO.nazwa AS miasto_pracownika,

    KLIENT_OSOBA.imie AS imie_klienta,
    KLIENT_OSOBA.nazwisko AS nazwisko_klienta,
    KLIENT_OSOBA.pesel AS pesel_klienta,
    KLIENT_ADRES.ulica AS ulica_klienta,
    KLIENT_ADRES.nr_domu AS nr_domu_klienta,
    KLIENT_ADRES.nr_mieszkania AS nr_mieszkania_klienta,
    KLIENT_MIASTO.nazwa AS miasto_klienta
  FROM ZLECENIE
  JOIN USLUGA ON (ZLECENIE.USLUGA_ID = USLUGA.ID)

  JOIN PRACOWNIK ON (ZLECENIE.PRACOWNIK_ID = PRACOWNIK.ID)
  JOIN OSOBA PRACOWNIK_OSOBA ON (PRACOWNIK.OSOBA_ID = PRACOWNIK_OSOBA.ID)
  JOIN ADRES PRACOWNIK_ADRES ON (PRACOWNIK_OSOBA.ADRES_ID = PRACOWNIK_ADRES.ID)
  JOIN MIASTO PRACOWNIK_MIASTO ON (PRACOWNIK_ADRES.MIASTO_ID = PRACOWNIK_MIASTO.ID)

  JOIN KLIENT ON (ZLECENIE.KLIENT_ID = KLIENT.ID)
  JOIN OSOBA KLIENT_OSOBA ON (KLIENT.OSOBA_ID = KLIENT_OSOBA.ID)
  JOIN ADRES KLIENT_ADRES ON (KLIENT_OSOBA.ADRES_ID = KLIENT_ADRES.ID)
  JOIN MIASTO KLIENT_MIASTO ON (KLIENT_ADRES.MIASTO_ID = KLIENT_MIASTO.ID)

  ORDER BY ZLECENIE.id DESC
) WHERE ROWNUM = 1
);

SELECT * FROM DATA_WAREHOUSE;


text:
local objectId = require 'resty-mongol.object_id'
local query = require 'lusty-store-mongo.query'
local connection = require 'lusty-store-mongo.store.mongo.connection'

return {
  handler = function(context)
    local q
    if getmetatable(context.query) then
      q = query(context.query)
    else
      q = context.query
    end
    local col = connection(lusty, config)
    if not context.data['_id'] then
      context.data['_id'] = q['_id'] and q['_id']['$in'][1] or objectId.new():tostring()
    end
    col:delete(q)
    return col:insert({context.data}, 0, 1)
  end
}


text: This is the new contor blog.


text:
[CmdletBinding()]
param()

$windowsSdks = @( )

# Get the Windows SDK version sub-key names.
$windowsSdkKeyName = 'Software\Microsoft\Microsoft SDKs\Windows'
$versionSubKeyNames =
    Get-RegistrySubKeyNames -Hive 'LocalMachine' -View 'Registry32' -KeyName $windowsSdkKeyName |
    Where-Object { $_ -clike 'v*A' }
foreach ($versionSubKeyName in $versionSubKeyNames) {
    # Parse the version.
    $version = $null
    if (!([System.Version]::TryParse($versionSubKeyName.Substring(1, $versionSubKeyName.Length - 2), [ref]$version))) {
        continue
    }

    # Get the installation folder.
    $versionKeyName = "$windowsSdkKeyName\$versionSubKeyName"
    $installationFolder = Get-RegistryValue -Hive 'LocalMachine' -View 'Registry32' -KeyName $versionKeyName -Value 'InstallationFolder'
    if (!$installationFolder) {
        continue
    }

    # Add the Windows SDK capability.
    $installationFolder = $installationFolder.TrimEnd([System.IO.Path]::DirectorySeparatorChar)
    $windowsSdkCapabilityName = ("WindowsSdk_{0}.{1}" -f $version.Major, $version.Minor)
    Write-Capability -Name $windowsSdkCapabilityName -Value $installationFolder

    # Add the Windows SDK info as an object with properties (for sorting).
    $windowsSdks += New-Object psobject -Property @{
        InstallationFolder = $installationFolder
        Version = $version
    }

    # Get the NetFx sub-key names.
    $netFxSubKeyNames =
        Get-RegistrySubKeyNames -Hive 'LocalMachine' -View 'Registry32' -KeyName $versionKeyName |
        Where-Object { $_ -clike '*NetFx*x86' -or $_ -clike '*NetFx*x64' }
    foreach ($netFxSubKeyName in $netFxSubKeyNames) {
        # Get the installation folder.
        $netFxKeyName = "$versionKeyName\$netFxSubKeyName"
        $installationFolder = Get-RegistryValue -Hive 'LocalMachine' -View 'Registry32' -KeyName $netFxKeyName -Value 'InstallationFolder'
        if (!$installationFolder) {
            continue
        }

        $installationFolder = $installationFolder.TrimEnd([System.IO.Path]::DirectorySeparatorChar)

        # Add the NetFx tool capability.
        $toolName = $netFxSubKeyName.Substring($netFxSubKeyName.IndexOf('NetFx')) # Trim before "NetFx".
        $toolName = $toolName.Substring(0, $toolName.Length - '-x86'.Length) # Trim the trailing "-x86"/"-x64".
        if ($netFxSubKeyName -clike '*x86') {
            $netFxCapabilityName = "$($windowsSdkCapabilityName)_$toolName"
        } else {
            $netFxCapabilityName = "$($windowsSdkCapabilityName)_$($toolName)_x64"
        }

        Write-Capability -Name $netFxCapabilityName -Value $installationFolder
    }
}

# Add a capability for the max.
$maxWindowsSdk =
    $windowsSdks |
    Sort-Object -Property Version -Descending |
    Select-Object -First 1
if ($maxWindowsSdk) {
    Write-Capability -Name 'WindowsSdk' -Value $maxWindowsSdk.InstallationFolder
}


text:
package focus.builders.model;

import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.code.Types;

import javax.lang.model.element.ExecutableElement;
import javax.lang.model.type.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static java.util.stream.Collectors.toList;

/**
 * Model of a method, that will be passed to the template, and can be used to drive generation of
 * derived java classes.
 */
public final class MethodModel {

    private static final Set<String> packages = new HashSet<String>() {{
        add("java.lang");
    }};

    private final Symbol.MethodSymbol methodSymbol;
    private final Types types;

    public MethodModel(ExecutableElement methodSymbol, Types types) {
        this.methodSymbol = (Symbol.MethodSymbol) methodSymbol;
        this.types = types;
    }

    /**
     * Get name of the method (simple string).
     * @return Name of the method.
     */
    public String name() {
        return methodSymbol.getSimpleName().toString();
    }

    /**
     * Get type model representing the return type.
     * @return TypeModel
     */
    public TypeModel type() {
        return new TypeModel(methodSymbol.getReturnType(), types);
    }

    /**
     * Get list of parameter (variable) models.
     * @return List of parameter (variable) models.
     */
    public List<VarModel> parameters() {
        return methodSymbol.getParameters().stream().map(var -> new VarModel(var, types)).collect(toList());
    }

    public TypeModel declaringClass() {
        return new TypeModel(methodSymbol.getEnclosingElement().asType(), types);
    }

    public boolean isConstructor() {
        return methodSymbol.isConstructor();
    }

    @Override
    public String toString() {
        return name();
    }

    public boolean isSimple(TypeModel model) {
        return model.type.accept(new TypeVisitor<Boolean, Boolean>() {
            @Override
            public Boolean visit(TypeMirror t, Boolean aBoolean) {
                return t.accept(this, aBoolean);
            }

            @Override
            public Boolean visit(TypeMirror t) {
                return visit(t, false);
            }

            @Override
            public Boolean visitPrimitive(PrimitiveType t, Boolean aBoolean) {
                return true;
            }

            @Override
            public Boolean visitNull(NullType t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitArray(ArrayType t, Boolean aBoolean) {
                return t.getComponentType().accept(this, aBoolean);
            }

            @Override
            public Boolean visitDeclared(DeclaredType t, Boolean aBoolean) {
                return packages.contains(t.asElement().getEnclosingElement().toString());
            }

            @Override
            public Boolean visitError(ErrorType t, Boolean aBoolean) {
                return true;
            }

            @Override
            public Boolean visitTypeVariable(TypeVariable t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitWildcard(WildcardType t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitExecutable(ExecutableType t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitNoType(NoType t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitUnknown(TypeMirror t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitUnion(UnionType t, Boolean aBoolean) {
                return false;
            }

            @Override
            public Boolean visitIntersection(IntersectionType t, Boolean aBoolean) {
                return false;
            }
        }, true);
    }

    public boolean isComplex(TypeModel typeModel) {
        return !isSimple(typeModel);
    }

}


text:
package com.hb.hkm.hypebeaststore.endpointmanagers;

import android.content.Context;

import com.google.gson.JsonIOException;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;
import com.hb.hkm.hypebeaststore.life.Config;
import com.squareup.okhttp.FormEncodingBuilder;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.RequestBody;

import org.json.JSONException;

/**
 * Created by hesk on 3/24/15.
 */
public class loginManager extends asyclient {
    public int request_method;
    private RequestBody rb;
    public static int LOGIN = 1, REG = 2;

    public loginManager(Context ccc, callback cb) {
        super(ccc, cb);

    }

    @Override
    protected void addHeaderParam(Request.Builder request) {
        request.post(rb);
    }

    public loginManager setToLogin(String user, String pass) {
        try {
            request_method = LOGIN;
            setURL(Config.login_endpoint);
            RequestBody formBody = new FormEncodingBuilder()
                    .add("_username", user)
                    .add("_password", pass)
                    .build();

            rb = formBody;
        } catch (Exception e) {

        }
        return this;
    }

    public loginManager setToRegister(String reg_email, String pass) {
        try {
            request_method = REG;
            setURL(Config.register_endpoint);
            RequestBody formBody = new FormEncodingBuilder()
                    .add("email", reg_email)
                    .add("plainPassword", pass)
                    .build();

            rb = formBody;
        } catch (Exception e) {

        }
        return this;
    }

    @Override
    protected void GSONParser(String data) throws JSONException, JsonSyntaxException, JsonIOException, JsonParseException {

    }

    @Override
    protected void ViewConstruction() {

    }
}


text:
package skinny.controller

import scala.language.dynamics

/**
 * org.scalatra.FlashMap wrapper.
 *
 * @param underlying scalatra's FlashMap
 */
case class Flash(underlying: org.scalatra.FlashMap) extends Dynamic {

  /**
   * Returns value if exists.
   *
   * @param key key
   * @return value if exists
   */
  def get(key: String): Option[Any] = underlying.get(key)

  /**
   * Enables accessing key using type-dynamic. Both of the following code is same.
   *
   * {{{
   *   flash.get("notice")
   *   flash.notice
   * }}}
   *
   * @param key key
   * @return value if exists
   */
  def selectDynamic(key: String): Option[Any] = get(key)

}


text:
namespace arangodb {
namespace pregel {

template <typename V>
struct VertexSerializer {
  virtual ~VertexSerializer() = default;

  virtual void serialize(VPackBuilder const& builder, V const* targetPtr) const = 0;

  virtual bool deserialize(VPackSlice const& data, V* targetPtr) const = 0;
};

template <>
struct VertexSerializer<int64_t> {
  virtual void serialize(VPackBuilder const& builder, int64_t const* targetPtr) const {
    builder.add(VPackValue(*targetPtr));
  };
  virtual bool deserialize(VPackSlice const& data, int64_t* targetPtr) const {
    *targetPtr = data.getInt();
  };
};
}  // namespace pregel
}  // namespace arangodb