text:
require 'spec_helper'

describe Spree::AffirmCheckout do
  let(:valid_checkout) { FactoryGirl.create(:affirm_checkout) }
  let(:affirm_payment) { FactoryGirl.create(:affirm_payment) }

  describe "scopes" do
    describe "with_payment_profile" do
      it "returns all" do
        expect(Spree::AffirmCheckout.all).to eq(Spree::AffirmCheckout.with_payment_profile)
      end
    end

  end

  describe '#details' do
    it "calls get_checkout from the payment provider exactly once" do
      _checkout = FactoryGirl.build(:affirm_checkout, stub_details: false)
      _checkout.payment_method.provider.stub(:get_checkout) do
         {"hello" => "there"}
      end
      expect(_checkout.payment_method.provider).to receive(:get_checkout).exactly(1).times
      _checkout.details
      _checkout.details
      _checkout.details
    end
  end

  describe "#valid?" do
    context "with all valid checkout details" do
      it "should return true" do
        expect(valid_checkout.valid?).to be(true)
      end
    end
  end

  describe "#check_valid_products" do
    context "with all matching fields" do
      it "does not set an error" do
        valid_checkout.check_valid_products
        expect(valid_checkout.errors.size).to be(0)
      end

      it "does not throw an error for case senstive name mismatches" do
        _checkout = FactoryGirl.build(:affirm_checkout, full_name_case_mismatch: true)
        _checkout.check_matching_billing_address
        expect(_checkout.errors.size).to be(0)

      end
    end

    context "with an extra product is in the checkout details" do
      it "sets an error on line_items" do
        _checkout = FactoryGirl.build(:affirm_checkout, extra_line_item: true )
        _checkout.check_valid_products
        expect(_checkout.errors[:line_items]).to_not be_empty
      end
    end

    context "with the checkout details are missing a product" do
      it "sets an error on line_items" do
        _checkout = FactoryGirl.build(:affirm_checkout, missing_line_item: true )
        _checkout.check_valid_products
        expect(_checkout.errors[:line_items]).to_not be_empty
      end
    end

    context "with a line item has mismatched quantity" do
      it "sets an error for the item" do
        _checkout = FactoryGirl.build(:affirm_checkout, quantity_mismatch: true )
        _checkout.check_valid_products
        expect(_checkout.errors.size).to be(1)
      end
    end

    context "with a line item has mismatched price" do
      it "sets an error for the item" do
        _checkout = FactoryGirl.build(:affirm_checkout, price_mismatch: true )
        _checkout.check_valid_products
        expect(_checkout.errors.size).to be(1)
      end
    end

  end

  describe "#check_matching_billing_address" do
    context "with a matching billing address" do
      it "does not set any errors for the billing_address" do
        valid_checkout.check_matching_billing_address
        expect(valid_checkout.errors.size).to be(0)
        expect(valid_checkout.errors[:billing_address]).to be_empty
      end

      context "with alternate address format" do
        it "does not set any errors for the billing_address" do
          _checkout = FactoryGirl.build(:affirm_checkout, alternate_billing_address_format: true)
          valid_checkout.check_matching_billing_address
          expect(valid_checkout.errors.size).to be(0)
          expect(valid_checkout.errors[:billing_address]).to be_empty
        end
      end

      context "with a name.full instead of first/last" do
        it "does not set any error for the billing_address" do
          _checkout = FactoryGirl.build(:affirm_checkout, billing_address_full_name: true)
          _checkout.check_matching_billing_address
          expect(_checkout.errors[:billing_address]).to be_empty
        end
      end
    end

    context "with a mismtached billing address" do
      it "sets an error for the billing_address" do
        _checkout = FactoryGirl.build(:affirm_checkout, billing_address_mismatch: true)
        _checkout.check_matching_billing_address
        expect(_checkout.errors[:billing_address]).not_to be_empty
      end

      context "with alternate address format" do
        it "sets an error for the billing_address" do
          _checkout = FactoryGirl.build(:affirm_checkout, billing_address_mismatch: true, alternate_billing_address_format: true)
          _checkout.check_matching_billing_address
          expect(_checkout.errors[:billing_address]).not_to be_empty
        end
      end

      context "with a name.full instead of first/last" do
        it "sets an error for the billing_address" do
          _checkout = FactoryGirl.build(:affirm_checkout, billing_address_mismatch: true, billing_address_full_name: true)
          _checkout.check_matching_billing_address
          expect(_checkout.errors[:billing_address]).not_to be_empty
        end
      end
    end
  end

  describe "#check_matching_shipping_address" do
    context "with a matching shipping address" do
      it "does not set an error for the shipping_address" do
        valid_checkout.check_matching_shipping_address
        expect(valid_checkout.errors[:shipping_address]).to be_empty
      end
    end

    context "with a mismatched shipping address" do
      it "adds an error for the shipping_address" do
        _checkout = FactoryGirl.build(:affirm_checkout, shipping_address_mismatch: true)
        _checkout.check_matching_shipping_address
        expect(_checkout.errors[:shipping_address]).not_to be_empty
      end
    end
  end

  describe "#check_matching_billing_email" do
    context "with a matching billing email" do
      it "does not set an error for the billing_email" do
        valid_checkout.check_matching_billing_email
        expect(valid_checkout.errors[:billing_email]).to be_empty
      end
    end

    context "with a mismatched billing email" do
      it "adds an error for billing_email" do
        _checkout = FactoryGirl.build(:affirm_checkout, billing_email_mismatch: true)
        _checkout.check_matching_billing_email
        expect(_checkout.errors[:billing_email]).not_to be_empty
      end
    end
  end

  describe "check_matching_product_key" do
    context "with a matching product key" do
      it "does not set an error for the financial_product_key" do
        valid_checkout.check_matching_product_key
        expect(valid_checkout.errors[:financial_product_key]).to be_empty
      end
    end

    context "with a mistmatched product key" do
      it "adds an error for financial_product_key" do
        _checkout = FactoryGirl.build(:affirm_checkout, product_key_mismatch: true)
        _checkout.check_matching_product_key
        expect(_checkout.errors[:financial_product_key]).not_to be_empty
      end
    end
  end

  describe "actions" do

    describe "#actions" do
      it "returns capture, void, and credit" do
        expect(valid_checkout.actions).to eq(['capture', 'void', 'credit'])
      end
    end

    describe "can_capture?" do
      context "with a payment response code set" do
        before(:each) { affirm_payment.response_code = "1234-1234" }

        context "with a payment in pending state" do
          before(:each) { affirm_payment.state = 'pending' }

          it "returns true" do
            expect(valid_checkout.can_capture?(affirm_payment)).to be(true)
          end
        end

        context "with a payment in checkout state" do
          before(:each) { affirm_payment.state = 'checkout' }

          it "returns true" do
            expect(valid_checkout.can_capture?(affirm_payment)).to be(true)
          end
        end

        context "with a payment in complete state" do
          before(:each) { affirm_payment.state = 'complete' }

          it "returns false" do
            expect(valid_checkout.can_capture?(affirm_payment)).to be(false)
          end
        end

      end

      context "with no response code set on the payment" do
        before(:each) { affirm_payment.response_code = nil }

        it "returns false" do
          expect(valid_checkout.can_capture?(affirm_payment)).to be(false)
        end
      end
    end

    describe "can_void?" do
      context "with a payment response code set" do
        before(:each) { affirm_payment.response_code = "1234-1234" }

        context "with a payment in pending state" do
          before(:each) { affirm_payment.state = 'pending' }

          it "returns true" do
            expect(valid_checkout.can_void?(affirm_payment)).to be(true)
          end
        end

        context "with a payment in checkout state" do
          before(:each) { affirm_payment.state = 'checkout' }

          it "returns false" do
            expect(valid_checkout.can_void?(affirm_payment)).to be(false)
          end
        end

        context "with a payment in complete state" do
          before(:each) { affirm_payment.state = 'complete' }

          it "returns false" do
            expect(valid_checkout.can_void?(affirm_payment)).to be(false)
          end
        end
      end

      context "with no response code set on the payment" do
        before(:each) { affirm_payment.response_code = nil }

        it "returns false" do
          expect(valid_checkout.can_void?(affirm_payment)).to be(false)
        end
      end
    end

    describe "can_credit?" do
      context "when the payment has not been completed" do
        before(:each) { affirm_payment.state = 'pending' }

        it "returns false" do
          expect(valid_checkout.can_credit?(affirm_payment)).to be(false)
        end
      end

      context "when the payment's order state is not 'credit_owed'" do
        before(:each) do
          affirm_payment.state = 'completed'
          affirm_payment.order.payment_state = 'completed'
        end

        it "returns false" do
          expect(valid_checkout.can_credit?(affirm_payment)).to be(false)
        end
      end

      context "when the payement's order state is 'credit_owed'" do
        before(:each) { affirm_payment.order.payment_state = 'credit_owed' }

        context "when the payment has been completed" do
          before(:each) { affirm_payment.state = 'completed'}

          context "when the payment credit_allowed is greater than 0" do
            before(:each) do
              affirm_payment.stub(:credit_allowed).and_return 100
            end

            it "returns true" do
              expect(valid_checkout.can_credit?(affirm_payment)).to be(true)
            end
          end

          context "when the payment credit_allowed is equal to 0" do
            before(:each) do
              affirm_payment.stub(:credit_allowed).and_return 0
            end

            it "returns false" do
              expect(valid_checkout.can_credit?(affirm_payment)).to be(false)
            end
          end
        end
      end

    end
  end
