text:
#include <algorithm>
#include <string>
#include "util/sstream.h"
#include "util/sexpr/option_declarations.h"
#include "kernel/for_each_fn.h"
#include "kernel/inductive/inductive.h"
#include "kernel/quotient/quotient.h"
#include "kernel/hits/hits.h"
#include "library/util.h"
#include "library/class.h"
#include "library/aliases.h"
#include "library/flycheck.h"
#include "library/pp_options.h"
#include "library/private.h"
#include "library/protected.h"
#include "library/attribute_manager.h"
#include "library/user_recursors.h"
#include "library/noncomputable.h"
#include "library/type_context.h"
#include "library/unification_hint.h"
#include "library/reducible.h"
#include "library/rfl_lemmas.h"
#include "library/tactic/kabstract.h"
#include "library/tactic/simplifier/simp_lemmas.h"
#include "library/tactic/simplifier/simp_extensions.h"
#include "frontends/lean/parser.h"
#include "frontends/lean/util.h"
#include "frontends/lean/tokens.h"
#include "frontends/lean/structure_cmd.h"

namespace lean {
struct print_axioms_deps {
    environment     m_env;
    io_state_stream m_ios;
    name_set        m_visited;
    bool            m_use_axioms;
    print_axioms_deps(environment const & env, io_state_stream const & ios):
        m_env(env), m_ios(ios), m_use_axioms(false) {}

    void visit(name const & n) {
        if (m_visited.contains(n))
            return;
        m_visited.insert(n);
        declaration const & d = m_env.get(n);
        if (!d.is_definition() && !m_env.is_builtin(n)) {
            m_use_axioms = true;
            m_ios << d.get_name() << "\n";
        }
        visit(d.get_type());
        if (d.is_definition())
            visit(d.get_value());
    }

    void visit(expr const & e) {
        for_each(e, [&](expr const & e, unsigned) {
                if (is_constant(e))
                    visit(const_name(e));
                return true;
            });
    }

