text:
from __future__ import (absolute_import, division, generators, nested_scopes, print_function,
                        unicode_literals, with_statement)

import hashlib
import logging
import os
import re
import select
import threading
import time

from six import string_types
from twitter.common.collections import maybe_list

from pants.base.build_environment import get_buildroot
from pants.java.executor import Executor, SubprocessExecutor
from pants.java.nailgun_client import NailgunClient
from pants.pantsd.process_manager import ProcessGroup, ProcessManager
from pants.util.dirutil import safe_open

logger = logging.getLogger(__name__)

class NailgunProcessGroup(ProcessGroup):
  _NAILGUN_KILL_LOCK = threading.Lock()

  def __init__(self):
    ProcessGroup.__init__(self, name='nailgun')
    # TODO: this should enumerate the .pids dir first, then fallback to ps enumeration (& warn).

  def _iter_nailgun_instances(self, everywhere=False):
    def predicate(proc):
      if proc.name() == NailgunExecutor._PROCESS_NAME:
        if not everywhere:
          return NailgunExecutor._PANTS_NG_ARG in proc.cmdline()
        else:
          return any(arg.startswith(NailgunExecutor._PANTS_NG_ARG_PREFIX) for arg in proc.cmdline())

    return self.iter_instances(predicate)

  def killall(self, everywhere=False):
    """Kills all nailgun servers started by pants.

       :param bool everywhere: If ``True``, kills all pants-started nailguns on this machine;
                               otherwise restricts the nailguns killed to those started for the
                               current build root.
    """
    with self._NAILGUN_KILL_LOCK:
      for proc in self._iter_nailgun_instances(everywhere):
        logger.info('killing nailgun server pid={pid}'.format(pid=proc.pid))
        proc.terminate()

