text: This is a simple libtime library.

redpajama_set_name: RedPajamaGithub


text:
<?php

declare(strict_types = 1);

namespace Rx\Functional\Operator;

use Rx\Functional\FunctionalTestCase;
use Rx\Observable;
use \Exception;

class RepeatWhenTest extends FunctionalTestCase
{
    /**
     * @test
     */
    public function repeatWhen_never()
    {
        $xs = $this->createHotObservable([
            onNext(150, 1),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::empty();
            });
        });

        $this->assertMessages([
            onCompleted(250)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 250)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_never()
    {
        $xs = $this->createHotObservable([
            onNext(150, 1),
            onNext(210, 2),
            onNext(220, 3),
            onNext(230, 4),
            onNext(240, 5),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::never();
            });
        });

        $this->assertMessages([
            onNext(210, 2),
            onNext(220, 3),
            onNext(230, 4),
            onNext(240, 5)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 250)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_empty()
    {
        $xs = $this->createColdObservable([
            onNext(100, 1),
            onNext(150, 2),
            onNext(200, 3),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::empty();
            });
        });

        $this->assertMessages([
            onNext(300, 1),
            onNext(350, 2),
            onNext(400, 3),
            onCompleted(450)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 450)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_next_error()
    {

        $error = new Exception("test");

        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onError(30, $error),
            onCompleted(40)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs, $error) {
            return $xs->repeatWhen(function (Observable $attempts) use ($error) {
                return $attempts->scan(function ($count) use ($error) {
                    if (++$count === 2) {
                        throw $error;
                    }
                    return $count;
                }, 0);
            });
        });

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2),
            onError(230, $error)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 230)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_complete()
    {
        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onCompleted(30)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::empty();
            });
        });

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2),
            onCompleted(230)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 230)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_next_complete()
    {
        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onCompleted(30)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function (Observable $attempts) {
                return $attempts
                    ->scan(function ($count) {
                        return $count + 1;
                    }, 0)
                    ->takeWhile(function ($count) {
                        return $count < 2;
                    });
            });
        });

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2),
            onNext(240, 1),
            onNext(250, 2),
            onCompleted(260)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 230),
            subscribe(230, 260)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_infinite()
    {
        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onCompleted(30)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::never();
            });
        });

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 230)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_dispose()
    {
        $xs = $this->createHotObservable([
            onNext(150, 1),
            onNext(210, 2),
            onNext(220, 3),
            onNext(230, 4),
            onNext(240, 5),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithDispose(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::never();
            });
        }, 225);

        $this->assertMessages([
            onNext(210, 2),
            onNext(220, 3),
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 225)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_dispose_second()
    {
        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onNext(30, 3),
            onNext(40, 4),
            onNext(50, 5),
            onCompleted(60)
        ]);

        $results = $this->scheduler->startWithDispose(function () use ($xs) {
            return $xs->repeatWhen(function ($n) {
                return $n;
            });
        }, 275);

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2),
            onNext(230, 3),
            onNext(240, 4),
            onNext(250, 5),
            onNext(270, 1)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 260),
            subscribe(260, 275)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_Observable_dispose_between()
    {
        $xs = $this->createColdObservable([
            onNext(10, 1),
            onNext(20, 2),
            onNext(30, 3),
            onNext(40, 4),
            onNext(50, 5),
            onCompleted(60)
        ]);

        $results = $this->scheduler->startWithDispose(function () use ($xs) {
            return $xs->repeatWhen(function () {
                return Observable::never();
            });
        }, 275);

        $this->assertMessages([
            onNext(210, 1),
            onNext(220, 2),
            onNext(230, 3),
            onNext(240, 4),
            onNext(250, 5)
        ], $results->getMessages());

        $this->assertSubscriptions([
            subscribe(200, 260)
        ], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_notifier_throws()
    {
        $xs = $this->createColdObservable([
            onNext(150, 1),
            onNext(210, 2),
            onNext(220, 3),
            onNext(230, 4),
            onNext(240, 5),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function (Observable $attempts) {
                throw new Exception('error');
            });
        });

        $this->assertMessages([
            onError(200, new Exception('error'))
        ], $results->getMessages());

        $this->assertSubscriptions([], $xs->getSubscriptions());
    }

    /**
     * @test
     */
    public function repeatWhen_notifier_returns_invalid_string()
    {
        $xs = $this->createColdObservable([
            onNext(150, 1),
            onNext(210, 2),
            onNext(220, 3),
            onNext(230, 4),
            onNext(240, 5),
            onCompleted(250)
        ]);

        $results = $this->scheduler->startWithCreate(function () use ($xs) {
            return $xs->repeatWhen(function (Observable $attempts) {
                return 'unexpected string';
            });
        });

        $this->assertMessages([
            onError(200, new Exception('error'))
        ], $results->getMessages());

        $this->assertSubscriptions([], $xs->getSubscriptions());
    }
}


text:
Extracts the dominant color palettes from a set of images and outputs them as a list of hex colors.

Supports GIF, PNG and JPEG.

