text:
namespace proxo {

Material::Material()
    : ambient(1), diffuse(1), specular(0.1), shininess(128), emissive(0),
      refractiveIndex(1), depthAbsorption{1,1,1}
{
}

} // namespace proxo

redpajama_set_name: RedPajamaGithub


text:
package sqlancer.oceanbase.gen;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import sqlancer.Randomly;
import sqlancer.common.DBMSCommon;
import sqlancer.common.query.ExpectedErrors;
import sqlancer.common.query.SQLQueryAdapter;
import sqlancer.oceanbase.OceanBaseGlobalState;
import sqlancer.oceanbase.OceanBaseSchema;
import sqlancer.oceanbase.OceanBaseSchema.OceanBaseDataType;

public class OceanBaseTableGenerator {

    private final StringBuilder sb = new StringBuilder();
    private final boolean allowPrimaryKey;
    private boolean setPrimaryKey;
    private final String tableName;
    private final Randomly r;
    private int columnId;
    private final List<String> columns = new ArrayList<>();
    private final OceanBaseSchema schema;
    private final OceanBaseGlobalState globalState;

    public OceanBaseTableGenerator(OceanBaseGlobalState globalState, String tableName) {
        this.tableName = tableName;
        this.r = globalState.getRandomly();
        this.schema = globalState.getSchema();
        allowPrimaryKey = Randomly.getBoolean();
        this.globalState = globalState;
    }

    public static SQLQueryAdapter generate(OceanBaseGlobalState globalState, String tableName) {
        return new OceanBaseTableGenerator(globalState, tableName).create();
    }

    private SQLQueryAdapter create() {
        ExpectedErrors errors = new ExpectedErrors();

        sb.append("CREATE");
        sb.append(" TABLE");
        if (Randomly.getBoolean()) {
            sb.append(" IF NOT EXISTS");
        }
        sb.append(" ");
        sb.append(tableName);
        if (Randomly.getBoolean() && !schema.getDatabaseTables().isEmpty()) {
            sb.append(" LIKE ");
            sb.append(schema.getRandomTable().getName());
            return new SQLQueryAdapter(sb.toString(), true);
        } else {
            sb.append("(");
            for (int i = 0; i < 1 + Randomly.smallNumber(); i++) {
                if (i != 0) {
                    sb.append(", ");
                }
                appendColumn();
            }
            sb.append(")");
            sb.append(" ");
            appendTableOptions();
            appendPartitionOptions();
            addCommonErrors(errors);
            return new SQLQueryAdapter(sb.toString(), errors, true);
        }

    }

    private void addCommonErrors(ExpectedErrors list) {
        list.add("doesn't have this option");
        list.add("must include all columns");
        list.add("not allowed type for this type of partitioning");
        list.add("doesn't support BLOB/TEXT columns");
        list.add("A BLOB field is not allowed in partition function");
        list.add("Too many keys specified; max 1 keys allowed");
        list.add("The total length of the partitioning fields is too large");
    }

    private enum PartitionOptions {
        HASH, KEY
    }

    private void appendPartitionOptions() {
        sb.append(" PARTITION BY");
        switch (Randomly.fromOptions(PartitionOptions.values())) {
        case HASH:
            sb.append(" HASH(");
            sb.append(Randomly.fromList(columns));
            sb.append(")");
            sb.append(" partitions ");
            sb.append(r.getInteger(1, 20));
            break;
        case KEY:
            sb.append(" KEY");
            sb.append(" (");
            sb.append(Randomly.nonEmptySubset(columns).stream().collect(Collectors.joining(", ")));
            sb.append(")");
            break;
        default:
            throw new AssertionError();
        }
    }

    private enum TableOptions {
        BS, BLOOM, AUTO_INCREMENT;

        public static List<TableOptions> getRandomTableOptions() {
            List<TableOptions> options;
            if (Randomly.getBooleanWithSmallProbability()) {
                options = Randomly.subset(TableOptions.values());
            } else {
                if (Randomly.getBoolean()) {
                    options = Collections.emptyList();
                } else {
                    options = Randomly.nonEmptySubset(Arrays.asList(TableOptions.values()), 0);
                }
            }
            return options;
        }
    }

    private void appendTableOptions() {
        List<TableOptions> tableOptions = TableOptions.getRandomTableOptions();
        int i = 0;
        for (TableOptions o : tableOptions) {
            if (i++ != 0) {
                sb.append(", ");
            }
            switch (o) {
            case AUTO_INCREMENT:
                sb.append("AUTO_INCREMENT = " + r.getPositiveInteger());
                break;
            case BLOOM:
                sb.append("USE_BLOOM_FILTER = ");
                if (Randomly.getBoolean()) {
                    sb.append(" FALSE ");
                } else {
                    sb.append(" true ");
                }
                break;
            case BS:
                sb.append(" BLOCK_SIZE = ");
                if (Randomly.getBoolean()) {
                    sb.append(" 16384 ");
                } else {
                    sb.append(" 32768 ");
                }
                break;
            default:
                throw new AssertionError(o);
            }
        }
    }

