text:
package com.google.common.geometry.benchmarks;

import static com.google.common.geometry.S2Projections.PROJ;
import static com.google.common.geometry.TestDataGenerator.kmToAngle;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;

import com.google.common.geometry.PrimitiveArrays.Bytes;
import com.google.common.geometry.PrimitiveArrays.Cursor;
import com.google.common.geometry.S1Angle;
import com.google.common.geometry.S1ChordAngle;
import com.google.common.geometry.S2BestDistanceTarget;
import com.google.common.geometry.S2BestEdgesQueryBase;
import com.google.common.geometry.S2Cap;
import com.google.common.geometry.S2Cell;
import com.google.common.geometry.S2CellId;
import com.google.common.geometry.S2Point;
import com.google.common.geometry.S2Shape;
import com.google.common.geometry.S2Shape.MutableEdge;
import com.google.common.geometry.S2ShapeIndex;
import com.google.common.geometry.S2ShapeIndexCoder;
import com.google.common.geometry.S2ShapeUtil;
import com.google.common.geometry.S2ShapeUtil.S2EdgeVectorShape;
import com.google.common.geometry.TestDataGenerator;
import com.google.common.geometry.TestDataGenerator.ShapeFactory;
import com.google.common.geometry.VectorCoder;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.BenchmarkParams;

/**
 * Infrastructure that is common to S2FurthestEdgeQueryBenchmark and S2ClosestEdgeQueryBenchmark.
 */
public final class BestEdgesBenchmarkHarness {
  private BestEdgesBenchmarkHarness() {}

  /** Targets may be of the following types. */
  public enum TargetType {
    POINT,
    EDGE,
    CELL,
    INDEX;
  }

  /** Factories may be of the following types. */
  public enum FactoryType {
    FRACTAL_LOOP,
    REGULAR_LOOP,
    POINT_CLOUD;
  }

  /**
   * A container for an index, an closest or furthest edge query on that index, and a set of targets
   * to test with.
   */
  public abstract static class BestEdgeQueryWithTargets {
    // The index may be replaced with an EncodedS2ShapeIndex.
    public S2ShapeIndex index = new S2ShapeIndex();

    // The number of edges in 'index'. Stored here to avoid repeated counting.
    public int numIndexEdges;

    // The query built on the index.
    public abstract S2BestEdgesQueryBase<S1ChordAngle> query();

    // Targets to query against the index.
    public abstract ArrayList<? extends S2BestDistanceTarget<S1ChordAngle>> targets();

    // If the index is encoded, this is the list of shapes in it, which are encoded separately.
    public List<S2Shape> shapes;
  }

  /**
   * A base benchmark @State for measuring the performance of S2ClosestEdgeQuery.findClosestEdges()
   * and S2FurthestEdgeQuery.findFurthestEdges() under a variety of scenarios.
   *
   *
The setup() method builds NUM_INDEX_SAMPLES different S2ShapeIndexes, each with
   * approximately "numIndexEdges" edges generated by a specified factory. Each S2ShapeIndex
   * geometry is generated within an S2Cap of the radius specified by DEFAULT_INDEX_RADIUS_KM, the
   * "index radius".
   *
   *
A S2ClosestEdgeQuery or S2FurthestEdgeQuery is constructed for each of those S2ShapeIndexes,
   * with options set according to the parameters to setup(). If maxDistanceFraction > 0, then
   * maxDistance() is set to the given fraction of the index radius. If maxErrorFraction > 0, then
   * maxError() is set to the given fraction of the index radius.
   *
   *
For each query, NUM_TARGET_SAMPLES different targets will also be built, of the given {@code
   * TargetType}. If "targetType" is INDEX, then the target will have approximately "numTargetEdges"
   * edges. The query and its targets are stored in either a ClosestEdgeQueryWithTargets or
   * FurthestEdgeQueryWithTargets, built by the {@code S2EdgeQueryGenerator}, which generates the
   * geometry for the index and targets according to the parameters passed to it, some of which are
   * described above. See that class for explanation of the other parameters.
   */
  @State(Scope.Thread)
  @BenchmarkMode(Mode.AverageTime)
  @OutputTimeUnit(MICROSECONDS)
  @Warmup(iterations = 3, time = 5, timeUnit = SECONDS)
  @Measurement(iterations = 5, time = 5, timeUnit = SECONDS)
  public abstract static class BestEdgesBenchmarkBaseState extends S2BenchmarkBaseState {
    // Default radius for indexed geometry, 1000 km.
    protected static final double DEFAULT_INDEX_RADIUS_KM = 1000;

    // Several different random S2ShapeIndexes are built to run queries against. (Performance is
    // affected by how the shapes are positioned relative to the S2Cell hierarchy.)
    protected static final int DEFAULT_NUM_INDEX_SAMPLES = 8;

    // How many targets will be tested for each query index?
    protected static final int DEFAULT_NUM_TARGET_SAMPLES = 16;

    /**
     * Must be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Specifies the {@link
     * TestDataGenerator.ShapeIndexFactory} to use to generate the index geometry. The index
     * geometry is always bounded by a cap of size {@link indexRadiusKm}. No default is provided.
     */
    protected FactoryType factoryType = null;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. True if the index
     * should be encoded with S2ShapeIndexCoder. Defaults to false.
     */
    protected boolean encodeIndex = false;

    /**
     * Should be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. The approximate
     * number of edges to be added to the index. The actual value may depend on the FactoryType.
     */
    protected int numIndexEdges = 1024;

    /**
     * Should be set by benchmarks inheriting from BestEdgesBenchmarkBaseState unless only
     * findClosestEdge() / findFurthestEdge() is used in the benchmark. The number of results to
     * obtain.
     */
    protected int maxResults = 1;

    /**
     * Should be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Determines if
     * interiors of indexed polygons be considered when measuring distance? Defaults to false.
     */
    protected boolean includeInteriors = false;

    /**
     * Must be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. The type of targets to
     * create.
     */
    protected TargetType targetType = null;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Specifies the number of
     * edges to use if targetType is INDEX, and ignored otherwise. Defaults to 4.
     */
    protected int numTargetEdges = 4;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. If positive, determines
     * the maxDistance to be used for S2ClosestEdgeQuery.Options, or minDistance used for the
     * S2FurthestEdgeQuery.Options as a fraction of {@link indexRadiusKm}.
     *
     *
A positive value indicates a fixed value, i.e. 0.5 for 500 km, while a negative value
     * indicates that no maximum distance (for closest edge queries) or minimum distance (for
     * furthest edge queries) will be set.
     *
     *
Defaults to -1, for no limits on distance.
     */
    protected double distanceFraction = -1;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Determines the maxError
     * to be used for the query Options as a fraction of {@link indexRadiusKm}.
     *
     *
A positive value indicates a fixed value, i.e. 0.5 for 500 km. A negative value, which is
     * the default, specifies that maxError will not be set, so will be zero.
     */
    protected double maxErrorFraction = -1;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. If true, the target
     * will be created by sampling edges from the index. Otherwise (the default) the target will be
     * created by constructing a shape within the target cap.
     */
    protected boolean chooseTargetFromIndex = false;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Determines the size of
     * the target cap, as a fraction of the {@link indexRadiusKm}.
     *
     *
A positive value indicates a fixed value, i.e. 0.5 for 500 km, while a negative value
     * indicates the maximum for a uniform distribution of values starting at zero. For example,
     * -0.5 indicates a uniformly distributed value between 0 and 500 km.
     *
     *
Defaults to -1, for uniformly distributed values between 0 and {@link indexRadiusKm}.
     */
    protected double targetRadiusFraction = -1;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Determines the distance
     * between the center of the S2Cap bounding the index and the center of the S2Cap bounding the
     * target.
     *
     *
A positive value indicates a fixed value, i.e. 0.5 for 500 km, while a negative value
     * indicates the maximum for a uniform distribution of values starting at zero. For example,
     * -0.5 indicates a uniformly distributed value between 0 and 500 km. Note that if
     * centerSeparationFraction is less than (0.5 * (1 + targetRadiusFraction)) then the S2Cap
     * bounding the target and the S2Cap bounding the index will overlap, and edges of the target
     * and index might intersect, or a polygon in the index might completely contain a connected
     * component of the target, or vice versa.
     *
     *
Defaults to -1, for uniformly distributed values between 0 and {@link indexRadiusKm}.
     */
    protected double centerSeparationFraction = -1;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. Determines the size of
     * generated indexes and other parameters above which are specified as fractions of this value.
     * Defaults to DEFAULT_INDEX_RADIUS_KM.
     */
    protected double indexRadiusKm = DEFAULT_INDEX_RADIUS_KM;

    /** The indexRadiusKm converted to an angle, which happens in initialize(). */
    protected S1Angle indexRadius;

    /**
     * May be set by benchmarks inheriting from BestEdgesBenchmarkBaseState. If true,
     * Options.setUseBruteForce(true) will be set. Defaults to false.
     */
    protected boolean useBruteForce = false;

    // An instance of ShapeFactory specified by the factoryType.
    protected ShapeFactory factory;

    // Current position as the benchmark iterates through the targets and queries.
    protected int queryIndex = 0;
    protected int targetIndex = 0;

    // The actual number of index samples to use.
    protected int numIndexSamples = DEFAULT_NUM_INDEX_SAMPLES;
    // The actual number of target samples to use.
    protected int numTargetSamples = DEFAULT_NUM_TARGET_SAMPLES;

    // Subclasses implement this to update the current query from the value of queryIndex.
    abstract void setCurrentQuery();

    // Subclasses implement this to update the current target from the values of queryIndex and
    // targetIndex.
    abstract void setCurrentTarget();

    // Subclasses implement this to create the list of queries with their indexes and targets.
    abstract void createQueriesAndTargets() throws IOException;

    /**
     * If "fraction" is positive, returns the given "radius" multiplied by "fraction". If "fraction"
     * is negative, returns a random S1Angle uniformly distributed between zero and a positive
     * maximum of "radius" * abs("fraction").
     */
    protected S1Angle fractionToRadiusOrRange(double fraction, S1Angle radius) {
      if (fraction < 0) {
        fraction = -(data.nextDouble() * fraction);
      }
      return radius.mul(fraction);
    }

