text:
package pl.selvin.android.listsyncsample.ui;

import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.BaseColumns;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.loader.app.LoaderManager;
import androidx.loader.content.CursorLoader;
import androidx.loader.content.Loader;
import androidx.cursoradapter.widget.SimpleCursorAdapter;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

import com.google.android.flexbox.AlignItems;
import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexboxLayoutManager;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;

import pl.selvin.android.listsyncsample.Constants.StringUtil;
import pl.selvin.android.listsyncsample.R;
import pl.selvin.android.listsyncsample.app.CursorRecyclerViewAdapter;
import pl.selvin.android.listsyncsample.app.GenericDialogFragment;
import pl.selvin.android.listsyncsample.app.ListFragmentCommon;
import pl.selvin.android.listsyncsample.provider.Database.Item;
import pl.selvin.android.listsyncsample.provider.Database.Priority;
import pl.selvin.android.listsyncsample.provider.Database.Status;
import pl.selvin.android.listsyncsample.provider.Database.Tag;
import pl.selvin.android.listsyncsample.provider.Database.TagItemMapping;
import pl.selvin.android.listsyncsample.provider.ListProvider;
import pl.selvin.android.listsyncsample.syncadapter.SyncService;
import pl.selvin.android.listsyncsample.utils.DateTimeUtils;
import pl.selvin.android.listsyncsample.utils.SpinnerHelper;
import pl.selvin.android.listsyncsample.utils.Ui;

public class ItemDetailsFragment extends Fragment implements
        LoaderManager.LoaderCallbacks<Cursor>, GenericDialogFragment.DatePicker.Callback, GenericDialogFragment.TimePicker.Callback, View.OnClickListener {

    private static final int MAIN_LOADER_ID = 61000;
    private static final int PRIORITIES_LOADER_ID = 61001;
    private static final int STATUSES_LOADER_ID = 61002;
    private static final int TAGS_LOADER_ID = 61003;
    private static final int UNUSED_LOADER_ID = 61004;
    private EditText mName, mDescription;
    private TextView mStartDate, mStartTime, mEndDate, mEndTime;
    private SpinnerHelper mPriority, mStatus;
    private TagsAdapter mTagsAdapter;
    private Uri mItemUri;
    private String mItemID;
    private static final int spinnerRowResource = androidx.appcompat.R.layout.support_simple_spinner_dropdown_item;

    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        final View root = inflater.inflate(R.layout.item_fragment, container, false);
        mName = Ui.getView(root, R.id.name);
        mDescription = Ui.getView(root, R.id.description);
        mPriority = new SpinnerHelper(Ui.<Spinner>getView(root, R.id.priority), PRIORITIES_LOADER_ID,
                new SimpleCursorAdapter(requireActivity(), spinnerRowResource, null, new String[]{Priority.NAME},
                        new int[]{android.R.id.text1}, 1), spinnerRowResource) {
            @Override
            public Loader<Cursor> getCursorLoader() {
                return new CursorLoader(requireActivity(), ListProvider.getHelper().getDirUri(Priority.TABLE_NAME, false),
                        new String[]{BaseColumns._ID, Priority.ID, Priority.NAME}, null, null, Priority.ID + " ASC");
            }
        };

        mStatus = new SpinnerHelper(Ui.<Spinner>getView(root, R.id.status), STATUSES_LOADER_ID,
                new SimpleCursorAdapter(requireActivity(), spinnerRowResource, null, new String[]{Status.NAME},
                        new int[]{android.R.id.text1}, 1), spinnerRowResource) {
            @Override
            public Loader<Cursor> getCursorLoader() {
                return new CursorLoader(requireActivity(), ListProvider.getHelper().getDirUri(Status.TABLE_NAME, false),
                        new String[]{BaseColumns._ID, Status.ID, Status.NAME}, null, null, Status.ID + " ASC");
            }
        };

        final RecyclerView recyclerView = Ui.getView(root, R.id.tags);
        final FlexboxLayoutManager layoutManager = new FlexboxLayoutManager(getContext());
        layoutManager.setFlexDirection(FlexDirection.ROW);
        recyclerView.setLayoutManager(layoutManager);
        mTagsAdapter = new TagsAdapter(getChildFragmentManager(), SyncService.getUserId(getContext()));
        recyclerView.setAdapter(mTagsAdapter);
        mStartDate = Ui.getView(root, R.id.start_date);
        mStartTime = Ui.getView(root, R.id.start_time);
        mEndDate = Ui.getView(root, R.id.end_date);
        mEndTime = Ui.getView(root, R.id.end_time);

        mStartDate.setOnClickListener(this);
        mStartTime.setOnClickListener(this);
        mEndDate.setOnClickListener(this);
        mEndTime.setOnClickListener(this);
        return root;
    }

    @Override
    public void onResume() {
        super.onResume();
        final LoaderManager loader = LoaderManager.getInstance(this);
        mPriority.initLoader(loader);
        mStatus.initLoader(loader);
        loader.initLoader(MAIN_LOADER_ID, null, this);
    }

    private Uri getItemUri() {
        return mItemUri == null ? mItemUri = requireArguments().getParcelable(GenericDetailsActivity.ITEM_URI) : mItemUri;
    }

    @NonNull
    @Override
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        switch (id) {
            case MAIN_LOADER_ID:
                return new CursorLoader(requireContext(), getItemUri(), new String[]{Item.NAME,
                        Item.DESCRIPTION, Item.PRIORITY,
                        Item.STATUS, Item.START_DATE,
                        Item.END_DATE, Item.ID}, null, null, null);
            case TAGS_LOADER_ID:
                return new CursorLoader(requireContext(), ListProvider.getHelper().getDirUri(TagItemMapping.TagItemMappingWithNames, false), new String[]{BaseColumns._ID,
                        Tag.NAME}, TagItemMapping.ITEM_ID + "=?", new String[]{mItemID}, Tag.NAME);
            case UNUSED_LOADER_ID:
                return new CursorLoader(requireContext(), ListProvider.getHelper().getDirUri(Tag.TagNotUsed),
                        new String[]{BaseColumns._ID}, null, new String[]{mItemID}, null);
        }
        throw new RuntimeException("Unknown loader id: " + id);
    }

    @Override
    public void onLoadFinished(@NonNull Loader<Cursor> loader, Cursor cursor) {
        switch (loader.getId()) {
            case MAIN_LOADER_ID:
                if (cursor.moveToFirst()) {
                    mName.setText(cursor.getString(0));
                    mDescription.setText(cursor.getString(1));
                    mPriority.setSelectedId(cursor.getInt(2));
                    mStatus.setSelectedId(cursor.getInt(3));
                    String time = cursor.getString(4);
                    Calendar cal = null;
                    try {
                        cal = DateTimeUtils.fromLong(time);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    mStartDate.setTag(cal);
                    mStartTime.setTag(cal);
                    if(cal != null) {
                        mStartDate.setText(DateTimeUtils.toShort(cal));
                        mStartTime.setText(DateTimeUtils.toTime(cal));
                    }
                    time = cursor.getString(5);
                    cal = Calendar.getInstance();
                    try {
                        cal = DateTimeUtils.fromLong(time);
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    mEndDate.setTag(cal);
                    mEndDate.setText(DateTimeUtils.toShort(cal));
                    mEndTime.setTag(cal);
                    mEndTime.setText(DateTimeUtils.toTime(cal));
                    mItemID = cursor.getString(6);
                    mTagsAdapter.setItemId(mItemID);
                    LoaderManager.getInstance(this).initLoader(TAGS_LOADER_ID, null, this);
                    LoaderManager.getInstance(this).initLoader(UNUSED_LOADER_ID, null, this);
                } else
                    requireActivity().finish();
                break;
            case TAGS_LOADER_ID:
                mTagsAdapter.swapCursor(cursor);
                break;
            case UNUSED_LOADER_ID:
                mTagsAdapter.setNewItemVisible(cursor.moveToFirst());
                break;
        }
    }

    @Override
    public void onLoaderReset(@NonNull Loader<Cursor> loader) {
        switch (loader.getId()) {
            case TAGS_LOADER_ID:
                mTagsAdapter.changeCursor(null);
                break;
        }
    }

    @Override
    public void onClick(View v) {
        final int vId = v.getId();
        switch (vId) {
            case R.id.start_date:
            case R.id.end_date:
                GenericDialogFragment.DatePicker.newInstance(vId, (Calendar) v.getTag()).show(getChildFragmentManager(), "DATE_PICKER_TAG_" + vId);
                break;
            case R.id.start_time:
            case R.id.end_time:
                GenericDialogFragment.TimePicker.newInstance(vId, (Calendar) v.getTag()).show(getChildFragmentManager(), "TIME_PICKER_TAG_" + vId);
                break;
        }
    }

    @Override
    public boolean onAction(int ID, boolean canceled, Calendar date) {
        if (!canceled) {
            switch (ID) {
                case R.id.start_date:
                    mStartDate.setText(DateTimeUtils.toShort(date));
                    mStartDate.setTag(date);
                    mStartTime.setTag(date);
                    break;
                case R.id.end_date:
                    mEndDate.setText(DateTimeUtils.toShort(date));
                    mEndDate.setTag(date);
                    mEndTime.setTag(date);
                    break;
                case R.id.start_time:
                    mStartTime.setText(DateTimeUtils.toTime(date));
                    mStartDate.setTag(date);
                    mStartTime.setTag(date);
                    break;
                case R.id.end_time:
                    mEndTime.setText(DateTimeUtils.toTime(date));
                    mEndDate.setTag(date);
                    mEndTime.setTag(date);
                    break;
            }
        }
        return true;
    }

    @Override
    public void onPause() {
        super.onPause();
        final String name = mName.getText().toString();
        final String description = mDescription.getText().toString();
        final long priority = mPriority.Spinner.getSelectedItemId();
        final long status = mStatus.Spinner.getSelectedItemId();
        final String startDate = DateTimeUtils.toLong((Calendar) mStartDate.getTag());
        final String endDate = DateTimeUtils.toLong((Calendar) mEndDate.getTag());
        final ContentValues values = new ContentValues();
        final StringBuilder where = new StringBuilder();
        final ArrayList<String> whereArgs = new ArrayList<>(6);
        values.put(Item.NAME, name);
        where.append(Item.NAME).append("!=?");
        whereArgs.add(name);
        values.put(Item.DESCRIPTION, description);
        where.append(" OR IFNULL(").append(Item.DESCRIPTION).append(", '')!=?");
        whereArgs.add(description);
        values.put(Item.PRIORITY, priority);
        where.append(" OR ").append(Item.PRIORITY).append("!=?");
        whereArgs.add(Long.toString(priority));
        values.put(Item.STATUS, status);
        where.append(" OR ").append(Item.STATUS).append("!=?");
        whereArgs.add(Long.toString(status));
        values.put(Item.START_DATE, startDate);
        where.append(" OR IFNULL(").append(Item.START_DATE).append(", '')!=?");
        whereArgs.add(startDate);
        values.put(Item.END_DATE, endDate);
        where.append(" OR IFNULL(").append(Item.END_DATE).append(", '')!=?");
        whereArgs.add(endDate);
        requireActivity().getContentResolver().update(getItemUri(), values, where.toString(), whereArgs.toArray(new String[0]));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (requireActivity().isFinishing()) {
            final String name = mName.getText().toString();
            final String description = mDescription.getText().toString();
            //if element is new and name and description is empty - delete item
            if (ListFragmentCommon.checkIsNewElement(getItemUri()) && StringUtil.EMPTY.equals(name) && StringUtil.EMPTY.equals(description))
                requireActivity().getContentResolver().delete(getItemUri(), null, null);
        }
    }

    private static class TagsAdapter extends CursorRecyclerViewAdapter<TagsAdapter.ViewHolderBase> {
        private final FragmentManager mManager;
        private final String mUserId;
        private String mItemId;
        private boolean mNewItemVisibility = false;

        @Override
        public int getItemCount() {
            return super.getItemCount() + (mNewItemVisibility ? 1 : 0);
        }

        public int getItemViewType(int position) {
            return position == 0 && mNewItemVisibility ? R.layout.tags_row_new : R.layout.tags_row;
        }

        TagsAdapter(FragmentManager manager, String userId) {
            mManager = manager;
            mUserId = userId;
            setHasStableIds(true);
        }

        void setNewItemVisible(boolean newItemVisibility) {
            final boolean old = mNewItemVisibility;
            mNewItemVisibility = newItemVisibility;
            if (old != newItemVisibility) {
                notifyDataSetChanged();
            }
        }

        @Override
        public long getItemId(int position) {
            return position == 0 && mNewItemVisibility ? -1 : super.getItemId(realPosition(position));
        }

        @Override
        public void onBindViewHolder(ViewHolderBase viewHolder, Cursor cursor) {
            ((TextView) viewHolder.itemView).setText(cursor.getString(1));
            ViewGroup.LayoutParams lp = viewHolder.itemView.getLayoutParams();
            if (lp instanceof FlexboxLayoutManager.LayoutParams) {
                FlexboxLayoutManager.LayoutParams flexboxLp = (FlexboxLayoutManager.LayoutParams) viewHolder.itemView.getLayoutParams();
                flexboxLp.setFlexGrow(1.0f);
                flexboxLp.setAlignSelf(AlignItems.STRETCH);
            }
        }

        private int realPosition(int position) {
            return mNewItemVisibility ? position - 1 : position;
        }

        @Override
        public void onBindViewHolder(@NonNull ViewHolderBase viewHolder, int position) {
            if (position == 0 && mNewItemVisibility)
                return;
            super.onBindViewHolder(viewHolder, realPosition(position));
        }

        @NonNull
        @Override
        public ViewHolderBase onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            final View itemView = LayoutInflater.from(parent.getContext()).inflate(viewType, parent, false);
            if (viewType == R.layout.tags_row) {
                return new ItemViewHolder(itemView);
            } else {
                return new NewItemViewHolder(itemView);
            }
        }

        void setItemId(String itemId) {
            mItemId = itemId;
        }

        static abstract class ViewHolderBase extends RecyclerView.ViewHolder implements android.view.View.OnClickListener {
            ViewHolderBase(View itemView) {
                super(itemView);
                itemView.setOnClickListener(this);
            }
        }

        private class NewItemViewHolder extends ViewHolderBase {
            NewItemViewHolder(View itemView) {
                super(itemView);
            }

            @Override
            public void onClick(final View view) {
                UnusedTagListFragment.newInstance(mItemId, mUserId).show(mManager, "TAG");
            }
        }

        private static class ItemViewHolder extends ViewHolderBase {

            ItemViewHolder(View itemView) {
                super(itemView);
            }

            @Override
            public void onClick(final View view) {
                final long id = getItemId();
                view.getContext().getContentResolver().delete(ListProvider.getHelper().getDirUri(TagItemMapping.TABLE_NAME, false), "ROWID=?", new String[]{Long.toString(id)});
            }
        }
    }
}