end


text:
package com.sg.model.sgdsRs.writeback;

import java.util.HashMap;
import java.util.Map;
import javax.annotation.Generated;
import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonSerialize;

@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@Generated("org.jsonschema2pojo")
@JsonPropertyOrder({
    "Msg",
    "Result",
    "Status"
})
public class WritebackStatusRs {

    @JsonProperty("Msg")
    private String msg;
    @JsonProperty("Result")
    private Integer result;
    @JsonProperty("Status")
    private Integer status;
    @JsonIgnore
    private Map<String, Object> additionalProperties = new HashMap<String, Object>();

    /**
     *
     * @return
     *     The msg
     */
    @JsonProperty("Msg")
    public String getMsg() {
        return msg;
    }

    /**
     *
     * @param msg
     *     The Msg
     */
    @JsonProperty("Msg")
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     *
     * @return
     *     The result
     */
    @JsonProperty("Result")
    public Integer getResult() {
        return result;
    }

    /**
     *
     * @param result
     *     The Result
     */
    @JsonProperty("Result")
    public void setResult(Integer result) {
        this.result = result;
    }

    /**
     *
     * @return
     *     The status
     */
    @JsonProperty("Status")
    public Integer getStatus() {
        return status;
    }

    /**
     *
     * @param status
     *     The Status
     */
    @JsonProperty("Status")
    public void setStatus(Integer status) {
        this.status = status;
    }

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(String name, Object value) {
        this.additionalProperties.put(name, value);
    }

}

redpajama_set_name: RedPajamaGithub


text:
using System.IO;
using System.Reflection;

namespace ESRI.ArcLogistics.Utility
{
    /// <summary>
    /// Helper for loading resources.
    /// </summary>
    internal static class ResourceLoader
    {
        #region internal static methods

        /// <summary>
        /// Load resource file as a string.
        /// </summary>
        /// <param name="filename">File name with extension.</param>
        /// <returns>File content as string.</returns>
        internal static string ReadFileAsString(string filename)
        {
            Assembly currentAssembly = Assembly.GetExecutingAssembly();
            Stream resource = currentAssembly.GetManifestResourceStream(RESOURCES_PATH + filename);
            return new StreamReader(resource).ReadToEnd();
        }

        #endregion

        #region private constants