    private void appendColumn() {
        String columnName = DBMSCommon.createColumnName(columnId);
        columns.add(columnName);
        sb.append(columnName);
        appendColumnDefinition();
        columnId++;
    }

    private enum ColumnOptions {
        NULL_OR_NOT_NULL, UNIQUE, COMMENT, PRIMARY_KEY
    }

    private void appendColumnDefinition() {
        sb.append(" ");

        OceanBaseDataType randomType = OceanBaseDataType.getRandom(globalState);
        boolean isTextType = randomType == OceanBaseDataType.VARCHAR;
        appendTypeString(randomType);
        sb.append(" ");
        boolean isNull = false;
        boolean columnHasPrimaryKey = false;

        List<ColumnOptions> columnOptions = Randomly.subset(ColumnOptions.values());
        if (isTextType) {
            columnOptions.remove(ColumnOptions.PRIMARY_KEY);
            columnOptions.remove(ColumnOptions.UNIQUE);
        }
        for (ColumnOptions o : columnOptions) {
            sb.append(" ");
            switch (o) {
            case NULL_OR_NOT_NULL:
                // PRIMARY KEYs cannot be NULL
                if (!columnHasPrimaryKey) {
                    if (Randomly.getBoolean()) {
                        sb.append("NULL");
                    }
                    isNull = true;
                } else {
                    sb.append("NOT NULL");
                }
                break;
            case UNIQUE:
                sb.append("UNIQUE");
                if (Randomly.getBoolean()) {
                    sb.append(" KEY");
                }
                break;
            case COMMENT:
                sb.append(String.format("COMMENT '%s' ", "asdf"));
                break;
            case PRIMARY_KEY:
                // PRIMARY KEYs cannot be NULL
                if (allowPrimaryKey && !setPrimaryKey && !isNull) {
                    sb.append("PRIMARY KEY");
                    setPrimaryKey = true;
                    columnHasPrimaryKey = true;
                }
                break;
            default:
                throw new AssertionError();
            }
        }

    }

    private void appendTypeString(OceanBaseDataType randomType) {
        switch (randomType) {
        case DECIMAL:
            sb.append("DECIMAL");
            optionallyAddPrecisionAndScale(sb);
            break;
        case INT:
            sb.append(Randomly.fromOptions("TINYINT", "SMALLINT", "MEDIUMINT", "INT", "BIGINT"));
            if (Randomly.getBoolean()) {
                sb.append("(");
                sb.append(Randomly.getNotCachedInteger(0, 255));
                sb.append(")");
            }
            break;
        case VARCHAR:
            sb.append(Randomly.fromOptions("VARCHAR(500)"));
            break;
        case FLOAT:
            sb.append("FLOAT");
            optionallyAddPrecisionAndScale(sb);
            break;
        case DOUBLE:
            sb.append(Randomly.fromOptions("DOUBLE", "FLOAT"));
            optionallyAddPrecisionAndScale(sb);
            break;
        default:
            throw new AssertionError();
        }
        if (randomType.isNumeric()) {
            if (Randomly.getBoolean() && randomType != OceanBaseDataType.INT) {
                sb.append(" UNSIGNED");
            }
            if (Randomly.getBoolean()) {
                sb.append(" ZEROFILL");
            }
        }
    }

    public static void optionallyAddPrecisionAndScale(StringBuilder sb) {
        if (Randomly.getBoolean()) {
            sb.append("(");
            long m = Randomly.getNotCachedInteger(1, 53);
            sb.append(m);
            sb.append(", ");
            long nCandidate = Randomly.getNotCachedInteger(1, 30);
            long n = Math.min(nCandidate, m);
            sb.append(n);
            sb.append(")");
        }
    }

}


text:
"""
Python Module Importer Utilities
================================

Allows a Python script to import modules using file system paths rather than
Python module paths.
"""

import importlib
import os
import sys

__version__ = '0.0.0'

#=============================================================================
def is_python( path, catchall = False ):
    """
    Attempts to load a Python file without knowing if it's valid Python
    code.

    @param path     The path to the Python file to check
    @param catchall True to catch all exceptions and return False
    @return         True if it can be parsed as Python code, otherwise False
    """

    # Wrap the load call to catch any syntax problems during loading.
    try:
        load( path )
    except SyntaxError:
        return False
    except:
        if catchall:
            return False
        raise
    return True

#=============================================================================
def load( path ):
    """
    Loads a Python module from a path to a file.

    @param path The path to the Python file to load as a module
    @return     A reference to the module
    """

    # Normalize and parse path to script.
    path            = os.path.realpath( path )
    basename        = os.path.basename( path )
    dirname         = os.path.dirname( path )
    name, extension = os.path.splitext( basename )

    # Remove any possible existing reference from the modules dictionary.
    if name in sys.modules:
        del sys.modules[ name ]

    # Prepend the directory to this file to the path list.
    sys.path.insert( 0, dirname )

    # Import the module.
    module = importlib.import_module( name )

    # Remove reference to module from modules dictionary.
    del sys.modules[ name ]

    # Remove the directory from path list.
    sys.path.pop( 0 )

    # Return the reference to the module.
    return module