    /**
     * Must be called by benchmarks inheriting from BestEdgesBenchmarkBaseState in their JMH @Setup.
     * Initializes the edgeQueriesAndTargets according to the current values that have been set for
     * the index and target generation and prepares to iterate through query indexes and targets.
     */
    protected void initialize(BenchmarkParams params) throws IOException {
      // Determine if we are running as part of a unit test.
      setUnitTestModeFromParams(params);

      // For unit tests, override setup parameters for speed.
      if (isUnitTest()) {
        numIndexEdges = 4;
        numTargetEdges = 4;
        numIndexSamples = 1;
        numTargetSamples = 1;
      }
      super.setup();
      indexRadius = kmToAngle(indexRadiusKm);

      // Create the factory from the factoryType.
      switch (factoryType) {
        case FRACTAL_LOOP:
          this.factory = data.new FractalLoopShapeFactory();
          break;
        case REGULAR_LOOP:
          this.factory = data.new RegularLoopShapeFactory();
          break;
        case POINT_CLOUD:
          this.factory = data.new PointCloudShapeFactory();
          break;
      }

      // Create indexes, with closest or furthest edge queries on them, and collections of closest
      // or furthest targets. This method is provided by subclasses.
      createQueriesAndTargets();

      // Reset iteration over targets and queries.
      queryIndex = 0;
      targetIndex = 0;
      setCurrentQuery();
      setCurrentTarget();
    }

    /** Generates an index according to the current specification, and returns the bounding cap. */
    protected S2Cap fillOutputIndex(BestEdgeQueryWithTargets output, boolean encodeIndex)
        throws IOException {
      // Use the factory to add edges to the index.
      S2Cap indexCap = S2Cap.fromAxisAngle(data.getRandomPoint(), kmToAngle(indexRadiusKm));
      output.index = factory.getShape(indexCap, numIndexEdges);

      // Count the number of edges added when done.
      output.numIndexEdges = S2ShapeUtil.countEdges(output.index);

      // Encode the index if required.
      if (encodeIndex) {
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        VectorCoder.FAST_SHAPE.encode(output.index.getShapes(), stream);
        S2ShapeIndexCoder.INSTANCE.encode(output.index, stream);

        Bytes data = Bytes.fromByteArray(stream.toByteArray());
        Cursor cursor = data.cursor();

        // Store the encoded index with its shapes in the output, replacing the un-encoded index.
        output.shapes = VectorCoder.FAST_SHAPE.decode(data, cursor);
        output.index = new S2ShapeIndexCoder(output.shapes).decode(data, cursor);
      }
      return indexCap;
    }

    protected S2Cap getTargetCap(S2Cap indexCap) {
      S1Angle targetDist = fractionToRadiusOrRange(centerSeparationFraction, indexRadius);
      return S2Cap.fromAxisAngle(
          data.sampleBoundary(S2Cap.fromAxisAngle(indexCap.axis(), targetDist)),
          fractionToRadiusOrRange(targetRadiusFraction, indexRadius));
    }

    protected S2Point getTargetPoint(BestEdgeQueryWithTargets output, S2Cap targetCap) {
      return chooseTargetFromIndex
          ? data.sampleEdge(output.index, output.numIndexEdges).getStart()
          : targetCap.axis();
    }

    protected MutableEdge getTargetEdge(BestEdgeQueryWithTargets output, S2Cap targetCap) {
      if (chooseTargetFromIndex) {
        return data.sampleEdge(output.index, output.numIndexEdges);
      }
      MutableEdge edge = new MutableEdge();
      edge.set(data.sampleBoundary(targetCap), data.sampleBoundary(targetCap));
      return edge;
    }

    protected S2Cell getTargetCell(BestEdgeQueryWithTargets output, S2Cap targetCap) {
      S2CellId cellId =
          chooseTargetFromIndex
              ? data.sampleCell(output.index)
              : S2CellId.fromPoint(targetCap.axis())
                  .parent(PROJ.maxDiag.getClosestLevel(targetCap.radius().radians()));
      return new S2Cell(cellId);
    }

    protected S2ShapeIndex getTargetIndex(BestEdgeQueryWithTargets output, S2Cap targetCap) {
      S2ShapeIndex targetIndex = new S2ShapeIndex();
      if (chooseTargetFromIndex) {
        // If the index factoryType is POINT_CLOUD the edges are points, and can't be added to
        // a S2EdgeVectorShape, because it checks that the edges are not degenerate. In that case,
        // use an S2Point.Shape.
        S2Shape shape;
        if (factoryType == FactoryType.POINT_CLOUD) {
          List<S2Point> points = new ArrayList<>();
          for (int p = 0; p < numTargetEdges; ++p) {
            MutableEdge edge = data.sampleEdge(output.index, output.numIndexEdges);
            points.add(edge.getStart());
          }
          shape = S2Point.Shape.fromList(points);
        } else {
          S2EdgeVectorShape edgeVectorshape = new S2EdgeVectorShape();
          for (int e = 0; e < numTargetEdges; ++e) {
            MutableEdge edge = data.sampleEdge(output.index, output.numIndexEdges);
            edgeVectorshape.add(edge.getStart(), edge.getEnd());
          }
          shape = edgeVectorshape;
        }
        targetIndex.add(shape);
      } else {
        targetIndex = factory.getShape(targetCap, numTargetEdges);
      }

      targetIndex.iterator(); // Force an index build.
      return targetIndex;
    }

    /**
     * Iterate through the targets. When all the targets for the current query are done, go to the
     * next query. Loop back to the start at the end of the queries.
     */
    public void next() {
      if (++targetIndex == numTargetSamples) {
        targetIndex = 0;
        if (++queryIndex == numIndexSamples) {
          queryIndex = 0;
        }
        setCurrentQuery();
      }
      setCurrentTarget();
    }
  }
}


text:
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.content.browser.input;

import com.google.common.annotations.VisibleForTesting;

import android.text.Editable;
import android.text.InputType;
import android.text.Selection;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;

/**
 * InputConnection is created by ContentView.onCreateInputConnection.
 * It then adapts android's IME to chrome's RenderWidgetHostView using the
 * native ImeAdapterAndroid via the class ImeAdapter.
 */
public class AdapterInputConnection extends BaseInputConnection {
    private static final String TAG =
            "org.chromium.content.browser.input.AdapterInputConnection";
    private static final boolean DEBUG = false;
    /**
     * Selection value should be -1 if not known. See EditorInfo.java for details.
     */
    public static final int INVALID_SELECTION = -1;
    public static final int INVALID_COMPOSITION = -1;

    private final View mInternalView;
    private final ImeAdapter mImeAdapter;

    private boolean mSingleLine;
    private int mNumNestedBatchEdits = 0;
    private boolean mIgnoreTextInputStateUpdates = false;

    private int mLastUpdateSelectionStart = INVALID_SELECTION;
    private int mLastUpdateSelectionEnd = INVALID_SELECTION;
    private int mLastUpdateCompositionStart = INVALID_COMPOSITION;
    private int mLastUpdateCompositionEnd = INVALID_COMPOSITION;

