text:
require 'unit_spec_helper'

describe Shoulda::Matchers::ActionController::SetSessionOrFlashMatcher do
  context 'without any qualifiers' do
    it 'produces the right description' do
      store = build_store(name: 'flash')
      matcher = described_class.new(store)
      expected_description = 'should set any key in flash'

      expect(matcher.description).to eq expected_description
    end

    context 'in the positive' do
      context 'if the store is not empty' do
        it 'accepts' do
          controller = define_class('MyController').new
          store = build_store(empty?: false)
          matcher = described_class.new(store)

          expect(controller).to matcher
        end
      end

      context 'if the store is empty' do
        it 'rejects' do
          controller = define_class('MyController').new
          store = build_store(empty?: true)
          matcher = described_class.new(store)

          expect(controller).not_to matcher
        end

        it 'produces the correct failure message' do
          controller = define_class('MyController').new
          store = build_store(name: 'flash', empty?: true)
          matcher = described_class.new(store)
          expected_message = 'Expected MyController to set any key in flash, but it did not'

          expect { expect(controller).to matcher }.
            to fail_with_message(expected_message)
        end
      end
    end

    context 'in the negative' do
      context 'if the given key is present in the store' do
        it 'produces the correct failure message' do
          controller = define_class('MyController').new
          store = build_store(name: 'flash', empty?: false)
          matcher = described_class.new(store)
          expected_message = 'Expected MyController not to set any key in flash, but it did'

          expect { expect(controller).not_to matcher }.
            to fail_with_message(expected_message)
        end
      end
    end
  end

  context 'with #[]' do
    it 'produces the right description' do
      store = build_store(name: 'flash')
      matcher = described_class.new(store)['the key']
      expected_description = 'should set flash["the key"]'

      expect(matcher.description).to eq expected_description
    end

    context 'in the positive' do
      context 'if the given key is present in the store' do
        it 'accepts' do
          controller = define_class('MyController').new
          store = build_store
          allow(store).to receive(:has_key?).
            with('the key').
            and_return(true)
          matcher = described_class.new(store)['the key']

          expect(controller).to matcher
        end
      end

      context 'if the given key is not present in the store' do
        it 'rejects' do
          controller = define_class('MyController').new
          store = build_store
          allow(store).to receive(:has_key?).
            with('the key').
            and_return(false)
          matcher = described_class.new(store)['the key']

          expect(controller).not_to matcher
        end

        it 'produces the correct failure message' do
          controller = define_class('MyController').new
          store = build_store(name: 'flash')
          allow(store).to receive(:has_key?).
            with('the key').
            and_return(false)
          matcher = described_class.new(store)['the key']
          expected_message = 'Expected MyController to set flash["the key"], but it did not'

          expect { expect(controller).to matcher }.
            to fail_with_message(expected_message)
        end
      end
    end

    context 'in the negative' do
      context 'if the given key is present in the store' do
        it 'produces the correct failure message' do
          controller = define_class('MyController').new
          store = build_store(name: 'flash')
          allow(store).to receive(:has_key?).
            with('the key').
            and_return(true)
          matcher = described_class.new(store)['the key']
          expected_message = 'Expected MyController not to set flash["the key"], but it did'

          expect { expect(controller).not_to matcher }.
            to fail_with_message(expected_message)
        end
      end
    end
  end

  context 'with #to' do
    context 'given a static value' do
      it 'produces the right description' do
        store = build_store(name: 'flash')
        matcher = described_class.new(store).to('the value')
        expected_description = 'should set any key in flash to "the value"'

        expect(matcher.description).to eq expected_description
      end

      context 'in the positive' do
        context 'if the given value is present in the store' do
          it 'accepts' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            matcher = described_class.new(store).to('the value')

            expect(controller).to matcher
          end

          it 'accepts given a value of nil' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with(nil).
              and_return(true)
            matcher = described_class.new(store).to(nil)

            expect(controller).to matcher
          end

          it 'accepts given a value of false' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with(false).
              and_return(true)
            matcher = described_class.new(store).to(false)

            expect(controller).to matcher
          end
        end

        context 'if the given value is not present in the store' do
          it 'rejects' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            matcher = described_class.new(store).to('the value')

            expect(controller).not_to matcher
          end

          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            matcher = described_class.new(store).to('the value')
            expected_message = 'Expected MyController to set any key in flash to "the value", but it did not'

            expect { expect(controller).to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end

      context 'in the negative' do
        context 'if the given value is present in the store' do
          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            matcher = described_class.new(store).to('the value')
            expected_message = 'Expected MyController not to set any key in flash to "the value", but it did'

            expect { expect(controller).not_to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end
    end

    context 'given a regexp' do
      it 'produces the right description' do
        store = build_store(name: 'flash')
        matcher = described_class.new(store).to(/the value/)
        expected_description = 'should set any key in flash to a value matching /the value/'

        expect(matcher.description).to eq expected_description
      end

      context 'in the positive' do
        context 'if the given value is present in the store' do
          it 'accepts' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with(/the value/).
              and_return(true)
            matcher = described_class.new(store).to(/the value/)

            expect(controller).to matcher
          end
        end

        context 'if the given value is not present in the store' do
          it 'rejects' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with(/the value/).
              and_return(false)
            matcher = described_class.new(store).to(/the value/)

            expect(controller).not_to matcher
          end

          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with(/the value/).
              and_return(false)
            matcher = described_class.new(store).to(/the value/)
            expected_message = 'Expected MyController to set any key in flash to a value matching /the value/, but it did not'

            expect { expect(controller).to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end

      context 'in the negative' do
        context 'if the given value is present in the store' do
          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with(/the value/).
              and_return(true)
            matcher = described_class.new(store).to(/the value/)
            expected_message = 'Expected MyController not to set any key in flash to a value matching /the value/, but it did'

            expect { expect(controller).not_to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end
    end

    context 'given a dynamic value' do
      it 'produces the right description' do
        store = build_store(name: 'flash')
        context = double('context', method_in_context: 'the value')
        matcher = described_class.new(store).
          in_context(context).
          to { method_in_context }
        expected_description = 'should set any key in flash to "the value"'

        expect(matcher.description).to eq expected_description
      end

      it 'requires in_context to be specified beforehand' do
        store = build_store(name: 'flash')
        matcher = described_class.new(store)
        expected_message = 'When specifying a value as a block, a context must be specified beforehand, e.g., flash.in_context(context).to { ... }'

        expect { matcher.to { whatever } }.
          to raise_error(ArgumentError, expected_message)
      end

      context 'in the positive' do
        context 'if the value evaluated in the context is present in the store' do
          it 'accepts' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store).
              in_context(context).
              to { method_in_context }

            expect(controller).to matcher
          end
        end

        context 'if the value evaluated in the context is not present in the store' do
          it 'rejects' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store).
              in_context(context).
              to { method_in_context }

            expect(controller).not_to matcher
          end

          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store).
              in_context(context).
              to { method_in_context }
            expected_message = 'Expected MyController to set any key in flash to "the value", but it did not'

            expect { expect(controller).to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end

      context 'in the negative' do
        context 'if the value evaluated in the context is present in the store' do
          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store).
              in_context(context).
              to { method_in_context }
            expected_message = 'Expected MyController not to set any key in flash to "the value", but it did'

            expect { expect(controller).not_to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end
    end
  end

  context 'with #[] + #to' do
    context 'given a static value' do
      it 'produces the right description' do
        store = build_store(name: 'flash')
        matcher = described_class.new(store)['the key'].to('the value')
        expected_description = 'should set flash["the key"] to "the value"'

        expect(matcher.description).to eq expected_description
      end

      context 'in the positive' do
        context 'if the given value is present in the store' do
          it 'accepts' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            matcher = described_class.new(store)['the key'].to('the value')

            expect(controller).to matcher
          end
        end

        context 'if the given value is not present in the store' do
          it 'rejects' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            matcher = described_class.new(store)['the key'].to('the value')

            expect(controller).not_to matcher
          end

          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(false)
            matcher = described_class.new(store)['the key'].to('the value')
            expected_message = 'Expected MyController to set flash["the key"] to "the value", but it did not'

            expect { expect(controller).to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end

      context 'in the negative' do
        context 'if the given value is present in the store' do
          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            matcher = described_class.new(store)['the key'].to('the value')
            expected_message = 'Expected MyController not to set flash["the key"] to "the value", but it did'

            expect { expect(controller).not_to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end
    end

    context 'given a dynamic value' do
      it 'produces the right description' do
        store = build_store(name: 'flash')
        context = double('context', method_in_context: 'the value')
        matcher = described_class.new(store)['the key'].
          in_context(context).
          to { method_in_context }
        expected_description = 'should set flash["the key"] to "the value"'

        expect(matcher.description).to eq expected_description
      end

      context 'in the positive' do
        context 'if the value evaluated in the context is present in the store' do
          it 'accepts' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store)['the key'].
              in_context(context).
              to { method_in_context }

            expect(controller).to matcher
          end
        end

        context 'if the value evaluated in the context is not present in the store' do
          it 'rejects' do
            controller = define_class('MyController').new
            store = build_store
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(false)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store)['the key'].
              in_context(context).
              to { method_in_context }

            expect(controller).not_to matcher
          end

          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(false)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store)['the key'].
              in_context(context).
              to { method_in_context }
            expected_message = 'Expected MyController to set flash["the key"] to "the value", but it did not'

            expect { expect(controller).to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end

      context 'in the negative' do
        context 'if the value evaluated in the context is present in the store' do
          it 'produces the correct failure message' do
            controller = define_class('MyController').new
            store = build_store(name: 'flash')
            allow(store).to receive(:has_key?).
              with('the key').
              and_return(true)
            allow(store).to receive(:has_value?).
              with('the value').
              and_return(true)
            context = double('context', method_in_context: 'the value')
            matcher = described_class.new(store)['the key'].
              in_context(context).
              to { method_in_context }
            expected_message = 'Expected MyController not to set flash["the key"] to "the value", but it did'

            expect { expect(controller).not_to matcher }.
              to fail_with_message(expected_message)
          end
        end
      end
    end
  end

  def build_store(overrides = {})
    defaults = {
      :name => 'store',
      :controller= => nil,
      :has_key? => nil,
      :has_value? => nil,
      :empty? => nil,
    }
    methods = defaults.merge(overrides)
    double('store', methods)
  end
end


text: DEBUG=myapp npm start

redpajama_set_name: RedPajamaGithub


text:
module consulo.util.nodep {
  requires java.xml;

  exports consulo.util.nodep;
  exports consulo.util.nodep.classloader;
  exports consulo.util.nodep.collection;
  exports consulo.util.nodep.function;
  exports consulo.util.nodep.io;
  exports consulo.util.nodep.map;
  exports consulo.util.nodep.reference;
  exports consulo.util.nodep.text;
  exports consulo.util.nodep.xml;
  exports consulo.util.nodep.xml.node;
}


text:
<!doctype html>

	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>TimeSpan | TimeSpanJS</title>
	<meta name="description" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="../assets/css/main.css">

						Search
						<input id="tsd-search-field" type="text" />

Preparing search index...

The search index is not available

					TimeSpanJS

						Options

							<input type="checkbox" id="tsd-filter-inherited" checked />
							Inherited
							<input type="checkbox" id="tsd-filter-private" checked />
							Private
							<input type="checkbox" id="tsd-filter-externals" checked />
							Externals
							<input type="checkbox" id="tsd-filter-only-exported" />
							Only exported

					Menu

					Globals

					TimeSpan

Class TimeSpan

A time span.

author

xenon

date

14.11.2014

Index

Constructor methods

constructor

Properties

_ticks

is<wbr>Time<wbr>Span

Get accessors

days

hours

milliseconds

minutes

seconds

ticks

total<wbr>Days

total<wbr>Hours

total<wbr>Milliseconds

total<wbr>Minutes

total<wbr>Seconds

Methods

add

add

compare

format

get<wbr>Version

negate

parse

subtract

subtract

Constructor methods

constructor

constructor(): TimeSpan

constructor(days: , hours: , minutes: , seconds: , milliseconds: ): TimeSpan

constructor(days: , hours: , minutes: , seconds: ): TimeSpan

constructor(days: , hours: , minutes: ): TimeSpan

constructor(value: , timeunit: ): TimeSpan

constructor(ticks: ): TimeSpan

constructor(timespan: ): TimeSpan

Defined in timespan.ts:33

Default constructor.

author

xenon

date

14.11.2014

Returns         TimeSpan

Defined in timespan.ts:84

Constructor.

author

xenon

date

14.11.2014

Parameters

days:

(Optional) the days.

hours:

(Optional) the hours.

minutes:

(Optional) the minutes.

seconds:

(Optional) the seconds.

milliseconds:

(Optional) the milliseconds.

Returns         TimeSpan

Defined in timespan.ts:72

Constructor.

author

xenon

date

14.11.2014

Parameters

days:

(Optional) the days.

hours:

(Optional) the hours.

minutes:

(Optional) the minutes.

seconds:

(Optional) the seconds.

Returns         TimeSpan

Defined in timespan.ts:61

Constructor.

author

xenon

date

14.11.2014

Parameters

days:

(Optional) the days.

hours:

(Optional) the hours.

minutes:

(Optional) the minutes.

Returns         TimeSpan

Defined in timespan.ts:51

Constructor.

author

xenon

date

14.11.2014

Parameters

value:

The value.

timeunit:

The timeunit.

Returns         TimeSpan

Defined in timespan.ts:42

Constructor.

Parameters

ticks:

Returns         TimeSpan

Defined in timespan.ts:41

Copy constructor.

author

xenon

date

14.11.2014

Parameters

timespan:

The timespan.

Returns         TimeSpan

Properties

private _ticks

_ticks:

Defined in timespan.ts:25

is<wbr>Time<wbr>Span

is<wbr>Time<wbr>Span:

Defined in timespan.ts:477

true if this object is time span.

Get accessors

days

days()

Defined in timespan.ts:293

Gets the days.

author

xenon

date

14.11.2014

hours

hours()

Defined in timespan.ts:282

Gets the hours.

author

xenon

date

14.11.2014

milliseconds

milliseconds()

Defined in timespan.ts:249

Gets the milliseconds.

author

xenon

date

14.11.2014

minutes

minutes()

Defined in timespan.ts:271

Gets the minutes.

author

xenon

date

14.11.2014

seconds

seconds()

Defined in timespan.ts:260

Gets the seconds.

author

xenon

date

14.11.2014

ticks

ticks(value: )

ticks()

Defined in timespan.ts:234

Set ticks to the given value.

author

xenon

date

14.11.2014

Parameters

value:

The value.

Defined in timespan.ts:222

Gets the ticks.

author

xenon

date

14.11.2014

total<wbr>Days

total<wbr>Days()

Defined in timespan.ts:166

Total days.

author

xenon

date

14.11.2014

total<wbr>Hours

total<wbr>Hours()

Defined in timespan.ts:178

Total hours.

author

xenon

date

14.11.2014

total<wbr>Milliseconds

total<wbr>Milliseconds()

Defined in timespan.ts:211

Total milliseconds.

author

xenon

date

14.11.2014

total<wbr>Minutes

total<wbr>Minutes()

Defined in timespan.ts:189

Total minutes.

author

xenon

date

14.11.2014

total<wbr>Seconds

total<wbr>Seconds()

Defined in timespan.ts:200

Total seconds.

author

xenon

date

14.11.2014

Methods

add

add(a?: , b?: )

add(value: , timeunit: )

add(timespan: )

Defined in timespan.ts:325

Adds a.

author

xenon

date

14.11.2014

Parameters

a?:  optional

(Optional) any to process.

b?:  optional

(Optional) any to process.

Defined in timespan.ts:315

Adds value.

author

xenon

date

14.11.2014

Parameters

value:

The value.

timeunit:

The timeunit.

Defined in timespan.ts:305

Adds timespan.

author

xenon

date

14.11.2014

Parameters

timespan:

The timespan to add.

static add

add(timespan1: , timespan2: )

Defined in timespan.ts:367

Adds timespan1.

author

xenon

date

14.11.2014

Parameters

timespan1:

The first timespan.

timespan2:

The second timespan.

static compare

compare(timespan1: , timespan2: )

Defined in timespan.ts:455

Compares two TimeSpan objects to determine their relative ordering.

author

xenon

date

14.11.2014

Parameters

timespan1:

Time span to be compared.

timespan2:

Time span to be compared.

format

format(format?: )

Defined in timespan.ts:498

Formats the given format.

author

xenon

date

14.11.2014

Parameters

format?:  optional

(Optional) describes the format to use.

static get<wbr>Version

get<wbr>Version()

Defined in timespan.ts:486

Gets the version.

author

xenon

date

14.11.2014

negate

negate()

Defined in timespan.ts:472

Negates this object.

author

xenon

date

14.11.2014

static parse

parse(formattedtext: )

Defined in timespan.ts:538

todo: Add max and min.

author

xenon

date

14.11.2014

Parameters

formattedtext:

The formattedtext.

static subtract

subtract(timespan1: , timespan2: )

Defined in timespan.ts:441

Subtracts.

author

xenon

date

14.11.2014

Parameters

timespan1:

The first timespan.

timespan2:

The second timespan.

subtract

subtract(a?: , b?: )

subtract(value: , timeunit: )

subtract(timespan: )

Defined in timespan.ts:399

Subtracts.

author

xenon

date

14.11.2014

Parameters

a?:  optional

(Optional) any to process.

b?:  optional

(Optional) any to process.

Defined in timespan.ts:389

Subtracts.

author

xenon

date

14.11.2014

Parameters

value:

The value.

timeunit:

The timeunit.

Defined in timespan.ts:379

Subtracts the given timespan.

author

xenon

date

14.11.2014

Parameters

timespan:

The timespan.

						Globals

						Time<wbr>Unit

						Time<wbr>Span

								constructor

								_ticks

								is<wbr>Time<wbr>Span

								days

								hours

								milliseconds

								minutes

								seconds

								ticks

								total<wbr>Days

								total<wbr>Hours

								total<wbr>Milliseconds

								total<wbr>Minutes

								total<wbr>Seconds

								add

								add

								compare

								format

								get<wbr>Version

								negate

								parse

								subtract

								subtract

Legend

Container, dynamic module

Enumeration

Enumeration member

Object literal

Constructor

Variable

Function, call signature, accessor

Index signature

Interface

Constructor

Property

Member, accessor

Index signature

Class

Constructor

Property

Member, accessor

Index signature

Inherited constructor

Inherited property

Inherited member

Private constructor

Private property

Private member

Static property

Static member

Generated using TypeDoc


text:
"""Setup.py module for the workflow's worker utilities.

All the workflow related code is gathered in a package that will be built as a
source distribution, staged in the staging area for the workflow being run and
then installed in the workers when they start running.

This behavior is triggered by specifying the --setup_file command line option
when running the workflow for remote execution.
"""

import setuptools
from setuptools import find_packages

REQUIREMENTS = [
    "apache-beam[gcp]==2.41.0",
    "hdbscan==0.8.28",
    "scikit-learn==1.0.2",
    "transformers==4.21.1",
    "torch==1.12.1",
    "pandas==1.3.5",
    "yagmail==0.15.283",
]

setuptools.setup(
    name="anomaly-detection-pipeline",
    version="1.1.1",
    install_requires=REQUIREMENTS,
    packages=find_packages(),
    author="Apache Software Foundation",
    author_email="dev@beam.apache.org",
    py_modules=["config"],
)


text:
<?php

namespace Ehann\RediSearch\Query;

class SearchResult
{
    protected $count;
    protected $documents;

    public function __construct(int $count, array $documents)
    {
        $this->count = $count;
        $this->documents = $documents;
    }

    public function getCount(): int
    {
        return $this->count;
    }

    public function getDocuments(): array
    {
        return $this->documents;
    }

    public static function makeSearchResult(
        array $rawRediSearchResult,
        bool $documentsAsArray,
        bool $withScores = false,
        bool $withPayloads = false,
        bool $noContent = false
    ) {
        $documentWidth = $noContent ? 1 : 2;

        if (!$rawRediSearchResult) {
            return false;
        }

        if (count($rawRediSearchResult) === 1) {
            return new SearchResult(0, []);
        }

        if ($withScores) {
            $documentWidth++;
        }

        if ($withPayloads) {
            $documentWidth++;
        }

        $count = array_shift($rawRediSearchResult);
        $documents = [];
        for ($i = 0; $i < count($rawRediSearchResult); $i += $documentWidth) {
            $document = $documentsAsArray ? [] : new \stdClass();
            $documentsAsArray ?
                $document['id'] = $rawRediSearchResult[$i] :
                $document->id = $rawRediSearchResult[$i];
            if ($withScores) {
                $documentsAsArray ?
                    $document['score'] = $rawRediSearchResult[$i+1] :
                    $document->score = $rawRediSearchResult[$i+1];
            }
            if ($withPayloads) {
                $j = $withScores ? 2 : 1;
                $documentsAsArray ?
                    $document['payload'] = $rawRediSearchResult[$i+$j] :
                    $document->payload = $rawRediSearchResult[$i+$j];
            }
            if (!$noContent) {
                $fields = $rawRediSearchResult[$i + ($documentWidth - 1)];
                if (is_array($fields)) {
                    for ($j = 0; $j < count($fields); $j += 2) {
                        $documentsAsArray ?
                            $document[$fields[$j]] = $fields[$j + 1] :
                            $document->{$fields[$j]} = $fields[$j + 1];
                    }
                }
            }
            $documents[] = $document;
        }
        return new SearchResult($count, $documents);
    }
}


text:
using content::BrowserThread;

namespace brightray {

namespace {

// Comma-separated list of rules that control how hostnames are mapped.
//
// For example:
//    "MAP * 127.0.0.1" --> Forces all hostnames to be mapped to 127.0.0.1
//    "MAP *.google.com proxy" --> Forces all google.com subdomains to be
//                                 resolved to "proxy".
//    "MAP test.com [::1]:77 --> Forces "test.com" to resolve to IPv6 loopback.
//                               Will also force the port of the resulting
//                               socket address to be 77.
//    "MAP * baz, EXCLUDE www.google.com" --> Remaps everything to "baz",
//                                            except for "www.google.com".
//
// These mappings apply to the endpoint host in a net::URLRequest (the TCP
// connect and host resolver in a direct connection, and the CONNECT in an http
// proxy connection, and the endpoint host in a SOCKS proxy connection).
const char kHostRules[] = "host-rules";

// Don't use a proxy server, always make direct connections. Overrides any
// other proxy server flags that are passed.
const char kNoProxyServer[] = "no-proxy-server";

// Uses a specified proxy server, overrides system settings. This switch only
// affects HTTP and HTTPS requests.
const char kProxyServer[] = "proxy-server";

}  // namespace

net::URLRequestJobFactory* URLRequestContextGetter::Delegate::CreateURLRequestJobFactory(
    content::ProtocolHandlerMap* protocol_handlers,
    content::URLRequestInterceptorScopedVector* protocol_interceptors) {
  scoped_ptr<net::URLRequestJobFactoryImpl> job_factory(new net::URLRequestJobFactoryImpl);

  for (auto it = protocol_handlers->begin(); it != protocol_handlers->end(); ++it)
    job_factory->SetProtocolHandler(it->first, it->second.release());
  protocol_handlers->clear();

  job_factory->SetProtocolHandler(url::kDataScheme, new net::DataProtocolHandler);
  job_factory->SetProtocolHandler(url::kFileScheme, new net::FileProtocolHandler(
      BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
          base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));

  // Set up interceptors in the reverse order.
  scoped_ptr<net::URLRequestJobFactory> top_job_factory =
      job_factory.PassAs<net::URLRequestJobFactory>();
  content::URLRequestInterceptorScopedVector::reverse_iterator i;
  for (i = protocol_interceptors->rbegin(); i != protocol_interceptors->rend(); ++i)
    top_job_factory.reset(new net::URLRequestInterceptingJobFactory(
        top_job_factory.Pass(), make_scoped_ptr(*i)));
  protocol_interceptors->weak_clear();

  return top_job_factory.release();
}

URLRequestContextGetter::URLRequestContextGetter(
    Delegate* delegate,
    const base::FilePath& base_path,
    base::MessageLoop* io_loop,
    base::MessageLoop* file_loop,
    content::ProtocolHandlerMap* protocol_handlers,
    content::URLRequestInterceptorScopedVector protocol_interceptors)
    : delegate_(delegate),
      base_path_(base_path),
      io_loop_(io_loop),
      file_loop_(file_loop),
      protocol_interceptors_(protocol_interceptors.Pass()) {
  // Must first be created on the UI thread.
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

  std::swap(protocol_handlers_, *protocol_handlers);

  // We must create the proxy config service on the UI loop on Linux because it
  // must synchronously run on the glib message loop. This will be passed to
  // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
  proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
      io_loop_->message_loop_proxy(), file_loop_));
}

URLRequestContextGetter::~URLRequestContextGetter() {
}

net::HostResolver* URLRequestContextGetter::host_resolver() {
  return url_request_context_->host_resolver();
}

net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));

  const CommandLine& command_line = *CommandLine::ForCurrentProcess();
  if (!url_request_context_.get()) {
    url_request_context_.reset(new net::URLRequestContext);
    network_delegate_.reset(delegate_->CreateNetworkDelegate());
    url_request_context_->set_network_delegate(network_delegate_.get());

    storage_.reset(new net::URLRequestContextStorage(url_request_context_.get()));
    auto cookie_config = content::CookieStoreConfig(
        base_path_.Append(FILE_PATH_LITERAL("Cookies")),
        content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
        NULL, NULL);
    storage_->set_cookie_store(content::CreateCookieStore(cookie_config));
    storage_->set_channel_id_service(new net::ChannelIDService(
        new net::DefaultChannelIDStore(NULL),
        base::WorkerPool::GetTaskRunner(true)));
    storage_->set_http_user_agent_settings(new net::StaticHttpUserAgentSettings(
        "en-us,en", base::EmptyString()));

    scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));

    // --host-resolver-rules
    if (command_line.HasSwitch(switches::kHostResolverRules)) {
      scoped_ptr<net::MappedHostResolver> remapped_resolver(
          new net::MappedHostResolver(host_resolver.Pass()));
      remapped_resolver->SetRulesFromString(
          command_line.GetSwitchValueASCII(switches::kHostResolverRules));
      host_resolver = remapped_resolver.PassAs<net::HostResolver>();
    }

    // --proxy-server
    net::DhcpProxyScriptFetcherFactory dhcp_factory;
    if (command_line.HasSwitch(kNoProxyServer))
      storage_->set_proxy_service(net::ProxyService::CreateDirect());
    else if (command_line.HasSwitch(kProxyServer))
      storage_->set_proxy_service(net::ProxyService::CreateFixed(
          command_line.GetSwitchValueASCII(kProxyServer)));
    else
      storage_->set_proxy_service(
          net::CreateProxyServiceUsingV8ProxyResolver(
              proxy_config_service_.release(),
              new net::ProxyScriptFetcherImpl(url_request_context_.get()),
              dhcp_factory.Create(url_request_context_.get()),
              host_resolver.get(),
              NULL,
              url_request_context_->network_delegate()));

    storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
    storage_->set_transport_security_state(new net::TransportSecurityState);
    storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
    storage_->set_http_auth_handler_factory(
        net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
    scoped_ptr<net::HttpServerProperties> server_properties(
        new net::HttpServerPropertiesImpl);
    storage_->set_http_server_properties(server_properties.Pass());

    net::HttpNetworkSession::Params network_session_params;
    network_session_params.cert_verifier = url_request_context_->cert_verifier();
    network_session_params.proxy_service = url_request_context_->proxy_service();
    network_session_params.ssl_config_service = url_request_context_->ssl_config_service();
    network_session_params.network_delegate = url_request_context_->network_delegate();
    network_session_params.http_server_properties = url_request_context_->http_server_properties();
    network_session_params.ignore_certificate_errors = false;
    network_session_params.transport_security_state =
        url_request_context_->transport_security_state();
    network_session_params.channel_id_service =
        url_request_context_->channel_id_service();
    network_session_params.http_auth_handler_factory =
        url_request_context_->http_auth_handler_factory();

    // --host-rules
    if (command_line.HasSwitch(kHostRules)) {
      host_mapping_rules_.reset(new net::HostMappingRules);
      host_mapping_rules_->SetRulesFromString(command_line.GetSwitchValueASCII(kHostRules));
      network_session_params.host_mapping_rules = host_mapping_rules_.get();
    }

    // Give |storage_| ownership at the end in case it's |mapped_host_resolver|.
    storage_->set_host_resolver(host_resolver.Pass());
    network_session_params.host_resolver = url_request_context_->host_resolver();

    base::FilePath cache_path = base_path_.Append(FILE_PATH_LITERAL("Cache"));
    net::HttpCache::DefaultBackend* backend =
        new net::HttpCache::DefaultBackend(
            net::DISK_CACHE,
            net::CACHE_BACKEND_DEFAULT,
            cache_path,
            0,
            BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
    storage_->set_http_transaction_factory(new net::HttpCache(network_session_params, backend));

    storage_->set_job_factory(delegate_->CreateURLRequestJobFactory(
        &protocol_handlers_, &protocol_interceptors_));
  }

  return url_request_context_.get();
}