    void operator()(name const & n) {
        visit(n);
        if (!m_use_axioms)
            m_ios << "no axioms" << endl;
    }
};

static environment print_axioms(parser & p) {
    if (p.curr_is_identifier()) {
        name c = p.check_constant_next("invalid 'print axioms', constant expected");
        environment new_env = p.reveal_all_theorems();
        type_context tc(new_env, p.get_options());
        auto out = regular(new_env, p.ios(), tc);
        print_axioms_deps(p.env(), out)(c);
        return new_env;
    } else {
        bool has_axioms = false;
        environment const & env = p.env();
        type_context tc(env, p.get_options());
        auto out = regular(env, p.ios(), tc);
        env.for_each_declaration([&](declaration const & d) {
                name const & n = d.get_name();
                if (!d.is_definition() && !env.is_builtin(n) && d.is_trusted()) {
                    out << n << " : " << d.get_type() << endl;
                    has_axioms = true;
                }
            });
        if (!has_axioms)
            out << "no axioms" << endl;
        return p.env();
    }
}

static void print_prefix(parser & p) {
    name prefix = p.check_id_next("invalid 'print prefix' command, identifier expected");
    environment const & env = p.env();
    buffer<declaration> to_print;
    type_context tc(env, p.get_options());
    auto out = regular(env, p.ios(), tc);
    env.for_each_declaration([&](declaration const & d) {
            if (is_prefix_of(prefix, d.get_name())) {
                to_print.push_back(d);
            }
        });
    std::sort(to_print.begin(), to_print.end(), [](declaration const & d1, declaration const & d2) { return d1.get_name() < d2.get_name(); });
    for (declaration const & d : to_print) {
        out << d.get_name() << " : " << d.get_type() << endl;
    }
    if (to_print.empty())
        out << "no declaration starting with prefix '" << prefix << "'" << endl;
}

static void print_fields(parser const & p, name const & S, pos_info const & pos) {
    environment const & env = p.env();
    if (!is_structure(env, S))
        throw parser_error(sstream() << "invalid 'print fields' command, '" << S << "' is not a structure", pos);
    buffer<name> field_names;
    get_structure_fields(env, S, field_names);
    type_context tc(env, p.get_options());
    auto out = regular(env, p.ios(), tc);
    for (name const & field_name : field_names) {
        declaration d = env.get(field_name);
        out << d.get_name() << " : " << d.get_type() << endl;
    }
}

static bool uses_token(unsigned num, notation::transition const * ts, name const & token) {
    for (unsigned i = 0; i < num; i++) {
        if (ts[i].get_token() == token)
            return true;
    }
    return false;
}

static bool uses_some_token(unsigned num, notation::transition const * ts, buffer<name> const & tokens) {
    return
        tokens.empty() ||
        std::any_of(tokens.begin(), tokens.end(), [&](name const & token) { return uses_token(num, ts, token); });
}

static bool print_parse_table(parser const & p, parse_table const & t, bool nud, buffer<name> const & tokens, bool tactic_table = false) {
    bool found = false;
    io_state ios = p.ios();
    options os   = ios.get_options();
    os = os.update_if_undef(get_pp_full_names_name(), true);
    os = os.update(get_pp_notation_name(), false);
    os = os.update(get_pp_preterm_name(), true);
    ios.set_options(os);
    type_context tc(p.env(), p.get_options());
    io_state_stream out = regular(p.env(), ios, tc);
    optional<token_table> tt(get_token_table(p.env()));
    t.for_each([&](unsigned num, notation::transition const * ts, list<notation::accepting> const & overloads) {
            if (uses_some_token(num, ts, tokens)) {
                if (tactic_table)
                    out << "tactic notation ";
                found = true;
                notation::display(out, num, ts, overloads, nud, tt);
            }
        });
    return found;
}

static void print_notation(parser & p) {
    buffer<name> tokens;
    while (p.curr_is_keyword()) {
        tokens.push_back(p.get_token_info().token());
        p.next();
    }
    bool found = false;
    if (print_parse_table(p, get_nud_table(p.env()), true, tokens))
        found = true;
    if (print_parse_table(p, get_led_table(p.env()), false, tokens))
        found = true;
    if (!found)
        p.ios().get_regular_stream() << "no notation" << std::endl;
}

#if 0
static void print_patterns(parser & p, name const & n) {
    if (is_forward_lemma(p.env(), n)) {
        // we regenerate the patterns to make sure they reflect the current set of reducible constants
        try {
            blast::scope_debug scope(p.env(), p.ios());
            auto hi = blast::mk_hi_lemma(n, LEAN_DEFAULT_PRIORITY);
            if (hi.m_multi_patterns) {
                options opts         = p.get_options();
                opts                 = opts.update_if_undef(get_pp_metavar_args_name(), true);
                io_state new_ios(p.ios(), opts);
                type_context tc(p.env(), opts);
                io_state_stream out = regular(p.env(), new_ios, tc);
                out << "(multi-)patterns:\n";
                if (!is_nil(hi.m_mvars)) {
                    expr m = head(hi.m_mvars);
                    out << m << " : " << mlocal_type(m);
                    for (expr const & m : tail(hi.m_mvars)) {
                        out << ", " << m << " : " << mlocal_type(m);
                    }
                }
                out << "\n";
                for (multi_pattern const & mp : hi.m_multi_patterns) {
                    out << "{";
                    bool first = true;
                    for (expr const & p : mp) {
                        if (first) first = false; else out << ", ";
                        out << p;
                    }
                    out << "}\n";
                }
            }
        } catch (exception & ex) {
            p.display_error(ex);
        }
    }
}
#endif

static name to_user_name(environment const & env, name const & n) {
    if (auto r = hidden_to_user_name(env, n))
        return *r;
    else
        return n;
}

static void print_definition(parser const & p, name const & n, pos_info const & pos) {
    environment const & env = p.env();
    declaration d = env.get(n);
    options opts        = p.get_options();
    opts                = opts.update_if_undef(get_pp_beta_name(), false);
    io_state ios(p.ios(), opts);
    type_context tc(env, opts);
    io_state_stream out = regular(env, ios, tc);
    if (d.is_axiom())
        throw parser_error(sstream() << "invalid 'print definition', theorem '" << to_user_name(env, n)
                           << "' is not available (suggestion: use command 'reveal " << to_user_name(env, n) << "')", pos);
    if (!d.is_definition())
        throw parser_error(sstream() << "invalid 'print definition', '" << to_user_name(env, n) << "' is not a definition", pos);
    out << d.get_value() << endl;
}

static void print_attributes(parser const & p, name const & n) {
    environment const & env = p.env();
    std::ostream & out = p.ios().get_regular_stream();
    buffer<attribute const *> attrs;
    get_attributes(p.env(), attrs);
    std::sort(attrs.begin(), attrs.end(), [](attribute const * a1, attribute const * a2) {
        return a1->get_name() < a2->get_name();
    });
    bool first = true;
    for (auto attr : attrs) {
        if (attr->get_name() == "reducibility")
            continue;
        if (auto data = attr->get_untyped(env, n)) {
            if (first) {
                out << "attribute [";
                first = false;
            } else {
                out << ", ";
            }
            out << attr->get_name();
            data->print(out);
            unsigned prio = attr->get_prio(env, n);
            if (prio != LEAN_DEFAULT_PRIORITY)
                out << ", priority " << prio;
        }
    }
    if (!first)
        out << "]\n";
}

static void print_inductive(parser const & p, name const & n, pos_info const & pos) {
    environment const & env = p.env();
    type_checker tc(env);
    io_state_stream out = regular(env, p.ios(), tc);
    if (auto idecl = inductive::is_inductive_decl(env, n)) {
        level_param_names ls = idecl->m_level_params;
        print_attributes(p, n);
        if (is_structure(env, n))
            out << "structure";
        else
            out << "inductive";
        out << " " << n;
        out << " : " << env.get(n).get_type() << "\n";
        if (is_structure(env, n)) {
            out << "fields:\n";
            print_fields(p, n, pos);
        } else {
            out << "constructors:\n";
            buffer<name> constructors;
            get_intro_rule_names(env, n, constructors);
            for (name const & c : constructors) {
                out << c << " : " << env.get(c).get_type() << "\n";
            }
        }
    } else {
        throw parser_error(sstream() << "invalid 'print inductive', '" << n << "' is not an inductive declaration", pos);
    }
}

static void print_recursor_info(parser & p) {
    name c = p.check_constant_next("invalid 'print [recursor]', constant expected");
    std::ostream & out = p.ios().get_regular_stream();
    recursor_info info = get_recursor_info(p.env(), c);
    out << "recursor information\n"
        << "  num. parameters:          " << info.get_num_params() << "\n"
        << "  num. indices:             " << info.get_num_indices() << "\n"
        << "  num. minors:              " << info.get_num_minors() << "\n"
        << "  recursive:                " << info.is_recursive() << "\n"
        << "  universe param pos.:     ";
    for (unsigned idx : info.get_universe_pos()) {
        if (idx == recursor_info::get_motive_univ_idx()) {
            out << " [motive univ]";
        } else {
            out << " " << idx;
        }
    }
    out << "\n";
    out << "  motive pos.:              " << info.get_motive_pos() + 1 << "\n"
        << "  major premise pos.:       " << info.get_major_pos() + 1 << "\n"
        << "  dep. elimination:         " << info.has_dep_elim() << "\n";
    if (info.get_num_params() > 0) {
        out << "  parameters pos. at major:";
        for (optional<unsigned> const & p : info.get_params_pos()) {
            if (p)
                out << " " << *p+1;
            else
                out << " [instance]";
        }
        out << "\n";
    }
    if (info.get_num_indices() > 0) {
        out << "  indices pos. at major:   ";
        for (unsigned p : info.get_indices_pos())
            out << " " << p+1;
        out << "\n";
    }
}

static bool print_constant(parser const & p, char const * kind, declaration const & d, bool is_def = false) {
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    print_attributes(p, d.get_name());
    if (is_protected(p.env(), d.get_name()))
        out << "protected ";
    if (d.is_definition() && is_marked_noncomputable(p.env(), d.get_name()))
        out << "noncomputable ";
    out << kind << " " << to_user_name(p.env(), d.get_name());
    out.update_options(out.get_options().update((name {"pp", "binder_types"}), true)) << " : " << d.get_type();
    if (is_def)
        out << " :=";
    out << "\n";
    return true;
}

bool print_id_info(parser & p, name const & id, bool show_value, pos_info const & pos) {
    // declarations
    try {
        environment const & env = p.env();
        type_checker tc(env);
        auto out = regular(env, p.ios(), tc);
        try {
            list<name> cs = p.to_constants(id, "", pos);
            bool first = true;
            for (name const & c : cs) {
                if (first) first = false; else out << "\n";
                declaration const & d = env.get(c);
                if (d.is_theorem()) {
                    print_constant(p, "theorem", d, show_value);
                    if (show_value)
                        print_definition(p, c, pos);
                } else if (d.is_axiom() || d.is_constant_assumption()) {
                    if (inductive::is_inductive_decl(env, c)) {
                        print_inductive(p, c, pos);
                    } else if (inductive::is_intro_rule(env, c)) {
                        print_constant(p, "constructor", d);
                    } else if (inductive::is_elim_rule(env, c)) {
                        print_constant(p, "eliminator", d);
                    } else if (is_quotient_decl(env, c)) {
                        print_constant(p, "builtin-quotient-type-constant", d);
                    } else if (is_hits_decl(env, c)) {
                        print_constant(p, "builtin-HIT-constant", d);
                    } else if (d.is_axiom()) {
                        print_constant(p, "axiom", d);
                    } else {
                        print_constant(p, "constant", d);
                    }
                } else if (d.is_definition()) {
                    print_constant(p, "definition", d, show_value);
                    if (show_value)
                        print_definition(p, c, pos);
                }
                // print_patterns(p, c);
            }
            return true;
        } catch (exception & ex) {}

        // variables and parameters
        if (expr const * type = p.get_local(id)) {
            if (is_local(*type)) {
                if (p.is_local_variable(*type)) {
                    out << "variable " << id << " : " << mlocal_type(*type) << "\n";
                } else {
                    out << "parameter " << id << " : " << mlocal_type(*type) << "\n";
                }
                return true;
            }
        }

        // options
        auto decls = get_option_declarations();
        bool found = false;
        decls.for_each([&](name const &, option_declaration const & opt) {
                if (found) return;
                if (opt.get_name() == id || opt.get_name() == name("lean") + id) {
                    out << "option  " << opt.get_name() << " (" << opt.kind() << ") "
                        << opt.get_description() << " (default: " << opt.get_default_value() << ")" << endl;
                    found = true;
                }
            });
        if (found) return true;
    } catch (exception &) {}
    return false;
}

bool print_token_info(parser const & p, name const & tk) {
    buffer<name> tokens;
    tokens.push_back(tk);
    bool found = false;
    if (print_parse_table(p, get_nud_table(p.env()), true, tokens)) {
        found = true;
    }
    if (print_parse_table(p, get_led_table(p.env()), false, tokens)) {
        found = true;
    }
    return found;
}

bool print_polymorphic(parser & p) {
    auto pos = p.pos();
    try {
        name id = p.check_id_next("");
        bool show_value = true;
        if (print_id_info(p, id, show_value, pos))
            return true;
    } catch (exception &) {}

    // notation
    if (p.curr_is_keyword()) {
        name tk = p.get_token_info().token();
        if (print_token_info(p, tk)) {
            p.next();
            return true;
        }
    }
    return false;
}

static void print_unification_hints(parser & p) {
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    out << pp_unification_hints(get_unification_hints(p.env()), out.get_formatter());
}

static void print_rfl_lemmas(parser & p) {
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    out << pp_rfl_lemmas(*get_rfl_lemmas(p.env()), out.get_formatter());
}

static void print_simp_rules(parser & p) {
    type_context aux_tctx(p.env(), p.get_options());
    name attr = p.check_id_next("invalid 'print [simp]' command, identifier expected");
    buffer<name> attrs;
    attrs.push_back(attr);
    buffer<name> no_congr;
    simp_lemmas slss = get_simp_lemmas(aux_tctx, attrs, no_congr);
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    out << slss.pp_simp(out.get_formatter());
}

static void print_congr_rules(parser & p) {
    type_context aux_tctx(p.env(), p.get_options());
    name attr = p.check_id_next("invalid 'print [congr]' command, identifier expected");
    buffer<name> no_simp;
    buffer<name> attrs;
    attrs.push_back(attr);
    simp_lemmas slss = get_simp_lemmas(aux_tctx, no_simp, attrs);
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    out << slss.pp_congr(out.get_formatter());
}

static void print_simp_extensions(parser & p) {
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    out << pp_simp_extensions(p.env());
}

#if 0
static void print_light_rules(parser & p) {
    type_checker tc(p.env());
    auto out = regular(p.env(), p.ios(), tc);
    light_rule_set lrs = get_light_rule_set(p.env());
    out << lrs;
}
#endif

static void print_aliases(parser const & p) {
    std::ostream & out = p.ios().get_regular_stream();
    for_each_expr_alias(p.env(), [&](name const & n, list<name> const & as) {
            out << n << " -> {";
            bool first = true;
            for (name const & a : as) {
                if (first) first = false; else out << ", ";
                out << a;
            }
            out << "}\n";
        });
}

static void print_key_equivalences(parser & p) {
    std::ostream & out = p.ios().get_regular_stream();
    for_each_key_equivalence(p.env(), [&](buffer<name> const & ns) {
            out << "[";
            for (unsigned i = 0; i < ns.size(); i++) {
                if (i > 0) out << ", ";
                out << ns[i];
            }
            out << "]\n";
        });
}

static void print_attribute(parser & p, attribute const & attr) {
    buffer<name> instances;
    attr.get_instances(p.env(), instances);

    // oldest first
    unsigned i = instances.size();
    while (i > 0) {
        --i;
        p.ios().get_regular_stream() << instances[i] << "\n";
    }
}

environment print_cmd(parser & p) {
    flycheck_information info(p.ios());
    environment const & env = p.env();
    type_checker tc(env);
    auto out = regular(env, p.ios(), tc);
    if (info.enabled()) {
        p.display_information_pos(p.cmd_pos());
        out << "print result:\n";
    }
    if (p.curr() == scanner::token_kind::String) {
        out << p.get_str_val() << endl;
        p.next();
    } else if (p.curr_is_token_or_id(get_raw_tk())) {
        p.next();
        expr e = p.parse_expr();
        options opts = out.get_options();
        opts = opts.update(get_pp_notation_name(), false);
        out.update_options(opts) << e << endl;
    } else if (p.curr_is_token_or_id(get_options_tk())) {
        p.next();
        out << p.ios().get_options() << endl;
    } else if (p.curr_is_token_or_id(get_trust_tk())) {
        p.next();
        out << "trust level: " << p.env().trust_lvl() << endl;
    } else if (p.curr_is_token_or_id(get_key_equivalences_tk())) {
        p.next();
        print_key_equivalences(p);
    } else if (p.curr_is_token_or_id(get_definition_tk())) {
        p.next();
        auto pos = p.pos();
        name id  = p.check_id_next("invalid 'print definition', constant expected");
        list<name> cs = p.to_constants(id, "invalid 'print definition', constant expected", pos);
        bool first = true;
        for (name const & c : cs) {
            if (first)
                first = false;
            else
                out << "\n";
            declaration const & d = p.env().get(c);
            if (d.is_theorem()) {
                print_constant(p, "theorem", d);
                print_definition(p, c, pos);
            } else if (d.is_definition()) {
                print_constant(p, "definition", d);
                print_definition(p, c, pos);
            } else {
                throw parser_error(sstream() << "invalid 'print definition', '" << to_user_name(p.env(), c) << "' is not a definition", pos);
            }
        }
    } else if (p.curr_is_token_or_id(get_instances_tk())) {
        p.next();
        name c = p.check_constant_next("invalid 'print instances', constant expected");
        for (name const & i : get_class_instances(env, c)) {
            out << i << " : " << env.get(i).get_type() << endl;
        }
    } else if (p.curr_is_token_or_id(get_classes_tk())) {
        p.next();
        buffer<name> classes;
        get_classes(env, classes);
        std::sort(classes.begin(), classes.end());
        for (name const & c : classes) {
            out << c << " : " << env.get(c).get_type() << endl;
        }
    } else if (p.curr_is_token_or_id(get_attributes_tk())) {
        p.next();
        buffer<attribute const *> attrs;
        get_attributes(p.env(), attrs);
        std::sort(attrs.begin(), attrs.end(), [](attribute const * a1, attribute const * a2) {
            return a1->get_name() < a2->get_name();
        });
        for (auto attr : attrs) {
            out << "[" << attr->get_name() << "] " << attr->get_description() << endl;
        }
    } else if (p.curr_is_token_or_id(get_prefix_tk())) {
        p.next();
        print_prefix(p);
    } else if (p.curr_is_token_or_id(get_aliases_tk())) {
        p.next();
        print_aliases(p);
    } else if (p.curr_is_token_or_id(get_axioms_tk())) {
        p.next();
        return print_axioms(p);
    } else if (p.curr_is_token_or_id(get_fields_tk())) {
        p.next();
        auto pos = p.pos();
        name S = p.check_constant_next("invalid 'print fields' command, constant expected");
        print_fields(p, S, pos);
    } else if (p.curr_is_token_or_id(get_notation_tk())) {
        p.next();
        print_notation(p);
    } else if (p.curr_is_token_or_id(get_inductive_tk())) {
        p.next();
        auto pos = p.pos();
        name c = p.check_constant_next("invalid 'print inductive', constant expected");
        print_inductive(p, c, pos);
    } else if (p.curr_is_token(get_lbracket_tk())) {
        p.next();
        auto pos = p.pos();
        auto name = p.check_id_next("invalid attribute declaration, identifier expected");
        p.check_token_next(get_rbracket_tk(), "invalid 'print [<attr>]', ']' expected");

        if (name == "recursor")
            print_recursor_info(p);
        else if (name == "unify")
            print_unification_hints(p);
        else if (name == "defeq")
            print_rfl_lemmas(p);
        else if (name == "simp")
            print_simp_rules(p);
        else if (name == "simp_ext")
            print_simp_extensions(p);
        else if (name == "congr")
            print_congr_rules(p);
        else if (name == "light") {
            // print_light_rules(p);
        } else {
            if (!is_attribute(p.env(), name))
                throw parser_error(sstream() << "unknown attribute [" << name << "]", pos);
            auto const & attr = get_attribute(p.env(), name);
            print_attribute(p, attr);
        }
    } else if (print_polymorphic(p)) {
    } else {
        throw parser_error("invalid print command", p.pos());
    }
    return p.env();
}
}