text:
package com.google.cloud.dialogflow.v2.samples;

// [START dialogflow_v2_generated_Versions_CreateVersion_sync]
import com.google.cloud.dialogflow.v2.AgentName;
import com.google.cloud.dialogflow.v2.CreateVersionRequest;
import com.google.cloud.dialogflow.v2.Version;
import com.google.cloud.dialogflow.v2.VersionsClient;

public class SyncCreateVersion {

  public static void main(String[] args) throws Exception {
    syncCreateVersion();
  }

  public static void syncCreateVersion() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (VersionsClient versionsClient = VersionsClient.create()) {
      CreateVersionRequest request =
          CreateVersionRequest.newBuilder()
              .setParent(AgentName.ofProjectName("[PROJECT]").toString())
              .setVersion(Version.newBuilder().build())
              .build();
      Version response = versionsClient.createVersion(request);
    }
  }
}
// [END dialogflow_v2_generated_Versions_CreateVersion_sync]


text:
<?php

namespace SiestaTest\End2End\Construct\Entity;

class EntityFactory
{

    public static function newFactoryEntity() {
        $factory = new Factory();
        $factory->setString1("FactoryGeneratedEntity");
        return $factory;
    }

}


text:
{% extends "base.html" %}

{% block extrahead %}
<title>Autotip Giveaway</title>
{% endblock %}

{% block content %}

Autotip Giveaway Information

Why?

To give users an incentive to give support to the creators of the content they consume on the web.

How are winners selected?

Each day your extension makes a tip, the extension is programmed to enter your
deposit address into a drawling done each week.

Does this mean Autotip is centralized?

Just the giveaway is centralized. The rest of the extension works without the need for a centralized
service. The giveaway is completely optional.

Who can participate?

Any user of Autotip. The giveaway is not even only limited to people who use Autotip.
Any other microtip client can send their user's deposit address into the givaway.
The winner selection process is basd on activity takes from the blockchain.
Whichever application created the trasaction does not matter.
If you are the developer of an Autotip-like microtip application and would like to
integrate the Autotip Giveaway Program to your application, get in contact with the developers for
more information.

Where does the money come from?

The money comes from donations to the autotip project.

Can I contribute to the giveaway fund?

Yes. Anyone can donate. The address is 1K65TijR56S4CcwjXBnecYEKmTNrMag5uq.

Can I make a profit from using Autotip?

The giveaway program is intende to offset the cost of using Autotip.
Some lucky users may end up making a profit from givaway payouts,
but most will make very little profit or no profit at all.
The design of Autotip is for the profit to to to the creators of content on the web.

When are payouts?

Payouts are every Friday.

Can I see the code that determines who gets payouts?

Yes you can. Its on github.

{% endblock %}


text:
.. include:: /Includes.rst.txt
.. highlight:: rst
.. index:: graphviz

===================
sphinx.ext.graphviz
===================

See https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html

.. contents:: This page
   :backlinks: top
   :class: compact-list
   :depth: 99
   :local:

Example: Topics
===============

Note there are links and tootips!

