text:
<title>kite 0.6.0: project(n) -- Kite Project Metadata Manager, submodule of kiteutils(n)</title>

 kite 0.6.0: Kite Project Automation Tool

NAME

project(n) -- Kite Project Metadata Manager, submodule of kiteutils(n)

NAME

SYNOPSIS

DESCRIPTION

Reading Project Metadata

COMMANDS

ENVIRONMENT

AUTHORS

SYNOPSIS

package require kiteutils 0.6.0
namespace import ::kiteutils::*

project add subcommand ?args...?

project add app name ?options...?

project add lib name ?options...?

project app subcommand ?args...?

project app names

project app primary

project app apptype app

project app exclude app

project app force app

project app gui app

project app icon app

project app loader app

project app binfile app

project app installfile app

project description

project dist subcommand ?args...?

project dist names

project dist patterns dist

project dist files dist

project dist zipfile dist

project getinfo

project globdirs ?patterns...?

project globfiles ?patterns...?

project globroot ?patterns...?

project hasinfo

project hook when tool

project hooks

project intree

project intree

project load

project libpath

project mansecs

project mansec section

project name

project new name ?description?

project poc

project provide subcommand ?args...?

project provide names

project provide binary lib

project provide platform lib

project provide zipfile lib

project require subcommand ?args...?

project require names

project require version lib

project require islocal lib

project root ?args...?

project save

project shell

project src subcommand ?args...?

project src names

project src build src

project src clean src

project version

project zippath

DESCRIPTION

Most modules in kiteutils(n) are intended for use by general
applications.  The project(n) module is specifically for use by
Kite itself, and for external development tools that need access to
Kite project metadata.

In particular, project(n) contains the code to:

 Locate the root of the project tree containing the current working
directory, if any.

 Load the project metadata from its project.kite file.

 Make the metadata available to the client.

 Update the metadata in certain ways.

 Save an updated project.kite.

 Create new, empty project trees.

In general, the commands that modify or create project trees should be
left for Kite's use.

The project(5) man page defines the syntax of the
project.kite file.

Reading Project Metadata

First, use project root to find the root directory of the project tree
that contains the current working directory.  If it returns the empty string,
you are not in a project tree.

Next, use project load to load the project metadata.  It will read
the project's project.kite file, throwing SYNTAX on error.

Next, use the various commands to query the metadata.

COMMANDS

project add subcommand ?args...?

The subcommands of this command add new elements to the project
metadata.  Note that they do not add anything to project tree itself;
the code to create new project elements on the disk resides in Kite itself.
As a result, these commands should be used only by Kite itself.

project add app name ?options...?

Adds a new application to the project metadata, as though it had been
read from project.kite.

project add lib name ?options...?

Adds a new provided library package to the project metadata, as though it
had been read from project.kite.

project app subcommand ?args...?

The subcommands of this command return information about any
applications defined by the project.

project app names

Returns a list of the names of the applications defined by the project.

project app primary

Returns the name of the project's primary application (the first defined
in the project file), or "" if the project doesn't include any applications.

project app apptype app

Returns the executable type for the named app, kit or exe.

project app exclude app

Returns a list of the project require names that are explicitly
excluded from this application.

project app force app

Returns 1 if the named app was defined with the -force option,
and 0 otherwise.

project app gui app

Returns 1 if the named app intends to use Tk, and 0 otherwise.

project app icon app

Returns the name of the app's icon file, or "" if none.

project app loader app

Returns the name of the project's application loader script, which is
generally root/bin/app.tcl.

project app binfile app

Returns the name of the executable produced for app on the current
platform, as found in the project's bin/ directory.

project app installfile app

Returns the name of the executable installed for app on the current
platform.

project description

Returns the project's description string, a kind of project title.

project dist subcommand ?args...?

The subcommands of this command return information about any
distribution .zip files defined by the project.

project dist names

Returns a list of the names of the distribution sets defined by
the project.

project dist patterns dist

Each distribution set is defined by a list of patterns which determine
which files are included in the .zip file.  This command returns the
list for the named dist set.

project dist files dist

This command returns a dictionary of the files that match the patterns
for the named dist set.  The value is the full name of each file
on the disk; the key is the name of the file in the distribution,
relative to the root directory of the distribution.

project dist zipfile dist

This command returns the name of the distribution .zip file for
this dist set.

project getinfo

This command returns a dictionary of all of the project's metadata.
The return value is in an internal format which can change without
notice.

project globdirs ?patterns...?

This command is like project globroot, but returns only the names
of project directories that match the joined patterns.

project globfiles ?patterns...?

This command is like project globroot, but returns only the names
of genuine files that match the joined patterns, i.e., it excludes
directories and so forth.

project globroot ?patterns...?

This command joins its arguments to the project's root directory, as
project root does, and then passes the resulting pattern to
glob,
returning the resulting list.  If no files are found, the result is
the empty list.

project hasinfo

Returns 1 if project metadata has been successfully loaded, and 0
otherwise.

project hook when tool

The value of when must be one of before or after.
Returns the list of hook scripts defined to run either before or
after the specified kite tool, or "" if none.
See project(5) for a list of the tools for which hooks are
defined.

project hooks

Returns a flat list of when tool pairs for the hooks that are actually
defined in the project file.

project intree

After project root has been called at least once, this command
returns 1 if the current working directory is within a Kite project
tree, and 0 otherwise.

project intree

After project root has been called at least once, this command
returns 1 if the current working directory is within a Kite project
tree, and 0 otherwise.

project load

Attempts to load the project metadata from the project.kite file.
Be sure to call project root first, and verify that there is a
profile file to load.  Once the metadata has been loaded,
project hasinfo will return 1.

project libpath

Returns a Tcl list of library directories associated with this project.
This is typically used to initialize TCL_LIB_PATH prior to invoking
an external tclsh.

project mansecs

Returns the section tags associated with the man page sections defined
for this project.

project mansec section

Returns the title of the man page section with tag section.

project name

Returns the project's name.

project new name ?description?

Creates a new project called name in a subdirectory of the current
working also called name.  The project's description defaults to
"Your project description".

This command is for use by Kite itself, and should be used with
caution.

project poc

Returns the e-mail address of the project's point-of-contact.

project provide subcommand ?args...?

The subcommands of this command return information about any
library packages provided by the project for external use.

project provide names

Returns a list of the names of the library packages
provided by the project.

project provide binary lib

Returns 1 if the named lib is a compiled binary extension, and 0
if it is pure-Tcl.

project provide platform lib

Returns the platform string to use when wrapping the library.  For pure-Tcl
packages, this is "tcl"; for binary packages it is generally the
platform::identify string.

project provide zipfile lib

Provides the base name of the teapot .zip file Kite produces when building
the provided library.

project require subcommand ?args...?

The subcommands of this command return information about any
external library packages required by the project.

project require names

Returns a list of the names of the external library packages
required by the project.

project require version lib

Returns the version number of the named lib that the project requires.

project require islocal lib

Returns 1 if the required lib is locally built (and so must be
installed manually by the developer) and 0 if it is available remotely
(i.e., from teapot.activestate.com).

project root ?args...?

Called with no arguments, this command locates the root directory of the
Kite project containing the current working directory, i.e., the directory
in which project.kite is found.  If arguments are provided, they
are joined to the root directory as by
file join
and the result is returned.

If no project is found, the command returns the empty string whether it
is given arguments or not.

project save

Saves the current metadata to project.kite.  This is useful only
after using one of the project add commands, and should be left
to Kite itself.

project shell

Returns the shell initialization script defined in the project file,
or "" if none.

project src subcommand ?args...?

The subcommands of this command return information about any
"src/" directories defined by the project.  "src/"
directories usually contain non-Tcl code that needs to compiled and
built into a binary Tcl extension.

project src names

Returns a list of the names of the "src/" directory names
defined by the project.

project src build src

Returns the build command for the named src directory, the
command used to compile the contents of the directory.

project src clean src

Returns the clean command for the named src directory, the
command used to clean up all build products for the directory.

project version

Returns the project's version number, which must be a valid Tcl package
version number.

project zippath

Returns the absolute path of the directory in which Kite places the
teapot .zip files it builds for provided library packages.

ENVIRONMENT

Requires Tcl 8.6 or later.

AUTHORS

Will Duquette

kite 0.6.0 Man page generated by manpage(n) on
Mon Oct 03 13:02:09 PDT 2016