text:
<?php
	#
	# $Id: watch-categories.php,v 1.1.2.24 2003-05-08 13:07:45 dan Exp $
	#
	# Copyright (c) 1998-2003 DVL Software Limited
	#

	require_once($_SERVER['DOCUMENT_ROOT'] . '/include/common.php');
	require_once($_SERVER['DOCUMENT_ROOT'] . '/include/freshports.php');
	require_once($_SERVER['DOCUMENT_ROOT'] . '/include/databaselogin.php');
	require_once($_SERVER['DOCUMENT_ROOT'] . '/include/getvalues.php');
	require_once($_SERVER['DOCUMENT_ROOT'] . '/include/watch-lists.php');

	// if we don't know who they are, we'll make sure they login first
	if (!$visitor) {
		header("Location: /login.php?origin=" . $_SERVER["PHP_SELF"]);  /* Redirect browser to PHP web site */
		exit;  /* Make sure that code below does not get executed when we redirect. */
	}

	freshports_Start('Watch categories',
					'freshports - new ports, applications',
					'FreeBSD, index, applications, ports');

$Debug = 0;

if ($Debug) # phpinfo();

$visitor = $_COOKIE["visitor"];

if ($_REQUEST['wlid']) {
		# they clicked on the GO button and we have to apply the
		# watch staging area against the watch list.
		$wlid = AddSlashes($_REQUEST["wlid"]);
		if ($Debug) echo "setting SetLastWatchListChosen => \$wlid='$wlid'";
		$User->SetLastWatchListChosen($wlid);
		if ($Debug) echo "\$wlid='$wlid'";
} else {
	$wlid = $User->last_watch_list_chosen;
	if ($Debug) echo "\$wlid='$wlid'";
	if ($wlid == '') {
		$WatchLists = new WatchLists($db);
		$wlid = $WatchLists->GetDefaultWatchListID($User->id);
		if ($Debug) echo "GetDefaultWatchListID => \$wlid='$wlid'";
	}
}

?>
<?php # main table start ?>
<table width="<? echo $TableWidth ?>" border="0" ALIGN="center">

<?php # article table start ?>

	<? echo freshports_PageBannerText("Watch List - categories"); ?>

<?php # list of categories table start ?>

This screen contains a list of the port categories. The categories with a * beside them contain ports which are
on your watch list. When a port changes in one of your watch categories, you will be notified by email if you have selected a
notification frequency within your personal preferences.

<?php # ddlb start ?>

Select...

<?php
if ($Debug) echo 'when calling freshports_WatchListDDLBForm, $wlid = \'' . $wlid . '\'';
echo freshports_WatchListDDLBForm($db, $User->id, $wlid);

?>

<?php # ddlb finish ?>

<?php # list of categories table finish ?>

<?php

if ($wlid != '') {
$sql = "
   select distinct(ports_categories.category_id) as category_id
     from watch_list, watch_list_element, ports, ports_categories
    WHERE watch_list.id      = " . $wlid . "
      and watch_list.user_id = $User->id
      and watch_list.id      = watch_list_element.watch_list_id
      and ports.element_id   = watch_list_element.element_id
      AND ports_categories.port_id = ports.id";

if ($Debug) echo "
$sql
";

echo '
' . "\n";

$result  = pg_exec ($db, $sql);
$numrows = pg_numrows($result);

if ($Debug) echo "num categories being watched = $numrows
";

for ($i = 0; $i < $numrows; $i++) {
	$myrow = pg_fetch_array($result, $i);
	$WatchedCategories{$myrow["category_id"]} = ' *';
	if ($Debug) echo "category " . $myrow["category_id"] . " = " . $WatchedCategories{$myrow["category_id"]} . '
';
}

# categories list start

$HTML .= "\n" . '
' . "\n";
$HTML .= '
';
// get the list of categories to display
$sql = "
    select categories.id          as category_id,
           categories.name        as category,
           categories.description as description
      from categories
  order by category";

$result  = pg_exec($db, $sql);
$numrows = pg_numrows($result);
$NumCategories = 0;
for ($i = 0; $i < $numrows; $i++) {
	$myrow = pg_fetch_array($result, $i);
	$NumCategories++;
	$rows[$NumCategories-1]=$myrow;
}

$RowCount = ceil($NumCategories / (double) 4);
$Row = 0;
for ($i = 0; $i < $NumCategories; $i++) {
	pg_fetch_array ($result, $i);
   $Row++;

   if ($Row > $RowCount) {
      $HTML .= "	\n";
      $Row = 1;
   }

   if ($Row == 1) {
      $HTML .= '';
   }

   $HTML .= ' ' . $rows[$i]["category"] . '';

   $HTML .= $WatchedCategories{$rows[$i]["category_id"]};
   $HTML .= "
\n";
}

if ($Row != 1) {
   $HTML .= "
\n";
}

echo $HTML;

echo "
\n";
# categories list finish

} else {
	echo '
';
} // if wlid
?>