.. graphviz::
   :caption: Structuring knowledge by topics. Note there are tooltips. Some
             nodes have operational hyperlinks.

   digraph Knowledge_by_topics  {
   layout=neato;
   ratio="0.6"
   // size="8.27,11.69"; // 210mmx297mm
   graph[label="",labelloc="t",tooltip="Structuring knowledge by topics",bgcolor="#f0f0f0"];
   node [fontsize = 14, style = solid];

   Looking_for [label="Looking for …",fillcolor=white,shape=rectangle,style="dashed,filled",tooltip="Suppose you are trying to find out about a topic …"];

   node [fontsize=12,style=filled,width=.75,height=.50];

   Looking_for -> Your_topic;
   Looking_for -> CKEditor;
   Looking_for -> Deployment;
   Looking_for -> Sitepackages;
   Looking_for -> More;

   node[fontsize=10,margin=".05",width=.75,height=.40,shape=ellipse,style=filled,fillcolor=white]

   CKEditor -> CKEditor_blogpostings;
   CKEditor -> CKEditor_official_docs;
   CKEditor -> CKEditor_onlinetryouts;

   Deployment -> Deployment_blog_postings;
   Deployment -> Deployment_clever_solutions;
   Deployment -> Deployment_tools;

   More -> More_best_practise;
   More -> More_resources;

   Sitepackages -> Sitepackages_tutorials;
   Sitepackages -> Sitepackages_videos;

   CKEditor               [                       href="../Topics/Ckeditor.html"                       ,target=_top,tooltip="CKEditor"];
   CKEditor_blogpostings  [label="Blog postings" ,href="../Topics/Ckeditor.html#blog-postings"         ,target=_top,tooltip="CKEditor: Blog postings"];
   CKEditor_official_docs [label="Official docs" ,href="../Topics/Ckeditor.html#official-documentation",target=_top,tooltip="CKEditor: Official documentation"];
   CKEditor_onlinetryouts [label="Online tryouts",href="../Topics/Ckeditor.html#online-tryouts"        ,target=_top,tooltip="CKEditor: Online tryouts"];

   Deployment                  [                         href="../Topics/Deployment.html"                 ,target=_top,tooltip="Deployment"];
   Deployment_blog_postings    [label="Blog postings"   ,href="../Topics/Deployment.html#blog-postings"   ,target=_top,tooltip="Deployment: Blog postings"];
   Deployment_tools            [label="Tools"           ,href="../Topics/Deployment.html#tools"           ,target=_top,tooltip="Deployment: Tools"];
   Deployment_clever_solutions [label="Clever solutions",href="../Topics/Deployment.html#clever-solutions",target=_top,tooltip="Deployment: Cever solutions"];

   More               [label="More…"        ,tooltip="There are more topics in this manual"];
   More_best_practise [label="Best practise",tooltip="More: Best practise"];
   More_resources     [label="Resources"    ,tooltip="More: Resources"];

   Sitepackages           [                  href="../Topics/Sitepackages.html"           ,target=_top,tooltip="Sitepackages"];
   Sitepackages_tutorials [label="Tutorials",href="../Topics/Sitepackages.html#tutorials" ,target=_top,tooltip="Sitepackages: Tutorials"];
   Sitepackages_videos    [label="Videos"   ,href="../Topics/Sitepackages.html#videos"    ,target=_top,tooltip="Sitepackages: Videos"];

   Your_topic             [label="Your topic…", tooltip="This can be your topic - if you contribute"];

   node [label="",shape=point,width=.1,height=.1];

   CKEditor     -> CKEditor_more;
   Deployment   -> Deployment_more;
   More         -> More_more;
   Sitepackages -> Sitepackages_more;
   Your_topic   -> Your_topic_more_1;
   Your_topic   -> Your_topic_more_2;
   Your_topic   -> Your_topic_more_3;
   Your_topic   -> Your_topic_more_4;
   Your_topic   -> Your_topic_more_5;

   Deployment_more   [label = "", tooltip = "Deployment: More…"];
   More_more         [label = "", tooltip = "More: …"];
   Your_topic_more_1 [label = "", tooltip = "More…"];
   Your_topic_more_2 [label = "", tooltip = "More…"];
   Your_topic_more_3 [label = "", tooltip = "More…"];
   Your_topic_more_4 [label = "", tooltip = "More…"];
   Your_topic_more_5 [label = "", tooltip = "More…"];

   CKEditor_more          [label="",tooltip="CKEditor: More…"];
   Sitepackages_more      [label="",tooltip="Sitepackages: More…"];

   }

Example: graphviz
=================

Source::

   .. graphviz::

      digraph foo {
         "bar" -> "baz";
      }

Result:

.. graphviz::

   digraph foo {
      "bar" -> "baz";
   }

Example: graphviz plus options
==============================

Additionally option `:layout:` can be used with one of the Graphviz layouts as
value, as there are: dot neato fdp sfdp twopi circo.

Source::

   .. graphviz::
      :alt: alternative text
      :align: center
      :caption: caption of the graph
      :name: this is a label

      digraph foo {
         "bar" -> "baz";
      }

Result:

.. graphviz::
   :alt: alternative text
   :align: center
   :caption: caption of the graph
   :name: this is a label

   digraph foo {
      "bar" -> "baz";
   }

Example: graph
==============

Source::

   .. graph:: foo

      "bar" -- "baz";

Result:

.. graph:: foo

   "bar" -- "baz";

Example: digraph
================

Source::

   .. digraph:: foo

      "bar" -> "baz" -> "quax";

Result:

.. digraph:: foo

   "bar" -> "baz" -> "quax";

Example with link in svg
========================

Source::

   .. graphviz::

      digraph example {
         a [label="sphinx", href="http://sphinx-doc.org", target="_top"];
         b [label="other"];
         a -> b;
      }

Result:

.. graphviz::

   digraph example {
      a [label="sphinx", href="http://sphinx-doc.org", target="_top"];
      b [label="other"];
      a -> b;
   }

Example: Unix 1984 - 1986
=========================

From http://www.graphviz.org/Gallery/directed/unix.html

