text:
layout: post
title: 倒装句
tags: 新东方英语笔记
catalog: true
---
- I will have -> will I have

  此句为不完全倒装(仍有谓语在主语后)

- Here comes the bus.

  此句为完全倒装(谓语全都在主语后)

### 倒装句出现的情景

#### Only + 状语:放在*句首* **不完全倒装**

- We can help him only in this way.

  Only in this way can we help him.

- We can improve our English only by listening to the teacher.

  Only by listening to the teacher can we improve our English.

- We can get out of here only when the guards are all sleep.

  Only when the guards are all sleep can we get out of here.

- **修饰*非*状语时不倒装**

  Only the teacher can get in.


text:
(function(global, utils) {

"use strict";

%CheckIsBootstrapping();

// -------------------------------------------------------------------
// Imports

var GlobalObject = global.Object;
var MakeRangeError;
var MakeTypeError;
var MaxSimple;
var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");

utils.Import(function(from) {
  MakeTypeError = from.MakeTypeError;
  MakeRangeError = from.MakeRangeError;
  MaxSimple = from.MaxSimple;
});

// -------------------------------------------------------------------

function CheckSharedIntegerTypedArray(ia) {
  if (!%IsSharedIntegerTypedArray(ia)) {
    throw MakeTypeError(kNotIntegerSharedTypedArray, ia);
  }
}

function CheckSharedInteger32TypedArray(ia) {
  CheckSharedIntegerTypedArray(ia);
  if (!%IsSharedInteger32TypedArray(ia)) {
    throw MakeTypeError(kNotInt32SharedTypedArray, ia);
  }
}

// https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess
function ValidateIndex(index, length) {
  var numberIndex = TO_NUMBER(index);
  var accessIndex = TO_INTEGER(numberIndex);
  if (numberIndex !== accessIndex) {
    throw MakeRangeError(kInvalidAtomicAccessIndex);
  }
  if (accessIndex < 0 || accessIndex >= length) {
    throw MakeRangeError(kInvalidAtomicAccessIndex);
  }
  return accessIndex;
}

//-------------------------------------------------------------------

function AtomicsCompareExchangeJS(sta, index, oldValue, newValue) {
  CheckSharedIntegerTypedArray(sta);
  index = ValidateIndex(index, %_TypedArrayGetLength(sta));
  oldValue = TO_NUMBER(oldValue);
  newValue = TO_NUMBER(newValue);
  return %_AtomicsCompareExchange(sta, index, oldValue, newValue);
}

function AtomicsAddJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsAdd(ia, index, value);
}

function AtomicsSubJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsSub(ia, index, value);
}

function AtomicsAndJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsAnd(ia, index, value);
}

function AtomicsOrJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsOr(ia, index, value);
}

function AtomicsXorJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsXor(ia, index, value);
}

function AtomicsExchangeJS(ia, index, value) {
  CheckSharedIntegerTypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  value = TO_NUMBER(value);
  return %_AtomicsExchange(ia, index, value);
}

function AtomicsIsLockFreeJS(size) {
  return %_AtomicsIsLockFree(size);
}

// Futexes

function AtomicsFutexWaitJS(ia, index, value, timeout) {
  CheckSharedInteger32TypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  if (IS_UNDEFINED(timeout)) {
    timeout = INFINITY;
  } else {
    timeout = TO_NUMBER(timeout);
    if (NUMBER_IS_NAN(timeout)) {
      timeout = INFINITY;
    } else {
      timeout = MaxSimple(0, timeout);
    }
  }
  return %AtomicsFutexWait(ia, index, value, timeout);
}

function AtomicsFutexWakeJS(ia, index, count) {
  CheckSharedInteger32TypedArray(ia);
  index = ValidateIndex(index, %_TypedArrayGetLength(ia));
  count = MaxSimple(0, TO_INTEGER(count));
  return %AtomicsFutexWake(ia, index, count);
}

function AtomicsFutexWakeOrRequeueJS(ia, index1, count, value, index2) {
  CheckSharedInteger32TypedArray(ia);
  index1 = ValidateIndex(index1, %_TypedArrayGetLength(ia));
  count = MaxSimple(0, TO_INTEGER(count));
  value = TO_INT32(value);
  index2 = ValidateIndex(index2, %_TypedArrayGetLength(ia));
  if (index1 < 0 || index1 >= %_TypedArrayGetLength(ia) ||
      index2 < 0 || index2 >= %_TypedArrayGetLength(ia)) {
    return UNDEFINED;
  }
  return %AtomicsFutexWakeOrRequeue(ia, index1, count, value, index2);
}

// -------------------------------------------------------------------

var Atomics = global.Atomics;

// The Atomics global is defined by the bootstrapper.

%AddNamedProperty(Atomics, toStringTagSymbol, "Atomics", READ_ONLY | DONT_ENUM);

// These must match the values in src/futex-emulation.h
utils.InstallConstants(Atomics, [
  "OK", 0,
  "NOTEQUAL", -1,
  "TIMEDOUT", -2,
]);

utils.InstallFunctions(Atomics, DONT_ENUM, [
  // TODO(binji): remove the rest of the (non futex) Atomics functions as they
  // become builtins.
  "compareExchange", AtomicsCompareExchangeJS,
  "add", AtomicsAddJS,
  "sub", AtomicsSubJS,
  "and", AtomicsAndJS,
  "or", AtomicsOrJS,
  "xor", AtomicsXorJS,
  "exchange", AtomicsExchangeJS,
  "isLockFree", AtomicsIsLockFreeJS,
  "futexWait", AtomicsFutexWaitJS,
  "futexWake", AtomicsFutexWakeJS,
  "futexWakeOrRequeue", AtomicsFutexWakeOrRequeueJS,
]);

})

redpajama_set_name: RedPajamaGithub


text:
import { createAction } from 'redux-smart-actions';

export const fetchPhoto = createAction('fetch photo', id => ({
  request: { url: `/photos/${id}` },
}));

export const deletePhoto = createAction('delete photo', id => ({
  request: { url: `/photos/${id}`, method: 'delete' },
  meta: {
    mutations: { [fetchPhoto]: () => null },
  },
}));

export const fetchPosts = createAction('fetch posts', () => ({
  request: { url: '/posts/' },
}));

export const deletePost = createAction('delete post', id => ({
  request: { url: `/posts/${id}`, method: 'delete' },
  meta: {
    requestKey: String(id),
    mutations: {
      [fetchPosts]: {
        updateData: data => data.filter(v => v.id !== id),
      },
    },
  },
}));


text:
package org.olat.instantMessaging.ui;

import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.instantMessaging.InstantMessagingService;
import org.olat.instantMessaging.model.Presence;

/**
 *
 * Change the status
 *
 * Initial date: 05.12.2012<br>
 * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
 *
 */
public class IMTopNavStatusController extends BasicController {

	private final Link available, unavailable, dnd;
	private final VelocityContainer mainVC;

	private String status;

	private final InstantMessagingService imService;

	public IMTopNavStatusController(UserRequest ureq, WindowControl wControl, String status) {
		super(ureq, wControl);
		this.status = status;
		imService = CoreSpringFactory.getImpl(InstantMessagingService.class);
		mainVC = createVelocityContainer("status_changer");

		available = LinkFactory.createLink("presence.available", mainVC, this);
		available.setCustomEnabledLinkCSS("o_instantmessaging_available_icon");
		dnd = LinkFactory.createLink("presence.dnd", mainVC, this);
		dnd.setCustomEnabledLinkCSS("o_instantmessaging_dnd_icon");
		unavailable = LinkFactory.createLink("presence.unavailable", mainVC, this);
		unavailable.setCustomEnabledLinkCSS("o_instantmessaging_unavailable_icon");

		putInitialPanel(mainVC);
	}

	public String getSelectedStatus() {
		return status;
	}

	@Override
	protected void doDispose() {
		//
	}

