text:
// This file is distributed under the MIT license.
// See the LICENSE file for details.

#include "async/connection.h"
#include "async/connection_manager.h"

#include <cassert>
#include <exception>
#include <iostream>
#include <memory>
#include <ostream>
#include <random>
#include <thread>
#include <utility>

#include <GL/glew.h>

#undef MATH_NAMESPACE
#include <virvo/vvfileio.h>
#undef MATH_NAMESPACE
#define MATH_NAMESPACE visionaray

#include <visionaray/math/math.h>
#include <visionaray/texture/texture.h>

#include "serialization.h"

using namespace visionaray;
namespace asio = boost::asio;
using boost::asio::ip::tcp;
using sphere = basic_sphere<float>;
using volume_ref            = texture_ref<uint8_t, ElementType, 3>;
using transfer_function_ref = texture_ref<vec4, ElementType, 1>;

using namespace async;

enum MessageType
{
    MT_Unknown,
    MT_Spheres,
    MT_Colors,
};

namespace visionaray
{

//-------------------------------------------------------------------------------------------------
// Tags
//

struct voxel_space_tag {};
struct object_space_tag {};

//-------------------------------------------------------------------------------------------------
// Simple brick list
//

struct bricks
{
    vec3i count = vec3i(0, 0, 0);           // bricks per dimension
    std::vector<aabbi> voxel_space_bricks;  // coordinates range from [ 0..size)
    std::vector<aabb> object_space_bricks;  // coordinates range from [-1..1]

    aabbi get_brick(voxel_space_tag, int i, int j, int k) const
    {
        return voxel_space_bricks[index(i, j, k)];
    }

    aabb  get_brick(object_space_tag, int i, int j, int k) const
    {
        return object_space_bricks[index(i, j, k)];
    }

    int index(int i, int j, int k) const
    {
        return k * count.y * count.x + j * count.x + i;
    }
};

} // visionaray

//-------------------------------------------------------------------------------------------------
// Make bricks from volume
//

bricks make_bricks(volume_ref const& volume, vec3i const& count)
{
    bricks bs;
    bs.count = count;

    vec3i size = vec3i(volume.width(), volume.height(), volume.depth()) / count;
    vec3 osize = ( vec3(size) / vec3(volume.width(), volume.height(), volume.depth()) ) * 2.0f;

    for (int z = 0; z < count.z; ++z)
    {
        for (int y = 0; y < count.y; ++y)
        {
            for (int x = 0; x < count.x; ++x)
            {
                vec3i min( x * size.x, y * size.y, z * size.z );
                vec3i max( min.x + size.x, min.y + size.y, min.z + size.z );
                bs.voxel_space_bricks.emplace_back(min, max);

                float ox = ( x / static_cast<float>(volume.width()) ) * 2.0f - 1.0f;
                float oy = ( y / static_cast<float>(volume.height())) * 2.0f - 1.0f;
                float oz = ( z / static_cast<float>(volume.depth()) ) * 2.0f - 1.0f;

                bs.object_space_bricks.emplace_back(
                        vec3( ox, oy, oz ),
                        vec3( ox + osize.x, oy + osize.y, oz + osize.z )
                        );
            }
        }
    }

    return bs;
}

template <class Func>
static void for_each_voxel(vec3i lower, vec3i upper, Func func)
{
    vec3i p;

    for (p.z = lower.z; p.z < upper.z; ++p.z)
    {
        for (p.y = lower.y; p.y < upper.y; ++p.y)
        {
            for (p.x = lower.x; p.x < upper.x; ++p.x)
            {
                func(p);
            }
        }
    }
}

template <class Func>
static void for_each_brick(vec3i lower, vec3i upper, vec3i size, Func func)
{
    vec3i p;
    vec3i s;

    for (p.z = lower.z; p.z < upper.z; p.z += size.z)
    {
        s.z = min(size.z, upper.z - p.z);

        for (p.y = lower.y; p.y < upper.y; p.y += size.y)
        {
            s.y = min(size.y, upper.y - p.y);

            for (p.x = lower.x; p.x < upper.x; p.x += size.x)
            {
                s.x = min(size.x, upper.x - p.x);

                func(p, s);
            }
        }
    }
}

template <class Func>
static void for_each_brick_aligned(vec3i lower, vec3i upper, vec3i size, Func func)
{
    lower = size * (lower / size);

    return for_each_brick_aligned(lower, upper, size, func);
}

//-------------------------------------------------------------------------------------------------
// Estimate radius based on #samples and the extent of the sampled box
//

float get_radius(vec3 const& extent, int num_samples)
{
    auto bvolume = hmul(extent);

    return std::cbrt(
            (3.0f / 4.0f)
          * (bvolume / (num_samples * visionaray::constants::pi<float>()))
            );
}

float get_radius(aabb const& bounds, int num_samples)
{
    return get_radius(bounds.size(), num_samples);
}

//-------------------------------------------------------------------------------------------------
// Naive sampling
//

void sample_volume(
        volume_ref const& volume,
        transfer_function_ref const& tf,
        std::vector<sphere>& spheres,        // vectors will be appended to!
        std::vector<vec4>& colors,           // vectors will be appended to!
        int num_samples
        )
{
    std::random_device rd;
    std::default_random_engine e1(rd());
    std::uniform_real_distribution<float> pos_dist(0.0f, 1.0f);

    auto vol_size = vec3(volume.size());
    vol_size /= 0.5f * max_element(vol_size);

    for (int i = 0; i < num_samples; ++i)
    {
        auto sample = vec3(pos_dist(e1), pos_dist(e1), pos_dist(e1));

        sphere s;

        s.center = vol_size * sample - vol_size / 2.0f;
        s.center.y = -s.center.y;
        s.center.z = -s.center.z;

        // sample volume file
        auto raw = tex3D(volume, sample);

        // early out?
//      if (raw == 0) continue;

        s.radius = get_radius(vol_size, num_samples);
        s.prim_id = i;
        spheres.push_back(s);
        colors.push_back(tex1D(tf, raw / 255.0f));
    }
}

//-------------------------------------------------------------------------------------------------
// Stratified sampling
//

#if 0
void sample_volume_stratified(
        volume_ref const& volume,
        transfer_function_ref const& tf,
        std::vector<sphere>& spheres,        // vectors will be appended to!
        std::vector<vec4>& colors,           // vectors will be appended to!
        int num_samples
        )
{
    std::random_device rd;
    std::default_random_engine e1(rd());
    std::uniform_real_distribution<float> pos_dist(0.0f, 1.0f);

    vec3i strata(16, 16, 16);

    auto num_strata = hmul(strata);
    auto samples_per_stratum = num_samples / num_strata;

    // adjust num_samples so that samples are equally distributed among strata
    num_samples = samples_per_stratum * num_strata;

    auto vol_size = vec3(volume.size());
    vol_size /= 0.5f * max_element(vol_size);

    auto bs = make_bricks(volume, strata);

    int i = 0;
    for (int z = 0; z < bs.count.z; ++z)
    {
        for (int y = 0; y < bs.count.y; ++y)
        {
            for (int x = 0; x < bs.count.x; ++x)
            {
                auto vox = bs.get_brick(voxel_space_tag(), x, y, z);
                auto obj = bs.get_brick(object_space_tag(), x, y, z);

                for (int samp = 0; samp < samples_per_stratum; ++samp)
                {
                    sphere s;

                    vec3 rnd( pos_dist(e1), pos_dist(e1), pos_dist(e1) );

                    // map to [0..1] texel coordinates
                    auto posf = ( rnd * vec3(vox.size()) + vec3(x, y, z) * vec3(vox.size()) )
                              / vec3(volume.width() - 1, volume.height() - 1, volume.depth() - 1);

                    // sample volume
                    auto raw = tex3D(volume, posf);

                    // early out?
//                  if (raw < 10) continue;

                    // map to [-1..1] object space coordinates
                    s.center = posf * vol_size - vol_size / 2.0f;
                    s.radius = get_radius(obj.size(), samples_per_stratum);
                    s.prim_id = i++;
                    spheres.push_back(s);
                    colors.push_back(tex1D(tf, raw / 255.0f));
                }
            }
        }
    }

//    assert( i == num_samples );
}
#else
void sample_volume_stratified(
        volume_ref const& volume,
        transfer_function_ref const& tf,
        std::vector<sphere>& spheres,        // vectors will be appended to!
        std::vector<vec4>& colors,           // vectors will be appended to!
        int num_samples
        )
{
    std::random_device rd;
    std::mt19937 rng(rd());
    std::uniform_real_distribution<float> pos_dist(0.0f, 1.0f);

    vec3i vsize = vec3i(volume.size());

    // How many strata per dimension?
    vec3i strata(16, 16, 16);

    float svol = (float)hmul(strata);

    // Compute the size per stratum
#if 1
    vec3i ssize = (vsize + strata - 1) / strata;
#else
    vec3i ssize = vsize / strata;
#endif

    float bvol = (float)hmul(ssize);

    // Average number of samples per stratum
    float samples_per_stratum = num_samples / svol;

    vec3f vol_size = vec3(vsize);

    vol_size /= 0.5f * max_element(vol_size);

    int i = 0;

    // Sample each stratum
    for_each_brick({0,0,0}, vsize, ssize, [&](vec3i bp, vec3i bs)
    {
        const int samples = (int)( samples_per_stratum * (hmul(bs) / bvol) + 0.5f );

        for (int k = 0; k < samples; ++k)
        {
            vec3f sample = vec3f(pos_dist(rng), pos_dist(rng), pos_dist(rng));

            // Compute the position of the sample inside the volume
            vec3f sample_pos = vec3f(bp) + sample * vec3f(bs);

            // Map to texture coordinates in [0...1]
            vec3f p = sample_pos / vec3f(vsize - 1);

            // Sample the volume
            auto raw = tex3D(volume, p);

            // early out?
//          if (raw == 0) continue;

            sphere s;

            s.center = (p - 0.5f) * vol_size;
            s.center.y = -s.center.y;
            s.center.z = -s.center.z;
            s.radius = get_radius(2.0f * vec3f(bs) / vec3f(vsize), samples);
            s.prim_id = i++;

            spheres.push_back(s);

            colors.push_back(tex1D(tf, raw / 255.0f));
        }
    });

    std::cout << "generated " << spheres.size() << " spheres.\n";
}
#endif

//-------------------------------------------------------------------------------------------------
// Average values associated with the bricks, and a factory function
//

struct brick_data
{
    brick_data() = default;
    brick_data(float avgd)
        : avg_density(avgd)
    {
    }