.. graphviz::

   /* courtesy Ian Darwin and Geoff Collyer, Softquad Inc. */
   /*   size="6,6"; */
   digraph unix {
      node [color=lightblue2, style=filled];
      "5th Edition" -> "6th Edition";
      "5th Edition" -> "PWB 1.0";
      "6th Edition" -> "LSX";
      "6th Edition" -> "1 BSD";
      "6th Edition" -> "Mini Unix";
      "6th Edition" -> "Wollongong";
      "6th Edition" -> "Interdata";
      "Interdata" -> "Unix/TS 3.0";
      "Interdata" -> "PWB 2.0";
      "Interdata" -> "7th Edition";
      "7th Edition" -> "8th Edition";
      "7th Edition" -> "32V";
      "7th Edition" -> "V7M";
      "7th Edition" -> "Ultrix-11";
      "7th Edition" -> "Xenix";
      "7th Edition" -> "UniPlus+";
      "V7M" -> "Ultrix-11";
      "8th Edition" -> "9th Edition";
      "1 BSD" -> "2 BSD";
      "2 BSD" -> "2.8 BSD";
      "2.8 BSD" -> "Ultrix-11";
      "2.8 BSD" -> "2.9 BSD";
      "32V" -> "3 BSD";
      "3 BSD" -> "4 BSD";
      "4 BSD" -> "4.1 BSD";
      "4.1 BSD" -> "4.2 BSD";
      "4.1 BSD" -> "2.8 BSD";
      "4.1 BSD" -> "8th Edition";
      "4.2 BSD" -> "4.3 BSD";
      "4.2 BSD" -> "Ultrix-32";
      "PWB 1.0" -> "PWB 1.2";
      "PWB 1.0" -> "USG 1.0";
      "PWB 1.2" -> "PWB 2.0";
      "USG 1.0" -> "CB Unix 1";
      "USG 1.0" -> "USG 2.0";
      "CB Unix 1" -> "CB Unix 2";
      "CB Unix 2" -> "CB Unix 3";
      "CB Unix 3" -> "Unix/TS++";
      "CB Unix 3" -> "PDP-11 Sys V";
      "USG 2.0" -> "USG 3.0";
      "USG 3.0" -> "Unix/TS 3.0";
      "PWB 2.0" -> "Unix/TS 3.0";
      "Unix/TS 1.0" -> "Unix/TS 3.0";
      "Unix/TS 3.0" -> "TS 4.0";
      "Unix/TS++" -> "TS 4.0";
      "CB Unix 3" -> "TS 4.0";
      "TS 4.0" -> "System V.0";
      "System V.0" -> "System V.2";
      "System V.2" -> "System V.3";
   }


text:
package com.speedment.tool.core.internal.controller;

import com.speedment.common.injector.annotation.Inject;
import com.speedment.generator.core.component.EventComponent;
import com.speedment.generator.core.event.ProjectLoaded;
import com.speedment.runtime.config.trait.HasEnabled;
import com.speedment.tool.actions.ProjectTreeComponent;
import com.speedment.tool.config.ColumnProperty;
import com.speedment.tool.config.DocumentProperty;
import com.speedment.tool.config.IndexProperty;
import com.speedment.tool.config.PrimaryKeyColumnProperty;
import com.speedment.tool.config.ProjectProperty;
import com.speedment.tool.config.trait.HasEnabledProperty;
import com.speedment.tool.config.trait.HasExpandedProperty;
import com.speedment.tool.config.trait.HasIconPath;
import com.speedment.tool.config.trait.HasNameProperty;
import com.speedment.tool.core.component.UserInterfaceComponent;
import com.speedment.tool.core.resource.SpeedmentIcon;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.collections.ListChangeListener;
import javafx.collections.MapChangeListener;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.net.URL;
import java.util.ResourceBundle;

import static java.util.Objects.requireNonNull;
import static javafx.application.Platform.runLater;
import static javafx.scene.control.SelectionMode.SINGLE;

/**
 *
 * @author Emil Forslund
 */
public final class ProjectTreeController implements Initializable {

    public @Inject UserInterfaceComponent ui;
    public @Inject ProjectTreeComponent projectTreeComponent;
    public @Inject EventComponent events;