Uses [quant](https://github.com/soniakeys/quant) to provide both median and mean quantizers.

Default palette size is 16 and capped at 256 colors.
Default quatization mode is median.

##Usage

```
color-extract --size=16 --mode=median /path/to/file1.png /path/to/file2.png...
```


text:
layout:         dojo
title:          "Challenge #6: Tér lélegezni"
description:    "6th exercise of an interactive iterative coding dojo."
date:           2018-07-06 15:00:00
previous-task:  /dojo/greeting-challenge-5
next-task:      /dojo/greeting-challenge-7
overview:       /greeting-kata
categories:     dojo
---

{{ page.title }}

    Legyen az üdvözlés előtt és után plusz 1-1 csillagokkal keretezett sor. Minden sor változatlanul
    40 karakter széles legyen!


text:
require 'cloudformation_mapper/parameter/string'
require 'cloudformation_mapper/parameter/vpc_id'
require 'cloudformation_mapper/parameter/subnet_id_list'
require 'cloudformation_mapper/parameter/security_group_id'
require 'cloudformation_mapper/parameter/security_group_id_list'
require 'cloudformation_mapper/parameter/db_subnet_group_name'
require 'cloudformation_mapper/parameter/cache_subnet_group_name'
require 'cloudformation_mapper/parameter/comma_delimited_list'


text:
module PostJson
  class ModelSettings < ActiveRecord::Base
    self.table_name = "post_json_model_settings"

    before_validation do |settings|
      settings.collection_name = settings.collection_name.to_s.strip
    end

    scope :by_collection, ->(name) { where("lower(collection_name) = ?", name.to_s.strip.downcase) }

    class << self
      def collection_name_digest(name)
        Digest::MD5.hexdigest(name.to_s.strip.downcase)
      end
    end
  end
end


text:
import { memo } from 'react';
import { withAnimator } from '@arwes/animator';

import { FramePentagon as Component } from './FramePentagon.component';

const FramePentagon = withAnimator()(memo(Component));

export * from './FramePentagon.component';
export { FramePentagon };


text:
_Applies to: Excel 2016, Office 2016_

Represents a collection of worksheet objects that are part of the workbook.

## Properties

| Property	   | Type	|Description
|:---------------|:--------|:----------|
|items|[Worksheet[]](worksheet.md)|A collection of worksheet objects. Read-only.|

_See property access [examples.](#property-access-examples)_

## Relationships
None

## Methods

| Method		   | Return Type	|Description|
|:---------------|:--------|:----------|
|[add(name: string)](#addname-string)|[Worksheet](worksheet.md)|Adds a new worksheet to the workbook. The worksheet will be added at the end of existing worksheets. If you wish to activate the newly added worksheet, call ".activate() on it.|
|[getActiveWorksheet()](#getactiveworksheet)|[Worksheet](worksheet.md)|Gets the currently active worksheet in the workbook.|
|[getItem(key: string)](#getitemkey-string)|[Worksheet](worksheet.md)|Gets a worksheet object using its Name or ID.|
|[load(param: object)](#loadparam-object)|void|Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.|

## Method Details

### add(name: string)
Adds a new worksheet to the workbook. The worksheet will be added at the end of existing worksheets. If you wish to activate the newly added worksheet, call ".activate() on it.

#### Syntax
```js
worksheetCollectionObject.add(name);
```

#### Parameters
| Parameter	   | Type	|Description|
|:---------------|:--------|:----------|
|name|string|Optional. The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet.|

#### Returns
[Worksheet](worksheet.md)

#### Examples

```js
Excel.run(function (ctx) {
	var wSheetName = 'Sample Name';
	var worksheet = ctx.workbook.worksheets.add(wSheetName);
	worksheet.load('name');
	return ctx.sync().then(function() {
		console.log(worksheet.name);
	});
}).catch(function(error) {
		console.log("Error: " + error);
		if (error instanceof OfficeExtension.Error) {
			console.log("Debug info: " + JSON.stringify(error.debugInfo));
		}
});
```

### getActiveWorksheet()
Gets the currently active worksheet in the workbook.

#### Syntax
```js
worksheetCollectionObject.getActiveWorksheet();
```

#### Parameters
None

#### Returns
[Worksheet](worksheet.md)

#### Examples

```js
Excel.run(function (ctx) {
	var activeWorksheet = ctx.workbook.worksheets.getActiveWorksheet();
	activeWorksheet.load('name');
	return ctx.sync().then(function() {
			console.log(activeWorksheet.name);
	});
}).catch(function(error) {
		console.log("Error: " + error);
		if (error instanceof OfficeExtension.Error) {
			console.log("Debug info: " + JSON.stringify(error.debugInfo));
		}
});
```

### getItem(key: string)
Gets a worksheet object using its Name or ID.

#### Syntax
```js
worksheetCollectionObject.getItem(key);
```

#### Parameters
| Parameter	   | Type	|Description|
|:---------------|:--------|:----------|
|key|string|The Name or ID of the worksheet.|

#### Returns
[Worksheet](worksheet.md)

### load(param: object)
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.

#### Syntax
```js
object.load(param);
```

#### Parameters
| Parameter	   | Type	|Description|
|:---------------|:--------|:----------|
|param|object|Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide [loadOption](loadoption.md) object.|

#### Returns
void
### Property access examples
```js
Excel.run(function (ctx) {
	var worksheets = ctx.workbook.worksheets;
	worksheets.load('items');
	return ctx.sync().then(function() {
		for (var i = 0; i < worksheets.items.length; i++)
		{
			console.log(worksheets.items[i].name);
			console.log(worksheets.items[i].index);
		}
	});
}).catch(function(error) {
		console.log("Error: " + error);
		if (error instanceof OfficeExtension.Error) {
			console.log("Debug info: " + JSON.stringify(error.debugInfo));
		}
});
```


text:
from recallprecisionexperiment import RecallPrecisionExperiment
from distanceratioexperiment import DistanceRatioExperiment


text:
package com.google.common.collect;

import static com.google.common.collect.BoundType.OPEN;
import static com.google.common.collect.Range.range;
import static com.google.common.truth.Truth.assertThat;

import com.google.common.annotations.GwtIncompatible;
import com.google.common.testing.SerializableTester;

import java.util.List;
import java.util.NavigableMap;

/**
 * Tests for {@link TreeRangeSet}.
 *
 * @author Louis Wasserman
 * @author Chris Povirk
 */
@GwtIncompatible // TreeRangeSet
public class TreeRangeSetTest extends AbstractRangeSetTest {
  // TODO(cpovirk): test all of these with the ranges added in the reverse order

  private static final ImmutableList<Range<Integer>> QUERY_RANGES;

  private static final int MIN_BOUND = -1;
  private static final int MAX_BOUND = 1;

  static {
    ImmutableList.Builder<Range<Integer>> queryBuilder = ImmutableList.builder();

    queryBuilder.add(Range.<Integer>all());

    for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
      for (BoundType boundType : BoundType.values()) {
        queryBuilder.add(Range.upTo(i, boundType));
        queryBuilder.add(Range.downTo(i, boundType));
      }
      queryBuilder.add(Range.singleton(i));
      queryBuilder.add(Range.openClosed(i, i));
      queryBuilder.add(Range.closedOpen(i, i));

      for (BoundType lowerBoundType : BoundType.values()) {
        for (int j = i + 1; j <= MAX_BOUND; j++) {
          for (BoundType upperBoundType : BoundType.values()) {
            queryBuilder.add(Range.range(i, lowerBoundType, j, upperBoundType));
          }
        }
      }
    }
    QUERY_RANGES = queryBuilder.build();
  }

  void testViewAgainstExpected(RangeSet<Integer> expected, RangeSet<Integer> view) {
    assertEquals(expected, view);
    assertEquals(expected.asRanges(), view.asRanges());
    assertEquals(expected.isEmpty(), view.isEmpty());

    if (!expected.isEmpty()) {
      assertEquals(expected.span(), view.span());
    }

    for (int i = MIN_BOUND - 1; i <= MAX_BOUND + 1; i++) {
      assertEquals(expected.contains(i), view.contains(i));
      assertEquals(expected.rangeContaining(i), view.rangeContaining(i));
    }
    testEnclosing(view);
    if (view instanceof TreeRangeSet) {
      testRangesByLowerBounds((TreeRangeSet<Integer>) view, expected.asRanges());
    }
  }

  private static final ImmutableList<Cut<Integer>> CUTS_TO_TEST;

  static {
    List<Cut<Integer>> cutsToTest = Lists.newArrayList();
    for (int i = MIN_BOUND - 1; i <= MAX_BOUND + 1; i++) {
      cutsToTest.add(Cut.belowValue(i));
      cutsToTest.add(Cut.aboveValue(i));
    }
    cutsToTest.add(Cut.<Integer>aboveAll());
    cutsToTest.add(Cut.<Integer>belowAll());
    CUTS_TO_TEST = ImmutableList.copyOf(cutsToTest);
  }

  private void testRangesByLowerBounds(
      TreeRangeSet<Integer> rangeSet, Iterable<Range<Integer>> expectedRanges) {
    NavigableMap<Cut<Integer>, Range<Integer>> expectedRangesByLowerBound = Maps.newTreeMap();
    for (Range<Integer> range : expectedRanges) {
      expectedRangesByLowerBound.put(range.lowerBound, range);
    }

    NavigableMap<Cut<Integer>, Range<Integer>> rangesByLowerBound = rangeSet.rangesByLowerBound;
    testNavigationAgainstExpected(expectedRangesByLowerBound, rangesByLowerBound, CUTS_TO_TEST);
  }

  <K, V> void testNavigationAgainstExpected(
      NavigableMap<K, V> expected, NavigableMap<K, V> navigableMap, Iterable<K> keysToTest) {
    for (K key : keysToTest) {
      assertEquals(expected.lowerEntry(key), navigableMap.lowerEntry(key));
      assertEquals(expected.floorEntry(key), navigableMap.floorEntry(key));
      assertEquals(expected.ceilingEntry(key), navigableMap.ceilingEntry(key));
      assertEquals(expected.higherEntry(key), navigableMap.higherEntry(key));
      for (boolean inclusive : new boolean[] {false, true}) {
        assertThat(navigableMap.headMap(key, inclusive).entrySet())
            .containsExactlyElementsIn(expected.headMap(key, inclusive).entrySet())
            .inOrder();
        assertThat(navigableMap.tailMap(key, inclusive).entrySet())
            .containsExactlyElementsIn(expected.tailMap(key, inclusive).entrySet())
            .inOrder();
        assertThat(navigableMap.headMap(key, inclusive).descendingMap().entrySet())
            .containsExactlyElementsIn(expected.headMap(key, inclusive).descendingMap().entrySet())
            .inOrder();
        assertThat(navigableMap.tailMap(key, inclusive).descendingMap().entrySet())
            .containsExactlyElementsIn(expected.tailMap(key, inclusive).descendingMap().entrySet())
            .inOrder();
      }
    }
  }

  public void testIntersects(RangeSet<Integer> rangeSet) {
    for (Range<Integer> query : QUERY_RANGES) {
      boolean expectIntersect = false;
      for (Range<Integer> expectedRange : rangeSet.asRanges()) {
        if (expectedRange.isConnected(query) && !expectedRange.intersection(query).isEmpty()) {
          expectIntersect = true;
          break;
        }
      }
      assertEquals(rangeSet + " was incorrect on intersects(" + query + ")", expectIntersect,
          rangeSet.intersects(query));
    }
  }

  public void testEnclosing(RangeSet<Integer> rangeSet) {
    for (Range<Integer> query : QUERY_RANGES) {
      boolean expectEnclose = false;
      for (Range<Integer> expectedRange : rangeSet.asRanges()) {
        if (expectedRange.encloses(query)) {
          expectEnclose = true;
          break;
        }
      }

      assertEquals(rangeSet + " was incorrect on encloses(" + query + ")", expectEnclose,
          rangeSet.encloses(query));
    }
  }

  public void testAllSingleRangesComplementAgainstRemove() {
    for (Range<Integer> range : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range);

      TreeRangeSet<Integer> complement = TreeRangeSet.create();
      complement.add(Range.<Integer>all());
      complement.remove(range);

      assertEquals(complement, rangeSet.complement());
      assertThat(rangeSet.complement().asRanges())
          .containsExactlyElementsIn(complement.asRanges())
          .inOrder();
    }
  }

  public void testInvariantsEmpty() {
    testInvariants(TreeRangeSet.create());
  }

  public void testEmptyIntersecting() {
    testIntersects(TreeRangeSet.<Integer>create());
    testIntersects(TreeRangeSet.<Integer>create().complement());
  }

  public void testAllSingleRangesIntersecting() {
    for (Range<Integer> range : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range);
      testIntersects(rangeSet);
      testIntersects(rangeSet.complement());
    }
  }

  public void testAllTwoRangesIntersecting() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        testIntersects(rangeSet);
        testIntersects(rangeSet.complement());
      }
    }
  }

  public void testEmptyEnclosing() {
    testEnclosing(TreeRangeSet.<Integer>create());
    testEnclosing(TreeRangeSet.<Integer>create().complement());
  }

  public void testAllSingleRangesEnclosing() {
    for (Range<Integer> range : QUERY_RANGES) {
      TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
      rangeSet.add(range);
      testEnclosing(rangeSet);
      testEnclosing(rangeSet.complement());
    }
  }

  public void testAllTwoRangesEnclosing() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        testEnclosing(rangeSet);
        testEnclosing(rangeSet.complement());
      }
    }
  }

  public void testCreateCopy() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);

        assertEquals(rangeSet, TreeRangeSet.create(rangeSet));
      }
    }
  }

  private RangeSet<Integer> expectedSubRangeSet(
      RangeSet<Integer> rangeSet, Range<Integer> subRange) {
    RangeSet<Integer> expected = TreeRangeSet.create();
    for (Range<Integer> range : rangeSet.asRanges()) {
      if (range.isConnected(subRange)) {
        expected.add(range.intersection(subRange));
      }
    }
    return expected;
  }

  private RangeSet<Integer> expectedComplement(RangeSet<Integer> rangeSet) {
    RangeSet<Integer> expected = TreeRangeSet.create();
    expected.add(Range.<Integer>all());
    expected.removeAll(rangeSet);
    return expected;
  }

  public void testSubRangeSet() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        for (Range<Integer> subRange : QUERY_RANGES) {
          testViewAgainstExpected(
              expectedSubRangeSet(rangeSet, subRange), rangeSet.subRangeSet(subRange));
        }
      }
    }
  }

  public void testComplement() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        testViewAgainstExpected(expectedComplement(rangeSet), rangeSet.complement());
      }
    }
  }

  public void testSubRangeSetOfComplement() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        for (Range<Integer> subRange : QUERY_RANGES) {
          testViewAgainstExpected(
              expectedSubRangeSet(expectedComplement(rangeSet), subRange),
              rangeSet.complement().subRangeSet(subRange));
        }
      }
    }
  }

  public void testComplementOfSubRangeSet() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);
        for (Range<Integer> subRange : QUERY_RANGES) {
          testViewAgainstExpected(
              expectedComplement(expectedSubRangeSet(rangeSet, subRange)),
              rangeSet.subRangeSet(subRange).complement());
        }
      }
    }
  }

  public void testRangesByUpperBound() {
    for (Range<Integer> range1 : QUERY_RANGES) {
      for (Range<Integer> range2 : QUERY_RANGES) {
        TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
        rangeSet.add(range1);
        rangeSet.add(range2);

        NavigableMap<Cut<Integer>, Range<Integer>> expectedRangesByUpperBound = Maps.newTreeMap();
        for (Range<Integer> range : rangeSet.asRanges()) {
          expectedRangesByUpperBound.put(range.upperBound, range);
        }
        testNavigationAgainstExpected(expectedRangesByUpperBound,
            new TreeRangeSet.RangesByUpperBound<Integer>(rangeSet.rangesByLowerBound),
            CUTS_TO_TEST);
      }
    }
  }

  public void testMergesConnectedWithOverlap() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 4));
    rangeSet.add(Range.open(2, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.atLeast(6))
        .inOrder();
  }

  public void testMergesConnectedDisjoint() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 4));
    rangeSet.add(Range.open(4, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.atLeast(6))
        .inOrder();
  }

  public void testIgnoresSmallerSharingNoBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 6));
    rangeSet.add(Range.open(2, 4));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testIgnoresSmallerSharingLowerBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 6));
    rangeSet.add(Range.closed(1, 4));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testIgnoresSmallerSharingUpperBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 6));
    rangeSet.add(Range.closed(3, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testIgnoresEqual() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 6));
    rangeSet.add(Range.closed(1, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testExtendSameLowerBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 4));
    rangeSet.add(Range.closed(1, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testExtendSameUpperBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.add(Range.closed(1, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testExtendBothDirections() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 4));
    rangeSet.add(Range.closed(1, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testAddEmpty() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closedOpen(3, 3));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).isEmpty();
    assertThat(rangeSet.complement().asRanges()).containsExactly(Range.<Integer>all());
  }

  public void testFillHoleExactly() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closedOpen(1, 3));
    rangeSet.add(Range.closedOpen(4, 6));
    rangeSet.add(Range.closedOpen(3, 4));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.atLeast(6))
        .inOrder();
  }

  public void testFillHoleWithOverlap() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closedOpen(1, 3));
    rangeSet.add(Range.closedOpen(4, 6));
    rangeSet.add(Range.closedOpen(2, 5));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closedOpen(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.atLeast(6))
        .inOrder();
  }

  public void testAddManyPairs() {
    for (int aLow = 0; aLow < 6; aLow++) {
      for (int aHigh = 0; aHigh < 6; aHigh++) {
        for (BoundType aLowType : BoundType.values()) {
          for (BoundType aHighType : BoundType.values()) {
            if ((aLow == aHigh && aLowType == OPEN && aHighType == OPEN) || aLow > aHigh) {
              continue;
            }
            for (int bLow = 0; bLow < 6; bLow++) {
              for (int bHigh = 0; bHigh < 6; bHigh++) {
                for (BoundType bLowType : BoundType.values()) {
                  for (BoundType bHighType : BoundType.values()) {
                    if ((bLow == bHigh && bLowType == OPEN && bHighType == OPEN) || bLow > bHigh) {
                      continue;
                    }
                    doPairTest(range(aLow, aLowType, aHigh, aHighType),
                        range(bLow, bLowType, bHigh, bHighType));
                  }
                }
              }
            }
          }
        }
      }
    }
  }

  private static void doPairTest(Range<Integer> a, Range<Integer> b) {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(a);
    rangeSet.add(b);
    if (a.isEmpty() && b.isEmpty()) {
      assertThat(rangeSet.asRanges()).isEmpty();
    } else if (a.isEmpty()) {
      assertThat(rangeSet.asRanges()).contains(b);
    } else if (b.isEmpty()) {
      assertThat(rangeSet.asRanges()).contains(a);
    } else if (a.isConnected(b)) {
      assertThat(rangeSet.asRanges()).containsExactly(a.span(b));
    } else {
      if (a.lowerEndpoint() < b.lowerEndpoint()) {
        assertThat(rangeSet.asRanges()).containsExactly(a, b).inOrder();
      } else {
        assertThat(rangeSet.asRanges()).containsExactly(b, a).inOrder();
      }
    }
  }

  public void testRemoveEmpty() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(1, 6));
    rangeSet.remove(Range.closedOpen(3, 3));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.closed(1, 6));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(1), Range.greaterThan(6))
        .inOrder();
  }

  public void testRemovePartSharingLowerBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 5));
    rangeSet.remove(Range.closedOpen(3, 5));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.singleton(5));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(5), Range.greaterThan(5))
        .inOrder();
  }

  public void testRemovePartSharingUpperBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 5));
    rangeSet.remove(Range.openClosed(3, 5));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).contains(Range.singleton(3));
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.lessThan(3), Range.greaterThan(3))
        .inOrder();
  }

  public void testRemoveMiddle() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.atMost(6));
    rangeSet.remove(Range.closedOpen(3, 4));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges())
        .containsExactly(Range.lessThan(3), Range.closed(4, 6)).inOrder();
    assertThat(rangeSet.complement().asRanges())
        .containsExactly(Range.closedOpen(3, 4), Range.greaterThan(6)).inOrder();
  }

  public void testRemoveNoOverlap() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closedOpen(1, 3));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).containsExactly(Range.closed(3, 6));
  }

  public void testRemovePartFromBelowLowerBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(1, 3));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).containsExactly(Range.openClosed(3, 6));
  }

  public void testRemovePartFromAboveUpperBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(6, 9));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).containsExactly(Range.closedOpen(3, 6));
  }

  public void testRemoveExact() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(3, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).isEmpty();
  }

  public void testRemoveAllFromBelowLowerBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(2, 6));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).isEmpty();
  }

  public void testRemoveAllFromAboveUpperBound() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(3, 7));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).isEmpty();
  }

  public void testRemoveAllExtendingBothDirections() {
    TreeRangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 6));
    rangeSet.remove(Range.closed(2, 7));
    testInvariants(rangeSet);
    assertThat(rangeSet.asRanges()).isEmpty();
  }

  public void testRangeContaining1() {
    RangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 10));
    assertEquals(Range.closed(3, 10), rangeSet.rangeContaining(5));
    assertTrue(rangeSet.contains(5));
    assertNull(rangeSet.rangeContaining(1));
    assertFalse(rangeSet.contains(1));
  }

  public void testRangeContaining2() {
    RangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 10));
    rangeSet.remove(Range.open(5, 7));
    assertEquals(Range.closed(3, 5), rangeSet.rangeContaining(5));
    assertTrue(rangeSet.contains(5));
    assertEquals(Range.closed(7, 10), rangeSet.rangeContaining(8));
    assertTrue(rangeSet.contains(8));
    assertNull(rangeSet.rangeContaining(6));
    assertFalse(rangeSet.contains(6));
  }

  @GwtIncompatible // SerializableTester
  public void testSerialization() {
    RangeSet<Integer> rangeSet = TreeRangeSet.create();
    rangeSet.add(Range.closed(3, 10));
    rangeSet.remove(Range.open(5, 7));
    SerializableTester.reserializeAndAssert(rangeSet);
  }
}