# TODO: Once we integrate standard logging into our reporting framework, we can consider making
# some of the log.debug() below into log.info(). Right now it just looks wrong on the console.
class NailgunExecutor(Executor, ProcessManager):
  """Executes java programs by launching them in nailgun server.

     If a nailgun is not available for a given set of jvm args and classpath, one is launched and
     re-used for the given jvm args and classpath on subsequent runs.
  """

  # 'NGServer 0.9.1 started on 127.0.0.1, port 53785.'
  _NG_PORT_REGEX = re.compile(r'.*\s+port\s+(\d+)\.$')

  # Used to identify if we own a given nailgun server.
  _PANTS_NG_ARG_PREFIX = b'-Dpants.buildroot'
  _PANTS_FINGERPRINT_ARG_PREFIX = b'-Dpants.nailgun.fingerprint'
  _PANTS_OWNER_ARG_PREFIX = b'-Dpants.nailgun.owner'
  _PANTS_NG_ARG = '='.join((_PANTS_NG_ARG_PREFIX, get_buildroot()))

  _NAILGUN_SPAWN_LOCK = threading.Lock()
  _SELECT_WAIT = 1
  _PROCESS_NAME = b'java'

  def __init__(self, identity, workdir, nailgun_classpath, distribution, ins=None,
               connect_timeout=10, connect_attempts=5):
    Executor.__init__(self, distribution=distribution)
    ProcessManager.__init__(self, name=identity, process_name=self._PROCESS_NAME)

    if not isinstance(workdir, string_types):
      raise ValueError('Workdir must be a path string, not: {workdir}'.format(workdir=workdir))

    self._identity = identity
    self._workdir = workdir
    self._ng_stdout = os.path.join(workdir, 'stdout')
    self._ng_stderr = os.path.join(workdir, 'stderr')
    self._nailgun_classpath = maybe_list(nailgun_classpath)
    self._ins = ins
    self._connect_timeout = connect_timeout
    self._connect_attempts = connect_attempts

  def __str__(self):
    return 'NailgunExecutor({identity}, dist={dist}, pid={pid} socket={socket})'.format(
      identity=self._identity, dist=self._distribution, pid=self.pid, socket=self.socket)

  def _parse_fingerprint(self, cmdline):
    fingerprints = [cmd.split('=')[1] for cmd in cmdline if cmd.startswith(
      self._PANTS_FINGERPRINT_ARG_PREFIX + '=')]
    return fingerprints[0] if fingerprints else None

  @property
  def fingerprint(self):
    """This provides the nailgun fingerprint of the running process otherwise None."""
    if self.cmdline:
      return self._parse_fingerprint(self.cmdline)

  def _create_owner_arg(self, workdir):
    # Currently the owner is identified via the full path to the workdir.
    return '='.join((self._PANTS_OWNER_ARG_PREFIX, workdir))

  def _create_fingerprint_arg(self, fingerprint):
    return '='.join((self._PANTS_FINGERPRINT_ARG_PREFIX, fingerprint))

  @staticmethod
  def _fingerprint(jvm_options, classpath, java_version):
    """Compute a fingerprint for this invocation of a Java task.

       :param list jvm_options: JVM options passed to the java invocation
       :param list classpath: The -cp arguments passed to the java invocation
       :param Revision java_version: return value from Distribution.version()
       :return: a hexstring representing a fingerprint of the java invocation
    """
    digest = hashlib.sha1()
    # TODO(John Sirois): hash classpath contents?
    [digest.update(item) for item in (''.join(sorted(jvm_options)),
                                      ''.join(sorted(classpath)),
                                      repr(java_version))]
    return digest.hexdigest()

  def _runner(self, classpath, main, jvm_options, args, cwd=None):
    """Runner factory. Called via Executor.execute()."""
    command = self._create_command(classpath, main, jvm_options, args)

    class Runner(self.Runner):
      @property
      def executor(this):
        return self

      @property
      def command(self):
        return list(command)

      def run(this, stdout=None, stderr=None, cwd=None):
        nailgun = self._get_nailgun_client(jvm_options, classpath, stdout, stderr)
        try:
          logger.debug('Executing via {ng_desc}: {cmd}'.format(ng_desc=nailgun, cmd=this.cmd))
          return nailgun(main, cwd, *args)
        except nailgun.NailgunError as e:
          self.terminate()
          raise self.Error('Problem launching via {ng_desc} command {main} {args}: {msg}'
                           .format(ng_desc=nailgun, main=main, args=' '.join(args), msg=e))

    return Runner()

  def _check_nailgun_state(self, new_fingerprint):
    running = self.is_alive()
    updated = running and (self.fingerprint != new_fingerprint or
                           self.cmd != self._distribution.java)
    logging.debug('Nailgun {nailgun} state: updated={up!s} running={run!s} fingerprint={old_fp} '
                  'new_fingerprint={new_fp} distribution={old_dist} new_distribution={new_dist}'
                  .format(nailgun=self._identity, up=updated, run=running,
                          old_fp=self.fingerprint, new_fp=new_fingerprint,
                          old_dist=self.cmd, new_dist=self._distribution.java))
    return running, updated

  def _get_nailgun_client(self, jvm_options, classpath, stdout, stderr):
    """This (somewhat unfortunately) is the main entrypoint to this class via the Runner. It handles
       creation of the running nailgun server as well as creation of the client."""
    classpath = self._nailgun_classpath + classpath
    new_fingerprint = self._fingerprint(jvm_options, classpath, self._distribution.version)

    with self._NAILGUN_SPAWN_LOCK:
      running, updated = self._check_nailgun_state(new_fingerprint)

      if running and updated:
        logger.debug('Found running nailgun server that needs updating, killing {server}'
                     .format(server=self._identity))
        self.terminate()

      if (not running) or (running and updated):
        return self._spawn_nailgun_server(new_fingerprint, jvm_options, classpath, stdout, stderr)

    return self._create_ngclient(self.socket, stdout, stderr)

  def _await_socket(self, timeout):
    """Blocks for the nailgun subprocess to bind and emit a listening port in the nailgun stdout."""
    with safe_open(self._ng_stdout, 'r') as ng_stdout:
      start_time = time.time()
      while 1:
        readable, _, _ = select.select([ng_stdout], [], [], self._SELECT_WAIT)
        if readable:
          line = ng_stdout.readline()                          # TODO: address deadlock risk here.
          try:
            return self._NG_PORT_REGEX.match(line).group(1)
          except AttributeError:
            pass

        if (time.time() - start_time) > timeout:
          raise NailgunClient.NailgunError(
            'Failed to read nailgun output after {sec} seconds!'.format(sec=timeout))

  def _create_ngclient(self, port, stdout, stderr):
    return NailgunClient(port=port, ins=self._ins, out=stdout, err=stderr, workdir=get_buildroot())

  def ensure_connectable(self, nailgun):
    """Ensures that a nailgun client is connectable or raises NailgunError."""
    attempt_count = 0
    while 1:
      if attempt_count > self._connect_attempts:
        logger.debug('Failed to connect to ng after {count} attempts'
                     .format(count=self._connect_attempts))
        raise NailgunClient.NailgunError('Failed to connect to ng server.')

      try:
        sock = nailgun.try_connect()
        if sock:
          logger.debug('Connected to ng server {server!r}'.format(server=self))
          return
      finally:
        sock.close()

      attempt_count += 1
      time.sleep(self.WAIT_INTERVAL)

  def _spawn_nailgun_server(self, fingerprint, jvm_options, classpath, stdout, stderr):
    """Synchronously spawn a new nailgun server."""
    # Truncate the nailguns stdout & stderr.
    self._write_file(self._ng_stdout, '')
    self._write_file(self._ng_stderr, '')

    jvm_options = jvm_options + [self._PANTS_NG_ARG,
                                 self._create_owner_arg(self._workdir),
                                 self._create_fingerprint_arg(fingerprint)]

    post_fork_child_opts = dict(fingerprint=fingerprint,
                                jvm_options=jvm_options,
                                classpath=classpath,
                                stdout=stdout,
                                stderr=stderr)

    logger.debug('Spawning nailgun server {i} with fingerprint={f}, jvm_options={j}, classpath={cp}'
                 .format(i=self._identity, f=fingerprint, j=jvm_options, cp=classpath))

    self.daemon_spawn(post_fork_child_opts=post_fork_child_opts)

    # Wait for and write the port information in the parent so we can bail on exception/timeout.
    self.await_pid(self._connect_timeout)
    self.write_socket(self._await_socket(self._connect_timeout))

    logger.debug('Spawned nailgun server {i} with fingerprint={f}, pid={pid} port={port}'
                 .format(i=self._identity, f=fingerprint, pid=self.pid, port=self.socket))

    client = self._create_ngclient(self.socket, stdout, stderr)
    self.ensure_connectable(client)

    return client

  def post_fork_child(self, fingerprint, jvm_options, classpath, stdout, stderr):
    """Post-fork() child callback for ProcessManager.daemon_spawn()."""
    java = SubprocessExecutor(self._distribution)

    subproc = java.spawn(classpath=classpath,
                         main='com.martiansoftware.nailgun.NGServer',
                         jvm_options=jvm_options,
                         args=[':0'],
                         stdin=safe_open('/dev/null', 'r'),
                         stdout=safe_open(self._ng_stdout, 'w'),
                         stderr=safe_open(self._ng_stderr, 'w'),
                         close_fds=True)

    self.write_pid(subproc.pid)