<?php # main article table finish ?>

  <?
  freshports_SideBar();
  ?>

<?php # main table finish ?>

<?
freshports_ShowFooter();
?>

redpajama_set_name: RedPajamaGithub


text:
package com.salesforce.dva.argus.service.metric.transform;

import com.salesforce.dva.argus.entity.Metric;
import org.junit.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

public class AbsoluteTransformTest {

    @Test
    public void transform_shouldReturnAbsoluteForOneMetric() {
        Metric m1 = new Metric("test_scope", "test_metric");
        Map<Long, String> dp = new HashMap<Long, String>();

        dp.put(2L, "-3.0");
        dp.put(4L, "-5.0");
        dp.put(5L, "-2.2");
        m1.setDatapoints(dp);

        List<Metric> metrics = Arrays.asList(m1);
        List<Metric> result = (new MetricMappingTransform(new AbsoluteValueMapping())).transform(metrics);

        assertThat(result, equalTo(metrics));

        Map<Long, String> expectedDps = new HashMap<Long, String>();

        expectedDps.put(2L, "3.0");
        expectedDps.put(4L, "5.0");
        expectedDps.put(5L, "2.2");
        assertThat(result.get(0).getDatapoints(), equalTo(expectedDps));
    }

    @Test
    public void transform_shouldReturnAbsoluteForMultipleMetric() {
        Metric m1 = new Metric("test_scope", "test_metric");
        HashMap<Long, String> dp1 = new HashMap<Long, String>();

        dp1.put(2L, "-4");
        dp1.put(3L, "-6");
        m1.setDatapoints(dp1);

        Metric m2 = new Metric("test_scope", "test_metric");
        HashMap<Long, String> dp2 = new HashMap<Long, String>();

        dp2.put(3L, "-5");
        dp2.put(9L, "-2");
        dp2.put(2L, "-6");
        m2.setDatapoints(dp2);

        List<Metric> metrics = Arrays.asList(m1, m2);
        List<Metric> results = (new MetricMappingTransform(new AbsoluteValueMapping())).transform(metrics);

        assertThat(results, equalTo(metrics));

        Map<Long, String> expectedDps1 = new HashMap<Long, String>();

        expectedDps1.put(2L, "4.0");
        expectedDps1.put(3L, "6.0");
        assertThat(results.get(0).getDatapoints(), equalTo(expectedDps1));

        Map<Long, String> expectedDps2 = new HashMap<Long, String>();

        expectedDps2.put(2L, "6.0");
        expectedDps2.put(3L, "5.0");
        expectedDps2.put(9L, "2.0");
        assertThat(results.get(1).getDatapoints(), equalTo(expectedDps2));
    }
}
/* Copyright (c) 2016, Salesforce.com, Inc.  All rights reserved. */


text:
package org.nbandroid.netbeans.gradle.v2.project.template.freemarker.converters;

import freemarker.template.*;
import java.util.List;
import org.nbandroid.netbeans.gradle.v2.project.template.freemarker.AssetNameConverter;
import org.nbandroid.netbeans.gradle.v2.project.template.freemarker.AssetNameConverter.Type;

/**
 * Method invoked by FreeMarker to convert a layout name into an appropriate
 * Activity class.
 */
public class FmLayoutToActivityMethod implements TemplateMethodModelEx {

    @Override
    public TemplateModel exec(List args) throws TemplateModelException {
        if (args.size() != 1) {
            throw new TemplateModelException("Wrong arguments");
        }

        String name = ((TemplateScalarModel) args.get(0)).getAsString();
        return new SimpleScalar(new AssetNameConverter(Type.LAYOUT, name).getValue(Type.ACTIVITY));
    }
}