text:
import os, sys
import random
import string

try:
    # Make Python2 work like Python3
    input = raw_input
except NameError:
    # On Python3; already using input
    pass

letters = string.ascii_letters
numbers = string.digits
punctuation = string.punctuation

def generate(password_length, at_least_one_letter, at_least_one_number, at_least_one_punctuation):
    """Generate a password by include enough random
    characters to meet the password length restriction.

    In addition, the user can specify that at least one
    of the each of the classes of character be used.
    """
    #
    # Any combination of characters is valid
    #
    valid_characters = ""
    if at_least_one_letter:
        valid_characters += letters
    if at_least_one_number:
        valid_characters += numbers
    if at_least_one_punctuation:
        valid_characters += punctuation

    #
    # Start with a blank password and then go round enough
    # times to make a password of the required length.
    #
    password = ""
    for i in range(password_length):
        #
        # Each time around, ensure that one of each of the selected
        # groups is chosen, and then just choose randomly from all
        # groups.
        #
        if at_least_one_letter:
            character = random.choice(letters)
            at_least_one_letter = False
        elif at_least_one_number:
            character = random.choice(numbers)
            at_least_one_number = False
        elif at_least_one_punctuation:
            character = random.choice(punctuation)
            at_least_one_punctuation = False
        else:
            character = random.choice(valid_characters)
        password += character

    #
    # Finally, shuffle the password so we don't always get a
    # letter at the beginning, with a number after and some
    # punctuation.
    #
    characters = list(password)
    #
    # random.shuffle shuffles a list *in place*
    #
    random.shuffle(characters)
    #
    # X.join(...) means: return all the strings in (...) joined by X
    # ", ".join(['Eggs', 'Bacon', 'Beans']) => "Eggs, Bacon, Beans"
    # But if you want to generate *real* .csv files, use the csv module
    # because there are lots of corner-cases.
    #
    password = "".join(characters)
    return password