text:
package org.jsonschema2pojo.util;

import android.os.Parcel;
import android.os.Parcelable.Creator;
import com.sun.codemodel.*;
import static org.jsonschema2pojo.util.Models.*;

public class ParcelableHelper {

    public void addWriteToParcel(JDefinedClass jclass) {
        JMethod method = jclass.method(JMod.PUBLIC, void.class, "writeToParcel");
        JVar dest = method.param(Parcel.class, "dest");
        method.param(int.class, "flags");

        for (JFieldVar f : jclass.fields().values()) {
            if( (f.mods().getValue() & JMod.STATIC) == JMod.STATIC ) {
                continue;
            }
            if (f.type().erasure().name().equals("List")) {
                method.body().invoke(dest, "writeList").arg(f);
            } else {
                method.body().invoke(dest, "writeValue").arg(f);
            }
        }
    }

    public void addDescribeContents(JDefinedClass jclass) {
        JMethod method = jclass.method(JMod.PUBLIC, int.class, "describeContents");
        method.body()._return(JExpr.lit(0));
    }

    public void addCreator(JDefinedClass jclass) {
        JClass creatorType = jclass.owner().ref(Creator.class).narrow(jclass);
        JDefinedClass creatorClass = jclass.owner().anonymousClass(creatorType);

        addCreateFromParcel(jclass, creatorClass);
        addNewArray(jclass, creatorClass);

        JFieldVar creatorField = jclass.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, creatorType, "CREATOR");
        creatorField.init(JExpr._new(creatorClass));
    }

    private void addNewArray(JDefinedClass jclass, JDefinedClass creatorClass) {
        JMethod newArray = creatorClass.method(JMod.PUBLIC, jclass.array(), "newArray");
        newArray.param(int.class, "size");
        newArray.body()._return(JExpr.direct("new " + jclass.name() + "[size]"));
    }

    private void addCreateFromParcel(JDefinedClass jclass, JDefinedClass creatorClass) {
        JMethod createFromParcel = creatorClass.method(JMod.PUBLIC, jclass, "createFromParcel");
        JVar in = createFromParcel.param(Parcel.class, "in");
        JVar instance = createFromParcel.body().decl(jclass, "instance", JExpr._new(jclass));
        suppressWarnings(createFromParcel, "unchecked");
        for (JFieldVar f : jclass.fields().values()) {
            if( (f.mods().getValue() & JMod.STATIC) == JMod.STATIC ) {
                continue;
            }
            if (f.type().erasure().name().equals("List")) {
                createFromParcel.body()
                        .invoke(in, "readList")
                        .arg(instance.ref(f))
                        .arg(JExpr.direct(getGenericType(f.type()) + ".class.getClassLoader()"));
             } else {
                createFromParcel.body().assign(
                        instance.ref(f),
                        JExpr.cast(
                                f.type(),
                                in.invoke("readValue").arg(JExpr.direct(f.type().erasure().name() + ".class.getClassLoader()"))
                        )
                );
            }

        }
        createFromParcel.body()._return(instance);
    }

    private String getGenericType(JType jType) {
        if (jType.erasure().name().equals("List")) {
            final String typeName = jType.fullName();
            int start = 0;
            int end = typeName.length();

            for (int i = 0; i < typeName.length(); ++i) {
                switch (typeName.charAt(i)) {
                    case '<':
                        start = i;
                        break;
                    case '>':
                        end = i;
                        break;
                }
            }
            // plus one for excluding '<'
            return typeName.substring(start+1, end);
        }
        return jType.erasure().name();
    }

}

