text:
<template>

  <require from="resources/features/extras/checkbox"></require>

        ${'notifications.preferred_language' | t}

      <select md-select="" value.two-way="preferredLanguage">
        <option value="" disabled selected>${'notifications.select_language' | t}</option>
        <option value="de-de">Deutsch</option>
        <option value="en-gb">English</option>
        <option value="pl-pl">Polski</option>
      </select>

        ${'notifications.email' | t}

          <checkbox value.bind="emailSettings[0]" label="${emailSettings[0].translationKey | t}"></checkbox>

          <checkbox value.bind="setting" label="${setting.translationKey | t}"
          description="${setting.description | t}"></checkbox>

        ${'notifications.push' | t}

          <checkbox value.bind="pushSettings[0]" label="${pushSettings[0].translationKey | t}"></checkbox>

          <checkbox value.bind="setting" label="${setting.translationKey | t}"
          description="${setting.description | t}"></checkbox>

</template>


text:
  <title>Todo List</title>

      Checkin Board

        {{> loginButtons}}

{{#if currentUser}}

    <form class="new-task">

        <input class="form-control" type="text" name="text" placeholder="What are you going to work on today?" style="font-family:Monospace;"/>

    </form>

{{/if}}

   {{#each lastupdates}}
     {{> task}}
   {{/each}}

<template name="task">
  {{#if currentUser}}

{{username}}

{{text}}

      {{#if isOwner}}
        {{#if private}}
          <button class="toggle-private btn-default btn-sm btn">
            Not looking to pair
          </button>
        {{else}}
          <button class="toggle-private btn-success btn-sm btn">
            Looking to pair!
          </button>
        {{/if}}
      {{/if}}

  {{/if}}
</template>

redpajama_set_name: RedPajamaGithub


text:
CKEDITOR.plugins.setLang( 'about', 'nl', {
	copy: 'Copyright © $1. Alle rechten voorbehouden.',
	dlgTitle: 'Over CKEditor',
	help: 'Bekijk de $1 voor hulp.',
	moreInfo: 'Voor licentie informatie, bezoek onze website:',
	title: 'Over CKEditor',
	userGuide: 'CKEditor gebruiksaanwijzing'
});


text:
<?php
/**
 * Left menu template
 *
 * @author: Andrii Birev
 */
defined('BEXEC')or die('No direct access!');
use \Brilliant\CMS\BLang;
$brouter=\Application\BRouter::getInstance();
?>

		<?php foreach($this->companies as $company): ?>

				<a class="nav-link" href="<?php echo('/members/mycompany-'.$company->id.'/'); ?>"><?php echo htmlspecialchars($company->name); ?>

				<a class="nav-link" href="<?php echo('/members/mycompany-'.$company->id.'/accounts/'); ?>">>> <?php echo BLang::_('COMPANIES_MYCOMP_ACCOUTNS'); ?>

				<a class="nav-link" href="<?php echo('/members/mycompany-'.$company->id.'/opgroups/'); ?>">>> <?php echo BLang::_('COMPANIES_MYCOMP_OPGROUPS'); ?>

				<a class="nav-link" href="<?php echo('/members/mycompany-'.$company->id.'/projects/'); ?>">>> <?php echo BLang::_('COMPANIES_MYCOMP_PROJECTS'); ?>

		<?php endforeach; ?>

Add company


text:
package dbvasconcelos.finance.view;

import java.io.IOException;
import java.io.Serializable;
import java.util.ResourceBundle;

import javax.annotation.PostConstruct;
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.event.Event;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import dbvasconcelos.finance.events.SignedIn;
import dbvasconcelos.finance.model.User;
import dbvasconcelos.finance.model.repository.impl.UserRepository;

@Named
@ConversationScoped
public class LoginView implements Serializable {
  private static final long serialVersionUID = 1L;

  @Inject
  private UserRepository users;

  @Inject
  private Conversation conversation;

  @Inject
  @SignedIn
  Event<User> signedInEvent;

  private String username;
  private String password;
  private String originalUrl;

  /**
   * Does some treatment to the url.
   */
  @PostConstruct
  public void init() {
    conversation.begin();
    final ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    originalUrl =
        (String) externalContext.getRequestMap().get(RequestDispatcher.FORWARD_REQUEST_URI);

    if (originalUrl == null) {
      originalUrl = externalContext.getRequestContextPath() + "/pages/home.xhtml";
    } else {
      final String originalQuery =
          (String) externalContext.getRequestMap().get(RequestDispatcher.FORWARD_QUERY_STRING);

      if (originalQuery != null) {
        originalUrl += "?" + originalQuery;
      }
    }
  }

  /**
   * The action of signing in.
   *
   * @throws IOException on failure
   */
  public void signIn() throws IOException {
    final FacesContext context = FacesContext.getCurrentInstance();
    final ExternalContext externalContext = context.getExternalContext();
    final HttpServletRequest request =
        (HttpServletRequest) context.getExternalContext().getRequest();

    try {
      request.login(username, password);
      final User user = users.findByUsername(username);
      signedInEvent.fire(user);
      externalContext.redirect(originalUrl);
      conversation.end();
    } catch (final ServletException e) {
      final ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msg");
      final String message = bundle.getString("login.failed");
      context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
    }
  }

  public String getUsername() {
    return username;
  }

  public void setUsername(final String username) {
    this.username = username;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(final String password) {
    this.password = password;
  }

}


text:
from django.db import models
from django.contrib.auth.models import User
from sprints.models import Sprint

class Task(models.Model):
    """
    Stores a single task.
    account ties task with a :model:`auth.User`
    categories tie task with :model:`tasks.Category`
    """
    account = models.ForeignKey(User)
    title = models.CharField(max_length=100)
    description = models.TextField(blank=True)

    category = models.ForeignKey("Category", related_name='tasks')
    sprints = models.ManyToManyField(Sprint, blank=True, null=True, related_name='tasks')

    completed = models.BooleanField(default=False)

    weight = models.IntegerField()

    date_added = models.DateTimeField(auto_now_add=True)
    date_closed = models.DateTimeField(blank=True, null=True)

    def __unicode__(self):
        return self.title

    def is_backlog(self):
        return not (self.completed or any([sprint.is_active() for sprint in self.sprints.all()]))

class Category(models.Model):
    """
    Stores User Categories
    account ties category with a :model:`auth.User`
    """
    account = models.ForeignKey(User)
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

    def get_open_tasks(self):
        return self.task_set.filter(completed=False)


text:
package org.apache.phoenix.schema.types;

import java.sql.Time;

import org.apache.phoenix.schema.SortOrder;

public class PTimeArray extends PArrayDataType<Time[]> {

    public static final PTimeArray INSTANCE = new PTimeArray();

    private PTimeArray() {
        super("TIME ARRAY", PDataType.ARRAY_TYPE_BASE + PTime.INSTANCE.getSqlType(), PhoenixArray.class,
                null, 38);
    }

    @Override
    public boolean isArrayType() {
        return true;
    }

    @Override
    public boolean isFixedWidth() {
        return false;
    }

    @Override
    public int compareTo(Object lhs, Object rhs, PDataType rhsType) {
        return compareTo(lhs, rhs);
    }

    @Override
    public Integer getByteSize() {
        return null;
    }

    @Override
    public byte[] toBytes(Object object) {
        return toBytes(object, SortOrder.ASC);
    }

    @Override
    public byte[] toBytes(Object object, SortOrder sortOrder) {
        return toBytes(object, PTime.INSTANCE, sortOrder);
    }

    @Override
    public Object toObject(byte[] bytes, int offset, int length,
            PDataType actualType, SortOrder sortOrder, Integer maxLength,
            Integer scale) {
        return toObject(bytes, offset, length, PTime.INSTANCE, sortOrder, maxLength, scale,
                PTime.INSTANCE);
    }

    @Override
    public boolean isCoercibleTo(PDataType targetType) {
        return isCoercibleTo(targetType, this);
    }

    @Override
    public boolean isCoercibleTo(PDataType targetType, Object value) {
        if (value == null) {
            return true;
        }
        PhoenixArray pArr = (PhoenixArray) value;
        Object[] timeArr = (Object[]) pArr.array;
        for (Object i : timeArr) {
            if (!super.isCoercibleTo(PTime.INSTANCE, i)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public Object getSampleValue(Integer maxLength, Integer arrayLength) {
        return getSampleValue(PTime.INSTANCE, arrayLength, maxLength);
    }
}


text:
define(["backbone", "handlebars"],
function(Backbone, Handlebars){

    var Lightbox = Backbone.View.extend({
        template: $('#lightbox-template'),
        initialize: function(options){

            this.selector = options.selector || "body";
            this.data = {
                content: options.content,
            };

        },

        events: {
            "click .close": "remove"
        },

        render: function(){
            $("#lightbox").remove();

            // ** Please swap this line and the line before initalize
            // ** with your template loading method, and engine you use
            var template = Handlebars.compile(this.template);

            this.$el.html(template(this.data));

            $(this.selector).append(this.el);
        }
    });

    return Lightbox;

});


text:
import hview
from numba_slice import zslice


text:
//The MIT License(MIT)

//copyright(c) 2016 Alberto Rodriguez

//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in all
//copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//SOFTWARE.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Windows.Forms.Integration;
using System.Windows.Media;
using LiveCharts.Maps;

namespace LiveCharts.WinForms
{
    /// <summary>
    ///
    /// </summary>
    /// <seealso cref="System.Windows.Forms.Integration.ElementHost" />
    [Designer("System.Windows.Forms.Design.ControlDesigner, System.Design")]
    [DesignerSerializer("System.ComponentModel.Design.Serialization.TypeCodeDomSerializer , System.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")]

    public class GeoMap : ElementHost
    {
        /// <summary>
        /// The WPF base
        /// </summary>
        protected readonly Wpf.GeoMap WpfBase = new Wpf.GeoMap();
        /// <summary>
        /// Initializes a new instance of the <see cref="GeoMap"/> class.
        /// </summary>
        public GeoMap()
        {
            Child = WpfBase;

            WpfBase.LandClick += (o, point) =>
            {
                if (LandClick != null) LandClick.Invoke(o, point);
            };
        }

        /// <summary>
        /// Occurs when [land click].
        /// </summary>
        public event Action<object, MapData> LandClick;

        /// <summary>
        /// Gets the base.
        /// </summary>
        /// <value>
        /// The base.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Wpf.GeoMap Base
        {
            get { return WpfBase; }
        }

        /// <summary>
        /// Gets or sets the language pack.
        /// </summary>
        /// <value>
        /// The language pack.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Dictionary<string, string> LanguagePack
        {
            get { return WpfBase.LanguagePack; }
            set { WpfBase.LanguagePack = value; }
        }

        /// <summary>
        /// Gets or sets the default land fill.
        /// </summary>
        /// <value>
        /// The default land fill.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Brush DefaultLandFill
        {
            get { return WpfBase.DefaultLandFill; }
            set { WpfBase.DefaultLandFill = value; }
        }

        /// <summary>
        /// Gets or sets the land stroke thickness.
        /// </summary>
        /// <value>
        /// The land stroke thickness.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public double LandStrokeThickness
        {
            get { return WpfBase.LandStrokeThickness; }
            set { WpfBase.LandStrokeThickness = value; }
        }

        /// <summary>
        /// Gets or sets the land stroke.
        /// </summary>
        /// <value>
        /// The land stroke.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Brush LandStroke
        {
            get { return WpfBase.LandStroke; }
            set { WpfBase.LandStroke = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [disable animations].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [disable animations]; otherwise, <c>false</c>.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool DisableAnimations
        {
            get { return WpfBase.DisableAnimations; }
            set { WpfBase.DisableAnimations = value; }
        }

        /// <summary>
        /// Gets or sets the animations speed.
        /// </summary>
        /// <value>
        /// The animations speed.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public TimeSpan AnimationsSpeed
        {
            get { return WpfBase.AnimationsSpeed; }
            set { WpfBase.AnimationsSpeed = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether this <see cref="GeoMap"/> is hoverable.
        /// </summary>
        /// <value>
        ///   <c>true</c> if hoverable; otherwise, <c>false</c>.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool Hoverable
        {
            get { return WpfBase.Hoverable; }
            set { WpfBase.Hoverable = value; }
        }

        /// <summary>
        /// Gets or sets the heat map.
        /// </summary>
        /// <value>
        /// The heat map.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public Dictionary<string, double> HeatMap
        {
            get { return WpfBase.HeatMap; }
            set { WpfBase.HeatMap = value; }
        }

        /// <summary>
        /// Gets or sets the gradient stop collection.
        /// </summary>
        /// <value>
        /// The gradient stop collection.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public GradientStopCollection GradientStopCollection
        {
            get { return WpfBase.GradientStopCollection; }
            set { WpfBase.GradientStopCollection = value; }
        }

        /// <summary>
        /// Gets or sets the source.
        /// </summary>
        /// <value>
        /// The source.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public string Source
        {
            get { return WpfBase.Source; }
            set { WpfBase.Source = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [enable zooming and panning].
        /// </summary>
        /// <value>
        /// <c>true</c> if [enable zooming and panning]; otherwise, <c>false</c>.
        /// </value>
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public bool EnableZoomingAndPanning
        {
            get { return WpfBase.EnableZoomingAndPanning; }
            set { WpfBase.EnableZoomingAndPanning = value; }
        }
    }
}


text:
#ifndef ArrayConventions_h
#define ArrayConventions_h

#include "IndexingHeader.h"
#include "WriteBarrier.h"

namespace JSC {

// Overview of JSArray
//
// Properties of JSArray objects may be stored in one of three locations:
//   * The regular JSObject property map.
//   * A storage vector.
//   * A sparse map of array entries.
//
// Properties with non-numeric identifiers, with identifiers that are not representable
// as an unsigned integer, or where the value is greater than  MAX_ARRAY_INDEX
// (specifically, this is only one property - the value 0xFFFFFFFFU as an unsigned 32-bit
// integer) are not considered array indices and will be stored in the JSObject property map.
//
// All properties with a numeric identifer, representable as an unsigned integer i,
// where (i <= MAX_ARRAY_INDEX), are an array index and will be stored in either the
// storage vector or the sparse map. An array index i will be handled in the following
// fashion:
//
//   * Where (i < MIN_SPARSE_ARRAY_INDEX) the value will be stored in the storage vector,
//     unless the array is in SparseMode in which case all properties go into the map.
//   * Where (MIN_SPARSE_ARRAY_INDEX <= i <= MAX_STORAGE_VECTOR_INDEX) the value will either
//     be stored in the storage vector or in the sparse array, depending on the density of
//     data that would be stored in the vector (a vector being used where at least
//     (1 / minDensityMultiplier) of the entries would be populated).
//   * Where (MAX_STORAGE_VECTOR_INDEX < i <= MAX_ARRAY_INDEX) the value will always be stored
//     in the sparse array.

// Define the maximum storage vector length to be 2^32 / sizeof(JSValue) / 2 to ensure that
// there is no risk of overflow.
#define MAX_STORAGE_VECTOR_LENGTH (static_cast<unsigned>(IndexingHeader::maximumLength))

// These values have to be macros to be used in max() and min() without introducing
// a PIC branch in Mach-O binaries, see <rdar://problem/5971391>.
#define MIN_SPARSE_ARRAY_INDEX 100000U
#define MAX_STORAGE_VECTOR_INDEX (MAX_STORAGE_VECTOR_LENGTH - 1)
// 0xFFFFFFFF is a bit weird -- is not an array index even though it's an integer.
#define MAX_ARRAY_INDEX 0xFFFFFFFEU

// The value BASE_VECTOR_LEN is the maximum number of vector elements we'll allocate
// for an array that was created with a sepcified length (e.g. a = new Array(123))
#define BASE_VECTOR_LEN 4U

// The upper bound to the size we'll grow a zero length array when the first element
// is added.
#define FIRST_VECTOR_GROW 4U

// Our policy for when to use a vector and when to use a sparse map.
// For all array indices under MIN_SPARSE_ARRAY_INDEX, we always use a vector.
// When indices greater than MIN_SPARSE_ARRAY_INDEX are involved, we use a vector
// as long as it is 1/8 full. If more sparse than that, we use a map.
static const unsigned minDensityMultiplier = 8;

inline bool isDenseEnoughForVector(unsigned length, unsigned numValues)
{
    return length / minDensityMultiplier <= numValues;
}

inline IndexingHeader indexingHeaderForArray(unsigned length, unsigned vectorLength)
{
    IndexingHeader result;
    result.setPublicLength(length);
    result.setVectorLength(vectorLength);
    return result;
}

inline IndexingHeader baseIndexingHeaderForArray(unsigned length)
{
    return indexingHeaderForArray(length, BASE_VECTOR_LEN);
}

} // namespace JSC

#endif // ArrayConventions_h


text:
java_import 'com.codahale.metrics.health.HealthCheck'

class BasicHealthCheck < HealthCheck
  def check
    Result.healthy
  end
end


text:
Cargo stores the output of a build into the "target" directory. By default,
this is the directory named `target` in the root of your workspace. To change
the location, you can set the `CARGO_TARGET_DIR` [environment variable], the
[`build.target-dir`] config value, or the `--target-dir` command-line flag.

The directory layout depends on whether or not you are using the `--target`
flag to build for a specific platform. If `--target` is not specified, Cargo
runs in a mode where it builds for the host architecture. The output goes into
the root of the target directory, separated based on whether or not it is a
release build:

Directory | Description
----------|------------
target/debug/ | Contains debug build output.
target/release/ | Contains release build output (with `--release` flag).

When building for another target with `--target`, the output is placed in a
directory with the name of the target:

Directory | Example
----------|--------
target/<triple>/debug/ | target/thumbv7em-none-eabihf/debug/
target/<triple>/release/ | target/thumbv7em-none-eabihf/release/

> **Note**: When not using `--target`, this has a consequence that Cargo will
> share your dependencies with build scripts and proc macros. [`RUSTFLAGS`]
> will be shared with every `rustc` invocation. With the `--target` flag,
> build scripts and proc macros are built separately (for the host
> architecture), and do not share `RUSTFLAGS`.

Within the profile directory (`debug` or `release`), artifacts are placed into
the following directories:

Directory | Description
----------|------------
target/debug/ | Contains the output of the package being built (the `[[bin]]` executables and `[lib]` library targets).
target/debug/examples/ | Contains examples (`[[example]]` targets).

Some commands place their output in dedicated directories in the top level of
the `target` directory:

Directory | Description
----------|------------
target/doc/ | Contains rustdoc documentation ([`cargo doc`]).
target/package/ | Contains the output of the [`cargo package`] and [`cargo publish`] commands.

Cargo also creates several other directories and files needed for the build
process. Their layout is considered internal to Cargo, and is subject to
change. Some of these directories are:

Directory | Description
----------|------------
target/debug/deps/ |  Dependencies and other artifacts.
target/debug/incremental/ |  `rustc` [incremental output], a cache used to speed up subsequent builds.
target/debug/build/ |  Output from [build scripts].

### Dep-info files

Next to each compiled artifact is a file called a "dep info" file with a `.d`
suffix. This file is a Makefile-like syntax that indicates all of the file
dependencies required to rebuild the artifact. These are intended to be used
with external build systems so that they can detect if Cargo needs to be
re-executed. The paths in the file are absolute by default. See the
[`build.dep-info-basedir`] config option to use relative paths.

```Makefile
# Example dep-info file found in target/debug/foo.d
/path/to/myproj/target/debug/foo: /path/to/myproj/src/lib.rs /path/to/myproj/src/main.rs
```

### Shared cache

A third party tool, [sccache], can be used to share built dependencies across
different workspaces.

To setup `sccache`, install it with `cargo install sccache` and set
`RUSTC_WRAPPER` environmental variable to `sccache` before invoking Cargo. If
you use bash, it makes sense to add `export RUSTC_WRAPPER=sccache` to
`.bashrc`. Alternatively, you can set [`build.rustc-wrapper`] in the [Cargo
configuration][config]. Refer to sccache documentation for more details.

[`RUSTFLAGS`]: ../reference/config.md#buildrustflags
[`build.dep-info-basedir`]: ../reference/config.md#builddep-info-basedir
[`build.rustc-wrapper`]: ../reference/config.md#buildrustc-wrapper
[`build.target-dir`]: ../reference/config.md#buildtarget-dir
[`cargo doc`]: ../commands/cargo-doc.md
[`cargo package`]: ../commands/cargo-package.md
[`cargo publish`]: ../commands/cargo-publish.md
[build scripts]: ../reference/build-scripts.md
[config]: ../reference/config.md
[environment variable]: ../reference/environment-variables.md
[incremental output]: ../reference/profiles.md#incremental
[sccache]: https://github.com/mozilla/sccache


text:
module AddParams2 where

collapse rightInner rightOuter = right
  where
    right           = (rightInner, rightOuter)


text:
from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [
        ('webarchives', '0001_initial'),
    ]

    operations = [
        migrations.AlterField(
            model_name='importedrecord',
            name='identifier',
            field=models.CharField(max_length=200, unique=True),
        ),
    ]


text:
package com.design.flyweight.sample;

import java.util.ArrayList;

public abstract class ObjectPool {
	private static final int MAX_POOL_SIZE = 20;
	private ArrayList<ObjectUnit> mObjectUnits = new ArrayList<ObjectUnit>();

	public ObjectUnit obtain() {
		ObjectUnit objectUnit = getObjectUnit();

		if (objectUnit == null) {
			synchronized (mObjectUnits) {
				if (mObjectUnits.size() < MAX_POOL_SIZE) {
					objectUnit = createNewObjectUnit();
					objectUnit.isRecycled = false;
					mObjectUnits.add(objectUnit);
					System.out.println(Thread.currentThread().getName()
							+ " new ObjectUnit");
				} else {
					while(true) {
						try {
							long time1 = System.currentTimeMillis();
							mObjectUnits.wait();
							System.out
									.println(Thread.currentThread().getName()
											+ " wait : "
											+ (System.currentTimeMillis() - time1));
							objectUnit = getObjectUnit();
							if(objectUnit != null) {
								objectUnit.isRecycled = false;
								break;
							}
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}

				}
			}

		} else {
			System.out.println(Thread.currentThread().getName()
					+ " cache ObjectUnit");
		}

		return objectUnit;
	}

	private ObjectUnit getObjectUnit() {
		synchronized (mObjectUnits) {
			for (int i = 0; i < mObjectUnits.size(); i++) {
				ObjectUnit objectUnit = mObjectUnits.get(i);
				synchronized (objectUnit) {
					if (objectUnit.isRecycled == true) {
						return objectUnit;
					}
				}
			}
		}
		return null;
	}

	public void recycle() {
		synchronized (mObjectUnits) {
			mObjectUnits.notifyAll();
		}

	}

	protected abstract ObjectUnit createNewObjectUnit();
}


text:
require 'spec_helper'

describe 'SemanticFormBuilder#inputs' do

  include FormtasticSpecHelper

  before do
    @output_buffer = ''
    mock_everything
  end

  describe 'with a block' do

    describe 'when no options are provided' do
      before do
        output_buffer.replace 'before_builder' # clear the output buffer and sets before_builder
        @form = semantic_form_for(@new_post) do |builder|
          @inputs_output = builder.inputs do
            concat('hello')
          end
        end
      end

      it 'should output just the content wrapped in inputs, not the whole template' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should      =~ /before_builder/
        @inputs_output.should_not =~ /before_builder/
      end

      it 'should render a fieldset inside the form, with a class of "inputs"' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs")
      end

      it 'should render an ol inside the fieldset' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs ol")
      end

      it 'should render the contents of the block inside the ol' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs ol", /hello/)
      end

      it 'should not render a legend inside the fieldset' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should_not have_tag("form fieldset.inputs legend")
      end

      it 'should render a fieldset even if no object is given' do
        form = semantic_form_for(:project, :url => 'http://test.host/') do |builder|
          @inputs_output = builder.inputs do
            concat('bye')
          end
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs ol", /bye/)
      end
    end

    describe 'when a :for option is provided' do

      before do
        @new_post.stub!(:respond_to?).and_return(true, true)
        @new_post.stub!(:author).and_return(@bob)
      end

      it 'should render nested inputs' do
        @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))

        form = semantic_form_for(@new_post) do |builder|
          inputs = builder.inputs :for => [:author, @bob] do |bob_builder|
            concat(bob_builder.input(:login))
          end
          concat(inputs)
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs #post_author_attributes_login")
        output_buffer.should_not have_tag("form fieldset.inputs #author_login")

      end

      it 'should concat rendered nested inputs to the template under rails3' do
        @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
        ::Formtastic::Util.stub!(:rails3?).and_return(true)

        form = semantic_form_for(@new_post) do |builder|
          builder.inputs :for => [:author, @bob] do |bob_builder|
            concat(bob_builder.input(:login))
          end
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset.inputs #post_author_attributes_login")
        output_buffer.should_not have_tag("form fieldset.inputs #author_login")

      end

      describe "as a symbol representing the association name" do

        it 'should nest the inputs with an _attributes suffix on the association name' do
          form = semantic_form_for(@new_post) do |post|
            inputs = post.inputs :for => :author do |author|
              concat(author.input(:login))
            end
            concat(inputs)
          end
          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form input[@name='post[author_attributes][login]']")
        end

      end

      describe "as a symbol representing a has_many association name" do
        before do
          @new_post.stub!(:authors).and_return([@bob, @fred])
          @new_post.stub!(:authors_attributes=)
        end

        it 'should nest the inputs with a name input for each item' do
          form = semantic_form_for(@new_post) do |post|
            post.inputs :for => :authors do |author|
              concat(author.input(:login))
            end
          end

          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form input[@name='post[authors_attributes][0][login]']")
          output_buffer.should have_tag("form input[@name='post[authors_attributes][1][login]']")
        end
      end

      describe 'as an array containing the a symbole for the association name and the associated object' do

        it 'should nest the inputs with an _attributes suffix on the association name' do
          form = semantic_form_for(@new_post) do |post|
            inputs = post.inputs :for => [:author, @new_post.author] do |author|
              concat(author.input(:login))
            end
            concat(inputs)
          end
          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form input[@name='post[author_attributes][login]']")
        end

      end

      describe 'as an associated object' do

        it 'should not nest the inputs with an _attributes suffix' do
          form = semantic_form_for(@new_post) do |post|
            inputs = post.inputs :for => @new_post.author do |author|
              concat(author.input(:login))
            end
            concat(inputs)
          end
          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form input[@name='post[author][login]']")
        end

      end

      it 'should raise an error if :for and block with no argument is given' do
        semantic_form_for(@new_post) do |builder|
          proc {
            builder.inputs(:for => [:author, @bob]) do
              #
            end
          }.should raise_error(ArgumentError, 'You gave :for option with a block to inputs method, ' <<
                                              'but the block does not accept any argument.')
        end
      end

      it 'should pass options down to semantic_fields_for' do
        @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))

        form = semantic_form_for(@new_post) do |builder|
          inputs = builder.inputs :for => [:author, @bob], :for_options => { :index => 10 } do |bob_builder|
            concat(bob_builder.input(:login))
          end
          concat(inputs)
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form fieldset ol li #post_author_attributes_10_login')
      end

      it 'should not add builder as a fieldset attribute tag' do
        form = semantic_form_for(@new_post) do |builder|
          inputs = builder.inputs :for => [:author, @bob], :for_options => { :index => 10 } do |bob_builder|
            concat('input')
          end
          concat(inputs)
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should_not have_tag('fieldset[@builder="Formtastic::SemanticFormHelper"]')
      end

      it 'should send parent_builder as an option to allow child index interpolation' do
        form = semantic_form_for(@new_post) do |builder|
          builder.instance_variable_set('@nested_child_index', 0)
          inputs = builder.inputs :for => [:author, @bob], :name => 'Author #%i' do |bob_builder|
            concat('input')
          end
          concat(inputs)
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('fieldset legend', 'Author #1')
      end

      it 'should also provide child index interpolation when nested child index is a hash' do
        form = semantic_form_for(@new_post) do |builder|
          builder.instance_variable_set('@nested_child_index', :author => 10)
          inputs = builder.inputs :for => [:author, @bob], :name => 'Author #%i' do |bob_builder|
            concat('input')
          end
          concat(inputs)
        end

        output_buffer.concat(form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('fieldset legend', 'Author #11')
      end
    end

    describe 'when a :name or :title option is provided' do
      describe 'and is a string' do
        before do
          @legend_text = "Advanced options"
          @legend_text_using_name = "Advanced options 2"
          @legend_text_using_title = "Advanced options 3"
          @nested_forms_legend_text = "This is a nested form title"
          @form = semantic_form_for(@new_post) do |builder|
            inputs = builder.inputs @legend_text do
            end
            concat(inputs)
            inputs = builder.inputs :name => @legend_text_using_name do
            end
            concat(inputs)
            inputs = builder.inputs :title => @legend_text_using_title do
            end
            concat(inputs)
            inputs = builder.inputs @nested_forms_legend_text, :for => :authors do |nf|
            end
            concat(inputs)
          end
        end

        it 'should render a fieldset with a legend inside the form' do
          output_buffer.concat(@form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form fieldset legend", /^#{@legend_text}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@legend_text_using_name}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@legend_text_using_title}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@nested_forms_legend_text}$/)
        end
      end

      describe 'and is a symbol' do
        before do
          @localized_legend_text = "Localized advanced options"
          @localized_legend_text_using_name = "Localized advanced options 2"
          @localized_legend_text_using_title = "Localized advanced options 3"
          @localized_nested_forms_legend_text = "This is a localized nested form title"
          ::I18n.backend.store_translations :en, :formtastic => {
              :titles => {
                  :post => {
                      :advanced_options => @localized_legend_text,
                      :advanced_options_using_name => @localized_legend_text_using_name,
                      :advanced_options_using_title => @localized_legend_text_using_title,
                      :nested_forms_title => @localized_nested_forms_legend_text
                    }
                }
            }
          @form = semantic_form_for(@new_post) do |builder|
            inputs = builder.inputs :advanced_options do
            end
            concat(inputs)
            inputs =builder.inputs :name => :advanced_options_using_name do
            end
            concat(inputs)
            inputs = builder.inputs :title => :advanced_options_using_title do
            end
            concat(inputs)
            inputs = builder.inputs :nested_forms_title, :for => :authors do |nf|
            end
            concat(inputs)
          end
        end

        it 'should render a fieldset with a localized legend inside the form' do
          output_buffer.concat(@form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text_using_name}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@localized_legend_text_using_title}$/)
          output_buffer.should have_tag("form fieldset legend", /^#{@localized_nested_forms_legend_text}$/)
        end
      end
    end

    describe 'when other options are provided' do
      before do
        @id_option = 'advanced'
        @class_option = 'wide'

        @form = semantic_form_for(@new_post) do |builder|
          builder.inputs :id => @id_option, :class => @class_option do
          end
        end
      end

      it 'should pass the options into the fieldset tag as attributes' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag("form fieldset##{@id_option}")
        output_buffer.should have_tag("form fieldset.#{@class_option}")
      end
    end

  end

  describe 'without a block' do

    before do
      ::Post.stub!(:reflections).and_return({:author => mock('reflection', :options => {}, :macro => :belongs_to),
                                           :comments => mock('reflection', :options => {}, :macro => :has_many) })
      ::Author.stub!(:find).and_return([@fred, @bob])

      @new_post.stub!(:title)
      @new_post.stub!(:body)
      @new_post.stub!(:author_id)

      @new_post.stub!(:column_for_attribute).with(:title).and_return(mock('column', :type => :string, :limit => 255))
      @new_post.stub!(:column_for_attribute).with(:body).and_return(mock('column', :type => :text))
      @new_post.stub!(:column_for_attribute).with(:created_at).and_return(mock('column', :type => :datetime))
      @new_post.stub!(:column_for_attribute).with(:author).and_return(nil)
    end

    describe 'with no args' do
      before do
        @form = semantic_form_for(@new_post) do |builder|
          concat(builder.inputs)
        end
      end

      it 'should render a form' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form')
      end

      it 'should render a fieldset inside the form' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs')
      end

      it 'should not render a legend in the fieldset' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should_not have_tag('form > fieldset.inputs > legend')
      end

      it 'should render an ol in the fieldset' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol')
      end

      it 'should render a list item in the ol for each column and reflection' do
        # Remove the :has_many macro and :created_at column
        count = ::Post.content_columns.size + ::Post.reflections.size - 2
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol > li', :count => count)
      end

      it 'should render a string list item for title' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol > li.string')
      end

      it 'should render a text list item for body' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol > li.text')
      end

      it 'should render a select list item for author_id' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol > li.select', :count => 1)
      end

      it 'should not render timestamps inputs by default' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should_not have_tag('form > fieldset.inputs > ol > li.datetime')
      end
    end

    describe 'with column names as args' do
      describe 'and an object is given' do
        it 'should render a form with a fieldset containing two list items' do
          form = semantic_form_for(@new_post) do |builder|
            concat(builder.inputs(:title, :body))
          end

          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag('form > fieldset.inputs > ol > li', :count => 2)
          output_buffer.should have_tag('form > fieldset.inputs > ol > li.string')
          output_buffer.should have_tag('form > fieldset.inputs > ol > li.text')
        end
      end

      describe 'and no object is given' do
        it 'should render a form with a fieldset containing two list items' do
          form = semantic_form_for(:project, :url => 'http://test.host') do |builder|
            concat(builder.inputs(:title, :body))
          end

          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag('form > fieldset.inputs > ol > li.string', :count => 2)
        end
      end
    end

    describe 'when a :for option is provided' do
      describe 'and an object is given' do
        it 'should render nested inputs' do
          @bob.stub!(:column_for_attribute).and_return(mock('column', :type => :string, :limit => 255))
          form = semantic_form_for(@new_post) do |builder|
            concat(builder.inputs(:login, :for => @bob))
          end

          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form fieldset.inputs #post_author_login")
          output_buffer.should_not have_tag("form fieldset.inputs #author_login")
        end
      end

      describe 'and no object is given' do
        it 'should render nested inputs' do
          form = semantic_form_for(:project, :url => 'http://test.host/') do |builder|
            concat(builder.inputs(:login, :for => @bob))
          end
          output_buffer.concat(form) if Formtastic::Util.rails3?
          output_buffer.should have_tag("form fieldset.inputs #project_author_login")
          output_buffer.should_not have_tag("form fieldset.inputs #project_login")
        end
      end
    end

    describe 'with column names and an options hash as args' do
      before do
        @form = semantic_form_for(@new_post) do |builder|
          @legend_text_using_option = "Legendary Legend Text"
          @legend_text_using_arg = "Legendary Legend Text 2"
          concat(builder.inputs(:title, :body, :name => @legend_text_using_option, :id => "my-id"))
          concat(builder.inputs(@legend_text_using_arg, :title, :body, :id => "my-id-2"))
        end
      end

      it 'should render a form with a fieldset containing two list items' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset.inputs > ol > li', :count => 4)
      end

      it 'should pass the options down to the fieldset' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset#my-id.inputs')
      end

      it 'should use the special :name option as a text for the legend tag' do
        output_buffer.concat(@form) if Formtastic::Util.rails3?
        output_buffer.should have_tag('form > fieldset#my-id.inputs > legend', /^#{@legend_text_using_option}$/)
        output_buffer.should have_tag('form > fieldset#my-id-2.inputs > legend', /^#{@legend_text_using_arg}$/)
      end
    end

  end
end