if __name__ == '__main__':
    password_length = int(input("How many letters? "))
    at_least_one_letter = "Y" == (input("At least one letter [Y/n]? ").upper() or "Y")
    at_least_one_number = "Y" == (input("At least one number [Y/n]? ").upper() or "Y")
    at_least_one_punctuation = "Y" == (input("At least one punctuation [Y/n]? ").upper() or "Y")
    password = generate(password_length, at_least_one_letter, at_least_one_number, at_least_one_punctuation)
    print("Your password is: {}".format(password))


text:
Introduction

  This document lists commonly used editor plugins and IDEs from the Go ecosystem
  that make Go development more productive and seamless.
  A comprehensive list of editor support and IDEs for Go development is available at
  the wiki.

Options

The Go ecosystem provides a variety of editor plugins and IDEs to enhance your day-to-day
editing, navigation, testing, and debugging experience.

vim: vim-go plugin provides Go programming language support

Visual Studio Code:
Go extension provides support for the Go programming language

Gogland: Gogland is distributed either as a standalone IDE
or as a plugin for the commercial IntelliJ Platform IDEs

Atom: Go-Plus is an Atom package that provides enhanced Go support

Note that these are only a few top solutions; a more comphensive
community-maintained list of
IDEs and text editor plugins
is available at the Wiki.

Each development environment integrates a number of Go-specific tools.
The following feature matrix lists and compares the most significant features.

vim

Visual Studio Code

Gogland

Atom

    Editing features

    Build and run from the editor/IDE
    Yes
    Yes
    Yes
    Yes

    Autocompletion of identifers (variable, method, and function names)
    Yes
    Yes
    Yes
    Yes

    Type-aware autocompletion
    No
    No
    Yes
    No

    Rename identifiers
    Yes
    Yes
    Yes
    Yes

    Auto format, build, vet, and lint on save
    Yes
    Yes
    Yes1
    Yes

    Auto insert import paths and remove unused on save
    Yes
    Yes
    Yes2
    Yes

    Auto generate JSON, XML tags for struct fields
    Yes
    Yes
    Yes
    Yes

    Navigation features

    Display documentation inline, or open godoc in browser
    Yes
    Yes
    Yes
    Yes

    Switch between *.go and *_test.go file
    Yes
    Yes
    Yes
    No

    Jump to definition and referees
    Yes
    Yes
    Yes
    Yes

    Look up for interface implementations
    Yes
    Yes
    Yes
    Yes

    Search for callers and callees
    Yes
    Yes
    Yes
    Yes

    Testing and debugging features

    Debugger support
    No
    Yes
    Yes
    Yes3

    Run a single test case, all tests from file, or all tests from a package
    Yes
    Yes
    Yes
    No

    Auto generate tests for packages, files and identifiers
    No
    Yes
    No
    No

    Debug tests
    No
    Yes
    Yes
    Yes3

    Display test coverage
    Yes
    Yes
    Yes
    Yes

    Install
    Install
    Install
    Install

1Possible when enabled via Settings > Go > On Save, go vet and golint are available via plugins. Also runs tests on save if configured.

2Additionally, user input can disambiguate when two or more options are available.

3Available if the go-debug package is installed.


text:
layout: post
microblog: true
date: 2008-07-16 19:00 -0500
guid: http://bdougherty.micro.blog/2008/07/17/t860636605.html
---
How about you don't crash Safari half the time I click on things, new Facebook profile. Thanks.


text:
package org.apache.spark.deploy.worker

import java.util.concurrent.atomic.AtomicBoolean

import org.apache.spark.internal.Logging
import org.apache.spark.rpc._

/**
 * Endpoint which connects to a worker process and terminates the JVM if the
 * connection is severed.
 * Provides fate sharing between a worker and its associated child processes.
 */
private[spark] class WorkerWatcher(
    override val rpcEnv: RpcEnv,
    workerUrl: String,
    isTesting: Boolean = false,
    isChildProcessStopping: AtomicBoolean = new AtomicBoolean(false))
  extends RpcEndpoint with Logging {

  logInfo(s"Connecting to worker $workerUrl")
  if (!isTesting) {
    rpcEnv.asyncSetupEndpointRefByURI(workerUrl)
  }

  // Used to avoid shutting down JVM during tests
  // In the normal case, exitNonZero will call `System.exit(-1)` to shutdown the JVM. In the unit
  // test, the user should call `setTesting(true)` so that `exitNonZero` will set `isShutDown` to
  // true rather than calling `System.exit`. The user can check `isShutDown` to know if
  // `exitNonZero` is called.
  private[deploy] var isShutDown = false

  // Lets filter events only from the worker's rpc system
  private val expectedAddress = RpcAddress.fromURIString(workerUrl)
  private def isWorker(address: RpcAddress) = expectedAddress == address

  private def exitNonZero() =
    if (isTesting) {
      isShutDown = true
    } else if (isChildProcessStopping.compareAndSet(false, true)) {
      // SPARK-35714: avoid the duplicate call of `System.exit` to avoid the dead lock
      System.exit(-1)
    }

  override def receive: PartialFunction[Any, Unit] = {
    case e => logWarning(s"Received unexpected message: $e")
  }

  override def onConnected(remoteAddress: RpcAddress): Unit = {
    if (isWorker(remoteAddress)) {
      logInfo(s"Successfully connected to $workerUrl")
    }
  }

  override def onDisconnected(remoteAddress: RpcAddress): Unit = {
    if (isWorker(remoteAddress)) {
      // This log message will never be seen
      logError(s"Lost connection to worker rpc endpoint $workerUrl. Exiting.")
      exitNonZero()
    }
  }

  override def onNetworkError(cause: Throwable, remoteAddress: RpcAddress): Unit = {
    if (isWorker(remoteAddress)) {
      // These logs may not be seen if the worker (and associated pipe) has died
      logError(s"Could not initialize connection to worker $workerUrl. Exiting.")
      logError(s"Error was: $cause")
      exitNonZero()
    }
  }
}


