text:
package org.bboxdb.test.distribution.placement;

import java.util.ArrayList;
import java.util.List;

import org.bboxdb.distribution.allocator.RandomResourceAllocator;
import org.bboxdb.distribution.allocator.ResourceAllocationException;
import org.bboxdb.distribution.allocator.ResourceAllocator;
import org.bboxdb.distribution.membership.BBoxDBInstance;
import org.bboxdb.distribution.membership.BBoxDBInstanceState;
import org.junit.Assert;
import org.junit.Test;

public class TestRandomRessourcePlacement {

	/**
	 * Get the placement strategy for the test
	 * @return
	 */
	public ResourceAllocator getPlacementStrategy() {
		return new RandomResourceAllocator();
	}

	/**
	 * Test placement 0 (empty list)
	 * @throws ResourceAllocationException
	 */
	@Test(expected=ResourceAllocationException.class)
	public void testPlacement0() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		resourcePlacementStrategy.getInstancesForNewRessource(systems);
	}

	/**
	 * Test placement 1 (all systems are blacklisted)
	 * @throws ResourceAllocationException
	 */
	@Test(expected=ResourceAllocationException.class)
	public void testPlacement1() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY));
		systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.READY));
		systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.READY));
		systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY));

		Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems, systems));
	}

	/**
	 * Test placement 2 (only one system)
	 * @throws ResourceAllocationException
	 */
	@Test(timeout=60000)
	public void testPlacement2() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.READY));

		Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
		Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
		Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
		Assert.assertEquals(systems.get(0), resourcePlacementStrategy.getInstancesForNewRessource(systems));
	}

	/**
	 * No system is ready
	 * @throws ResourceAllocationException
	 */
	@Test(expected=ResourceAllocationException.class)
	public void testNonReadySystems1() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.OUTDATED));
		systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.FAILED));

		resourcePlacementStrategy.getInstancesForNewRessource(systems);
	}

	/**
	 * No system is ready
	 * @throws ResourceAllocationException
	 */
	@Test(expected=ResourceAllocationException.class)
	public void testNonReadySystems2() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.OUTDATED));
		systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.FAILED));

		resourcePlacementStrategy.getInstancesForNewRessource(systems);
	}

	/**
	 * Only ready systems should be returned
	 * @throws ResourceAllocationException
	 */
	@Test(timeout=60000)
	public void testNonReadySystems3() throws ResourceAllocationException {
		final ResourceAllocator resourcePlacementStrategy = getPlacementStrategy();
		final List<BBoxDBInstance> systems = new ArrayList<BBoxDBInstance>();
		systems.add(new BBoxDBInstance("node1:123", "0.1", BBoxDBInstanceState.OUTDATED));
		systems.add(new BBoxDBInstance("node2:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node3:123", "0.1", BBoxDBInstanceState.FAILED));
		systems.add(new BBoxDBInstance("node4:123", "0.1", BBoxDBInstanceState.READY));

		for(int i = 0; i < 100; i++) {
			Assert.assertEquals(systems.get(3), resourcePlacementStrategy.getInstancesForNewRessource(systems));
		}
	}
}


text:
package org.apache.flink.runtime.leaderelection;

import java.util.UUID;

/**
 * Interface for a service which allows to elect a leader among a group of contenders.
 *
 * Prior to using this service, it has to be started calling the start method. The start method
 * takes the contender as a parameter. If there are multiple contenders, then each contender has
 * to instantiate its own leader election service.
 *
 * Once a contender has been granted leadership he has to confirm the received leader session ID
 * by calling the method confirmLeaderSessionID. This will notify the leader election service, that
 * the contender has received the new leader session ID and that it can now be published for
 * leader retrieval services.
 */
public interface LeaderElectionService {

	/**
	 * Starts the leader election service. This method can only be called once.
	 *
	 * @param contender LeaderContender which applies for the leadership
	 * @throws Exception
	 */
	void start(LeaderContender contender) throws Exception;