    float avg_density;
};

std::vector<brick_data> make_brick_data(bricks const& bs, volume_ref const& volume)
{
    std::vector<brick_data> result;

    for (auto b : bs.voxel_space_bricks)
    {
        auto maxx = min(b.max.x, (int)volume.width());
        auto maxy = min(b.max.y, (int)volume.height());
        auto maxz = min(b.max.z, (int)volume.depth());

        float avg_density = 0;

        for (int z = b.min.z; z < maxz; ++z)
        {
            for (int y = b.min.y; y < maxy; ++y)
            {
                for (int x = b.min.x; x < maxx; ++x)
                {
                    avg_density += volume(x, y, z);// / 255.0f;
                }
            }
        }

        auto bounds = aabbi(b.min, vec3i(maxx, maxy, maxz));

        avg_density /= visionaray::volume(bounds);

        result.emplace_back(avg_density);
    }

    return result;
}

//-------------------------------------------------------------------------------------------------
// A binary XXX-partitioning tree (maybe kd-tree, maybe BVH)
//

struct tree_node
{
    aabbi                       bounds;
    std::shared_ptr<tree_node>  child_left          = nullptr;
    std::shared_ptr<tree_node>  child_right         = nullptr;

    vec3i                       first_brick_index;
    vec3i                       num_bricks;
};

//-------------------------------------------------------------------------------------------------
// Calc stats based on bricks contained in bounds
//

struct stats
{
    float expected_value;
    float variance;
    float std_deviation;
    float rel_deviation;
    vec3i center_of_mass;
};

stats statistics(
        aabbi const& bounds,
        bricks const& bs,
        std::vector<brick_data> const& bd
        )
{
    stats result;

    result.variance = 0;

    float total_density = 0.0f;
    int contained = 0;

    // calc center of mass, total and avg density

    vec3 com(0.0);

    for (size_t i = 0; i < bs.voxel_space_bricks.size(); ++i)
    {
        auto b = bs.voxel_space_bricks[i];
        if (!bounds.contains(b))
        {
            continue;
        }

        com += vec3(b.min) * bd[i].avg_density;
        total_density += bd[i].avg_density;

        ++contained;
    }

    assert( contained > 0 );

    result.expected_value = total_density / contained;
    result.center_of_mass = vec3i(com / total_density);

    // calc variance and count outliers

    for (size_t i = 0; i < bs.voxel_space_bricks.size(); ++i)
    {
        auto b = bs.voxel_space_bricks[i];
        if (!bounds.contains(b))
        {
            continue;
        }

        auto tmp = bd[i].avg_density - result.expected_value;
        result.variance += tmp * tmp;
    }

    result.variance /= contained;
    result.std_deviation = sqrt(result.variance);
    result.rel_deviation = (result.variance == 0 || result.expected_value == 0)
            ? 0
            : result.std_deviation / result.expected_value;

    return result;
}

//-------------------------------------------------------------------------------------------------
// Recursively construct the tree
//

void split(tree_node* node, bricks const& bs, std::vector<brick_data> const& bd)
{
    // use binning to find split plane

    float threshold         = 0.05f;
    int best_pos            = 0;
    int best_axis           = -1;
    auto brick_size         = bs.voxel_space_bricks[0].size();

    auto s = statistics(node->bounds, bs, bd);

    best_axis = (int)max_index(node->bounds.size());

    if (s.rel_deviation > threshold && node->num_bricks[best_axis] > 4)
    {
        // best pos for median split
        best_pos = s.center_of_mass[best_axis];

        if (best_pos == node->bounds.min[best_axis])
        {
            ++best_pos;
        }

        node->child_left  = std::make_shared<tree_node>();
        node->child_right = std::make_shared<tree_node>();

        assert( best_axis > -1 && best_axis < 3 );

        node->child_left->first_brick_index  = node->first_brick_index;
        node->child_right->first_brick_index = node->first_brick_index;
        node->child_right->first_brick_index[best_axis] = best_pos / brick_size[best_axis];

        node->child_left->num_bricks  = node->num_bricks;
        node->child_left->num_bricks[best_axis] = best_pos / brick_size[best_axis] - node->child_left->first_brick_index[best_axis];

        node->child_right->num_bricks = node->num_bricks;
        node->child_right->num_bricks[best_axis] = node->num_bricks[best_axis] - node->child_left->num_bricks[best_axis];

        node->child_left->bounds = node->bounds;
        node->child_left->bounds.max[best_axis] = best_pos;

        node->child_right->bounds = node->bounds;
        node->child_right->bounds.min[best_axis] = best_pos;

        split(node->child_left.get(),  bs, bd);
        split(node->child_right.get(), bs, bd);
    }
}

//-------------------------------------------------------------------------------------------------
// Traverse leaves and count them
//

void traverse_and_count_leaves(tree_node* node, int& count)
{
    if ( node->child_left == nullptr && node->child_right == nullptr )
    {
        ++count;
    }
    else
    {
        traverse_and_count_leaves( node->child_left.get(), count );
        traverse_and_count_leaves( node->child_right.get(), count );
    }
}

//-------------------------------------------------------------------------------------------------
// Traverse leaves and sample
//

template <typename RandomEngine, typename Distribution01>
void traverse_and_sample_leaves(
        tree_node* node,
        volume_ref const& volume,
        transfer_function_ref const& tf,
        std::vector<sphere>& spheres,
        std::vector<vec4>& colors,
        RandomEngine& engine,
        Distribution01& dist,
        int& prim_id,
        int samples_per_leaf
        )
{
    if ( node->child_left == nullptr && node->child_right == nullptr )
    {
        auto vol_size = vec3(volume.size());
        vol_size /= 0.5f * max_element(vol_size);

        // transform vox -> obj

        auto vox = node->bounds;

        float ox    = ( vox.min.x / static_cast<float>(volume.width()) ) * vol_size.x - vol_size.x / 2.0f;
        float oy    = ( vox.min.y / static_cast<float>(volume.height())) * vol_size.y - vol_size.y / 2.0f;
        float oz    = ( vox.min.z / static_cast<float>(volume.depth()) ) * vol_size.z - vol_size.z / 2.0f;

        vec3 osize  = ( vec3(vox.size()) / vec3(volume.width(), volume.height(), volume.depth()) ) * 2.0f;

        aabb obj( vec3(ox, oy, oz), vec3(ox + osize.x, oy + osize.y, oz + osize.z) );

//      samples_per_leaf = min(samples_per_leaf, (int)visionaray::volume(node->bounds));

        for (int samp = 0; samp < samples_per_leaf; ++samp)
        {
            vec3 rnd( dist(engine), dist(engine), dist(engine) );

            // map to [0..1] texel coordinates
            auto posf = ( rnd * vec3(vox.size()) + vec3(vox.min) )
                      / vec3(volume.width() - 1, volume.height() - 1, volume.depth() - 1);

            // sample volume
            auto raw = tex3D(volume, posf);

            // early out?
//          if (raw == 0) continue;

            sphere s;
            s.center = posf * vol_size - vol_size / 2.0f;
            s.center.y = -s.center.y;
            s.center.z = -s.center.z;
            s.radius = get_radius(obj.size(), samples_per_leaf);
            s.prim_id = prim_id++;
            spheres.push_back(s);
            colors.push_back(tex1D(tf, raw / 255.0f));
        }
    }
    else
    {
        traverse_and_sample_leaves(
                node->child_left.get(),
                volume,
                tf,
                spheres,
                colors,
                engine,
                dist,
                prim_id,
                samples_per_leaf
                );

        traverse_and_sample_leaves(
                node->child_right.get(),
                volume,
                tf,
                spheres,
                colors,
                engine,
                dist,
                prim_id,
                samples_per_leaf
                );
    }
}

//-------------------------------------------------------------------------------------------------
// Importance sampling (dispatch)
//

void sample_volume_importance(
        volume_ref const& volume,
        transfer_function_ref const& tf,
        std::vector<sphere>& spheres,        // vectors will be appended to!
        std::vector<vec4>& colors,           // vectors will be appended to!
        int num_samples
        )
{
    vec3i num_bricks(64, 64, 64);
    auto bs = make_bricks(volume, num_bricks);
    auto bd = make_brick_data(bs, volume);

    tree_node root;
    root.bounds = aabbi(
            vec3i(0, 0, 0),
            vec3i(volume.width(), volume.height(), volume.depth())
            );

    root.first_brick_index = vec3i(0, 0, 0);
    root.num_bricks = bs.count;

    split(&root, bs, bd);

    int count = 0;
    traverse_and_count_leaves(
            &root,
            count
            );

    std::random_device rd;
    std::default_random_engine engine(rd());
    std::uniform_real_distribution<float> dist(0.0f, 1.0f);

    int prim_id = 0;
    auto samples_per_leaf = num_samples / count;

    traverse_and_sample_leaves(
            &root,
            volume,
            tf,
            spheres,
            colors,
            engine,
            dist,
            prim_id,
            samples_per_leaf
            );
}

//-------------------------------------------------------------------------------------------------
// TCP server
//

template <typename Buffer>
class server
{
public:

    explicit server(unsigned short port = 31050)
        : manager(makeConnectionManager(port))
    {
    }

    void accept()
    {
        std::cout << "server: accepting...\n";

        manager->accept(boost::bind(&server::handle_new_connection, this, _1, _2));
    }

    void run()
    {
        manager->run_in_thread();
    }

    void wait()
    {
        manager->wait();
    }

    void handle_message(Connection::Reason reason, MessagePointer message, boost::system::error_code const& e)
    {
        if (e)
        {
            std::cout << "server: error: " << e.message() << "\n";

            manager->stop();
            return;
        }

        if (reason == Connection::Read)
        {
            // Read complete.
            // Got a message from the client.
            //
            // Nothing to do yet.
        }
        else
        {
            // Write complete.
            // Reload and send data again...

            // Order of messages is MT_Spheres, MT_Colors.

            if (message->type() == MT_Spheres)
            {
                std::cout << "server: sent spheres...\n";

                return;
            }

            if (message->type() == MT_Colors)
            {
                std::cout << "server: sent colors...\n";

                // Blocking :-(
                send_data();
                return;
            }
        }
    }

    bool handle_new_connection(ConnectionPointer connection, boost::system::error_code const& e)
    {
        if (e)
        {
            std::cout << "server: could not connect to client: " << e.message() << "\n";
            return false;
        }

        std::cout << "server: connected.\n";

        // Accept and save this connection
        // and set the message handler of the connection.
        conn = connection;
        conn->set_handler(boost::bind(&server::handle_message, this, _1, _2, _3));

        // Get ready to rumble...
        // Blocking :-(
        send_data();

        return true;
    }