        /// <summary>
        /// Path to the folder with resource files.
        /// </summary>
        private const string RESOURCES_PATH = @"ESRI.ArcLogistics.Resources.";

        #endregion
    }
}


text:
using MyNetworkLibrary;
using System;

namespace CardGameMessages
{
    [Serializable]
    public class PlayerNameMessage : Message
    {
        public string PlayerName;
    }
}


text:
/**
 * Screen Test Template By => create-module script
 * @version 1.0.0
 *
 */

import React from 'react';
import { shallow } from 'enzyme';
import {
  Screen,
  Header,
  Page,
  CardList,
} from 'ui';
import Home from 'screens/home/Home';

describe('test/app/screens/home/Home.test.js', () => {
  const props = {
    Screen,
    Header,
    Page,
    CardList,
    cards: [{ id: 1 }, { id: 2 }],
    fetchPublications: jest.fn(),
  };

  it('Render', () => {
    const wrapper = shallow(<Home {...props} />);
    expect(wrapper).toMatchSnapshot();
  });
});


text:
import * as React from 'react';
import { OverridableStringUnion } from '@material-ui/types';
import { OverridableComponent, OverrideProps } from '@material-ui/core/OverridableComponent';
import { SxProps } from '@material-ui/system';
import { Theme } from '../styles';
import { UsePaginationItem } from '../usePagination/usePagination';
import { PaginationItemClasses } from './paginationItemClasses';

export interface PaginationItemPropsVariantOverrides {}

export interface PaginationItemPropsSizeOverrides {}

export interface PaginationItemPropsColorOverrides {}

export interface PaginationItemTypeMap<P = {}, D extends React.ElementType = 'div'> {
  props: P & {
    /**
     * Override or extend the styles applied to the component.
     */
    classes?: Partial<PaginationItemClasses>;
    /**
     * The active color.
     * @default 'standard'
     */
    color?: OverridableStringUnion<
      'standard' | 'primary' | 'secondary',
      PaginationItemPropsColorOverrides
    >;
    /**
     * If `true`, the component is disabled.
     * @default false
     */
    disabled?: boolean;
    /**
     * The current page number.
     */
    page?: React.ReactNode;
    /**
     * If `true` the pagination item is selected.
     * @default false
     */
    selected?: boolean;
    /**
     * The shape of the pagination item.
     * @default 'circular'
     */
    shape?: 'circular' | 'rounded';
    /**
     * The size of the component.
     * @default 'medium'
     */
    size?: OverridableStringUnion<'small' | 'medium' | 'large', PaginationItemPropsSizeOverrides>;
    /**
     * The system prop that allows defining system overrides as well as additional CSS styles.
     */
    sx?: SxProps<Theme>;
    /**
     * The type of pagination item.
     * @default 'page'
     */
    type?: UsePaginationItem['type'];
    /**
     * The variant to use.
     * @default 'text'
     */
    variant?: OverridableStringUnion<'text' | 'outlined', PaginationItemPropsVariantOverrides>;
  };
  defaultComponent: D;
}

/**
 *
 * Demos:
 *
 * - [Pagination](https://material-ui.com/components/pagination/)
 *
 * API:
 *
 * - [PaginationItem API](https://material-ui.com/api/pagination-item/)
 */
declare const PaginationItem: OverridableComponent<PaginationItemTypeMap>;

export type PaginationItemProps<
  D extends React.ElementType = PaginationItemTypeMap['defaultComponent'],
  P = {}
> = OverrideProps<PaginationItemTypeMap<P, D>, D>;

export default PaginationItem;


text:
module.exports = function http_build_query (formdata, numericPrefix, argSeparator, encType) { // eslint-disable-line camelcase
  //  discuss at: https://locutus.io/php/http_build_query/
  // original by: Kevin van Zonneveld (https://kvz.io)
  // improved by: Legaev Andrey
  // improved by: Michael White (https://getsprink.com)
  // improved by: Kevin van Zonneveld (https://kvz.io)
  // improved by: Brett Zamir (https://brett-zamir.me)
  //  revised by: stag019
  //    input by: Dreamer
  // bugfixed by: Brett Zamir (https://brett-zamir.me)
  // bugfixed by: MIO_KODUKI (https://mio-koduki.blogspot.com/)
  // improved by: Will Rowe
  //      note 1: If the value is null, key and value are skipped in the
  //      note 1: http_build_query of PHP while in locutus they are not.
  //   example 1: http_build_query({foo: 'bar', php: 'hypertext processor', baz: 'boom', cow: 'milk'}, '', '&')
  //   returns 1: 'foo=bar&php=hypertext+processor&baz=boom&cow=milk'
  //   example 2: http_build_query({'php': 'hypertext processor', 0: 'foo', 1: 'bar', 2: 'baz', 3: 'boom', 'cow': 'milk'}, 'myvar_')
  //   returns 2: 'myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&php=hypertext+processor&cow=milk'
  //   example 3: http_build_query({foo: 'bar', php: 'hypertext processor', baz: 'boom', cow: 'milk'}, '', '&', 'PHP_QUERY_RFC3986')
  //   returns 3: 'foo=bar&php=hypertext%20processor&baz=boom&cow=milk'

  var encodeFunc

  switch (encType) {
    case 'PHP_QUERY_RFC3986':
      encodeFunc = require('../url/rawurlencode')
      break

    case 'PHP_QUERY_RFC1738':
    default:
      encodeFunc = require('../url/urlencode')
      break
  }

  var value
  var key
  var tmp = []

  var _httpBuildQueryHelper = function (key, val, argSeparator) {
    var k
    var tmp = []
    if (val === true) {
      val = '1'
    } else if (val === false) {
      val = '0'
    }
    if (val !== null) {
      if (typeof val === 'object') {
        for (k in val) {
          if (val[k] !== null) {
            tmp.push(_httpBuildQueryHelper(key + '[' + k + ']', val[k], argSeparator))
          }
        }
        return tmp.join(argSeparator)
      } else if (typeof val !== 'function') {
        return encodeFunc(key) + '=' + encodeFunc(val)
      } else {
        throw new Error('There was an error processing for http_build_query().')
      }
    } else {
      return ''
    }
  }

  if (!argSeparator) {
    argSeparator = '&'
  }
  for (key in formdata) {
    value = formdata[key]
    if (numericPrefix && !isNaN(key)) {
      key = String(numericPrefix) + key
    }
    var query = _httpBuildQueryHelper(key, value, argSeparator)
    if (query !== '') {
      tmp.push(query)
    }
  }

  return tmp.join(argSeparator)
}