text:
define
(
    ["model/base", "model/Core"],
    /**
     * An extension to the Core Package that, in association with the Terminal class, models Connectivity, that is the physical definition of how equipment is connected together.
     *
     * In addition it models Topology, that is the logical definition of how equipment is connected via closed switches. The Topology definition is independent of the other electrical characteristics.
     *
     */
    function (base, Core)
    {
        /**
         * Used to apply user standard names to TopologicalNodes.
         *
         * Associated with one or more terminals that are normally connected with the bus name.    The associated terminals are normally connected by non-retained switches. For a ring bus station configuration, all BusbarSection terminals in the ring are typically associated.   For a breaker and a half scheme, both BusbarSections would normally be associated.  For a ring bus, all BusbarSections would normally be associated.  For a "straight" busbar configuration, normally only the main terminal at the BusbarSection would be associated.
         *
         */
        class BusNameMarker extends Core.IdentifiedObject
        {
            constructor (template, cim_data)
            {
                super (template, cim_data);
                let bucket = cim_data.BusNameMarker;
                if (null == bucket)
                   cim_data.BusNameMarker = bucket = {};
                bucket[template.id] = template;
            }

            remove (obj, cim_data)
            {
               super.remove (obj, cim_data);
               delete cim_data.BusNameMarker[obj.id];
            }

            parse (context, sub)
            {
                let obj = Core.IdentifiedObject.prototype.parse.call (this, context, sub);
                obj.cls = "BusNameMarker";
                base.parse_element (/<cim:BusNameMarker.priority>([\s\S]*?)<\/cim:BusNameMarker.priority>/g, obj, "priority", base.to_string, sub, context);
                base.parse_attribute (/<cim:BusNameMarker.ReportingGroup\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "ReportingGroup", sub, context);
                base.parse_attribute (/<cim:BusNameMarker.TopologicalNode\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "TopologicalNode", sub, context);
                base.parse_attributes (/<cim:BusNameMarker.Terminal\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "Terminal", sub, context);
                let bucket = context.parsed.BusNameMarker;
                if (null == bucket)
                   context.parsed.BusNameMarker = bucket = {};
                bucket[obj.id] = obj;

                return (obj);
            }

            export (obj, full)
            {
                let fields = Core.IdentifiedObject.prototype.export.call (this, obj, false);

                base.export_element (obj, "BusNameMarker", "priority", "priority",  base.from_string, fields);
                base.export_attribute (obj, "BusNameMarker", "ReportingGroup", "ReportingGroup", fields);
                base.export_attribute (obj, "BusNameMarker", "TopologicalNode", "TopologicalNode", fields);
                base.export_attributes (obj, "BusNameMarker", "Terminal", "Terminal", fields);
                if (full)
                    base.Element.prototype.export.call (this, obj, fields);

                return (fields);
            }

            template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>BusNameMarker</legend>

                    `
                    + Core.IdentifiedObject.prototype.template.call (this) +
                    `
                    {{#priority}}
priority: {{priority}}
{{/priority}}
                    {{#ReportingGroup}}
ReportingGroup: {{ReportingGroup}}
{{/ReportingGroup}}
                    {{#TopologicalNode}}
TopologicalNode: {{TopologicalNode}}
{{/TopologicalNode}}
                    {{#Terminal}}
Terminal: {{.}}
{{/Terminal}}

                    </fieldset>

                    `
                );
            }

            condition (obj)
            {
                super.condition (obj);
                if (obj["Terminal"]) obj["Terminal_string"] = obj["Terminal"].join ();
            }

            uncondition (obj)
            {
                super.uncondition (obj);
                delete obj["Terminal_string"];
            }

            edit_template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>BusNameMarker</legend>

                    `
                    + Core.IdentifiedObject.prototype.edit_template.call (this) +
                    `

priority:
<input id='{{id}}_priority' class='form-control' type='text'{{#priority}} value='{{priority}}'{{/priority}}>

ReportingGroup:
<input id='{{id}}_ReportingGroup' class='form-control' type='text'{{#ReportingGroup}} value='{{ReportingGroup}}'{{/ReportingGroup}}>

TopologicalNode:
<input id='{{id}}_TopologicalNode' class='form-control' type='text'{{#TopologicalNode}} value='{{TopologicalNode}}'{{/TopologicalNode}}>

                    </fieldset>
                    `
                );
            }

            submit (id, obj)
            {
                let temp;

                obj = obj || { id: id, cls: "BusNameMarker" };
                super.submit (id, obj);
                temp = document.getElementById (id + "_priority").value; if ("" !== temp) obj["priority"] = temp;
                temp = document.getElementById (id + "_ReportingGroup").value; if ("" !== temp) obj["ReportingGroup"] = temp;
                temp = document.getElementById (id + "_TopologicalNode").value; if ("" !== temp) obj["TopologicalNode"] = temp;

                return (obj);
            }

            relations ()
            {
                return (
                    super.relations ().concat (
                        [
                            ["ReportingGroup", "0..1", "0..*", "ReportingGroup", "BusNameMarker"],
                            ["TopologicalNode", "0..1", "0..*", "TopologicalNode", "BusNameMarker"],
                            ["Terminal", "1..*", "0..1", "ACDCTerminal", "BusNameMarker"]
                        ]
                    )
                );
            }
        }

        /**
         * For a detailed substation model a topological node is a set of connectivity nodes that, in the current network state, are connected together through any type of closed switches, including  jumpers.
         *
         * Topological nodes change as the current network state changes (i.e., switches, breakers, etc. change state).
         * For a planning model, switch statuses are not used to form topological nodes. Instead they are manually created or deleted in a model builder tool. Topological nodes maintained this way are also called "busses".
         *
         */
        class TopologicalNode extends Core.IdentifiedObject
        {
            constructor (template, cim_data)
            {
                super (template, cim_data);
                let bucket = cim_data.TopologicalNode;
                if (null == bucket)
                   cim_data.TopologicalNode = bucket = {};
                bucket[template.id] = template;
            }

            remove (obj, cim_data)
            {
               super.remove (obj, cim_data);
               delete cim_data.TopologicalNode[obj.id];
            }

            parse (context, sub)
            {
                let obj = Core.IdentifiedObject.prototype.parse.call (this, context, sub);
                obj.cls = "TopologicalNode";
                base.parse_element (/<cim:TopologicalNode.pInjection>([\s\S]*?)<\/cim:TopologicalNode.pInjection>/g, obj, "pInjection", base.to_string, sub, context);
                base.parse_element (/<cim:TopologicalNode.qInjection>([\s\S]*?)<\/cim:TopologicalNode.qInjection>/g, obj, "qInjection", base.to_string, sub, context);
                base.parse_attribute (/<cim:TopologicalNode.AngleRefTopologicalIsland\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "AngleRefTopologicalIsland", sub, context);
                base.parse_attribute (/<cim:TopologicalNode.TopologicalIsland\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "TopologicalIsland", sub, context);
                base.parse_attributes (/<cim:TopologicalNode.Terminal\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "Terminal", sub, context);
                base.parse_attribute (/<cim:TopologicalNode.BaseVoltage\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "BaseVoltage", sub, context);
                base.parse_attributes (/<cim:TopologicalNode.ConnectivityNodes\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "ConnectivityNodes", sub, context);
                base.parse_attribute (/<cim:TopologicalNode.ReportingGroup\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "ReportingGroup", sub, context);
                base.parse_attribute (/<cim:TopologicalNode.ConnectivityNodeContainer\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "ConnectivityNodeContainer", sub, context);
                base.parse_attributes (/<cim:TopologicalNode.BusNameMarker\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "BusNameMarker", sub, context);
                base.parse_attributes (/<cim:TopologicalNode.SvInjection\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "SvInjection", sub, context);
                base.parse_attributes (/<cim:TopologicalNode.SvVoltage\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "SvVoltage", sub, context);
                let bucket = context.parsed.TopologicalNode;
                if (null == bucket)
                   context.parsed.TopologicalNode = bucket = {};
                bucket[obj.id] = obj;

                return (obj);
            }

            export (obj, full)
            {
                let fields = Core.IdentifiedObject.prototype.export.call (this, obj, false);

                base.export_element (obj, "TopologicalNode", "pInjection", "pInjection",  base.from_string, fields);
                base.export_element (obj, "TopologicalNode", "qInjection", "qInjection",  base.from_string, fields);
                base.export_attribute (obj, "TopologicalNode", "AngleRefTopologicalIsland", "AngleRefTopologicalIsland", fields);
                base.export_attribute (obj, "TopologicalNode", "TopologicalIsland", "TopologicalIsland", fields);
                base.export_attributes (obj, "TopologicalNode", "Terminal", "Terminal", fields);
                base.export_attribute (obj, "TopologicalNode", "BaseVoltage", "BaseVoltage", fields);
                base.export_attributes (obj, "TopologicalNode", "ConnectivityNodes", "ConnectivityNodes", fields);
                base.export_attribute (obj, "TopologicalNode", "ReportingGroup", "ReportingGroup", fields);
                base.export_attribute (obj, "TopologicalNode", "ConnectivityNodeContainer", "ConnectivityNodeContainer", fields);
                base.export_attributes (obj, "TopologicalNode", "BusNameMarker", "BusNameMarker", fields);
                base.export_attributes (obj, "TopologicalNode", "SvInjection", "SvInjection", fields);
                base.export_attributes (obj, "TopologicalNode", "SvVoltage", "SvVoltage", fields);
                if (full)
                    base.Element.prototype.export.call (this, obj, fields);

                return (fields);
            }

            template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>TopologicalNode</legend>

                    `
                    + Core.IdentifiedObject.prototype.template.call (this) +
                    `
                    {{#pInjection}}
pInjection: {{pInjection}}
{{/pInjection}}
                    {{#qInjection}}
qInjection: {{qInjection}}
{{/qInjection}}
                    {{#AngleRefTopologicalIsland}}
AngleRefTopologicalIsland: {{AngleRefTopologicalIsland}}
{{/AngleRefTopologicalIsland}}
                    {{#TopologicalIsland}}
TopologicalIsland: {{TopologicalIsland}}
{{/TopologicalIsland}}
                    {{#Terminal}}
Terminal: {{.}}
{{/Terminal}}
                    {{#BaseVoltage}}
BaseVoltage: {{BaseVoltage}}
{{/BaseVoltage}}
                    {{#ConnectivityNodes}}
ConnectivityNodes: {{.}}
{{/ConnectivityNodes}}
                    {{#ReportingGroup}}
ReportingGroup: {{ReportingGroup}}
{{/ReportingGroup}}
                    {{#ConnectivityNodeContainer}}
ConnectivityNodeContainer: {{ConnectivityNodeContainer}}
{{/ConnectivityNodeContainer}}
                    {{#BusNameMarker}}
BusNameMarker: {{.}}
{{/BusNameMarker}}
                    {{#SvInjection}}
SvInjection: {{.}}
{{/SvInjection}}
                    {{#SvVoltage}}
SvVoltage: {{.}}
{{/SvVoltage}}

                    </fieldset>

                    `
                );
            }

            condition (obj)
            {
                super.condition (obj);
                if (obj["Terminal"]) obj["Terminal_string"] = obj["Terminal"].join ();
                if (obj["ConnectivityNodes"]) obj["ConnectivityNodes_string"] = obj["ConnectivityNodes"].join ();
                if (obj["BusNameMarker"]) obj["BusNameMarker_string"] = obj["BusNameMarker"].join ();
                if (obj["SvInjection"]) obj["SvInjection_string"] = obj["SvInjection"].join ();
                if (obj["SvVoltage"]) obj["SvVoltage_string"] = obj["SvVoltage"].join ();
            }

            uncondition (obj)
            {
                super.uncondition (obj);
                delete obj["Terminal_string"];
                delete obj["ConnectivityNodes_string"];
                delete obj["BusNameMarker_string"];
                delete obj["SvInjection_string"];
                delete obj["SvVoltage_string"];
            }

            edit_template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>TopologicalNode</legend>

                    `
                    + Core.IdentifiedObject.prototype.edit_template.call (this) +
                    `

pInjection:
<input id='{{id}}_pInjection' class='form-control' type='text'{{#pInjection}} value='{{pInjection}}'{{/pInjection}}>

qInjection:
<input id='{{id}}_qInjection' class='form-control' type='text'{{#qInjection}} value='{{qInjection}}'{{/qInjection}}>

AngleRefTopologicalIsland:
<input id='{{id}}_AngleRefTopologicalIsland' class='form-control' type='text'{{#AngleRefTopologicalIsland}} value='{{AngleRefTopologicalIsland}}'{{/AngleRefTopologicalIsland}}>

TopologicalIsland:
<input id='{{id}}_TopologicalIsland' class='form-control' type='text'{{#TopologicalIsland}} value='{{TopologicalIsland}}'{{/TopologicalIsland}}>

BaseVoltage:
<input id='{{id}}_BaseVoltage' class='form-control' type='text'{{#BaseVoltage}} value='{{BaseVoltage}}'{{/BaseVoltage}}>

ReportingGroup:
<input id='{{id}}_ReportingGroup' class='form-control' type='text'{{#ReportingGroup}} value='{{ReportingGroup}}'{{/ReportingGroup}}>

ConnectivityNodeContainer:
<input id='{{id}}_ConnectivityNodeContainer' class='form-control' type='text'{{#ConnectivityNodeContainer}} value='{{ConnectivityNodeContainer}}'{{/ConnectivityNodeContainer}}>

                    </fieldset>
                    `
                );
            }

            submit (id, obj)
            {
                let temp;

                obj = obj || { id: id, cls: "TopologicalNode" };
                super.submit (id, obj);
                temp = document.getElementById (id + "_pInjection").value; if ("" !== temp) obj["pInjection"] = temp;
                temp = document.getElementById (id + "_qInjection").value; if ("" !== temp) obj["qInjection"] = temp;
                temp = document.getElementById (id + "_AngleRefTopologicalIsland").value; if ("" !== temp) obj["AngleRefTopologicalIsland"] = temp;
                temp = document.getElementById (id + "_TopologicalIsland").value; if ("" !== temp) obj["TopologicalIsland"] = temp;
                temp = document.getElementById (id + "_BaseVoltage").value; if ("" !== temp) obj["BaseVoltage"] = temp;
                temp = document.getElementById (id + "_ReportingGroup").value; if ("" !== temp) obj["ReportingGroup"] = temp;
                temp = document.getElementById (id + "_ConnectivityNodeContainer").value; if ("" !== temp) obj["ConnectivityNodeContainer"] = temp;

                return (obj);
            }

            relations ()
            {
                return (
                    super.relations ().concat (
                        [
                            ["AngleRefTopologicalIsland", "0..1", "0..1", "TopologicalIsland", "AngleRefTopologicalNode"],
                            ["TopologicalIsland", "0..1", "1..*", "TopologicalIsland", "TopologicalNodes"],
                            ["Terminal", "0..*", "0..1", "Terminal", "TopologicalNode"],
                            ["BaseVoltage", "0..1", "0..*", "BaseVoltage", "TopologicalNode"],
                            ["ConnectivityNodes", "0..*", "0..1", "ConnectivityNode", "TopologicalNode"],
                            ["ReportingGroup", "0..1", "0..*", "ReportingGroup", "TopologicalNode"],
                            ["ConnectivityNodeContainer", "0..1", "0..*", "ConnectivityNodeContainer", "TopologicalNode"],
                            ["BusNameMarker", "0..*", "0..1", "BusNameMarker", "TopologicalNode"],
                            ["SvInjection", "0..*", "1", "SvInjection", "TopologicalNode"],
                            ["SvVoltage", "0..*", "1", "SvVoltage", "TopologicalNode"]
                        ]
                    )
                );
            }
        }

        /**
         * An electrically connected subset of the network.
         *
         * Topological islands can change as the current network state changes, e.g. due to:
         * - disconnect switches or breakers changing state in a SCADA/EMS.
         * - manual creation, change or deletion of topological nodes in a planning tool.
         * Only energised TopologicalNode-s shall be part of the topological island.
         *
         */
        class TopologicalIsland extends Core.IdentifiedObject
        {
            constructor (template, cim_data)
            {
                super (template, cim_data);
                let bucket = cim_data.TopologicalIsland;
                if (null == bucket)
                   cim_data.TopologicalIsland = bucket = {};
                bucket[template.id] = template;
            }

            remove (obj, cim_data)
            {
               super.remove (obj, cim_data);
               delete cim_data.TopologicalIsland[obj.id];
            }

            parse (context, sub)
            {
                let obj = Core.IdentifiedObject.prototype.parse.call (this, context, sub);
                obj.cls = "TopologicalIsland";
                base.parse_attribute (/<cim:TopologicalIsland.AngleRefTopologicalNode\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "AngleRefTopologicalNode", sub, context);
                base.parse_attributes (/<cim:TopologicalIsland.TopologicalNodes\s+rdf:resource\s*?=\s*?(["'])([\s\S]*?)\1\s*?\/>/g, obj, "TopologicalNodes", sub, context);
                let bucket = context.parsed.TopologicalIsland;
                if (null == bucket)
                   context.parsed.TopologicalIsland = bucket = {};
                bucket[obj.id] = obj;

                return (obj);
            }

            export (obj, full)
            {
                let fields = Core.IdentifiedObject.prototype.export.call (this, obj, false);

                base.export_attribute (obj, "TopologicalIsland", "AngleRefTopologicalNode", "AngleRefTopologicalNode", fields);
                base.export_attributes (obj, "TopologicalIsland", "TopologicalNodes", "TopologicalNodes", fields);
                if (full)
                    base.Element.prototype.export.call (this, obj, fields);

                return (fields);
            }

            template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>TopologicalIsland</legend>

                    `
                    + Core.IdentifiedObject.prototype.template.call (this) +
                    `
                    {{#AngleRefTopologicalNode}}
AngleRefTopologicalNode: {{AngleRefTopologicalNode}}
{{/AngleRefTopologicalNode}}
                    {{#TopologicalNodes}}
TopologicalNodes: {{.}}
{{/TopologicalNodes}}

                    </fieldset>

                    `
                );
            }

            condition (obj)
            {
                super.condition (obj);
                if (obj["TopologicalNodes"]) obj["TopologicalNodes_string"] = obj["TopologicalNodes"].join ();
            }

            uncondition (obj)
            {
                super.uncondition (obj);
                delete obj["TopologicalNodes_string"];
            }

            edit_template ()
            {
                return (
                    `
                    <fieldset>
                    <legend class='col-form-legend'>TopologicalIsland</legend>

                    `
                    + Core.IdentifiedObject.prototype.edit_template.call (this) +
                    `

AngleRefTopologicalNode:
<input id='{{id}}_AngleRefTopologicalNode' class='form-control' type='text'{{#AngleRefTopologicalNode}} value='{{AngleRefTopologicalNode}}'{{/AngleRefTopologicalNode}}>

                    </fieldset>
                    `
                );
            }

            submit (id, obj)
            {
                let temp;

                obj = obj || { id: id, cls: "TopologicalIsland" };
                super.submit (id, obj);
                temp = document.getElementById (id + "_AngleRefTopologicalNode").value; if ("" !== temp) obj["AngleRefTopologicalNode"] = temp;

                return (obj);
            }

            relations ()
            {
                return (
                    super.relations ().concat (
                        [
                            ["AngleRefTopologicalNode", "0..1", "0..1", "TopologicalNode", "AngleRefTopologicalIsland"],
                            ["TopologicalNodes", "1..*", "0..1", "TopologicalNode", "TopologicalIsland"]
                        ]
                    )
                );
            }
        }

        return (
            {
                TopologicalNode: TopologicalNode,
                TopologicalIsland: TopologicalIsland,
                BusNameMarker: BusNameMarker
            }
        );
    }
);

redpajama_set_name: RedPajamaGithub


text:
typedef struct tree_node {
    int32_t value;
    struct tree_node *left;
    struct tree_node *right;
} node;

node *createNode(int32_t value) {
    node *newNode = (node *) malloc(sizeof(node));
    if (newNode == NULL) {
        exit(EXIT_FAILURE);
    }

    newNode->value = value;
    newNode->left = EMPTY_NODE;
    newNode->right = EMPTY_NODE;

    return newNode;
}

bool isBinarySearchTree(node *root, int32_t min, int32_t max) {
    if (root == EMPTY_NODE) {
        return true;
    }

    if (root->value <= min || root->value > max) {
        return false;
    }

    bool isLeftBst = isBinarySearchTree(root->left, min, root->value);
    bool isRightBst = isBinarySearchTree(root->right, root->value, max);

    return isLeftBst && isRightBst;
}

int main(int argc, const char * argv[]) {
    // create a BST tree
    node *aTree = createNode(20);
    aTree->left = createNode(10);
    aTree->right = createNode(30);
    aTree->right->left = createNode(29);
    aTree->right->right = createNode(40);
    aTree->left->left = createNode(5);
    aTree->left->right = createNode(15);
    printf("aTree is a BST: %s\n", isBinarySearchTree(aTree, INT32_MIN, INT32_MAX) ? "true" : "false");

    // create a non BST tree by adding an "incorrect" value into its leaf.
    node *bTree = aTree;
    bTree->left->right->value = 4; // violate the BST definition
    printf("bTree is a BST: %s\n", isBinarySearchTree(bTree, INT32_MIN, INT32_MAX) ? "true" : "false");

    return 0;
}


text:
FROM node:7.5

MAINTAINER Lechuck Roh <lechuckroh@gmail.com>

RUN mkdir -p /app

WORKDIR /app

ADD . /app

RUN npm install

ENV NODE_ENV=development

EXPOSE 9990

CMD ["npm", "start"]


text:
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#if defined(__sun)
#include <stropts.h>
#endif
#include "config.h"

#if (ULONG_MAX == 4294967295UL)
#define MEMTEST_32BIT
#elif (ULONG_MAX == 18446744073709551615ULL)
#define MEMTEST_64BIT
#else
#error "ULONG_MAX value not supported."
#endif

#ifdef MEMTEST_32BIT
#define ULONG_ONEZERO 0xaaaaaaaaUL
#define ULONG_ZEROONE 0x55555555UL
#else
#define ULONG_ONEZERO 0xaaaaaaaaaaaaaaaaUL
#define ULONG_ZEROONE 0x5555555555555555UL
#endif

#if defined(__has_attribute)
#if __has_attribute(no_sanitize)
#define NO_SANITIZE(sanitizer) __attribute__((no_sanitize(sanitizer)))
#endif
#endif

#if !defined(NO_SANITIZE)
#define NO_SANITIZE(sanitizer)
#endif

static struct winsize ws;
size_t progress_printed; /* Printed chars in screen-wide progress bar. */
size_t progress_full; /* How many chars to write to fill the progress bar. */

void memtest_progress_start(char *title, int pass) {
    int j;

    printf("\x1b[H\x1b[2J");    /* Cursor home, clear screen. */
    /* Fill with dots. */
    for (j = 0; j < ws.ws_col*(ws.ws_row-2); j++) printf(".");
    printf("Please keep the test running several minutes per GB of memory.\n");
    printf("Also check http://www.memtest86.com/ and http://pyropus.ca/software/memtester/");
    printf("\x1b[H\x1b[2K");          /* Cursor home, clear current line.  */
    printf("%s [%d]\n", title, pass); /* Print title. */
    progress_printed = 0;
    progress_full = (size_t)ws.ws_col*(ws.ws_row-3);
    fflush(stdout);
}

void memtest_progress_end(void) {
    printf("\x1b[H\x1b[2J");    /* Cursor home, clear screen. */
}

void memtest_progress_step(size_t curr, size_t size, char c) {
    size_t chars = ((unsigned long long)curr*progress_full)/size, j;

    for (j = 0; j < chars-progress_printed; j++) printf("%c",c);
    progress_printed = chars;
    fflush(stdout);
}

/* Test that addressing is fine. Every location is populated with its own
 * address, and finally verified. This test is very fast but may detect
 * ASAP big issues with the memory subsystem. */
int memtest_addressing(unsigned long *l, size_t bytes, int interactive) {
    unsigned long words = bytes/sizeof(unsigned long);
    unsigned long j, *p;

    /* Fill */
    p = l;
    for (j = 0; j < words; j++) {
        *p = (unsigned long)p;
        p++;
        if ((j & 0xffff) == 0 && interactive)
            memtest_progress_step(j,words*2,'A');
    }
    /* Test */
    p = l;
    for (j = 0; j < words; j++) {
        if (*p != (unsigned long)p) {
            if (interactive) {
                printf("\n*** MEMORY ADDRESSING ERROR: %p contains %lu\n",
                    (void*) p, *p);
                exit(1);
            }
            return 1;
        }
        p++;
        if ((j & 0xffff) == 0 && interactive)
            memtest_progress_step(j+words,words*2,'A');
    }
    return 0;
}

/* Fill words stepping a single page at every write, so we continue to
 * touch all the pages in the smallest amount of time reducing the
 * effectiveness of caches, and making it hard for the OS to transfer
 * pages on the swap.
 *
 * In this test we can't call rand() since the system may be completely
 * unable to handle library calls, so we have to resort to our own
 * PRNG that only uses local state. We use an xorshift* PRNG. */
#define xorshift64star_next() do { \
        rseed ^= rseed >> 12; \
        rseed ^= rseed << 25; \
        rseed ^= rseed >> 27; \
        rout = rseed * UINT64_C(2685821657736338717); \
} while(0)

void memtest_fill_random(unsigned long *l, size_t bytes, int interactive) {
    unsigned long step = 4096/sizeof(unsigned long);
    unsigned long words = bytes/sizeof(unsigned long)/2;
    unsigned long iwords = words/step;  /* words per iteration */
    unsigned long off, w, *l1, *l2;
    uint64_t rseed = UINT64_C(0xd13133de9afdb566); /* Just a random seed. */
    uint64_t rout = 0;

    assert((bytes & 4095) == 0);
    for (off = 0; off < step; off++) {
        l1 = l+off;
        l2 = l1+words;
        for (w = 0; w < iwords; w++) {
            xorshift64star_next();
            *l1 = *l2 = (unsigned long) rout;
            l1 += step;
            l2 += step;
            if ((w & 0xffff) == 0 && interactive)
                memtest_progress_step(w+iwords*off,words,'R');
        }
    }
}

/* Like memtest_fill_random() but uses the two specified values to fill
 * memory, in an alternated way (v1|v2|v1|v2|...) */
void memtest_fill_value(unsigned long *l, size_t bytes, unsigned long v1,
                        unsigned long v2, char sym, int interactive)
{
    unsigned long step = 4096/sizeof(unsigned long);
    unsigned long words = bytes/sizeof(unsigned long)/2;
    unsigned long iwords = words/step;  /* words per iteration */
    unsigned long off, w, *l1, *l2, v;

    assert((bytes & 4095) == 0);
    for (off = 0; off < step; off++) {
        l1 = l+off;
        l2 = l1+words;
        v = (off & 1) ? v2 : v1;
        for (w = 0; w < iwords; w++) {
#ifdef MEMTEST_32BIT
            *l1 = *l2 = ((unsigned long)     v) |
                        (((unsigned long)    v) << 16);
#else
            *l1 = *l2 = ((unsigned long)     v) |
                        (((unsigned long)    v) << 16) |
                        (((unsigned long)    v) << 32) |
                        (((unsigned long)    v) << 48);
#endif
            l1 += step;
            l2 += step;
            if ((w & 0xffff) == 0 && interactive)
                memtest_progress_step(w+iwords*off,words,sym);
        }
    }
}

int memtest_compare(unsigned long *l, size_t bytes, int interactive) {
    unsigned long words = bytes/sizeof(unsigned long)/2;
    unsigned long w, *l1, *l2;

    assert((bytes & 4095) == 0);
    l1 = l;
    l2 = l1+words;
    for (w = 0; w < words; w++) {
        if (*l1 != *l2) {
            if (interactive) {
                printf("\n*** MEMORY ERROR DETECTED: %p != %p (%lu vs %lu)\n",
                    (void*)l1, (void*)l2, *l1, *l2);
                exit(1);
            }
            return 1;
        }
        l1 ++;
        l2 ++;
        if ((w & 0xffff) == 0 && interactive)
            memtest_progress_step(w,words,'=');
    }
    return 0;
}

int memtest_compare_times(unsigned long *m, size_t bytes, int pass, int times,
                          int interactive)
{
    int j;
    int errors = 0;

    for (j = 0; j < times; j++) {
        if (interactive) memtest_progress_start("Compare",pass);
        errors += memtest_compare(m,bytes,interactive);
        if (interactive) memtest_progress_end();
    }
    return errors;
}

/* Test the specified memory. The number of bytes must be multiple of 4096.
 * If interactive is true the program exists with an error and prints
 * ASCII arts to show progresses. Instead when interactive is 0, it can
 * be used as an API call, and returns 1 if memory errors were found or
 * 0 if there were no errors detected. */
int memtest_test(unsigned long *m, size_t bytes, int passes, int interactive) {
    int pass = 0;
    int errors = 0;

    while (pass != passes) {
        pass++;

        if (interactive) memtest_progress_start("Addressing test",pass);
        errors += memtest_addressing(m,bytes,interactive);
        if (interactive) memtest_progress_end();

        if (interactive) memtest_progress_start("Random fill",pass);
        memtest_fill_random(m,bytes,interactive);
        if (interactive) memtest_progress_end();
        errors += memtest_compare_times(m,bytes,pass,4,interactive);

        if (interactive) memtest_progress_start("Solid fill",pass);
        memtest_fill_value(m,bytes,0,(unsigned long)-1,'S',interactive);
        if (interactive) memtest_progress_end();
        errors += memtest_compare_times(m,bytes,pass,4,interactive);

        if (interactive) memtest_progress_start("Checkerboard fill",pass);
        memtest_fill_value(m,bytes,ULONG_ONEZERO,ULONG_ZEROONE,'C',interactive);
        if (interactive) memtest_progress_end();
        errors += memtest_compare_times(m,bytes,pass,4,interactive);
    }
    return errors;
}

/* A version of memtest_test() that tests memory in small pieces
 * in order to restore the memory content at exit.
 *
 * One problem we have with this approach, is that the cache can avoid
 * real memory accesses, and we can't test big chunks of memory at the
 * same time, because we need to backup them on the stack (the allocator
 * may not be usable or we may be already in an out of memory condition).
 * So what we do is to try to trash the cache with useless memory accesses
 * between the fill and compare cycles. */
#define MEMTEST_BACKUP_WORDS (1024*(1024/sizeof(long)))
/* Random accesses of MEMTEST_DECACHE_SIZE are performed at the start and
 * end of the region between fill and compare cycles in order to trash
 * the cache. */
#define MEMTEST_DECACHE_SIZE (1024*8)

NO_SANITIZE("undefined")
int memtest_preserving_test(unsigned long *m, size_t bytes, int passes) {
    unsigned long backup[MEMTEST_BACKUP_WORDS];
    unsigned long *p = m;
    unsigned long *end = (unsigned long*) (((unsigned char*)m)+(bytes-MEMTEST_DECACHE_SIZE));
    size_t left = bytes;
    int errors = 0;

    if (bytes & 4095) return 0; /* Can't test across 4k page boundaries. */
    if (bytes < 4096*2) return 0; /* Can't test a single page. */

    while(left) {
        /* If we have to test a single final page, go back a single page
         * so that we can test two pages, since the code can't test a single
         * page but at least two. */
        if (left == 4096) {
            left += 4096;
            p -= 4096/sizeof(unsigned long);
        }

        int pass = 0;
        size_t len = (left > sizeof(backup)) ? sizeof(backup) : left;

        /* Always test an even number of pages. */
        if (len/4096 % 2) len -= 4096;

        memcpy(backup,p,len); /* Backup. */
        while(pass != passes) {
            pass++;
            errors += memtest_addressing(p,len,0);
            memtest_fill_random(p,len,0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
            memtest_fill_value(p,len,0,(unsigned long)-1,'S',0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
            memtest_fill_value(p,len,ULONG_ONEZERO,ULONG_ZEROONE,'C',0);
            if (bytes >= MEMTEST_DECACHE_SIZE) {
                memtest_compare_times(m,MEMTEST_DECACHE_SIZE,pass,1,0);
                memtest_compare_times(end,MEMTEST_DECACHE_SIZE,pass,1,0);
            }
            errors += memtest_compare_times(p,len,pass,4,0);
        }
        memcpy(p,backup,len); /* Restore. */
        left -= len;
        p += len/sizeof(unsigned long);
    }
    return errors;
}

/* Perform an interactive test allocating the specified number of megabytes. */
void memtest_alloc_and_test(size_t megabytes, int passes) {
    size_t bytes = megabytes*1024*1024;
    unsigned long *m = malloc(bytes);

    if (m == NULL) {
        fprintf(stderr,"Unable to allocate %zu megabytes: %s",
            megabytes, strerror(errno));
        exit(1);
    }
    memtest_test(m,bytes,passes,1);
    free(m);
}

void memtest(size_t megabytes, int passes) {
#if !defined(__HAIKU__)
    if (ioctl(1, TIOCGWINSZ, &ws) == -1) {
        ws.ws_col = 80;
        ws.ws_row = 20;
    }
#else
    ws.ws_col = 80;
    ws.ws_row = 20;
#endif
    memtest_alloc_and_test(megabytes,passes);
    printf("\nYour memory passed this test.\n");
    printf("Please if you are still in doubt use the following two tools:\n");
    printf("1) memtest86: http://www.memtest86.com/\n");
    printf("2) memtester: http://pyropus.ca/software/memtester/\n");
    exit(0);
}


text:
<?php

namespace Mcuser\Authentication\Adapter;

use Zend\Authentication\Adapter\AdapterInterface;
use ContentinumComponents\Crypt\Password;
use Zend\Authentication\Result;
use Zend\Db\Sql\Ddl\Column\Boolean;

class Database extends AbstractAdapter implements AdapterInterface
{

    /**
     * Mcuser\Model\Auth\User
     *
     * @var Mcuser\Model\Auth\User
     */
    private $worker;

    /**
     * User query array
     *
     * @var array
     */
    private $user;

    /**
     * $identityColumn - the column to use as the identity
     *
     * @var string
     */
    private $identityColumn = 'login_username';

    /**
     * $_credentialColumns - columns to be used as the credentials
     *
     * @var string
     */
    private $credentialColumn = 'login_password';

    /**
     * $identity - Identity value
     *
     * @var string
     */
    private $identity = null;

    /**
     * $credential - Credential values
     *
     * @var string
     */
    private $credential = null;

    /**
     * $credentialTreatment - Treatment applied to the credential, such as MD5() or PASSWORD()
     *
     * @var ContentinumComponents\Crypt\CryptInterface
     */
    private $credentialTreatment = null;

    /**
     * $authenticateResultInfo
     *
     * @var array
     */
    protected $authenticateResultInfo = null;

    /**
     * Cryption salt
     * @var string
     */
    protected $salt;

    /**
     *
     * @var Boolean
     */
    protected $userLocked = false;

    /**
     *
     * @return the $worker
     */
    public function getWorker()
    {
        return $this->worker;
    }

    /**
     *
     * @param \Mcuser\Model\Auth\Mcuser\Model\Auth\User $worker
     */
    public function setWorker($worker)
    {
        $this->worker = $worker;
    }

    /**
     *
     * @return the $user
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     *
     * @param multitype: $user
     */
    public function setUser($user)
    {
        $this->user = $user;
    }

    /**
     *
     * @return the $identityColumn
     */
    public function getIdentityColumn()
    {
        return $this->identityColumn;
    }

    /**
     *
     * @param string $identityColumn
     */
    public function setIdentityColumn($identityColumn)
    {
        $this->identityColumn = $identityColumn;
    }

    /**
     *
     * @return the $credentialColumn
     */
    public function getCredentialColumn()
    {
        return $this->credentialColumn;
    }

    /**
     *
     * @param string $credentialColumn
     */
    public function setCredentialColumn($credentialColumn)
    {
        $this->credentialColumn = $credentialColumn;
    }

    /**
     *
     * @return the $identity
     */
    public function getIdentity()
    {
        return $this->identity;
    }

    /**
     *
     * @param string $identity
     */
    public function setIdentity($identity, $treatment = 'md5')
    {
        if (false !== $treatment) {
            $identity = $treatment($identity);
        }

        $this->identity = $identity;
    }

    /**
     *
     * @return the $credential
     */
    public function getCredential()
    {
        return $this->credential;
    }

    /**
     *
     * @param string $credential
     */
    public function setCredential($credential)
    {
        $this->credential = $credential;
    }

    /**
     *
     * @return the $credentialTreatment
     */
    public function getCredentialTreatment()
    {
        return $this->credentialTreatment;
    }

    /**
     *
     * @param string $credentialTreatment
     */
    public function setCredentialTreatment($credentialTreatment = null)
    {
        if (null === $credentialTreatment) {
            $credentialTreatment = new Password();
        }

        $this->credentialTreatment = $credentialTreatment;
    }

    /**
     *
     * @return the $authenticateResultInfo
     */
    public function getAuthenticateResultInfo()
    {
        return $this->authenticateResultInfo;
    }

    /**
     *
     * @param multitype: $authenticateResultInfo
     */
    public function setAuthenticateResultInfo($authenticateResultInfo)
    {
        $this->authenticateResultInfo = $authenticateResultInfo;
    }

    /**
     * @return the $salt
     */
    public function getSalt()
    {
        return $this->salt;
    }

	/**
     * @param string $salt
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;
    }

    /**
     * @return the $userLocked
     */
    public function getUserLocked()
    {
        return $this->userLocked;
    }

 /**
     * @param \Zend\Db\Sql\Ddl\Column\Boolean $userLocked
     */
    public function setUserLocked($userLocked)
    {
        $this->userLocked = $userLocked;
    }

 /**
     * Sets username and password for authentication
     *
     * @return void
     */
    public function setLoginDatas($identity, $credential, $worker, $user)
    {
        $this->setIdentity($identity);
        $this->setCredential($credential);
        $this->setWorker($worker);
        $this->setUser($user);
        $this->setCredentialTreatment();
        return $this;
    }

	/**
     * Performs an authentication attempt
     *
     * @return \Zend\Authentication\Result
     * @throws \Zend\Authentication\Adapter\Exception\ExceptionInterface If authentication cannot be performed
     */
    public function authenticate()
    {
        if (isset($this->user[$this->identityColumn]) && $this->identity === $this->user[$this->identityColumn]) {
            if ( $this->user['try_login'] < 3 ) {
                if (isset($this->user[$this->credentialColumn])) {
                    $credential = $this->credentialTreatment->encode($this->credential, $this->getSalt());
                    if ($credential === $this->user[$this->credentialColumn]) {
                        $authResultInfo['code'] = Result::SUCCESS;
                        $authResultInfo['messages'][] = 'Authentication successful.';
                    } else {
                        $authResultInfo['code'] = Result::FAILURE_CREDENTIAL_INVALID;
                        switch ($this->user['try_login']) {
                            case '2':
                                $authResultInfo['messages'][] = 'Supplied credential is invalid, third try! The account has been locked!';
                                break;
                            case '1':
                                $authResultInfo['messages'][] = 'Supplied credential is invalid, second try!';
                                break;
                            case '0':
                            default:
                                $authResultInfo['messages'][] = 'Supplied credential is invalid.';
                                break;
                        }
                    }
                } else {
                    $authResultInfo['code'] = Result::FAILURE_UNCATEGORIZED;
                    $authResultInfo['messages'][] = 'Unknown error.';
                }
            } else {
                $authResultInfo['code'] = Result::FAILURE;
                $authResultInfo['messages'][] = 'user_locked';
                $this->userLocked = true;
            }
        } else {
            $authResultInfo['code'] = Result::FAILURE_IDENTITY_NOT_FOUND;
            $authResultInfo['messages'][] = 'User not found or locked.';
        }
        $this->setAuthenticateResultInfo($authResultInfo);
        return $this->createAuthResult();
    }

    /**
     *
     * @param unknown $sl
     */
    public function getIdentityResult($sl)
    {
        $user = $sl->get('User\Identity');
        return $user->userIdentityInstance($this->user['id']);
    }

    /**
     *
     * @return string
     */
    public function getSessionStorageKey()
    {
        return 'contentinum' . md5($this->user['username']. $this->user[$this->credentialColumn]);
    }

    /**
     *
     * @return \Zend\Authentication\Result
     */
    protected function createAuthResult()
    {
        return new Result($this->authenticateResultInfo['code'], $this->identity, $this->authenticateResultInfo['messages']);
    }
}


text:
@extends('boilerplate::layout.index', [
    'title' => __('boilerplate::users.profile.title'),
    'subtitle' => $user->name,
    'breadcrumb' => [
        $user->name => 'boilerplate.user.profile',
    ]
])

@section('content')
    {{ Form::open(['route' => ['boilerplate.user.profile'], 'method' => 'post', 'autocomplete' => 'off', 'files' => true]) }}

                    <button type="submit" class="btn btn-primary">
                        @lang('boilerplate::users.save')
                    </button>

                @component('boilerplate::card', ['title' => __('boilerplate::users.profile.title')])

                            @include('boilerplate::users.avatar')

{{ $user->name  }}

{{ $user->getRolesList() }}

                                     {{ $user->email }}

                                    {{ __('boilerplate::users.profile.subscribedsince', [
                                        'date' => $user->created_at->isoFormat(__('boilerplate::date.lFdY')),
                                        'since' => $user->created_at->diffForHumans()]) }}

                @endcomponent

                @component('boilerplate::card', ['color' => 'teal', 'title' => __('boilerplate::users.informations')])

                            @component('boilerplate::input', ['name' => 'first_name', 'label' => 'boilerplate::users.firstname', 'value' => $user->first_name, 'autofocus' => true])@endcomponent

                            @component('boilerplate::input', ['name' => 'last_name', 'label' => 'boilerplate::users.lastname', 'value' => $user->last_name])@endcomponent

                            @component('boilerplate::password', ['name' => 'password', 'label' => ucfirst(__('boilerplate::auth.fields.password'))])@endcomponent

                            @component('boilerplate::password', ['name' => 'password_confirmation', 'label' => ucfirst(__('boilerplate::auth.fields.password_confirm')), 'check' => false])@endcomponent

                @endcomponent

    {{ Form::close() }}
@endsection

@push('js')

@endpush


text:
package net.floodlightcontroller.core.web.serializers;

import java.io.IOException;
import java.util.Iterator;

import net.floodlightcontroller.util.MatchUtils;

import org.projectfloodlight.openflow.protocol.match.Match;
import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * Serialize any Match in JSON.
 *
 * Use automatically by Jackson via JsonSerialize(using=MatchSerializer.class),
 * or use the static function within this class within another serializer.
 *
 * @author Ryan Izard, ryan.izard@bigswitch.com, rizard@g.clemson.edu
 */
public class MatchSerializer extends JsonSerializer<Match> {
	protected static Logger logger = LoggerFactory.getLogger(OFActionListSerializer.class);

	@Override
	public void serialize(Match match, JsonGenerator jGen, SerializerProvider serializer) throws IOException,
	JsonProcessingException {
		serializeMatch(jGen, match);
	}

	@SuppressWarnings("unchecked")
	public static String matchValueToString(Match m, @SuppressWarnings("rawtypes") MatchField mf) {
		return m.isPartiallyMasked(mf) ? m.getMasked(mf).toString() : m.get(mf).toString();
	}

	public static void serializeMatch(JsonGenerator jGen, Match match) throws IOException, JsonProcessingException {
		// list flow matches
		jGen.writeObjectFieldStart("match");
		Iterator<MatchField<?>> mi = match.getMatchFields().iterator(); // get iter to any match field type
		Match m = match;

		while (mi.hasNext()) {
			MatchField<?> mf = mi.next();
			switch (mf.id) {
			case IN_PORT:
				jGen.writeStringField(MatchUtils.STR_IN_PORT, matchValueToString(m, mf));
				break;
			case IN_PHY_PORT:
				jGen.writeStringField(MatchUtils.STR_IN_PHYS_PORT, matchValueToString(m, mf));
				break;
			case ARP_OP:
				jGen.writeStringField(MatchUtils.STR_ARP_OPCODE, matchValueToString(m, mf));
				break;
			case ARP_SHA:
				jGen.writeStringField(MatchUtils.STR_ARP_SHA, matchValueToString(m, mf));
				break;
			case ARP_SPA:
				jGen.writeStringField(MatchUtils.STR_ARP_SPA, matchValueToString(m, mf));
				break;
			case ARP_THA:
				jGen.writeStringField(MatchUtils.STR_ARP_DHA, matchValueToString(m, mf));
				break;
			case ARP_TPA:
				jGen.writeStringField(MatchUtils.STR_ARP_DPA, matchValueToString(m, mf));
				break;
			case ETH_TYPE: // TODO Remove this "0x" when Loxigen is updated.
				jGen.writeStringField(MatchUtils.STR_DL_TYPE, m.isPartiallyMasked(mf) ?
						"0x" + m.getMasked(mf).toString() : "0x" + m.get(mf).toString());
				break;
			case ETH_SRC:
				jGen.writeStringField(MatchUtils.STR_DL_SRC, matchValueToString(m, mf));
				break;
			case ETH_DST:
				jGen.writeStringField(MatchUtils.STR_DL_DST, matchValueToString(m, mf));
				break;
			case VLAN_VID:
				jGen.writeStringField(MatchUtils.STR_DL_VLAN, matchValueToString(m, mf));
				break;
			case VLAN_PCP:
				jGen.writeStringField(MatchUtils.STR_DL_VLAN_PCP, matchValueToString(m, mf));
				break;
			case ICMPV4_TYPE:
				jGen.writeStringField(MatchUtils.STR_ICMP_TYPE, matchValueToString(m, mf));
				break;
			case ICMPV4_CODE:
				jGen.writeStringField(MatchUtils.STR_ICMP_CODE, matchValueToString(m, mf));
				break;
			case ICMPV6_TYPE:
				jGen.writeStringField(MatchUtils.STR_ICMPV6_TYPE, matchValueToString(m, mf));
				break;
			case ICMPV6_CODE:
				jGen.writeStringField(MatchUtils.STR_ICMPV6_CODE, matchValueToString(m, mf));
				break;
			case IP_DSCP:
				jGen.writeStringField(MatchUtils.STR_NW_DSCP, matchValueToString(m, mf));
				break;
			case IP_ECN:
				jGen.writeStringField(MatchUtils.STR_NW_ECN, matchValueToString(m, mf));
				break;
			case IP_PROTO:
				jGen.writeStringField(MatchUtils.STR_NW_PROTO, matchValueToString(m, mf));
				break;
			case IPV4_SRC:
				jGen.writeStringField(MatchUtils.STR_NW_SRC, matchValueToString(m, mf));
				break;
			case IPV4_DST:
				jGen.writeStringField(MatchUtils.STR_NW_DST, matchValueToString(m, mf));
				break;
			case IPV6_SRC:
				jGen.writeStringField(MatchUtils.STR_IPV6_SRC, matchValueToString(m, mf));
				break;
			case IPV6_DST:
				jGen.writeStringField(MatchUtils.STR_IPV6_DST, matchValueToString(m, mf));
				break;
			case IPV6_FLABEL:
				jGen.writeStringField(MatchUtils.STR_IPV6_FLOW_LABEL, matchValueToString(m, mf));
				break;
			case IPV6_ND_SLL:
				jGen.writeStringField(MatchUtils.STR_IPV6_ND_SSL, matchValueToString(m, mf));
				break;
			case IPV6_ND_TARGET:
				jGen.writeStringField(MatchUtils.STR_IPV6_ND_TARGET, matchValueToString(m, mf));
				break;
			case IPV6_ND_TLL:
				jGen.writeStringField(MatchUtils.STR_IPV6_ND_TTL, matchValueToString(m, mf));
				break;
			case METADATA:
				jGen.writeStringField(MatchUtils.STR_METADATA, matchValueToString(m, mf));
				break;
			case MPLS_LABEL:
				jGen.writeStringField(MatchUtils.STR_MPLS_LABEL, matchValueToString(m, mf));
				break;
			case MPLS_TC:
				jGen.writeStringField(MatchUtils.STR_MPLS_TC, matchValueToString(m, mf));
				break;
			case MPLS_BOS:
				jGen.writeStringField(MatchUtils.STR_MPLS_BOS, matchValueToString(m, mf));
				break;
			case SCTP_SRC:
				jGen.writeStringField(MatchUtils.STR_SCTP_SRC, matchValueToString(m, mf));
				break;
			case SCTP_DST:
				jGen.writeStringField(MatchUtils.STR_SCTP_DST, matchValueToString(m, mf));
				break;
			case TCP_SRC:
				jGen.writeStringField(MatchUtils.STR_TCP_SRC, matchValueToString(m, mf));
				break;
			case TCP_DST:
				jGen.writeStringField(MatchUtils.STR_TCP_DST, matchValueToString(m, mf));
				break;
			case UDP_SRC:
				jGen.writeStringField(MatchUtils.STR_UDP_SRC, matchValueToString(m, mf));
				break;
			case UDP_DST:
				jGen.writeStringField(MatchUtils.STR_UDP_DST, matchValueToString(m, mf));
				break;
			default:
				// either a BSN or unknown match type
				break;
			} // end switch of match type
		} // end while over non-wildcarded matches

		jGen.writeEndObject(); // end match
	}
}


text:
module AmazonPay
  # Removes PII and other sensitive data for the logger
  class Sanitize
    def initialize(input_data)
      @copy = input_data ? input_data.dup : ''
    end

    def sanitize_request_data
      # Array of item to remove

      patterns = %w[
        Buyer
        PhysicalDestination
        BillingAddress
        AuthorizationBillingAddress
        SellerNote
        SellerAuthorizationNote
        SellerCaptureNote
        SellerRefundNote
      ]

      patterns.each do |s|
        @copy.gsub!(/([?|&]#{s}=)[^\&]+/ms, s + '=*REMOVED*')
      end

      @copy
    end

    def sanitize_response_data
      # Array of item to remove

      patterns = []
      patterns.push(%r{(?<=<Buyer>).*(?=<\/Buyer>)}s)
      patterns.push(%r{(?<=<PhysicalDestination>).*(?=<\/PhysicalDestination>)}ms)
      patterns.push(%r{(?<=<BillingAddress>).*(?=<\/BillingAddress>)}s)
      patterns.push(%r{(?<=<SellerNote>).*(?=<\/SellerNote>)}s)
      patterns.push(%r{(?<=<AuthorizationBillingAddress>).*(?=<\/AuthorizationBillingAddress>)}s)
      patterns.push(%r{(?<=<SellerAuthorizationNote>).*(?=<\/SellerAuthorizationNote>)}s)
      patterns.push(%r{(?<=<SellerCaptureNote>).*(?=<\/SellerCaptureNote>)}s)
      patterns.push(%r{(?<=<SellerRefundNote>).*(?=<\/SellerRefundNote>)}s)

      patterns.each do |s|
        @copy.gsub!(s, '*REMOVED*')
      end

      @copy
    end
  end
end


text:
namespace core {
  namespace filesystem {                            // Functions used to read and modify the file system of the user.
    bool fileExists( const std::string &fileName ); // Used to check if a certain file exists with a certain directory
  }
  namespace console {
    int getConsoleWidth();                 // Used to get the current Width of the console window
    int getConsoleHeight();                // Used to get the current Height of the console window
    void toggleEcho( const bool &enable ); // Stops the console from printing anything if disabled.
    std::string
    getPassword( const char *prompt ); // Used to get the password of the user without exposing what they typed.
  }
  template <typename Iter, typename RandomGenerator> Iter randomSelect( Iter start, Iter end, RandomGenerator &g );
  template <typename Iter> Iter randomSelect( Iter start, Iter end );
  void pause();
  // Just so I don't have to type as much crap...
  void sleep( std::chrono::seconds seconds );
  void sleep( std::chrono::milliseconds milliseconds );
  enum Keys { up = 0, down = 1, left = 2, right = 3, enter = 4, escape = 5, extended = 6 };
  Keys getKeyInput();
  Keys getKeyInput( bool delayed );
  void save();  // Serialize namespace player
  int load();   // Deserialize namespace player
  void clear(); // This is used to clear the screen and reset any formatting changes.
  int createMenu( const std::string &title, const std::vector<std::string> &menuContent,
                  const bool &backEnabled ); // Creates a menu without using the nCurses library, not likely to be
                                             // efficient. Still needs linux code.
}

#endif // CORE_H


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
in Engler & Prantl, Nat. Pflanzenfam. (Leipzig), Teil. <b>I</b> 1**: 224 (1898)

#### Original name
Panus farneus Fr.

### Remarks
null


text:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <gradient
        android:startColor="#00333333"
        android:centerColor="#FFE6E6E6"
        android:endColor="#00333333"
        android:angle="0" />
</shape>


text:
let fs = require('fs');
let esprima = require('esprima');
let estraverse = require('estraverse');
let vscode = require('vscode');

function getCoords(fileContent) {
    var tree = esprima.parse(fileContent, { sourceType: 'module', tokens: true, range: true, loc: true });

    var coords = {
        depPath: null,
        depParam: null
    };

    estraverse.traverse(tree, {
        enter: function (node, parent) {

            if (parent && parent.type == 'CallExpression' && parent.callee.name == 'define') {
                if (node.type == 'ArrayExpression') {
                    coords.depPath = {
                        start : {
                            row: node.loc.start.line,
                            col: node.loc.start.column
                        },
                        end : {
                            row: node.loc.end.line,
                            col: node.loc.end.column
                        },
                        range: [node.range[0], node.range[1]]
                    };
                }

                if (node.type == 'ArrowFunctionExpression' || node.type == 'FunctionExpression') {
                    coords.depParam = {
                        start : {
                            row: node.loc.start.line,
                            col: node.loc.start.column
                        },
                        end : {
                            row: node.body.loc.start.line,
                            col: node.body.loc.start.column
                        },
                        range: [node.range[0], node.body.range[0]]
                    };
                }
            }
        }
    });

    return coords;
}

function createPosition(row, col) {
    return new vscode.Position(row, col);
}

function rangeFactory(start, end) {
    return new vscode.Range(start, end);
}

function textEditFactory(range, content) {
    return new vscode.TextEdit(range, content);
}

function editFactory (coords, content){
    var start = createPosition(coords.start.line, coords.start.char);
    var end = createPosition(coords.end.line, coords.end.char);
    var range = rangeFactory(start, end);

    return textEditFactory(range, content);
}

function workspaceEditFactory() {
    return new vscode.WorkspaceEdit();
}

function setEditFactory(uri, coords, content) {
    var workspaceEdit = workspaceEditFactory();
    var edit = editFactory(coords, content);

    workspaceEdit.set(uri, [edit]);
    return workspaceEdit;
}

function getDocument (vsEditor) {
    return typeof vsEditor._documentData !== 'undefined' ? vsEditor._documentData : vsEditor._document
}

async function editCurrentDocument(vsEditor, coords, content){
    var vsDocument = getDocument(vsEditor);
    var edit = setEditFactory(vsDocument._uri, coords, content);
    await vscode.workspace.applyEdit(edit);
}

function replaceStringRange(source, replacement, from, to) {
    return source.substring(0, from) + replacement + source.substring(to);
}

function getUpdatedFunctionParams(newDependecyParam, oldString) {
    let newString = oldString;

    if (oldString.indexOf('function') != -1) {
        let fromIndex = oldString.indexOf('(') + 1;
        let toIndex = oldString.indexOf(')');
        let oldParams = oldString.substring(fromIndex, toIndex);
        let newParams = oldParams.trim();
        newParams = newParams.length > 0 ? newParams + ', ' + newDependecyParam : newDependecyParam;

        newString = replaceStringRange(oldString, newParams, fromIndex, toIndex);
    }
    if (oldString.indexOf('=>') != -1) {
        let params = oldString.split("=>")[0].trim();

        if (params.indexOf('(') == -1) { // "param => "
            newString = '(' + params + ', ' + newDependecyParam + ') => ';
        } else {
            let fromIndex = oldString.indexOf('(') + 1;
            let toIndex = oldString.indexOf(')');
            let oldParams = oldString.substring(fromIndex, toIndex);
            let newParams = oldParams.trim();
            newParams = newParams.length > 0 ? newParams + ', ' + newDependecyParam : newDependecyParam;

            newString = replaceStringRange(oldString, newParams, fromIndex, toIndex);
        }
    }

    return newString;
}

function getUpdatedDepPath(newDependecyPath, oldString) {
    if (oldString) {
        let fromIndex = oldString.indexOf('[') + 1;
        let toIndex = oldString.indexOf(']');
        let oldPaths = oldString.substring(fromIndex, toIndex);
        let newPaths = oldPaths.trim();
        newPaths = newPaths.length > 0 ? newPaths + ", '" + newDependecyPath + "'" : "'" + newDependecyPath + "'";

        return replaceStringRange(oldString, newPaths, fromIndex, toIndex);
    }

    return "['" + newDependecyPath + "']";
}

async function updateDocument(editor, startLine, startChar, endLine, endChar, content) {
    var editorCoords = {
        start : {
            line: startLine,
            char: startChar
        },
        end : {
            line: endLine,
            char: endChar
        }
    }

    await editCurrentDocument(editor, editorCoords, content);
}

exports.getCoords = getCoords;
exports.getUpdatedFunctionParams = getUpdatedFunctionParams;
exports.getUpdatedDepPath = getUpdatedDepPath;
exports.createPosition = createPosition;
exports.editCurrentDocument = editCurrentDocument;
exports.updateDocument = updateDocument;


text:
import codecs
from sys import argv, exit

if len(argv) < 3:
    print('Insufficient arguments.')
    exit(-1)

filename_in = argv[1]
filename_out = argv[2]
lines = {}

with codecs.open(filename_in, 'r', 'latin1') as f:
    for line in f.readlines():
        line = line.strip()
        if line in lines:
            lines[line] += 1
        else:
            lines[line] = 1

sorted_lines = sorted(lines.items(), key=lambda item: item[1], reverse=True)

with codecs.open(filename_out, 'w', 'latin1') as f:
    for line, count in sorted_lines:
        f.write('{}: {}\n'.format(line, count))