redpajama_set_name: RedPajamaGithub


text:
  <title>clans.io</title>
  <meta http-equiv="x-ua-compatible" content="IE=edge" />
  <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-touch-fullscreen" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  <link rel="apple-touch-icon" href="/images/apple-touch-icon.png"/>

<template name="layout">
  {{> drawer }}

      {{> yield }}

</template>


text:
module Autocomplete
  # Finder for retrieving a group to use for autocomplete data sources.
  class GroupFinder
    attr_reader :current_user, :project, :group_id

    # current_user - The currently logged in user, if any.
    # project - The Project (if any) to use for the autocomplete data sources.
    # params - A Hash containing parameters to use for finding the project.
    #
    # The following parameters are supported:
    #
    # * group_id: The ID of the group to find.
    def initialize(current_user = nil, project = nil, params = {})
      @current_user = current_user
      @project = project
      @group_id = params[:group_id]
    end

    # Attempts to find a Group based on the current group ID.
    def execute
      return unless project.blank? && group_id.present?

      group = Group.find(group_id)

      # This removes the need for using `return render_404` and similar patterns
      # in controllers that use this finder.
      unless Ability.allowed?(current_user, :read_group, group)
        raise ActiveRecord::RecordNotFound
          .new("Could not find a Group with ID #{group_id}")
      end

      group
    end
  end
end


text:
				ServerMap

					Search Depth
					( Inbound  Outbound)

						<button type="button" class="btn btn-default">
							 {{callee}}  {{caller}}
						</button>
						<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" style="padding-bottom:6px">

							Toggle Dropdown
						</button>

 Inbound