    private @FXML TreeView<DocumentProperty> hierarchy;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        runLater(() -> prepareTree(ui.projectProperty()));
    }

    private void prepareTree(ProjectProperty project) {
        requireNonNull(project);

        events.notify(new ProjectLoaded(project));

        Bindings.bindContent(ui.getSelectedTreeItems(), hierarchy.getSelectionModel().getSelectedItems());
        hierarchy.setCellFactory(view -> new DocumentPropertyCell(projectTreeComponent));
        hierarchy.getSelectionModel().setSelectionMode(SINGLE);

        populateTree(project);
    }

    private void populateTree(ProjectProperty project) {
        requireNonNull(project);
        final TreeItem<DocumentProperty> root = branch(project);
        hierarchy.setRoot(root);
        hierarchy.getSelectionModel().select(root);
    }

    private <P extends DocumentProperty & HasExpandedProperty>
    TreeItem<DocumentProperty> branch(P doc) {
        requireNonNull(doc);

        final TreeItem<DocumentProperty> branch = new TreeItem<>(doc);
        branch.expandedProperty().bindBidirectional(doc.expandedProperty());

        final ListChangeListener<? super DocumentProperty> onListChange =
            (ListChangeListener.Change<? extends DocumentProperty> change) -> {
            while (change.next()) {
                if (change.wasAdded()) {
                    change.getAddedSubList().stream()
                        .filter(HasExpandedProperty.class::isInstance)
                        .map(d -> (HasExpandedProperty) d)
                        .map(this::branch)
                        .forEachOrdered(branch.getChildren()::add);
                }

                if (change.wasRemoved()) {
                    change.getRemoved()
                        .forEach(val -> branch.getChildren()
                            .removeIf(item -> val.equals(item.getValue()))
                        );
                }
            }
        };

        // Create a branch for every child
        doc.children()
            .filter(HasExpandedProperty.class::isInstance)
            .map(d -> (HasExpandedProperty) d)
            .map(this::branch)
            .forEachOrdered(branch.getChildren()::add);

        //  Listen to changes in the actual map
        doc.childrenProperty().addListener(
            (MapChangeListener.Change<
                ? extends String,
                ? extends ObservableList<DocumentProperty>> change) -> {

            if (change.wasAdded()) {

                // Listen for changes in the added list
                change.getValueAdded().addListener(onListChange);

                // Create a branch for every child
                change.getValueAdded().stream()
                    .filter(HasExpandedProperty.class::isInstance)
                    .map(d -> (DocumentProperty & HasExpandedProperty) d)
                    .map(this::branch)
                    .forEachOrdered(branch.getChildren()::add);
            }
        });

        // Listen to changes in every list inside the map
        doc.childrenProperty()
            .values()
            .forEach(list -> list.addListener(onListChange));

        return branch;
    }

    private static final class DocumentPropertyCell extends TreeCell<DocumentProperty> {

        private final ChangeListener<Boolean> change = (ob, o, enabled) -> {
            if (enabled) {
                enable();
            } else {
                disable();
            }
        };

        private final ProjectTreeComponent projectTreeComponent;

        DocumentPropertyCell(ProjectTreeComponent projectTreeComponent) {
            this.projectTreeComponent = requireNonNull(projectTreeComponent);

            // Listener should be initiated with a listener attached
            // that removes enabled-listeners attached to the previous
            // node when a new node is selected.
            itemProperty().addListener((ob, o, n) -> {

                if (o instanceof HasEnabledProperty) {
                    final HasEnabledProperty hasEnabled = (HasEnabledProperty) o;
                    hasEnabled.enabledProperty().removeListener(change);
                }

                if (n instanceof HasEnabledProperty) {
                    final HasEnabledProperty hasEnabled = (HasEnabledProperty) n;
                    hasEnabled.enabledProperty().addListener(change);
                }
            });
        }

        private void disable() {
            getStyleClass().add("gui-disabled");
        }

        private void enable() {
            while (getStyleClass().remove("gui-disabled")) {
                // Do nothing.
            }
        }

        @Override
        protected void updateItem(DocumentProperty item, boolean empty) {
            // item can be null
            super.updateItem(item, empty);

            if (empty || item == null) {
                textProperty().unbind();

                setText(null);
                setGraphic(null);
                setContextMenu(null);

                disable();
            } else {
                final ImageView icon;

                if (item instanceof HasIconPath) {
                    final HasIconPath hasIcon = (HasIconPath) item;
                    icon = new ImageView(new Image(hasIcon.getIconPath()));
                } else {
                    icon = SpeedmentIcon.forNode(item);
                }

                setGraphic(icon);

                if (item instanceof HasNameProperty) {
                    @SuppressWarnings("unchecked")
                    final HasNameProperty withName = (HasNameProperty) item;
                    textProperty().bind(withName.nameProperty());
                } else {
                    textProperty().unbind();
                    textProperty().setValue(null);
                }

                projectTreeComponent.createContextMenu(this, item)
                    .ifPresent(this::setContextMenu);

                updateEnabled(item);

                getTreeView().refresh();
            }
        }

        private void updateEnabled(DocumentProperty item) {
            boolean indicateEnabled = HasEnabled.test(item);

            if (item instanceof ColumnProperty) {
                indicateEnabled &= ((ColumnProperty) item).getParentOrThrow().isEnabled();
            } else if (item instanceof IndexProperty) {
                indicateEnabled &= ((IndexProperty) item).getParentOrThrow().isEnabled();
            } else if (item instanceof PrimaryKeyColumnProperty) {
                indicateEnabled &= ((PrimaryKeyColumnProperty) item).getParentOrThrow().isEnabled();
            }

            if (indicateEnabled) {
                enable();
            } else {
                disable();
            }
        }
    }
}


text:
'use strict'

var mongojs = require('mongojs')
var Promise = require('promise')

function denodeify(proto, method) {
  proto[method] = Promise.denodeify(proto[method])
}

function mixinPromise(proto, fn) {
  proto.then = function (onFulfilled, onRejected) {
    var self = this
    var res = new Promise(function (resolve, reject) {
      fn(self, function (err, res) {
        if (err) reject(err)
        else resolve(res)
      })
    })
    return res.then.apply(res, arguments)
  }
  Object.keys(Promise.prototype)
    .forEach(function (key) {
      if (!(key in proto)) {
        proto[key] = Promise.prototype[key]
      }
    })
}

/* Fix Cursor */

var Cursor = mongojs.Cursor

mixinPromise(Cursor.prototype, function (self, cb) {
  return self.toArray(cb)
})
var cursorTerminators = [
  'count',
  'explain',
  'close'
];
cursorTerminators.forEach(function (key) {
  denodeify(Cursor.prototype, key)
})

/* Fix Collection */

var Collection = mongojs.Collection

Object.keys(Collection.prototype)
  .forEach(function (key) {
    if (key !== 'find' && key[0] != '_' && typeof Collection.prototype[key] === 'function') {
      denodeify(Collection.prototype, key)
    }
  })