	/**
	 * Stops the leader election service.
	 * @throws Exception
	 */
	void stop() throws Exception;

	/**
	 * Confirms that the new leader session ID has been successfully received by the new leader.
	 * This method is usually called by the newly appointed {@link LeaderContender}.
	 *
	 * The rational behind this method is to establish an order between setting the new leader
	 * session ID in the {@link LeaderContender} and publishing the new leader session ID to the
	 * leader retrieval services.
	 *
	 * @param leaderSessionID The new leader session ID
	 */
	void confirmLeaderSessionID(UUID leaderSessionID);

	/**
	 * Returns true if the {@link LeaderContender} with which the service has been started owns
	 * currently the leadership.
	 *
	 * @return true if the associated {@link LeaderContender} is the leader, otherwise false
	 */
	boolean hasLeadership();

}

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:duration="500"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%p"
        android:pivotY="50%p"
        android:toXScale="1.5"
        android:toYScale="1.5"/>

    <alpha
        android:duration="500"
        android:fromAlpha="1.0"
        android:toAlpha="0"/>

</set>


text:
package ru.job4j.application;

import java.util.ArrayList;

/**
 * @author Dmitry Belokursky
 * @since 11.07.17.
 */
public class ValidateInput extends ConsoleInput {
    public int ask(String question, ArrayList<Integer> range) {
        boolean invalid = true;
        int value = -1;
        do {
            try {
                value = super.ask(question, range);
                invalid = false;
            } catch (MenuOutException moe) {
                System.out.println("Please select key from menu.");
            } catch (NumberFormatException nfe) {
                System.out.println("Please enter valid data again.");
            }
        } while (invalid);
        return value;
    }
}


text:
class Tournament
{
private:
	ContactListener *contactListener;
	std::chrono::milliseconds deltaTime;
	std::chrono::high_resolution_clock::time_point lastRun = std::chrono::high_resolution_clock::now();

public:
	std::vector<Boop*> deadBoops;
	Tournament();
	void setBoops(std::vector<Boop*> newBoops);
	void manageFood();
	std::vector<Food*> foods;
	std::vector<Boop*> boops;
	b2Body *groundBody;
	b2World *physWorld;
	void run();
	void reset();
};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using CoreTweet.Streaming;
using CoreTweet;
using NLua;

namespace Kbtter4.Models.Plugin
{
    class Kbtter4LuaPlugin : Kbtter4Plugin
    {
        Lua lua;
        Kbtter ins;
        public Kbtter4LuaPlugin(Lua l,Kbtter k)
        {
            ins = k;
            lua = l;
        }

        public override string Name
        {
            get
            {
                return lua["Name"] as string;
            }
        }