    void set_payload(Buffer const& spheres, Buffer const& colors)
    {
        spheres_ = spheres;
        colors_  = colors;
    }

    void send_data()
    {
        std::cout << "server: loading data...\n";

        load_data();

        std::cout << "server: loading data... done.\n";

        std::cout << "server: sending data...\n";

        write_spheres();
        write_colors();
    }

private:

    bool connected()
    {
        return (bool)conn;
    }

    void write_spheres()
    {
        conn->write(MT_Spheres, spheres_);
    }

    void write_colors()
    {
        conn->write(MT_Colors, colors_);
    }

    bool load_data()
    {
        // load virvo file

        auto filename = "/Users/stefan/visionaray/build/sim3.xvf"; // adapt to your needs

        std::shared_ptr<vvVolDesc> vd = std::make_shared<vvVolDesc>(filename);

        vvFileIO fio;

        std::cout << "    loading data...\n";

        fio.loadVolumeData(vd.get());

        // Set default color scheme if no TF present:
        if (vd->tf[0].isEmpty())
        {
            vd->tf[0].setDefaultAlpha(0, 0.0, 1.0);
            vd->tf[0].setDefaultColors((vd->chan==1) ? 0 : 2, 0.0, 1.0);
        }

        size_t lut_entries = 256;

        std::vector<vec4> tf(lut_entries);

        vd->computeTFTexture(lut_entries, 1, 1, reinterpret_cast<float*>(tf.data()));

        std::cout << "    computing tf texture...\n";

        // convert volume and tf to visionaray texture_refs

        volume_ref vol_tex(vd->vox[0], vd->vox[1], vd->vox[2]);

        vol_tex.set_data(vd->getRaw(0/*frame_num++ % vd->frames*/));
        vol_tex.set_filter_mode(Linear);
        vol_tex.set_address_mode(Clamp);

        transfer_function_ref tf_tex(lut_entries);

        tf_tex.set_data(tf.data());
        tf_tex.set_filter_mode(Linear);
        tf_tex.set_address_mode(Clamp);

        // sample

        std::cout << "    sampling data...\n";

        std::vector<sphere> spheres;
        std::vector<vec4> colors;

        sample_volume_importance(vol_tex, tf_tex, spheres, colors, 100000);

        splatrend::serialize(spheres_, spheres);
        splatrend::serialize(colors_, colors);

        return true;
    }

    ConnectionManagerPointer manager;
    ConnectionPointer conn;

    Buffer spheres_;
    Buffer colors_;

    int frame_num = 0;

};

int main(int argc, char** argv)
{
    try
    {
        server<std::vector<char>> srv;

        srv.accept();
        srv.run();
        srv.wait();

        std::cout << "DONE\n";
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << '\n';
    }
}


text:
package my.dossier;

import java.util.*;
import java.io.*;

public class Player
{
    private final String firstName;
    private final String lastName;
    private final String username;
    private String password;
    private String team;
    private final int ID;
    private static int currID = 0;
    public ArrayList<Question> qList = new ArrayList<Question>();

    public Player(int myID){
        ID = myID;
        firstName = "";
        lastName = "";
        username = "";
        password = "";
        team = "";
    }

    public Player(String myFirstName, String myLastName, String myTeam)
    {
        firstName = myFirstName.toLowerCase();
        lastName = myLastName.toLowerCase();
        username = firstName.substring(0, 1) + lastName;
        password = "password";
        if(currID == 0){
            String thisLine = null;
            String readID = "";
            String file = "Data/PlayerData.txt";
            try{
                BufferedReader br = new BufferedReader(new FileReader(file));
                while((thisLine = br.readLine()) != null){
                    readID = thisLine.substring(0, thisLine.indexOf(" "));
                }
                currID = Integer.parseInt(readID);
            }
            catch(IOException e){
                e.printStackTrace();
            }
        }
        currID++;
        ID = currID;
        team = myTeam.toLowerCase();
    }

    public Player(String myFirstName, String myLastName, String myPassword, int myID, String myTeam)
    {
        firstName = myFirstName;
        lastName = myLastName;
        username = firstName.substring(0, 1) + lastName;
        password = myPassword;
        ID = myID;
        team = myTeam;
    }

    public String getFirstName()
    {
        return firstName;
    }

     public String getLastName()
    {
        return lastName;
    }

    public String getUsername()
    {
        return username;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String newPass){
        password = newPass.toLowerCase();
    }

    public int getID(){
        return ID;
    }

    public String getTeam(){
        return team;
    }

    public void setTeam(String newTeam){
        team = newTeam.toLowerCase();
    }

    public void addQuestion(Question q){
        qList.add(q);
    }

    //Print player data onto text file
    public String print(){
        String questions = "";
        for(Question q : qList){
            questions += q.printForPlayer();
        }
        return getID() + " " + getUsername() + " " + getPassword() + " " + getTeam() + " " + getFirstName() + " " + getLastName() + " questions:" + questions;
    }

    public String printPerformance(){
        String s = "";
        ArrayList<String> categories = new ArrayList<String>();
        for(Question q : qList){
            if(categories.isEmpty()){
                categories.add(q.getCategory());
                continue;
            }
            for(int i = 0; i < categories.size(); i++){
                String c = categories.get(i);
                if(!q.getCategory().equals(c.toLowerCase())){
                    categories.add(q.getCategory());
                }
            }
        }
        int[] part = new int[categories.size()];
        for(int p : part){
            p = 0;
        }
        int[] whole = new int[categories.size()];
        for(int w : whole){
            w = 0;
        }
        for(Question q : qList){
            if(q.getEvaluation().equals("u")){
                break;
            }
            int index = -2;
            for(String c : categories){
                if(c.toLowerCase().equals(q.getCategory().toLowerCase())){
                    index = categories.indexOf(c);
                }
            }
            if(index >= 0){
                whole[index] = whole[index] + 1;
                if(q.getEvaluation().equals("c")){
                    part[index]++;
                }
            }
        }
        int a = 0;
        for(String c : categories){
            s += (c + ": " + part[a] + "/" + whole[a] + "\n");
            a++;
        }
        return s;

    }
}

redpajama_set_name: RedPajamaGithub


text:
#ifndef SLEEPMGR_H
#define SLEEPMGR_H

#include <compiler.h>
#include <parts.h>

#if (SAM3S || SAM3U || SAM3N || SAM3XA || SAM4S || SAM4E)
# include "sam/sleepmgr.h"
#elif XMEGA
# include "xmega/sleepmgr.h"
#elif UC3
# include "uc3/sleepmgr.h"
#elif SAM4L
# include "sam4l/sleepmgr.h"
#else
# error Unsupported device.
#endif

/**
 * \defgroup sleepmgr_group Sleep manager
 *
 * The sleep manager is a service for ensuring that the device is not put to
 * sleep in deeper sleep modes than the system (e.g., peripheral drivers,
 * services or the application) allows at any given time.
 *
 * It is based on the use of lock counting for the individual sleep modes, and
 * will put the device to sleep in the shallowest sleep mode that has a non-zero
 * lock count. The drivers/services/application can change these counts by use
 * of \ref sleepmgr_lock_mode and \ref sleepmgr_unlock_mode.
 * Refer to \ref sleepmgr_mode for a list of the sleep modes available for
 * locking, and the device datasheet for information on their effect.
 *
 * The application must supply the file \ref conf_sleepmgr.h.
 *
 * For the sleep manager to be enabled, the symbol \ref CONFIG_SLEEPMGR_ENABLE
 * must be defined, e.g., in \ref conf_sleepmgr.h. If this symbol is not
 * defined, the functions are replaced with dummy functions and no RAM is used.
 *
 * @{
 */

/**
 * \def CONFIG_SLEEPMGR_ENABLE
 * \brief Configuration symbol for enabling the sleep manager
 *
 * If this symbol is not defined, the functions of this service are replaced
 * with dummy functions. This is useful for reducing code size and execution
 * time if the sleep manager is not needed in the application.
 *
 * This symbol may be defined in \ref conf_sleepmgr.h.
 */
#if defined(__DOXYGEN__) && !defined(CONFIG_SLEEPMGR_ENABLE)
#  define CONFIG_SLEEPMGR_ENABLE
#endif

/**
 * \enum sleepmgr_mode
 * \brief Sleep mode locks
 *
 * Identifiers for the different sleep mode locks.
 */

/**
 * \brief Initialize the lock counts
 *
 * Sets all lock counts to 0, except the very last one, which is set to 1. This
 * is done to simplify the algorithm for finding the deepest allowable sleep
 * mode in \ref sleepmgr_enter_sleep.
 */
static inline void sleepmgr_init(void)
{
#ifdef CONFIG_SLEEPMGR_ENABLE
	uint8_t i;

	for (i = 0; i < SLEEPMGR_NR_OF_MODES - 1; i++) {
		sleepmgr_locks[i] = 0;
	}
	sleepmgr_locks[SLEEPMGR_NR_OF_MODES - 1] = 1;
#endif /* CONFIG_SLEEPMGR_ENABLE */
}

/**
 * \brief Increase lock count for a sleep mode
 *
 * Increases the lock count for \a mode to ensure that the sleep manager does
 * not put the device to sleep in the deeper sleep modes.
 *
 * \param mode Sleep mode to lock.
 */
static inline void sleepmgr_lock_mode(enum sleepmgr_mode mode)
{
#ifdef CONFIG_SLEEPMGR_ENABLE
	irqflags_t flags;

	Assert(sleepmgr_locks[mode] < 0xff);

	// Enter a critical section
	flags = cpu_irq_save();

	++sleepmgr_locks[mode];

	// Leave the critical section
	cpu_irq_restore(flags);
#else
	UNUSED(mode);
#endif /* CONFIG_SLEEPMGR_ENABLE */
}

/**
 * \brief Decrease lock count for a sleep mode
 *
 * Decreases the lock count for \a mode. If the lock count reaches 0, the sleep
 * manager can put the device to sleep in the deeper sleep modes.
 *
 * \param mode Sleep mode to unlock.
 */
static inline void sleepmgr_unlock_mode(enum sleepmgr_mode mode)
{
#ifdef CONFIG_SLEEPMGR_ENABLE
	irqflags_t flags;

	Assert(sleepmgr_locks[mode]);

	// Enter a critical section
	flags = cpu_irq_save();

	--sleepmgr_locks[mode];

	// Leave the critical section
	cpu_irq_restore(flags);
#else
	UNUSED(mode);
#endif /* CONFIG_SLEEPMGR_ENABLE */
}

 /**
 * \brief Retrieves the deepest allowable sleep mode
 *
 * Searches through the sleep mode lock counts, starting at the shallowest sleep
 * mode, until the first non-zero lock count is found. The deepest allowable
 * sleep mode is then returned.
 */