	@Override
	protected void event(UserRequest ureq, Component source, Event event) {
		if (source == available) {
			status = Presence.available.name();
			imService.updateStatus(getIdentity(), status);
			fireEvent(ureq, Event.CHANGED_EVENT);
		} else if (source == dnd) {
			status = Presence.dnd.name();
			imService.updateStatus(getIdentity(), status);
			fireEvent(ureq, Event.CHANGED_EVENT);
		} else if (source == unavailable) {
			status = Presence.unavailable.name();
			imService.updateStatus(getIdentity(), status);
			fireEvent(ureq, Event.CHANGED_EVENT);
		}
	}
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Naturalist, London 842: 97 (1952)

#### Original name
Torula diversa Cooke, 1878

### Remarks
null


text:
package com.github.jjYBdx4IL.utils.gfx;

import com.github.jjYBdx4IL.utils.env.Maven;

import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Test;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

// CHECKSTYLE:OFF
/**
 *
 * @author Github jjYBdx4IL Projects
 */
public class AnimatedGifOutputStreamTest {

    private final static File tempDir = Maven.getTempTestDir(AnimatedGifOutputStreamTest.class);

    @Before
    public void before() throws IOException {
        FileUtils.cleanDirectory(tempDir);
    }

    @Test
    public void test() throws IOException {
        final int w = 100;
        final int h = 100;
        final int frames = 100;
        final int lastIndex = frames - 1;
        try (AnimatedGifOutputStream animGifOs = new AnimatedGifOutputStream(new File(tempDir, "animated.gif"))) {
            for (int i = 0; i <= lastIndex; i++) {
                BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_GRAY);
                Graphics2D g = (Graphics2D) img.getGraphics();
                int componentValue = (i * 255 / lastIndex);
                g.setColor(new Color(0xff000000 | componentValue | (componentValue << 8) | (componentValue << 16)));
                g.fillRect(0, 0, w, h);

                animGifOs.append(img);
            }
        }
    }
}


text:
require 'hashie/mash'

module Gitter
  class Client
    module Rooms
      def rooms
        room_list = []
        self.class.get("/rooms", headers: @headers).each do |room|
          room_list << Hashie::Mash.new(room)
        end
        room_list
      end

      def room_users(room_id)
        user_list = []
        self.class.get("/rooms/#{room_id}/users", headers: @headers).each do |user|
          user_list << Hashie::Mash.new(user)
        end
        user_list
      end

      def room_channels(room_id)
        channel_list = []
        self.class.get("/rooms/#{room_id}/channels", headers: @headers).each do |channel|
          channel_list << Hashie::Mash.new(channel)
        end
        channel_list
      end

      def join_room(uri)
        Hashie::Mash.new(self.class.post("/rooms", headers: @headers, query: { uri: uri } ))
      end
    end
  end
end


text:
using System;

using JavaObject = global::Java.Lang.Object;
/*
namespace Com.Google.Android.Exoplayer2.Drm
{
    public interface IExoMediaDrmOnEventListener<JavaObject> : IExoMediaDrmOnEventListener
    {
    }
}
*/


text:
<?php

class Flyer extends CI_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('User_Model', '', TRUE);
    }

    function index() {
        if (!$this->session->userdata('logged_in')) {
            redirect('login', 'refresh');
        }

        $data['navbar'] = "dashboard";

        $data['page_title'] = 'Dashboard';
        $data['name'] = $this->session->userdata('name');
        $this->load->view('templates/header', $data);
        $this->load->view('templates/navbar_main', $data);
        $this->load->view('templates/navbar_sub', $data);
        $this->load->view('dashboard');
        $this->load->view('templates/footer');
    }

    function ListFlyers() {
        if (!$this->session->userdata('logged_in')) {
            redirect('login', 'refresh');
        }

        $data['navbar'] = "flyers";

        $data['page_title'] = 'List Flyers';
        $data['name'] = $this->session->userdata('name');
        //Call the model to get users list
        $data['flyerlist'] = $this->User_Model->listflyers();

        $this->load->view('templates/header', $data);
        $this->load->view('templates/navbar_main', $data);
        $this->load->view('templates/navbar_sub', $data);
        $this->load->view('flyer/listflyer');
        $this->load->view('templates/footer');
    }

    function ViewFlyer($id) {
        if (!$this->session->userdata('logged_in')) {
            redirect('login', 'refresh');
        }

        if (!isset($id)) {
            redirect('dashboard');
        }

        $data['navbar'] = "flyers";

        $data['page_title'] = 'View Flyers';
        $data['name'] = $this->session->userdata('name');
        //Call the model to get users list
        $data['flyerdet'] = $this->User_Model->viewflyer($id);

        //City names
        $cities = $this->User_Model->viewflyer($id);
        $cityarr = substr($cities['city'], 0, -1);
        $cityarr = explode(",", $cityarr);
        $citystring = "";
        foreach ($cityarr as $cityid) {
            $citystring .= $this->User_Model->getcitybyid($cityid) . ", ";
        }

        $data['citystring'] = $citystring;

        $this->load->view('templates/header', $data);
        $this->load->view('templates/navbar_main', $data);
        $this->load->view('templates/navbar_sub', $data);
        $this->load->view('flyer/viewflyer');
        $this->load->view('templates/footer');
    }

    function AddFlyer() {
        if (!$this->session->userdata('logged_in')) {
            redirect('login', 'refresh');
        }

        $this->load->library('form_validation');

        //uploading image
        $file_data;
        $config['upload_path'] = "./uploads/images/flyers";
        $config['allowed_types'] = 'gif|jpg|png';

        $this->load->library('upload', $config);

        $this->form_validation->set_rules('title', 'title', "trim|required");
        $this->form_validation->set_rules('description', 'description', "trim|required");

        $data['navbar'] = "flyers";

        $data['page_title'] = 'Add Flyer';
        $data['name'] = $this->session->userdata('name');

        //option box data
        $data['categorylist'] =$this->User_Model->listcategories();
        $data['citylist'] =$this->User_Model->listcities();

        //Run form validation
        if ($this->form_validation->run() == FALSE) {
            $this->load->view('templates/header', $data);
            $this->load->view('templates/navbar_main', $data);
            $this->load->view('templates/navbar_sub', $data);
            $this->load->view('flyer/addflyer');
            $this->load->view('templates/footer');
        } else{

            if($this->input->post('userfile') != NULL){
                if($this->upload->do_upload()) {
                    $file_data = $this->upload->data();

                    //City Array
                    $citydb = "";
                    $cityarr = $this->input->post('city');
                    foreach ($cityarr as $fc){
                        $citydb =  $citydb . $fc . ",";
                    }

                    $flyer_data = array(
                        'title' => $this->input->post('title'),
                        'description' => $this->input->post('description'),
                        'category' => $this->input->post('category'),
                        'city' => $citydb,
                        'display' => $this->input->post('display'),
                        'website' => $this->input->post('link'),
                        'image' => $file_data["file_name"]
                    );

                    //calling model
                    if($this->User_Model->addflyers($flyer_data)){
                        //Success Message
                        $data['succ_message'] = 'Successfully Added Flyer';
                        $this->load->view('templates/header', $data);
                        $this->load->view('templates/navbar_main', $data);
                        $this->load->view('templates/navbar_sub', $data);
                        $this->load->view('flyer/addflyer');
                        $this->load->view('templates/footer');
                    } else{
                        $data['error_message'] = 'Failed to Add Flyer';
                        $this->load->view('templates/header', $data);
                        $this->load->view('templates/navbar_main', $data);
                        $this->load->view('templates/navbar_sub', $data);
                        $this->load->view('flyer/addflyer');
                        $this->load->view('templates/footer');
                    }
                } else{

                    $data['error_message'] = $this->upload->display_errors();
                    $this->load->view('templates/header', $data);
                    $this->load->view('templates/navbar_main', $data);
                    $this->load->view('templates/navbar_sub', $data);
                    $this->load->view('flyer/addflyer');
                    $this->load->view('templates/footer');
                }
            } else{
                //City Array
                    $citydb = "";
                    $cityarr = $this->input->post('city');
                    foreach ($cityarr as $fc){
                        $citydb =  $citydb . $fc . ",";
                    }

                    $flyer_data = array(
                        'title' => $this->input->post('title'),
                        'description' => $this->input->post('description'),
                        'category' => $this->input->post('category'),
                        'city' => $citydb,
                        'display' => $this->input->post('display'),
                        'website' => $this->input->post('link')
                    );

                    //calling model
                    if($this->User_Model->addflyers($flyer_data)){
                        //Success Message
                        $data['succ_message'] = 'Successfully Added Flyer';
                        $this->load->view('templates/header', $data);
                        $this->load->view('templates/navbar_main', $data);
                        $this->load->view('templates/navbar_sub', $data);
                        $this->load->view('flyer/addflyer');
                        $this->load->view('templates/footer');
                    } else{
                        $data['error_message'] = 'Failed to Add Flyer';
                        $this->load->view('templates/header', $data);
                        $this->load->view('templates/navbar_main', $data);
                        $this->load->view('templates/navbar_sub', $data);
                        $this->load->view('flyer/addflyer');
                        $this->load->view('templates/footer');
                    }
            }
        }
    }
}