    @VisibleForTesting
    AdapterInputConnection(View view, ImeAdapter imeAdapter, EditorInfo outAttrs) {
        super(view, true);
        mInternalView = view;
        mImeAdapter = imeAdapter;
        mImeAdapter.setInputConnection(this);
        mSingleLine = true;
        outAttrs.imeOptions = EditorInfo.IME_FLAG_NO_FULLSCREEN;
        outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT
                | EditorInfo.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT;

        if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeText) {
            // Normal text field
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTextArea ||
                imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeContentEditable) {
            // TextArea or contenteditable.
            outAttrs.inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE
                    | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES
                    | EditorInfo.TYPE_TEXT_FLAG_AUTO_CORRECT;
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_NONE;
            mSingleLine = false;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypePassword) {
            // Password
            outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                    | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeSearch) {
            // Search
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_SEARCH;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeUrl) {
            // Url
            // TYPE_TEXT_VARIATION_URI prevents Tab key from showing, so
            // exclude it for now.
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeEmail) {
            // Email
            outAttrs.inputType = InputType.TYPE_CLASS_TEXT
                    | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS;
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_GO;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeTel) {
            // Telephone
            // Number and telephone do not have both a Tab key and an
            // action in default OSK, so set the action to NEXT
            outAttrs.inputType = InputType.TYPE_CLASS_PHONE;
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
        } else if (imeAdapter.getTextInputType() == ImeAdapter.sTextInputTypeNumber) {
            // Number
            outAttrs.inputType = InputType.TYPE_CLASS_NUMBER
                    | InputType.TYPE_NUMBER_VARIATION_NORMAL;
            outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
        }
        outAttrs.initialSelStart = imeAdapter.getInitialSelectionStart();
        outAttrs.initialSelEnd = imeAdapter.getInitialSelectionStart();
    }

    /**
     * Updates the AdapterInputConnection's internal representation of the text
     * being edited and its selection and composition properties. The resulting
     * Editable is accessible through the getEditable() method.
     * If the text has not changed, this also calls updateSelection on the InputMethodManager.
     * @param text The String contents of the field being edited
     * @param selectionStart The character offset of the selection start, or the caret
     * position if there is no selection
     * @param selectionEnd The character offset of the selection end, or the caret
     * position if there is no selection
     * @param compositionStart The character offset of the composition start, or -1
     * if there is no composition
     * @param compositionEnd The character offset of the composition end, or -1
     * if there is no selection
     */
    public void setEditableText(String text, int selectionStart, int selectionEnd,
            int compositionStart, int compositionEnd) {
        if (DEBUG) {
            Log.w(TAG, "setEditableText [" + text + "] [" + selectionStart + " " + selectionEnd
                    + "] [" + compositionStart + " " + compositionEnd + "]");
        }
        // Non-breaking spaces can cause the IME to get confused. Replace with normal spaces.
        text = text.replace('\u00A0', ' ');

        Editable editable = getEditable();

        int prevSelectionStart = Selection.getSelectionStart(editable);
        int prevSelectionEnd = Selection.getSelectionEnd(editable);
        int prevCompositionStart = getComposingSpanStart(editable);
        int prevCompositionEnd = getComposingSpanEnd(editable);
        String prevText = editable.toString();

        selectionStart = Math.min(selectionStart, text.length());
        selectionEnd = Math.min(selectionEnd, text.length());
        compositionStart = Math.min(compositionStart, text.length());
        compositionEnd = Math.min(compositionEnd, text.length());

        boolean textUnchanged = prevText.equals(text);

        if (!textUnchanged) {
            editable.replace(0, editable.length(), text);
        }

        if (prevSelectionStart == selectionStart && prevSelectionEnd == selectionEnd
                && prevCompositionStart == compositionStart
                && prevCompositionEnd == compositionEnd) {
            // Nothing has changed; don't need to do anything
            return;
        }

        Selection.setSelection(editable, selectionStart, selectionEnd);

        if (compositionStart == compositionEnd) {
            removeComposingSpans(editable);
        } else {
            super.setComposingRegion(compositionStart, compositionEnd);
        }

        if (mIgnoreTextInputStateUpdates) return;
        updateSelection(selectionStart, selectionEnd, compositionStart, compositionEnd);
    }

    @VisibleForTesting
    protected void updateSelection(
            int selectionStart, int selectionEnd,
            int compositionStart, int compositionEnd) {
        // Avoid sending update if we sent an exact update already previously.
        if (mLastUpdateSelectionStart == selectionStart &&
                mLastUpdateSelectionEnd == selectionEnd &&
                mLastUpdateCompositionStart == compositionStart &&
                mLastUpdateCompositionEnd == compositionEnd) {
            return;
        }
        if (DEBUG) {
            Log.w(TAG, "updateSelection [" + selectionStart + " " + selectionEnd + "] ["
                    + compositionStart + " " + compositionEnd + "]");
        }
        // updateSelection should be called every time the selection or composition changes
        // if it happens not within a batch edit, or at the end of each top level batch edit.
        getInputMethodManagerWrapper().updateSelection(mInternalView,
                selectionStart, selectionEnd, compositionStart, compositionEnd);
        mLastUpdateSelectionStart = selectionStart;
        mLastUpdateSelectionEnd = selectionEnd;
        mLastUpdateCompositionStart = compositionStart;
        mLastUpdateCompositionEnd = compositionEnd;
    }

    /**
     * @see BaseInputConnection#setComposingText(java.lang.CharSequence, int)
     */
    @Override
    public boolean setComposingText(CharSequence text, int newCursorPosition) {
        if (DEBUG) Log.w(TAG, "setComposingText [" + text + "] [" + newCursorPosition + "]");
        super.setComposingText(text, newCursorPosition);
        return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(),
                newCursorPosition, false);
    }

    /**
     * @see BaseInputConnection#commitText(java.lang.CharSequence, int)
     */
    @Override
    public boolean commitText(CharSequence text, int newCursorPosition) {
        if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition + "]");
        super.commitText(text, newCursorPosition);
        return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(),
                newCursorPosition, text.length() > 0);
    }

    /**
     * @see BaseInputConnection#performEditorAction(int)
     */
    @Override
    public boolean performEditorAction(int actionCode) {
        if (DEBUG) Log.w(TAG, "performEditorAction [" + actionCode + "]");
        if (actionCode == EditorInfo.IME_ACTION_NEXT) {
            restartInput();
            // Send TAB key event
            long timeStampMs = System.currentTimeMillis();
            mImeAdapter.sendSyntheticKeyEvent(
                    ImeAdapter.sEventTypeRawKeyDown, timeStampMs, KeyEvent.KEYCODE_TAB, 0);
        } else {
            mImeAdapter.sendKeyEventWithKeyCode(KeyEvent.KEYCODE_ENTER,
                    KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE
                    | KeyEvent.FLAG_EDITOR_ACTION);
        }
        return true;
    }

    /**
     * @see BaseInputConnection#performContextMenuAction(int)
     */
    @Override
    public boolean performContextMenuAction(int id) {
        if (DEBUG) Log.w(TAG, "performContextMenuAction [" + id + "]");
        switch (id) {
            case android.R.id.selectAll:
                return mImeAdapter.selectAll();
            case android.R.id.cut:
                return mImeAdapter.cut();
            case android.R.id.copy:
                return mImeAdapter.copy();
            case android.R.id.paste:
                return mImeAdapter.paste();
            default:
                return false;
        }
    }

    /**
     * @see BaseInputConnection#getExtractedText(android.view.inputmethod.ExtractedTextRequest,
     *                                           int)
     */
    @Override
    public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
        if (DEBUG) Log.w(TAG, "getExtractedText");
        ExtractedText et = new ExtractedText();
        Editable editable = getEditable();
        et.text = editable.toString();
        et.partialEndOffset = editable.length();
        et.selectionStart = Selection.getSelectionStart(editable);
        et.selectionEnd = Selection.getSelectionEnd(editable);
        et.flags = mSingleLine ? ExtractedText.FLAG_SINGLE_LINE : 0;
        return et;
    }

    /**
     * @see BaseInputConnection#beginBatchEdit()
     */
    @Override
    public boolean beginBatchEdit() {
        if (DEBUG) Log.w(TAG, "beginBatchEdit [" + (mNumNestedBatchEdits == 0) + "]");
        if (mNumNestedBatchEdits == 0) mImeAdapter.batchStateChanged(true);

        mNumNestedBatchEdits++;
        return false;
    }

    /**
     * @see BaseInputConnection#endBatchEdit()
     */
    @Override
    public boolean endBatchEdit() {
        if (mNumNestedBatchEdits == 0) return false;

        --mNumNestedBatchEdits;
        if (DEBUG) Log.w(TAG, "endBatchEdit [" + (mNumNestedBatchEdits == 0) + "]");
        if (mNumNestedBatchEdits == 0) mImeAdapter.batchStateChanged(false);
        return false;
    }

    /**
     * @see BaseInputConnection#deleteSurroundingText(int, int)
     */
    @Override
    public boolean deleteSurroundingText(int leftLength, int rightLength) {
        if (DEBUG) {
            Log.w(TAG, "deleteSurroundingText [" + leftLength + " " + rightLength + "]");
        }
        if (!super.deleteSurroundingText(leftLength, rightLength)) {
            return false;
        }
        return mImeAdapter.deleteSurroundingText(leftLength, rightLength);
    }

    /**
     * @see BaseInputConnection#sendKeyEvent(android.view.KeyEvent)
     */
    @Override
    public boolean sendKeyEvent(KeyEvent event) {
        if (DEBUG) Log.w(TAG, "sendKeyEvent [" + event.getAction() + "]");
        mImeAdapter.hideSelectionAndInsertionHandleControllers();

        // If this is a key-up, and backspace/del or if the key has a character representation,
        // need to update the underlying Editable (i.e. the local representation of the text
        // being edited).
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                super.deleteSurroundingText(1, 0);
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_FORWARD_DEL) {
                super.deleteSurroundingText(0, 1);
            } else {
                int unicodeChar = event.getUnicodeChar();
                if (unicodeChar != 0) {
                    Editable editable = getEditable();
                    int selectionStart = Selection.getSelectionStart(editable);
                    int selectionEnd = Selection.getSelectionEnd(editable);
                    if (selectionStart > selectionEnd) {
                        int temp = selectionStart;
                        selectionStart = selectionEnd;
                        selectionEnd = temp;
                    }
                    editable.replace(selectionStart, selectionEnd,
                            Character.toString((char)unicodeChar));
                }
            }
        }
        mImeAdapter.translateAndSendNativeEvents(event);
        return true;
    }

    /**
     * @see BaseInputConnection#finishComposingText()
     */
    @Override
    public boolean finishComposingText() {
        if (DEBUG) Log.w(TAG, "finishComposingText");
        Editable editable = getEditable();
        if (getComposingSpanStart(editable) == getComposingSpanEnd(editable)) {
            return true;
        }

        // TODO(aurimas): remove this workaround of changing composition before confirmComposition
        //                Blink should support keeping the cursor (http://crbug.com/239923)
        int selectionStart = Selection.getSelectionStart(editable);
        int compositionStart = getComposingSpanStart(editable);
        super.finishComposingText();

        beginBatchEdit();
        if (compositionStart != -1 && compositionStart < selectionStart
                && !mImeAdapter.setComposingRegion(compositionStart, selectionStart)) {
            return false;
        }
        if (!mImeAdapter.checkCompositionQueueAndCallNative("", 0, true)) return false;
        endBatchEdit();
        return true;
    }

    /**
     * @see BaseInputConnection#setSelection(int, int)
     */
    @Override
    public boolean setSelection(int start, int end) {
        if (DEBUG) Log.w(TAG, "setSelection");
        if (start < 0 || end < 0) return true;
        super.setSelection(start, end);
        return mImeAdapter.setEditableSelectionOffsets(start, end);
    }

    /**
     * Informs the InputMethodManager and InputMethodSession (i.e. the IME) that the text
     * state is no longer what the IME has and that it needs to be updated.
     */
    void restartInput() {
        if (DEBUG) Log.w(TAG, "restartInput");
        getInputMethodManagerWrapper().restartInput(mInternalView);
        mIgnoreTextInputStateUpdates = false;
        mNumNestedBatchEdits = 0;
    }

    /**
     * @see BaseInputConnection#setComposingRegion(int, int)
     */
    @Override
    public boolean setComposingRegion(int start, int end) {
        if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + "]");
        int a = Math.min(start, end);
        int b = Math.max(start, end);
        if (a < 0) a = 0;
        if (b < 0) b = 0;

        if (a == b) {
            removeComposingSpans(getEditable());
        } else {
            super.setComposingRegion(a, b);
        }
        return mImeAdapter.setComposingRegion(a, b);
    }

    boolean isActive() {
        return getInputMethodManagerWrapper().isActive(mInternalView);
    }

    public void setIgnoreTextInputStateUpdates(boolean shouldIgnore) {
        mIgnoreTextInputStateUpdates = shouldIgnore;
        if (shouldIgnore) return;

        Editable editable = getEditable();
        updateSelection(Selection.getSelectionStart(editable),
                Selection.getSelectionEnd(editable),
                getComposingSpanStart(editable),
                getComposingSpanEnd(editable));
    }

    @VisibleForTesting
    protected boolean isIgnoringTextInputStateUpdates() {
        return mIgnoreTextInputStateUpdates;
    }

    private InputMethodManagerWrapper getInputMethodManagerWrapper() {
        return mImeAdapter.getInputMethodManagerWrapper();
    }
}