text:
{% extends "moderation/moderators_base.html" %}
{% load humanize i18n static %}

{% block page_title %}{% trans "Invite a New Member" %}{% endblock %}
{% block invite_member_active %}active{% endblock %}

{% block moderators_content %}

    {% include "messages.html" %}
    {% if reinvitation_form.non_field_errors %}

            {% for error in reinvitation_form.non_field_errors %}
                {{ error|escape }}
            {% endfor %}

    {% endif %}

    <form action="{% url 'moderation:invite-user' %}" method="post" class="horizontal-form" novalidate data-parsley-validate>
        <fieldset>
            <legend>{% trans "Invite a New Member" %}</legend>

{% trans "Please provide the details of the member you wish to invite.  Once they have accepted your invitatation, they will be able to edit the details provided here." %}

            {% csrf_token %}
            {{ invitation_form.form_type }}

{% trans "Name" %}

                    {{ invitation_form.full_name }}
                    {% if invitation_form.full_name.errors %}

                            {% for error in invitation_form.full_name.errors %}
                                {{ error|escape }}
                            {% endfor %}

                    {% endif %}

{% trans "Email" %}

                    {{ invitation_form.email }}
                    {% if invitation_form.email.errors %}

                            {% for error in invitation_form.email.errors %}
                                {{ error|escape }}
                            {% endfor %}

                    {% endif %}
                    {% if invitation_form.non_field_errors %}

                            {% for error in invitation_form.non_field_errors %}
                                {{ error|escape }}
                            {% endfor %}

                    {% endif %}

                    <input type="submit" value="{% trans 'Invite New Member' %}" class="button"/>

        </fieldset>
    </form>
    {% if pending %}

{% trans "Invitations pending activation" %}

            {% blocktrans count c=pending|length with count=pending|length|apnumber|title trimmed %}
                {{ count }} member you have invited has not yet activated their account:
            {% plural %}
                {{ count }} members you have invited have not yet activated their account:
            {% endblocktrans %}

                    {% trans "Name" %}
                    {% trans "Email Address" %}
                    {% trans "Date Invited" %}
                    {% trans "Actions" %}

                {% for user in pending %}

                    {{ user.get_full_name|title }}
                    {{ user.email }}
                    {{ user.date_joined|date:"M d, Y" }}

                        {% trans "Resend Invitation" %}
                        {% trans "Revoke Invitation" %}

                {% endfor %}

            <form action="{% url 'moderation:reinvite-user' %}" method="post" class="reinvite-member-form" data-parsley-validate>
                {% csrf_token %}

                    {% trans "Email:" %}
                    {{ reinvitation_form.email }}

                {{ reinvitation_form.user_id }}
                <input type="submit" value="{% trans 'Resend Invitation' %}" class="button"/>
            </form>

            <form action="{% url 'moderation:revoke-invitation' %}" method="post" class="revoke-invitation-form" data-parsley-validate>
                {% csrf_token %}

                        {{ revocation_form.confirm }}
                        {% blocktrans trimmed %}
                            Revoke my invitation to this user at this email address.
                        {% endblocktrans %}

{% trans "This action will also remove logs related to inviting this user" %}.

                {{ revocation_form.user_id }}
                <input type="submit" value="{% trans 'Revoke Invitation' %}" class="button" />
            </form>

    {% endif %}
{% endblock %}


text:
#region License

#endregion

#region Imports

using System;
using System.Reflection;
using System.Text;

using Spring.Core;
using Spring.Core.TypeResolution;
using Spring.Util;

#endregion

namespace Spring.Objects.Factory.Config
{
	///
	/// <see cref="Spring.Objects.Factory.IFactoryObject"/> implementation that
	/// retrieves a <see lang="static"/> or non-static public property value.
	///
	/// <remarks>
	///

	/// Typically used for retrieving public property values.
	///

	/// </remarks>
	/// <author>Rick Evans (.NET)</author>
    [Serializable]
    public class PropertyRetrievingFactoryObject : AbstractFactoryObject, IInitializingObject
	{
		#region Constructor (s) / Destructor

		///
		/// Creates a new instance of the
		/// <see cref="Spring.Objects.Factory.Config.PropertyRetrievingFactoryObject"/> class.
		///
		public PropertyRetrievingFactoryObject()
		{
			Arguments = new object[] {};
		}

		#endregion

		#region Properties

		///
		/// The <see cref="System.Type.AssemblyQualifiedName"/> of the static property
		/// to be retrieved.
		///
		public string StaticProperty
		{
			set
			{
				AssertUtils.ArgumentNotNull(value, "StaticProperty");
                TypeAssemblyHolder info = new TypeAssemblyHolder(value);
				string typeName = info.TypeName;
				int indexWherePropertyStarts = 0;
				do
				{
					try
					{
						indexWherePropertyStarts = typeName.LastIndexOf('.');

						#region Sanity Check

						if (indexWherePropertyStarts == -1
							|| indexWherePropertyStarts == typeName.Length)
						{
							throw new ArgumentException(
								"The value passed to the StaticProperty property must be a fully " +
									"qualified Type plus property name: " +
									"e.g. 'Example.MyExampleClass.MyProperty, MyAssembly'");
						}

						#endregion

						typeName = typeName.Substring(0, indexWherePropertyStarts);
						StringBuilder buffer = new StringBuilder(typeName);
						if (info.IsAssemblyQualified)
						{
                            buffer.Append(TypeAssemblyHolder.TypeAssemblySeparator);
							buffer.Append(info.AssemblyName);
						}
						TargetType = TypeResolutionUtils.ResolveType(buffer.ToString());
					}
					catch (TypeLoadException)
					{
					}
				} while (TargetType == null);
				TargetProperty = info.TypeName.Substring(indexWherePropertyStarts + 1);
			}
		}

		///
		/// Arguments for the property invocation.
		///
		/// <remarks>
		///

		/// If this property is not set, or the value passed to the setter invocation
		/// is a null or zero-length array, a property with no arguments is assumed.
		///

		/// </remarks>
		public object[] Arguments
		{
			get { return _arguments; }
			set
			{
				if (value != null)
				{
					this._arguments = value;
				}
			}
		}

		///
		/// The name of the property the value of which is to be retrieved.
		///
		/// <remarks>
		///

		/// Refers to either a <see lang="static"/> property or a non-static property,
		/// depending on a target object being set.
		///

		/// </remarks>
		public string TargetProperty
		{
			get { return _targetProperty; }
			set { _targetProperty = value; }
		}

		///
		/// The object instance on which the property is defined.
		///
		public object TargetObject
		{
			get { return _targetObject; }
			set
			{
				_targetObject = value;
				_targetObjectWrapper = new ObjectWrapper(_targetObject);
			}
		}

		///
		/// The <see cref="System.Type"/> on which the property is defined.
		///
		public Type TargetType
		{
			get { return _targetType; }
			set { _targetType = value; }
		}

		///
		/// Return the type of object that this
		/// <see cref="Spring.Objects.Factory.IFactoryObject"/> creates, or
		/// <see lang="null"/> if not known in advance.
		///
		public override Type ObjectType
		{
			get { return (Property == null) ? null : Property.PropertyType; }
		}

		private PropertyInfo Property
		{
			get { return _property; }
			set { _property = value; }
		}

		#endregion

		#region Methods