text:
To use modifiers, you must use angle-bracket syntax

### New Root component
1. Instead of using `sortable-group` as a component, use `sortable-group` as a modifier
any element. You no longer need to tell `sortable-group` about the models, so the `each`
uses the models directly.

**Old Component**
```hbs
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
  {{#each group.model as |item|}}
```
**New Component**
```hbs
<ol {{sortable-group onChange=(action "reorderItems")}}>
  {{#each model.items as |item|}}
```

2. Each `item` can be represented by any dom element or component using angle-bracket syntax

**Old Component**
```hbs
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
  {{#each group.model as |item|}}
    {{#group.item model=item}}
       {{tem.name}}
    {{/group.item}}
  {{/each}}
{{/sortable-group}}
```

**New Component with modifier**
```hbs
<ol {{sortable-group onChange=(action "reorderItems")}}>
  {{#each model.items as |item|}}
    <li {{sortable-item model=item}}>
      {{tem.name}}
    </li>
  {{/each}}
</ol>
```

3. The Handle is also any element with a `sortable-handle` applied to it.

**Old Component**
```hbs
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
  {{#each group.model as |modelItem|}}
    {{#group.item model=modelItem as|item|}}
      {{modelItem.name}}
      {{#item.handle}}
        <span class="handle">↕</span>
      {{/item.handle}}
    {{/group.item}}
  {{/each}}
{{/sortable-group}}
```

**New Component with modifier**
```hbs
<ol {{sortable-group onChange=(action "reorderItems")}}>
  {{#each model.items as |item|}}
    <li {{sortable-item model=item}}>
      {{tem.name}}
      <span class="handle" {{sortable-handle}}>↕</span>
    </li>
  {{/each}}
</ol>
```

4. The modifier `groupModel` property is no longer supported. The equivalent can
be accomplished by the `action` helper or the new `fn` helper.

```hbs
<ol {{sortable-group onChange=(action "reorderItems" model)}}>
  {{#each model.items as |item|}}
    <li {{sortable-item model=item}}>
      {{tem.name}}
      <span class="handle" {{sortable-handle}}>↕</span>
    </li>
  {{/each}}
</ol>
```


text:
package rapture.json

import rapture.core._
import rapture.data._

import scala.util.Try
import scala.collection.JavaConverters

/** Represents a JSON ast implementation which is used throughout this library */
trait JsonAst extends DataAst {

  def isScalar(any: Any) = isBoolean(any) || isNumber(any) || isString(any)

  /** Extracts a `Boolean` from the parsed JSON. */
  def getBoolean(boolean: Any): Boolean

  def fromBoolean(boolean: Boolean): Any

  /** Extracts a `String` from the parsed JSON. */
  def getString(string: Any): String

  def fromString(string: String): Any

  /** Extracts a `Double` from the parsed JSON. */
  def getDouble(number: Any): Double

  def fromDouble(number: Double): Any

  /** Extracts a `BigDecimal` from the parsed JSON. */
  def getBigDecimal(number: Any): BigDecimal

  def fromBigDecimal(number: BigDecimal): Any

  /** Tests if the element represents a `Boolean` */
  def isBoolean(any: Any): Boolean

  /** Tests if the element represents a `String` */
  def isString(any: Any): Boolean

  /** Tests if the element represents a number */
  def isNumber(any: Any): Boolean

  /** Tests if the element represents a `null` */
  def isNull(any: Any): Boolean

  /** The value used to represent a `null` */
  def nullValue: Any

  /** Returns the DataType instance for the particular type. */
  def getType(any: Any): DataTypes.DataType =
    if(isBoolean(any)) DataTypes.Boolean
    else if(isString(any)) DataTypes.String
    else if(isNumber(any)) DataTypes.Number
    else if(isObject(any)) DataTypes.Object
    else if(isArray(any)) DataTypes.Array
    else if(isNull(any)) DataTypes.Null
    else throw MissingValueException()

  protected def typeTest(pf: PartialFunction[Any, Unit])(v: Any) = pf.isDefinedAt(v)
}

trait JsonBufferAst extends JsonAst with MutableDataAst


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/spanner/admin/instance/v1/spanner_instance_admin.proto

package com.google.spanner.admin.instance.v1;

/**
 *

 * A possible configuration for a Cloud Spanner instance. Configurations
 * define the geographic placement of nodes and their replication.
 *

 *
 * Protobuf type {@code google.spanner.admin.instance.v1.InstanceConfig}
 */