text:
require 'spec_helper_min'
require 'mock_redis'

describe Carto::Api::VizJSON3Presenter do
  include Carto::Factories::Visualizations
  include_context 'visualization creation helpers'

  before(:all) do
    @user_1 = FactoryGirl.create(:carto_user, private_tables_enabled: false)
  end

  after(:all) do
    @user_1.destroy
  end

  let(:redis_mock) do
    MockRedis.new
  end

  shared_context 'full visualization' do
    before(:all) do
      @map, @table, @table_visualization, @visualization = create_full_visualization(Carto::User.find(@user_1.id))
    end

    after(:all) do
      destroy_full_visualization(@map, @table, @table_visualization, @visualization)
    end

    let(:viewer_user) { @visualization.user }
  end

  describe 'caching' do
    include_context 'full visualization'

    let(:fake_vizjson) { { fake: 'sure!', layers: [] } }

    it 'to_vizjson uses the redis vizjson cache' do
      cache_mock = mock
      cache_mock.expects(:cached).with(@visualization.id, false, 3).twice.returns(fake_vizjson)
      presenter = Carto::Api::VizJSON3Presenter.new(@visualization, cache_mock)
      v1 = presenter.to_vizjson
      v2 = presenter.to_vizjson
      v1.should eq fake_vizjson
      v1.should eq v2
    end

    it 'every call to_vizjson uses calculate_vizjson if no cache is provided' do
      presenter = Carto::Api::VizJSON3Presenter.new(@visualization, nil)
      presenter.expects(:calculate_vizjson).twice.returns(fake_vizjson)
      presenter.to_vizjson
      presenter.to_vizjson
    end

    it 'to_vizjson is not overriden by v2 caching or to_named_map_vizjson' do
      v2_presenter = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata)
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization)

      v2_vizjson = v2_presenter.to_vizjson
      v3_vizjson = v3_presenter.to_vizjson
      v3n_vizjson = v3_presenter.to_named_map_vizjson

      v3_vizjson.should_not eq v2_vizjson
      v2_vizjson[:version].should eq '0.1.0'
      v3_vizjson[:version].should eq '3.0.0'
      v3n_vizjson[:version].should eq '3.0.0'
    end

    it 'to_vizjson does not override v2 caching or named map vizjson' do
      v2_presenter = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata)
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization)

      v3_vizjson = v3_presenter.to_vizjson
      v2_vizjson = v2_presenter.to_vizjson
      v3n_vizjson = v3_presenter.to_named_map_vizjson

      v2_vizjson.should_not eq v3_vizjson
      v3n_vizjson.should_not eq v3_vizjson
      v2_vizjson[:version].should eq '0.1.0'
      v3_vizjson[:version].should eq '3.0.0'
      v3n_vizjson[:version].should eq '3.0.0'
    end

    it 'to_vizjson does not cache vector' do
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization)
      vizjson_a = v3_presenter.to_vizjson(vector: true)
      vizjson_b = v3_presenter.to_vizjson(vector: false)
      vizjson_a[:vector].should eq true
      vizjson_b[:vector].should eq false
    end

    it 'to_named_map_vizjson uses the redis vizjson cache' do
      fake_vizjson = { fake: 'sure!', layers: [] }

      cache_mock = mock
      cache_mock.expects(:cached).with(@visualization.id, false, anything).returns(fake_vizjson).twice
      presenter = Carto::Api::VizJSON3Presenter.new(@visualization, cache_mock)
      v1 = presenter.to_named_map_vizjson
      v2 = presenter.to_named_map_vizjson
      v1.should eq fake_vizjson
      v1.should eq v2
    end

    it 'to_named_map_vizjson does not cache vector' do
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization)
      vizjson_a = v3_presenter.to_named_map_vizjson(vector: true)
      vizjson_b = v3_presenter.to_named_map_vizjson(vector: false)
      vizjson_a[:vector].should eq true
      vizjson_b[:vector].should eq false
    end
  end

  describe '#to_named_map_vizjson' do
    include_context 'full visualization'

    it 'generates the vizjson of visualizations that have not named map as if they had' do
      @table.privacy = Carto::UserTable::PRIVACY_PUBLIC
      @table.save
      @visualization = Carto::Visualization.find(@visualization.id)
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization, nil)

      original_vizjson = v3_presenter.to_vizjson.reject { |k, _| k == :updated_at }
      original_named_vizjson = v3_presenter.to_named_map_vizjson.reject { |k, _| k == :updated_at }
      original_vizjson.should_not eq original_named_vizjson

      @table.privacy = Carto::UserTable::PRIVACY_PRIVATE
      @table.save
      @visualization = Carto::Visualization.find(@visualization.id)
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization, nil)

      named_vizjson = v3_presenter.to_vizjson.reject { |k, _| k == :updated_at }
      original_named_vizjson.should eq named_vizjson
      named_named_vizjson = v3_presenter.to_vizjson.reject { |k, _| k == :updated_at }
      named_named_vizjson.should eq named_vizjson
    end

    it 'includes analyses information without including sources parameters' do
      analysis = FactoryGirl.create(:analysis_with_source, visualization: @visualization, user: @user_1)
      analysis.analysis_definition[:params].should_not be_nil
      @visualization.reload
      v3_presenter = Carto::Api::VizJSON3Presenter.new(@visualization, nil)
      named_vizjson = v3_presenter.to_vizjson
      analyses_json = named_vizjson[:analyses]
      analyses_json.should_not be_nil
      source_analysis_definition = analyses_json[0][:params][:source]
      source_analysis_definition[:type].should eq 'source'
      source_analysis_definition[:params].should be_nil
    end

    it 'includes source at layers options' do
      source = 'a1'
      layer = @visualization.data_layers.first
      layer.options['source'] = source
      layer.save
      @table.privacy = Carto::UserTable::PRIVACY_PRIVATE
      @table.save
      @visualization.reload

      v3_vizjson = Carto::Api::VizJSON3Presenter.new(@visualization, viewer_user).send :calculate_vizjson
      v3_vizjson[:layers][1][:options][:named_map][:layers][0][:options].should eq source: source
    end
  end

  describe 'analyses' do
    include_context 'full visualization'

    it 'sends `source` at layer options instead of sql if source is set for named maps' do
      query = "select * from #{@table.name}"

      layer = @visualization.data_layers.first
      layer.options['source'].should eq nil
      layer.options['query'] = query
      layer.save

      # INFO: send :calculate_vizjson won't use cache
      v2_vizjson = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata).send(:calculate_vizjson)
      nm_vizjson = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata).send(:calculate_vizjson, for_named_map: true)
      v3_vizjson = Carto::Api::VizJSON3Presenter.new(@visualization, viewer_user).send(:calculate_vizjson)

      v2_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should eq query
      v2_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should be_nil
      nm_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should eq query
      nm_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should be_nil
      v3_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should eq query
      v3_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should be_nil

      source = 'a1'
      layer.options['source'] = source
      layer.save
      @visualization.reload

      v2_vizjson = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata).send(:calculate_vizjson)
      nm_vizjson = Carto::Api::VizJSONPresenter.new(@visualization, $tables_metadata).send(:calculate_vizjson, for_named_map: true)
      v3_vizjson = Carto::Api::VizJSON3Presenter.new(@visualization, viewer_user).send(:calculate_vizjson)

      v2_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should eq query
      v2_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should be_nil
      nm_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should be_nil
      nm_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should eq(id: source)
      v3_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql].should be_nil
      v3_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:source].should eq source
    end