static inline enum sleepmgr_mode sleepmgr_get_sleep_mode(void)
{
	enum sleepmgr_mode sleep_mode = SLEEPMGR_ACTIVE;

#ifdef CONFIG_SLEEPMGR_ENABLE
	uint8_t *lock_ptr = sleepmgr_locks;

	// Find first non-zero lock count, starting with the shallowest modes.
	while (!(*lock_ptr)) {
		lock_ptr++;
		sleep_mode++;
	}

	// Catch the case where one too many sleepmgr_unlock_mode() call has been
	// performed on the deepest sleep mode.
	Assert((uintptr_t)(lock_ptr - sleepmgr_locks) < SLEEPMGR_NR_OF_MODES);

#endif /* CONFIG_SLEEPMGR_ENABLE */

	return sleep_mode;
}

/**
 * \fn sleepmgr_enter_sleep
 * \brief Go to sleep in the deepest allowed mode
 *
 * Searches through the sleep mode lock counts, starting at the shallowest sleep
 * mode, until the first non-zero lock count is found. The device is then put to
 * sleep in the sleep mode that corresponds to the lock.
 *
 * \note This function enables interrupts before going to sleep, and will leave
 * them enabled upon return. This also applies if sleep is skipped due to ACTIVE
 * mode being locked.
 */

static inline void sleepmgr_enter_sleep(void)
{
#ifdef CONFIG_SLEEPMGR_ENABLE
	enum sleepmgr_mode sleep_mode;

	cpu_irq_disable();

	// Find the deepest allowable sleep mode
	sleep_mode = sleepmgr_get_sleep_mode();
	// Return right away if first mode (ACTIVE) is locked.
	if (sleep_mode==SLEEPMGR_ACTIVE) {
		cpu_irq_enable();
		return;
	}
	// Enter the deepest allowable sleep mode with interrupts enabled
	sleepmgr_sleep(sleep_mode);
#else
	cpu_irq_enable();
#endif /* CONFIG_SLEEPMGR_ENABLE */
}

//! @}

#endif /* SLEEPMGR_H */


text:
package com.payler.paylergateapi.lib.model.request;

public class RepeatPayRequest extends GateRequest {

    private String key;

    private String orderId;

    private Long amount;

    private String recurrentTemplateId;

    public RepeatPayRequest setKey(String key) {
        this.key = key;
        return this;
    }

    public RepeatPayRequest setOrderId(String orderId) {
        this.orderId = orderId;
        return this;
    }

    public RepeatPayRequest setAmount(Long amount) {
        this.amount = amount;
        return this;
    }

    public RepeatPayRequest setRecurrentTemplateId(String recurrentTemplateId) {
        this.recurrentTemplateId = recurrentTemplateId;
        return this;
    }
}


text:
@implementation Accelerometer

@dynamic x;
@dynamic y;
@dynamic z;
@dynamic timesTamp;

- (void)setDataWithDict:(NSDictionary*)dict {
    self.x     = [dict objectForKey:kX];
    self.y     = [dict objectForKey:kY];
    self.z     = [dict objectForKey:kZ];
    self.timesTamp = [dict objectForKey:kTimesTamp];
}

- (NSDictionary*)getDictionary {
    NSDictionary* dict = @{kX:self.x,
                           kY:self.y,
                           kZ:self.z,
                           kTimesTamp:self.timesTamp};
    return dict;
}

@end


text:
class ship {

  public:
    ship(uint32_t _id) : ID(_id) {}
    uint32_t getID(void) { return ID; }
    double getAttack(void) const { return attack_strength; }
    double getDefense(void) const { return defense_strength; }
    double getMass(void) const { return mass; }
    double getThrust(void) const { return thrust; }
    bool getIsTransport(void) const { return is_transport; }
    bool getIsCommand(void) const { return is_command; }
    virtual void printDescription(void) = 0;

  private:
    uint32_t ID;
    double attack_strength;
    double defense_strength;
    double mass;
    double thrust;
    bool is_transport;
    bool is_command;
};

class scout : public ship {
  public:
    scout(uint32_t _id) : ship(_id) {}
    void printDescription(void) {
      std::cout << "This is a scout ship." << std::endl;
    }
};

class warship : public ship {
  public:
    warship(uint32_t _id) : ship(_id) {}
    void printDescription(void) {
      std::cout << "This is a warship." << std::endl;
    }
};

class defender : public ship {
  public:
    defender(uint32_t _id) : ship(_id) {}
    void printDescription(void) {
      std::cout << "This is a defender ship." << std::endl;
    }
};

class command : public ship {
  public:
    command(uint32_t _id) : ship(_id) {}
    void printDescription(void) {
      std::cout << "This is a command ship." << std::endl;
    }
};

class transport : public ship {
  public:
    transport(uint32_t _id) : ship(_id) {}
    void printDescription(void) {
      std::cout << "This is a transport ship." << std::endl;
    }
};

#endif


text:
/*
 * ResumePage Messages
 *
 * This contains all the text for the ResumePage component.
 */
import { defineMessages } from 'react-intl';

export default defineMessages({
  header: {
    id: 'boilerplate.containers.Contact.header',
    defaultMessage: 'Contact Information',
  },
  linkedIn:{
    id: 'boilerplate.containers.contact.linkedIn',
    defaultMessage: 'Find me on LinkedIn: '
  },
  github:{
    id: 'boilerplate.containers.contact.github',
    defaultMessage: 'Or Github: '
  },
  email:{
    id: 'boilerplate.containers.contact.email',
    defaultMessage: 'Or Email Me: matt@matthewhoule.com'
  }
});


text:
#import "NSObject.h"

@class DVTMutableOrderedSet, NSSet;

@interface IBSelectionOwner : NSObject
{
    DVTMutableOrderedSet *selection;
    DVTMutableOrderedSet *cachedSelectionCopy;
    BOOL delegateImplementsWillSelect;
    BOOL delegateImplementsDidSelect;
    id <IBSelectionOwnerDelegate> _delegate;
}

+ (BOOL)eventWouldToggleSelection:(id)arg1;
+ (BOOL)eventWouldExtendSelection:(id)arg1;
@property __weak id <IBSelectionOwnerDelegate> delegate; // @synthesize delegate=_delegate;
- (void).cxx_destruct;
- (id)firstSelectedObject;
- (id)lastSelectedObject;
@property(readonly) NSSet *selection;
@property(readonly) long long numberOfSelectedObjects;
- (void)clearSelection;
- (void)deselectObject:(id)arg1;
- (void)deselectObjects:(id)arg1;
- (void)selectObject:(id)arg1 withEvent:(id)arg2;
- (void)selectObject:(id)arg1 byExtending:(BOOL)arg2 andToggling:(BOOL)arg3;
- (void)selectObjects:(id)arg1 withEvent:(id)arg2;
- (void)setSelectedObjects:(id)arg1;
- (void)setSelectedObject:(id)arg1;
- (void)updateSelectionWithArrowMovement:(id)arg1 canidateLists:(id)arg2 andAnchor:(id *)arg3;
- (void)updateSelectionWithBandIntersectingObjects:(id)arg1 withEvent:(id)arg2 initialSelection:(id)arg3;
- (void)selectObjects:(id)arg1 byExtending:(BOOL)arg2 andToggling:(BOOL)arg3;
- (void)primitiveUpdateSelection:(id)arg1;
- (void)didSelect:(id)arg1 andDeselect:(id)arg2;
- (void)willSelect:(id)arg1 andDeselect:(id)arg2;
- (BOOL)selectionContainsObject:(id)arg1;
- (id)init;
- (id)initWithDelegate:(id)arg1;

@end


text:
using base::win::RegKey;

