text:
namespace bpy = boost::python;
using namespace foundation;
using namespace renderer;

namespace
{
    Tile* copy_tile(const Tile* source)
    {
        return new Tile(*source);
    }

    Tile* deepcopy_tile(const Tile* source, bpy::dict& memo)
    {
        // todo: not sure what to store in memo...
        return new Tile(*source);
    }

    void copy_tile_data_to_py_buffer(const Tile& tile, bpy::object& buffer)
    {
        void* array = nullptr;
        Py_ssize_t len;

        const int success = PyObject_AsWriteBuffer(buffer.ptr(), &array, &len);

        if (success != 0)
            bpy::throw_error_already_set();

        if (static_cast<size_t>(len) < tile.get_size())
        {
            PyErr_SetString(PyExc_IndexError, "Buffer size is smaller than data size");
            bpy::throw_error_already_set();
        }

        std::copy(
            tile.get_storage(),
            tile.get_storage() + tile.get_size(),
            reinterpret_cast<uint8*>(array));
    }

    bpy::list blender_tile_data(const Tile& tile)
    {
        bpy::list pixels;

        for (size_t y = 0, height = tile.get_height(); y < height; ++y)
        {
            for (size_t x = 0, width = tile.get_width(); x < width; ++x)
            {
                // Blender's image coordinate system is y up.
                Color4f linear_rgba;
                tile.get_pixel(x, height - y - 1, linear_rgba);

                bpy::list p;
                p.append(linear_rgba[0]);
                p.append(linear_rgba[1]);
                p.append(linear_rgba[2]);
                p.append(linear_rgba[3]);
                pixels.append(p);
            }
        }

        return pixels;
    }

    Image* copy_image(const Image* source)
    {
        return new Image(*source);
    }

    Image* deepcopy_image(const Image* source, bpy::dict& memo)
    {
        // todo: not sure what to store in memo...
        return new Image(*source);
    }

    std::string image_stack_get_name(const ImageStack* image_stack, const size_t index)
    {
        return image_stack->get_name(index);
    }
}

void bind_image()
{
    bpy::enum_<PixelFormat>("PixelFormat")
        .value("UInt8",  PixelFormatUInt8)
        .value("UInt16", PixelFormatUInt16)
        .value("UInt32", PixelFormatUInt32)
        .value("Half",   PixelFormatHalf)
        .value("Float",  PixelFormatFloat)
        .value("Double", PixelFormatDouble)
        ;

    bpy::class_<CanvasProperties, boost::noncopyable>("CanvasProperties", bpy::no_init)
        .def_readonly("canvas_width", &CanvasProperties::m_canvas_width)
        .def_readonly("canvas_height", &CanvasProperties::m_canvas_height)
        .def_readonly("tile_width", &CanvasProperties::m_tile_width)
        .def_readonly("tile_height", &CanvasProperties::m_tile_height)
        .def_readonly("channel_count", &CanvasProperties::m_channel_count)
        .def_readonly("pixel_format", &CanvasProperties::m_pixel_format)
        .def_readonly("rcp_canvas_width", &CanvasProperties::m_rcp_canvas_width)
        .def_readonly("rcp_canvas_height", &CanvasProperties::m_rcp_canvas_height)
        .def_readonly("rcp_tile_width", &CanvasProperties::m_rcp_tile_width)
        .def_readonly("rcp_tile_height", &CanvasProperties::m_rcp_tile_height)
        .def_readonly("tile_count_x", &CanvasProperties::m_tile_count_x)
        .def_readonly("tile_count_y", &CanvasProperties::m_tile_count_y)
        .def_readonly("tile_count", &CanvasProperties::m_tile_count)
        .def_readonly("pixel_count", &CanvasProperties::m_pixel_count)
        .def_readonly("pixel_size", &CanvasProperties::m_pixel_size)
        .def("get_tile_width", &CanvasProperties::get_tile_width)
        .def("get_tile_height", &CanvasProperties::get_tile_height)
        ;

    bpy::class_<Tile, boost::noncopyable>("Tile", bpy::init<size_t, size_t, size_t, PixelFormat>())
        .def("__copy__", copy_tile, bpy::return_value_policy<bpy::manage_new_object>())
        .def("__deepcopy__", deepcopy_tile, bpy::return_value_policy<bpy::manage_new_object>())
        .def("get_pixel_format", &Tile::get_pixel_format)
        .def("get_width", &Tile::get_width)
        .def("get_height", &Tile::get_height)
        .def("get_channel_count", &Tile::get_channel_count)
        .def("get_pixel_count", &Tile::get_pixel_count)
        .def("get_size", &Tile::get_size)
        .def("copy_data_to", copy_tile_data_to_py_buffer)   // todo: maybe this needs a better name

        .def("blender_tile_data", blender_tile_data)
        ;

    const Tile& (Image::*image_get_tile)(const size_t, const size_t) const = &Image::tile;

    bpy::class_<Image, boost::noncopyable>("Image", bpy::no_init)
        .def("__copy__", copy_image, bpy::return_value_policy<bpy::manage_new_object>())
        .def("__deepcopy__", copy_image, bpy::return_value_policy<bpy::manage_new_object>())
        .def("properties", &Image::properties, bpy::return_value_policy<bpy::reference_existing_object>())
        .def("tile", image_get_tile, bpy::return_value_policy<bpy::reference_existing_object>())
        ;

    const Image& (ImageStack::*image_stack_get_image)(const size_t) const = &ImageStack::get_image;

    bpy::class_<ImageStack, boost::noncopyable>("ImageStack", bpy::no_init)
        .def("empty", &ImageStack::empty)
        .def("size", &ImageStack::size)
        .def("get_name", image_stack_get_name)
        .def("get_image", image_stack_get_image, bpy::return_value_policy<bpy::reference_existing_object>())
        ;
}