		///
		/// Invoked by an <see cref="Spring.Objects.Factory.IObjectFactory"/>
		/// after it has set all object properties supplied
		/// (and satisfied <see cref="Spring.Objects.Factory.IObjectFactoryAware"/>
		/// and ApplicationContextAware).
		///
		/// <exception cref="System.Exception">
		/// In the event of misconfiguration (such as failure to set an essential
		/// property) or if initialization fails.
		/// </exception>
		public override void AfterPropertiesSet()
		{
			if (TargetType == null
				&& TargetObject == null)
			{
				throw new ArgumentException("One of the TargetType or TargetObject properties must be set.");
			}
			if (TargetProperty == null)
			{
				throw new ArgumentException("The TargetProperty property is required.");
			}
			Type targetType = null;
			BindingFlags propertyFlags = BindingFlags.Public | BindingFlags.IgnoreCase;
			if (TargetObject == null)
			{
				// a static property...
				propertyFlags |= BindingFlags.Static;
				targetType = TargetType;
				if (TargetProperty.IndexOf(".") == -1)
				{
					Property = targetType.GetProperty(TargetProperty, propertyFlags);
				}
				else
				{
					// $£%#@! a nested static property... recurse to the end property
					string property = TargetProperty;
					int propertyIndex = property.IndexOf(".");
					string startProperty = property.Substring(0, propertyIndex);
					Property = targetType.GetProperty(startProperty, propertyFlags);
					TargetObject = Property.GetValue(null, new object[] {});
					TargetProperty = property.Substring(propertyIndex + 1);
					AfterPropertiesSet();
				}
			}
			else
			{
				// an instance property...
				propertyFlags |= BindingFlags.Instance;
				targetType = TargetObject.GetType();

				// using the object wrapper does nested property lookup
				Property = _targetObjectWrapper.GetPropertyInfo(TargetProperty);
			}
			if (Property == null)
			{
				throw new InvalidPropertyException(targetType, TargetProperty);
			}
			if (!Property.CanRead)
			{
				throw new NotWritablePropertyException(TargetProperty, targetType);
			}
			base.AfterPropertiesSet();
		}

		///
		/// Template method that subclasses must override to construct the object
		/// returned by this factory.
		///
		/// <exception cref="System.Exception">
		/// If an exception occured during object creation.
		/// </exception>
		/// <returns>The object returned by this factory.</returns>
		protected override object CreateInstance()
		{
			object instance = null;
			object target = null;
			if (TargetObject != null)
			{
				target = TargetObject;
			}
			try
			{
				if (Arguments.Length == 0 && target != null)
				{
					// using object wrapper supports nested property lookup...
					instance = _targetObjectWrapper.GetPropertyValue(_targetProperty);
				}
				else
				{
					instance = Property.GetValue(target, Arguments);
				}
			}
			catch (Exception ex)
			{
				throw new FatalObjectException("Error reading property value.", ex);
			}
			return instance;
		}

		#endregion

		#region Fields

		private string _targetProperty;
		private ObjectWrapper _targetObjectWrapper;
		private object _targetObject;
		private Type _targetType;
		private PropertyInfo _property;
		private object[] _arguments;

		#endregion
	}
}


text:
package org.mozilla.javascript.ast;

import org.mozilla.javascript.Token;

/**
 * New expression. Node type is {@link Token#NEW}.

 *
 *
NewExpression :
 *      MemberExpression
 *      new NewExpression

 *
 * This node is a subtype of {@link FunctionCall}, mostly for internal code
 * sharing.  Structurally a {@code NewExpression} node is very similar to a
 * {@code FunctionCall}, so it made a certain amount of sense.
 */
public class NewExpression extends FunctionCall {

    private ObjectLiteral initializer;

    {
        type = Token.NEW;
    }

    public NewExpression() {
    }

    public NewExpression(int pos) {
        super(pos);
    }

    public NewExpression(int pos, int len) {
        super(pos, len);
    }

    /**
     * Returns initializer object, if any.
     * @return extra initializer object-literal expression, or {@code null} if
     * not specified.
     */
    public ObjectLiteral getInitializer() {
      return initializer;
    }

    /**
     * Sets initializer object.  Rhino supports an experimental syntax
     * of the form {@code new expr [ ( arglist ) ] [initializer]},
     * in which initializer is an object literal that is used to set
     * additional properties on the newly-created {@code expr} object.
     *
     * @param initializer extra initializer object.
     * Can be {@code null}.
     */
    public void setInitializer(ObjectLiteral initializer) {
      this.initializer = initializer;
      if (initializer != null)
          initializer.setParent(this);
    }

    @Override
    public String toSource(int depth) {
        StringBuilder sb = new StringBuilder();
        sb.append(makeIndent(depth));
        sb.append("new ");
        sb.append(target.toSource(0));
        sb.append("(");
        if (arguments != null) {
            printList(arguments, sb);
        }
        sb.append(")");
        if (initializer != null) {
            sb.append(" ");
            sb.append(initializer.toSource(0));
        }
        return sb.toString();
    }

    /**
     * Visits this node, the target, and each argument.  If there is
     * a trailing initializer node, visits that last.
     */
    @Override
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            target.visit(v);
            for (AstNode arg : getArguments()) {
                arg.visit(v);
            }
            if (initializer != null) {
                initializer.visit(v);
            }
        }
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/divide"
    tools:context="net.coding.program.login.SetGlobalKeyActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:gravity="center_vertical|center_horizontal"
            android:lineSpacingExtra="3dp"
            android:text="您还未设置过用户名(个性后缀)\n 设置后才能正常登录!"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/font_3"
            android:textSize="14sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:orientation="vertical">

            <net.coding.program.common.widget.LoginEditText
                android:id="@+id/globalKeyEdit"
                style="@style/EmailEdit"
                app:digits="@string/input_format_global_key"
                app:hint="用户名(个性后缀)"
                app:topLine="false" />

            <include layout="@layout/divide_bottom_15" />

        </LinearLayout>

        <Button
            android:id="@+id/loginButton"
            style="@style/SendButton"
            android:enabled="true"
            android:text="马上设置" />

    </LinearLayout>
</ScrollView>


text:
MongooseDocument
Type aliasprivate

Module
import { MongooseDocument } from "@tsed/mongoose/lib/interfaces/MongooseDocument"

Source	/mongoose/interfaces/MongooseDocument.ts

### Overview

type MongooseDocument<T> = T & mongoose.Document;


text:
package twitter4j;

/**
 * @author Yusuke Yamamoto - yusuke at mac.com
 * @since Twitter4J 2.1.8
 */
public interface StreamListener {
    void onException(Exception ex);
}


text:
title: 'Production applications updated on 19th of March 2019 at 10:00 AM – 11:00 PM (EET)'
categories: en News
image:
lang: en
published: true
ref: 2019-03-19-release
traffictypes:
  - Road
  - Marine
tags:
  - APIs
  - Admin
---

Digitraffic production applications have been updated.

Changelog:

ROAD

- DPO-586 - Datex2 muotoisen TMS-datan information status -kenttä
- DPO-697 - Asemien laskennallisten vakioiden haku LOTJUsta ja jakaminen Digitrafficissa (BETA-rajapinta)
- DPO-566 - Tarkennettu keliennustepalvelu (BETA-rajapinta)
- DPO-746 - Osa LAM-antureista ei päivity testissä
- DPO-753 - AWS-tuotantoasennuksessa web-instansseja pitäisi käynnistyä kaksi kappaletta
- DPO-755 - Postgresiin pg_stat_statements päälle analysointia varten
- DPO-756 - RoadStationSensorValueDtoRepository:ssa max measured timen korjaus
- DPO-762 - Testissä osa LAM-antureista on hävinnyt

MARINE

- DPO-578 - Uusi integraatio AIS-tiedolle
- DPO-712 - vessels/status topic palauttaa vain "CONNECTED"
- DPO-734 - AIS-tietojen suodatus
- DPO-748 - Vanhan ais-websocket-kuuntelijan poisto
- DPO-755 - Postgresiin pg_stat_statements päälle analysointia varten

We apologize for any inconvenience.


text:
require "rails_helper"