redpajama_set_name: RedPajamaGithub


text:
import api from '../../api'
import axios from 'axios'
import Cookies from 'js-cookie'
import * as types from '../mutation-types'

// initial state
const state = {
  user: null,
  token: Cookies.get('token')
}

// mutations
const mutations = {
  [types.SAVE_TOKEN] (state, { token, remember }) {
    state.token = token
    Cookies.set('token', token, { expires: remember ? 365 : null })
  },

  [types.FETCH_USER_SUCCESS] (state, { user }) {
    state.user = user
  },

  [types.FETCH_USER_FAILURE] (state) {
    state.token = null
    Cookies.remove('token')
  },

  [types.LOGOUT] (state) {
    state.user = null
    state.token = null

    Cookies.remove('token')
  },

  [types.UPDATE_USER] (state, { user }) {
    state.user = user
  }
}

// actions
const actions = {
  saveToken ({ commit, dispatch }, payload) {
    commit(types.SAVE_TOKEN, payload)
  },

  fetchUser ({ commit }) {
    return new Promise(async (resolve, reject) => {
      const user = await api.fetchUser()

      if (user) {
        commit(types.FETCH_USER_SUCCESS, { user })
        resolve(user)
      } else {
        commit(types.FETCH_USER_FAILURE)
        reject()
      }
    })
  },

  updateUser ({ commit }, payload) {
    commit(types.UPDATE_USER, payload)
  },

  logout ({ commit }) {
    return new Promise((resolve, reject) => {
      axios.post('/api/logout')
        .then(() => {
          commit(types.LOGOUT)

          resolve()
        })
        .catch(reject)
    })
  }
}

// getters
const getters = {
  authUser: state => state.user,
  authToken: state => state.token,
  authCheck: state => state.user !== null
}

export default {
  state,
  mutations,
  actions,
  getters
}


text:
     {{ datosPrincipales.nombres[0] || "Agregar un nombre" }}

    Otros nombres
     0">
      <button class="btn btn-xs btn-primary" ng-click="listados.volverPrincipal('Nombres',datosPrincipales.nombres,$index);$event.stopPropagation()">↑</button>{{nombre}}

      {{listados.mensaje || '+ Agregar'}}

    |
    Alias:
     0">
      {{alias}}

      {{listados.mensaje || '+ Agregar'}}

Banderas:

Colombia(1900 - 1987)

España(1900 - 1987)

Alemania(1900 - 1987)

Añadir bandera


text:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by CSGenerator.
// </auto-generated>
//------------------------------------------------------------------------------
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;

using jsval = JSApi.jsval;

public class JSB_UnityEngine_MeshCollider
{

////////////////////// MeshCollider ///////////////////////////////////////
// constructors

static bool MeshCollider_MeshCollider1(JSVCall vc, int argc)
{
    int _this = JSApi.getObject((int)JSApi.GetType.Arg);
    JSApi.attachFinalizerObject(_this);
    --argc;

    int len = argc;
    if (len == 0)
    {
        JSMgr.addJSCSRel(_this, new UnityEngine.MeshCollider());
    }

    return true;
}

// fields

// properties
static void MeshCollider_sharedMesh(JSVCall vc)
{
    if (vc.bGet)
    {
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        var result = _this.sharedMesh;
                JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
    }
    else
    {
        UnityEngine.Mesh arg0 = (UnityEngine.Mesh)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        _this.sharedMesh = arg0;
    }
}
static void MeshCollider_convex(JSVCall vc)
{
    if (vc.bGet)
    {
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        var result = _this.convex;
                JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
    else
    {
        System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        _this.convex = arg0;
    }
}
static void MeshCollider_smoothSphereCollisions(JSVCall vc)
{
    if (vc.bGet)
    {
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        var result = _this.smoothSphereCollisions;
                JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
    else
    {
        System.Boolean arg0 = (System.Boolean)JSApi.getBooleanS((int)JSApi.GetType.Arg);
        UnityEngine.MeshCollider _this = (UnityEngine.MeshCollider)vc.csObj;
        _this.smoothSphereCollisions = arg0;
    }
}

// methods

//register

public static void __Register()
{
    JSMgr.CallbackInfo ci = new JSMgr.CallbackInfo();
    ci.type = typeof(UnityEngine.MeshCollider);
    ci.fields = new JSMgr.CSCallbackField[]
    {

    };
    ci.properties = new JSMgr.CSCallbackProperty[]
    {
        MeshCollider_sharedMesh,
        MeshCollider_convex,
        MeshCollider_smoothSphereCollisions,

    };
    ci.constructors = new JSMgr.MethodCallBackInfo[]
    {
        new JSMgr.MethodCallBackInfo(MeshCollider_MeshCollider1, ".ctor"),

    };
    ci.methods = new JSMgr.MethodCallBackInfo[]
    {

    };
    JSMgr.allCallbackInfo.Add(ci);
}

}


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- PYCSW_VERSION -->
<csw:GetRecordsResponse xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:gml="http://www.opengis.net/gml" xmlns:dif="http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ows="http://www.opengis.net/ows" xmlns:fgdc="http://www.opengis.net/cat/csw/csdgm" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:ogc="http://www.opengis.net/ogc" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd">
  <csw:SearchStatus timestamp="PYCSW_TIMESTAMP"/>
  <csw:SearchResults nextRecord="0" numberOfRecordsMatched="10" numberOfRecordsReturned="10" recordSchema="http://www.opengis.net/cat/csw/2.0.2" elementSet="summary">
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:1ef30a8b-876d-4828-9246-c37ab4510bbd</dc:identifier>
      <dc:title></dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Service</dc:type>
      <dct:abstract>Proin sit amet justo. In justo. Aenean adipiscing nulla id tellus.</dct:abstract>
      <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
        <ows:LowerCorner>60.04 13.75</ows:LowerCorner>
        <ows:UpperCorner>68.41 17.92</ows:UpperCorner>
      </ows:BoundingBox>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:66ae76b7-54ba-489b-a582-0f0633d96493</dc:identifier>
      <dc:title>Maecenas enim</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Text</dc:type>
      <dc:subject>Marine sediments</dc:subject>
      <dc:format>application/xhtml+xml</dc:format>
      <dct:abstract>Pellentesque tempus magna non sapien fringilla blandit.</dct:abstract>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:6a3de50b-fa66-4b58-a0e6-ca146fdd18d4</dc:identifier>
      <dc:title>Ut facilisis justo ut lacus</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Service</dc:type>
      <dc:subject>Vegetation</dc:subject>
      <dc:relation>urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63</dc:relation>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:784e2afd-a9fd-44a6-9a92-a3848371c8ec</dc:identifier>
      <dc:title>Aliquam fermentum purus quis arcu</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Text</dc:type>
      <dc:subject>Hydrography--Dictionaries</dc:subject>
      <dc:format>application/pdf</dc:format>
      <dct:abstract>Vestibulum quis ipsum sit amet metus imperdiet vehicula. Nulla scelerisque cursus mi.</dct:abstract>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:829babb0-b2f1-49e1-8cd5-7b489fe71a1e</dc:identifier>
      <dc:title>Vestibulum massa purus</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Image</dc:type>
      <dc:format>image/jp2</dc:format>
      <dc:relation>urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc</dc:relation>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:88247b56-4cbc-4df9-9860-db3f8042e357</dc:identifier>
      <dc:title></dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Dataset</dc:type>
      <dc:subject>Physiography-Landforms</dc:subject>
      <dct:abstract>Donec scelerisque pede ut nisl luctus accumsan. Quisque ultrices, lorem eget feugiat fringilla, lorem dui porttitor ante, cursus ultrices magna odio eu neque.</dct:abstract>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:94bc9c83-97f6-4b40-9eb8-a8e8787a5c63</dc:identifier>
      <dc:title>Mauris sed neque</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Dataset</dc:type>
      <dc:subject>Vegetation-Cropland</dc:subject>
      <dct:abstract>Curabitur lacinia, ante non porta tempus, mi lorem feugiat odio, eget suscipit eros pede ac velit.</dct:abstract>
      <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
        <ows:LowerCorner>47.59 -4.1</ows:LowerCorner>
        <ows:UpperCorner>51.22 0.89</ows:UpperCorner>
      </ows:BoundingBox>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:9a669547-b69b-469f-a11f-2d875366bbdc</dc:identifier>
      <dc:title>Ñunç elementum</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Dataset</dc:type>
      <dc:subject>Hydrography-Oceanographic</dc:subject>
      <ows:BoundingBox crs="urn:x-ogc:def:crs:EPSG:6.11:4326" dimensions="2">
        <ows:LowerCorner>44.79 -6.17</ows:LowerCorner>
        <ows:UpperCorner>51.13 -2.23</ows:UpperCorner>
      </ows:BoundingBox>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:ab42a8c4-95e8-4630-bf79-33e59241605a</dc:identifier>
      <dc:title></dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Service</dc:type>
      <dc:subject>Physiography</dc:subject>
      <dc:relation>urn:uuid:88247b56-4cbc-4df9-9860-db3f8042e357</dc:relation>
      <dct:abstract>Suspendisse accumsan molestie lorem. Nullam velit turpis, mattis ut, varius bibendum, laoreet non, quam.</dct:abstract>
    </csw:SummaryRecord>
    <csw:SummaryRecord>
      <dc:identifier>urn:uuid:e9330592-0932-474b-be34-c3a3bb67c7db</dc:identifier>
      <dc:title>Fuscé vitae ligulä</dc:title>
      <dc:type>http://purl.org/dc/dcmitype/Text</dc:type>
      <dc:subject>Land titles</dc:subject>
      <dc:format>text/rtf</dc:format>
      <dct:abstract>Morbi ultriçes, dui suscipit vestibulum prètium, velit ante pretium tortor, egët tincidunt pede odio ac nulla.</dct:abstract>
    </csw:SummaryRecord>
  </csw:SearchResults>
</csw:GetRecordsResponse>


text:
<?xml version="1.0" encoding="UTF-8"?>
<LearningStandards>
  <LearningStandardItem xml:lang="en" RefID="DA01BD070DF34765B20815B5951405C0">
    <RefURI>http://corestandards.org/ELA-Literacy/WHST/11-12/4/</RefURI>
    <StandardHierarchyLevel>
      <number>6</number>
      <description>Standard</description>
    </StandardHierarchyLevel>
    <StatementCodes>
      <StatementCode>CCSS.ELA-Literacy.WHST.11-12.4</StatementCode>
    </StatementCodes>
    <Statements>
      <Statement>Produce clear and coherent writing in which the development, organization, and style are appropriate to task, purpose, and audience.</Statement>
    </Statements>
    <GradeLevels>
      <GradeLevel>11-12</GradeLevel>
    </GradeLevels>
    <LearningStandardDocumentRefId>0FAC40650F514a459951A657F942B845</LearningStandardDocumentRefId>
    <RelatedLearningStandardItems>
      <LearningStandardItemRefId RelationshipType="childOf">7C4C5F10707345bbAA45CA22FA8E37DC</LearningStandardItemRefId>
    </RelatedLearningStandardItems>
  </LearningStandardItem>
</LearningStandards>


text:
package com.agilemods.materiamuto.common.emc;

import com.agilemods.materiamuto.MateriaMuto;
import com.agilemods.materiamuto.api.IRecipeScanner;
import com.agilemods.materiamuto.api.wrapper.IStackWrapper;
import com.agilemods.materiamuto.api.wrapper.VanillaStackWrapper;
import com.agilemods.materiamuto.common.core.MMItems;
import com.agilemods.materiamuto.common.emc.recipe.VanillaCraftingScanner;
import com.agilemods.materiamuto.common.emc.recipe.VanillaSmeltingScanner;
import com.agilemods.materiamuto.common.emc.recipe.compat.ic2.IC2CraftingScanner;
import com.agilemods.materiamuto.common.emc.recipe.compat.ic2.IC2MetalFormerScanner;
import com.agilemods.materiamuto.common.emc.recipe.compat.thaumcraft.ThaumcraftCraftingScanner;
import com.agilemods.materiamuto.common.emc.recipe.compat.thaumcraft.ThaumcraftCrucibleScanner;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameData;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStoneBrick;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;

import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class EMCRegistry {

    private static Map<VanillaStackWrapper, Double> emcMapping = Maps.newHashMap();
    private static Map<String, Double> genericEmcMapping = Maps.newHashMap();

    private static Set<VanillaStackWrapper> blacklist = Sets.newHashSet();

    private static List<IRecipeScanner> recipeScanners = Lists.newArrayList();

    private static Set<IStackWrapper> tempBlacklist = Sets.newHashSet();

    private static final EMCDelegate emcDelegate = new EMCDelegate();

    public static void blacklist(VanillaStackWrapper VanillaStackWrapper) {
        blacklist.add(VanillaStackWrapper);
    }

    private static boolean canDisable = false;

    public static void addRecipeScanner(IRecipeScanner recipeScanner) {
        boolean canScan = !canDisable;
        if (canDisable) {
            MateriaMuto.configuration.get("recipeScanner", recipeScanner.getClass().getSimpleName(), true).getBoolean(true);
            MateriaMuto.configuration.save();
        }

        if (canScan) {
            recipeScanners.add(recipeScanner);
            recipeScanner.scan();
        }
    }

    public static void reset() {
        emcMapping.clear();
        genericEmcMapping.clear();
        blacklist.clear();
        recipeScanners.clear();
        tempBlacklist.clear();
        canDisable = false;
    }

    private static void determineEMC(VanillaStackWrapper stackWrapper) {
        if (getEMC(stackWrapper, false) <= 0) {
            EMCRegistry.tempBlacklist.add(stackWrapper);

            double emc = Double.MAX_VALUE;

            for (IRecipeScanner recipeScanner : recipeScanners) {
                double subEmc = recipeScanner.getEMC(emcDelegate, stackWrapper);
                if (subEmc > 0 && subEmc < emc) {
                    emc = subEmc;
                }
            }

            if (emc == Double.MAX_VALUE)
                emc = 0;

            EMCRegistry.setEMC(stackWrapper, emc, true);

            EMCRegistry.tempBlacklist.remove(stackWrapper);
        }
    }

    public static void setEMC(Fluid fluid, double value) {
        setGenericEMC(fluid.getName(), value);
    }

    public static double getEMC(Fluid fluid) {
        return getGenericEMC(fluid.getName());
    }

    public static void setGenericEMC(String ident, double value) {
        genericEmcMapping.put(ident, value);
    }

    public static double getGenericEMC(String ident) {
        Double value = genericEmcMapping.get(ident);
        return value == null ? 0 : value;
    }

    public static void setEMC(Block block, double value) {
        setEMC(new VanillaStackWrapper(block), value, false);
    }

    public static void setEMC(Item item, double value) {
        setEMC(new VanillaStackWrapper(item), value, false);
    }

    public static void setEMC_wild(Block block, double value) {
        setEMC(new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE), value);
    }

    public static void setEMC_wild(Item item, double value) {
        setEMC(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE), value);
    }