namespace google_update {

namespace {

const int kGoogleUpdateTimeoutMs = 20 * 1000;

const char kEnvVariableUntrustedData[] = "GoogleUpdateUntrustedData";
const int kEnvVariableUntrustedDataMaxLength = 4096;

// Returns true if Google Update is present at the given level.
bool IsGoogleUpdatePresent(bool system_install) {
  // Using the existence of version key in the registry to decide.
  return GoogleUpdateSettings::GetGoogleUpdateVersion(system_install).IsValid();
}

// Returns GoogleUpdateSetup.exe's executable path at specified level.
// or an empty path if none is found.
base::FilePath GetGoogleUpdateSetupExe(bool system_install) {
  const HKEY root_key = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER;
  RegKey update_key;

  if (update_key.Open(root_key, kRegPathGoogleUpdate, KEY_QUERY_VALUE) ==
          ERROR_SUCCESS) {
    string16 path_str;
    string16 version_str;
    if ((update_key.ReadValue(kRegPathField, &path_str) == ERROR_SUCCESS) &&
        (update_key.ReadValue(kRegGoogleUpdateVersion, &version_str) ==
             ERROR_SUCCESS)) {
      return base::FilePath(path_str).DirName().Append(version_str).
          Append(kGoogleUpdateSetupExe);
    }
  }
  return base::FilePath();
}

// If Google Update is present at system-level, sets |cmd_string| to the command
// line to install Google Update at user-level and returns true.
// Otherwise, clears |cmd_string| and returns false.
bool GetUserLevelGoogleUpdateInstallCommandLine(string16* cmd_string) {
  cmd_string->clear();
  base::FilePath google_update_setup(
      GetGoogleUpdateSetupExe(true));  // system-level.
  if (!google_update_setup.empty()) {
    CommandLine cmd(google_update_setup);
    // Appends "/install runtime=true&needsadmin=false /silent /nomitag".
    // NB: /nomitag needs to be at the end.
    // Constants are found in code.google.com/p/omaha/common/const_cmd_line.h.
    cmd.AppendArg("/install");
    // The "&" can be used in base::LaunchProcess() without quotation
    // (this is problematic only if run from command prompt).
    cmd.AppendArg("runtime=true&needsadmin=false");
    cmd.AppendArg("/silent");
    cmd.AppendArg("/nomitag");
    *cmd_string = cmd.GetCommandLineString();
  }
  return !cmd_string->empty();
}

// Launches command |cmd_string|, and waits for |timeout| milliseconds before
// timing out.  To wait indefinitely, one can set
// |timeout| to be base::TimeDelta::FromMilliseconds(INFINITE).
// Returns true if this executes successfully.
// Returns false if command execution fails to execute, or times out.
bool LaunchProcessAndWaitWithTimeout(const string16& cmd_string,
                                     base::TimeDelta timeout) {
  bool success = false;
  base::win::ScopedHandle process;
  int exit_code = 0;
  LOG(INFO) << "Launching: " << cmd_string;
  if (!base::LaunchProcess(cmd_string, base::LaunchOptions(),
                           process.Receive())) {
    PLOG(ERROR) << "Failed to launch (" << cmd_string << ")";
  } else if (!base::WaitForExitCodeWithTimeout(process, &exit_code, timeout)) {
    // The GetExitCodeProcess failed or timed-out.
    LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than "
               << timeout.InMilliseconds() << " milliseconds to complete.";
  } else if (exit_code != 0) {
    LOG(ERROR) << "Command (" << cmd_string << ") exited with code "
               << exit_code;
  } else {
    success = true;
  }
  return success;
}

bool IsNotPrintable(unsigned char c) {
  return c < 32 || c >= 127;
}

// Returns whether or not |s| consists of printable characters.
bool IsStringPrintable(const std::string& s) {
  return std::find_if(s.begin(), s.end(), IsNotPrintable) == s.end();
}

bool IsIllegalUntrustedDataKeyChar(unsigned char c) {
  return !(c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' ||
           c >= '0' && c <= '9' || c == '-' || c == '_' || c == '$');
}

// Returns true if |key| from untrusted data is valid.
bool IsUntrustedDataKeyValid(const std::string& key) {
  return std::find_if(key.begin(), key.end(), IsIllegalUntrustedDataKeyChar)
      == key.end();
}

// Reads and parses untrusted data passed from Google Update as key-value
// pairs, then overwrites |untrusted_data_map| with the result.
// Returns true if data are successfully read.
bool GetGoogleUpdateUntrustedData(
    std::map<std::string, std::string>* untrusted_data) {
  DCHECK(untrusted_data);
  scoped_ptr<base::Environment> env(base::Environment::Create());
  std::string data_string;
  if (env == NULL || !env->GetVar(kEnvVariableUntrustedData, &data_string))
    return false;

  if (data_string.length() > kEnvVariableUntrustedDataMaxLength ||
      !IsStringPrintable(data_string)) {
    LOG(ERROR) << "Invalid value in " << kEnvVariableUntrustedData;
    return false;
  }

  VLOG(1) << kEnvVariableUntrustedData << ": " << data_string;

  std::vector<std::pair<std::string, std::string> > kv_pairs;
  if (!base::SplitStringIntoKeyValuePairs(data_string, '=', '&', &kv_pairs)) {
    LOG(ERROR) << "Failed to parse untrusted data: " << data_string;
    return false;
  }

  untrusted_data->clear();
  std::vector<std::pair<std::string, std::string> >::const_iterator it;
  for (it = kv_pairs.begin(); it != kv_pairs.end(); ++it) {
    const std::string& key(it->first);
    // TODO(huangs): URL unescape |value|.
    const std::string& value(it->second);
    if (IsUntrustedDataKeyValid(key) && IsStringPrintable(value))
      (*untrusted_data)[key] = value;
    else
      LOG(ERROR) << "Illegal character found in untrusted data.";
  }
  return true;
}

}  // namespace

bool EnsureUserLevelGoogleUpdatePresent() {
  LOG(INFO) << "Ensuring Google Update is present at user-level.";

  bool success = false;
  if (IsGoogleUpdatePresent(false)) {
    success = true;
  } else {
    string16 cmd_string;
    if (!GetUserLevelGoogleUpdateInstallCommandLine(&cmd_string)) {
      LOG(ERROR) << "Cannot find Google Update at system-level.";
      // Ideally we should return false. However, this case should not be
      // encountered by regular users, and developers (who often installs
      // Chrome without Google Update) may be unduly impeded by this case.
      // Therefore we return true.
      success = true;
    } else {
      success = LaunchProcessAndWaitWithTimeout(cmd_string,
          base::TimeDelta::FromMilliseconds(INFINITE));
    }
  }
  return success;
}

bool UninstallGoogleUpdate(bool system_install) {
  bool success = false;
  string16 cmd_string(
      GoogleUpdateSettings::GetUninstallCommandLine(system_install));
  if (cmd_string.empty()) {
    success = true;  // Nothing to; vacuous success.
  } else {
    success = LaunchProcessAndWaitWithTimeout(cmd_string,
        base::TimeDelta::FromMilliseconds(kGoogleUpdateTimeoutMs));
  }
  return success;
}

std::string GetUntrustedDataValue(const std::string& key) {
  std::map<std::string, std::string> untrusted_data;
  if (GetGoogleUpdateUntrustedData(&untrusted_data)) {
    std::map<std::string, std::string>::const_iterator data_it(
        untrusted_data.find(key));
    if (data_it != untrusted_data.end())
      return data_it->second;
  }

  return std::string();
}

}  // namespace google_update


text:
  <title>Test directory for export</title>

All platform docs

All installed documentation

All platform java API docs

All installed API documentation


text:
<!DOCTYPE html>
<html>
<head>
    <base href="/">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Closure loader example app</title>
    <meta name="viewport" content="width=device-width">
    {% for (var chunk in o.htmlWebpackPlugin.files.chunks) { %}
    <script src="{%=o.htmlWebpackPlugin.files.chunks[chunk].entry %}"></script>{% } %}
</head>
<body>
    Example app
</body>
</html>


text: System for tracking probationers


text:
#ifndef __car_model_sfun_h__
#define __car_model_sfun_h__

/* Include files */
#define S_FUNCTION_NAME                sf_sfun
#include "sfc_sf.h"
#include "sfc_mex.h"
#include "rtwtypes.h"
#include "sfcdebug.h"
#define rtInf                          (mxGetInf())
#define rtMinusInf                     (-(mxGetInf()))
#define rtNaN                          (mxGetNaN())
#define rtIsNaN(X)                     ((int)mxIsNaN(X))
#define rtIsInf(X)                     ((int)mxIsInf(X))

/* Type Definitions */

/* Named Constants */
#define CALL_EVENT                     (-1)

/* Variable Declarations */
extern int32_T _sfEvent_;
extern uint32_T _car_modelMachineNumber_;
extern real_T _sfTime_;

/* Variable Definitions */

/* Function Declarations */
extern void car_model_initializer(void);
extern void car_model_terminator(void);

/* Function Definitions */
#endif


text:
<?xml version="1.0" ?><!DOCTYPE TS><TS language="cs_CZ" version="2.1">
<context>
    <name>AboutPage</name>
    <message>
        <source>Change toolbar</source>
        <translation type="vanished">Změnit nabídku</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="28"/>
        <source>Draw freehand line</source>
        <translation>Kreslení od ruky</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="29"/>
        <source>Eraser</source>
        <translation>Guma</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="30"/>
        <source>Sprayer</source>
        <translation>Sprej</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="31"/>
        <source>Draw geometric shape</source>
        <translation>Nakreslit geometrický útvar</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="32"/>
        <source>Change color, width</source>
        <translation>Změnit barvu, tloušťku</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="33"/>
        <source>Draw line</source>
        <translation>Nakreslit čáru</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="34"/>
        <source>Draw rectangle</source>
        <translation>Nakreslit obdelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="35"/>
        <source>Draw filled rectangle</source>
        <translation>Nakreslit vyplněný obdelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="36"/>
        <source>Draw square</source>
        <translation>Nakreslit čtverec</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="37"/>
        <source>Draw filled square</source>
        <translation>Nakreslit vyplněný čtverec</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="38"/>
        <source>Draw circle</source>
        <translation>Nakreslit kružnici</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="39"/>
        <source>Draw filled circle</source>
        <translation>Nakreslit vyplněnou kružnici</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="40"/>
        <source>Draw ellipse</source>
        <translation>Nakreslit elipsu</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="41"/>
        <source>Draw filled ellipse</source>
        <translation>Nakreslit vyplněnou elipsu</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="42"/>
        <source>Draw equilateral triangle</source>
        <translation>Nakreslit rovnostranný trojúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="43"/>
        <source>Draw filled e-triangle</source>
        <translation>Nakreslit vyplňený rovn. trojúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="44"/>
        <source>Draw right isosceles triangle</source>
        <translation>Nakreslit vpravo rovnoramenný trojúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="45"/>
        <source>Draw filled ri-triangle</source>
        <translation>Nakreslit vyplněný rovnoramený trojúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="46"/>
        <source>Draw regular polygon</source>
        <translation>Nakreslit pravidelný mnohoúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="47"/>
        <source>Draw filled regular polygon</source>
        <translation>Nakreslit pravidelný vyplněný mnohoúhelník</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="48"/>
        <source>Draw regular polygram</source>
        <translation>Nakreslit pravidelný polygram</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="49"/>
        <source>Draw filled regular polygram</source>
        <translation>Nakreslit pravidelný vyplněný polygram</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="53"/>
        <source>Add/cancel text</source>
        <translation>Vložit/zrušit text</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="54"/>
        <source>Add/cancel image</source>
        <translation>Vložit/zrušit obrázek</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="50"/>
        <source>Draw thick arrow</source>
        <translation>Nakreslit tlustou šipku</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="51"/>
        <source>Draw filled thick arrow</source>
        <translation>Nakreslit vyplněnou tlustou šipku</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="52"/>
        <source>Fill mode toggle</source>
        <translation>Přepnout výplň</translation>
    </message>
    <message>
        <source>Text tool (cancel text)</source>
        <translation type="vanished">Psaní textu (zrušit)</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="55"/>
        <source>Accept current text/image</source>
        <translation>Použít napsaný text/obrázek</translation>
    </message>
    <message>
        <source>Accept current text</source>
        <translation type="vanished">Použít napsaný text</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="56"/>
        <source>Dimensioning tool</source>
        <translation>Nástroj pro měření</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="57"/>
        <source>Grid</source>
        <translation>Mřížka</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="58"/>
        <source>About Paint</source>
        <translation>O programu malování</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="59"/>
        <source>Change settings</source>
        <translation>Změnit nastavení</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="60"/>
        <source>Clear drawing</source>
        <translation>Vymazat obrázek</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="61"/>
        <source>Change background</source>
        <translation>Změnit pozadí</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="62"/>
        <source>Save snapshot</source>
        <translation>Uložit momentku</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="85"/>
        <source>About </source>
        <translation>O programu</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="120"/>
        <source>Version: </source>
        <translation>Verze: </translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="129"/>
        <source>translation credit placeholder</source>
        <translation>Jozef Mlich</translation>
    </message>
    <message>
        <location filename="../qml/pages/AboutPage.qml" line="139"/>
        <source>Help</source>
        <translation>Nápověda</translation>
    </message>