end
  describe 'anonyous_vizjson' do
    include_context 'full visualization'

    it 'v3 should include sql_wrap' do
      v3_vizjson = Carto::Api::VizJSON3Presenter.new(@visualization, viewer_user).send :calculate_vizjson
      v3_vizjson[:layers][1][:options][:layer_definition][:layers][0][:options][:sql_wrap].should eq "select * from (<%= sql %>) __wrap"
    end
  end

end


text:
2D Image processing for chess board in computer screen.

## [Source Code](https://github.com/mhusam/ChessBot/)

## Installation Guide
[![Installation Guide in Youtube](http://img.youtube.com/vi/Voih6Vj07HY/0.jpg)](https://youtu.be/Voih6Vj07HY)


text:
package net.floodlightcontroller.flowcache;

import org.projectfloodlight.openflow.types.MacAddress;

/**
 * The Class for FlowReconcileQuery for link down event.
 */
@Deprecated
public class FRQueryBvsMatchMac extends FlowReconcileQuery {
    /*the match mac*/
    public String mac;

    public FRQueryBvsMatchMac() {
        super(ReconcileQueryEvType.BVS_INTERFACE_RULE_CHANGED_MATCH_MAC);
    }

    public FRQueryBvsMatchMac(String mac) {
        this();
        this.mac = mac;
    }

    @Override
    public int hashCode() {
        final int prime = 347;
        int result = super.hashCode();
        result = prime * result + mac.hashCode();
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (!(obj instanceof FRQueryBvsMatchMac)) {
            return false;
        }
        FRQueryBvsMatchMac other = (FRQueryBvsMatchMac) obj;
        if (! mac.equals(other.mac)) return false;
        return true;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("[");
        builder.append("MAC: ");
        builder.append(MacAddress.of(mac).toString());
        builder.append("]");
        return builder.toString();
    }
}


text:
require 'rails'
require "roar"
require "roar-rails"
require 'rest_client'
require 'rack/cors'
require "ka_mod_users/version"
require "ka_mod_users/engine"
require "ka_mod_users/facebook.rb"
require "ka_mod_users/version_constraints.rb"

module KaModUsers
end


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">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Kanscience</title>

    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <link href="css/clean-blog.css" rel="stylesheet">

    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Architects+Daughter:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

Kanscience

                        Speaks the soul

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

        </button>

Home

Blog

Art

About

Contact

                          Deeper

                          Your glassy surface

Posted on December 14, 2016

                          Asian Roots

                          Red folds of wedding dress

Posted on November 12, 2016

                          Eat in Peace or Pieces

                          Pass the butter, hand the bread

Posted on October 28, 2016

                        Newer Posts →


text:
#include "as.h"
#include "dwarf2dbg.h"
#include "subsegs.h"
#include "symcat.h"
#include "opcodes/mt-desc.h"
#include "opcodes/mt-opc.h"
#include "cgen.h"
#include "elf/common.h"
#include "elf/mt.h"
#include "libbfd.h"

/* Structure to hold all of the different components
   describing an individual instruction.  */
typedef struct
{
  const CGEN_INSN *	insn;
  const CGEN_INSN *	orig_insn;
  CGEN_FIELDS		fields;
#if CGEN_INT_INSN_P
  CGEN_INSN_INT         buffer [1];
#define INSN_VALUE(buf) (*(buf))
#else
  unsigned char         buffer [CGEN_MAX_INSN_SIZE];
#define INSN_VALUE(buf) (buf)
#endif
  char *		addr;
  fragS *		frag;
  int                   num_fixups;
  fixS *                fixups [GAS_CGEN_MAX_FIXUPS];
  int                   indices [MAX_OPERAND_INSTANCES];
}
mt_insn;

const char comment_chars[]        = ";";
const char line_comment_chars[]   = "#";
const char line_separator_chars[] = "";
const char EXP_CHARS[]            = "eE";
const char FLT_CHARS[]            = "dD";

/* The target specific pseudo-ops which we support.  */
const pseudo_typeS md_pseudo_table[] =
{
    { "word",   cons,                   4 },
    { NULL, 	NULL,			0 }
};

static int no_scheduling_restrictions = 0;

struct option md_longopts[] =
{
#define OPTION_NO_SCHED_REST	(OPTION_MD_BASE)
  { "nosched",	   no_argument, NULL, OPTION_NO_SCHED_REST },
#define OPTION_MARCH		(OPTION_MD_BASE + 1)
  { "march", required_argument, NULL, OPTION_MARCH},
  { NULL,	   no_argument, NULL, 0 },
};
size_t md_longopts_size = sizeof (md_longopts);

const char * md_shortopts = "";

/* Mach selected from command line.  */
static int mt_mach = bfd_mach_ms1;
static unsigned mt_mach_bitmask = 1 << MACH_MS1;

/* Flags to set in the elf header */
static flagword mt_flags = EF_MT_CPU_MRISC;

/* The architecture to use.  */
enum mt_architectures
  {
    ms1_64_001,
    ms1_16_002,
    ms1_16_003,
    ms2
  };

/* MT architecture we are using for this output file.  */
static enum mt_architectures mt_arch = ms1_16_002;

int
md_parse_option (int c ATTRIBUTE_UNUSED, char * arg)
{
  switch (c)
    {
    case OPTION_MARCH:
      if (strcmp (arg, "ms1-64-001") == 0)
 	{
 	  mt_flags = (mt_flags & ~EF_MT_CPU_MASK) | EF_MT_CPU_MRISC;
 	  mt_mach = bfd_mach_ms1;
 	  mt_mach_bitmask = 1 << MACH_MS1;
 	  mt_arch = ms1_64_001;
 	}
      else if (strcmp (arg, "ms1-16-002") == 0)
 	{
 	  mt_flags = (mt_flags & ~EF_MT_CPU_MASK) | EF_MT_CPU_MRISC;
 	  mt_mach = bfd_mach_ms1;
 	  mt_mach_bitmask = 1 << MACH_MS1;
 	  mt_arch = ms1_16_002;
 	}
      else if (strcmp (arg, "ms1-16-003") == 0)
 	{
 	  mt_flags = (mt_flags & ~EF_MT_CPU_MASK) | EF_MT_CPU_MRISC2;
 	  mt_mach = bfd_mach_mrisc2;
 	  mt_mach_bitmask = 1 << MACH_MS1_003;
 	  mt_arch = ms1_16_003;
 	}
      else if (strcmp (arg, "ms2") == 0)
 	{
 	  mt_flags = (mt_flags & ~EF_MT_CPU_MASK) | EF_MT_CPU_MS2;
 	  mt_mach = bfd_mach_mrisc2;
 	  mt_mach_bitmask = 1 << MACH_MS2;
 	  mt_arch = ms2;
 	}
    case OPTION_NO_SCHED_REST:
      no_scheduling_restrictions = 1;
      break;
    default:
      return 0;
    }

  return 1;
}

void
md_show_usage (FILE * stream)
{
  fprintf (stream, _("MT specific command line options:\n"));
  fprintf (stream, _("  -march=ms1-64-001         allow ms1-64-001 instructions\n"));
  fprintf (stream, _("  -march=ms1-16-002         allow ms1-16-002 instructions (default)\n"));
  fprintf (stream, _("  -march=ms1-16-003         allow ms1-16-003 instructions\n"));
  fprintf (stream, _("  -march=ms2                allow ms2 instructions \n"));
  fprintf (stream, _("  -nosched                  disable scheduling restrictions\n"));
}

void
md_begin (void)
{
  /* Initialize the `cgen' interface.  */

  /* Set the machine number and endian.  */
  gas_cgen_cpu_desc = mt_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, mt_mach_bitmask,
					CGEN_CPU_OPEN_ENDIAN,
					CGEN_ENDIAN_BIG,
					CGEN_CPU_OPEN_END);
  mt_cgen_init_asm (gas_cgen_cpu_desc);

  /* This is a callback from cgen to gas to parse operands.  */
  cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand);

  /* Set the ELF flags if desired. */
  if (mt_flags)
    bfd_set_private_flags (stdoutput, mt_flags);

  /* Set the machine type.  */
  bfd_default_set_arch_mach (stdoutput, bfd_arch_mt, mt_mach);
}