redpajama_set_name: RedPajamaGithub


text:
package squidpony.squidmath;

import java.io.Serializable;
import java.util.Random;

/**
 * This makes java.util.Random available for testing purposes.
 * It is relevant mainly as example code, or if you want to
 * compare what your results would have been without using a
 * better RNG. Results might not be apparent in some cases,
 * although the terrible performance of java.util.Random is
 * likely to be the first thing a user notices if this is
 * used heavily (i.e. to generate white noise with one call
 * to {@link #nextDouble()} per cell).
 * @author Ben McLean
 */
public class JavaRNG implements RandomnessSource, Serializable
{
    public Random random;

    /** Creates a new generator seeded using Math.random. */
    public JavaRNG() { this((long) Math.floor(Math.random() * Long.MAX_VALUE)); }

    public JavaRNG( final long seed ) { this.random = new Random(seed); }

    public JavaRNG( final Random random ) { this.random = random; }

    @Override
    public int next( int bits ) {
        return random.nextInt() >>> (32 - bits);
        // return random.next(bits);
    }

    @Override
    public long nextLong() { return random.nextLong(); }

    @Override
    public RandomnessSource copy() { return new JavaRNG(random); }

    public int nextInt() { return random.nextInt(); }

    public int nextInt( final int bound ) { return random.nextInt(bound); }
    /**
     * Inclusive lower, exclusive upper.
     * @param lower the lower bound, inclusive, can be positive or negative
     * @param upper the upper bound, exclusive, should be positive, must be greater than lower
     * @return a random int at least equal to lower and less than upper
     */
    public int nextInt( final int lower, final int upper ) {
        if ( upper - lower <= 0 ) throw new IllegalArgumentException("Upper bound must be greater than lower bound");
        return lower + nextInt(upper - lower);
    }

    public double nextDouble() { return random.nextDouble(); }
    public double nextDouble(final double outer) {
        return nextDouble() * outer;
    }

    /**
     * Gets a uniform random float in the range [0.0,1.0)
     * @return a random float at least equal to 0.0 and less than 1.0
     */
    public float nextFloat() { return random.nextFloat(); }
    /**
     * Gets a random value, true or false.
     * @return a random true or false value.
     */
    public boolean nextBoolean() { return ( random.nextBoolean()); }

    /**
     * Given a byte array as a parameter, this will fill the array with random bytes (modifying it
     * in-place).
     */
    public void nextBytes( final byte[] bytes ) { random.nextBytes(bytes); }

    @Override
    public String toString() {
        return "JavaRNG wrapping java.util.Random with id " + System.identityHashCode(random);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        JavaRNG javaRNG = (JavaRNG) o;

        return random.equals(javaRNG.random);
    }

    @Override
    public int hashCode() {
        return random.hashCode() * 31;
    }
}


text:
package org.apache.poi.ss.formula.functions;

import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;

/**
 * Implementation for Excel REPT () function.

 *

 * Syntax:
 REPT  (text,number_times )

 *

 * Repeats text a given number of times. Use REPT to fill a cell with a number of instances of a text string.
 *
 * text : text The text that you want to repeat.
 * number_times:	A positive number specifying the number of times to repeat text.
 *
 * If number_times is 0 (zero), REPT returns "" (empty text).
 * If this argument contains a decimal value, this function ignores the numbers to the right side of the decimal point.
 *
 * The result of the REPT function cannot be longer than 32,767 characters, or REPT returns #VALUE!.
 *
 * @author cedric dot walter @ gmail dot com
 */
public class Rept extends Fixed2ArgFunction  {

    public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval text, ValueEval number_times) {

        ValueEval veText1;
        try {
            veText1 = OperandResolver.getSingleValue(text, srcRowIndex, srcColumnIndex);
        } catch (EvaluationException e) {
            return e.getErrorEval();
        }
        String strText1 = OperandResolver.coerceValueToString(veText1);
        double numberOfTime = 0;
        try {
            numberOfTime = OperandResolver.coerceValueToDouble(number_times);
        } catch (EvaluationException e) {
            return ErrorEval.VALUE_INVALID;
        }

        int numberOfTimeInt = (int)numberOfTime;
        StringBuffer strb = new StringBuffer(strText1.length() * numberOfTimeInt);
        for(int i = 0; i < numberOfTimeInt; i++) {
            strb.append(strText1);
        }

        if (strb.toString().length() > 32767) {
            return ErrorEval.VALUE_INVALID;
        }

        return new StringEval(strb.toString());
    }
}


text:
<?php

declare(strict_types=1);

namespace sad_spirit\pg_builder\nodes\lists;

use sad_spirit\pg_builder\nodes\NonRecursiveNode;
use sad_spirit\pg_builder\nodes\range\ColumnDefinition;

/**
 * Column definition list, may appear in aliases for functions in FROM
 *
 * @extends NonAssociativeList<ColumnDefinition, iterable<ColumnDefinition>, ColumnDefinition>
 */
class ColumnDefinitionList extends NonAssociativeList
{
    use NonRecursiveNode;

    protected static function getAllowedElementClasses(): array
    {
        return [ColumnDefinition::class];
    }
}


text:
package net.sourceforge.stripes.validation;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Documented;

/**
 * Annotation used to capture the validation needs of nested properties within an ActionBean. It
 * contains a simple array of the Validate annotations.  Each Validate annotation must have its
 * field property set to the name of the field within the annotated property that is to be validated.
 *
 * @author Tim Fennell
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD, ElementType.METHOD})
@Documented
public @interface ValidateNestedProperties {
    Validate[] value();
}