    public static void setEMC(ItemStack itemStack, double value) {
        setEMC(new VanillaStackWrapper(itemStack), value, false);
    }

    public static void setEMC(VanillaStackWrapper stackWrapper, double value, boolean force) {
        if (!blacklist.contains(stackWrapper)) {
            if (force) {
                emcMapping.remove(stackWrapper);
            }
            emcMapping.put(stackWrapper, value);
        }
    }

    public static double getEMC(Object object) {
        if (object instanceof Block) {
            return getEMC((Block) object);
        }
        if (object instanceof Item) {
            return getEMC((Item) object);
        }
        if (object instanceof ItemStack) {
            return getEMC((ItemStack) object);
        }
        if (object instanceof VanillaStackWrapper) {
            return getEMC((VanillaStackWrapper) object, true);
        }
        return 0;
    }

    public static double getEMC(Block block) {
        return getEMC(new VanillaStackWrapper(block), true);
    }

    public static double getEMC(Item item) {
        return getEMC(new VanillaStackWrapper(item), true);
    }

    public static double getEMC(ItemStack itemStack) {
        return getEMC(new VanillaStackWrapper(itemStack), true);
    }

    public static double getEMC(VanillaStackWrapper stackWrapper, boolean scan) {
        if (!tempBlacklist.contains(stackWrapper) && !blacklist.contains(stackWrapper)) {

            tempBlacklist.add(stackWrapper);
            Double value = emcMapping.get(stackWrapper);
            if (scan) {
                if (value == null || Double.isNaN(value) || value <= 0) {
                    determineEMC(stackWrapper);
                    value = getEMC(stackWrapper, false);
                }
            }
            tempBlacklist.remove(stackWrapper);

            if (value == null || Double.isNaN(value)) {
                return 0;
            } else {
                return value;
            }
        } else {
            return 0;
        }
    }

    public static void initialize() {
        initializeBlacklist();

        initializeLazyValues();
        initializeLazyFluidValues();

        FuelRegistry.initialize();

        addRecipeScanner(new VanillaCraftingScanner());
        addRecipeScanner(new VanillaSmeltingScanner());

        // Global flag to determine if recipe scanner should be checked against config
        canDisable = true;

        if (Loader.isModLoaded("IC2")) {
            addRecipeScanner(new IC2CraftingScanner());
            addRecipeScanner(new IC2MetalFormerScanner());
        }

        if (Loader.isModLoaded("Thaumcraft")) {
            addRecipeScanner(new ThaumcraftCraftingScanner());
            addRecipeScanner(new ThaumcraftCrucibleScanner());
        }

        addFinalValues();
    }

    private static void initializeBlacklist() {
        if (Loader.isModLoaded("IC2")) {
            blacklist.add(new VanillaStackWrapper(GameRegistry.findItem("IC2", "itemToolForgeHammer")));
            blacklist.add(new VanillaStackWrapper(GameRegistry.findItem("IC2", "itemToolCutter")));
        }
    }