text:
package com.google.cloud.dataflow.sdk.values;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.cloud.dataflow.sdk.coders.Coder;
import com.google.cloud.dataflow.sdk.coders.InstantCoder;
import com.google.cloud.dataflow.sdk.coders.StandardCoder;
import com.google.cloud.dataflow.sdk.util.PropertyNames;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import org.joda.time.Instant;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * An immutable (value, timestamp) pair.
 *
 * <p> Used for assigning initial timestamps to values inserted into a pipeline
 * with {@link com.google.cloud.dataflow.sdk.transforms.Create#timestamped}.
 *
 * @param <V> the type of the value
 */
public class TimestampedValue<V> {

  /**
   * Returns a new {@code TimestampedValue} with the given value and timestamp.
   */
  public static <V> TimestampedValue<V> of(V value, Instant timestamp) {
    return new TimestampedValue<>(value, timestamp);
  }

  public V getValue() {
    return value;
  }

  public Instant getTimestamp() {
    return timestamp;
  }

  @Override
  public boolean equals(Object other) {
    if (!(other instanceof TimestampedValue)) {
      return false;
    }
    TimestampedValue that = (TimestampedValue) other;
    return Objects.equals(value, that.value) && Objects.equals(timestamp, that.timestamp);
  }

  @Override
  public int hashCode() {
    return Objects.hash(value, timestamp);
  }

  @Override
  public String toString() {
    return "TimestampedValue(" + value + ", " + timestamp + ")";
  }

  /////////////////////////////////////////////////////////////////////////////

  /**
   * Coder for {@code TimestampedValue}.
   */
  @SuppressWarnings("serial")
  public static class TimestampedValueCoder<T>
      extends StandardCoder<TimestampedValue<T>> {

    private final Coder<T> valueCoder;

    public static <T> TimestampedValueCoder<T> of(Coder<T> valueCoder) {
      return new TimestampedValueCoder<>(valueCoder);
    }

    @JsonCreator
    public static TimestampedValueCoder<?> of(
        @JsonProperty(PropertyNames.COMPONENT_ENCODINGS)
        List<Object> components) {
      checkArgument(components.size() == 1,
                    "Expecting 1 component, got " + components.size());
      return of((Coder<?>) components.get(0));
    }

    @SuppressWarnings("unchecked")
    TimestampedValueCoder(Coder<T> valueCoder) {
      this.valueCoder = checkNotNull(valueCoder);
    }

    @Override
    public void encode(TimestampedValue<T> windowedElem,
                       OutputStream outStream,
                       Context context)
        throws IOException {
      valueCoder.encode(windowedElem.getValue(), outStream, context.nested());
      InstantCoder.of().encode(
          windowedElem.getTimestamp(), outStream, context);
    }

    @Override
    public TimestampedValue<T> decode(InputStream inStream, Context context)
        throws IOException {
      T value = valueCoder.decode(inStream, context.nested());
      Instant timestamp = InstantCoder.of().decode(inStream, context);
      return TimestampedValue.of(value, timestamp);
    }

    @Override
    @Deprecated
    public boolean isDeterministic() {
      return valueCoder.isDeterministic();
    }

    @Override
    public void verifyDeterministic() throws NonDeterministicException {
      verifyDeterministic(
          "TimestampedValueCoder requires a deterministic valueCoder",
          valueCoder);
    }

    @Override
    public List<? extends Coder<?>> getCoderArguments() {
      return Arrays.<Coder<?>>asList(valueCoder);
    }

    public static <T> List<Object> getInstanceComponents(TimestampedValue<T> exampleValue) {
      return Arrays.<Object>asList(exampleValue.getValue());
    }
  }

  /////////////////////////////////////////////////////////////////////////////

  private final V value;
  private final Instant timestamp;

  protected TimestampedValue(V value, Instant timestamp) {
    this.value = value;
    this.timestamp = timestamp;
  }
}


text:
/**
 * Container for custom node types
 */
SceneJS.Types = new (function () {

    /**
     * Installs a node type
     * @param typeName
     * @param methods
     */
    this.addType = function (typeName, methods) {
        SceneJS_NodeFactory.createNodeType(typeName, methods,
            // Augments the basic node type with our custom type's methods
            function (type) {
                var method;
                for (var methodName in methods) {
                    if (methods.hasOwnProperty(methodName)) {
                        method = methods[methodName];
                        switch (methodName) {
                            case "init": // Deprecated
                            case "construct":
                                (function () {
                                    var _method = methods[methodName];
                                    type.prototype._init = function (params) {
                                        _method.call(this, params);
                                    };

                                    // Mark node type as a plugin
                                    type.prototype._fromPlugin = true;
                                })();
                                break;
                            case "destroy": // Deprecated
                            case "destruct":
                                type.prototype._destroy = method;
                                break;
                            default:
                                type.prototype[methodName] = method;
                        }
                    }
                }
            });
    };

    /**
     * Tests if given node type is installed
     * @param typeName
     * @param methods
     */
    this.hasType = function (typeName) {
        return !!SceneJS_NodeFactory.nodeTypes[typeName];
    };
})();


text:
/**
 * Plugin for extending jsdoc3 with bem-specific tags.
 *
 * Adds the following tags:
 * 1. `@block [name]` for defining blocks JS code.
 * 2. `@mod [mod name]` and `@val [mod value]` for defining modifiers
 * JS code. Must be used with `@block` tag.
 * 3. `@final` - specifies, that method should not be overriden in
 * subclasses.
 *
 * Automatically detects `BEM.DOM.decl` calls, so for the most time
 * you would not need to use `@block`, `@mod` and `@val` tags.
 *
 */
'use strict';

/**
 * @see http://usejsdoc.org/about-plugins.html#tag-definitions
 */
exports.defineTags = function(dictionary) {
    dictionary.defineTag('block', {
        canHaveType: false,
        onTagged: function(doclet, tag) {
            doclet.addTag('kind', 'block');
            if (tag.value) {
                doclet.addTag('name', tag.value);
            }
            doclet.block = tag.value;
        }
    });

    dictionary.defineTag('mod', {
        canHaveType: false,
        onTagged: function(doclet, tag) {
            doclet.addTag('kind', 'mod');

            doclet.mod = doclet.mod || {};
            doclet.mod.name = tag.value;
        }
    });

    dictionary.defineTag('val', {
        canHaveType: false,
        onTagged: function(doclet, tag) {
            doclet.mod = doclet.mod || {};
            doclet.mod.value = tag.value;
        }
    });

    dictionary.defineTag('final', {
        canHaveType: false,
        canHaveValue: false,

        onTagged: function(doclet, tag) {
            doclet.final = true;
        }
    });
};

/**
 * astNodeVisitor should be used instead of nodeVisitor for
 * node+esprima.
 * @see http://usejsdoc.org/about-plugins.html#node-visitors
 */
exports.astNodeVisitor = {
    visitNode: function(node, e, parser, currentSourceName) {
        if (isBemDecl(node)) {
            var bemEntity = getEntity(node.arguments[0]),
                name = getEntityName(bemEntity),
                comment = getEntityDocComment(node, bemEntity);

            e.id = node.nodeId;
            e.comment = comment;
            e.filename = currentSourceName;
            e.lineno = node.loc.start.line;
            e.astnode = node;
            e.event = "symbolFound";
            e.code = {
                name: name,
                bemEntity: bemEntity,
                type: "ObjectExpression",
                node: node
            };
            e.finishers = [
                addDocletBemEntity,
                parser.addDocletRef
            ];
        } else if (node.type === "ObjectExpression" && isBemDecl(node.parent)) {
            var entityName = getEntityName(getEntity(node.parent.arguments[0])),
                lends = isStaticDecl(node) ? entityName : entityName + '.prototype';

            e.id = node.nodeId;
            e.comment = '/** @lends ' + lends + '*/';
            e.filename = currentSourceName;
            e.lineno = node.loc.start.line;
            e.astnode = node;
            e.event = "symbolFound";
            e.code = {
                name: "____",
                type: "Property",
                node: node
            };

            e.finishers = [
                parser.addDocletRef,
            ];

        }

    }
};

/**
 * Checks if AST node is `BEM.decl` or `BEM.DOM.decl` call.
 *
 * @param {Object} node Mozilla Parser API AST node
 */
function isBemDecl(node) {
    if (node.type !== 'CallExpression') {
        return false;
    }

    if (node.callee.type !== 'MemberExpression') {
        return false;
    }

    if (node.callee.property.type !== 'Identifier' || node.callee.property.name !== 'decl') {
        return false;
    }

    var obj = node.callee.object;
    if (obj.type === "Identifier") {
        return obj.name === "BEM";
    }

    if (obj.type === "MemberExpression") {
        if (obj.object.type !== "Identifier") {
            return false;
        }

        if (obj.object.name !== "BEM") {
            return false;
        }

        if (obj.property.type !== "Identifier") {
            return false;
        }

        return obj.property.name === "DOM";
    }
    return false;
}

/**
 * Constructs a bem entity description
 * from first argument of `BEM.DOM.decl`
 *
 * @param {Object} decl an AST node of a first argument of
 * BEM.DOM.decl
 * @returns {Object} bem entity description with `block`,
 * `mod`, and `val` keys
 */
function getEntity(decl) {
    if (decl.type === "Literal") {
        return {block: decl.value};
    }

    if (decl.type === "ObjectExpression") {
        var base = getProperty(decl, 'baseBlock'),
            o = {
                block: getProperty(decl, 'block'),
                mod: getProperty(decl, 'modName'),
                val: getProperty(decl, 'modVal')
            };

        if (base) {
            o.base = base;
        }
        return o;
    }

}

/**
 * Returns a value of property by name from
 * given object literal AST node
 *
 * @param {Object} objNode an AST node of an object literal
 * (node.type is assumed to be equal to "ObjectExpression")
 * @param {String} name a name of a property to return
 */
function getProperty(objNode, name) {
    for (var i=0; i<objNode.properties.length; i++) {
        if (getKey(objNode.properties[i]) === name) {
            return getValue(objNode.properties[i]);
        }
    }
}

/**
 * Returns a key value of a property expression
 * @param {Object} propNode an AST node of a propery expression
 */
function getKey(propNode) {
    if (propNode.key.type === "Literal") {
        return propNode.key.value;
    }

    if (propNode.key.type === "Identifier") {
        return propNode.key.name;
    }
}

function getValue(propNode) {
    return propNode.value.value;
}

function getEntityName(entity) {
    return entity.block +
        (entity.mod? '_' + entity.mod : '') +
        (entity.val? '_' + entity.val: '');
}

/**
 * Constructs new doc comment by appending
 * custom doc tags (@block, @elem, @mod) to
 * to source doc comment.
 *
 * @param {Object} node AST node to document
 * @param {Object} entity BEM entity, declared by node
 * @returns {String} doc comment for a bem entity
 */
function getEntityDocComment(node, entity) {
    var comment = ['/**'];
    if (node.leadingComments && node.leadingComments[0]) {
        comment.push(node.leadingComments[0].value);
    }

    if (entity.block) {
        comment.push('@block');
    }

    if (entity.mod) {
        comment.push('@mod');
    }

    if (entity.val) {
        comment.push('@val');
    }

    comment.push('*/');
    return comment.join('\n');
}

/**
 * Adds bem entity description to a doclet.
 * This method is called after doclet has
 * been constructed but before it sent to template.
 * Its required, because automatically inserted
 * `@block`, `@elem` and `@mod` keys does not
 * contain names.
 * @param {Object} e symbolFound event, generated from
 * `astNodeVisitor`. At this stage should already have
 * doclet property, which contains parsed docs.
 */
function addDocletBemEntity(e) {
    var bemEntity = e.code.bemEntity;
    e.doclet.block = bemEntity.block;
    if (bemEntity.base) {
        e.doclet.baseBlock = bemEntity.base;
    }
    if (bemEntity.mod) {
        e.doclet.mod = {
            name: bemEntity.mod,
            value: bemEntity.val
        };
    }
}

/**
 * Returns true if passed AST node is a static
 * methods declaration of BEM.DOM.decl
 * @param {Object} node an AST node of BEM.DOM.decl argument
 * @returns {Boolean}
 */
function isStaticDecl(node) {
    var parent = node.parent;
    return hasStatic(parent) &&
        parent.arguments[2] === node;
}

/**
 * Returns true if `BEM.DOM.decl` AST node has
 * static methods declaration.
 * @param {Object} node AST node of BEM.DOM.decl`
 * @return {Boolean}
 */
function hasStatic(node) {
    var args = node.arguments;
    if (!args) {
        return false;
    }
    return args.length >= 3 &&
        args[1].type === "ObjectExpression" &&
        args[2].type === "ObjectExpression";
}


text:
<?php
/*
This program uses a function defined in admin_functions_rwd.php
to create destinations for a site and grants access to a group.
*/
require_once( 'admin_functions_rwd.php' );

use cascade_ws_AOHS      as aohs;
use cascade_ws_constants as c;
use cascade_ws_asset     as a;
use cascade_ws_property  as p;
use cascade_ws_utility   as u;
use cascade_ws_exception as e;

try
{
    $site_name = "cascade-database";

    createDestinationForSites(
        $cascade,
        $site_name,
        "cru" // group name
    );
}
catch( \Exception $e )
{
    echo S_PRE . $e . E_PRE;
}
catch( \Error $er )
{
    echo S_PRE . $er . E_PRE;
}
?>


text:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Mvc.Server.Models;
using Mvc.Server.Services;
using static OpenIddict.Abstractions.OpenIddictConstants;

namespace Mvc.Server
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
            => Configuration = configuration;

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddDbContext<ApplicationDbContext>(options =>
            {
                // Configure the context to use Microsoft SQL Server.
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));

                // Register the entity sets needed by OpenIddict.
                // Note: use the generic overload if you need
                // to replace the default OpenIddict entities.
                options.UseOpenIddict();
            });

            // Register the Identity services.
            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<ApplicationDbContext>()
                .AddDefaultTokenProviders();

            // Configure Identity to use the same JWT claims as OpenIddict instead
            // of the legacy WS-Federation claims it uses by default (ClaimTypes),
            // which saves you from doing the mapping in your authorization controller.
            services.Configure<IdentityOptions>(options =>
            {
                options.ClaimsIdentity.UserNameClaimType = Claims.Name;
                options.ClaimsIdentity.UserIdClaimType = Claims.Subject;
                options.ClaimsIdentity.RoleClaimType = Claims.Role;
            });

            services.AddOpenIddict()

                // Register the OpenIddict core components.
                .AddCore(options =>
                {
                    // Configure OpenIddict to use the Entity Framework Core stores and models.
                    // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities.
                    options.UseEntityFrameworkCore()
                           .UseDbContext<ApplicationDbContext>();
                })

                // Register the OpenIddict server components.
                .AddServer(options =>
                {
                    // Enable the authorization, device, logout, token, userinfo and verification endpoints.
                    options.SetAuthorizationEndpointUris("/connect/authorize")
                           .SetDeviceEndpointUris("/connect/device")
                           .SetLogoutEndpointUris("/connect/logout")
                           .SetTokenEndpointUris("/connect/token")
                           .SetUserinfoEndpointUris("/connect/userinfo")
                           .SetVerificationEndpointUris("/connect/verify");

                    // Note: the Mvc.Client sample only uses the code flow and the password flow, but you
                    // can enable the other flows if you need to support implicit or client credentials.
                    options.AllowAuthorizationCodeFlow()
                           .AllowDeviceCodeFlow()
                           .AllowPasswordFlow()
                           .AllowRefreshTokenFlow();

                    // Mark the "email", "profile", "roles" and "demo_api" scopes as supported scopes.
                    options.RegisterScopes(Scopes.Email, Scopes.Profile, Scopes.Roles, "demo_api");

                    // Register the signing and encryption credentials.
                    options.AddDevelopmentEncryptionCertificate()
                           .AddDevelopmentSigningCertificate();

                    // Register the ASP.NET Core host and configure the ASP.NET Core-specific options.
                    options.UseAspNetCore()
                           .EnableStatusCodePagesIntegration()
                           .EnableAuthorizationEndpointPassthrough()
                           .EnableLogoutEndpointPassthrough()
                           .EnableTokenEndpointPassthrough()
                           .EnableUserinfoEndpointPassthrough()
                           .EnableVerificationEndpointPassthrough()
                           .DisableTransportSecurityRequirement(); // During development, you can disable the HTTPS requirement.

                    // Note: if you don't want to specify a client_id when sending
                    // a token or revocation request, uncomment the following line:
                    //
                    // options.AcceptAnonymousClients();

                    // Note: if you want to process authorization and token requests
                    // that specify non-registered scopes, uncomment the following line:
                    //
                    // options.DisableScopeValidation();

                    // Note: if you don't want to use permissions, you can disable
                    // permission enforcement by uncommenting the following lines:
                    //
                    // options.IgnoreEndpointPermissions()
                    //        .IgnoreGrantTypePermissions()
                    //        .IgnoreScopePermissions();

                    // Note: when issuing access tokens used by third-party APIs
                    // you don't own, you can disable access token encryption:
                    //
                    // options.DisableAccessTokenEncryption();
                })

                // Register the OpenIddict validation components.
                .AddValidation(options =>
                {
                    // Configure the audience accepted by this resource server.
                    // The value MUST match the audience associated with the
                    // "demo_api" scope, which is used by ResourceController.
                    options.AddAudiences("resource_server");

                    // Import the configuration from the local OpenIddict server instance.
                    options.UseLocalServer();

                    // Register the ASP.NET Core host.
                    options.UseAspNetCore();

                    // For applications that need immediate access token or authorization
                    // revocation, the database entry of the received tokens and their
                    // associated authorizations can be validated for each API call.
                    // Enabling these options may have a negative impact on performance.
                    //
                    // options.EnableAuthorizationEntryValidation();
                    // options.EnableTokenEntryValidation();
                });

            services.AddTransient<IEmailSender, AuthMessageSender>();
            services.AddTransient<ISmsSender, AuthMessageSender>();

            // Register the worker responsible of seeding the database with the sample clients.
            // Note: in a real world application, this step should be part of a setup script.
            services.AddHostedService<Worker>();
        }

        public void Configure(IApplicationBuilder app)
        {
            app.UseDeveloperExceptionPage();

            app.UseStaticFiles();

            app.UseStatusCodePagesWithReExecute("/error");

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(options => options.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}"));
        }
    }
}