scoped_refptr<base::SingleThreadTaskRunner> URLRequestContextGetter::GetNetworkTaskRunner() const {
  return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
}

}  // namespace brightray


text:
This is a brief introduction to some common practices when it comes to testing frontend modules, and *test-driven development.* The goal is to test *while* you develop the module, so that you end up with a test for each feature you've added.

## contents

- [global tools](#global-tools)
- [tape](#tape)
- [nodemon](#nodemon)
- [beefy](#beefy)
- [smokestack](#smokestack)
- [pretty-printing](#pretty-printing)
- [alternatives](#alternatives)

## global tools

The first step is to install some global tools that we will use for testing and development. Usually it's recommended to install these tools locally (per-module), but we will get to that a bit later. For now, global tools help us get up and running a bit quicker.

```sh
# installs some global tools
npm i beefy nodemon browserify faucet -g
```

*TIP* - `npm i` is shorthand for `npm install`

## tape

Many modules are generic and not tied specifically to NodeJS or the browser. For example, a `rgb-to-hsl` color conversion module does not need to rely on the DOM or on any OS-level features. For these modules we can use [tape](https://www.npmjs.com/package/tape), which works in Node and the browser.

First, stub out a `test.js` file. If you plan to have many tests and assets, you might want to put this in a `tests` folder. Some tools like [module-generator](https://www.npmjs.com/package/module-generator) might already stub this out for you.

```js
var rgb2hsl = require('./')
var test = require('tape')

test('converts rgb colors to hsl', function(t) {
    //... unit tests here
    t.end()
})
```

Then, you can update the `scripts` field of your `package.json`. This might already be done if you used a module generator.

```json
  "scripts": {
    "test": "node test.js"
  }
```

You can now test the module with `npm test` (alias for `npm run test`), or just running `node test.js`.

## nodemon

When working with a generic module like `rgb-to-hsl`, it's usually faster to develop it in a terminal than to set up HTML and a browser. During development, we can use [nodemon](https://www.npmjs.com/package/nodemon) to live-reload the test file. The process looks like this:

```sh
# start listening to our test.js file
nodemon test.js
```

Now when you save the `test.js` file, it will auto-reload the terminal script and print the results.

## adding unit tests

Now you can start developing your core module, and testing while you do so. For example, your tests might look like this after a few iterations. We use `equal` to compare two values with strict equality, and then `deepEqual` to compare arrays and objects. Make sure to end tests with `t.end()`.

You can read more about tape, async tests, and other features [here](http://substack.net/how_I_write_tests_for_node_and_the_browser).

```js
var rgb2hsl = require('./')
var test = require('tape')

test('converts rgb colors to hsl', function(t) {
    var color = [125, 125, 125]
    t.equal(rgb2hsl(color).length, 3, 'should return [H, S, V] array')
    t.equal(rgb2hsl(color)[1], 0, 'should be zero saturation')
    t.deepEqual(rgb2hsl([255, 0, 0]), [0, 100, 50], 'should be pure red')
    //.. some other tests..
    t.end()
})
```

## beefy

The above `nodemon` tool won't work with browser code. If we're making a browser-specific module (like [dom-css](https://github.com/mattdesl/dom-css)) we can do some initial development with [beefy](https://www.npmjs.com/package/beefy) using the following command:

```sh
#run beefy and open the browser
beefy test --open
```

*TIP* - `beefy foo` is shorthand for `beefy foo.js`

This will serve the file at `localhost:9966`. Now you can save the `test.js` file and reload the browser to see the results in the console. Beefy is useful for rapid prototyping, and modules that are harder to automate (like WebGL code, user interactions, etc). It's also a good way to deliver [demo / example code](https://github.com/Jam3/delaunify/blob/e83a2118df8e1fc7f5dc03311d288fc8dc3b8cb6/package.json#L27) to the user.

It's typically a good idea to save these tools locally, so that anybody cloning your repo is running the same versions you are.

```sh
npm install beefy browserify --save-dev
```

Users cloning the repo won't be able to run `beefy test.js` from terminal. Instead, locally-installed tools are run via `npm-scripts` (it first looks inside `node_modules`). So now your package.json looks like this:

```json
  "scripts": {
    "test": "beefy test.js --open"
  }
```

Now running `npm test` will open beefy.

## smokestack

Although beefy is pretty good, it would be better if we could automate our tests and eventually have them running in the cloud (like with [zuul](https://github.com/defunctzombie/zuul) and SauceLabs). It can also be tedious to have to open DevTools just to see the test results.

One alternative to beefy is to use [smokestack](https://www.npmjs.com/package/smokestack) for automation. This launches Chrome or FireFox, so it allows us to test the full range of Web APIs (WebGL, WebAudio, etc).

We will install it locally, as well as a couple of other tools:

```sh
npm install smokestack tap-closer browserify --save-dev
```

Then our tests are run like so:

```json
  "scripts": {
    "test": "browserify test.js | tap-closer | smokestack"
  }
```

Now when we run `npm test` it will run the tests in a browser and print the result to the console. Eventually, these modules can be updated to run the tests in the cloud on a variety of browsers. An example is [dom-css](https://github.com/mattdesl/dom-css), which uses SauceLabs for testing and Travis for continuous integration.

You may also be interested in [testling](https://www.npmjs.com/package/testling) which has similar goals, except focuses more on PhantomJS (i.e. runs heedlessly, but doesn't support full range of browser capabilities).

## pretty-printing

![img](http://i.imgur.com/bROGMVq.png)

We can use [faucet](https://www.npmjs.com/package/faucet) or [tap-spec](https://www.npmjs.com/package/tap-spec) to pretty-print the test results, making them coloured and more compact. Example:

```sh
nodemon test | faucet
```

needs a globally-installed faucet

If you use it in your package.json, you should install it locally.

```js
npm install faucet --save-dev
```

For example, if we are using smokestack:

```json
  "scripts": {
    "test": "browserify test.js | tap-closer | smokestack | faucet"
  }
```

## alternatives

- [wzrd](https://www.npmjs.com/package/wzrd), [budo](https://www.npmjs.com/package/budo) or [prova](https://www.npmjs.com/package/prova) can be used instead of `beefy`
- [testling](https://www.npmjs.com/package/testling) and [zuul](https://github.com/defunctzombie/zuul) can be used instead of `smokestack`
- [a bunch of alternatives](https://github.com/substack/tape#pretty-reporters) to `faucet`


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Stressor Dashboard</title>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.css" rel="stylesheet" type="text/css">


text:
package com.young.simpledict.service.event;

import android.util.Pair;

import java.io.File;

/**
 * Author: landerlyoung
 * Date:   2014-10-28
 * Time:   20:47
 * Life with passion. Code with creativity!
 */
public class DownloadBlobRequest extends BaseEvent {
    public Pair<String, File> requestUrlAndFileToStore;
}


text:
controllers.controller('footerController', ['$scope', '$http', '$location', 'mainService',
  function($scope, $http, $location, $mainService, $eventService) {

  }]);


text:
<?php
require '../../common.inc.php';
$_groupid == 1 or exit('Access Denied');
isset($mediaid) or exit('Access Denied');
require DT_ROOT.'/api/weixin/init.inc.php';
dheader('http://file.api.weixin.qq.com/cgi-bin/media/get?access_token='.$access_token.'&media_id='.$mediaid);
?>


text:
{% set page = {
  title: 'index',
  dev: true,
  secondary: true,
  html_classes: ['page-class']
} %}

{% extends page.layout | d(prototype.current.layout) %}

{% block primary %}
Back

Do you have any savings?

  <form>

      <fieldset>

          <input id="example-contact-by-text" type="radio" name="checkbox-contact-group" value="No">
          Yes

          How much?
          <input class="form-control" name="contact-text-message" type="text" id="contact-text-message">

          <input id="example-contact-by-email" type="radio" name="checkbox-contact-group" value="Yes">
          No

    </fieldset>

  </form>

    Continue

{% endblock %}

{% block secondary %}

{% endblock %}