void
md_assemble (char * str)
{
  static long delayed_load_register = 0;
  static long prev_delayed_load_register = 0;
  static int last_insn_had_delay_slot = 0;
  static int last_insn_in_noncond_delay_slot = 0;
  static int last_insn_has_load_delay = 0;
  static int last_insn_was_memory_access = 0;
  static int last_insn_was_io_insn = 0;
  static int last_insn_was_arithmetic_or_logic = 0;
  static int last_insn_was_branch_insn = 0;
  static int last_insn_was_conditional_branch_insn = 0;

  mt_insn insn;
  char * errmsg;

  /* Initialize GAS's cgen interface for a new instruction.  */
  gas_cgen_init_parse ();

  insn.insn = mt_cgen_assemble_insn
      (gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg);

  if (!insn.insn)
    {
      as_bad ("%s", errmsg);
      return;
    }

  /* Doesn't really matter what we pass for RELAX_P here.  */
  gas_cgen_finish_insn (insn.insn, insn.buffer,
			CGEN_FIELDS_BITSIZE (& insn.fields), 1, NULL);

  /* Handle Scheduling Restrictions.  */
  if (!no_scheduling_restrictions)
    {
      /* Detect consecutive Memory Accesses.  */
      if (last_insn_was_memory_access
	  && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_MEMORY_ACCESS)
	  && mt_mach == ms1_64_001)
	as_warn (_("instruction %s may not follow another memory access instruction."),
		 CGEN_INSN_NAME (insn.insn));

      /* Detect consecutive I/O Instructions.  */
      else if (last_insn_was_io_insn
	       && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_IO_INSN))
	as_warn (_("instruction %s may not follow another I/O instruction."),
		 CGEN_INSN_NAME (insn.insn));

      /* Detect consecutive branch instructions.  */
      else if (last_insn_was_branch_insn
	       && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_BR_INSN))
	as_warn (_("%s may not occupy the delay slot of another branch insn."),
		 CGEN_INSN_NAME (insn.insn));

      /* Detect data dependencies on delayed loads: memory and input insns.  */
      if (last_insn_has_load_delay && delayed_load_register)
	{
	  if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR1)
	      && insn.fields.f_sr1 == delayed_load_register)
	    as_warn (_("operand references R%ld of previous load."),
		     insn.fields.f_sr1);

	  if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR2)
	      && insn.fields.f_sr2 == delayed_load_register)
	    as_warn (_("operand references R%ld of previous load."),
		     insn.fields.f_sr2);
	}

      /* Detect JAL/RETI hazard */
      if (mt_mach == ms2
	  && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_JAL_HAZARD))
	{
	  if ((CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR1)
	       && insn.fields.f_sr1 == delayed_load_register)
	      || (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR2)
		  && insn.fields.f_sr2 == delayed_load_register))
	    as_warn (_("operand references R%ld of previous instrutcion."),
		     delayed_load_register);
	  else if ((CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR1)
		    && insn.fields.f_sr1 == prev_delayed_load_register)
		   || (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR2)
		       && insn.fields.f_sr2 == prev_delayed_load_register))
	    as_warn (_("operand references R%ld of instructcion before previous."),
		     prev_delayed_load_register);
	}

      /* Detect data dependency between conditional branch instruction
         and an immediately preceding arithmetic or logical instruction.  */
      if (last_insn_was_arithmetic_or_logic
	  && !last_insn_in_noncond_delay_slot
	  && (delayed_load_register != 0)
	  && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_BR_INSN)
	  && mt_arch == ms1_64_001)
	{
	  if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR1)
	      && insn.fields.f_sr1 == delayed_load_register)
	    as_warn (_("conditional branch or jal insn's operand references R%ld of previous arithmetic or logic insn."),
		     insn.fields.f_sr1);

	  if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR2)
	      && insn.fields.f_sr2 == delayed_load_register)
	    as_warn (_("conditional branch or jal insn's operand references R%ld of previous arithmetic or logic insn."),
		     insn.fields.f_sr2);
	}
    }

  /* Keep track of details of this insn for processing next insn.  */
  last_insn_in_noncond_delay_slot = last_insn_was_branch_insn
    && !last_insn_was_conditional_branch_insn;

  last_insn_had_delay_slot =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_DELAY_SLOT);
  (void) last_insn_had_delay_slot;

  last_insn_has_load_delay =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_LOAD_DELAY);

  last_insn_was_memory_access =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_MEMORY_ACCESS);

  last_insn_was_io_insn =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_IO_INSN);

  last_insn_was_arithmetic_or_logic =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_AL_INSN);

  last_insn_was_branch_insn =
    CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_BR_INSN);

  last_insn_was_conditional_branch_insn =
  CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_BR_INSN)
    && CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRSR2);

  prev_delayed_load_register = delayed_load_register;

  if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRDR))
     delayed_load_register = insn.fields.f_dr;
  else if (CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_USES_FRDRRR))
     delayed_load_register = insn.fields.f_drrr;
  else  /* Insns has no destination register.  */
     delayed_load_register = 0;

  /* Generate dwarf2 line numbers.  */
  dwarf2_emit_insn (4);
}