text:
using UnityEngine;
public class MonoBehaviourSingleton<T> : MonoBehaviour where T : MonoBehaviourSingleton<T>
{
    static T m_instance;

    public static T Instance
    {
        get { return m_instance ? m_instance : m_instance = GetInstance(); }
    }

    static T GetInstance()
    {
        T[] instances = FindObjectsOfType<T>();
        if (instances.Length == 0)
        {
            Debug.Log("不存在单例:" + typeof(T) + ",立即创建一个单例");
            GameObject go = new GameObject(typeof(T).ToString());
            DontDestroyOnLoad(go);
            return go.AddComponent<T>();
        }

        if (instances.Length > 1)
        {
            Debug.Log("有多个单例: " + typeof(T) + ",返回第一个发现的");
        }
        return instances[0];
    }

    protected virtual void Awake()
    {
        if (m_instance) Debug.Log("已存在一个单例类的实例: " + typeof(T) + ",你不应该再创建它");
        else m_instance = this as T;
    }
}

redpajama_set_name: RedPajamaGithub


text:
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'

class <%= class_name %>Test < ActiveSupport::TestCase
  # Replace this with your real tests.
  def test_truth
    assert true
  end

<%- notnulls.each do |nn| %>
  def test_<%= nn %>_not_null
    assert false
  end

<% end -%>
<%- lengths.each do |nn| %>
  def test_<%= nn[0] %>_length
    assert false
  end

<% end -%>
<%- numerics.each do |nn| %>
  def test_<%= nn %>_numeric_only
    assert false
  end

<% end -%>
end


text:
package dk.itu.kelvin.util;

// General utilities
import java.util.ArrayList;
import java.util.List;

// JUnit annotations
import dk.itu.kelvin.model.Node;
import org.junit.Test;

// JUnit assertions
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * {@link PointTree} test suite.
 */
public final class PointTreeTest {
  /**
   * Test the size of tree.
   */
  @Test
  public void testSize() {
    List<Node> nodes = new ArrayList<>();
    PointTree<Node> pointTree = new PointTree<>(nodes);

    assertTrue(pointTree.isEmpty());
    nodes.add(new Node(1, 1));
    pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.size() == 1);
    for (int i = 0; i < 50; i++) {
      nodes.add(new Node(i, i * 2));
    }
    pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.size() == 51);

    for (int i = 0; i < 337; i++) {
      nodes.add(new Node(i, i * 2));
    }
    pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.size() == 388);
    assertFalse(pointTree.isEmpty());
  }

  /**
   * Test if tree contains specified element.
   */
  @Test
  public void testContains() {
    List<Node> nodes = new ArrayList<>();
    PointTree<Node> pointTree = new PointTree<>(nodes);
    assertFalse(pointTree.contains(new Node(1, 1)));
    assertFalse(pointTree.contains(null));

    nodes.add(new Node(1, 1));
    pointTree = new PointTree<>(nodes);
    assertFalse(pointTree.contains(null));

    assertTrue(pointTree.contains(new Node(1, 1)));
    for (int i = 0; i < 20; i++) {
      nodes.add(new Node(i * 2, i * 3));
    }
    pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.contains(new Node(4, 6)));
    assertTrue(pointTree.contains(new Node(8, 12)));
    assertFalse(pointTree.contains(new Node(8, 11)));
  }

  /**
   * Test elements within the range of specified bounds.
   */
  @Test
  public void testRange() {
    List<Node> nodes = new ArrayList<>();
    PointTree<Node> pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.range(null) == null);

    nodes.add(new Node(1, 1));
    pointTree = new PointTree<>(nodes);
    assertTrue(pointTree.range(null) == null);

    for (int i = 0; i < 500; i++) {
      nodes.add(new Node(i * 2, i));
    }
    pointTree = new PointTree<>(nodes);

    List<Node> result = pointTree.range(new SpatialIndex.Bounds(1, 1, 10, 10));
    List<Node> expected = new ArrayList<>();
    expected.add(new Node(1, 1));

    Node n1 = new Node(2, 1);
    n1.tag("test tag", "true");
    expected.add(n1);
    Node n2 = new Node(4, 2);
    n2.tag("test tag", "false");
    expected.add(n2);
    Node n3 = new Node(6, 3);
    n3.tag("false tag", "true");
    expected.add(n3);

    expected.add(new Node(8, 4));
    expected.add(new Node(10, 5));
    for (Node n: result) {
      assertTrue(expected.contains(n));
      expected.remove(n);
    }
    assertTrue(expected.isEmpty());

    assertTrue(pointTree.range(
      new SpatialIndex.Bounds(1, 1, 1 , 1), null
    ) == null);
    assertTrue(pointTree.range(null, null) == null);
    assertTrue(pointTree.range(null, (element) -> {
      return element.tags().containsKey("test tag");
    }) == null);

    result = pointTree.range(
      new SpatialIndex.Bounds(1, 1, 10, 10),
      (element) -> {
        return element.tags().containsKey("test tag");
      }
    );
    expected.clear();
    expected.add(n1);
    expected.add(n2);
    for (Node n: result) {
      assertTrue(expected.contains(n));
      expected.remove(n);
    }
    expected.isEmpty();
  }

  /**
   * Test the if important methods work when bucket_max is transcended.
   */
  @Test
  public void testBucket() {
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < 2049; i++) {
      nodes.add(new Node(i, i));
    }

    PointTree<Node> pointTree = new PointTree<>(nodes);
    // Bug, when the PointTree size exceed Maximum Bucket size(2048) the
    // contains method doesn't work.
    assertFalse(pointTree.contains(new Node(75, 75)));

    assertFalse(pointTree.contains(new Node(75, 74)));
    List<Node> expected = new ArrayList<>();
    List<Node> result = pointTree.range(
            new SpatialIndex.Bounds(49, 50, 51, 80));
    assertTrue(pointTree.range(null) == null);

    expected.add(new Node(50, 50));
    expected.add(new Node(51, 51));
    for (Node n: result) {
      assertTrue(expected.contains(n));
      expected.remove(n);
    }
    expected.isEmpty();

    assertTrue(pointTree.range(new SpatialIndex.Bounds(1, 1, 1, 1)) != null);
  }

  /**
   * Test the if important methods work when bucket_max is transcended.
   */
  @Test
  public void testBucket2() {
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < 7500; i++) {
      nodes.add(new Node(i * 5 - 2, i * 4 + 3));
    }

    Node n1 = new Node(1902, 4600);
    Node n2 = new Node(5001, 4600);
    n1.tag("key", "test value");
    n1.tag("key2", "test multi-tags");
    n2.tag("key3", "test multi-tags");
    nodes.add(n1);
    nodes.add(n2);

    PointTree<Node> pointTree = new PointTree<>(nodes);

    List<Node> result = pointTree.range(
      new SpatialIndex.Bounds(1901, 1800, 5001, 4601),
      (element) -> {
        return element.tags().containsValue("test multi-tags");
      }
    );
    List<Node> expected = new ArrayList<>();
    expected.add(n1);
    expected.add(n2);
    for (Node n: result) {
      assertTrue(expected.contains(n));
    }

    result = pointTree.range(
      new SpatialIndex.Bounds(1901, 1800, 5001, 4601),
      (element) -> {
        return element.tags().containsValue("test value");
      }
    );
    assertTrue(result.contains(n1));
    assertFalse(result.contains(n2));
  }
}


text: export { default } from 'ember-flexberry-gis/components/markers-styles/image';


text:
<!DOCTYPE html>

    <meta charset="utf-8" />
    <title>angular-pickr example</title>
    <link rel="stylesheet" type="text/css" href="../bower_components/pickr/dist/pickr.css">

      <input pickr="{allowPastDays:false}" ng-model="testModel" />

Inline Pickr


text:
@ECHO OFF
CD /D %~dp0

CALL Pack-SqlServer.bat

CALL Pack-Oracle-ODP.NET.Managed.bat

CALL Pack-Oracle-ODP.NET.bat

CALL Pack-Oracle-DataDirect.bat


text:
/**
 * @namespace ForwardRate

 * @memberof module:api
 */

import { retrieve } from './forwardrate'
export { retrieve }