/* Fix Database */

var Database = mongojs.Database

Object.keys(Database.prototype)
  .forEach(function (key) {
    if (key !== 'removeAllEventListeners' && key !== 'collection' && key[0] != '_' && typeof Database.prototype[key] === 'function') {
      denodeify(Database.prototype, key)
    }
  })

module.exports = mongojs


text:
package timely.client.websocket;

import java.util.List;
import java.util.Map;

import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.MessageHandler;
import javax.websocket.Session;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class ClientHandler extends Endpoint {

    private final static Logger LOG = LoggerFactory.getLogger(ClientHandler.class);

    @Override
    public void onOpen(Session session, EndpointConfig config) {
        LOG.info("Websocket session {} opened.", session.getId());
        session.addMessageHandler(new MessageHandler.Whole<String>() {

            @Override
            public void onMessage(String message) {
                LOG.info("Message received on Websocket session {}: {}", session.getId(), message);
            }
        });
    }

    @Override
    public void onClose(Session session, CloseReason reason) {
        LOG.info("Websocket session {} closed.", session.getId());
    }

    @Override
    public void onError(Session session, Throwable error) {
        LOG.error("Error occurred on Websocket session" + session.getId(), error);
    }

    public void beforeRequest(Map<String, List<String>> headers) {
    }
}


text:
import argparse

import numpy as np
from pandasql import sqldf

from research.dataframe import *

def pysqldf(q):
    return sqldf(q, globals())

parser = argparse.ArgumentParser(description='Query a structured file using SQL syntax')
parser.add_argument('input', nargs='+', help='Input files')
parser.add_argument('--sql', '-q', type=str, help='SQL query')
parser.add_argument('--output', '-o', help='Output file')
parser.add_argument('--input-formats', '-f', nargs='*', help='A list of input file formats')
parser.add_argument('--output-format', '-F', help='The output file format', default="parquet")
parser.add_argument('--dtypes', '-d', nargs='*', type=type_mapping, help='Types of column you want to explicitly define')
args = parser.parse_args()

formats = args.input_formats
if formats is None:
    formats = ["parquet" for i in args.input]
if len(formats) == 1 and len(args.input) > 1:
    formats = [formats[0] for i in args.input]
if len(formats) < len(args.input):
    raise ValueError("Not enough input formats")

for idx, file in enumerate(args.input):
    vars()["df{}".format(idx)] = get_file(file, formats[idx])
df = vars()["df0"]

if args.sql is None:
    r = df
else:
    r = pysqldf(args.sql)

if args.dtypes is not None:
    for column, type in args.dtypes:
        r[column] = r[column].astype(getattr(np, type))

if args.output is None:
    print(r)
else:
    save_file(r, args.output, args.output_format)


text:
if [ -z "$ANACONDA_API_TOKEN" ]; then
    echo "The variable 'ANACONDA_API_TOKEN' cannot be empty"
    exit 1
fi

# Create all the osx conda packages
conda build .

# Start docker for the linux packages
open --hide --background -a Docker
while ! (docker ps > /dev/null 2>&1); do
    echo "Waiting for docker to start..."
    sleep 1
done

# Create all the linux binary conda packages on centos 6
docker run -i -t \
    -e ANACONDA_API_TOKEN \
    -v ${HOME}/.condarc:/root/.condarc:ro \
    -v `pwd`:/code \
    moble/miniconda-centos bash -c 'conda build /code'