        public override void Initialize()
        {
            try
            {
                var f = lua["Initialize"] as Action;
                if (f != null) f();
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void Dispose()
        {
            try
            {
                var f = lua["Dispose"] as Action;
                if (f != null) f();
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnLogin(User user)
        {
            try
            {
                var f = lua["OnLogin"] as Action<User>;
                if (f != null) f(user);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnLogout(User user)
        {
            try
            {
                var f = lua["OnLogout"] as Action<User>;
                if (f != null) f(user);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnStartStreaming()
        {
            try
            {
                var f = lua["OnStartStreaming"] as Action;
                if (f != null) f();
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnStopStreaming()
        {
            try
            {
                var f = lua["OnStopStreaming"] as Action;
                if (f != null) f();
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnStatus(StatusMessage mes)
        {
            try
            {
                var f = lua["OnStatus"] as Action<StatusMessage>;
                if (f != null) f(mes);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnEvent(EventMessage mes)
        {
            try
            {
                var f = lua["OnEvent"] as Action<EventMessage>;
                if (f != null) f(mes);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnDelete(DeleteMessage mes)
        {
            try
            {
                var f = lua["OnDelete"] as Action<DeleteMessage>;
                if (f != null) f(mes);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override void OnDirectMessage(DirectMessageMessage mes)
        {
            try
            {
                var f = lua["OnDirectMessage"] as Action<DirectMessageMessage>;
                if (f != null) f(mes);
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
            }
        }

        public override StatusMessage OnStatusDestructive(StatusMessage mes)
        {
            try
            {
                var f = lua["OnStatusDestructive"] as Func<StatusMessage, StatusMessage>;
                if (f != null)
                {
                    return f(mes);
                }
                else
                {
                    return mes;
                }
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
                return mes;
            }
        }

        public override EventMessage OnEventDestructive(EventMessage mes)
        {
            try
            {
                var f = lua["OnEventDestructive"] as Func<EventMessage, EventMessage>;
                if (f != null)
                {
                    return f(mes);
                }
                else
                {
                    return mes;
                }
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
                return mes;
            }
        }

        public override DeleteMessage OnDeleteDestructive(DeleteMessage mes)
        {
            try
            {
                var f = lua["OnDeleteDestructive"] as Func<DeleteMessage, DeleteMessage>;
                if (f != null)
                {
                    return f(mes);
                }
                else
                {
                    return mes;
                }
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
                return mes;
            }
        }

        public override DirectMessageMessage OnDirectMessageDestructive(DirectMessageMessage mes)
        {
            try
            {
                var f = lua["OnDirectMessageDestructive"] as Func<DirectMessageMessage, DirectMessageMessage>;
                if (f != null)
                {
                    return f(mes);
                }
                else
                {
                    return mes;
                }
            }
            catch (Exception e)
            {
                ins.LogError("プラグイン " + Name + "でエラーが発生しました : " + e.Message);
                ins.SaveLog();
                return mes;
            }
        }
    }

    public sealed class Kbtter4LuaPluginLoader : Kbtter4PluginLoader
    {

        public override string Language
        {
            get { return "Lua"; }
        }

        public override IEnumerable<Kbtter4Plugin> Load(Kbtter instance, IList<string> filenames)
        {
            var list = new List<Kbtter4LuaPlugin>();
            var files = filenames.Where(p => p.EndsWith(".lua"));
            foreach (var i in files)
            {
                try
                {
                    Lua l = new Lua();
                    l.LoadCLRPackage();
                    l["Kbtter4"] = new Kbtter4PluginProvider(instance);
                    l.DoFile(i);
                    list.Add(new Kbtter4LuaPlugin(l,instance));
                }
                catch (Exception e)
                {
                    instance.LogError("Luaプラグイン読み込み中にエラーが発生しました : " + e.Message);
                }
            }

            return list;
        }
    }
}


text:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.util.prefs.Preferences;

/**
 * Main class
 * @author bencall
 *
 */

//
public class Window implements ActionListener {
	private JButton startButton;
	private JButton stopButton;
	private JTextField nameField;
	private JPasswordField passField;
	private LaunchThread t;
	private Preferences prefs;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new RPlay();
	}

	public Window() {
		prefs = Preferences.userRoot().node(this.getClass().getName());
		String apname = prefs.get("apname", "");
		String pass = prefs.get("pass", "");

		nameField = new JTextField(apname,10);
		passField = new JPasswordField(pass,10);
		startButton = new JButton("Start");
		stopButton = new JButton("Stop");
		startButton.addActionListener(this);
		stopButton.addActionListener(this);
		startButton.setEnabled(true);
		stopButton.setEnabled(false);

		JFrame window = new JFrame();
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.setTitle("RPlay");
		window.setSize(300, 100);
		java.awt.Container content = window.getContentPane();
		content.setLayout(new FlowLayout());

		content.add(new JLabel("AP name:  "));
		content.add(nameField);
		content.add(startButton);
		content.add(new JLabel("Password: "));
		content.add(passField);
		content.add(stopButton);

		//window.pack();
		window.setVisible(true);

		// If previously started, start it now
		if (prefs.getBoolean("launched", true)) {
			startButton.doClick();
		}
	}

	@Override
	public void actionPerformed(ActionEvent event) {
		if(event.getSource() == startButton) {
			if(passField.getText().isEmpty())
				t = new LaunchThread(nameField.getText());
			else
				t = new LaunchThread(nameField.getText(), passField.getText());

			t.start();

			prefs.put("apname", nameField.getText());
			prefs.put("pass", passField.getText());
			prefs.putBoolean("launched", true); // Used on next launch

			startButton.setEnabled(false);
			stopButton.setEnabled(true);
		} else if(event.getSource() == stopButton) {
			t.stopThread();

			prefs.putBoolean("launched", false); // Used on next launch

			startButton.setEnabled(true);
			stopButton.setEnabled(false);
		} else {
			JOptionPane.showMessageDialog(null, "What are you up to?", "?!", JOptionPane.QUESTION_MESSAGE);
		}
	}

}


text:
rubocop --only Lint/ElseLayout

rubocop --only Lint/StringConversionInInterpolation
rubocop --only Lint/DeprecatedClassMethods
rubocop --only Style/ColonMethodCall
rubocop --only Style/LeadingCommentSpace
rubocop --only Style/SingleSpaceBeforeFirstArg
rubocop --only Style/WhenThen
rubocop --only Style/HashSyntax
# rubocop --only Metrics/LineLength


text:
package cz.vutbr.fit.xproko26.pivis.gui.help;

import java.util.List;
import javax.swing.AbstractListModel;

/**
 * HelpListModel represents internal model of help chapter list used by
 * {@link HelpFrame HelpFrame}. It stores list of {@link HelpElement HelpElements}.
 * @author Dagmar Prokopova
 */
public class HelpListModel extends AbstractListModel {

    //list of help elements
    private final List<HelpElement> helplist;

    /**
     * Initializes internal list of help elements.
     * @param list list of help elements
     */
    public HelpListModel(List<HelpElement> list) {
        this.helplist = list;
    }

    /**
     * Returns size of the list.
     * @return size of the list
     */
    @Override
    public int getSize() {
        return helplist.size();
    }

    /**
     * Returns help element title at specified index.
     * @param i index
     * @return help element title
     */
    @Override
    public Object getElementAt(int i) {
        return getHelpElementAt(i).getTitle();
    }

    /**
     * Returns help element at specified index.
     * @param i index into the list
     * @return help element
     */
    public HelpElement getHelpElementAt(int i) {
        return helplist.get(i);
    }

}


text:
Submerged is an opensource .NET based framework for connecting your aquarium to the IoT. The full solution consists of:

* An Azure based IoT back-end which collects data and hosts an API
* Arduino devices connected to a Raspberry Pi running Windows IoT Core via Bluetooth
* An Apache Cordova mobile app for mobile phones

# What does it do?

Submerged is meant to help you monitor your aquarium in every way you want to. At the moment, I use it to monitor things like temperature, pH and leakage. Based on those readings you can set triggers so your phone notifies you as soon as things go south for whatever reason. It's also possible to control hardware such as relays to switch power sockets on / off. And I'm planning on adding a lot more functionality such as an intelligent log which alerts you when your stock solutions or CO2 bottle need replacing.

# Supported functionality
The current list of functionality includes:
* **Monitoring Sensors**:
 * Temperature (DS18B20)
 * pH (Atlas EZO pH)
 * Flow (hall effect flow sensors)
 * Leakage (generic moisture sensors)
 * Stock solution level (level switch sensors)
* **Getting Notifications**: all of the sensors which output data can be monitored against min/max thresholds. A notification is sent to your mobile device as soon as one of the sensor reports an out of bound value.
* **Controlling Relays**: using your mobile app, you can control relays inside of your cabinet remotely. Maintenance mode allows to easily switch multiple relays on/off when performing tank maintenance.
* **Live data**: the measured data can be monitored live using the mobile app for smartphone. Internet connection required.
* **Analytics**: all data is aggregated and stored. This allows you to view long-term statics of your tank per hour, day, week or month.

# How do I use it?

At the moment, the sources are here for you to use under the Apache 2.0 License. To run the entire solution, you'll need both the hardware ([here](hardware.md)) as well as an Azure subscription to run the back-end. If you don't want to run the Azure back-end yourself, please get in touch so I can add you yo my subscription. The end goal is to create a multi-tenant back-end so that you only need to plug in the hardware that you use.

More information on how I built this and how you configure the back-end parts can be found in this blog series: <http://blog.repsaj.nl/index.php/series/azure-aquarium-monitor/>.

# Solution Overview

The solution architecture of submerged looks like this:

![Solution Overview](http://www.repsaj.nl/Uploads/submerged/submerged_overview.png)

Here's roughly what each component does:

* Each arduino device is called a **module** in order to standardize a bit. The "Sensor module" is capable of reading sensors (temperature, pH, flow, etc.). The "cabinet module" will control relays and connect to water sensors for leak detection. More module types might follow in the future.
* A Raspberry Pi running Windows 10 IoT serves as a **gateway**. It connects to the different modules you have and communicates with Azure in a secure way. At the moment the modules are connected via Bluetooth, but I'm planning on maybe replacing that with Alljoyn.
* **Azure IoT hub** takes care of communications from and to the gateway. Your gateway needs to be registered as a device with IoT hub.
* The incoming telemetry data is then processed by **Azure Stream Analytics**. One task ASA has is to seperate notifications and device data from normal telemetry data.
* All data is stored in **Azure blob storage** where it can reside for a long time.
* Notifications and device data are sent to a **Event Hub**. The items in the event hub are then processed by **Azure functions**.
* Events are forwarded to a **Notification hub**. This hub takes care of forwarding the information to a registered device (such as your smartphone).
* A **WebAPI** running in Azure serves as API. The API is secured using Azure AD.
* **Azure DocumentDB** is used to store information about the subscriptions, tanks, sensors and all stuff we need to run the service.
* Lastly, a Cordova mobile app allows you to read out telemetry data, control relays and do all kinds of other stuff.

# Can I contribute?

Yes, please! I'm very much looking for enthusiasts who'd like to help build this out more. There's plenty of stuff to do. Here's a todo list:

* Implement additional sensors / modules
* Implement some of the missing features, such as the intelligent journal
* Test the mobile app for iPhone, currently only Android is being used / tested
* Build a web based entry point for management / extensive resporting / etc
* Implement additional unit tests
* Any other awesome additions I didn't think of
* There could probably be a little additional documentation, do check out the [blog series](http://blog.repsaj.nl/index.php/series/azure-aquarium-monitor/) for that too

So please get in touch if you want to contribute in any way! :)

# What do I get?

Pictures say more than a thousands words!

Screendumps of the mobile app:

Screendump of the gateway dashboard:


text:
package com.intellij.ui;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.ui.Divider;
import com.intellij.openapi.ui.PseudoSplitter;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.vcs.changes.RefreshablePanel;
import com.intellij.util.ui.JBUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;

public abstract class SplitterWithSecondHideable {
  public interface OnOffListener<T> {
    void on(T t);
    void off(T t);
  }

  private final PseudoSplitter mySplitter;
  private final AbstractTitledSeparatorWithIcon myTitledSeparator;
  private final OnOffListener<Integer> myListener;
  private final JPanel myFictivePanel;
  private Splitter.DividerImpl mySuperDivider;
  private float myPreviousProportion;

  public SplitterWithSecondHideable(boolean vertical,
                                    String separatorText,
                                    JComponent firstComponent,
                                    OnOffListener<Integer> listener) {
    myListener = listener;
    myFictivePanel = new JPanel(new BorderLayout());
    Icon icon;
    Icon openIcon;
    if (vertical) {
      icon = AllIcons.General.ComboArrowRight;
      openIcon = AllIcons.General.ComboArrowDown;
    }
    else {
      icon = AllIcons.General.ComboArrowRight;
      openIcon = AllIcons.General.ComboArrowRightPassive;
    }

    myTitledSeparator = new AbstractTitledSeparatorWithIcon(icon, openIcon, separatorText) {
      @Override
      protected RefreshablePanel createPanel() {
        return createDetails();
      }

      @Override
      protected void initOnImpl() {
        final float proportion = myPreviousProportion > 0 ? myPreviousProportion : getSplitterInitialProportion();
        mySplitter.setSecondComponent(myDetailsComponent.getPanel());
        mySuperDivider.setResizeEnabled(true);

        SwingUtilities.invokeLater(() -> {
          mySplitter.fixFirst(proportion);
          mySplitter.invalidate();
          mySplitter.validate();
          mySplitter.repaint();
        });
      }

      @Override
      protected void onImpl() {
        final float proportion = myPreviousProportion > 0 ? myPreviousProportion : getSplitterInitialProportion();
        final int firstSize = vertical ? mySplitter.getFirstComponent().getHeight() : mySplitter.getFirstComponent().getWidth();
        // !! order is important! first fix
        mySplitter.fixFirst();
        myListener.on((int)((1 - proportion) * firstSize / proportion));
        //mySplitter.setProportion(proportion);
        mySplitter.setSecondComponent(myDetailsComponent.getPanel());
        mySplitter.revalidate();
        mySplitter.repaint();
        mySuperDivider.setResizeEnabled(true);
      }

      @Override
      protected void offImpl() {
        final int previousSize = vertical ? mySplitter.getSecondComponent().getHeight() : mySplitter.getSecondComponent().getWidth();
        mySplitter.setSecondComponent(myFictivePanel);
        myPreviousProportion = mySplitter.getProportion();
        mySplitter.freeAll();
        mySplitter.setProportion(1.0f);
        mySplitter.revalidate();
        mySplitter.repaint();
        myListener.off(previousSize);
        mySuperDivider.setResizeEnabled(false);
      }
    };
    mySplitter = new PseudoSplitter(vertical) {
      {
        myTitledSeparator.mySeparator.addMouseListener(new MouseAdapter() {
          @Override
          public void mouseEntered(MouseEvent e) {
            myTitledSeparator.mySeparator.setCursor(new Cursor(myTitledSeparator.myOn ? Cursor.S_RESIZE_CURSOR : Cursor.DEFAULT_CURSOR));
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseExited(MouseEvent e) {
            myTitledSeparator.mySeparator.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseClicked(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mousePressed(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseReleased(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseWheelMoved(MouseWheelEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseDragged(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }

          @Override
          public void mouseMoved(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseEvent(e);
          }
        });

        myTitledSeparator.mySeparator.addMouseMotionListener(new MouseMotionListener() {
          @Override
          public void mouseDragged(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseMotionEvent(e);
          }

          @Override
          public void mouseMoved(MouseEvent e) {
            ((MyDivider)mySuperDivider).processMouseMotionEvent(e);
          }
        });
      }

      @Override
      protected Divider createDivider() {
        mySuperDivider = new MyDivider();
        mySuperDivider.add(myTitledSeparator,
                           new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
                                                  JBUI.emptyInsets(), 0, 0));
        return mySuperDivider;
      }

      @Override
      public int getDividerWidth() {
        return vertical ? myTitledSeparator.getHeight() : myTitledSeparator.getWidth();
      }

      class MyDivider extends DividerImpl {
        @Override
        public void processMouseMotionEvent(MouseEvent e) {
          super.processMouseMotionEvent(e);
        }

        @Override
        public void processMouseEvent(MouseEvent e) {
          super.processMouseEvent(e);
        }
      }
    };
    mySplitter.setDoubleBuffered(true);
    mySplitter.setFirstComponent(firstComponent);
    mySplitter.setSecondComponent(myFictivePanel);
    //mySplitter.setShowDividerIcon(false);
    mySplitter.setProportion(1.0f);
  }

  public void setText(final String value) {
    myTitledSeparator.setText(value);
  }

  public Splitter getComponent() {
    return mySplitter;
  }

  protected abstract RefreshablePanel createDetails();

  protected abstract float getSplitterInitialProportion();

  public float getUsedProportion() {
    return isOn() ? mySplitter.getProportion() : myPreviousProportion;
  }

  public void initOn() {
    myTitledSeparator.initOn();
  }

  public void on() {
    myTitledSeparator.on();
  }

  public void off() {
    myTitledSeparator.off();
  }

  public boolean isOn() {
    return myTitledSeparator.myOn;
  }
}


text:
<?php
namespace Stats\Entity;
use Nakade\TournamentInterface;

/**
 * AbstractPrize
 *
 * @package Stats\Entity
 */
abstract class AbstractPrize implements PrizeInterface
{
    protected $gold = array();
    protected $silver = array();
    protected $bronze = array();

    /**
     * @param TournamentInterface $tournament
     *
     * @return $this
     */
    public function addBronze(TournamentInterface $tournament)
    {
        $this->bronze[] = $tournament;
        return $this;
    }

    /**
     * @return array
     */
    public function getBronze()
    {
        return $this->bronze;
    }

    /**
     * @return int
     */
    public function getNoBronze()
    {
        return count($this->bronze);
    }

    /**
     * @param TournamentInterface $tournament
     *
     * @return $this
     */
    public function addGold(TournamentInterface $tournament)
    {
        $this->gold[] = $tournament;
        return $this;
    }

    /**
     * @return array
     */
    public function getGold()
    {
        return $this->gold;
    }

    /**
     * @return int
     */
    public function getNoGold()
    {
        return count($this->gold);
    }

    /**
     * @param TournamentInterface $tournament
     *
     * @return $this
     */
    public function addSilver(TournamentInterface $tournament)
    {
        $this->silver[] = $tournament;
        return $this;
    }

    /**
     * @return array
     */
    public function getSilver()
    {
        return $this->silver;
    }

    /**
     * @return int
     */
    public function getNoSilver()
    {
        return count($this->silver);
    }

}


text:
<?php

include dirname(__FILE__).'/../bootstrap/unit.php';
include_once dirname(__FILE__).'/test_stub.php';
$t = new lime_test(2, new lime_output_color());

$storage = new sfPropelEzcWorkflowDefinitionStorage();
$workflow = $storage->loadByName('Test');
// Set up database-based workflow executer.
$execution = new sfPropelEzcWorkflowExecution();
// Pass workflow object to workflow executer.
$execution->workflow = $workflow;
$sf_ezc_testing_message = null;
// Start workflow execution.
$id = $execution->start();
$t->is($execution->isSuspended(),true,'Execution is suspended');

$propel_obj = sfEzcWorkflowExecutionPeer::retrieveByPK($id);
$variables = array('test' => 'value', 'test_2' => 'value 2');
$propel_obj->setVariables($variables);
$propel_obj->save();

$propel_obj = sfEzcWorkflowExecutionPeer::retrieveByPK($id);
$variables_retrieved = $propel_obj->getVariables();

$t->is($variables_retrieved, $variables);


text:
<?php
namespace PayPal\Test\Common;

use PayPal\Common\ArrayUtil;

class ArrayUtilTest extends \PHPUnit_Framework_TestCase
{

    public function testIsAssocArray()
    {
        $arr = array(1, 2, 3);
        $this->assertEquals(false, ArrayUtil::isAssocArray($arr));

        $arr = array(
            'name' => 'John Doe',
            'City' => 'San Jose'
        );
        $this->assertEquals(true, ArrayUtil::isAssocArray($arr));

        $arr[] = 'CA';
        $this->assertEquals(false, ArrayUtil::isAssocArray($arr));
    }
}