</context>
<context>
    <name>ColorSelector</name>
    <message>
        <location filename="../qml/components/ColorSelector.qml" line="27"/>
        <source>Edit color %1</source>
        <translation>Upravit barvu %1</translation>
    </message>
</context>
<context>
    <name>MediaSelector</name>
    <message>
        <source>Image selected</source>
        <translation type="vanished">Vybraný obrazek</translation>
    </message>
    <message>
        <source>Select image</source>
        <translation type="vanished">Vybrat obrázek</translation>
    </message>
</context>
<context>
    <name>Paint</name>
    <message>
        <location filename="../qml/pages/Paint.qml" line="193"/>
        <source>Swipe to change toolbar</source>
        <translation>Smykem změníte panel nástrojů</translation>
    </message>
    <message>
        <location filename="../qml/pages/Paint.qml" line="213"/>
        <source>Pinch to zoom</source>
        <translation>Přiblížení dvěma prsty</translation>
    </message>
</context>
<context>
    <name>Toolbar3</name>
    <message>
        <location filename="../qml/components/Toolbar3.qml" line="54"/>
        <source>File format</source>
        <translation>Formát souboru</translation>
    </message>
    <message>
        <location filename="../qml/components/Toolbar3.qml" line="138"/>
        <source>Mark area and click save again</source>
        <translation type="unfinished"/>
    </message>
    <message>
        <location filename="../qml/components/Toolbar3.qml" line="166"/>
        <source>Save failed...</source>
        <translation>Ukládání selhalo...</translation>
    </message>
</context>
<context>
    <name>Toolbox</name>
    <message>
        <location filename="../qml/components/Toolbox.qml" line="42"/>
        <source>Clearing</source>
        <translation>Maže se</translation>
    </message>
</context>
<context>
    <name>askFilenameDialog</name>
    <message>
        <location filename="../qml/pages/askFilenameDialog.qml" line="49"/>
        <location filename="../qml/pages/askFilenameDialog.qml" line="57"/>
        <source>Enter filename</source>
        <translation>Zadejte jméno souboru</translation>
    </message>
    <message>
        <location filename="../qml/pages/askFilenameDialog.qml" line="75"/>
        <source>File already exists</source>
        <translation>Soubor již existuje</translation>
    </message>
    <message>
        <location filename="../qml/pages/askFilenameDialog.qml" line="84"/>
        <source>Crop before saving</source>
        <translation type="unfinished"/>
    </message>
</context>
<context>
    <name>bgSettingsDialog</name>
    <message>
        <location filename="../qml/pages/bgSettingsDialog.qml" line="46"/>
        <source>Select background</source>
        <translation>Vybrat pozadí</translation>
    </message>
    <message>
        <location filename="../qml/pages/bgSettingsDialog.qml" line="65"/>
        <source>Select color</source>
        <translation>Vybrat barvu</translation>
    </message>
    <message>
        <location filename="../qml/pages/bgSettingsDialog.qml" line="78"/>
        <source>None</source>
        <translation>Žádný</translation>
    </message>
    <message>
        <location filename="../qml/pages/bgSettingsDialog.qml" line="100"/>
        <source>Image</source>
        <translation>Obrázek</translation>
    </message>
</context>
<context>
    <name>dimensionDialog</name>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="37"/>
        <source>Warning: Do not cancel now</source>
        <translation>Varování: teď nepřerušujte</translation>
    </message>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="53"/>
        <source>Dimensioning</source>
        <translation>Rozměry</translation>
    </message>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="71"/>
        <source>Scale all dimensions</source>
        <translation>Roztáhnout na rozměr</translation>
    </message>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="77"/>
        <source>Reference length %1</source>
        <translation>Referenční velikost %1</translation>
    </message>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="83"/>
        <source>Currently scaled length %1</source>
        <translation>Momentálně zvětšeno na %1</translation>
    </message>
    <message>
        <location filename="../qml/pages/dimensionDialog.qml" line="91"/>
        <source>Enter true length</source>
        <translation>Nastavte skutečnou velikost</translation>
    </message>
</context>
<context>
    <name>eraserSettingsDialog</name>
    <message>
        <location filename="../qml/pages/eraserSettingsDialog.qml" line="37"/>
        <source>Eraser settings</source>
        <translation>Nastavení gumy</translation>
    </message>
    <message>
        <location filename="../qml/pages/eraserSettingsDialog.qml" line="55"/>
        <source>Eraser size</source>
        <translation>Velikost gumy</translation>
    </message>
</context>
<context>
    <name>genSettings</name>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="40"/>
        <source>General settings</source>
        <translation>Obecné nastavení</translation>
    </message>
    <message>
        <source>File format</source>
        <translation type="vanished">formát souboru</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="60"/>
        <source>Saving options</source>
        <translation>Možnosti uložení</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="98"/>
        <source>Ask filename when saving</source>
        <translation>Zeptat se na jméno souboru při ukládání</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="106"/>
        <source>Toolbox location</source>
        <translation>Umístění panelu nástrojů</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="116"/>
        <source>Top</source>
        <translation>Horní okraj</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="130"/>
        <source>Bottom</source>
        <translation>Dolní okraj</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="144"/>
        <source>Grid settings</source>
        <translation>Nastavní mřížky</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="151"/>
        <source>Snap to Grid</source>
        <translation>Zarovnat k mřížce</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="159"/>
        <source>Grid spacing</source>
        <translation>Rozteč mřížky</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="170"/>
        <source>Tool settings</source>
        <translation>Nastavení nástroje</translation>
    </message>
    <message>
        <location filename="../qml/pages/genSettings.qml" line="177"/>
        <source>Remember tool settings</source>
        <translation>Zapamatovat si nastavení nástroje</translation>
    </message>
</context>
<context>
    <name>paint</name>
    <message>
        <location filename="../qml/paint.qml" line="14"/>
        <source>Accept</source>
        <translation>Příjmout</translation>
    </message>
    <message>
        <location filename="../qml/paint.qml" line="15"/>
        <source>Cancel</source>
        <translation>Zrušit</translation>
    </message>
</context>
<context>
    <name>penSettingsDialog</name>
    <message>
        <location filename="../qml/pages/penSettingsDialog.qml" line="38"/>
        <source>Pen settings</source>
        <translation>Nastavení pera</translation>
    </message>
    <message>
        <location filename="../qml/pages/penSettingsDialog.qml" line="56"/>
        <source>Select color</source>
        <translation>Vyberte barvu</translation>
    </message>
    <message>
        <location filename="../qml/pages/penSettingsDialog.qml" line="68"/>
        <source>Pen width</source>
        <translation>Tloušťka pera</translation>
    </message>
</context>
<context>
    <name>spraySettingsDialog</name>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="61"/>
        <source>Sprayer settings</source>
        <translation>Nastavení spreje</translation>
    </message>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="80"/>
        <source>Select color</source>
        <translation>Vyberte barvu</translation>
    </message>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="126"/>
        <source>Sprayer parameters</source>
        <translation>Parametry spreje</translation>
    </message>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="132"/>
        <source>Size</source>
        <translation>Velikost</translation>
    </message>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="145"/>
        <source>Density</source>
        <translation>Hustota</translation>
    </message>
    <message>
        <location filename="../qml/pages/spraySettingsDialog.qml" line="159"/>
        <source>Particle size</source>
        <translation>Velikost částice</translation>
    </message>
</context>
<context>
    <name>textEntryDialog</name>
    <message>
        <location filename="../qml/pages/textEntryDialog.qml" line="51"/>
        <source>Enter some text</source>
        <translation>Zadejte nějaký text</translation>
    </message>
</context>
<context>
    <name>textSettingsDialog</name>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="42"/>
        <source>Text settings</source>
        <translation>Nastavení textu</translation>
    </message>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="60"/>
        <source>Select color</source>
        <translation>Vyberte barvu</translation>
    </message>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="71"/>
        <source>Font size</source>
        <translation>Velikost písma</translation>
    </message>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="93"/>
        <source>Bold</source>
        <translation>Tučným</translation>
    </message>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="100"/>
        <source>Italic</source>
        <translation>Kurzíva</translation>
    </message>
    <message>
        <location filename="../qml/pages/textSettingsDialog.qml" line="108"/>
        <source>Font</source>
        <translation>Písmo</translation>
    </message>
</context>
</TS>


text:
TAGS=$1

juju model-config disable-network-management=true
MACHINE="$(juju add-machine --constraints tags=${TAGS} 2>&1 >/dev/null |grep -o -E "[0-9]+")"

echo "== add-unit ceph-osd to ${MACHINE} =="
juju add-unit ceph-osd --to ${MACHINE}


text:
package tai.saitawngpha.panglongfont;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.app.ActionBarActivity;

import tai.saitawngpha.panglongfont.CalligraphyContextWrapper;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Inject pragmatically
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.container, PlaceholderFragment.getInstance())
                .commit();

        new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
            @Override
            public void run() {
                setTitle("Calligraphy changed");
                getSupportActionBar().setSubtitle("Added subtitle");
            }
        }, 1000);
    }

    /*
        Uncomment if you disable PrivateFactory injection. See CalligraphyConfig#disablePrivateFactoryInjection()
     */
//    @Override
//    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
//    public View onCreateView(View parent, String name, @NonNull Context context, @NonNull AttributeSet attrs) {
//        return CalligraphyContextWrapper.onActivityCreateView(this, parent, super.onCreateView(parent, name, context, attrs), name, context, attrs);
//    }

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }

}


text:
/*
 * execBitmapParquetScan.c
 *   Support routines for scanning parquet tables using bitmaps.
 *
 */

#include "postgres.h"
#include "nodes/execnodes.h"
#include "executor/tuptable.h"

void BitmapParquetScanBegin(ScanState *scanState);
void BitmapParquetScanEnd(ScanState *scanState);
TupleTableSlot* BitmapParquetScanNext(ScanState *scanState);
void BitmapParquetScanReScan(ScanState *scanState);

/*
 * Prepares for a new parquet scan.
 */
void
BitmapParquetScanBegin(ScanState *scanState)
{
	Insist(!"Bitmap index scan on parquet table is not supported");
}

/*
 * Cleans up after the scanning is done.
 */
void
BitmapParquetScanEnd(ScanState *scanState)
{
	Insist(!"Bitmap index scan on parquet table is not supported");
}