{{d}}

 Outbound

{{d}}

								<button type="button" class="btn btn-default btn-xs" style="float:right;" ng-click="closeInOut()">Close</button>

					Search Period
					<select class="period form-control" ng-change="changePeriod()" ng-model="period" style="width:60%;display:inline-block;height:30px;">
						<option ng-repeat="per in periodTime" ng-selected="per == period" value="{{per}}">{{per}}</option>
					</select>

				Favorite Application

					<application-list-directive init-app-name="" use-favorite="false" not-set-open="false" ></application-list-directive>

 {{fav.split('@')[0]}} <button class="btn btn-danger btn-xs" style="float:right" ng-click="removeFavorite(fav)"></button>


text:
extern mod std;
use std::sync;
fn main() {
    let x = ~sync::RWlock();
    let mut y = None;
    do x.write_downgrade |write_mode| {
        y = Some(write_mode);
    }
    // Adding this line causes a method unification failure instead
    // do (&option::unwrap(y)).write { }
}


text:
<?php $this->pageTitle=Yii::app()->name . ' - Reset Password';
?>

<?php if(Yii::app()->user->hasFlash('reset')): ?>

	<?php echo Yii::app()->user->getFlash('reset'); ?>

<?php else: ?>

Reset Password

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'reset-form',
	'enableClientValidation'=>true,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
)); ?>

		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'password'); ?>

		<?php echo $form->labelEx($model,'confirm'); ?>
		<?php echo $form->passwordField($model,'confirm',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'confirm'); ?>

		<?php echo CHtml::submitButton('Submit'); ?>
	<?php $this->endWidget(); ?>

	<?php endif; ?>


text:
namespace AggregateSource
{
    public class AggregateRootEntityStub : AggregateRootEntity
    {
    }
}


text:
<!--<?xml version="1.0" encoding="utf-8" ?>-->
<StructureMap MementoStyle="Attribute">
  <Assembly Name="StructureMap.Testing.Widget"/>
  <Assembly Name="StructureMap.Testing.Widget2"/>
  <Assembly Name="StructureMap.Testing.Widget3"/>

  <PluginFamily Type="StructureMap.Testing.Widget.IWidget" Assembly="StructureMap.Testing.Widget" DefaultKey="Red">
    <Instance Key="Red" Type="Color" color="Red" />
    <Instance Key="Blue" Type="Color" color="Blue" />
    <Plugin Assembly="StructureMap.Testing.Widget" Type="StructureMap.Testing.Widget.NotPluggableWidget" ConcreteKey="NotPluggable"/>
  </PluginFamily>

  <PluginFamily Type="StructureMap.Testing.Widget.Rule" Assembly="StructureMap.Testing.Widget" DefaultKey="Blue">
    <Instance Key="Red" Type="Color" color="Red" />
    <Instance Key="Blue" Type="Color" color="Blue" />
    <Instance Key="Bigger" Type="GreaterThan" Attribute="MyDad" Value="10" />
  </PluginFamily>

  <AddInstance PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget"  Type="Default" Key="Tommy" RightHanded="false" BirthYear="1972"/>

  <AddInstance
    PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget"
    Type="Default"
    Key="Todd"
    RightHanded="true"
    BirthYear="1975" />

  <AddInstance PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget"   Type="Leftie" Key="Trevor" BirthYear="1979" />
  <AddInstance PluginType="StructureMap.Testing.Widget.Child, StructureMap.Testing.Widget" Type="Default" Key="Tom" Name="Tom">
    <MyGrandChild Type="Leftie" BirthYear="1984" />
  </AddInstance>

</StructureMap>