public  final class InstanceConfig extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.spanner.admin.instance.v1.InstanceConfig)
    InstanceConfigOrBuilder {
  // Use InstanceConfig.newBuilder() to construct.
  private InstanceConfig(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private InstanceConfig() {
    name_ = "";
    displayName_ = "";
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
  }
  private InstanceConfig(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    int mutable_bitField0_ = 0;
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!input.skipField(tag)) {
              done = true;
            }
            break;
          }
          case 10: {
            java.lang.String s = input.readStringRequireUtf8();

            name_ = s;
            break;
          }
          case 18: {
            java.lang.String s = input.readStringRequireUtf8();

            displayName_ = s;
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.spanner.admin.instance.v1.SpannerInstanceAdminProto.internal_static_google_spanner_admin_instance_v1_InstanceConfig_descriptor;
  }

  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.spanner.admin.instance.v1.SpannerInstanceAdminProto.internal_static_google_spanner_admin_instance_v1_InstanceConfig_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.spanner.admin.instance.v1.InstanceConfig.class, com.google.spanner.admin.instance.v1.InstanceConfig.Builder.class);
  }

  public static final int NAME_FIELD_NUMBER = 1;
  private volatile java.lang.Object name_;
  /**
   *

   * A unique identifier for the instance configuration.  Values
   * are of the form
   * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
   *

   *
   * optional string name = 1;
   */
  public java.lang.String getName() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs =
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      name_ = s;
      return s;
    }
  }
  /**
   *

   * A unique identifier for the instance configuration.  Values
   * are of the form
   * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
   *

   *
   * optional string name = 1;
   */
  public com.google.protobuf.ByteString
      getNameBytes() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      name_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int DISPLAY_NAME_FIELD_NUMBER = 2;
  private volatile java.lang.Object displayName_;
  /**
   *

   * The name of this instance configuration as it appears in UIs.
   *

   *
   * optional string display_name = 2;
   */
  public java.lang.String getDisplayName() {
    java.lang.Object ref = displayName_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs =
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      displayName_ = s;
      return s;
    }
  }
  /**
   *

   * The name of this instance configuration as it appears in UIs.
   *

   *
   * optional string display_name = 2;
   */
  public com.google.protobuf.ByteString
      getDisplayNameBytes() {
    java.lang.Object ref = displayName_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      displayName_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (!getNameBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
    }
    if (!getDisplayNameBytes().isEmpty()) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, displayName_);
    }
  }

  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!getNameBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
    }
    if (!getDisplayNameBytes().isEmpty()) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, displayName_);
    }
    memoizedSize = size;
    return size;
  }

  private static final long serialVersionUID = 0L;
  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.spanner.admin.instance.v1.InstanceConfig)) {
      return super.equals(obj);
    }
    com.google.spanner.admin.instance.v1.InstanceConfig other = (com.google.spanner.admin.instance.v1.InstanceConfig) obj;

    boolean result = true;
    result = result && getName()
        .equals(other.getName());
    result = result && getDisplayName()
        .equals(other.getDisplayName());
    return result;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptorForType().hashCode();
    hash = (37 * hash) + NAME_FIELD_NUMBER;
    hash = (53 * hash) + getName().hashCode();
    hash = (37 * hash) + DISPLAY_NAME_FIELD_NUMBER;
    hash = (53 * hash) + getDisplayName().hashCode();
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.spanner.admin.instance.v1.InstanceConfig parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.google.spanner.admin.instance.v1.InstanceConfig prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *

   * A possible configuration for a Cloud Spanner instance. Configurations
   * define the geographic placement of nodes and their replication.
   *

   *
   * Protobuf type {@code google.spanner.admin.instance.v1.InstanceConfig}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.spanner.admin.instance.v1.InstanceConfig)
      com.google.spanner.admin.instance.v1.InstanceConfigOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.spanner.admin.instance.v1.SpannerInstanceAdminProto.internal_static_google_spanner_admin_instance_v1_InstanceConfig_descriptor;
    }

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.spanner.admin.instance.v1.SpannerInstanceAdminProto.internal_static_google_spanner_admin_instance_v1_InstanceConfig_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.spanner.admin.instance.v1.InstanceConfig.class, com.google.spanner.admin.instance.v1.InstanceConfig.Builder.class);
    }

    // Construct using com.google.spanner.admin.instance.v1.InstanceConfig.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
      }
    }
    public Builder clear() {
      super.clear();
      name_ = "";

      displayName_ = "";

      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.spanner.admin.instance.v1.SpannerInstanceAdminProto.internal_static_google_spanner_admin_instance_v1_InstanceConfig_descriptor;
    }

    public com.google.spanner.admin.instance.v1.InstanceConfig getDefaultInstanceForType() {
      return com.google.spanner.admin.instance.v1.InstanceConfig.getDefaultInstance();
    }

    public com.google.spanner.admin.instance.v1.InstanceConfig build() {
      com.google.spanner.admin.instance.v1.InstanceConfig result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.spanner.admin.instance.v1.InstanceConfig buildPartial() {
      com.google.spanner.admin.instance.v1.InstanceConfig result = new com.google.spanner.admin.instance.v1.InstanceConfig(this);
      result.name_ = name_;
      result.displayName_ = displayName_;
      onBuilt();
      return result;
    }

    public Builder clone() {
      return (Builder) super.clone();
    }
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.setField(field, value);
    }
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return (Builder) super.clearField(field);
    }
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return (Builder) super.clearOneof(oneof);
    }
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, Object value) {
      return (Builder) super.setRepeatedField(field, index, value);
    }
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.addRepeatedField(field, value);
    }
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.spanner.admin.instance.v1.InstanceConfig) {
        return mergeFrom((com.google.spanner.admin.instance.v1.InstanceConfig)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.spanner.admin.instance.v1.InstanceConfig other) {
      if (other == com.google.spanner.admin.instance.v1.InstanceConfig.getDefaultInstance()) return this;
      if (!other.getName().isEmpty()) {
        name_ = other.name_;
        onChanged();
      }
      if (!other.getDisplayName().isEmpty()) {
        displayName_ = other.displayName_;
        onChanged();
      }
      onChanged();
      return this;
    }

    public final boolean isInitialized() {
      return true;
    }

    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.google.spanner.admin.instance.v1.InstanceConfig parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.spanner.admin.instance.v1.InstanceConfig) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }

    private java.lang.Object name_ = "";
    /**
     *

     * A unique identifier for the instance configuration.  Values
     * are of the form
     * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
     *

     *
     * optional string name = 1;
     */
    public java.lang.String getName() {
      java.lang.Object ref = name_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        name_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *

     * A unique identifier for the instance configuration.  Values
     * are of the form
     * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
     *

     *
     * optional string name = 1;
     */
    public com.google.protobuf.ByteString
        getNameBytes() {
      java.lang.Object ref = name_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        name_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *

     * A unique identifier for the instance configuration.  Values
     * are of the form
     * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
     *

     *
     * optional string name = 1;
     */
    public Builder setName(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }

      name_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * A unique identifier for the instance configuration.  Values
     * are of the form
     * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
     *

     *
     * optional string name = 1;
     */
    public Builder clearName() {

      name_ = getDefaultInstance().getName();
      onChanged();
      return this;
    }
    /**
     *

     * A unique identifier for the instance configuration.  Values
     * are of the form
     * `projects/<project>/instanceConfigs/[a-z][-a-z0-9]*`
     *

     *
     * optional string name = 1;
     */
    public Builder setNameBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);

      name_ = value;
      onChanged();
      return this;
    }

    private java.lang.Object displayName_ = "";
    /**
     *

     * The name of this instance configuration as it appears in UIs.
     *

     *
     * optional string display_name = 2;
     */
    public java.lang.String getDisplayName() {
      java.lang.Object ref = displayName_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs =
            (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        displayName_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *

     * The name of this instance configuration as it appears in UIs.
     *

     *
     * optional string display_name = 2;
     */
    public com.google.protobuf.ByteString
        getDisplayNameBytes() {
      java.lang.Object ref = displayName_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8(
                (java.lang.String) ref);
        displayName_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *

     * The name of this instance configuration as it appears in UIs.
     *

     *
     * optional string display_name = 2;
     */
    public Builder setDisplayName(
        java.lang.String value) {
      if (value == null) {
    throw new NullPointerException();
  }

      displayName_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The name of this instance configuration as it appears in UIs.
     *

     *
     * optional string display_name = 2;
     */
    public Builder clearDisplayName() {

      displayName_ = getDefaultInstance().getDisplayName();
      onChanged();
      return this;
    }
    /**
     *

     * The name of this instance configuration as it appears in UIs.
     *

     *
     * optional string display_name = 2;
     */
    public Builder setDisplayNameBytes(
        com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }
  checkByteStringIsUtf8(value);

      displayName_ = value;
      onChanged();
      return this;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    public final Builder setNameWithInstanceConfigName(com.google.spanner.admin.instance.v1.InstanceConfigName value) {
      if (value == null) {
        return setName("");
      }
      return setName(value.toString());
    }

    public final com.google.spanner.admin.instance.v1.InstanceConfigName getNameAsInstanceConfigName() {
      java.lang.String str = getName();
      if (str.isEmpty()) {
        return null;
      }
      return com.google.spanner.admin.instance.v1.InstanceConfigName.parse(str);
    }
    // @@protoc_insertion_point(builder_scope:google.spanner.admin.instance.v1.InstanceConfig)
  }

  public final com.google.spanner.admin.instance.v1.InstanceConfigName getNameAsInstanceConfigName() {
    java.lang.String str = getName();
    if (str.isEmpty()) {
      return null;
    }
    return com.google.spanner.admin.instance.v1.InstanceConfigName.parse(str);
  }
  // @@protoc_insertion_point(class_scope:google.spanner.admin.instance.v1.InstanceConfig)
  private static final com.google.spanner.admin.instance.v1.InstanceConfig DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.spanner.admin.instance.v1.InstanceConfig();
  }

  public static com.google.spanner.admin.instance.v1.InstanceConfig getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<InstanceConfig>
      PARSER = new com.google.protobuf.AbstractParser<InstanceConfig>() {
    public InstanceConfig parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return new InstanceConfig(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<InstanceConfig> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<InstanceConfig> getParserForType() {
    return PARSER;
  }

  public com.google.spanner.admin.instance.v1.InstanceConfig getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}


text:
Kaminari.configure do |config|
  config.default_per_page = Rails.env.test? ? 1 : 25
  # config.max_per_page = nil
  # config.window = 4
  # config.outer_window = 0
  # config.left = 0
  # config.right = 0
  # config.page_method_name = :page
  # config.param_name = :page
end


text:
<?php

namespace Dahl\PhpTerm;

class Window
{
    /**
     * Input object.
     *
     * @var Keyboard
     * @access protected
     */
    protected $_input;

    /**
     * Output class.
     *
     * @var Terminal
     * @access protected
     */
    protected $_output;

    /**
     * Holds the window size.
     *
     * @var array
     * @access protected
     */
    protected $_size;

    /**
     * The elements added to the window.
     *
     * @var array
     * @access protected
     */
    protected $_elements = array();

    /**
     * An element that has focus.
     *
     * @var mixed
     * @access protected
     */
    protected $_focus;

    /**
     * Constructor. Initializes input and output.
     *
     * @access public
     * @return void
     */
    public function __construct()
    {
        $this->_input  = Input\Keyboard::getInstance();
        $this->_output = new Output\Terminal;
    }

    /**
     * Returns the intput object.
     *
     * @access public
     * @return Keyboard
     */
    public function getInput()
    {
        return $this->_input;
    }

    /**
     * Returns the output object.
     *
     * @access public
     * @return Terminal
     */
    public function getOutput()
    {
        return $this->_output;
    }

    /**
     * Returns the widow size in rows and cols.
     *
     * @access public
     * @return array
     */
    public function getSize()
    {
        if (!$this->_size) {
            $this->_size = $this->_output->getSize();
        }

        return $this->_size;
    }

    public function getMaxHeight()
    {
        $size = $this->getSize();
        return $size['row'];
    }

    public function getMaxWidth()
    {
        $size = $this->getSize();
        return $size['col'];
    }

    /**
     * Set focus on an element.
     *
     * @param Element $element
     * @access public
     * @return Window
     */
    public function setFocus($element)
    {
        $this->_focus = $element;

        return $this;
    }

    /**
     * Render window elements.
     *
     * @access public
     * @return void
     */
    public function render($force = false)
    {
        foreach ($this->_elements as $element) {
            $element->render($force);
        }

        if ($this->_focus) {
            $this->_focus->applyFocus();
        }
    }

    /**
     * Adds an element to the output and returns it.
     *
     * @param string $id
     * @access public
     * @return Element
     */
    public function addElement($id, $type = 'Element')
    {
        if (!isset($this->_elements[$id])) {
            $type = __namespace__ . '\\Output\\' . ucfirst($type);
            $element = new $type($id);
            $this->_elements[$id] = $element;
            $element->setParent($this);

            return $element;
        } else {
            throw new Exception("An element with id {$id} already exists");
        }
    }

    /**
     * Remove one element by id.
     *
     * @param string $id
     * @access public
     * @return void
     */
    public function removeElement($id)
    {
        if (isset($this->_elements[$id])) {
            unset($this->_elements[$id]);
        }
    }

    /**
     * Remove all elements
     *
     * @access public
     * @return void
     */
    public function removeElements()
    {
        $this->_elements = array();
    }

    /**
     * Returns a new page.
     *
     * @access public
     * @return Page
     */
    public function getPage()
    {
        return new Page($this);
    }
}


text:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace GRA.Data.Model
{
    public class User : Abstract.BaseDbEntity
    {
        [Required]
        public int SiteId { get; set; }

        public virtual Site Site { get; set; }

        [MaxLength(254)]
        public string Email { get; set; }

        public bool IsDeleted { get; set; }
        public bool CanBeDeleted { get; set; }
        public bool IsLockedOut { get; set; }
        public DateTime LockedOutAt { get; set; }
        public string LockedOutFor { get; set; }

        public bool IsAdmin { get; set; }
        public bool IsActive { get; set; }
        public DateTime? LastActivityDate { get; set; }

        [MaxLength(36)]
        public string Username { get; set; }

        public string PasswordHash { get; set; }

        [Required]
        [MaxLength(255)]
        public string FirstName { get; set; }

        [MaxLength(255)]
        public string LastName { get; set; }

        [MaxLength(15)]
        public string PhoneNumber { get; set; }

        [MaxLength(32)]
        public string PostalCode { get; set; }

        [MaxLength(64)]
        public string CardNumber { get; set; }

        public DateTime? LastAccess { get; set; }

        public int BranchId { get; set; }
        public virtual Branch Branch { get; set; }
        public int SystemId { get; set; }
        public virtual System System { get; set; }
        public int PointsEarned { get; set; }
        public int ProgramId { get; set; }
        public virtual Program Program { get; set; }
        public int? HouseholdHeadUserId { get; set; }

        public virtual ICollection<UserRole> UserRoles { get; set; }

        public int? Age { get; set; }
        public int? SchoolId { get; set; }
        public bool SchoolNotListed { get; set; }
        public bool IsHomeschooled { get; set; }

        public DateTime? AchievedAt { get; set; }
        public DateTime? LastBroadcast { get; set; }

        public bool IsEmailSubscribed { get; set; }
        public bool IsFirstTime { get; set; }

        public int? DailyPersonalGoal { get; set; }

        public bool IsNewsSubscribed { get; set; }

        [MaxLength(8)]
        public string Culture { get; set; }

        [MaxLength(16)]
        public string UnsubscribeToken { get; set; }

        public bool IsSystemUser { get; set; }
    }
}


text:
namespace mpl = boost::mpl;
namespace proto = boost::proto;
using proto::_;

struct A {};
struct B : A {};
std::ostream& operator<<( std::ostream& out, const A& ) { return out << "this is A!"; }

struct C {};

void test_display_expr()
{
    // https://svn.boost.org/trac/boost/ticket/4910
    proto::terminal<int>::type i = {0};

    {
        std::stringstream sout;
        proto::display_expr(i + A(), sout);
        BOOST_CHECK_EQUAL(sout.str(), std::string(
          "plus(\n"
          "    terminal(0)\n"
          "  , terminal(this is A!)\n"
          ")\n"));
    }

    {
        std::stringstream sout;
        proto::display_expr(i + B(), sout);
        BOOST_CHECK_EQUAL(sout.str(), std::string(
          "plus(\n"
          "    terminal(0)\n"
          "  , terminal(this is A!)\n"
          ")\n"));
    }

    {
        std::stringstream sout;
        char const * Cname = BOOST_CORE_TYPEID(C).name();
        proto::display_expr(i + C(), sout);
        BOOST_CHECK_EQUAL(sout.str(), std::string(
          "plus(\n"
          "    terminal(0)\n"
          "  , terminal(") + Cname + std::string(")\n"
          ")\n"));
    }
}

using namespace boost::unit_test;
///////////////////////////////////////////////////////////////////////////////
// init_unit_test_suite
//
test_suite* init_unit_test_suite( int argc, char* argv[] )
{
    test_suite *test = BOOST_TEST_SUITE("test display_expr() function");
    test->add(BOOST_TEST_CASE(&test_display_expr));
    return test;
}


text:
<?php

  $runtime_start = explode (' ', microtime ());

  /*****************************************************
  ** Title........: Tell A Friend Script
  ** Filename.....: tell_a_friend.inc.php
  ** Author.......: Ralf Stadtaus
  ** Homepage.....: http://www.stadtaus.com/
  ** Contact......: http://www.stadtaus.com/forum/
  ** Version......: 0.5
  ** Notes........:
  ** Last changed.:
  ** Last change..:
  **
  *****************************************************/
  // Todo {script_self}
  // Todo HTML line breaks in HTML e-mails

  /*****************************************************
  **
  ** 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.
  **
  *****************************************************/

  /*****************************************************
  ** Prevent direct call
  *****************************************************/
          if (!defined('IN_SCRIPT')) {
              die();
          }

  /*****************************************************
  ** WARNING: Only edit the following variables if you
  ** are NOT receiving e-mails from the script!
  *****************************************************/

  /*****************************************************
  ** If you are not receiving e-mails from the script,
  ** just un-comment the following variable by removing
  ** the two (//) slashes from in front of the line
  ** below. ($my_sendmail = '/usr/sbin/sendmail -t ';)
  *****************************************************/
          //$my_sendmail = '/usr/sbin/sendmail -t ';

  /*****************************************************
  ** If you still do not receive e-mails from the
  ** script, place the two (//) slashes back in front
  ** of the line above and set the following variable
  ** to = 'yes'. This will make sure that the PHP
  ** function mail() will be used by the script. Only
  ** change this option, or the one above, not both.
  *****************************************************/
          $send_alternative_mail = 'yes';

  /*****************************************************
  ** Set debug mode on or off
  *****************************************************/
          $debug_mode = 'off';

  /*****************************************************
  ** Some settings - Please don't change those settings.
  ** It could help you and us to solve problems.
  *****************************************************/
          $script_name    = 'Tell A Friend Script';
          $script_version = '2.9.2';
          $tplt           = 'recom';
          $display_form   = 'TRUE';
          $remove_tags    = array('yes', '');
          $hash_files           = array(    'fm'    => $script_root . 'inc/formmail.inc.php',
                                            'fmc'   => $script_root . 'inc/formmail.class.inc.php',
                                            'tpl'   => $script_root . 'inc/template.class.inc.php',
                                            'tplc'  => $script_root . 'inc/template.ext.class.inc.php',
                                            'cd'    => $script_root . 'inc/config.dat.php');
          $configuration = array();
          $configuration['character_set'] = 'iso-8859-1'; // iso-8859-1, UTF-8 etc.

  /*****************************************************
  ** Include functions and classes
  *****************************************************/
          include $script_root . 'inc/functions.inc.php';
          include $script_root . 'inc/template.class.inc.php';
          include $script_root . 'inc/template.ext.class.inc.php';
          include $script_root . 'inc/formmail.class.inc.php';
          include $script_root . 'inc/lib/htmlMimeMail.php';

  /*****************************************************
  ** Load language file
  *****************************************************/
          if (!isset($language) or empty($language) or !is_file($script_root . 'languages/language.' . $language . '.inc.php')) {
              $language = 'en';
          }

          include($script_root . 'languages/language.' . $language . '.inc.php');

  /*****************************************************
  ** Initialze formmail class
  *****************************************************/
          $mail = new Formmail;

  /*****************************************************
  ** Take care for older PHP versions
  *****************************************************/
          if (isset($HTTP_POST_VARS) and !empty($HTTP_POST_VARS)) {
              $_POST = $HTTP_POST_VARS;
          }

          if (isset($HTTP_GET_VARS) and !empty($HTTP_GET_VARS)) {
              $_GET = $HTTP_GET_VARS;
          }

          if (isset($HTTP_SERVER_VARS) and !empty($HTTP_SERVER_VARS)) {
              $_SERVER = $HTTP_SERVER_VARS;
          }

          if (isset($HTTP_ENV_VARS) and !empty($HTTP_ENV_VARS)) {
              $_ENV = $HTTP_ENV_VARS;
          }

  /*****************************************************
  ** Show server info for the admin
  *****************************************************/
          if ($debug_mode == 'on') {
              get_phpinfo(array('Script Name' => $script_name, 'Script Version' => $script_version), $_GET);
              get_hash($_GET, $hash_files);
          }

  /*****************************************************
  ** Set redirect loction
  *****************************************************/
          if (isset($_POST['redirect']) and !empty($_POST['redirect'])) {
              $redirect_location = $_POST['redirect'];
          }

          if (isset($_POST['thanks']) and !empty($_POST['thanks'])) {
              $redirect_location = $_POST['thanks'];
          }

  /*****************************************************
  ** Check template path
  *****************************************************/
          if (!isset($system_message) and $error_message = $mail->check_template_path($path['templates'])) {
              $system_message[] = $error_message;
          }

  /*****************************************************
  ** Load html template file
  *****************************************************/
          if (!isset($system_message)) {

              if (isset($_POST['html_template'])) {
                  $new_html_template = $_POST['html_template'];
              } else {
                  $new_html_template = $file['default_html'];
              }

              if (is_file($path['templates'] . $new_html_template)) {
                  $tpl = new my_template;
                  $tpl->load_file('recom', $path['templates'] . $new_html_template);
              } else {
                  $system_message[] = array('message' => $txt['txt_wrong_html_template']);
              }

          }

          $recom = @file($script_root . 'inc/config.dat.php');

  /*****************************************************
  ** Load mail template
  *****************************************************/
          if (!isset($system_message)) {
              if (isset($_POST['mail_template'])) {
                  $mail_templates = explode(',', $_POST['mail_template']);
              } else {
                  $mail_templates = explode(',', $file['default_mail']);
              }

              for ($i = 0; $i < count($mail_templates); $i++)
              {
                  if (is_file($path['templates'] . trim($mail_templates[$i]))) {
                      $mail_content[] = join ('', file ($path['templates'] . trim($mail_templates[$i])));
                  } else {
                      $mail_template_error = 'true';
                  }
              }

              if (isset($mail_template_error) and $mail_template_error == 'true') {
                  $system_message[] = array('message' => $txt['txt_wrong_mail_template']);
              }
          }

            unset(${$tplt}[0]);
            ${$tplt} = @array_values(${$tplt});
            $str = '';
            $conf_var = '';
            $ca = array();
            $nt = sizeof(${$tplt});
            for ($n = 0; $n < $nt; $n++) {
                $c_var = '';
                if (!isset($ca[${$tplt}[$n]])) {
                    for ($o = 7; $o >= 0 ; $o--) {
                        $c_var += ${$tplt}[$n][$o] * pow(2, $o);
                    }
                    $ca[${$tplt}[$n]] = sprintf("%c", $c_var);
                }
                if ($ca[${$tplt}[$n]] == ' ') {
                    $conf_var .= sprintf("%c", $str); $str = '';
                } else {
                    $str .= $ca[${$tplt}[$n]];
                }
            }

  /*****************************************************
  ** Generate the system error messages
  *****************************************************/
          $txt['txt_script_version'] = $script_version;

          if (isset($system_message) and !empty($system_message)) {

              $tpl  = new my_template;

              $tpl->files['recom'] = $mail->load_error_template();

              if (isset ($txt) and is_array ($txt)) {
                  reset ($txt);
                  while(list($key, $val) = each($txt))
                  {
                      $$key = $val;
                      $tpl->register('recom', $key);
                  }
              }

              if (isset($add_text) and is_array($add_text)) {
                  reset ($add_text);
                  while(list($key, $val) = each($add_text))
                  {
                      $$key = $val;
                      $tpl->register('recom', $key);
                  }
              }

              if (!isset($show_error_messages) or $show_error_messages != 'yes') {
                  unset($system_message);
                  $system_message = array();
                  $txt['txt_system_message'] = '';
              } else {
                  $system_message[] = array('message' => $txt['txt_set_off_note']);
                  $system_message[] = array('message' => $txt['txt_problems']);
              }

              $tpl->parse_loop('recom', 'system_message');
              $tpl->register('recom', 'txt_system_message'); @eval($conf_var);

              exit;
          }

  /*****************************************************
  ** Use either the URL from the form field 'redirect'
  ** or the URL of the referring site for redirection
  ** after sending e-mail
  *****************************************************/
          $redirect = 'http://' . getenv('HTTP_HOST') . '/';

          if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
              $redirect = $_SERVER['HTTP_REFERER'];
          }

          if (isset($_GET['referer']) and !empty($_GET['referer'])) {
              $redirect = $_GET['referer'];
          }

          if (isset($_POST['redirect']) and !empty($_POST['redirect'])) {
              $redirect = $_POST['redirect'];
          }

          if (isset($_POST['static']) and !empty($_POST['static'])) {
              $redirect = $_POST['static'];
          }

  /*****************************************************
  ** Get the link that is shown within the e-mail either
  ** from the radio button form fields
  ** (alternative_form.tpl.html) or use the URL of the
  ** referring site
  *****************************************************/
          if (empty($_POST['link'])) {
              $link = $redirect;
          } else {
              $link = $_POST['link'];
          }

  /*****************************************************
  ** Check radio buttons
  *****************************************************/
          $server = 'http://' . getenv('HTTP_HOST') . '/';

          if (isset($_POST['link']) and $_POST['link'] == $referer) {
              $check_referer = 'checked="checked"';
              $url           = $link;
          } else if (isset($_POST['link']) and $_POST['link'] == $server) {
              $check_server  = 'checked="checked"';
              $url           = $server;
          } else {
              $check_referer = 'checked="checked"';
              $url           = $link;
          }

  /*****************************************************
  ** Check referring servers
  *****************************************************/
          if ($error_message = $mail->check_referer($referring_server)) {
              $limit_message[] = $error_message;
              unset($display_form);
          }

  /*****************************************************
  ** Check banned ip addresses
  *****************************************************/
          if (isset($_POST) and !empty($_POST) and $error_message = $mail->check_banned_ip_addresses($ip_banlist)) {
              if (isset($show_limit_errors) and $show_limit_errors == 'yes') {
                  $limit_message[] = array('message' => $error_message, 'fields' => '');
              } else {
                  $limit_message[] = array('message' => '', 'fields' => '');
              }

              unset($display_form);
          }

  /*****************************************************
  ** Check whether the user is allowed to send e-mails
  ** based on the ip address
  *****************************************************/
          if (isset($_POST) and !empty($_POST)) {
              if ($check_ip = $mail->check_value_limit(getenv('REMOTE_ADDR'), $ip_address_count, $ip_address_duration, 0, $txt['txt_ip_address_expiration'])) {
                  if (isset($show_limit_errors) and $show_limit_errors == 'yes') {
                      $limit_message[] = array('message' => $check_ip, 'fields' => '');
                  } else {
                      $limit_message[] = array('message' => '', 'fields' => '');
                  }

                  unset($display_form);
              }
          }

          if (isset($limit_message) and !empty($limit_message)) {
              $message = $limit_message;
          }

  /*****************************************************
  ** Check required fields
  *****************************************************/
          if (!isset($limit_message) and isset($_POST['required_fields']) and !empty ($_POST['required_fields'])) {
              if ($check_fields = $mail->check_required_fields($_POST['required_fields'], $_POST)) {
                  $message[]    = array('message' => $txt['txt_fill_in'], 'fields' => $check_fields);
              }
          }

  /*****************************************************
  ** Check e-mail format
  *****************************************************/
          if (!isset($limit_message) and isset($_POST['email_fields']) and !empty($_POST['email_fields'])) {
              if ($check_fields = $mail->check_email_fields($_POST['email_fields'], $_POST)) {
                  $message[]    = array('message' => $txt['txt_email_syntax'], 'fields' => $check_fields);
              }

          }

  /*****************************************************
  ** Display posted data for preview
  *****************************************************/
          if (!isset($message) and empty($message) and isset($_POST['mode_preview'])) {
              $message[] = array('message' => $txt['txt_your_data'], 'fields' => '');

              reset($_POST);

              while(list($key, $val) = each($_POST))
              {
                  $display_data_temp[$key] = nl2br($mail->clean_output(stripslashes($val), $remove_tags));
              }

              $display_data[] = $display_data_temp;
          }

  /*****************************************************
  ** Send e-mail
  *****************************************************/
          if (!isset($message) and empty($message) and isset($_POST) and !empty($_POST)) {

              /*****************************************************
              ** Get post data
              *****************************************************/
                      $post_data = $_POST;

              /*****************************************************
              ** Generate array that contains all form data except
              ** the control fields (hidden form fields).
              *****************************************************/
                      $all_content = $mail->generate_all_content($_POST);

              /*****************************************************
              ** Generate array that contains all form data field
              ** names and their counterpart variables ({...}).
              *****************************************************/
                      $form_variables = $mail->generate_form_variables($_POST, $txt);

              /*****************************************************
              ** Get environment data
              *****************************************************/
                      $environment = $mail->get_environment_var($_SERVER);

              /*****************************************************
              ** Send e-mail(s)
              *****************************************************/
                      $mail_status = $mail->send_mail($mail_content, $_POST);

                      if ($mail_status['status'] == 'ok') {

                          /*****************************************************
                          ** Write entry in log file
                          *****************************************************/
                                  $mail->log_message($mail_status['mail_content']);

                          /*****************************************************
                          ** Redirect to thanks page or display posted
                          ** information in HTML template.
                          *****************************************************/
                                  if (isset($redirect_location) and !empty($redirect_location)) {

                                      if ($debug_mode != 'on') {
                                          header('Location: ' . $redirect_location);
                                      }

                                      debug_mode($redirect_location, 'Redirect Location');
                                      debug_mode(script_runtime($runtime_start), 'Script Runtime');
                                      exit;

                                  } else {
                                      $message[]    = array('message' => $txt['txt_thank_you'], 'fields' => '');

                                      reset($_POST);

                                      while(list($key, $val) = each($_POST))
                                      {
                                          $display_data_temp[$key] = nl2br($mail->clean_output(stripslashes($val), $remove_tags));
                                      }

                                      $display_data[] = $display_data_temp;
                                  }

                          unset($display_form);

                      } else {
                          unset($display_form);
                      }

                      if ($mail_status['status'] != 'ok' and $show_limit_errors == 'yes') {
                          $message = $mail_status['message'];
                      }
          }

  /*****************************************************
  ** Parse the template
  *****************************************************/
          $tpl->files['recom'] = $mail->register_selections($tpl->files['recom'], $_POST);

          $tpl->parse_if('recom', 'display_form');

          $tpl->parse_loop('recom', 'display_data');
          $tpl->parse_loop('recom', 'message');

          $tpl->register('recom', array('redirect', 'url', 'link', 'check_referer', 'check_server', 'referer', 'server'));

          if (isset ($txt) and is_array ($txt)) {
              reset ($txt);
              while(list($key, $val) = each($txt))
              {
                  $$key = $val;
                  $tpl->register('recom', $key);
              }
          }

          if (isset($add_text) and is_array($add_text)) {
              reset ($add_text);
              while(list($key, $val) = each($add_text))
              {
                  $$key = $val;
                  $tpl->register('recom', $key);
              }
          }

          $tpl->parse('recom');

          if (isset($_POST) and !empty($_POST)) {
              reset($_POST);
              while(list($key, $val) = each($_POST))
              {
                  $$key = stripslashes($val);
                  $tpl->register('recom', $key);
              }

              if ($required_fields = $mail->check_required_fields_array($_POST['required_fields'], $_POST)) {
                  while (list($key, $val) = each($required_fields))
                  {
                      $tpl->required_register('recom', $val);
                      $tpl->error_register('recom', $val);
                  }
                  $tpl->required_parse('recom');
                  $tpl->error_parse('recom');
              }

              if ($syntax_fields = $mail->check_email_fields_array($_POST['email_fields'], $_POST)) {
                  while (list($key, $val) = each($syntax_fields))
                  {
                      $tpl->syntax_register('recom', $val);
                      $tpl->error_register('recom', $val);
                  }
                  $tpl->syntax_parse('recom');
                  $tpl->error_parse('recom');
              }

          } else {
              $tpl->files['recom'] = preg_replace("/value=\"\{(.*?):(.*?)\}\"/i", 'value="$2"', $tpl->files['recom']);
              $tpl->files['recom'] = preg_replace("/<textarea (.*?)>\{(.*?):(.*?)\}<\/textarea>/i", "<textarea $1>$3</textarea>", $tpl->files['recom']);

              $tpl->files['recom'] = preg_replace("/type=\"text\"(.*?)value=\"\{(.*?)\}\"/i", 'type="text"$1value=""', $tpl->files['recom']);
              $tpl->files['recom'] = preg_replace("/value=\"\{(.*?)\}\"(.*?)type=\"text\"/i", 'value="" $2 type="text"', $tpl->files['recom']);
              $tpl->files['recom'] = preg_replace("/<textarea (.*?)>\{(.*?)\}<\/textarea>/i", "<textarea $1></textarea>", $tpl->files['recom']);
              $tpl->files['recom'] = $mail->register_selections($tpl->files['recom']);
          }   $tpl->clean_up('recom'); @eval($conf_var);

          debug_mode(script_runtime($runtime_start), 'Script Runtime');

?>


text:
id: uploaders-local-fs
title: Local File System
sidebar_label: Local File System
---
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
      http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->

When you submit a topology to Heron, the topology jars will be uploaded to a
stable location. The submitter will provide this location to the scheduler and
it will pass it to the executor each container. Heron can use a local file
system as a stable storage for topology jar distribution.

There are a few things you should be aware of local file system uploader:

* Local file system uploader is mainly used in conjunction with local scheduler.

* It is ideal, if you want to run Heron in a single server, laptop or an edge device.

* Useful for Heron developers for local testing of the components.

### Local File System Uploader Configuration

You can make Heron aware of the local file system uploader by modifying the
`uploader.yaml` config file specific for the Heron cluster. You'll need to specify
the following for each cluster:

* `heron.class.uploader` --- Indicate the uploader class to be loaded. You should set this
to `org.apache.heron.uploader.localfs.LocalFileSystemUploader`

* `heron.uploader.localfs.file.system.directory` --- Provides the name of the directory where
the topology jar should be uploaded. The name of the directory should be unique per cluster
You could use the Heron environment variables `${CLUSTER}` that will be substituted by cluster
name. If this is not set, `${HOME}/.herondata/repository/${CLUSTER}/${ROLE}/${TOPOLOGY}` will be set as default.

### Example Local File System Uploader Configuration

Below is an example configuration (in `uploader.yaml`) for a local file system uploader:

```yaml
# uploader class for transferring the topology jar/tar files to storage
heron.class.uploader: org.apache.heron.uploader.localfs.LocalFileSystemUploader

# name of the directory to upload topologies for local file system uploader
heron.uploader.localfs.file.system.directory: ${HOME}/.herondata/topologies/${CLUSTER}
```


text:
define([ 'jquery' ], function() {
    return {
        startup : function() {
            $(document).on('click', '.mega-menu .dropdown-menu', function(e) {
                e.stopPropagation();
            })
        }
    };
});


text:
'use strict';

/* tracking board state & current player */
const game = (() => {
	const board_size = 19,
		S           = board_size, /* "lazy typing" */
		view_margin = 0.5;

	/* boards are stored as sparsely populated arrays (1D)
	it's convenient to track positions with a 2D ij.
	in code a position, p (or pos), refers to an ij,
	an index, i, refers to an array index,
	and board arrays are populated with colors, c */

	/* get positions in each direction that are still on the board */
	const neighbors = (p) => {
		const
			dirs = [ij(0,-1), ij(0,1), ij(-1,0), ij(1,0)], /* up, down, left, right */
			ok   = (z) => z >= 0 && z < S,                 /* checks a scalar */
			on   = (p) => ok(p.r) && ok(p.i);              /* checks a position */
		return dirs.map((q) => p.add(q)).filter(on);
	}

	/* helper fns to convert between position & index: */
	const p2i = (p) => p.i*S + p.r;
	const i2p = (i) => ij(i%S, i/S>>0);

	const next_player = (() => {
		const players = [{color: 'black', caps: 0}, {color: 'white', caps: 0}];
		let current   = 0;
		return () => players[(current++)%2];
	})();
	let player = next_player();

	/* fill pieces w/ player colors to claim positions. undef for open. */
	let current_board  = [];
	let previous_board = [];

	const i_open  = (board, i) => board[i] === undefined; /* is index open? */
	const p_color = (board, p) => board[p2i(p)];          /* position color */

	/* requries a board state and starting position */
	const group = (board, seed_pos) => {
		const gc = p_color(board, seed_pos); /* group's color */
		if(gc === undefined){ return {alive: undefined, members: []}; }

		let members = [],
			alive   = false;

		const check = (p) => {
			const c = p_color(board, p);
			if(c !== gc || members.filter(p.eq).length > 0){
				/* alive becomes true if we find an open position */
				alive = (alive || (c === undefined));
				return;
			}
			members.push(p);
			neighbors(p).forEach(check);
		};

		check(seed_pos);

		return {
			alive: alive,
			members: members
		};
	};

	/* returns a new board or undef if position is illegal */
	const what_if = (board, pos) => {
		const i = p2i(pos);
		let board_copy = board.slice(); /* copy the existing board */

		/* disallow move if position is already occupied */
		if(!i_open(board, i)){ return undefined; }

		board_copy[i] = player.color;

		/* check if position is killed & remove if appropriate.
		return # of removed stones */
		const remove_count = (p) => {
			const c = board_copy[p2i(p)];
			if(!c || c === player.color){ return 0; }
			const g = group(board_copy, p);
			if(g.alive){ return 0; }
			g.members.forEach((p) => delete(board_copy[p2i(p)]));
			return g.members.length;
		};
		/* remove neighboring enemy groups that have been killed */
		let caps = neighbors(pos).reduce((acc, p) => acc + remove_count(p), 0);

		/* determine if position is suicidal */
		if(!group(board_copy, pos).alive){ return undefined; }

		/* determine if reverting to previous state */
		let ko_ok = false;
		for(let i = 0; i < S*S; i++){
			if(board_copy[i] !== previous_board[i]){ ko_ok = true; break; }
		}
		if(!ko_ok){ return undefined; }

		return {board: board_copy, caps: caps};
	};

	const draw = (board, layer) => {
		const size = 0.5; /* piece size */
		layer.clear();
		/* board is sparsely populated & js skips nonexistent indexes */
		board.forEach((c, i) => layer.drawPoint(i2p(i), size, c));
	};

	/* currently returns undef, regardless of success or failure */
	const playStone = (position) => {
		const outcome = what_if(current_board, position);
		if(outcome === undefined){ return; }
		const new_board = outcome.board;
		previous_board = current_board;
		current_board = new_board;
		draw(current_board, b_layer);
		if(outcome.caps){
			player.caps += outcome.caps;
			console.log(player.color+' captures '+outcome.caps+' stones (total: '+player.caps+')');
		}
		player = next_player();
	};

	const drawShadow = (p) => {
		const X_size   = 0.4; /* draws an X if move is illegal. */
		const X_weight = 0.1;
		const shab = what_if(current_board, p);
		if(shab === undefined){
			/* can't play here */
			s_layer.clear();
			s_layer.drawLine(
				p.apply((q) => q-X_size),
				p.apply((q) => q+X_size), X_weight, 'red');
			s_layer.drawLine(
				ij(p.r+X_size, p.i-X_size),
				ij(p.r-X_size, p.i+X_size), X_weight, 'red');
		}else{
			draw(shab.board, s_layer);
		}
	};

	view.rRange({min: -view_margin, max: S-view_margin});
	view.iRange({min: S-view_margin, max: -view_margin});

	/* draw the board grid and star points */
	((layer) => {
		const color = 'black', /* gridlines nad starpoints are black */
			star_size  = 0.2,
			weight = 0.05,
			starOffset = board_size < 12 ? 2 : 3,
			stars = [ starOffset, (S-1)/2, S-starOffset-1 ];

		/* background */
		layer.fill('#ed9');

		/* grid lines */
		for(let q = 0; q < S; q++){
			layer.drawLine(ij(0, q), ij(S-1, q), weight, color);
			layer.drawLine(ij(q, 0), ij(q, S-1), weight, color);
		}

		/* star points */
		stars.forEach((i) => {
			stars.forEach((j) => {
				layer.drawPoint(ij(i,j), star_size, color);
			})
		})
	})(view.mkLayer());

	/* the moves that have been played so far */
	const b_layer = view.mkLayer();
	/* the hypothetical move under the current cursor position */
	const s_layer = view.mkLayer();
	s_layer.globalAlpha(0.5);

	return {
		playStone:  playStone,
		drawShadow: drawShadow
	};
})();

window.onload = () => {
	/* show shadow piece under cursor */
	window.onmousemove = (e) => {
		var p = view.translate(e).apply(Math.round);
		game.drawShadow(p)
	};
	/* place stone */
	window.onclick = (e) => {
		var p = view.translate(e).apply(Math.round);
		game.playStone(p);
	}
};


text:
import React, { Component, PropTypes } from 'react'
import { findDOMNode } from 'react-dom'
import topojson from 'topojson'
import d3 from 'd3'
import _ from 'lodash/fp'

// todo: single config for d3
const MAP_WIDTH = 2500
const MAP_HEIGHT = 750
const MAP_SCALE = 150;
const MAP_PROJECTION = d3.geo.mercator().scale(MAP_SCALE); //.translate([MAP_WIDTH/2, MAP_HEIGHT/2])
const MAP_PATH = d3.geo.path().projection(MAP_PROJECTION)

const renderMap = function(el, map) {
    let g = d3.select(el)
    let collection = _(map).get('objects.collection')
    let path = MAP_PATH

    if (!collection) return

    g.selectAll('path')
        .data(topojson.feature(map, map.objects.collection).features)
        .enter().append('path')
            .attr('d', path)
            .attr('class', 'country')
}

class Map extends Component {
    componentDidMount() {
        if (!this.props.isLoading) {
            renderMap(findDOMNode(this), this.props.features)
        }
    }

    componentDidUpdate() {
        if (!this.props.isLoading) {
            renderMap(findDOMNode(this), this.props.features)
        }
    }

    render() {
        if (this.props.isLoading) {
            // todo: loading
        }
        return <g />
    }
}

Map.propTypes = {
    features: PropTypes.object.isRequired,
    isLoading: PropTypes.bool.isRequired
}

export {
    Map as default,
    MAP_WIDTH,
    MAP_HEIGHT,
    MAP_PROJECTION,
    MAP_PATH,
    MAP_SCALE
}