/*
 * Returns the next matching tuple.
 */
TupleTableSlot *
BitmapParquetScanNext(ScanState *scanState)
{
	Insist(!"Bitmap index scan on parquet table is not supported");
}

/*
 * Prepares for a re-scan.
 */
void
BitmapParquetScanReScan(ScanState *scanState)
{
	Insist(!"Bitmap index scan on parquet table is not supported");
}


text:
using namespace rapidjson;

class LevelParser
{
public:
	Level* parse_level(const char* levelFile);
private:
	void parse_tilesets(const Value& tileset_root, std::vector<Tileset>* tilesets);
	void parse_tile_layer(const Value& tile_element, std::vector<Layer*> layers, const std::vector<Tileset>* tilesets);
	int m_tile_size;
	int m_width;
	int m_height;
};

#endif // !__LEVELPARSER_H__


text:
<TITLE>cgGetContextBehavior</TITLE>

<object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e">
</object>

NAME

cgGetContextBehavior - get the behavior enumerant for a context

SYNOPSIS

  #include <Cg/cg.h>

  CGbehavior cgGetContextBehavior( CGcontext context );

PARAMETERS

context

The context for which the behavior enumerant will be returned.

RETURN VALUES

Returns the behavior enumerant for context.

Returns CG_BEHAVIOR_UNKNOWN if an error occurs.

DESCRIPTION

cgGetContextBehavior allows the application to retrieve the behavior
enumerant for a context.  The valid enumerants and their meanings are
described in cgSetContextBehavior.

EXAMPLES

  /* create a context and get the default context behavior enum */

  CGcontext context = cgCreateContext();
  CGbehavior cb = cgGetContextBehavior(context);

ERRORS

CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context.

HISTORY

cgGetContextBehavior was introduced in Cg 3.0.

SEE ALSO

cgCreateContext,
cgSetContextBehavior,
cgGetBehavior,
cgGetBehaviorString


text:
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using OfficeOpenXml;
using OfficeOpenXml.Drawing;
using OfficeOpenXml.Export.ToDataTable;
using OfficeOpenXml.Style;

namespace ISSIAS_Library.Excel
{
    public static class ExcelService
    {
        public static DataTable OpenBook(string book, string sheetName,
            string startLiteral,
            string endLiteral,
            ToDataTableOptions options)
        {
            using (var package = new ExcelPackage(new FileInfo(book)))
            {
                var workSheet =
                    package.Workbook.Worksheets.FirstOrDefault(w => w.Name.ToLower().Contains(sheetName.ToLower()));
                var maxRows = workSheet.Dimension.Rows;

                var start = workSheet.Cells
                    .Where(c => c.Value != null)
                    .First(c => c.Value.ToString().ToLower().Contains(startLiteral.ToLower())).Address;

                var endAddress = workSheet.Cells
                    .Where(c => c.Value != null)
                    .First(c => c.Value.ToString().ToLower().Contains(endLiteral.ToLower())).Address;

                var end = new string(endAddress.TakeWhile(x => !char.IsNumber(x)).ToArray());

                var dataTable = workSheet.Cells[$"{start}:{end}{maxRows}"]
                    .ToDataTable(options);

                return dataTable;
            }
        }

        public static void SaveBook(string path, string sheetName, IEnumerable<asset> assets, MemberInfo[] memberInfos)
        {
            //if (File.Exists(path)) File.Delete(path);

            using (var package = new ExcelPackage(new FileInfo(path)))
            {
                var workSheet = package.Workbook.Worksheets.Add(sheetName);
                workSheet.Cells["A1"]
                    .LoadFromCollection(assets, c =>
                    {
                        c.PrintHeaders = true;
                        if (memberInfos != null && memberInfos.Any())
                            c.Members = memberInfos;
                    });

                workSheet.Cells[$"C2:C{workSheet.Dimension.Rows}"].Style.Numberformat.Format = "mm-dd-yy";

                workSheet.Cells.AutoFitColumns();

                workSheet.Cells[$"B2:B{workSheet.Dimension.Rows}"].Value = "";

                ParallelWork(workSheet, assets);

                package.Save();
            }
        }

        private static void ParallelWork(ExcelWorksheet workSheet, IEnumerable<asset> assets)
        {
            Parallel.For(1, workSheet.Dimension.Rows + 1, index => { workSheet.Row(index).Height = 50; });

            var row = 0;
            foreach (var element in assets.AsParallel())
            {
                ++row;
                if (element.AssetBarcode == null) continue;

                var pic = workSheet.Drawings.AddPicture(Guid.NewGuid().ToString(), element.AssetBarcode);
                pic.SetPosition(row, 25, 1, 10);
                pic.LockAspectRatio = true;
                pic.ChangeCellAnchor(eEditAs.TwoCell);
            }
        }
    }
}


text:
import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {

  val appName         = "play-activate-mysql"
  val appVersion      = "1.0-SNAPSHOT"

  val activateVersion = "1.4.4"
  val activateCore = "net.fwbrasil" %% "activate-core" % activateVersion
  val activateJdbc = "net.fwbrasil" %% "activate-jdbc" % activateVersion
  val activatePlay = "net.fwbrasil" %% "activate-play" % activateVersion

  val mysql = "mysql" % "mysql-connector-java" % "5.1.16"

  val appDependencies = Seq(
    mysql,
    activateCore,
    activateJdbc,
    activatePlay
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
	  resolvers ++= Seq("fwbrasil.net" at "http://fwbrasil.net/maven/")
  )

}


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
	        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
        <!--是否开启嵌套事务,默认为false-->
        <!--<property name="nestedTransactionAllowed" value="true"/>-->
    </bean>
    <!--加入对web的支持-->
    <bean class="org.springframework.data.web.config.SpringDataWebConfiguration"/>
    <jpa:repositories base-package="com.byd.repository" repository-impl-postfix="Impl"
                      entity-manager-factory-ref="entityManagerFactory"/>
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="packagesToScan" value="com.byd.entity" />
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="generateDdl" value="false" />
                <property name="database" value="MYSQL" />
                <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
                 <property name="showSql" value="true" />
            </bean>
        </property>
        <property name="jpaDialect">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
        </property>
        <property name="jpaPropertyMap">
            <map>
                <entry key="hibernate.query.substitutions" value="true 1, false 0" />
                <entry key="hibernate.default_batch_fetch_size" value="16" />
                <entry key="hibernate.max_fetch_depth" value="2" />
                <entry key="hibernate.generate_statistics" value="true" />
                <entry key="hibernate.bytecode.use_reflection_optimizer" value="true" />
                <entry key="hibernate.cache.use_second_level_cache" value="false" />
                <entry key="hibernate.cache.use_query_cache" value="false" />
            </map>
        </property>
    </bean>
    <!-- 数据源配置,使用应用内的c3p0数据库连接池 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <property name="driverClass" value="${jdbc.driver}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="minPoolSize" value="${jdbc.pool.minPoolSize}" />
        <property name="maxPoolSize" value="${jdbc.pool.maxPoolSize}" />
        <property name="initialPoolSize" value="5" />	 		<!-- 初始化时获取5个连接,取值应在minPoolSize与maxPoolSize之间 -->
        <property name="idleConnectionTestPeriod" value="300" /> 	<!-- 每5分钟秒检查所有连接池中的空闲连接。Default:0 -->
        <property name="autoCommitOnClose" value="false" />  	<!-- 连接关闭时默认将所有未提交的操作回滚。Default: false -->
        <property name="testConnectionOnCheckout" value="false" />
    </bean>
    <!--注册jdbcTemplate-->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
</beans>


text:
/*************************************************************************/
/*  gd_mono_assembly.cpp                                                 */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                      https://godotengine.org                          */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur.                 */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md)    */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#include "gd_mono_assembly.h"

#include <mono/metadata/mono-debug.h>
#include <mono/metadata/tokentype.h>

#include "list.h"
#include "os/file_access.h"
#include "os/os.h"

#include "../godotsharp_dirs.h"
#include "gd_mono_class.h"

bool GDMonoAssembly::no_search = false;
Vector<String> GDMonoAssembly::search_dirs;

MonoAssembly *GDMonoAssembly::_search_hook(MonoAssemblyName *aname, void *user_data) {

	(void)user_data; // UNUSED

	String name = mono_assembly_name_get_name(aname);
	bool has_extension = name.ends_with(".dll") || name.ends_with(".exe");

	if (no_search)
		return NULL;

	GDMonoAssembly **loaded_asm = GDMono::get_singleton()->get_loaded_assembly(has_extension ? name.get_basename() : name);
	if (loaded_asm)
		return (*loaded_asm)->get_assembly();

	no_search = true; // Avoid the recursion madness

	String path;
	MonoAssembly *res = NULL;

	for (int i = 0; i < search_dirs.size(); i++) {
		const String &search_dir = search_dirs[i];

		if (has_extension) {
			path = search_dir.plus_file(name);
			if (FileAccess::exists(path)) {
				res = _load_assembly_from(name.get_basename(), path);
				break;
			}
		} else {
			path = search_dir.plus_file(name + ".dll");
			if (FileAccess::exists(path)) {
				res = _load_assembly_from(name, path);
				break;
			}

			path = search_dir.plus_file(name + ".exe");
			if (FileAccess::exists(path)) {
				res = _load_assembly_from(name, path);
				break;
			}
		}
	}

	no_search = false;

	return res;
}

MonoAssembly *GDMonoAssembly::_preload_hook(MonoAssemblyName *aname, char **assemblies_path, void *user_data) {

	(void)user_data; // UNUSED

	if (search_dirs.empty()) {
		search_dirs.push_back(GodotSharpDirs::get_res_temp_assemblies_dir());
		search_dirs.push_back(GodotSharpDirs::get_res_assemblies_dir());
		search_dirs.push_back(OS::get_singleton()->get_resource_dir());
		search_dirs.push_back(OS::get_singleton()->get_executable_path().get_base_dir());

		const char *rootdir = mono_assembly_getrootdir();
		if (rootdir) {
			search_dirs.push_back(String(rootdir).plus_file("mono").plus_file("4.5"));
		}

		while (assemblies_path) {
			if (*assemblies_path)
				search_dirs.push_back(*assemblies_path);
			++assemblies_path;
		}
	}

	return NULL;
}