text:
header {
    position: relative;
    background-color: black;
    height: 75vh;
    min-height: 25rem;
    width: 100%;
    overflow: hidden;
  }

  header video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 0;
    -ms-transform: translateX(-50%) translateY(-50%);
    -moz-transform: translateX(-50%) translateY(-50%);
    -webkit-transform: translateX(-50%) translateY(-50%);
    transform: translateX(-50%) translateY(-50%);
  }

  header .container {
    position: relative;
    z-index: 2;
  }

  header .overlay {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: black;
    opacity: 0.5;
    z-index: 1;
  }

  @media (pointer: coarse) and (hover: none) {
    header {
      background: url('https://source.unsplash.com/XT5OInaElMw/1600x900') black no-repeat center center scroll;
    }
    header video {
      display: none;
    }
  }


text:
class NFCSkillConsumeManagerModule
    : public NFISkillConsumeManagerModule,
      NFMap<int, NFISkillConsumeProcessModule>
{
public:
    NFCSkillConsumeManagerModule( NFIPluginManager* p )
    {
        pPluginManager = p;
    }
    virtual bool Init();
    virtual bool Shut();
    virtual bool Execute();
    virtual bool AfterInit();

    virtual bool ResgisterConsumeModule( const int nModuleType, NFISkillConsumeProcessModule* pModule );

    virtual NFISkillConsumeProcessModule* GetConsumeModule( const int nModuleType );

};

#endif


text:
package Paws::RDS::CreateDBSecurityGroupResult;
  use Moose;
  has DBSecurityGroup => (is => 'ro', isa => 'Paws::RDS::DBSecurityGroup');

  has _request_id => (is => 'ro', isa => 'Str');
1;

### main pod documentation begin ###

=head1 NAME

Paws::RDS::CreateDBSecurityGroupResult

=head1 ATTRIBUTES

=head2 DBSecurityGroup => L<Paws::RDS::DBSecurityGroup>

=head2 _request_id => Str

=cut


text:
namespace LegendaryClient.Controls
{
    /// <summary>
    ///     Interaction logic for BotControl.xaml
    /// </summary>
    public partial class BotControl
    {
        public BotControl()
        {
            InitializeComponent();
        }

        public int difficulty { get; set; }
        public bool blueSide { get; set; }
    }
}