text:
<?php

interface PresentationRepositoryInterface
{
    public function all();

    public function find($id);

    public function create($input);

}


text:
namespace TypeVisualiser.ILAnalyser
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;
    using System.Reflection.Emit;

    using TypeVisualiser.Properties;

    internal static class GlobalIntermediateLanguageConstants
    {
        private static readonly object SyncRoot = new object();

        private static bool isInitialised;

        private static ReadOnlyDictionary<int, OpCode> multiByteOpCodes = new ReadOnlyDictionary<int, OpCode>();

        private static ReadOnlyDictionary<int, OpCode> singleByteOpCodes = new ReadOnlyDictionary<int, OpCode>();

        public static ReadOnlyDictionary<int, OpCode> MultiByteOpCodes
        {
            get
            {
                return multiByteOpCodes;
            }
        }

        public static ReadOnlyDictionary<int, OpCode> SingleByteOpCodes
        {
            get
            {
                return singleByteOpCodes;
            }
        }

        internal static void LoadOpCodes()
        {
            if (isInitialised)
            {
                return;
            }

            lock (SyncRoot)
            {
                if (isInitialised)
                {
                    return;
                }

                var multiByteOps = new Dictionary<int, OpCode>();
                var singleByteOps = new Dictionary<int, OpCode>();
                isInitialised = true;
                FieldInfo[] infoArray1 = typeof(OpCodes).GetFields();
                foreach (FieldInfo info1 in infoArray1)
                {
                    if (info1.FieldType == typeof(OpCode))
                    {
                        var code1 = (OpCode)info1.GetValue(null);
                        var num2 = (ushort)code1.Value;
                        if (num2 < 0x100)
                        {
                            singleByteOps[num2] = code1;
                        }
                        else
                        {
                            if ((num2 & 0xff00) != 0xfe00)
                            {
                                throw new InvalidOperationException(Resources.Globals_LoadOpCodes_Invalid_IL_Op_Code);
                            }

                            multiByteOps[num2 & 0xff] = code1;
                        }
                    }
                }

                multiByteOpCodes = new ReadOnlyDictionary<int, OpCode>(multiByteOps);
                singleByteOpCodes = new ReadOnlyDictionary<int, OpCode>(singleByteOps);
            }
        }

        // ***BR 22-2-12 not needed right now
        ///// <summary>
        ///// Retrieve the friendly name of a type
        ///// </summary>
        ///// <param name="typeName">
        ///// The complete name to the type
        ///// </param>
        ///// <returns>
        ///// The simplified name of the type (i.e. "int" instead f System.Int32)
        ///// </returns>
        // internal static string ProcessSpecialTypes(string typeName)
        // {
        // string result = typeName;
        // switch (typeName)
        // {
        // case "System.string":
        // case "System.String":
        // case "String":
        // result = "string";
        // break;
        // case "System.Int32":
        // case "Int":
        // case "Int32":
        // result = "int";
        // break;
        // case "System.Int64":
        // case "long":
        // result = "long";
        // break;
        // }
        // return result;
        // }
    }
}


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.6
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2015.08.28 at 04:10:22 PM CST
//

package org.shaolin.bmdp.designtime.andriod.datamodel;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
Java class for CalendarView complex type.
 *
 *