MonoAssembly *GDMonoAssembly::_load_assembly_from(const String &p_name, const String &p_path) {

	GDMonoAssembly *assembly = memnew(GDMonoAssembly(p_name, p_path));

	MonoDomain *domain = mono_domain_get();

	Error err = assembly->load(domain);

	if (err != OK) {
		memdelete(assembly);
		ERR_FAIL_V(NULL);
	}

	GDMono::get_singleton()->add_assembly(domain ? mono_domain_get_id(domain) : 0, assembly);

	return assembly->get_assembly();
}

void GDMonoAssembly::initialize() {

	// TODO refonly as well?
	mono_install_assembly_preload_hook(&GDMonoAssembly::_preload_hook, NULL);
	mono_install_assembly_search_hook(&GDMonoAssembly::_search_hook, NULL);
}

Error GDMonoAssembly::load(MonoDomain *p_domain) {

	ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE);

	uint64_t last_modified_time = FileAccess::get_modified_time(path);

	Vector<uint8_t> data = FileAccess::get_file_as_array(path);
	ERR_FAIL_COND_V(data.empty(), ERR_FILE_CANT_READ);

	String image_filename(path);

	MonoImageOpenStatus status;

	image = mono_image_open_from_data_with_name(
			(char *)&data[0], data.size(),
			true, &status, false,
			image_filename.utf8().get_data());

	ERR_FAIL_COND_V(status != MONO_IMAGE_OK || image == NULL, ERR_FILE_CANT_OPEN);

#ifdef DEBUG_ENABLED
	String pdb_path(path + ".pdb");

	if (!FileAccess::exists(pdb_path)) {
		pdb_path = path.get_basename() + ".pdb"; // without .dll

		if (!FileAccess::exists(pdb_path))
			goto no_pdb;
	}

	pdb_data.clear();
	pdb_data = FileAccess::get_file_as_array(pdb_path);
	mono_debug_open_image_from_memory(image, &pdb_data[0], pdb_data.size());

no_pdb:

#endif

	assembly = mono_assembly_load_from_full(image, image_filename.utf8().get_data(), &status, false);

	ERR_FAIL_COND_V(status != MONO_IMAGE_OK || assembly == NULL, ERR_FILE_CANT_OPEN);

	if (p_domain && mono_image_get_entry_point(image)) {
		// TODO should this be removed? do we want to call main? what other effects does this have?
		mono_jit_exec(p_domain, assembly, 0, NULL);
	}

	loaded = true;
	modified_time = last_modified_time;

	return OK;
}

Error GDMonoAssembly::wrapper_for_image(MonoImage *p_image) {

	ERR_FAIL_COND_V(loaded, ERR_FILE_ALREADY_IN_USE);

	assembly = mono_image_get_assembly(p_image);
	ERR_FAIL_NULL_V(assembly, FAILED);

	image = p_image;

	mono_image_addref(image);

	loaded = true;

	return OK;
}

void GDMonoAssembly::unload() {

	ERR_FAIL_COND(!loaded);

#ifdef DEBUG_ENABLED
	if (pdb_data.size()) {
		mono_debug_close_image(image);
		pdb_data.clear();
	}
#endif

	for (Map<MonoClass *, GDMonoClass *>::Element *E = cached_raw.front(); E; E = E->next()) {
		memdelete(E->value());
	}

	cached_classes.clear();
	cached_raw.clear();

	mono_image_close(image);

	assembly = NULL;
	image = NULL;
	loaded = false;
}

GDMonoClass *GDMonoAssembly::get_class(const StringName &p_namespace, const StringName &p_name) {

	ERR_FAIL_COND_V(!loaded, NULL);

	ClassKey key(p_namespace, p_name);

	GDMonoClass **match = cached_classes.getptr(key);

	if (match)
		return *match;

	MonoClass *mono_class = mono_class_from_name(image, String(p_namespace).utf8(), String(p_name).utf8());

	if (!mono_class)
		return NULL;

	GDMonoClass *wrapped_class = memnew(GDMonoClass(p_namespace, p_name, mono_class, this));

	cached_classes[key] = wrapped_class;
	cached_raw[mono_class] = wrapped_class;

	return wrapped_class;
}

GDMonoClass *GDMonoAssembly::get_class(MonoClass *p_mono_class) {

	ERR_FAIL_COND_V(!loaded, NULL);

	Map<MonoClass *, GDMonoClass *>::Element *match = cached_raw.find(p_mono_class);

	if (match)
		return match->value();

	StringName namespace_name = mono_class_get_namespace(p_mono_class);
	StringName class_name = mono_class_get_name(p_mono_class);

	GDMonoClass *wrapped_class = memnew(GDMonoClass(namespace_name, class_name, p_mono_class, this));

	cached_classes[ClassKey(namespace_name, class_name)] = wrapped_class;
	cached_raw[p_mono_class] = wrapped_class;

	return wrapped_class;
}

GDMonoClass *GDMonoAssembly::get_object_derived_class(const StringName &p_class) {

	GDMonoClass *match = NULL;

	if (gdobject_class_cache_updated) {
		Map<StringName, GDMonoClass *>::Element *result = gdobject_class_cache.find(p_class);

		if (result)
			match = result->get();
	} else {
		List<GDMonoClass *> nested_classes;

		int rows = mono_image_get_table_rows(image, MONO_TABLE_TYPEDEF);

		for (int i = 1; i < rows; i++) {
			MonoClass *mono_class = mono_class_get(image, (i + 1) | MONO_TOKEN_TYPE_DEF);

			if (!mono_class_is_assignable_from(CACHED_CLASS_RAW(GodotObject), mono_class))
				continue;

			GDMonoClass *current = get_class(mono_class);

			if (!current)
				continue;

			nested_classes.push_back(current);

			if (!match && current->get_name() == p_class)
				match = current;

			while (!nested_classes.empty()) {
				GDMonoClass *current_nested = nested_classes.front()->get();
				nested_classes.pop_back();

				void *iter = NULL;

				while (true) {
					MonoClass *raw_nested = mono_class_get_nested_types(current_nested->get_raw(), &iter);

					if (!raw_nested)
						break;

					GDMonoClass *nested_class = get_class(raw_nested);

					if (nested_class) {
						gdobject_class_cache.insert(nested_class->get_name(), nested_class);
						nested_classes.push_back(nested_class);
					}
				}
			}

			gdobject_class_cache.insert(current->get_name(), current);
		}

		gdobject_class_cache_updated = true;
	}

	return match;
}

GDMonoAssembly::GDMonoAssembly(const String &p_name, const String &p_path) {

	loaded = false;
	gdobject_class_cache_updated = false;
	name = p_name;
	path = p_path;
	modified_time = 0;
	assembly = NULL;
	image = NULL;
}

GDMonoAssembly::~GDMonoAssembly() {

	if (loaded)
		unload();
}


text:
---

title: "Rush Request Policy"

---

The UC Davis Analytical Lab strives to meet its clients' turnaround time requirements. The Lab's current turnaround times are variable. In fairness to all submitters, samples are processed in the order received by the Lab.

If your analytical results require an expedited time frame, please contact the Lab Office, (530) 752-0147, prior to sample submission to ensure that your request can be accommodated. Rush requests are reviewed and approved based on the laboratory's resources and workload at the time of the request.

Requests to rush samples are subject to additional charges ranging from 1.5x to 4x of the original listed price


text:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<database>
	<name>*dbname*</name>
	<create>true</create>
	<overwrite>false</overwrite>
	<charset>utf8</charset>
	<table>
		<name>*dbprefix*share_external</name>
		<declaration>
			<field>
				<name>id</name>
				<type>integer</type>
				<default>0</default>
				<notnull>true</notnull>
				<autoincrement>1</autoincrement>
				<length>4</length>
			</field>
			<field>
				<name>remote</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>512</length>
				<comments>Url of the remove owncloud instance</comments>
			</field>
			<field>
				<name>share_token</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Public share token</comments>
			</field>
			<field>
				<name>password</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Optional password for the public share</comments>
			</field>
			<field>
				<name>name</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Original name on the remote server</comments>
			</field>
			<field>
				<name>owner</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>User that owns the public share on the remote server</comments>
			</field>
			<field>
				<name>user</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>64</length>
				<comments>Local user which added the external share</comments>
			</field>
			<field>
				<name>mountpoint</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>4000</length>
				<comments>Full path where the share is mounted</comments>
			</field>
			<field>
				<name>mountpoint_hash</name>
				<type>text</type>
				<notnull>true</notnull>
				<length>32</length>
				<comments>md5 hash of the mountpoint</comments>
			</field>
			<index>
				<name>sh_external_user</name>
				<field>
					<name>user</name>
					<sorting>ascending</sorting>
				</field>
			</index>
			<index>
				<name>sh_external_mp</name>
				<unique>true</unique>
				<field>
					<name>user</name>
					<sorting>ascending</sorting>
				</field>
				<field>
					<name>mountpoint_hash</name>
					<sorting>ascending</sorting>
				</field>
			</index>
		</declaration>
	</table>
</database>


text:
<?php
namespace buycraft\task;

use buycraft\api\Actions;
use buycraft\api\ApiTask;
use buycraft\util\DebugUtils;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerJoinEvent;
use pocketmine\scheduler\PluginTask;
use pocketmine\scheduler\TaskHandler;

/*
 * Does NOT perform any API communication, uses another task.
 */
class PendingPlayerCheckerTask extends PluginTask implements Listener{
    private $pendingPlayers = [];
    /** @var  TaskHandler */
    private $handler;
    public function onRun($tick, $manual = false){
        DebugUtils::taskCalled($this);
        if($this->getOwner()->getConfig()->get('commandChecker') || $manual){
            $task = new PendingUsersTask($this->getOwner());
            $task->call();
        }
    }
    public function call(){
        DebugUtils::taskRegistered($this);
        $this->getOwner()->getServer()->getPluginManager()->registerEvents($this, $this->getOwner());
        $this->handler = $this->getOwner()->getServer()->getScheduler()->scheduleRepeatingTask($this, 40);
    }
    public function onPlayerJoin(PlayerJoinEvent $event){
        if(isset($this->pendingPlayers[$event->getPlayer()->getName()])){
            $fetch = new CommandFetchTask($this->getOwner(), ["users" => [$event->getPlayer()->getName()], "offlineCommands" => false]);
            $fetch->call();
            unset($this->pendingPlayers[$event->getPlayer()->getName()]);
        }
    }
    public function resetPendingPlayers(){
        $this->pendingPlayers = [];
    }
    public function addPendingPlayer($name){
        $this->pendingPlayers[] = $name;
    }
    public function setUpdateInterval($interval){
        $this->handler->cancel();
        $this->handler = $this->getOwner()->getServer()->getScheduler()->scheduleRepeatingTask($this, $interval);
    }
}