RSpec.describe ListsController do
  include PublishingApiHelpers

  describe "GET show" do
    let(:list) { create(:list, tag:) }

    context "Tag is a MainstreamBrowsePage" do
      let(:tag) { create(:mainstream_browse_page) }

      it "assign the correct instance variables and renders the show template" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        get :show, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :show
      end

      it "does not allow users without GDS Editor permissions access" do
        stub_user.update!(permissions: %w[signin])

        get :show, params: { tag_id: tag.content_id, id: list.id }

        expect(response.status).to eq(403)
      end
    end

    context "Tag is a topic and user does not have `GDS Editor permissions`" do
      let(:tag) { create(:topic) }

      it "assign the correct instance vaiables and renders the show template" do
        stub_user.update!(permissions: %w[signin])

        get :show, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :show
      end
    end
  end

  describe "GET edit_list_items" do
    let(:list) { create(:list, tag:) }

    context "Tag is a MainstreamBrowsePage" do
      let(:tag) { create(:mainstream_browse_page) }

      it "assign the correct instance variables and renders the edit_list_items template" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        get :edit_list_items, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :edit_list_items
      end

      it "does not allow users without GDS Editor permissions access" do
        stub_user.update!(permissions: %w[signin])

        get :edit_list_items, params: { tag_id: tag.content_id, id: list.id }

        expect(response.status).to eq(403)
      end
    end

    context "Tag is a topic and user does not have `GDS Editor permissions`" do
      let(:tag) { create(:topic) }

      it "assign the correct instance vaiables and renders the edit_list_items template" do
        stub_user.update!(permissions: %w[signin])

        get :edit_list_items, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :edit_list_items
      end
    end
  end

  describe "PATCH update_list_items" do
    let(:list) { create(:list, tag:) }
    let!(:list_item1) { create(:list_item, list:, index: 1) }
    let!(:list_item2) { create(:list_item, list:, index: 2) }
    let(:tagged_documents) do
      [
        TaggedDocuments::Document.new(list_item1.title, list_item1.base_path, "123"),
        TaggedDocuments::Document.new(list_item2.title, list_item2.base_path, "456"),
        TaggedDocuments::Document.new("New list", "/new-list", "789"),
        TaggedDocuments::Document.new("Newer list", "/newer-list", "012"),
      ]
    end

    before do
      stub_any_publishing_api_call
      allow_any_instance_of(TaggedDocuments).to receive(:documents).and_return(tagged_documents)
    end

    context "Tag is a MainstreamBrowsePage" do
      let(:tag) { create(:mainstream_browse_page, :published) }

      it "creates a new list item and makes the correct calls to the Publishing API" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        patch :update_list_items, params: {
          tag_id: tag.content_id,
          id: list.id,
          list: { list_items: ["/new-list", "/newer-list"] },
        }

        new_list_item1, new_list_item2 = list.list_items.last(2)

        expect(list.list_items.count).to eq 4
        expect(new_list_item1.title).to eq "New list"
        expect(new_list_item1.base_path).to eq "/new-list"
        expect(new_list_item1.index).to eq 3
        expect(new_list_item2.title).to eq "Newer list"
        expect(new_list_item2.base_path).to eq "/newer-list"
        expect(new_list_item2.index).to eq 4
        expect(response.status).to eq(302)
        expect(response).to redirect_to(tag_list_path(tag, list))
        expect(flash.notice).to eq "2 links successfully added to the list"
        assert_publishing_api_put_content(
          tag.content_id,
          request_json_includes(
            "details" => {
              "groups" => [
                {
                  "name" => list.name,
                  "contents" => [
                    list_item1.base_path,
                    list_item2.base_path,
                    "/new-list",
                    "/newer-list",
                  ],
                },
              ],
              "internal_name" => tag.title,
              "second_level_ordering" => "alphabetical",
              "ordered_second_level_browse_pages" => [],
            },
          ),
        )
        assert_publishing_api_publish(tag.content_id)
        assert_publishing_api_patch_links(tag.content_id)
      end

      it "does not allow users without GDS Editor permissions access" do
        stub_user.update!(permissions: %w[signin])

        patch :update_list_items, params: { tag_id: tag.content_id, id: list.id, list: { list_items: ["/new-list"] } }

        expect(response.status).to eq(403)
      end

      it "adds an error to the list and rerenders then page when no list items are passed into the params" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        patch :update_list_items, params: { tag_id: tag.content_id, id: list.id, list: { list_items: [] } }

        expect(assigns(:list).errors.first.message).to eq "Select a link to add to the list"
        expect(response).to render_template :edit_list_items
      end
    end

    context "Tag is a topic and user does not have `GDS Editor permissions`" do
      let(:tag) { create(:topic, :published) }

      it "creates a new list item and makes the correct calls to the Publishing API" do
        stub_user.update!(permissions: %w[signin])

        patch :update_list_items, params: { tag_id: tag.content_id, id: list.id, list: { list_items: ["/new-list"] } }

        new_list_item = list.reload.list_items.last

        expect(list.list_items.count).to eq 3
        expect(new_list_item.title).to eq "New list"
        expect(new_list_item.base_path).to eq "/new-list"
        expect(new_list_item.index).to eq 3
        expect(response.status).to eq(302)
        expect(response).to redirect_to(tag_list_path(tag, list))
        expect(flash.notice).to eq "1 link successfully added to the list"
        assert_publishing_api_put_content(
          tag.content_id,
          request_json_includes(
            "details" => {
              "groups" => [
                {
                  "name" => list.name,
                  "contents" => [
                    list_item1.base_path,
                    list_item2.base_path,
                    "/new-list",
                  ],
                },
              ],
              "internal_name" => tag.title,
            },
          ),
        )
        assert_publishing_api_publish(tag.content_id)
        assert_publishing_api_patch_links(tag.content_id)
      end
    end
  end

  describe "GET manage_list_item_ordering" do
    let(:list) { create(:list, tag:) }

    context "Tag is a MainstreamBrowsePage" do
      let(:tag) { create(:mainstream_browse_page) }

      it "assign the correct instance variables and renders the manage_list_item_ordering template" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        get :manage_list_item_ordering, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :manage_list_item_ordering
      end

      it "does not allow users without GDS Editor permissions access" do
        stub_user.update!(permissions: %w[signin])

        get :manage_list_item_ordering, params: { tag_id: tag.content_id, id: list.id }

        expect(response.status).to eq(403)
      end
    end

    context "Tag is a topic and user does not have `GDS Editor permissions`" do
      let(:tag) { create(:topic) }

      it "assign the correct instance vaiables and renders the manage_list_item_ordering template" do
        stub_user.update!(permissions: %w[signin])

        get :manage_list_item_ordering, params: { tag_id: tag.content_id, id: list.id }

        expect(assigns(:tag).id).to eq tag.id
        expect(assigns(:list).id).to eq list.id
        expect(response.status).to eq(200)
        expect(response).to render_template :manage_list_item_ordering
      end
    end
  end

  describe "PATCH update_list_item_ordering" do
    let(:list) { create(:list, tag:) }
    let!(:list_item1) { create(:list_item, list:, index: 1) }
    let!(:list_item2) { create(:list_item, list:, index: 2) }
    let(:tagged_documents) do
      [
        TaggedDocuments::Document.new(list_item1.title, list_item1.base_path, "123"),
        TaggedDocuments::Document.new(list_item2.title, list_item2.base_path, "456"),
        TaggedDocuments::Document.new("New list", "/new-list", "789"),
      ]
    end

    before do
      stub_any_publishing_api_call
      allow_any_instance_of(TaggedDocuments).to receive(:documents).and_return(tagged_documents)
    end

    context "Tag is a MainstreamBrowsePage" do
      let(:tag) { create(:mainstream_browse_page, :published) }

      it "updates the list link ordering and makes the correct calls to the Publishing API" do
        stub_user.update!(permissions: ["signin", "GDS Editor"])

        patch :update_list_item_ordering, params: {
          tag_id: tag.content_id,
          id: list.id,
          ordering: { list_item2.id => "1", list_item1.id => "2" },
        }

        expect(list_item2.reload.index).to eq 1
        expect(list_item1.reload.index).to eq 2
        expect(response.status).to eq(302)
        expect(response).to redirect_to(tag_list_path(tag, list))
        expect(flash.notice).to eq "List links reordered successfully"
        assert_publishing_api_put_content(
          tag.content_id,
          request_json_includes(
            "details" => {
              "groups" => [
                {
                  "name" => list.name,
                  "contents" => [
                    list_item2.base_path,
                    list_item1.base_path,
                  ],
                },
              ],
              "internal_name" => tag.title,
              "second_level_ordering" => "alphabetical",
              "ordered_second_level_browse_pages" => [],
            },
          ),
        )
        assert_publishing_api_publish(tag.content_id)
        assert_publishing_api_patch_links(tag.content_id)
      end

      it "does not allow users without GDS Editor permissions access" do
        stub_user.update!(permissions: %w[signin])

        patch :update_list_item_ordering, params: {
          tag_id: tag.content_id,
          id: list.id,
          ordering: { list_item2.id => "1", list_item1.id => "2" },
        }

        expect(response.status).to eq(403)
      end
    end

    context "Tag is a topic and user does not have `GDS Editor permissions`" do
      let(:tag) { create(:topic, :published) }

      it "updates the list link ordering and makes the correct calls to the Publishing API" do
        stub_user.update!(permissions: %w[signin])

        patch :update_list_item_ordering, params: {
          tag_id: tag.content_id,
          id: list.id,
          ordering: { list_item2.id => "1", list_item1.id => "2" },
        }

        expect(list_item2.reload.index).to eq 1
        expect(list_item1.reload.index).to eq 2
        expect(response.status).to eq(302)
        expect(response).to redirect_to(tag_list_path(tag, list))
        expect(flash.notice).to eq "List links reordered successfully"
        assert_publishing_api_put_content(
          tag.content_id,
          request_json_includes(
            "details" => {
              "groups" => [
                {
                  "name" => list.name,
                  "contents" => [
                    list_item2.base_path,
                    list_item1.base_path,
                  ],
                },
              ],
              "internal_name" => tag.title,
            },
          ),
        )
        assert_publishing_api_publish(tag.content_id)
        assert_publishing_api_patch_links(tag.content_id)
      end
    end
  end