valueT
md_section_align (segT segment, valueT size)
{
  int align = bfd_get_section_alignment (stdoutput, segment);

  return ((size + (1 << align) - 1) & (-1 << align));
}

symbolS *
md_undefined_symbol (char * name ATTRIBUTE_UNUSED)
{
    return NULL;
}

int
md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED,
			       segT    segment ATTRIBUTE_UNUSED)
{
  as_fatal (_("md_estimate_size_before_relax\n"));
  return 1;
}

/* *fragP has been relaxed to its final size, and now needs to have
   the bytes inside it modified to conform to the new size.

   Called after relaxation is finished.
   fragP->fr_type == rs_machine_dependent.
   fragP->fr_subtype is the subtype of what the address relaxed to.  */

void
md_convert_frag (bfd   * abfd  ATTRIBUTE_UNUSED,
		 segT    sec   ATTRIBUTE_UNUSED,
		 fragS * fragP ATTRIBUTE_UNUSED)
{
}

/* Functions concerning relocs.  */

long
md_pcrel_from_section (fixS *fixP, segT sec)
{
  if (fixP->fx_addsy != (symbolS *) NULL
      && (!S_IS_DEFINED (fixP->fx_addsy)
	  || S_GET_SEGMENT (fixP->fx_addsy) != sec))
    /* The symbol is undefined (or is defined but not in this section).
       Let the linker figure it out.  */
    return 0;

  /* Return the address of the opcode - cgen adjusts for opcode size
     itself, to be consistent with the disassembler, which must do
     so.  */
  return fixP->fx_where + fixP->fx_frag->fr_address;
}

/* Return the bfd reloc type for OPERAND of INSN at fixup FIXP.
   Returns BFD_RELOC_NONE if no reloc type can be found.
   *FIXP may be modified if desired.  */