text:
(function (wquery) {
  var divId = '#route-authors';

  function updateTable(response) {
    var authors = response.data;
    wquery.empty(divId + ' tbody');
    authors.forEach(function(author) {
      var rows = [author.name, author.email, author.key];
      rows.push(app.createButtons(['edit', 'delete'], author.id));
      app.addRow(rows, divId);
    });

    // handle Actions
    app.tableButtonHandler(divId, [
      {id: 'edit', handler: app.editHelper},
      {id: 'delete', handler: deleteAuthor}
    ]);

    delete response.data;
    app.setFooter(divId, response, authorsLoader);
  }

  function deleteAuthor(e) {
    app.deleteHelper('/author', 'Author', e, function(remove) {
      if (remove.success) {
        updateTable(remove);
      }
    });
  }

  function authorsLoader(e) {
    app.getPageAndSizeData(e, '/author', function(data) {
      if (data.success) {
        updateTable(data);
      }
    });
  }

  app.authorsHandler = function() {
    app.newPageHelper(divId);
    authorsLoader();
  }
})(_WQ);


text:
% Created 2017-08-23 Wed 13:10
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage[left=1in,right=1in,bottom=1in,top=1in]{geometry}
\date{Fall 2017}
\title{PSYC 3330: Elementary Statistics for the Behavioral Sciences}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 25.2.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle

\section*{Contact info}
\label{sec-1}
\begin{itemize}
\item Professor: Thomas J. Faulkenberry, Ph.D
\item Office: Math 319
\item Office hours: MTWRF 1-3 pm
\item Email: faulkenberry@tarleton.edu
\item Website: \url{http://tomfaulkenberry.github.io}
\item Phone: 254-968-9816
\end{itemize}

\section*{Course description}
\label{sec-2}

Statistical methods are the primary tool for research in psychology.
They are what allow us as researchers to make consistent, data-driven
decisions.  As such, this is an extremely important course and one that I
take very seriously as your professor.

The topics we will cover this semester will include descriptive statistics
(how we describe data) and inferential statistics (how we make decisions
about data).  Specifically, this includes central tendency, variability,
correlation, the distinction between populations and samples, hypothesis
testing, statistical significance, and a variety of inferential tests
that we can apply to data, including t-tests and analysis of variance.

\section*{Course materials}
\label{sec-3}
\begin{itemize}
\item \emph{Statistics for the Behavioral Sciences (10th ed.)} by Gravetter and Wallnau \href{http://www.amazon.com/Statistics-Behavioral-Sciences-MindTap-Psychology/dp/1305504917/}{Amazon link}
\item Note:  older editions of this textbook are just fine.  Please feel free to find a used copy of an older edition on Amazon; it will save you a LOT of money!
\end{itemize}

\section*{Student learning outcomes}
\label{sec-4}
\begin{enumerate}
\item Identify variables under study (including independent and dependent variables)
\item Choose appropriate measures of descriptive statistics
\item Select and perform appropriate inferential statistics
\item Draw appropriate statistical conclusions from results of analyses
\end{enumerate}

\section*{Requirements and grading}
\label{sec-5}
\begin{itemize}
\item Exam 1 (100 pts)
\item Exam 2 (100 pts)
\item Exam 3 (100 pts)
\item Final exam (100 pts)
\item Unit quizzes (100 pts)
\item \emph{Total = 500 points}
\end{itemize}

Grades will be assigned based on the percentage of points you accumulate out of these 600 points.  I will use the standard grading scale of A=90\%, B=80\%, etc.

\subsection*{Exams (80\% of grade)}
\label{sec-5-1}
There will be four total exams throughout the semester, occurring approximately once every three to four weeks.  They will cover material from lectures, quizzes, and homework exercises.  Exam questions will be a mix of multiple choice and short answer.  Exams are due by 11:59 pm on their due date.  Each exam will have a time limit (2 hours) and may only be attempted once.

Due dates:

\begin{itemize}
\item Exam 1 (Sunday, September 24 at 11:59 pm)
\item Exam 2 (Sunday, October 22 at 11:59 pm)
\item Exam 3 (Sunday, December 3 at 11:59 pm)
\item Final exam (Sunday, December 10 at 11:59 pm)
\end{itemize}

\subsection*{Unit quizzes (20\% of grade)}
\label{sec-5-2}
At the end of each unit, you will complete a 20-question quiz over the content of that unit.  The quizzes will have a generous time limit (60 minutes), and may be attempted twice.  In the event that you complete two attempts, your last graded attempt is the one that will be recorded.  Each quiz counts for 10 possible points.  Since there are 10 units, you will earn up to 100 points for your quiz grade.

\section*{Course Communication}
\label{sec-6}

Email is the primary means of communication for this course.  If you have questions about the course, always feel free to send me an email at faulkenberry@tarleton.edu.  I only ask that you adhere to two guidelines:
\begin{itemize}
\item please include the course number (PSYC 3330) in the subject line.  For example, one good way to do this is:  Subject: [PSYC 3330] Question about Exam 2
\item please use proper email etiquette.  Include a salutation (e.g., Dear Dr. Faulkenberry), complete sentences, and a closing (e.g., "Regards, Your Name").  You might be surprised how many times I get an email from a nondescript email address with no indication from WHOM the email was sent!
\end{itemize}

Also, I will be sending periodic emails to each of you that update you on course progress, due dates, etc.  It is imperative that you check your \emph{Tarleton email address} regularly so that you don't miss any of these messages.

\section*{University Policy on "F" Grades}
\label{sec-7}
Beginning in Fall 2015, Tarleton will begin differentiating between a failed grade in a class because a student never attended (F0 grade), stopped attending at some point in the semester (FX grade), or because the student did not pass the course (F) but attended the entire semester. These grades will be noted on the official transcript. Stopping or never attending class can result in the student having to return aid monies received.  For more information see the Tarleton Financial Aid website.

\section*{Academic Honesty}
\label{sec-8}

Tarleton State University expects its students to maintain high standards of personal and scholarly conduct. Students guilty of academic dishonesty are subject to disciplinary action. Cheating, plagiarism (submitting another person's materials or ideas as one's own), or doing work for another person who will receive academic credit are all disallowed. This includes the use of unauthorized books, notebooks, or other sources in order to secure of give help during an examination, the unauthorized copying of examinations, assignments, reports, or term papers, or the presentation of unacknowledged material as if it were the student's own work. Disciplinary action may be taken beyond the academic discipline administered by the faculty member who teaches the course in which the cheating took place.

In particular, any exam taken online must be completed without the aid of any unauthorized resource (including using any search engine, Google, etc.).  Authorized resources are limited only to the official textbook and any lecture notes from the course.  Any other authorized resources will be provided to you before the exam.  The minimum sanction for violation of this policy is a grade of 0 on the affected exam.

Each student's honesty and integrity are taken for granted. However, if I find evidence of academic misconduct I will pursue the matter to the fullest extent permitted by the university. ACADEMIC MISCONDUCT OR DISHONESTY WILL RESULT IN A GRADE OF F FOR THE COURSE.  Students are strongly advised to avoid even the \emph{appearance} of academic misconduct.

\section*{Academic Affairs Core Value Statements}
\label{sec-9}

\subsection*{Academic Integrity Statement}
\label{sec-9-1}
Tarleton State University's core values are integrity, leadership, tradition, civility, excellence, and service.  Central to these values is integrity, which is maintaining a high standard of personal and scholarly conduct.  Academic integrity represents the choice to uphold ethical responsibility for one's learning within the academic community, regardless of audience or situation.

\subsection*{Academic Civility Statement}
\label{sec-9-2}
Students are expected to interact with professors and peers in a respectful manner that enhances the learning environment. Professors may require a student who deviates from this expectation to leave the face-to-face (or virtual) classroom learning environment for that particular class session (and potentially subsequent class sessions) for a specific amount of time. In addition, the professor might consider the university disciplinary process (for Academic Affairs/Student Life) for egregious or continued disruptive behavior.

\subsection*{Academic Excellence Statement}
\label{sec-9-3}
Tarleton holds high expectations for students to assume responsibility for their own individual learning. Students are also expected to achieve academic excellence by:
\begin{itemize}
\item honoring Tarleton's core values, upholding high standards of habit and behavior.
\item maintaining excellence through class attendance and punctuality, preparing for active participation in all learning experiences.
\item putting forth their best individual effort.
\item continually improving as independent learners.
\item engaging in extracurricular opportunities that encourage personal and academic growth.
\item reflecting critically upon feedback and applying these lessons to meet future challenges.
\end{itemize}

\section*{Students with Disabilities Policy}
\label{sec-10}

It is the policy of Tarleton State University to comply with the Americans with Disabilities  Act (www.ada.gov) and other applicable laws.  If you are a student with a disability seeking accommodations for this course, please contact the Center for Access and Academic Testing, at 254.968.9400 or caat@tarleton.edu. The office is located in Math 201. More information can be found at www.tarleton.edu/caat or in the University Catalog.

\textbf{Note:  any changes to this syllabus will be communicated to you by the instructor!}

\section*{Semester Schedule}
\label{sec-11}
\begin{center}
\begin{tabular}{rll}
Unit & Topic & Due date\\
\hline
1 & Displaying data & Sunday, Sept 3\\
2 & Descriptives 1: central tendency, variation, and z-scores & Sunday, Sept 10\\
3 & Descriptives 2: correlation & Sunday, Sept 17\\
 & \textbf{Exam 1} & Sunday, Sept 24\\
4 & The normal distribution: measuring likelihood & Sunday, Oct 1\\
5 & The logic of hypothesis testing & Sunday, Oct 8\\
6 & Testing means of samples of \textbf{known} populations: $z$-tests & Sunday, Oct 15\\
 & \textbf{Exam 2} & Sunday, Oct 22\\
7 & Testing means of samples of \textbf{unknown} populations: $t$-tests & Sunday, Oct 29\\
8 & More $t$-tests (independent samples, etc.) & Sunday, Nov 5\\
9 & Analysis of variance (ANOVA): one independent variable & Sunday, Nov 12\\
10 & Analysis of variance (ANOVA): two independent variables & Sunday, Nov 19\\
 & \textbf{Exam 3} & Sunday, Dec 3\\
 & \textbf{Final exam} & Sunday, Dec 10\\
\end{tabular}
\end{center}
% Emacs 25.2.1 (Org mode 8.2.10)
\end{document}


text:
/**
* Used for helpful debugging info.
*
* @type Boolean Weather to show events when bad stuff happens.
*/
Debugging = true;
/**
* ScannerDevice library to listen and set options to the Linea device. Note that you must then register the object after it's been
* constructed or no events will be passed to function.
*
* @param {Object} mappings If you wish to set listeners, you do it here by passing the listener function here.
* @example DeviceObject = ScannerDevice({
	barcodeData: function (data, bar_type){
		alert('Barcode scanned with with data: '+data+' and of type: '+bar_type);
	},
	magneticCardData: function (track1, track2, track3){
		alert('Card read with following data: '+track1+'\n'+track2+'\n'+track3);
	},
	magneticCardRawData: function (data){
		alert('Raw data read from card reader: '+data);
	},
	buttonPressed: function (button){
		// Currently device only registers 1 button.
		alert('Button was pressed');
	},
	buttonReleased: function (button){
		// Currently device only registers 1 button.
		alert('Button was released');
	},
	connectionState: function (state){
		alert('Scanner is now in state: '+state);
	}
});
ScannerDevice.registerListener(Device);
* @namespace ScannerDevice
* @constructor
*/
ScannerDevice = function (mappings){
	/* BEGIN PRIVATE VARS */
	/**
	* Used to save memory by using the same ref for every empty function
	* instead of createing a new instance every time
	* @ignore
	*/
	var emptyFn = function (){};
	/**
	* Used as a default callback if none is specified. Used only for error
	* callback.
	*
	* @param {Array} params Error returned by cordova or scanner.
	* @ignore
	*/
	var emptyErrFn = function (params){
		if(Debugging)
			alert(params);
	};
	/* END PRIVATE VARS */
	/**
	* Helper function to return the constant name of a barcode by it's ID.
	* *Note this function only works for non extended barcodes.
	*
	* @param {Int} barcode_id Barcode ID.
	* @returns {String|Null} Constant name of barcode if exists.
	*/
	this.getBarcodeConstName = function(barcode_id){
		barcode_id = parseInt(barcode_id);
		var i;
		for(i in ScannerDevice.CONSTANTS.BAR_TYPES){
			if(ScannerDevice.CONSTANTS.BAR_TYPES[i] == barcode_id){
				return i;
			}
		}
		return null;
	};
	/**
	* @see ScannerDevice#unregisterListener
	*/
	this.destroy = function (){
		ScannerDevice.unregisterListener(this);
	};
	/**
	* Sends a command though cordova to the Linea Device. See each individual functions
	* for available commands
	*
	* @param {String} command Command to send to device.
	* @param {Array} args Arguments to send along with command.
	* @param {Function} callback Success callback function. Callback contains 1 arguments containing an array of arguments.
	* @param {Function} errorCallback Error callback function. Callback contains 1 arguments containing an array of arguments.
	*/
	this.sendCommand = function (command, args, callback, errorCallback){
		switch(command){
			case 'enableBarcode':
				ScannerDevice.lastSettings.barcodeStatus[parseInt(args[0])] = args[1] ? true : false;
				break;
			case 'playSound': break;
			case 'startScan':
				ScannerDevice.LAZER_ON = true;
				break;
			case 'stopScan':
				ScannerDevice.LAZER_ON = false;
				break;
			case 'setScanMode':
				ScannerDevice.lastSettings.SCAN_MODE = parseInt(args[0]);
				break;
			case 'setScanBeep':
				ScannerDevice.lastSettings.SCAN_BEEP_ENABLED = args[0] ? true : false;
				ScannerDevice.lastSettings.SCAN_BEEP = args[2];
				break;
			case 'setScanButtonMode':
				ScannerDevice.lastSettings.BUTTON_ENABLED = args[0] ? true : false;
				break;
			case 'setMSCardDataMode':
				ScannerDevice.lastSettings.MS_MODE = parseInt(args[0]);
				break;
			case 'setBarcodeTypeMode':
				ScannerDevice.lastSettings.BARCODE_TYPE = parseInt(args[0]);
				break;
			case 'getBatteryCapacity': break;
			case 'getBatteryVoltage': break;
			case 'isBarcodeEnabled': break;
			case 'isBarcodeSupported': break;
			case 'getMSCardDataMode': break;
			case 'getCharging': break;
			case 'setCharging':
				ScannerDevice.lastSettings.CHARGING = args[0] ? true : false;
				break;
			case 'getSyncButtonMode': break;
			case 'msProcessFinancialCard': break;
			case 'getBarcodeTypeMode': break;
			case 'barcodeEnginePowerControl':
				ScannerDevice.lastSettings.BARCODE_ENGINE_POWER = args[0] ? true : false;
				break;
			case 'barcodeType2Text': break;
			case 'getConnectionState': break;
		}
		if(ScannerDevice.allowedFunctions.indexOf(command) == -1){
			if(Debugging)
				alert('Command not found: '+command);
			return false;
		}
		cordova.exec(callback || emptyFn, errorCallback || emptyErrFn, "LineaDevice", command, args || []);
		return true;
	};
	/**
	* Enables or Disables a single barcode by it's ID.
	* @param {Int} Integer of barcode enableing/disableing (see ScannerDevice.CONSTANTS.BAR_TYPES for mappings).
	* @param {Boolean} enabled To enable or disable barcode.
	*/
	this.enableBarcode = function (barcode, enabled){
		this.sendCommand('enableBarcode', [barcode, enabled]);
	};
	/**
	* Plays a sound from the linea device.
	*
	* @param {Array} sounds Sound to play. This can be in the following formats: [frequency,duration,frequency,duration,...] or [[frequency,duration], [frequency,duration], ...] or [{frequency: xxx, duration: xxx}, {frequency: xxx, duration: xxx}, ...]
	* 	Note: This argument cannot exceed 5 sounds at a time (10 array elements).
	*/
	this.playSound = function (sounds){
		if(!(sounds instanceof Array)){
			return false;
		}
		var newSounds = [];
		for(var i=0;i<sounds.length;i++){
			if(sounds[i] instanceof Array){
				newSounds.push(parseInt(sounds[i][0] || 0));
				newSounds.push(parseInt(sounds[i][1] || 0));
			}else if(sounds[i] instanceof Object){
				newSounds.push(parseInt(sounds[i].frequency || 0));
				newSounds.push(parseInt(sounds[i].duration || 0));
			}else{
				newSounds.push(parseInt(sounds[i] || 0));
				newSounds.push(parseInt(sounds[i+1] || 0));
				i++;
			}
		}
		this.sendCommand('playSound', [100, newSounds]);
	};
	/**
	* Starts the scanner on device.
	*/
	this.startScan = function (){
		this.sendCommand('startScan');
	};
	/**
	* Stops the scanner on device. (if scanning)
	*/
	this.stopScan = function (){
		this.sendCommand('stopScan');
	};
	/**
	* Sets if the scanner will remain active after scanning barcode.
	*
	* @param {Int} mode Mode to scan in. See: ScannerDevice.CONSTANTS.MODE_*
	*/
	this.setScanMode = function (mode){
		this.sendCommand('setScanMode', [mode]);
	};
	/**
	* Sets the beep for when a barcode is scanned.@argument
	*
	* @param {Boolean} enabled Weather scanner beep is enabled or not.
	* @param {Array} See ScannerLibrary#playSound for more info.
	*/
	this.setScanBeep = function (enabled, sounds){
		if(!sounds instanceof Array){
			return false;
		}
		var newSounds = [];
		for(var i=0;i<sounds.length;i++){
			if(sounds[i] instanceof Array){
				newSounds.push(parseInt(sounds[i][0] || 0));
				newSounds.push(parseInt(sounds[i][1] || 0));
			}else if(sounds[i] instanceof Object){
				newSounds.push(parseInt(sounds[i].frequency || 0));
				newSounds.push(parseInt(sounds[i].duration || 0));
			}else{
				newSounds.push(parseInt(sounds[i] || 0));
				newSounds.push(parseInt(sounds[i+1] || 0));
				i++;
			}
		}
		this.sendCommand('setScanBeep', [enabled ? true : false, 100, newSounds]);
	};
	/**
	* Sets if the button is enabled or disabled on the scanner.
	*
	* @param {Boolean} enabled Weather to enable or disable the button.
	*/
	this.setScanButtonMode = function (enabled){
		this.sendCommand('setScanButtonMode', [enabled ? true : false]);
	};
	/**
	* Sets the mode for the card swipper.
	*
	* @param {Int} Mode to put the swipper in. See: ScannerDevice.CONSTANTS.MS_* for availale options.
	*/
	this.setMSCardDataMode = function (mode){
		this.sendCommand('setScanButtonMode', [mode]);
	};
	/**
	* Sets the mode to receive the barcodes in.
	*
	* @param {Int} type The mode to receive the barcodes in. See: ScannerDevice.CONSTANTS.BARCODE_TYPE_*
	*/
	this.setBarcodeTypeMode = function (type){
		this.sendCommand('setBarcodeTypeMode', [type]);
	};
	/**
	* Retrieves the battery capacity in percent of Linea device.
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var percent = params[0]; }
	*/
	this.getBatteryCapacity = function (callback){
		this.sendCommand('getBatteryCapacity', [], function (params){
			callback(params[0]);
		});
	};
	/**
	* Gets the voltage of the battery.
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var voltage = params[0]; }
	*/
	this.getBatteryVoltage = function (callback){
		this.sendCommand('getBatteryVoltage', [], function (params){
			callback(params[0]);
		});
	};
	/**
	* Check weather barcode is enabled or not.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var enabled = params[0]; }
	* @param {Int} barcode Barcode to check if enabled. See ScannerDevice.CONSTANTS.BAR_TYPES.* for available values.
	*/
	this.isBarcodeEnabled = function (callback, barcode){
		this.sendCommand('isBarcodeEnabled', [barcode], function (params){
			callback(params[0]);
		});
	};
	/**
	* Checks if barcode is supported.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var supported = params[0]; }
	* @param {Int} barcode Barcode to check if supported. See ScannerDevice.CONSTANTS.BAR_TYPES.* for available values.
	*/
	this.isBarcodeSupported = function (callback, barcode){
		this.sendCommand('isBarcodeSupported', [barcode], function (params){
			callback(params[0]);
		});
	};
	/**
	* Checks if device is charging.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var charging = params[0]; }
	*/
	this.getCharging = function (callback){
		this.sendCommand('getCharging', [], function (params){
			callback(Boolean(paseInt(params[0])));
		});
	};
	/**
	* Set if you wish to charge iphone/ipod/ipad.
	*
	* @param {Boolean} enabled Weather to enable or disable charging.
	*/
	this.setCharging = function (enabled){
		this.sendCommand('setCharging', [enabled ? true : false]);
	};
	/**
	* Retreives the sync button mode (Very little documentation is given on this, so I am not even sure what it does.)
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var sync_mode = params[0]; }
	*/
	this.getSyncButtonMode = function (callback){
		this.sendCommand('getSyncButtonMode', [], function (params){
			callback(parseInt(params[0]));
		});
	};
	/**
	* Tries to process credit card info from a swipped card.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) {
				var accountNumber = params[0].accountNumber,
					cardholderName = params[0].cardholderName,
					discretionaryData = params[0].discretionaryData,
					exirationMonth = params[0].exirationMonth,
					exirationYear = params[0].exirationYear,
					firstName = params[0].firstName,
					lastName = params[0].lastName,
					serviceCode = params[0].serviceCode;
			}
	* @param {String} track1 Data from track1.
	* @param {String} track2 Data from track2.
	* @param {String} track3 Data from track3.
	*/
	this.msProcessFinancialCard = function (callback, track1, track2, track3){
		this.sendCommand('msProcessFinancialCard', [track1 || '', track2 || '', track3 || ''], function (params){
			callback(params[0]);
		});
	};
	/**
	* Gets the mode cards are received in. See: ScannerDevice.CONSTANTS.MS_* for more info.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var mode = params[0]; }
	*/
	this.getMSCardDataMode = function (callback){
		this.sendCommand('getMSCardDataMode', [], function (params){
			callback(params[0]);
		});
	};
	/**
	* Gets the mode barcodes will be scanned in. See: ScannerDevice.CONSTANTS.BARCODE_TYPE_*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var bar_type_mode = params[0]; }
	*/
	this.getBarcodeTypeMode = function (type, callback){
		this.sendCommand('getBarcodeTypeMode', [], function (){
			callback(params[0]);
		});
	};
	/**
	* You can turn the barcode engine off with this function. When the engine is turned back on it may take up to 2 seconds for device to be
	* responsive again. (Don't play with this unless you know what you are doing.)
	*
	* @param {Boolean} enabled Weather to enable or disable engine.
	*/
	this.barcodeEnginePowerControl = function (enabled){
		this.sendCommand('barcodeEnginePowerControl', []);
	};
	/**
	* Helper function to get the name of barcodes by their code.
	*
	* @param {Int} type Barcode type to get name. See: ScannerDeice.CONSTANTS.BAR_TYPES.* for available barcodes.
	*/
	this.barcodeType2Text = function (type, callback){
		this.sendCommand('barcodeType2Text', [], function (params){
			callback(params[0]);
		});
	};
	/**
	* Gets the connection state of the device.
	*
	* @param {Function} callback Callback to execute after info is received. Example: function (params) { var state = params[0]; } // See ScannerDevice.CONSTANTS.CONN_*
	*/
	this.getConnectionState = function (callback){
		this.sendCommand('getConnectionState', [], function (params){
			callback(params[0]);
		});
	}
	var i;
	for(i in mappings){
		if(ScannerDevice.allowedCallbacks.indexOf(i) != -1 && mappings[i] && mappings[i] instanceof Function){
			this[i] = mappings[i];
		}
	}
};
/**
* Deligate functions device will automatically execute when an event happens.
*/
ScannerDevice.allowedCallbacks = [
	'barcodeData',
	'magneticCardData',
	'magneticCardRawData',
	'buttonPressed',
	'buttonReleased',
	'connectionState'
];
/**
* Allowed functions that scanner accepts.
*/
ScannerDevice.allowedFunctions = [
	'enableBarcode',
	'playSound',
	'startScan',
	'stopScan',
	'setScanMode',
	'setScanBeep',
	'setScanButtonMode',
	'setMSCardDataMode',
	'setBarcodeTypeMode',
	'getBatteryCapacity',
	'getBatteryVoltage',
	'isBarcodeEnabled',
	'isBarcodeSupported',
	'getMSCardDataMode',
	'getCharging',
	'setCharging',
	'getSyncButtonMode',
	'msProcessFinancialCard',
	'getBarcodeTypeMode',
	'barcodeEnginePowerControl',
	'barcodeType2Text',
	'getConnectionState',
];
/**
* List of objects listeneing on device.
*
* @static
* @private
*/
ScannerDevice.listeners = [];
/**
* Registers a listener to device.
*
* @param {ScannerDevice} obj ScannerDevice object to listen to device on.
* @static
*/
ScannerDevice.registerListener = function (obj){
	if(obj instanceof ScannerDevice){
		var i = 0,
			objs = ScannerDevice.listeners,
			len = objs.length;
		for(;i<len;i++){
			if(objs[i] === obj){
				return false; // Already assigned
			}
		}
		ScannerDevice.listeners.push(obj);
		return true;
	}else{
		return false;
	}
};
/**
* Unregisters a listener to device.
*
* @param {ScannerDevice} obj ScannerDevice object to unregister with library.
*/
ScannerDevice.unregisterListener = function (obj){
	if(obj instanceof ScannerDevice){
		var i = 0,
			objs = ScannerDevice.listeners,
			len = objs.length;
		for(;i<len;i++){
			if(objs[i] === obj){
				objs.splice(i, 1);
				return true;
			}
		}
		return false;
	}else{
		return false;
	}
};
/**
* Master function to listen to events. Do not override this unless you wish to write your own library.
*
* @param {Array} params Params passed from device.
* @static
* @private
*/
ScannerDevice.triggerEvent = function (params){
	var event = params[0],
		listeners = ScannerDevice.listeners,
		len = listeners.length, i, obj, args = [], emptyFn = function (){},
		emptyErrFn = function (params){
			if(window.Debugging)
				alert(params);
		};
	if(!event || ScannerDevice.allowedCallbacks.indexOf(event) == -1){
		return false;
	}
	switch(event){
		case 'connectionState':
			ScannerDevice.CONNECTION_STATE = parseInt(params[1]); // Set local Connection state variable
			break;
		case 'buttonPressed':
			if(ScannerDevice.lastSettings.BUTTON_ENABLED == ScannerDevice.CONSTANTS.BUTTON_ENABLED){
				ScannerDevice.LAZER_ON = true;
			}
			ScannerDevice.BUTTON_PRESSED = true;
			break;
		case 'buttonReleased':
			if(ScannerDevice.lastSettings.BUTTON_ENABLED == ScannerDevice.CONSTANTS.BUTTON_ENABLED){
				ScannerDevice.LAZER_ON = false;
			}
			ScannerDevice.BUTTON_PRESSED = false;
	}
	for(i=1;i<params.length;i++){
		args.push(params[i]);
	}
	for(i=0;i<len;i++){
		obj = listeners[i];
		if(obj[event] && obj[event] instanceof Function){
			try{
				obj[event].apply(obj[event], args);
			}catch(e){
				if(Debugging){
					alert(e);
				}
			}
		}
	}
	if(event == 'connectionState'){
		if(ScannerDevice.CONNECTION_STATE == ScannerDevice.CONSTANTS.CONN_CONNECTED){
			cordova.exec(emptyFn, emptyErrFn, "LineaDevice", 'configureAllSettings', [ScannerDevice.lastSettings]);
		}
	}
};
/**
* Usefull constants.
* @static
*/
ScannerDevice.CONSTANTS = {
	/* BEGIN CONN STATES */
	CONN_DISCONNECTED: 0,
	CONN_CONNECTING: 1,
	CONN_CONNECTED: 2,
	/* END CONN STATES */
	/* BEGIN SCAN MODES */
	MODE_SINGLE_SCAN: 0,
	MODE_MULTI_SCAN: 1,
	/* END SCAN MODES */
	/* BEGIN BUTTON STATES */
	BUTTON_DISABLED:0,
	BUTTON_ENABLED:1,
	/* END BUTTON STATES */
	/* BEGIN MS MODES */
	MS_PROCESSED_CARD_DATA:0,
	MS_RAW_CARD_DATA:1,
	/* BEGIN BARCODE TYPES MODE */
	BARCODE_TYPE_DEFAULT:0,
	BARCODE_TYPE_EXTENDED:1,

	/* BEGIN BARCODE TYPES */
	BAR_TYPES: {
		BAR_ALL: 0,
		BAR_UPC: 1,
		BAR_CODABAR: 2,
		BAR_CODE25_NI2OF5: 3,
		BAR_CODE25_I2OF5: 4,
		BAR_CODE39: 5,
		BAR_CODE93: 6,
		BAR_CODE128: 7,
		BAR_CODE11: 8,
		BAR_CPCBINARY: 9,
		BAR_DUN14: 10,
		BAR_EAN2: 11,
		BAR_EAN5: 12,
		BAR_EAN8: 13,
		BAR_EAN13: 14,
		BAR_EAN128: 15,
		BAR_GS1DATABAR: 16,
		BAR_ITF14: 17,
		BAR_LATENT_IMAGE: 18,
		BAR_PHARMACODE: 19,
		BAR_PLANET: 20,
		BAR_POSTNET: 21,
		BAR_INTELLIGENT_MAIL: 22,
		BAR_MSI: 23,
		BAR_POSTBAR: 24,
		BAR_RM4SCC: 25,
		BAR_TELEPEN: 26,
		BAR_PLESSEY: 27,
		BAR_PDF417: 28,
		BAR_MICROPDF417: 29,
		BAR_DATAMATRIX: 30,
		BAR_AZTEK: 31,
		BAR_QRCODE: 32,
		BAR_MAXICODE: 33,
		BAR_LAST: 34,

		BAR_EX_ALL: 0,
		BAR_EX_UPCA: 1,
		BAR_EX_CODABAR: 2,
		BAR_EX_CODE25_NI2OF5: 3,
		BAR_EX_CODE25_I2OF5: 4,
		BAR_EX_CODE39: 5,
		BAR_EX_CODE93: 6,
		BAR_EX_CODE128: 7,
		BAR_EX_CODE11: 8,
		BAR_EX_CPCBINARY: 9,
		BAR_EX_DUN14: 10,
		BAR_EX_EAN2: 11,
		BAR_EX_EAN5: 12,
		BAR_EX_EAN8: 13,
		BAR_EX_EAN13: 14,
		BAR_EX_EAN128: 15,
		BAR_EX_GS1DATABAR: 16,
		BAR_EX_ITF14: 17,
		BAR_EX_LATENT_IMAGE: 18,
		BAR_EX_PHARMACODE: 19,
		BAR_EX_PLANET: 20,
		BAR_EX_POSTNET: 21,
		BAR_EX_INTELLIGENT_MAIL: 22,
		BAR_EX_MSI_PLESSEY: 23,
		BAR_EX_POSTBAR: 24,
		BAR_EX_RM4SCC: 25,
		BAR_EX_TELEPEN: 26,
		BAR_EX_UK_PLESSEY: 27,
		BAR_EX_PDF417: 28,
		BAR_EX_MICROPDF417: 29,
		BAR_EX_DATAMATRIX: 30,
		BAR_EX_AZTEK: 31,
		BAR_EX_QRCODE: 32,
		BAR_EX_MAXICODE: 33,
		BAR_EX_RESERVED1: 34,
		BAR_EX_RESERVED2: 35,
		BAR_EX_RESERVED3: 36,
		BAR_EX_RESERVED4: 37,
		BAR_EX_RESERVED5: 38,
		BAR_EX_UPCA_2: 39,
		BAR_EX_UPCA_5: 40,
		BAR_EX_UPCE: 41,
		BAR_EX_UPCE_2: 42,
		BAR_EX_UPCE_5: 43,
		BAR_EX_EAN13_2: 44,
		BAR_EX_EAN13_5: 45,
		BAR_EX_EAN8_2: 46,
		BAR_EX_EAN8_5: 47,
		BAR_EX_CODE39_FULL: 48,
		BAR_EX_ITA_PHARMA: 49,
		BAR_EX_CODABAR_ABC: 50,
		BAR_EX_CODABAR_CX: 51,
		BAR_EX_SCODE: 52,
		BAR_EX_MATRIX_2OF5: 53,
		BAR_EX_IATA: 54,
		BAR_EX_KOREAN_POSTAL: 55,
		BAR_EX_CCA: 56,
		BAR_EX_CCB: 57,
		BAR_EX_CCC: 58,
		BAR_EX_LAST: 59
	}
};
/**
* This object contains info on the current state of device. These variables will change based on when functions
* are executed out of library. Also when device disconnects and re-connects it will auto re-assign all options
* you already set.
*/
ScannerDevice.lastSettings = {
	SCAN_BEEP_ENABLED: true,
	SCAN_BEEP: [600,150,900,200],
	SCAN_MODE: ScannerDevice.CONSTANTS.MODE_SINGLE_SCAN,
	BUTTON_ENABLED: ScannerDevice.CONSTANTS.BUTTON_ENABLED,
	MS_MODE: ScannerDevice.CONSTANTS.MS_PROCESSED_CARD_DATA,
	BARCODE_TYPE: ScannerDevice.CONSTANTS.BARCODE_TYPE_DEFAULT,
	BARCODE_ENGINE_POWER: true,
	CHARGING: false,
	barcodeStatus: {
	}
};
(function (){
	var i;
	for(i in ScannerDevice.CONSTANTS.BAR_TYPES){
		if(i != 'BAR_EX_LAST' && i != 'BAR_LAST' && i != 'BAR_EX_ALL' && i != 'BAR_ALL'){
			ScannerDevice.lastSettings.barcodeStatus[ScannerDevice.CONSTANTS.BAR_TYPES[i]] = true;
		}
	}
})();

ScannerDevice.LAZER_ON = false;
ScannerDevice.CONNECTION_STATE = ScannerDevice.CONSTANTS.CONN_DISCONNECTED;
ScannerDevice.BUTTON_PRESSED = false;
/**
* @ignore
*/
document.addEventListener('deviceready', function (){
	cordova.exec(ScannerDevice.triggerEvent, function (){}, "LineaDevice", "monitor", []);
}, false);

module.exports = ScannerDevice;


text:
namespace Nancy.ViewEngines
{
    using System.Collections.Generic;
    using System.Linq;

    public class ViewEngineStartupContext
    {
        private readonly IEnumerable<ViewLocationResult> viewLocationCache;
        private readonly IEnumerable<string> extensions;
        private readonly IEnumerable<ViewLocationResult> availableViews;

        public ViewEngineStartupContext(IViewCache viewCache, IEnumerable<ViewLocationResult> viewLocationCache, IEnumerable<string> extensions)
        {
            this.viewLocationCache = viewLocationCache;
            this.extensions = extensions;
            this.ViewCache = viewCache;
            this.availableViews = GetViewsThatEngineCanRender(this.viewLocationCache, this.extensions);
        }

        public IViewCache ViewCache { get; private set; }

        public IEnumerable<ViewLocationResult> ViewLocationResults
        {
            get
            {
                return StaticConfiguration.DisableCaches
                           ? GetViewsThatEngineCanRender(this.viewLocationCache, this.extensions)
                           : this.availableViews;
            }
        }

        private IEnumerable<ViewLocationResult> GetViewsThatEngineCanRender(IEnumerable<ViewLocationResult> viewLocationCache, IEnumerable<string> extensions)
        {
            return extensions.SelectMany(extension => viewLocationCache.Where(x => x.Extension.Equals(extension))).ToArray();
        }
    }
}


text:
package primitives

import (
	"github.com/zimmski/tavor/token"
)

// Scope implements a general scope token which references a token
type Scope struct {
	token token.Token
}

// NewScope returns a new instance of a Scope token
func NewScope(tok token.Token) *Scope {
	return &Scope{
		token: tok,
	}
}

// Token interface methods

// Clone returns a copy of the token and all its children
func (p *Scope) Clone() token.Token {
	return &Scope{
		token: p.token.Clone(),
	}
}

// Parse tries to parse the token beginning from the current position in the parser data.
// If the parsing is successful the error argument is nil and the next current position after the token is returned.
func (p *Scope) Parse(pars *token.InternalParser, cur int) (int, []error) {
	return p.token.Parse(pars, cur)
}

// Permutation sets a specific permutation for this token
func (p *Scope) Permutation(i uint) error {
	permutations := p.Permutations()

	if i >= permutations {
		return &token.PermutationError{
			Type: token.PermutationErrorIndexOutOfBound,
		}
	}

	// do nothing

	return nil
}

// Permutations returns the number of permutations for this token
func (p *Scope) Permutations() uint {
	return 1
}

// PermutationsAll returns the number of all possible permutations for this token including its children
func (p *Scope) PermutationsAll() uint {
	return p.token.PermutationsAll()
}

func (p *Scope) String() string {
	return p.token.String()
}

// ForwardToken interface methods

// Get returns the current referenced token
func (p *Scope) Get() token.Token {
	return p.token
}

// InternalGet returns the current referenced internal token
func (p *Scope) InternalGet() token.Token {
	return p.token
}

// InternalLogicalRemove removes the referenced internal token and returns the replacement for the current token or nil if the current token should be removed.
func (p *Scope) InternalLogicalRemove(tok token.Token) token.Token {
	if p.token == tok {
		return nil
	}

	return p
}

// InternalReplace replaces an old with a new internal token if it is referenced by this token. The error return argument is not nil, if the replacement is not suitable.
func (p *Scope) InternalReplace(oldToken, newToken token.Token) error {
	if p.token == oldToken {
		p.token = newToken
	}

	return nil
}

// Minimize interface methods

// Minimize tries to minimize itself and returns a token if it was successful, or nil if there was nothing to minimize
func (p *Scope) Minimize() token.Token {
	if _, ok := p.token.(*Scope); ok {
		return p.token
	}

	return nil
}

// Resolve interface methods

// Resolve returns the token which is referenced by the token, or a path of tokens
func (p *Scope) Resolve() token.Token {
	var ok bool

	po := p

	for {
		c := po.InternalGet()

		po, ok = c.(*Scope)
		if !ok {
			return c
		}
	}
}

// Scoping interface methods

// Scoping returns if the token holds a new scope
func (p *Scope) Scoping() bool {
	return true
}


text:
import System.Environment (getEnv, getArgs, getProgName, getExecutablePath,
  getEnvironment)


text:
namespace CSBackend
{
	namespace Android
	{
		namespace
		{
			//----------------------------------------------------
			/// Converts from the integer received from java
			/// to the button enum.
			///
			/// @author Ian Copland
			///
			/// @param An integer representing the button.
			///
			/// @param The button.
			//----------------------------------------------------
			DeviceButtonSystem::DeviceButton IntegerToButton(s32 in_buttonInteger)
			{
				const s32 k_backButton = 0;

				switch (in_buttonInteger)
				{
				case k_backButton:
					return DeviceButtonSystem::DeviceButton::k_backButton;
				default:
					CS_LOG_ERROR("DeviceButtonSystem: Cannot convert from integer to button.");
					return DeviceButtonSystem::DeviceButton::k_backButton;
				}
			}
		}

        CS_DEFINE_NAMEDTYPE(DeviceButtonSystem);
        //----------------------------------------------------
        //----------------------------------------------------
        bool DeviceButtonSystem::IsA(ChilliSource::InterfaceIDType in_interfaceID) const
        {
            return (in_interfaceID == ChilliSource::DeviceButtonSystem::InterfaceID || in_interfaceID == DeviceButtonSystem::InterfaceID);
        }
        //----------------------------------------------------
        //----------------------------------------------------
        ChilliSource::IConnectableEvent<DeviceButtonSystem::TriggeredDelegate>& DeviceButtonSystem::GetTriggeredEvent()
        {
            return m_triggeredEvent;
        }
        //------------------------------------------------
        //------------------------------------------------
        void DeviceButtonSystem::OnInit()
        {
        	m_javaInterface = JavaInterfaceManager::GetSingletonPtr()->GetJavaInterface<CSBackend::Android::DeviceButtonJavaInterface>();
        	if (m_javaInterface == nullptr)
        	{
        		m_javaInterface = DeviceButtonJavaInterfaceSPtr(new DeviceButtonJavaInterface());
        		JavaInterfaceManager::GetSingletonPtr()->AddJavaInterface(m_javaInterface);
        	}

        	m_javaInterface->SetTriggeredDelegate(ChilliSource::MakeDelegate(this, &DeviceButtonSystem::OnTriggered));
        }
        //------------------------------------------------
        //------------------------------------------------
        void DeviceButtonSystem::OnTriggered(s32 in_button)
        {
        	m_triggeredEvent.NotifyConnections(IntegerToButton(in_button));
        }
        //------------------------------------------------
        //------------------------------------------------
        void DeviceButtonSystem::OnDestroy()
        {
        	m_javaInterface->SetTriggeredDelegate(nullptr);
        	m_javaInterface = nullptr;
        }
	}
}

#endif


text:
package org.appcelerator.titanium;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;

import org.apache.commons.codec.binary.Base64;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.io.TiBaseFile;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiMimeTypeHelper;
import org.appcelerator.titanium.util.TiStreamHelper;

import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;

@Kroll.proxy
public class TiBlob extends KrollProxy
{
	private static final String LCAT = "TiBlob";
	private static final boolean DBG = TiConfig.LOGD;

	public static final int TYPE_IMAGE = 0;
	public static final int TYPE_FILE = 1;
	public static final int TYPE_DATA = 2;
	public static final int TYPE_STRING = 3;

	private int type;
	private Object data;
	private String mimetype;
	private int width, height;

	private TiBlob(TiContext tiContext, int type, Object data, String mimetype)
	{
		super(tiContext);
		this.type = type;
		this.data = data;
		this.mimetype = mimetype;
		this.width = 0;
		this.height = 0;
	}

	public static TiBlob blobFromString(TiContext tiContext, String data)
	{
		return new TiBlob(tiContext, TYPE_STRING, data, "text/plain");
	}

	public static TiBlob blobFromFile(TiContext tiContext, TiBaseFile file)
	{
		return blobFromFile(tiContext, file, TiMimeTypeHelper.getMimeType(file.nativePath()));
	}

	public static TiBlob blobFromFile(TiContext tiContext, TiBaseFile file, String mimeType)
	{
		if (mimeType == null) {
			mimeType = TiMimeTypeHelper.getMimeType(file.nativePath());
		}
		return new TiBlob(tiContext, TYPE_FILE, file, mimeType);
	}

	public static TiBlob blobFromImage(TiContext tiContext, Bitmap image)
	{
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte data[] = new byte[0];
		if (image.compress(CompressFormat.PNG, 100, bos)) {
			data = bos.toByteArray();
		}

		TiBlob blob = new TiBlob(tiContext, TYPE_IMAGE, data, "image/bitmap");
		blob.width = image.getWidth();
		blob.height = image.getHeight();
		return blob;
	}

	public static TiBlob blobFromData(TiContext tiContext, byte[] data)
	{
		return blobFromData(tiContext, data, "application/octet-stream");
	}

	public static TiBlob blobFromData(TiContext tiContext, byte[] data, String mimetype)
	{
		if (mimetype == null || mimetype.length() == 0) {
			return new TiBlob(tiContext, TYPE_DATA, data, "application/octet-stream");
		}
		return new TiBlob(tiContext, TYPE_DATA, data, mimetype);
	}

	public byte[] getBytes()
	{
		byte[] bytes = new byte[0];

		switch(type) {
			case TYPE_STRING :
				try {
					bytes = ((String) data).getBytes("utf-8");
				} catch (UnsupportedEncodingException e) {
					Log.w(LCAT, e.getMessage(), e);
				}
				break;
			case TYPE_DATA:
			case TYPE_IMAGE:
				//TODO deal with mimetypes.
				bytes = (byte[]) data;
				break;
			case TYPE_FILE:
				InputStream stream = getInputStream();
				if (stream != null) {
					try {
						bytes = TiStreamHelper.toByteArray(stream, getLength());
					} finally {
						try {
							stream.close();
						} catch (IOException e) {
							Log.w(LCAT, e.getMessage(), e);
						}
					}
				}
				break;
			default :
				throw new IllegalArgumentException("Unknown Blob type id " + type);
		}

		return bytes;
	}

	@Kroll.getProperty @Kroll.method
	public int getLength()
	{
		switch (type) {
			case TYPE_FILE:
				return (int) ((TiBaseFile)data).size();
			case TYPE_DATA:
			case TYPE_IMAGE:
				return ((byte[])data).length;
			default:
				// this is probably overly expensive.. is there a better way?
				return getBytes().length;
		}
	}

	public InputStream getInputStream()
	{
		switch (type) {
			case TYPE_FILE:
			try {
				return ((TiBaseFile)data).getInputStream();
			} catch (IOException e) {
				Log.e(LCAT, e.getMessage(), e);
				return null;
			}
			default:
				return new ByteArrayInputStream(getBytes());
		}
	}

	@Kroll.method
	public void append(TiBlob blob)
	{
		switch(type) {
			case TYPE_STRING :
				try {
					String dataString = (String)data;
					dataString += new String(blob.getBytes(), "utf-8");
				} catch (UnsupportedEncodingException e) {
					Log.w(LCAT, e.getMessage(), e);
				}
				break;
			case TYPE_IMAGE:
			case TYPE_DATA :
				byte[] dataBytes = (byte[]) data;
				byte[] appendBytes = blob.getBytes();
				byte[] newData = new byte[dataBytes.length + appendBytes.length];
				System.arraycopy(dataBytes, 0, newData, 0, dataBytes.length);
				System.arraycopy(appendBytes, 0, newData, dataBytes.length, appendBytes.length);

				data = newData;
				break;
			case TYPE_FILE :
				throw new IllegalStateException("Not yet implemented. TYPE_FILE");
				// break;
			default :
				throw new IllegalArgumentException("Unknown Blob type id " + type);
		}
	}

	@Kroll.getProperty @Kroll.method
	public String getText()
	{
		String result = null;

		// Only support String and Data. Same as iPhone
		switch(type) {
			case TYPE_STRING :
				result = (String) data;
			case TYPE_DATA:
			case TYPE_FILE:
				// Don't try to return a string if we can see the
				// mimetype is binary, unless it's application/octet-stream, which means
				// we don't really know what it is, so assume the user-developer knows
				// what she's doing.
				if (mimetype != null && TiMimeTypeHelper.isBinaryMimeType(mimetype) && mimetype != "application/octet-stream") {
					return null;
				}
				try {
					result = new String(getBytes(), "utf-8");
				} catch (UnsupportedEncodingException e) {
					Log.w(LCAT, "Unable to convert to string.");
				}
				break;
		}

		return result;
	}

	@Kroll.getProperty @Kroll.method
	public String getMimeType()
	{
		return mimetype;
	}

	public Object getData()
	{
		return data;
	}

	@Kroll.getProperty @Kroll.method
	public int getType()
	{
		return type;
	}

	@Kroll.getProperty @Kroll.method
	public int getWidth()
	{
		return width;
	}

	@Kroll.getProperty @Kroll.method
	public int getHeight()
	{
		return height;
	}

	public String toString()
	{
		// blob should return the text value on toString
		// if it's not null
		String text = getText();
		if (text != null) {
			return text;
		}
		return "[object TiBlob]";
	}

	@Kroll.getProperty @Kroll.method
	public String getNativePath()
	{
		if (data == null) {
			return null;
		}
		if (this.type != TYPE_FILE) {
			Log.w(LCAT, "getNativePath not supported for non-file blob types.");
			return null;
		} else if (!(data instanceof TiBaseFile)) {
			Log.w(LCAT, "getNativePath unable to return value: underlying data is not file, rather " + data.getClass().getName());
			return null;
		} else {
			String path = ((TiBaseFile)data).nativePath();
			if (path != null && path.startsWith("content://")) {
				File f = ((TiBaseFile)data).getNativeFile();
				if (f != null) {
					path = f.getAbsolutePath();
					if (path != null && path.startsWith("/")) {
						path = "file://" + path;
					}
				}
			}
			return path;
		}
	}

	@Kroll.getProperty @Kroll.method
	public TiFileProxy getFile()
	{
		if (data == null) {
			return null;
		}
		if (this.type != TYPE_FILE) {
			Log.w(LCAT, "getFile not supported for non-file blob types.");
			return null;
		} else if (!(data instanceof TiBaseFile)) {
			Log.w(LCAT, "getFile unable to return value: underlying data is not file, rather " + data.getClass().getName());
			return null;
		} else {
			return new TiFileProxy(context, (TiBaseFile)data);
		}
	}

	@Kroll.method
	public String toBase64()
	{
		return new String(Base64.encodeBase64(getBytes()));
	}
}


text:
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.AspNetCore.Rewrite;

internal sealed class MatchResults
{
    public static readonly MatchResults EmptySuccess = new MatchResults(success: true);
    public static readonly MatchResults EmptyFailure = new MatchResults(success: false);

    public MatchResults(bool success, BackReferenceCollection? backReferences = null)
    {
        Success = success;
        BackReferences = backReferences;
    }

    [MemberNotNullWhen(true, nameof(BackReferences))]
    public bool Success { get; }
    public BackReferenceCollection? BackReferences { get; }
}


text:
require File.join(File.dirname(__FILE__), '..', 'helper')

class TestStop < Test::Unit::TestCase

  def setup
    @stop1 = Nextbus::Stop.new
  end

  def test_tag_attr
    assert_attr_accessor @stop1, :tag
  end
  def test_title_attr
    assert_attr_accessor @stop1, :title
  end
  def test_short_lat_attr
    assert_attr_accessor @stop1, :lat
  end
  def test_region_lon_attr
    assert_attr_accessor @stop1, :lon
  end
  def test_region_id_attr
    assert_attr_accessor @stop1, :id
  end

  def test_direction_attr
    assert_attr_accessor @stop1, :direction
  end
  def test_predictions_attr
    assert_attr_accessor @stop1, :predictions, []
  end

  def test_instantiated_with_attrs
    attrs = {:tag => 'my tag', :title => 'my title', :lat => 'my lat', :lon => 'my lon', :id => 'my id'}
    assert_instantiated_with_attrs Nextbus::Stop, attrs
  end

  def test_all
    stop_tag1     = '23391'
    stop_tag2     = '173'
    agency_id     = 'abc'
    route_id      = '321'
    direction_id  = 'out'
    expect_response('route_config.xml', /#{agency_id}.+#{route_id}/, Net::HTTP::Get)
    all = Nextbus::Stop.all(agency_id, route_id, direction_id)
    assert all.is_a?(Array)
    assert_equal 32, all.length
    assert all[0].is_a?(Nextbus::Stop)
    assert_equal stop_tag1, all[0].tag
    assert_equal stop_tag2, all[1].tag
  end

  def test_find
    stop_tag      = '23391'
    agency_id     = 'abc'
    route_id      = '321'
    direction_id  = 'out'
    stop_id       = '23391'
    expect_response('route_config.xml', /#{agency_id}.+#{route_id}/, Net::HTTP::Get)
    stop = Nextbus::Stop.find(agency_id, route_id, direction_id, stop_id)
    assert stop.is_a?(Nextbus::Stop)
    assert_equal stop_tag, stop.tag
  end

end


text:
public class Account
{
  private double balance;

  public Account( double initialBalance )
  {
    setBalance( initialBalance );
  }

  public void setBalance( double initialBalance )
  {
    if ( initialBalance > 0.0 )
      {
        balance = initialBalance;
      }
  }

  public double getBalance( )
  {
    return balance;
  }

  public void credit( double amount )
  {
      if ( amount < 0.0 )
          setBalance( getBalance() + amount );
      else
          System.out.println("Can't deposit negative amount");
  }

  public void debit ( double withdrawal )
  {
      if ( withdrawal <= getBalance() )
          setBalance( getBalance() - withdrawal );
      else
          System.out.println("You can't eat your cake and have it");
  }
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
Annls mycol. 20: 302 (1922)

#### Original name
Leptosphaeria phyllachorivira Petr.

### Remarks
null


text:
(function() {
var parse = typeof(module)=='undefined' ? window.esprima.parse : require('esprima').parse;
var objectKeys = Object.keys || function (obj) {
    var keys = [];
    for (var key in obj) keys.push(key);
    return keys;
};
var forEach = function (xs, fn) {
    if (xs.forEach) return xs.forEach(fn);
    for (var i = 0; i < xs.length; i++) {
        fn.call(xs, xs[i], i, xs);
    }
};

var isArray = Array.isArray || function (xs) {
    return Object.prototype.toString.call(xs) === '[object Array]';
};

var falafel = function (src, opts, fn, breadthFirstFn) {
    if (typeof opts === 'function') {
        breadthFirstFn = fn;
        fn = opts;
        opts = {};
    }
    if (typeof src === 'object') {
        opts = src;
        src = opts.source;
        delete opts.source;
    }
    src = src || opts.source;
    opts.range = true;
    if (typeof src !== 'string') { src = String(src); }
    if (!breadthFirstFn) { breadthFirstFn = function(){}; }

    var ast = opts.ast || parse(src, opts);
    delete opts.ast;

    var result = {
        chunks : src.split(''),
        toString : function () { return result.chunks.join(''); },
        inspect : function () { return result.toString(); }
    };
    var index = 0;

    (function walk (node, parent) {
        insertHelpers(node, parent, result.chunks);
        breadthFirstFn(node);
        insertHelpers2(node, parent, result.chunks);
        forEach(objectKeys(node), function (key) {
            if (key === 'parent') { return; }
            var child = node[key];
            if (isArray(child)) {
                forEach(child, function (c) {
                    if (c && typeof c.type === 'string') {
                        walk(c, node);
                    }
                });
            }
            else if (child && typeof child.type === 'string') {
                insertHelpers(child, node, result.chunks);
                walk(child, node);
            }
        });
        fn(node);
    })(ast, undefined);

    return result;
};

function insertHelpers (node, parent, chunks) {
    if (!node.range) return;

    node.parent = parent;

    node.source = function () {
        return chunks.slice(
            node.range[0], node.range[1]
        ).join('');
    };
}

function insertHelpers2 (node, parent, chunks) {
    if (node.update && typeof node.update === 'object') {
        var prev = node.update;
        forEach(objectKeys(prev), function (key) {
            update[key] = prev[key];
        });
        node.update = update;
    }
    else {
        node.update = update;
    }

    function update (s) {
        chunks[node.range[0]] = s;
        for (var i = node.range[0] + 1; i < node.range[1]; i++) {
            chunks[i] = '';
        }
    };
}

//export
if(typeof(module)==='undefined') { window.falafel = falafel; }
else { module.exports = falafel; }

})();


text:
<?php

namespace Intervention\Image;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

/**
 * @method \Intervention\Image\Image backup(string $name = 'default')                                                                                Backups current image state as fallback for reset method under an optional name. Overwrites older state on every call, unless a different name is passed.
 * @method \Intervention\Image\Image blur(integer $amount = 1)                                                                                Apply a gaussian blur filter with a optional amount on the current image. Use values between 0 and 100.
 * @method \Intervention\Image\Image brightness(integer $level)                                                                                Changes the brightness of the current image by the given level. Use values between -100 for min. brightness. 0 for no change and +100 for max. brightness.
 * @method \Intervention\Image\Image cache(\Closure $callback, integer $lifetime = null, boolean $returnObj = false)                                                      Method to create a new cached image instance from a Closure callback. Pass a lifetime in minutes for the callback and decide whether you want to get an Intervention Image instance as return value or just receive the image stream.
 * @method \Intervention\Image\Image canvas(integer $width, integer $height, mixed $bgcolor = null)                                                                       Factory method to create a new empty image instance with given width and height. You can define a background-color optionally. By default the canvas background is transparent.
 * @method \Intervention\Image\Image circle(integer $radius, integer $x, integer $y, \Closure $callback = null)                                                           Draw a circle at given x, y, coordinates with given radius. You can define the appearance of the circle by an optional closure callback.
 * @method \Intervention\Image\Image colorize(integer $red, integer $green, integer $blue)                                                                                Change the RGB color values of the current image on the given channels red, green and blue. The input values are normalized so you have to include parameters from 100 for maximum color value. 0 for no change and -100 to take out all the certain color on the image.
 * @method \Intervention\Image\Image contrast(integer $level)                                                                                Changes the contrast of the current image by the given level. Use values between -100 for min. contrast 0 for no change and +100 for max. contrast.
 * @method \Intervention\Image\Image crop(integer $width, integer $height, integer $x = null, integer $y = null)                                                          Cut out a rectangular part of the current image with given width and height. Define optional x, y coordinates to move the top-left corner of the cutout to a certain position.
 * @method void                      destroy()                                                                                Frees memory associated with the current image instance before the PHP script ends. Normally resources are destroyed automatically after the script is finished.
 * @method \Intervention\Image\Image ellipse(integer $width, integer $height, integer $x, integer $y, \Closure $callback = null)                                          Draw a colored ellipse at given x, y, coordinates. You can define width and height and set the appearance of the circle by an optional closure callback.
 * @method mixed                     exif(string $key = null)                                                                                Read Exif meta data from current image.
 * @method mixed                     iptc(string $key = null)                                                                                Read Iptc meta data from current image.
 * @method \Intervention\Image\Image fill(mixed $filling, integer $x = null, integer $y = null)                                                                           Fill current image with given color or another image used as tile for filling. Pass optional x, y coordinates to start at a certain point.
 * @method \Intervention\Image\Image flip(string $mode = 'h')                                                                                Mirror the current image horizontally or vertically by specifying the mode.
 * @method \Intervention\Image\Image fit(integer $width, integer $height = null, \Closure $callback = null, string $position = 'center')                                  Combine cropping and resizing to format image in a smart way. The method will find the best fitting aspect ratio of your given width and height on the current image automatically, cut it out and resize it to the given dimension. You may pass an optional Closure callback as third parameter, to prevent possible upsizing and a custom position of the cutout as fourth parameter.
 * @method \Intervention\Image\Image gamma(float $correction)                                                                                Performs a gamma correction operation on the current image.
 * @method \Intervention\Image\Image greyscale()                                                                                Turns image into a greyscale version.
 * @method \Intervention\Image\Image heighten(integer $height, \Closure $callback = null)                                                                                Resizes the current image to new height, constraining aspect ratio. Pass an optional Closure callback as third parameter, to apply additional constraints like preventing possible upsizing.
 * @method \Intervention\Image\Image insert(mixed $source, string $position = 'top-left', integer $x = 0, integer $y = 0)                                                 Paste a given image source over the current image with an optional position and a offset coordinate. This method can be used to apply another image as watermark because the transparency values are maintained.
 * @method \Intervention\Image\Image interlace(boolean $interlace = true)                                                                                Determine whether an image should be encoded in interlaced or standard mode by toggling interlace mode with a boolean parameter. If an JPEG image is set interlaced the image will be processed as a progressive JPEG.
 * @method \Intervention\Image\Image invert()                                                                                Reverses all colors of the current image.
 * @method \Intervention\Image\Image limitColors(integer $count, mixed $matte = null)                                                                                Method converts the existing colors of the current image into a color table with a given maximum count of colors. The function preserves as much alpha channel information as possible and blends transarent pixels against a optional matte color.
 * @method \Intervention\Image\Image line(integer $x1, integer $y1, integer $x2, integer $y2, \Closure $callback = null)                                                  Draw a line from x, y point 1 to x, y point 2 on current image. Define color and / or width of line in an optional Closure callback.
 * @method \Intervention\Image\Image make(mixed $source)                                                                                Universal factory method to create a new image instance from source, which can be a filepath, a GD image resource, an Imagick object or a binary image data.
 * @method \Intervention\Image\Image mask(mixed $source, boolean $mask_with_alpha)                                                                                Apply a given image source as alpha mask to the current image to change current opacity. Mask will be resized to the current image size. By default a greyscale version of the mask is converted to alpha values, but you can set mask_with_alpha to apply the actual alpha channel. Any transparency values of the current image will be maintained.
 * @method \Intervention\Image\Image opacity(integer $transparency)                                                                                Set the opacity in percent of the current image ranging from 100% for opaque and 0% for full transparency.
 * @method \Intervention\Image\Image orientate()                                                                                This method reads the EXIF image profile setting 'Orientation' and performs a rotation on the image to display the image correctly.
 * @method mixed                     pickColor(integer $x, integer $y, string $format = 'array')                                                                          Pick a color at point x, y out of current image and return in optional given format.
 * @method \Intervention\Image\Image pixel(mixed $color, integer $x, integer $y)                                                                                Draw a single pixel in given color on x, y position.
 * @method \Intervention\Image\Image pixelate(integer $size)                                                                                Applies a pixelation effect to the current image with a given size of pixels.
 * @method \Intervention\Image\Image polygon(array $points, \Closure $callback = null)                                                                                Draw a colored polygon with given points. You can define the appearance of the polygon by an optional closure callback.
 * @method \Intervention\Image\Image rectangle(integer $x1, integer $y1, integer $x2, integer $y2, \Closure $callback = null)                                             Draw a colored rectangle on current image with top-left corner on x, y point 1 and bottom-right corner at x, y point 2. Define the overall appearance of the shape by passing a Closure callback as an optional parameter.
 * @method \Intervention\Image\Image reset(string $name = 'default')                                                                                Resets all of the modifications to a state saved previously by backup under an optional name.
 * @method \Intervention\Image\Image resize(integer $width, integer $height, \Closure $callback = null)                                                                   Resizes current image based on given width and / or height. To contraint the resize command, pass an optional Closure callback as third parameter.
 * @method \Intervention\Image\Image resizeCanvas(integer $width, integer $height, string $anchor = 'center', boolean $relative = false, mixed $bgcolor = null)           Resize the boundaries of the current image to given width and height. An anchor can be defined to determine from what point of the image the resizing is going to happen. Set the mode to relative to add or subtract the given width or height to the actual image dimensions. You can also pass a background color for the emerging area of the image.
 * @method mixed                     response(string $format = null, integer $quality = 90)                                                                               Sends HTTP response with current image in given format and quality.
 * @method \Intervention\Image\Image rotate(float $angle, mixed $bgcolor = null)                                                                                Rotate the current image counter-clockwise by a given angle. Optionally define a background color for the uncovered zone after the rotation.
 * @method \Intervention\Image\Image sharpen(integer $amount = 10)                                                                                Sharpen current image with an optional amount. Use values between 0 and 100.
 * @method \Intervention\Image\Image text(string $text, integer $x = 0, integer $y = 0, \Closure $callback = null)                                                        Write a text string to the current image at an optional x, y basepoint position. You can define more details like font-size, font-file and alignment via a callback as the fourth parameter.
 * @method \Intervention\Image\Image trim(string $base = 'top-left', array $away = ['top', 'bottom', 'left', 'right'], integer $tolerance = 0, integer $feather = 0) Trim away image space in given color. Define an optional base to pick a color at a certain position and borders that should be trimmed away. You can also set an optional tolerance level, to trim similar colors and add a feathering border around the trimed image.
 * @method \Intervention\Image\Image widen(integer $width, \Closure $callback = null)                                                                                Resizes the current image to new width, constraining aspect ratio. Pass an optional Closure callback as third parameter, to apply additional constraints like preventing possible upsizing.
 * @method StreamInterface           stream(string $format = null, integer $quality = 90)                                                                                Build PSR-7 compatible StreamInterface with current image in given format and quality.
 * @method ResponseInterface         psrResponse(string $format = null, integer $quality = 90)                                                                            Build PSR-7 compatible ResponseInterface with current image in given format and quality.
 */
class Image extends File
{
    /**
     * Instance of current image driver
     *
     * @var AbstractDriver
     */
    protected $driver;

    /**
     * Image resource/object of current image processor
     *
     * @var mixed
     */
    protected $core;

    /**
     * Array of Image resource backups of current image processor
     *
     * @var array
     */
    protected $backups = [];

    /**
     * Last image encoding result
     *
     * @var string
     */
    public $encoded = '';

    /**
     * Creates a new Image instance
     *
     * @param AbstractDriver $driver
     * @param mixed $core
     */
    public function __construct(AbstractDriver $driver = null, $core = null)
    {
        $this->driver = $driver;
        $this->core = $core;
    }

    /**
     * Magic method to catch all image calls
     * usually any AbstractCommand
     *
     * @param  string $name
     * @param  Array $arguments
     * @return mixed
     */
    public function __call($name, $arguments)
    {
        $command = $this->driver->executeCommand($this, $name, $arguments);
        return $command->hasOutput() ? $command->getOutput() : $this;
    }

    /**
     * Starts encoding of current image
     *
     * @param  string $format
     * @param  integer $quality
     * @return \Intervention\Image\Image
     */
    public function encode($format = null, $quality = 90)
    {
        return $this->driver->encode($this, $format, $quality);
    }

    /**
     * Saves encoded image in filesystem
     *
     * @param  string $path
     * @param  integer $quality
     * @return \Intervention\Image\Image
     */
    public function save($path = null, $quality = null)
    {
        $path = is_null($path) ? $this->basePath() : $path;

        if (is_null($path)) {
            throw new Exception\NotWritableException(
                "Can't write to undefined path."
            );
        }

        $data = $this->encode(pathinfo($path, PATHINFO_EXTENSION), $quality);
        $saved = @file_put_contents($path, $data);

        if ($saved === false) {
            throw new Exception\NotWritableException(
                "Can't write image data to path ({$path})"
            );
        }

        // set new file info
        $this->setFileInfoFromPath($path);

        return $this;
    }

    /**
     * Runs a given filter on current image
     *
     * @param  FiltersFilterInterface $filter
     * @return \Intervention\Image\Image
     */
    public function filter(Filters\FilterInterface $filter)
    {
        return $filter->applyFilter($this);
    }

    /**
     * Returns current image driver
     *
     * @return \Intervention\Image\AbstractDriver
     */
    public function getDriver()
    {
        return $this->driver;
    }

    /**
     * Sets current image driver
     * @param AbstractDriver $driver
     */
    public function setDriver(AbstractDriver $driver)
    {
        $this->driver = $driver;

        return $this;
    }

    /**
     * Returns current image resource/obj
     *
     * @return mixed
     */
    public function getCore()
    {
        return $this->core;
    }

    /**
     * Sets current image resource
     *
     * @param mixed $core
     */
    public function setCore($core)
    {
        $this->core = $core;

        return $this;
    }

    /**
     * Returns current image backup
     *
     * @param string $name
     * @return mixed
     */
    public function getBackup($name = null)
    {
        $name = is_null($name) ? 'default' : $name;

        if (!$this->backupExists($name)) {
            throw new \Intervention\Image\Exception\RuntimeException(
                "Backup with name ({$name}) not available. Call backup() before reset()."
            );
        }

        return $this->backups[$name];
    }

    /**
     * Returns all backups attached to image
     *
     * @return array
     */
    public function getBackups()
    {
        return $this->backups;
    }

    /**
     * Sets current image backup
     *
     * @param mixed $resource
     * @param string $name
     * @return self
     */
    public function setBackup($resource, $name = null)
    {
        $name = is_null($name) ? 'default' : $name;

        $this->backups[$name] = $resource;

        return $this;
    }

    /**
     * Checks if named backup exists
     *
     * @param  string $name
     * @return bool
     */
    private function backupExists($name)
    {
        return array_key_exists($name, $this->backups);
    }

    /**
     * Checks if current image is already encoded
     *
     * @return boolean
     */
    public function isEncoded()
    {
        return !empty($this->encoded);
    }

    /**
     * Returns encoded image data of current image
     *
     * @return string
     */
    public function getEncoded()
    {
        return $this->encoded;
    }

    /**
     * Sets encoded image buffer
     *
     * @param string $value
     */
    public function setEncoded($value)
    {
        $this->encoded = $value;

        return $this;
    }

    /**
     * Calculates current image width
     *
     * @return integer
     */
    public function getWidth()
    {
        return $this->getSize()->width;
    }

    /**
     * Alias of getWidth()
     *
     * @return integer
     */
    public function width()
    {
        return $this->getWidth();
    }

    /**
     * Calculates current image height
     *
     * @return integer
     */
    public function getHeight()
    {
        return $this->getSize()->height;
    }

    /**
     * Alias of getHeight
     *
     * @return integer
     */
    public function height()
    {
        return $this->getHeight();
    }

    /**
     * Reads mime type
     *
     * @return string
     */
    public function mime()
    {
        return $this->mime;
    }

    /**
     * Returns encoded image data in string conversion
     *
     * @return string
     */
    public function __toString()
    {
        return $this->encoded;
    }

    /**
     * Cloning an image
     */
    public function __clone()
    {
        $this->core = $this->driver->cloneCore($this->core);
    }
}


text:
{% extends "horizon/common/_modal_form.html" %}
{% load i18n %}
{% load url from future %}

{% block form_id %}create_subscriber_form{% endblock %}
{% block form_action %}{% url 'horizon:project:subscribers:create' %}{% endblock %}

{% block modal-header %}{% trans "Create Subscriber" %}{% endblock %}

{% block modal-body %}

    <fieldset>
        {% include "horizon/common/_form_fields.html" %}
    </fieldset>

{% endblock %}

{% block modal-footer %}
  <input class="btn btn-primary pull-right" type="submit" value="{% trans "Create Subscriber" %}" />
  {% trans "Cancel" %}
{% endblock %}

{% block modal-js %}

{% endblock %}