end


text:
/**
 * ag-grid-community - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
 * @version v21.1.1
 * @link http://www.ag-grid.com/
 * @license MIT
 */
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var context_1 = require("../context/context");
var gridOptionsWrapper_1 = require("../gridOptionsWrapper");
var utils_1 = require("../utils");
var ResizeObserverService = /** @class */ (function () {
    function ResizeObserverService() {
    }
    ResizeObserverService.prototype.observeResize = function (element, callback, debounceDelay) {
        if (debounceDelay === void 0) { debounceDelay = 50; }
        // put in variable, so available to usePolyfill() function below
        var frameworkFactory = this.frameworkOverrides;
        // this gets fired too often and might cause some relayout issues
        // so we add a debounce to the callback here to avoid the flashing effect.
        var debouncedCallback = utils_1._.debounce(callback, debounceDelay);
        var useBrowserResizeObserver = function () {
            var resizeObserver = new window.ResizeObserver(debouncedCallback);
            resizeObserver.observe(element);
            return function () { return resizeObserver.disconnect(); };
        };
        var usePolyfill = function () {
            // initialise to the current width and height, so first call will have no changes
            var widthLastTime = utils_1._.offsetWidth(element);
            var heightLastTime = utils_1._.offsetHeight(element);
            // when finished, this gets turned to false.
            var running = true;
            var periodicallyCheckWidthAndHeight = function () {
                if (running) {
                    var newWidth = utils_1._.offsetWidth(element);
                    var newHeight = utils_1._.offsetHeight(element);
                    var changed = newWidth !== widthLastTime || newHeight !== heightLastTime;
                    if (changed) {
                        widthLastTime = newWidth;
                        heightLastTime = newHeight;
                        callback();
                    }
                    frameworkFactory.setTimeout(periodicallyCheckWidthAndHeight, debounceDelay);
                }
            };
            periodicallyCheckWidthAndHeight();
            // the callback function we return sets running to false
            return function () { return running = false; };
        };
        var suppressResize = this.gridOptionsWrapper.isSuppressBrowserResizeObserver();
        var resizeObserverExists = !!window.ResizeObserver;
        if (resizeObserverExists && !suppressResize) {
            return useBrowserResizeObserver();
        }
        else {
            return usePolyfill();
        }
    };
    __decorate([
        context_1.Autowired('gridOptionsWrapper'),
        __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
    ], ResizeObserverService.prototype, "gridOptionsWrapper", void 0);
    __decorate([
        context_1.Autowired('frameworkOverrides'),
        __metadata("design:type", Object)
    ], ResizeObserverService.prototype, "frameworkOverrides", void 0);
    ResizeObserverService = __decorate([
        context_1.Bean('resizeObserverService')
    ], ResizeObserverService);
    return ResizeObserverService;
}());
exports.ResizeObserverService = ResizeObserverService;


text:
"""Tests for dopamine.utils.agent_visualizer."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
import shutil

from absl import flags
from dopamine.utils.agent_visualizer import AgentVisualizer
from dopamine.utils.line_plotter import LinePlotter
import numpy as np
from PIL import Image
import tensorflow as tf

FLAGS = flags.FLAGS

class AgentVisualizerTest(tf.test.TestCase):

  def setUp(self):
    super(AgentVisualizerTest, self).setUp()
    self._test_subdir = os.path.join('/tmp/dopamine_tests', 'agent_visualizer')
    shutil.rmtree(self._test_subdir, ignore_errors=True)
    os.makedirs(self._test_subdir)

  def test_agent_visualizer_save_frame(self):
    parameter_dict = LinePlotter._defaults.copy()
    parameter_dict['get_line_data_fn'] = lambda: [[1, 2, 3]]
    plotter = LinePlotter(parameter_dict=parameter_dict)

    agent_visualizer = AgentVisualizer(self._test_subdir, [plotter])
    agent_visualizer.save_frame()

    frame_filename = os.path.join(self._test_subdir, 'frame_000000.png')
    self.assertTrue(tf.io.gfile.exists(frame_filename))

    im = Image.open(frame_filename)
    im_arr = np.array(im)
    self.assertTrue(np.array_equal(im_arr, agent_visualizer.record_frame))

if __name__ == '__main__':
  tf.compat.v1.disable_v2_behavior()
  tf.test.main()


text:
from boards import board_base
import artists
import plants

ITERS = 100
WIDTH = 200
HEIGHT = 200
ARTIST = artists.artist_base()
PLANTS = [plants.plant_base()]
BOARD = board_base.BoardBase(WIDTH, HEIGHT, PLANTS)

class Controller:

    def __init__(self, iterations, board, artist, plants):
        # pick random plant starting places
        self.run()

    def step(self):
        """ Iterate through each plant and give it its possible moves
        and get each move.
        Then update the board accordingly
        """
        board.update()
        artist.draw_board(board)

    def run():
        for _ in range(self.iterations):
            self.step()

if __name__ == "__main__":
    Controller(ITERS, BOARD, ARTIST, PLANTS)


text:
ACCEPTED

#### According to
International Plant Names Index

#### Published in
Ann. Bot. Fenn. 34:149. 1997

#### Original name
null

### Remarks
null


text:
Thank you!

## Editor settings
We use VSCode as our primary editor. The most important plugins we use are:
1. Eslint
2. Editorconfig
3. Beautify
4. Path Intellisense

We use es6 pretty much everywhere. Please use it when you are contributing.

Any functions or classes you are adding must be commented.

If you have questions related to the structure of the application please ask me (@tahnik). If you are curious about the design please ask Hampus (@rekkyrek)


text:
var walmart = require('../index.js')(process.env.WALMART_API_KEY, {protocol: 'http'});

walmart.stores.search(100, "cheerios").then(function(data) {
  console.log("Found " + data.count + " items");
});

walmart.getItem(10449075).then(function(item) {
  console.log(item.product.productName);
});

walmart.getItemByUPC("041100005373").then(function(item) {
  console.log(item.product.productName);
});

walmart.feeds.trending().then(function(data) {
  console.log("Trending found " + data.items.length + " items");
});


text:
<?php
namespace NeuroSYS\DoctrineDatatables;

interface RendererInterface
{
    public function render($template, array $values = array());
}


text:
#import "ElasticLoadBalancingApplySecurityGroupsToLoadBalancerRequest.h"

@implementation ElasticLoadBalancingApplySecurityGroupsToLoadBalancerRequest

@synthesize loadBalancerName;
@synthesize securityGroups;

-(id)init
{
    if (self = [super init]) {
        loadBalancerName = nil;
        securityGroups   = [[NSMutableArray alloc] initWithCapacity:1];
    }

    return self;
}

-(void)addSecurityGroup:(NSString *)securityGroupObject
{
    if (securityGroups == nil) {
        securityGroups = [[NSMutableArray alloc] initWithCapacity:1];
    }

    [securityGroups addObject:securityGroupObject];
}

-(NSString *)description
{
    NSMutableString *buffer = [[NSMutableString alloc] initWithCapacity:256];

    [buffer appendString:@"{"];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"LoadBalancerName: %@,", loadBalancerName] autorelease]];
    [buffer appendString:[[[NSString alloc] initWithFormat:@"SecurityGroups: %@,", securityGroups] autorelease]];
    [buffer appendString:[super description]];
    [buffer appendString:@"}"];

    return [buffer autorelease];
}

-(void)dealloc
{
    [loadBalancerName release];
    [securityGroups release];

    [super dealloc];
}

@end