bfd_reloc_code_real_type
md_cgen_lookup_reloc (const CGEN_INSN *    insn     ATTRIBUTE_UNUSED,
		      const CGEN_OPERAND * operand,
		      fixS *               fixP     ATTRIBUTE_UNUSED)
{
  bfd_reloc_code_real_type result;

  result = BFD_RELOC_NONE;

  switch (operand->type)
    {
    case MT_OPERAND_IMM16O:
      result = BFD_RELOC_16_PCREL;
      fixP->fx_pcrel = 1;
      /* fixP->fx_no_overflow = 1; */
      break;
    case MT_OPERAND_IMM16:
    case MT_OPERAND_IMM16Z:
      /* These may have been processed at parse time.  */
      if (fixP->fx_cgen.opinfo != 0)
        result = fixP->fx_cgen.opinfo;
      fixP->fx_no_overflow = 1;
      break;
    case MT_OPERAND_LOOPSIZE:
      result = BFD_RELOC_MT_PCINSN8;
      fixP->fx_pcrel = 1;
      /* Adjust for the delay slot, which is not part of the loop  */
      fixP->fx_offset -= 8;
      break;
    default:
      result = BFD_RELOC_NONE;
      break;
    }

  return result;
}

/* Write a value out to the object file, using the appropriate endianness.  */

void
md_number_to_chars (char * buf, valueT val, int n)
{
  number_to_chars_bigendian (buf, val, n);
}

char *
md_atof (int type, char * litP, int * sizeP)
{
  return ieee_md_atof (type, litP, sizeP, FALSE);
}

/* See whether we need to force a relocation into the output file.  */

int
mt_force_relocation (fixS * fixp ATTRIBUTE_UNUSED)
{
  return 0;
}

void
mt_apply_fix (fixS *fixP, valueT *valueP, segT seg)
{
  if ((fixP->fx_pcrel != 0) && (fixP->fx_r_type == BFD_RELOC_32))
    fixP->fx_r_type = BFD_RELOC_32_PCREL;

  gas_cgen_md_apply_fix (fixP, valueP, seg);
}

bfd_boolean
mt_fix_adjustable (fixS * fixP)
{
  if ((int) fixP->fx_r_type >= (int) BFD_RELOC_UNUSED)
    {
      const CGEN_INSN *insn = NULL;
      int opindex = (int) fixP->fx_r_type - (int) BFD_RELOC_UNUSED;
      const CGEN_OPERAND *operand;

      operand = cgen_operand_lookup_by_num(gas_cgen_cpu_desc, opindex);
      md_cgen_lookup_reloc (insn, operand, fixP);
    }

  if (fixP->fx_addsy == NULL)
    return TRUE;

  /* Prevent all adjustments to global symbols.  */
  if (S_IS_EXTERNAL (fixP->fx_addsy))
    return FALSE;

  if (S_IS_WEAK (fixP->fx_addsy))
    return FALSE;

  return 1;
}


text:
module FSM
  module Options
    module InstanceMethods
      def assert_options(options, optional_keys = {}, mandatory_keys = {})
        keys_processed = []
        mandatory_keys.each do |key|
          raise ArgumentError.new("Mandatory Key #{key} is missing") unless options.keys.include?(key)
          keys_processed << key
        end
        options.keys.each do |key|
          raise ArgumentError.new("Unsupported key #{key}") unless optional_keys.include?(key) || mandatory_keys.include?(key)
        end
      end
    end
  end
end


text:
(function() {
  var EncodingNamespace;

  module.exports = EncodingNamespace = (function() {

    /**
     * Creates a new EncodingNamespace instance
     * @class
     * @property {object} typeCodes Type codes dictionary.
     * @return {EncodingNamespace} an EncodingNamespace instance.
     */
    function EncodingNamespace(fdb) {
      this.fdb = fdb;
      this.adapters = require('./adapters')(this);
    }

    /**
     * Encode value to buffer
     * @method
     * @param {string} [prefix] String identifier.
     * @param {(undefined|string|integer|double|boolean|null|date|array|object)} value Value to encode.
     * @return {Buffer} Buffer
     */

    EncodingNamespace.prototype.encode = function(value, prefix) {
      var TypedAdapter, adapter, startPos, typeCode;
      if (value === '\xff') {
        return value;
      }
      startPos = 1;
      typeCode = this.adapters.types.get(value);
      TypedAdapter = this.adapters.get(typeCode);
      if (prefix) {
        startPos += prefix.length;
        adapter = new TypedAdapter(value, startPos);
        adapter.data.write(prefix, 0, startPos, 'ascii');
      } else {
        adapter = new TypedAdapter(value, startPos);
      }
      adapter.data.writeUInt8(typeCode, startPos - 1);
      return adapter.data;
    };

    /**
     * Decode value from buffer
     * @method
     * @param {Buffer} buffer Buffer to decode.
     * @param {string} [prefix] String identifier.
     * @return {(undefined|string|integer|double|boolean|null|date|array|object)} Value
     */

    EncodingNamespace.prototype.decode = function(buffer, prefix) {
      var TypedAdapter, adapter, startPos, typeCode;
      if (!buffer) {
        return null;
      }
      startPos = 0;
      if (prefix) {
        if (buffer.toString('ascii', 0, prefix.length) === prefix) {
          startPos = prefix.length;
        } else {
          throw new Error("Invalid prefix \"" + prefix + "\".");
        }
      }
      typeCode = buffer.readUInt8(startPos);
      TypedAdapter = this.adapters.get(typeCode);
      adapter = new TypedAdapter(buffer, startPos + 1);
      return adapter.value;
    };

    return EncodingNamespace;

  })();

  module.exports = function(fdb) {
    return fdb.encoding = new EncodingNamespace(fdb);
  };

}).call(this);


text:
'use strict';
const Page = require( './page' );

class CreateAccountPage extends Page {

	get username() { return browser.element( '#wpName2' ); }
	get password() { return browser.element( '#wpPassword2' ); }
	get confirmPassword() { return browser.element( '#wpRetype' ); }
	get create() { return browser.element( '#wpCreateaccount' ); }
	get heading() { return browser.element( '#firstHeading' ); }

	open() {
		super.open( 'Special:CreateAccount' );
	}

	createAccount( username, password ) {
		this.open();
		this.username.setValue( username );
		this.password.setValue( password );
		this.confirmPassword.setValue( password );
		this.create.click();
	}

}
module.exports = new CreateAccountPage();