The following schema fragment specifies the expected content contained within this class.
 *
 *

 * <complexType name="CalendarView">
 *   <complexContent>
 *     <extension base="{}FrameLayout">
 *       <attribute ref="{http://schemas.android.com/apk/res/android}dateTextAppearance"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}firstDayOfWeek"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}focusedMonthDateColor"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}maxDate"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}minDate"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}selectedDateVerticalBar"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}selectedWeekBackgroundColor"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}showWeekNumber"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}shownWeekCount"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}unfocusedMonthDateColor"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}weekDayTextAppearance"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}weekNumberColor"/>
 *       <attribute ref="{http://schemas.android.com/apk/res/android}weekSeparatorLineColor"/>
 *     </extension>
 *   </complexContent>
 * </complexType>
 *

 *
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CalendarView")
@XmlRootElement(name = "CalendarView")
public class CalendarView
    extends FrameLayout
    implements Serializable
{

    private final static long serialVersionUID = 1L;
    @XmlAttribute(name = "dateTextAppearance", namespace = "http://schemas.android.com/apk/res/android")
    protected String dateTextAppearance;
    @XmlAttribute(name = "firstDayOfWeek", namespace = "http://schemas.android.com/apk/res/android")
    protected String firstDayOfWeek;
    @XmlAttribute(name = "focusedMonthDateColor", namespace = "http://schemas.android.com/apk/res/android")
    protected String focusedMonthDateColor;
    @XmlAttribute(name = "maxDate", namespace = "http://schemas.android.com/apk/res/android")
    protected String maxDate;
    @XmlAttribute(name = "minDate", namespace = "http://schemas.android.com/apk/res/android")
    protected String minDate;
    @XmlAttribute(name = "selectedDateVerticalBar", namespace = "http://schemas.android.com/apk/res/android")
    protected String selectedDateVerticalBar;
    @XmlAttribute(name = "selectedWeekBackgroundColor", namespace = "http://schemas.android.com/apk/res/android")
    protected String selectedWeekBackgroundColor;
    @XmlAttribute(name = "showWeekNumber", namespace = "http://schemas.android.com/apk/res/android")
    protected String showWeekNumber;
    @XmlAttribute(name = "shownWeekCount", namespace = "http://schemas.android.com/apk/res/android")
    protected String shownWeekCount;
    @XmlAttribute(name = "unfocusedMonthDateColor", namespace = "http://schemas.android.com/apk/res/android")
    protected String unfocusedMonthDateColor;
    @XmlAttribute(name = "weekDayTextAppearance", namespace = "http://schemas.android.com/apk/res/android")
    protected String weekDayTextAppearance;
    @XmlAttribute(name = "weekNumberColor", namespace = "http://schemas.android.com/apk/res/android")
    protected String weekNumberColor;
    @XmlAttribute(name = "weekSeparatorLineColor", namespace = "http://schemas.android.com/apk/res/android")
    protected String weekSeparatorLineColor;

    /**
     * Gets the value of the dateTextAppearance property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDateTextAppearance() {
        return dateTextAppearance;
    }

    /**
     * Sets the value of the dateTextAppearance property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setDateTextAppearance(String value) {
        this.dateTextAppearance = value;
    }

    /**
     * Gets the value of the firstDayOfWeek property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getFirstDayOfWeek() {
        return firstDayOfWeek;
    }

    /**
     * Sets the value of the firstDayOfWeek property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setFirstDayOfWeek(String value) {
        this.firstDayOfWeek = value;
    }

    /**
     * Gets the value of the focusedMonthDateColor property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getFocusedMonthDateColor() {
        return focusedMonthDateColor;
    }

    /**
     * Sets the value of the focusedMonthDateColor property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setFocusedMonthDateColor(String value) {
        this.focusedMonthDateColor = value;
    }

    /**
     * Gets the value of the maxDate property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getMaxDate() {
        return maxDate;
    }

    /**
     * Sets the value of the maxDate property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setMaxDate(String value) {
        this.maxDate = value;
    }

    /**
     * Gets the value of the minDate property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getMinDate() {
        return minDate;
    }

    /**
     * Sets the value of the minDate property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setMinDate(String value) {
        this.minDate = value;
    }

    /**
     * Gets the value of the selectedDateVerticalBar property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSelectedDateVerticalBar() {
        return selectedDateVerticalBar;
    }

    /**
     * Sets the value of the selectedDateVerticalBar property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSelectedDateVerticalBar(String value) {
        this.selectedDateVerticalBar = value;
    }

    /**
     * Gets the value of the selectedWeekBackgroundColor property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getSelectedWeekBackgroundColor() {
        return selectedWeekBackgroundColor;
    }

    /**
     * Sets the value of the selectedWeekBackgroundColor property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setSelectedWeekBackgroundColor(String value) {
        this.selectedWeekBackgroundColor = value;
    }

    /**
     * Gets the value of the showWeekNumber property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getShowWeekNumber() {
        return showWeekNumber;
    }

    /**
     * Sets the value of the showWeekNumber property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setShowWeekNumber(String value) {
        this.showWeekNumber = value;
    }

    /**
     * Gets the value of the shownWeekCount property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getShownWeekCount() {
        return shownWeekCount;
    }

    /**
     * Sets the value of the shownWeekCount property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setShownWeekCount(String value) {
        this.shownWeekCount = value;
    }

    /**
     * Gets the value of the unfocusedMonthDateColor property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getUnfocusedMonthDateColor() {
        return unfocusedMonthDateColor;
    }

    /**
     * Sets the value of the unfocusedMonthDateColor property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setUnfocusedMonthDateColor(String value) {
        this.unfocusedMonthDateColor = value;
    }

    /**
     * Gets the value of the weekDayTextAppearance property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getWeekDayTextAppearance() {
        return weekDayTextAppearance;
    }

    /**
     * Sets the value of the weekDayTextAppearance property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setWeekDayTextAppearance(String value) {
        this.weekDayTextAppearance = value;
    }

    /**
     * Gets the value of the weekNumberColor property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getWeekNumberColor() {
        return weekNumberColor;
    }

    /**
     * Sets the value of the weekNumberColor property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setWeekNumberColor(String value) {
        this.weekNumberColor = value;
    }

    /**
     * Gets the value of the weekSeparatorLineColor property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getWeekSeparatorLineColor() {
        return weekSeparatorLineColor;
    }

    /**
     * Sets the value of the weekSeparatorLineColor property.
     *
     * @param value
     *     allowed object is
     *     {@link String }
     *
     */
    public void setWeekSeparatorLineColor(String value) {
        this.weekSeparatorLineColor = value;
    }

}


text:
if (Ti.version < 1.8 ) {
	alert('Sorry - this application template requires Titanium Mobile SDK 1.8 or later');
}

// This is a single context application with mutliple windows in a stack
(function() {
	//determine platform and form factor and render approproate components
	var osname = Ti.Platform.osname,
		version = Ti.Platform.version,
		height = Ti.Platform.displayCaps.platformHeight,
		width = Ti.Platform.displayCaps.platformWidth;
	//considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide
	//yourself what you consider a tablet form factor for android
	var isTablet = osname === 'ipad' || (osname === 'android' && (width > 899 || height > 899));
	var Util = require('etc/Util');
	var Window;
	if (isTablet) {
		Window = require('ui/tablet/ApplicationWindow');
		Util.RATIO = 2;
	}
	else {
		Window = require('ui/handheld/ApplicationWindow');
	}
	if (osname == 'iphone') {
		Titanium.UI.iPhone.statusBarStyle = Titanium.UI.iPhone.StatusBar.OPAQUE_BLACK;
	}

	Titanium.Facebook.appid = "514307815249030";
	Titanium.Facebook.permissions = ['publish_stream', 'read_stream'];

	var ApplicationTabGroup = require('ui/common/ApplicationTabGroup');
	new ApplicationTabGroup(Window).open({transition: Ti.UI.iPhone.AnimationStyle.CURL_UP});
})();

//CACHE REMOTE IMAGE
// var Utils = {
	// /* modified version of https://gist.github.com/1243697
	// *  adds detection of file extension rather than hard-coding .jpg as in the original
	// */
	// _getExtension: function(fn) {
		// // from http://stackoverflow.com/a/680982/292947
		// var re = /(?:\.([^.]+))?$/;
		// var tmpext = re.exec(fn)[1];
		// return (tmpext) ? tmpext : '';
	// },
	// RemoteImage: function(a){
		// a = a || {};
		// var md5;
		// var needsToSave = false;
		// var savedFile;
		// if(a.image){
			// md5 = Ti.Utils.md5HexDigest(a.image)+this._getExtension(a.image);
			// savedFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,md5);
			// if(savedFile.exists()){
				// a.image = savedFile;
			// } else {
				// needsToSave = true;
			// }
		// }
		// var image = Ti.UI.createImageView(a);
		// if(needsToSave === true){
			// function saveImage(e){
				// image.removeEventListener('load',saveImage);
				// savedFile.write(
					// Ti.UI.createImageView({image:image.image,width:'auto',height:'auto'}).toImage()
				// );
			// }
			// image.addEventListener('load',saveImage);
		// }
		// return image;
	// }
// };
// // example usage
// var image = Utils.RemoteImage({
	// image:'http://farm7.staticflickr.com/6059/6262552465_e53bccbd52_z.jpg',
	// defaultImage:'KS_nav_ui.png',
	// width:300,
	// height:200,
	// top:20
// });
// win.add(image);


text:
/* ------------------------------------------------------------------------------
*
*  # Media library
*
*  Specific JS code additions for gallery_library.html page
*
*  Version: 1.0
*  Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */

$(function() {

    // Table setup
    // ------------------------------

    // Setting datatable defaults
    $.extend( $.fn.dataTable.defaults, {
        autoWidth: false,
        columnDefs: [
            {
            	orderable: false,
                width: '20px',
                targets: 0
            },
            {
            	orderable: false,
                width: '100px',
                targets: 1
            },
	        {
	            orderable: false,
	            width: '90px',
	            targets: 6
	        }
        ],
        order: [[ 2, "asc" ]],
        lengthMenu: [ 25, 50, 75, 100 ],
        displayLength: 25,
        dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
        language: {
            search: 'Filter: _INPUT_',
            lengthMenu: 'Show: _MENU_',
            paginate: { 'first': 'First', 'last': 'Last', 'next': '→', 'previous': '←' }
        },
        drawCallback: function () {
            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
        },
        preDrawCallback: function() {
            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
        }
    });

    //
    // Single row selection
    //

    // Initialize table
    var media_library = $('.media-library').DataTable({
        drawCallback: function () {
            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
        },
        preDrawCallback: function() {
            $(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
        }
    });

    // Toggle success class
    $('.media-library tbody td input[type=checkbox]').on('change', function () {
        if ($(this).is(':checked')) {
        	$(this).parents('tr').addClass('success');
            $.uniform.update();
        }
        else {
        	$(this).parents('tr').removeClass('success');
            $.uniform.update();
        }
    });

    // External table additions
    // ------------------------------

    // Lightbox
    $('[data-popup="lightbox"]').fancybox({
        padding: 3
    });

    // Styles checkboxes, radios
    $('.styled').uniform({
    	radioClass: 'choice'
    });

    // Add placeholder to the datatable filter option
    $('.dataTables_filter input[type=search]').attr('placeholder','Type to filter...');

    // Enable Select2 select for the length option
    $('.dataTables_length select').select2({
        minimumResultsForSearch: Infinity,
        width: 'auto'
    });

});


text:
#ifndef _AUDIO_ACDB_H
#define _AUDIO_ACDB_H

#include <linux/msm_audio_acdb.h>
#include <sound/q6adm-v2.h>

enum {
	RX_CAL,
	TX_CAL,
	MAX_AUDPROC_TYPES
};

enum {
	VOCPROC_CAL,
	VOCSTRM_CAL,
	VOCVOL_CAL,
	MAX_VOCPROC_TYPES
};

struct acdb_cal_block {
	uint32_t		cal_size;
	uint32_t		cal_kvaddr;
	uint32_t		cal_paddr;
};

struct hw_delay_entry {
	uint32_t sample_rate;
	uint32_t delay_usec;
};

uint32_t get_voice_rx_topology(void);
uint32_t get_voice_tx_topology(void);
uint32_t get_adm_rx_topology(void);
uint32_t get_adm_tx_topology(void);
uint32_t get_asm_topology(void);
void reset_custom_topology_flags(void);
int get_adm_custom_topology(struct acdb_cal_block *cal_block);
int get_asm_custom_topology(struct acdb_cal_block *cal_block);
int get_voice_cal_allocation(struct acdb_cal_block *cal_block);
int get_lsm_cal(struct acdb_cal_block *cal_block);
int get_anc_cal(struct acdb_cal_block *cal_block);
int get_afe_cal(int32_t path, struct acdb_cal_block *cal_block);
int get_audproc_cal(int32_t path, struct acdb_cal_block *cal_block);
int get_audstrm_cal(int32_t path, struct acdb_cal_block *cal_block);
int get_audvol_cal(int32_t path, struct acdb_cal_block *cal_block);
int get_voice_col_data(uint32_t vocproc_type,
	struct acdb_cal_block *cal_block);
int get_vocproc_dev_cfg_cal(struct acdb_cal_block *cal_block);
int get_vocproc_cal(struct acdb_cal_block *cal_block);
int get_vocstrm_cal(struct acdb_cal_block *cal_block);
int get_vocvol_cal(struct acdb_cal_block *cal_block);
int get_sidetone_cal(struct sidetone_cal *cal_data);
int get_spk_protection_cfg(struct msm_spk_prot_cfg *prot_cfg);
int get_aanc_cal(struct acdb_cal_block *cal_block);
int get_hw_delay(int32_t path, struct hw_delay_entry *delay_info);

#endif


text:
//Write a LINQ query that finds the first name and last name of all students with age between 18 and 24.

namespace Students
{
    using System;
    using System.Linq;

    class AgeRange
    {
        static void Main()
        {
            //create a new Student array & fill it with students
            var studentsArr = new Student[10];
            studentsArr[0] = new Student("Peter", "Petrov", 19);
            studentsArr[1] = new Student("Asen", "Ivanov", 18);
            studentsArr[2] = new Student("Vladislav", "Ivanov", 30);
            studentsArr[3] = new Student("Apostol", "Bakalov", 21);
            studentsArr[4] = new Student("Ilina", "Konsulova", 16);
            studentsArr[5] = new Student("Valentina", "Zheliazkova", 24);
            studentsArr[6] = new Student("Stoyan", "Ganchev", 25);
            studentsArr[7] = new Student("Stoyan", "Stoyanov", 26);
            studentsArr[8] = new Student("Dimitrina", "Gospodinova", 27);
            studentsArr[9] = new Student("Antonia", "Atanasova", 21);
            Console.WriteLine("Initial Array:\r\n");
            Console.WriteLine(studentsArr.PrintStudentsArray());

            var selectByAge = studentsArr
                .Where(x => (x.Age > 17) && (x.Age < 25)).ToArray();

            Console.WriteLine("All students with age between 18 and 24\r\n");
            Console.WriteLine(selectByAge.PrintStudentsArray());

        }
    }
}


text:
/*
    jQuery Dynamic Margin
    Version 1.1
    Author: github.com/pietrofxq
*/

(function($) {

	$.fn.dynamicMargin = function(options) {

       var that = $(this);

       function destroy() {
            that.removeAttr("margin-right");
            that.removeAttr("margin-left");
            $(window).off("resize",space);
        }

       switch(options) {
           case "destroy":
               return destroy();
	    }

		var settings = $.extend({
			container: window,
            minMargin: 10,
            onResizeWindow: false,
            onResizeAndLoad:true,
            bodyReset:true,
            outerWidthElement:false,
            outerWidthContainer: false
		}, options);

		if (settings.bodyReset) {
			$("body").css({
				margin : 0,
				padding: 0
			});
		}

        var container = settings.container,
			margin = settings.minMargin;

		var space =  function() {
			var minMargin = margin,
			containerWidth = settings.outerWidthContainer? $(container).outerWidth() : $(container).width(),
			divWidth = settings.outerWidthElement ? that.outerWidth() : that.width(),
			qntSquare = Math.floor(containerWidth / (divWidth + minMargin)),
			rest = containerWidth - ((divWidth + minMargin) * qntSquare),
			marginWidth = (rest / qntSquare) + minMargin;

			console.log('container: ' + containerWidth);
			console.log('element: ' + divWidth);

            return that.each(function(){
                $(this).css({
                    "margin-left": marginWidth/2 + "px",
                    "margin-right": marginWidth/2 + "px"
                });
            });
		};

        if (settings.onResizeWindow || settings.onResizeAndLoad) {
        	if(settings.onResizeAndLoad) {
        		space();
        	}
        	$(window).resize(space)
        }

		return space();
	};

})(jQuery);


text:
import org.scalatest.{Matchers, FlatSpec}

class PalindromeProductsTest extends FlatSpec with Matchers {

  it should "find smallest palindrome from a single digit factors" in {
    val (value, factors) = PalindromeProducts(1, 9).smallest
    value should be (1)
    factors should be (Set((1, 1)))
  }

  it should "find largest palindrome from a single digit factors" in {
    val (value, factors) = PalindromeProducts(0, 9).largest
    value should be (9)
    factors should be (Set((1, 9), (3, 3)))
  }

  it should "find smallest palindrome from a double digit factors" in {
    val (value, factors) = PalindromeProducts(10, 99).smallest
    value should be (121)
    factors should be (Set((11, 11)))
  }

  it should "find largest palindrome from a double digit factors" in {
    val (value, factors) = PalindromeProducts(10, 99).largest
    value should be (9009)
    factors should be (Set((91, 99)))
  }

  it should "find smallest palindrome from a triple digit factors" in {
    val (value, factors) = PalindromeProducts(100, 999).smallest
    value should be (10201)
    factors should be (Set((101, 101)))
  }

  it should "find largest palindrome from a triple digit factors" in {
    val (value, factors) = PalindromeProducts(100, 999).largest
    value should be (906609)
    factors should be (Set((913, 993)))
  }

  it should "find smallest palindrome from a four digit factors" in {
    val (value, factors) = PalindromeProducts(1000, 9999).smallest
    value should be (1002001)
    factors should be (Set((1001, 1001)))
  }

  it should "find largest palindrome from a four digit factors" in {
    val (value, factors) = PalindromeProducts(1000, 9999).largest
    value should be (99000099)
    factors should be (Set((9901, 9999)))
  }
}