    private static void initializeLazyValues() {
        setEMC(Blocks.brown_mushroom, 32);
        setEMC(Blocks.cactus, 8);
        setEMC(Blocks.dragon_egg, 262144);
        setEMC(Blocks.end_stone, 4);
        setEMC(Blocks.grass, 1);
        setEMC(Blocks.gravel, 4);
        setEMC(Blocks.ice, 1);
        setEMC(Blocks.mossy_cobblestone, 145);
        setEMC(Blocks.mycelium, 1);
        setEMC(Blocks.netherrack, 1);
        setEMC(Blocks.obsidian, 64);
        setEMC(Blocks.packed_ice, 4);
        setEMC(Blocks.pumpkin, 144);
        setEMC(Blocks.red_mushroom, 32);
        setEMC(Blocks.snow, 1);
        setEMC(Blocks.soul_sand, 49);
        setEMC(Blocks.torch, 9);
        setEMC(Blocks.vine, 8);
        setEMC(Blocks.waterlily, 16);
        setEMC(Blocks.web, 12);
        setEMC(new ItemStack(MMItems.alchemicalFuel, 1, 0), 512);
        setEMC(new ItemStack(MMItems.alchemicalFuel, 1, 1), 2048);
        setEMC(new ItemStack(MMItems.alchemicalFuel, 1, 2), 8192);
        setEMC(Items.apple, 128);
        setEMC(Items.beef, 64);
        setEMC(Items.blaze_powder, 768);
        setEMC(Items.blaze_rod, 1536);
        setEMC(Items.bone, 144);
        setEMC(Items.carrot, 64);
        setEMC(new ItemStack(Items.coal, 1, 0), 128);
        setEMC(new ItemStack(Items.coal, 1, 1), 32);
        setEMC(Items.chicken, 64);
        setEMC(Items.clay_ball, 16);
        setEMC(Items.diamond, 8192);
        setEMC(Items.diamond_horse_armor, 40960);
        setEMC(Items.egg, 32);
        setEMC(Items.emerald, 16384);
        setEMC(Items.enchanted_book, 2048);
        setEMC(Items.ender_pearl, 1024);
        setEMC(Items.feather, 48);
        setEMC(Items.filled_map, 1472);
        setEMC(Items.flint, 4);
        setEMC(Items.ghast_tear, 4096);
        setEMC(Items.glowstone_dust, 384);
        setEMC(Items.gold_ingot, 2048);
        setEMC(Items.golden_horse_armor, 1024);
        setEMC(Items.gunpowder, 192);
        setEMC(Items.iron_horse_armor, 1280);
        setEMC(Items.iron_ingot, 256);
        setEMC(Items.leather, 64);
        setEMC(Items.milk_bucket, 833);
        setEMC(Items.melon, 16);
        setEMC(Items.nether_star, 139264);
        setEMC(Items.nether_wart, 24);
        setEMC(Items.porkchop, 64);
        setEMC(Items.quartz, 256);
        setEMC(Items.record_11, 2048);
        setEMC(Items.record_13, 2048);
        setEMC(Items.record_blocks, 2048);
        setEMC(Items.record_cat, 2048);
        setEMC(Items.record_chirp, 2048);
        setEMC(Items.record_far, 2048);
        setEMC(Items.record_mall, 2048);
        setEMC(Items.record_mellohi, 2048);
        setEMC(Items.record_stal, 2048);
        setEMC(Items.record_strad, 2048);
        setEMC(Items.record_wait, 2048);
        setEMC(Items.record_ward, 2048);
        setEMC(Items.redstone, 64);
        setEMC(Items.reeds, 32);
        setEMC(Items.rotten_flesh, 32);
        setEMC(Items.saddle, 192);
        setEMC(Items.slime_ball, 32);
        setEMC(Items.snowball, 1);
        setEMC(Items.spider_eye, 128);
        setEMC(Items.stick, 4);
        setEMC(Items.string, 12);
        setEMC(Items.wheat, 24);
        setEMC(Items.wheat_seeds, 16);
        setEMC_wild(Blocks.cobblestone, 1);
        setEMC_wild(Blocks.deadbush, 1);
        setEMC_wild(Blocks.dirt, 1);
        setEMC_wild(Blocks.double_plant, 32);
        setEMC_wild(Blocks.leaves2, 1);
        setEMC_wild(Blocks.leaves, 1);
        setEMC_wild(Blocks.log2, 32);
        setEMC_wild(Blocks.log, 32);
        setEMC_wild(Blocks.red_flower, 16);
        setEMC_wild(Blocks.sand, 1);
        setEMC_wild(Blocks.sapling, 32);
        setEMC_wild(Blocks.tallgrass, 1);
        setEMC_wild(Blocks.yellow_flower, 16);
        setEMC_wild(Items.fish, 64);
        setEMC_wild(Items.potato, 64);

        // Dye Handling
        for (int i = 0; i < 16; i++) {
            double emc = 16;

            if (i == 3) {
                emc = 128;
            } else if (i == 4) {
                emc = 864;
            } else if (i == 15) {
                emc = 48;
            }

            setEMC(new ItemStack(Items.dye, 1, i), emc);
        }

        addOreDictionaryValue("ingotCopper", 85);
        addOreDictionaryValue("ingotTin", 256);
        addOreDictionaryValue("ingotLead", 256);
        addOreDictionaryValue("ingotSilver", 512);

        // Also add ore dictionary tags
        ImmutableSet<VanillaStackWrapper> immutableSet = ImmutableSet.copyOf(emcMapping.keySet());
        for (VanillaStackWrapper VanillaStackWrapper : immutableSet) {
            double emc = getEMC(VanillaStackWrapper);
            ItemStack itemStack = VanillaStackWrapper.toItemStack();

            for (int id : OreDictionary.getOreIDs(itemStack)) {
                String name = OreDictionary.getOreName(id);
                for (ItemStack oreStack : OreDictionary.getOres(name)) {
                    setEMC(oreStack, emc);
                }
            }
        }
    }

    private static void addOreDictionaryValue(String oreTag, double value) {
        for (ItemStack itemStack : OreDictionary.getOres(oreTag)) {
            setEMC(itemStack, value);
        }
    }

    private static void initializeLazyFluidValues() {
        setEMC(FluidRegistry.WATER, 1);
        setEMC(FluidRegistry.LAVA, 64);
    }

    private static void addFinalValues() {
        // Fluid handling
        for (Item item : GameData.getItemRegistry().typeSafeIterable()) {
            LinkedList<ItemStack> subItems = Lists.newLinkedList();

            try {
                item.getSubItems(item, item.getCreativeTab(), subItems);
            } catch (Exception ignore) {}

            for (ItemStack itemStack : subItems) {
                if (FluidContainerRegistry.isContainer(itemStack)) {
                    FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(itemStack);
                    ItemStack empty = FluidContainerRegistry.drainFluidContainer(itemStack);

                    if (fluidStack != null && empty != null) {
                        setEMC(itemStack, getEMC(empty) + getEMC(fluidStack.getFluid()));
                    }
                }
            }
        }

        // Stone brick handling
        double stoneBrickEmc = getEMC(Blocks.stonebrick);
        for (int i = 1; i < BlockStoneBrick.field_150141_b.length; i++) {
            setEMC(new ItemStack(Blocks.stonebrick, 1, i), stoneBrickEmc);
        }

        // Anvil handling
        double anvilEmc = getEMC(new ItemStack(Blocks.anvil, 1, 0));
        setEMC(new ItemStack(Blocks.anvil, 1, 1), anvilEmc * 0.66D);
        setEMC(new ItemStack(Blocks.anvil, 1, 2), anvilEmc * 0.33D);

        // Name tag
        double string = getEMC(Items.string);
        double paper = getEMC(Items.paper);
        setEMC(Items.name_tag, string + paper);

        if (Loader.isModLoaded("Thaumcraft")) {
            setEMC(GameRegistry.findItem("Thaumcraft", "ItemThaumonomicon"), getEMC(Blocks.bookshelf));
        }
    }
}


text:
title: "Securing Sensu"
description: "As with all software, it's important to minimize any attack surface exposed by the software. Sensu is no different. In this guide, you'll learn about the components that need to be secured (and how to do so)."
weight: 1000
version: "5.12"
product: "Sensu Go"
platformContent: false
menu:
  sensu-go-5.12:
    parent: guides
---

As with any piece of software, it is critical to minimize any attack surface exposed by the software. Sensu is no different. The following component pieces need to be secured in order for Sensu to be considered production ready:

* [etcd peer communication](#securing-etcd-peer-communication)
* [API and dashboard](#securing-the-api-and-the-dashboard)
* [Sensu agent to server communication](#securing-sensu-agent-to-server-communication)

We'll cover securing each one of those pieces, starting with etcd peer communication.

## Securing etcd peer communication

Let's start by covering how to secure etcd peer communication via the configuration at `/etc/sensu/backend.yml`. Let's look at the parameters you'll need to configure:

{{< highlight yml >}}
##
# backend store configuration
##
etcd-listen-client-urls: "https://localhost:2379"
etcd-listen-peer-urls: "https://localhost:2380"
etcd-initial-advertise-peer-urls: "https://localhost:2380"
etcd-cert-file: "/path/to/your/cert"
etcd-key-file: "/path/to/your/key"
etcd-trusted-ca-file: "/path/to/your/ca/file"
etcd-peer-cert-file: "/path/to/your/peer/cert"
etcd-peer-key-file: "/path/to/your/peer/key"
etcd-peer-client-cert-auth: "true"
etcd-peer-trusted-ca-file: "/path/to/your/peer/ca/file"
{{< /highlight >}}

## Securing the API and the dashboard

Let's go over how to secure the API and dashboard. Please note that by changing the parameters below, the server will now communicate over TLS and expect agents connecting to it to use the WebSocket secure protocol. In order for communication to continue, both this section and the [following section](#securing-sensu-agent-to-server-communication) must be completed.

Both the Sensu Go API and the dashboard use a common stanza in `/etc/sensu/backend.yml` to provide the certificate, key, and CA file needed to provide secure communication. Let's look at the attributes you'll need to configure:

{{< highlight yml >}}
##
# backend ssl configuration
##
cert-file: "/path/to/ssl/cert.pem"
key-file: "/path/to/ssl/key.pem"
trusted-ca-file: "/path/to/trusted-certificate-authorities.pem"
insecure-skip-tls-verify: false
{{< /highlight >}}

Providing the above cert-file and key-file parameters will cause the API to serve HTTP requests over
SSL/TLS (https). As a result, you will also need to specify `https://` schema
for the `api-url` parameter:

{{< highlight yml >}}
##
# backend api configuration
##
api-url: "https://localhost:8080"
{{< /highlight >}}

You can also specify a certificate and key for the dashboard separately from the API using the `dashboard-cert-file` and `dashboard-key-file` parameters as shown in the following example.

{{< highlight yml >}}
##
# backend ssl configuration
##
cert-file: "/path/to/ssl/cert.pem"
key-file: "/path/to/ssl/key.pem"
trusted-ca-file: "/path/to/trusted-certificate-authorities.pem"
insecure-skip-tls-verify: false
dashboard-cert-file: "/path/to/ssl/cert.pem"
dashboard-key-file: "/path/to/ssl/key.pem"
{{< /highlight >}}

In the example above, we provide the path to the cert, key and CA file. After restarting the `sensu-backend` service, the parameters are loaded and you are able to access the dashboard at https://localhost:3000. Configuring these attributes will also ensure that agents are able to communicate securely. Let's move on to securing agent to server communication.

## Securing Sensu agent to server communication

We'll now discuss securing agent to server communication. Please note: by changing the agent configuration to communicate via WebSocket Secure protocol, the agent will no longer communicate over a plaintext connection. If the server is not secured as described in the [section above](#securing-the-api-and-the-dashboard), communication between the agent and server will not function.

By default, an agent uses the insecure `ws://` transport. Let's look at the example from `/etc/sensu/agent.yml`:

{{< highlight yml >}}
---
##
# agent configuration
##
backend-url:
  - "ws://127.0.0.1:8081"
{{< /highlight >}}

In order to use WebSockets over SSL/TLS (wss), change the `backend-url` value to the `wss://` schema:

{{< highlight yml >}}
---
##
# agent configuration
##
backend-url:
  - "wss://127.0.0.1:8081"
{{< /highlight >}}

The agent will then connect to Sensu backends over wss. Do note that by changing the configuration to wss, plaintext communication will not be possible.

It is also possible to provide a trusted CA as part of the agent configuration by passing `--trusted-ca-file` if starting the agent via `sensu-agent start`.

You may include it as part of the agent configuration in `/etc/sensu/agent.yml` as:

{{< highlight yaml>}}
trusted-ca-file: "/path/to/trusted-certificate-authorities.pem"
{{< /highlight >}}

_NOTE: If creating a Sensu cluster, every cluster member needs to be present in the configuration. See the [Sensu Go clustering guide][2] for more information on how to configure agents for a clustered configuration._

Hopefully you've found this useful! If you find any issues or have any questions, feel free to reach out in our [Community Slack][3], or [open an issue][4] on Github.

<!-- LINKS -->
[1]: /sensu-core/latest/guides/securing-sensu/
[2]: ../clustering
[3]: https://slack.sensu.io
[4]: https://github.com/sensu/sensu-docs/issues/new


text:
fixed click behavior for older webkit browsers

## 2014-9-24
* Listening to resize of scroller instead of number of elements
* Default option preventDefualt set to false (allow clicktrhough)

## 2014-07-14
* Moved to version number 0.5.8
* Fixed bower.json of distribution package so that the ```main``` path is now a valid path
    * Fixes issue that grunt-wiredep couldn't inject angular-momentum-scroll
    * Bower package version contains now build timestamp
* Modified build process so that the minified file holds now proper license informations of angular-momentum-scroll and the used iScroll library
* Wrapped scrollable.js into an IIFE to avoid code leaking
* Source map gets now included into the distribution package
* Updated NPM and Bower dependencies
* Updated Karma test suite

## 2014-06-15
fixed check for scrollX

## 2014-01-17
fixed horizontal scroll css

## 2013-12-18
fixed $destroy

## 2013-11-30
fixed reinitialization on DOM extension
fixed accessing undefined scope vars

## 2013-10-31
fixed horizontal scroll for new iScroll parameter scrollX

## 2013-10-30
Fixed regular scroll

## 2013-10-18
migrated to iscroll 5 for better performance on Android

## 2013-09-19 v0.4.9
initialization of snappping scroll fixed

## 2013-09-16 v0.4.8
smaller fix for orientation change

## 2013-09-16 v0.4.7

## 2013-08-27 v0.4.6
Fixed horizontal scroll (css)

## 2013-06-09v0.4.4
Add isMaxX/isMinX/isMaxY/isMinY as an interface to the final TOP and bottoms positions.

## 2013-06-08 v0.4.3
Now supports X and Y coordinates of scroller

## 2013-05-17 v0.4.1
Fixed a bug with emtpy scrollers

## 2013-05-16 v0.4.0
Added two way data bound pages

## 2013-05-09 v0.3.0
Added callbacks for 'on' handles of iScroll

## 2013-05-08 v0.2.0
now supporting scrollToPage method of iScroll

## 2013-05-06 v0.1.1
Added some css hack to allow horizontal scrolling with css only. No hacky width calculations necessary


text:
Add New Event

      	<form id="addEventForm" method="post" enctype="multipart/form-data">

	         <select name="wedding_id" id="wedding_id">
			      <option value="" disabled selected>Choose your Wedding</option>
			      <?php foreach($allWeddings as $key => $allWeddingsRow){ ?>
			      <option value="<?php echo $allWeddingsRow['id']; ?>"><?php echo $allWeddingsRow['weddingName']; ?></option>
			      <?php } ?>

		     </select>
	           Name

	        	<input type="text" class="validate" required="required" name="name" id="name">
	          	Event Name

	          <input type="text" class="datepicker" name="date" id="date">
	          Date

	          <input type="text" class="timepicker validate" name="time" id="time">
	          Time

	           <input type="file" name="image" id="image" style="display:none;">
          	   <button type="button" name="image" id="image" onclick="$('#eventImage input').click()" class="btn black upload-btn"> Event Image</button>

	         <textarea  class="materialize-textarea" name="location" id="location"></textarea>
          	   Location

      	</form>


text:
<?php

namespace JsonLoader {

	class Loader {

		/**
		 * @var string The filepath of the JSON file, if loaded from a file
		 */
		var $filepath;

		/**
		 * @var Logger
		 */
		var $logger;

		/**
		 * @var self
		 */
	    static $instance;

		/**
		 * @return Loader
		 */
	    static function instance() {

			return self::$instance;

	    }

		/**
		 * @param string $filepath
		 * @param callable $class_factory
		 * @param array $args {
		 *
*@type boolean|Logger $logger
		 *      @type boolean|Object $parent
		 * }
		 * @return \JsonLoader\Object
		 */
		function load( $filepath, $class_factory, $args = array() ) {

			$args = Util::parse_args( $args, array(
				'logger' => false,
				'parent' => false,
			));

			$this->logger = $args['logger'] ? $args['logger'] : new Logger();

			$this->filepath = $filepath;

			if ( empty( $filepath ) ) {
				Util::log_error( "The filename passed was empty." );
			}

			if ( ! is_file( $filepath ) ) {
				Util::log_error( "The file {$filepath} does not exist." );
			}

			$json = file_get_contents( $filepath );

			if ( empty( $json ) ) {
				Util::log_error( "The JSON value provided is empty." );
			}

			$data = @json_decode( $json );

			if ( is_null( $data ) ) {
				Util::log_error( "The JSON file {$filepath} has invalid syntax." );
			}

			if ( ! is_callable( $class_factory ) ) {
				Util::log_error( "Class factory is not a callable." );
			}

			$object = call_user_func( $class_factory, $data, $filepath, $args );

			return $object;

		}

	}

	Loader::$instance = new Loader();

}


text:
<script>
	window.location.href = 'http://lucas.possatti.com.br/';
</script>


text:
'use strict';

const models = require('./index');

/**
 * Schedules applicable to a virtual machine. The schedules may have been
 * defined on a VM or on lab level.
 *
 * @extends models['Resource']
 */
class ApplicableSchedule extends models['Resource'] {
  /**
   * Create a ApplicableSchedule.
   * @property {object} [labVmsShutdown] The auto-shutdown schedule, if one has
   * been set at the lab or lab resource level.
   * @property {string} [labVmsShutdown.status] The status of the schedule
   * (i.e. Enabled, Disabled). Possible values include: 'Enabled', 'Disabled'
   * @property {string} [labVmsShutdown.taskType] The task type of the schedule
   * (e.g. LabVmsShutdownTask, LabVmAutoStart).
   * @property {object} [labVmsShutdown.weeklyRecurrence] If the schedule will
   * occur only some days of the week, specify the weekly recurrence.
   * @property {array} [labVmsShutdown.weeklyRecurrence.weekdays] The days of
   * the week for which the schedule is set (e.g. Sunday, Monday, Tuesday,
   * etc.).
   * @property {string} [labVmsShutdown.weeklyRecurrence.time] The time of the
   * day the schedule will occur.
   * @property {object} [labVmsShutdown.dailyRecurrence] If the schedule will
   * occur once each day of the week, specify the daily recurrence.
   * @property {string} [labVmsShutdown.dailyRecurrence.time] The time of day
   * the schedule will occur.
   * @property {object} [labVmsShutdown.hourlyRecurrence] If the schedule will
   * occur multiple times a day, specify the hourly recurrence.
   * @property {number} [labVmsShutdown.hourlyRecurrence.minute] Minutes of the
   * hour the schedule will run.
   * @property {string} [labVmsShutdown.timeZoneId] The time zone ID (e.g.
   * Pacific Standard time).
   * @property {object} [labVmsShutdown.notificationSettings] Notification
   * settings.
   * @property {string} [labVmsShutdown.notificationSettings.status] If
   * notifications are enabled for this schedule (i.e. Enabled, Disabled).
   * Possible values include: 'Enabled', 'Disabled'
   * @property {number} [labVmsShutdown.notificationSettings.timeInMinutes]
   * Time in minutes before event at which notification will be sent.
   * @property {string} [labVmsShutdown.notificationSettings.webhookUrl] The
   * webhook URL to which the notification will be sent.
   * @property {string} [labVmsShutdown.notificationSettings.emailRecipient]
   * The email recipient to send notifications to (can be a list of semi-colon
   * separated email addresses).
   * @property {string}
   * [labVmsShutdown.notificationSettings.notificationLocale] The locale to use
   * when sending a notification (fallback for unsupported languages is EN).
   * @property {date} [labVmsShutdown.createdDate] The creation date of the
   * schedule.
   * @property {string} [labVmsShutdown.targetResourceId] The resource ID to
   * which the schedule belongs
   * @property {string} [labVmsShutdown.provisioningState] The provisioning
   * status of the resource.
   * @property {string} [labVmsShutdown.uniqueIdentifier] The unique immutable
   * identifier of a resource (Guid).
   * @property {object} [labVmsStartup] The auto-startup schedule, if one has
   * been set at the lab or lab resource level.
   * @property {string} [labVmsStartup.status] The status of the schedule (i.e.
   * Enabled, Disabled). Possible values include: 'Enabled', 'Disabled'
   * @property {string} [labVmsStartup.taskType] The task type of the schedule
   * (e.g. LabVmsShutdownTask, LabVmAutoStart).
   * @property {object} [labVmsStartup.weeklyRecurrence] If the schedule will
   * occur only some days of the week, specify the weekly recurrence.
   * @property {array} [labVmsStartup.weeklyRecurrence.weekdays] The days of
   * the week for which the schedule is set (e.g. Sunday, Monday, Tuesday,
   * etc.).
   * @property {string} [labVmsStartup.weeklyRecurrence.time] The time of the
   * day the schedule will occur.
   * @property {object} [labVmsStartup.dailyRecurrence] If the schedule will
   * occur once each day of the week, specify the daily recurrence.
   * @property {string} [labVmsStartup.dailyRecurrence.time] The time of day
   * the schedule will occur.
   * @property {object} [labVmsStartup.hourlyRecurrence] If the schedule will
   * occur multiple times a day, specify the hourly recurrence.
   * @property {number} [labVmsStartup.hourlyRecurrence.minute] Minutes of the
   * hour the schedule will run.
   * @property {string} [labVmsStartup.timeZoneId] The time zone ID (e.g.
   * Pacific Standard time).
   * @property {object} [labVmsStartup.notificationSettings] Notification
   * settings.
   * @property {string} [labVmsStartup.notificationSettings.status] If
   * notifications are enabled for this schedule (i.e. Enabled, Disabled).
   * Possible values include: 'Enabled', 'Disabled'
   * @property {number} [labVmsStartup.notificationSettings.timeInMinutes] Time
   * in minutes before event at which notification will be sent.
   * @property {string} [labVmsStartup.notificationSettings.webhookUrl] The
   * webhook URL to which the notification will be sent.
   * @property {string} [labVmsStartup.notificationSettings.emailRecipient] The
   * email recipient to send notifications to (can be a list of semi-colon
   * separated email addresses).
   * @property {string} [labVmsStartup.notificationSettings.notificationLocale]
   * The locale to use when sending a notification (fallback for unsupported
   * languages is EN).
   * @property {date} [labVmsStartup.createdDate] The creation date of the
   * schedule.
   * @property {string} [labVmsStartup.targetResourceId] The resource ID to
   * which the schedule belongs
   * @property {string} [labVmsStartup.provisioningState] The provisioning
   * status of the resource.
   * @property {string} [labVmsStartup.uniqueIdentifier] The unique immutable
   * identifier of a resource (Guid).
   */
  constructor() {
    super();
  }

  /**
   * Defines the metadata of ApplicableSchedule
   *
   * @returns {object} metadata of ApplicableSchedule
   *
   */
  mapper() {
    return {
      required: false,
      serializedName: 'ApplicableSchedule',
      type: {
        name: 'Composite',
        className: 'ApplicableSchedule',
        modelProperties: {
          id: {
            required: false,
            readOnly: true,
            serializedName: 'id',
            type: {
              name: 'String'
            }
          },
          name: {
            required: false,
            readOnly: true,
            serializedName: 'name',
            type: {
              name: 'String'
            }
          },
          type: {
            required: false,
            readOnly: true,
            serializedName: 'type',
            type: {
              name: 'String'
            }
          },
          location: {
            required: false,
            serializedName: 'location',
            type: {
              name: 'String'
            }
          },
          tags: {
            required: false,
            serializedName: 'tags',
            type: {
              name: 'Dictionary',
              value: {
                  required: false,
                  serializedName: 'StringElementType',
                  type: {
                    name: 'String'
                  }
              }
            }
          },
          labVmsShutdown: {
            required: false,
            serializedName: 'properties.labVmsShutdown',
            type: {
              name: 'Composite',
              className: 'Schedule'
            }
          },
          labVmsStartup: {
            required: false,
            serializedName: 'properties.labVmsStartup',
            type: {
              name: 'Composite',
              className: 'Schedule'
            }
          }
        }
      }
    };
  }
}

module.exports = ApplicableSchedule;


text:
I was somewhat aware of most of these techniques and have used various elements of them before. I have meditated for some years (though sporadically) and certainly know the benefits of that. And I read the book "Flow" which I really liked. Flow seems to be a kind of combination of meditation and activity. I have certainly gotten into this state before and know how productive and pleasurable it can be. I do believe our modern multi-tab open, notifications filed lifestyles make it hard to get into the flow state.

Though I think one thing I learned was just this idea of micro habits, and how effective they can be. I think the one thing that has always been hardest for me is irregular time management. Working independently and having your own business creates a situation where you don't have external structures, timelines or accountability much of the time, so its hard to create your own structure and regular schedule if no one is doing that for you. Habits can help with this, but I have always had a hard time developing regular habits, many times because i try to change them all at once or in large ways. Micro habits can really help this. Learning about how to use those will be helpful.

What is "Time Boxing?" How can you use it in Phase 0?

Time boxing is the practice of creating limited and defined blocks of time to work in and stopping/ reviewing when those times are up, or taking a break. Instead of just working in undefined time until a task or project is done, you break it into concrete limited blocks of work time. I think this can be great in phase 0 to not get lost in any one task, which I am certainly capable of doing. I can also be used to not mentally tire or burn yourself out.

How do you manage your time currently?

Currently I don't really manage my time in any concrete way. Which is a problem. Mostly because my work is project based, I can from times of full on intense activity to times of nebulous or low activity.

Is your current strategy working? If not, why not?

No my current strategy doesn't work simply because it is too extreme between the pendulums. I tend to burn myself out when working on something and then being unable to get things going when I am not working on something.

Can/will you employ any of them? If so, how?

Yes I think micro habits and time blocks will be helpful. Micro habits for creating waypoints and pillars in the day to structure things around, and then time blocks for preventing burn out and allowing one to get into a flow state without distractions.

What is your overall plan for Phase 0 time management?

For phase0 I will create a series of micro morning habits that get my day started in a regular way. I will then use time blocks, and record that time to measure regular progress on tasks.

# 1.2 The Command Line Reflection

What is a shell? What is "bash?"

Shell is the command line interface to interact with the computer. Bash is the unix/osx version of shell, the command line language, I believe.

What was the most challenging for you in going through this material?

The most challenging thing was actually the typing. I need to practice and increase my typing accuracy. I do a lot of writing so I type fast but due to the leeway of autocorrect my typing is a bit sloppy.

Were you able to successfully use all of the commands?

I was able to use most all of the terminal commands, but the practice will of curse becoming fluent in them.

In your opinion, what are the most important commands and arguments to know?

It's hard to to say which shell commands might be the most important at this point. It seems like many of the more advanced ones will be replaced by programs outside of the terminal. But I think the list important ones will be the directory and navigating commands to see and locate directories and files, like cd, ls, and the maybe to search files like grep. Honestly hard to say at this point as it seems some of these might be taken over by a text editor.

Can you remember what each of the following does of the top of your head? Write what each does.

pwd - prints the directory you are currently in
ls- lists what is in side the directory you are
mv- moves the file or directory you are in
cd- move into a new directory, forward or backwards
../ - command for moving back or up a directory
touch - ???
mkdir - create a new directory
less - lets you read through a file page by page.
rmdir - remove a directory
rm - remove a file
help - get help on a term or command, I believe this is the Windows shell term, not the OS X one.

# 1.4 Forking and Cloning Reflection

What is a shell? What is "bash?"

Shell is the command line interface to interact with the computer. Bash is the unix/osx version of shell, the command line language, I believe.

What was the most challenging for you in going through this material?

The most challenging thing was actually the typing. I need to practice and increase my typing accuracy. I do a lot of writing so I type fast but due to the leeway of autocorrect my typing is a bit sloppy.

Were you able to successfully use all of the commands?

I was able to use most all of the terminal commands, but the practice will of curse becoming fluent in them.

In your opinion, what are the most important commands and arguments to know?

It's hard to to say which shell commands might be the most important at this point. It seems like many of the more advanced ones will be replaced by programs outside of the terminal. But I think the list important ones will be the directory and navigating commands to see and locate directories and files, like cd, ls, and the maybe to search files like grep. Honestly hard to say at this point as it seems some of these might be taken over by a text editor.

Can you remember what each of the following does of the top of your head? Write what each does.

pwd - prints the directory you are currently in
ls- lists what is in side the directory you are
mv- moves the file or directory you are in
cd- move into a new directory, forward or backwards
../ - command for moving back or up a directory
touch - ???
mkdir - create a new directory
less - lets you read through a file page by page.
rmdir - remove a directory
rm - remove a file
help - get help on a term or command, I believe this is the Windows shell term, not the OS X one.

# 1.5 Tracking Changes

Tracking adding changes helps developers because it allows a road map to find bugs should they arise. If at some point your code stops working, you can go back the point where it was working and then solve from there.

A commit is a save point that you can revert back to.

Commit messages should be simple, short descriptions of what changes were made. They should be written in the imperative verb tense for compatibility. If longer than one line, the message can have a title line and then a body that includes more description if necessary.

The HEAD^ argument allows you to reference, access and change files from the last commit.

The three git stages are modified, staged, and committed. Modified simply means a file has been changed. Staged means the file has been added to the stage to be committed on the next commit. And commit means it has been committed to the repository. to go from stage to stage you use the commands "git add" and "git commit".

GIT CHEAT SHEET
git add .  ==> add modified files to the stage
git commit ==> commit all the files in the staging area to the repository.
git status ==> check the current status of files and where they are in the git progression.

A pull request is used to bring a remote repository onto your local machine. Doing this will "pull" will automatically merge this with your local repository, or you can use "fetch" and then "merge".

Pull requests and working on branches are preferable when working with teams in order to ensure that people are again working in sync and to make sure that people are not working from code that hasn't been approved.

# 1.6 Your Website, part 1

http://joecase.github.io/

To create a new repository on Github, click the plus icon next to your photo on your github page, then select "New Repository". To clone the repo to your local machine, to the repo on gihub and copy the URL for the repo (SSH if you have SSH setup, HTTPS if you do not). to to terminal, navigate to the directory you want to clone the repo to and give the command "git clone" and then past the URL

Open source is the process of sharing the source code to software and making it free and open for anyone to use, change and improve upon.

I think open source is fantastic for certain things. It is a kind of utopia. Obviously it gives anyone the chance to start a project from an already rich code base, and also allows free tools to be give out to a lot of people. Obviously if I had some kind of revolutionary tech I was developing, I probably wouldn't make it open source, but I think a lot of the greatest technology advancements have come from open source software.

I guess the importance of licenses is to somehow create legal precedence, if something did arise. I think most of the time, if you are open source, you probably don't care much what license you are using. From the opposite of a protection standpoint, a license can give clear permission to anyone to help out, which they might not if they think they won't be able to use it. I think it is a simple good practice.

The pulling process was solidified. Since "pulling" goes in multiple directions I was a bit confused.

Nope, I figured it out mostly from the provided resources and I had a bit of experience with it before.


text:
import { formatRFC7231 } from 'date-fns/fp'
export default formatRFC7231


text:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="io.humio.androidlogger">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:supportsRtl="true">

    </application>

</manifest>


text: export { QT16 as default } from "../../../";


text:
<!DOCTYPE html>

  <meta charset=utf-8>
  <meta content='width=device-width' name=viewport>
  <title>Infini</title>

Accounts Payable

Company CC charges

Reimbursements

Invoices to Pay

Accounts Receivable

Update Billing Information

Payroll

Reimbursements


text: Native technologies dependency manager