text:
{-# LANGUAGE TypeFamilies #-}
module ALife.Realtra.Config where

import ALife.Creatur.Universe (CachedUniverse, mkCachedUniverse)
import ALife.Realtra.ImageDB (mkImageDB)
import ALife.Realtra.Wain (Astronomer, Config(..))

onServer :: Bool
onServer = False

config :: Config (CachedUniverse Astronomer)
config = Config
  {
    universe
      = mkCachedUniverse
          "Mnist"                  -- experiment name
          "/home/amy/alife/mnist1" -- directory
          (if onServer             -- cache size (in bytes)
             then 10000000000
             else 20000000),

    statsFile = "/home/amy/alife/mnist1/stats",
    rawStatsFile = "/home/amy/alife/mnist1/rawStats",

    -- Number of microseconds to sleep after each agent gets its turn
    -- at the CPU.
    sleepBetweenTasks = 0,

    imageDB = mkImageDB "/home/amy/mnist/testDataWithAnomalies",

    imageHeight = 28,
    imageWidth = 28,

    -- The classifier portion of a wain's brain is a Self-Organising Map
    -- (SOM). This SOM uses a hexagonal grid with hexagonal tiles. The
    -- setting below controls the maximum length of one side of the
    -- grid, for the /initial/ population. The processing time required
    -- is proportional to the square of this value.
    initialPopulationClassifierSizeRange =
      if onServer then (2, 5) else (2, 3),

    -- The decider portion of a wain's brain is also a SOM, using a
    -- hexagonal grid with hexagonal tiles. The setting below controls
    -- the maximum length of one side of the grid,
    -- for the /initial/ population. The processing time
    -- required is proportional to the square of this value.
    initialPopulationDeciderSizeRange = (2, 5),

    -- The maximum amount of energy that wains in the initial population
    -- give to their children at birth.
    initialPopulationDevotionRange = (0, 0.3),

    -- The maximum age at which wains mature in the initial population.
    initialPopulationMaturityRange =
      if onServer then (1, 50) else (1, 2),

    -- The size of the initial population.
    initialPopulationSize = if onServer then 200 else 20,

    easementTime = 250,
    easementCooperationBonus = 0.1,
    easementAgreementBonus = 0.9,

    energyPoolSize = 1000,

    -- The daemon will stop if the population falls outside this range.
    -- This gives you a chance to analyse the problem and perhaps
    -- adjust your configuration.
    populationSizeRange = if onServer then (100, 300) else (4,20),

    -- To ensure that smaller agents don't have an excessive advantage
    -- over larger agents, part of the metabolic cost is fixed.
    -- Compare with maxSizeBasedMetabolismDeltaE.
    -- This is normally an energy LOSS, so it should be negative.
    -- You probably won't need to alter this field.
    baseMetabolismDeltaE = -0.005,

    -- To ensure that agents use resources efficiently, part of their
    -- metabolic cost is based on their size.
    -- If you don't know what value to use, multiply the average size
    -- of your initial population by -0.001 and use that.
    -- This is normally an energy LOSS, so it should be negative.
    energyCostPerByte = -0.00000001,

    -- A wain rearing a child pays a fraction of the metabolic cost
    -- that the child would pay if it were full-grown. It's only a
    -- fraction because, biologically speaking, a child is only
    -- completely helpless when it's small (so the resource
    -- cost of raising it would be small).
    -- You probably won't need to alter this field.
    childCostFactor = 0.2,

    -- *** Controlling the frequency of flirting

    -- Every time an agent flirts, its energy changes by a fixed amount.
    -- This is normally an energy LOSS, so it should be negative.
    flirtingDeltaE = -0.05,

    -- Note: Passion is reset to zero after mating.

    -- *** Controlling the frequency of co-operation

    -- When an agent initiates co-operation (trading classifications), its
    -- energy changes by a fixed amount.
    -- This is normally an energy LOSS, so it should be negative.
    cooperationDeltaE = -0.01,

    -- When two agents co-operate, and agree on a classification,
    -- their energy changes by this amount, multiplied by the
    -- novelty of the image.
    -- This is in addition to minimum agreement energy change.
    -- This is normally an energy GAIN, so it should be positive.
    noveltyBasedCooperationAgreementDeltaE = 0.9,

    -- When two agents co-operate, and agree on a classification,
    -- their energy changes by this amount.
    -- This is in addition to the energy change based on novelty.
    -- This is normally an energy GAIN, so it should be positive.
    minCooperationAgreementDeltaE = 0.1,

    -- The range of values allowed for r0 (the learning rate applied to
    -- the BMU at time 0) in the learning function for the
    -- classifier in the initial population.
    classifierR0Range = (0, 1),

    -- The range of values allowed for rf (the learning rate applied to
    -- the BMU at time tf) in the learning function for the
    -- classifier in the initial population.
    classifierRfRange = (0, 1),

    -- The range of values allowed for w0 (the neighbourhood width at
    -- time 0) in the learning function for the
    -- classifier in the initial population.
    classifierW0Range = (0, 5),

    -- The range of values allowed for wf (the neighbourhood width at
    -- time tf) in the learning function for the
    -- classifier in the initial population.
    classifierWfRange = (0, 5),

    -- The range of values allowed for tf (the time at which the learning
    -- rate becomes negligible) in the learning function for the
    -- classifier in the initial population.
    classifierTfRange = (1, 10000),

    -- The range of values allowed for r0 (the learning rate applied to
    -- the BMU at time 0) in the learning function for the
    -- decider in the initial population.
    deciderR0Range = (0, 1),

    -- The range of values allowed for rf (the learning rate applied to
    -- the BMU at time tf) in the learning function for the
    -- decider in the initial population.
    deciderRfRange = (0, 1),

    -- The range of values allowed for w0 (the neighbourhood width at
    -- time 0) in the learning function for the
    -- decider in the initial population.
    deciderW0Range = (0, 5),

    -- The range of values allowed for wf (the neighbourhood width at
    -- time tf) in the learning function for the
    -- decider in the initial population.
    deciderWfRange = (0, 5),

    -- The range of values allowed for tf (the time at which the learning
    -- rate becomes negligible) in the learning function for the
    -- decider in the initial population.
    deciderTfRange = (1, 10000)
  }