text:
classdef prtFeatSelSbs < prtFeatSel
% prtFeatSelSfs   Sequential forward feature selection object.
%
%    FEATSEL = prtFeatSelSfs creates a sequental forward feature selection
%    object.
%
%    FEATSEL = prtFeatSelSfs(PROPERTY1, VALUE1, ...) constructs a
%    prttFeatSelSfs object FEATSEL with properties as specified by
%    PROPERTY/VALUE pair
%
%    A prtFeatSelSfsobject has the following properties:
%
%    nFeatures             - The number of features to be selected
%    showProgressBar       - Flag indicating whether or not to show the
%                            progress bar during feature selection.
%    evaluationMetric      - The metric to be used to determine which
%                            features are selected. evaluationMetric must
%                            be a function handle. The function handle must
%                            be in the form:
%                            @(dataSet)prtEval(prtClass, dataSet, varargin)
%                            where prtEvak is a prtEval function, prtClass
%                            is a prt classifier object, and varargin
%                            represents optional input arguments to a
%                            prtEval function.
%
%    peformance            - The performance obtained by the using the
%                            features selected.
%    selectedFeatures      - The indices of the features selected that gave
%                            the best performance.
%
%   A prtFeatSelExhaustive object inherits the TRAIN and RUN methods
%   from prtClass.
%
%   Example:
%
%   dataSet = prtDataGenFeatureSelection;         % Generate a data set
%   featSel = prtFeatSelSfs;          % Create a feature selction object
%   featSel.nFeatures = 3;            % Select only one feature of the data
%   featSel = featSel.train(dataSet); % Train the feature selection object
%   outDataSet = featSel.run(dataSet);% Extract the data set with only the
%                                     % selected features
%
%   %   Change the scoring function to prtScorePdAtPf, and change the
%   %   classification method to prtClassMAP
%
%   featSel.evaluationMetric = @(DS)prtEvalPdAtPf(prtClassMap, DS, .9);
%
%   featSel = featSel.train(dataSet);
%   outDataSet = featSel.run(dataSet);
%
 % See Also:  prtFeatSelStatic, prtFeatSelExhaustive

    properties (SetAccess=private)
        name = 'Sequentual Backward Search'
        nameAbbreviation = 'SBS'
    end

    properties
        % General Classifier Properties
        nFeatures = 3;                    % The number of features to be selected
        evaluationMetric = @(DS)prtEvalAuc(prtClassFld,DS);   % The metric used to evaluate performance
    end

    properties (SetAccess = protected)
        performance = [];        % The evalutationMetric for the selected features
        selectedFeatures = [];   % The integer values of the selected features
    end

    methods
        function Obj = prtFeatSelSbs(varargin)
            Obj.isCrossValidateValid = false;
            Obj = prtUtilAssignStringValuePairs(Obj,varargin{:});
        end

        function Obj = set.nFeatures(Obj,val)
            if ~prtUtilIsPositiveScalarInteger(val);
                error('prt:prtFeatSelSfs','nFeatures must be a positive scalar integer.');
            end
            Obj.nFeatures = val;
        end

        function Obj = set.evaluationMetric(Obj,val)
            assert(isa(val, 'function_handle') && nargin(val)>=1,'prt:prtFeatSelExhaustive','evaluationMetric must be a function handle that accepts one input argument.');
            Obj.evaluationMetric = val;
        end

    end
    methods (Access=protected,Hidden=true)

        function Obj = trainAction(Obj,DS)

            nFeatsTotal = DS.nFeatures;
            nSelectFeatures = min(nFeatsTotal,Obj.nFeatures);
            nFeatsToRemove = nFeatsTotal-nSelectFeatures;

            Obj.performance = nan(1,nSelectFeatures);
            Obj.selectedFeatures = nan(1,nSelectFeatures);

            sbsSelectedFeatures = 1:nFeatsTotal;

            if Obj.showProgressBar
                h = prtUtilProgressBar(0,'Feature Selection - SBS','autoClose',true);
            end

            for j = 1:nFeatsToRemove

                if Obj.showProgressBar && j == 1
                    h2 = prtUtilProgressBar(0,sprintf('Selecting Feature %d',j),'autoClose',false);
                elseif Obj.showProgressBar
                    h2.titleStr = sprintf('Selecting Feature %d',j);
                    h2.update(0);
                end

                cPerformance = nan(1,length(sbsSelectedFeatures));
                for i = 1:length(sbsSelectedFeatures)
                    currentFeatureSet = sbsSelectedFeatures;
                    currentFeatureSet(i) = [];
                    tempDataSet = DS.retainFeatures(currentFeatureSet);

                    cPerformance(i) = Obj.evaluationMetric(tempDataSet);

                    if Obj.showProgressBar
                        h2.update(i/length(sbsSelectedFeatures));
                    end
                end

                if Obj.showProgressBar
                    % Make sure it's closed.
                    h2.update(1);
                end

                if all(~isfinite(cPerformance))
                    error('prt:prtFeatSelSfs','All evaluation matrics resulted in non-finite values. Check evalutionMetric');
                end

                % Randomly choose the next feature if more than one provide the same performance
                [val,worstFeatInd] = max(cPerformance);
                sbsSelectedFeatures(worstFeatInd) = [];

                if Obj.showProgressBar
                    h.update(j/nFeatsToRemove);
                end
            end
            Obj.performance = val;
            Obj.selectedFeatures = sbsSelectedFeatures;

            if Obj.showProgressBar
                % Make sure it's closed.
                h.update(1);
            end
        end

        function DataSet = runAction(Obj,DataSet)
            if ~Obj.isTrained
                error('prt:prtFeatSelSfs','Attempt to run a prtFeatSel that is not trained');
            end
            DataSet = DataSet.retainFeatures(Obj.selectedFeatures);
        end
    end
end


text:
@interface DHSettingDetailTableViewController : UITableViewController

@end


text:
import UrlBuilder from './urlBuilder'
import UtilXHR from './utilXhr'

export default class Object {

  constructor (type, id, payload) {
    this._type = type
    this._id = id
    this._payload = payload
  }

  create (cb) {
    var ret = this._payload;
    UtilXHR.post(this._payload, UrlBuilder.forData(this._type), function(err, data){

      if (data) {
        ret.meta = {
          id: data.id
        }
      }

      cb(err, ret)
    });
  }

  update (cb, opts) {
    UtilXHR.put(this._payload, UrlBuilder.forDataObject(this._type, this._id, opts), cb)
  }

  delete (cb) {
    UtilXHR.delete(UrlBuilder.forDataObject(this._type, this._id), cb)
  }

  get (cb) {
    UtilXHR.get(UrlBuilder.forDataObject(this._type, this._id), cb)
  }

}