text:
package test

import (
	"fmt"
	"reflect"
	"testing"

	"github.com/noypi/kv"
)

// tests focused on verifying that readers are isolated from writers

func CommonTestReaderIsolation(t *testing.T, s kv.KVStore) {
	// insert a kv pair
	writer, err := s.Writer()
	if err != nil {
		t.Error(err)
	}

	// **************************************************
	// this is a hack only required for BoltDB
	// however its harmless so to keep the tests
	// the same everywhere, we include it here
	//
	// this is a hack to try to pre-emptively overflow
	// boltdb writes *MAY* block a long reader
	// in particular, if the write requires additional
	// allocation, it must acquire the same lock as
	// the reader, thus cannot continue until that
	// reader is closed.
	// in general this is not a problem for bleve
	// (though it may affect performance in some cases)
	// but it is a problem for this test which attempts
	// to easily verify that readers are isolated
	// this hack writes enough initial data such that
	// the subsequent writes do not require additional
	// space
	hackSize := 1000
	batch := writer.NewBatch()
	for i := 0; i < hackSize; i++ {
		k := fmt.Sprintf("x%d", i)
		batch.Set([]byte(k), []byte("filler"))
	}
	err = writer.ExecuteBatch(batch)
	if err != nil {
		t.Fatal(err)
	}
	// **************************************************

	batch = writer.NewBatch()
	batch.Set([]byte("a"), []byte("val-a"))
	err = writer.ExecuteBatch(batch)
	if err != nil {
		t.Fatal(err)
	}
	err = writer.Close()
	if err != nil {
		t.Fatal(err)
	}

	// create an isolated reader
	reader, err := s.Reader()
	if err != nil {
		t.Error(err)
	}
	defer func() {
		err := reader.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()

	// verify that we see the value already inserted
	val, err := reader.Get([]byte("a"))
	if err != nil {
		t.Error(err)
	}
	if !reflect.DeepEqual(val, []byte("val-a")) {
		t.Errorf("expected val-a, got nil")
	}

	// verify that an iterator sees it
	count := 0
	it := reader.RangeIterator([]byte{0}, []byte{'x'})
	defer func() {
		err := it.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()
	for it.Valid() {
		it.Next()
		count++
	}
	if count != 1 {
		t.Errorf("expected iterator to see 1, saw %d", count)
	}

	// add something after the reader was created
	writer, err = s.Writer()
	if err != nil {
		t.Error(err)
	}
	batch = writer.NewBatch()
	batch.Set([]byte("b"), []byte("val-b"))
	err = writer.ExecuteBatch(batch)
	if err != nil {
		t.Fatal(err)
	}
	err = writer.Close()
	if err != nil {
		t.Fatal(err)
	}

	// ensure that a newer reader sees it
	newReader, err := s.Reader()
	if err != nil {
		t.Error(err)
	}
	defer func() {
		err := newReader.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()
	val, err = newReader.Get([]byte("b"))
	if err != nil {
		t.Error(err)
	}
	if !reflect.DeepEqual(val, []byte("val-b")) {
		t.Errorf("expected val-b, got nil")
	}

	// ensure that the direct iterator sees it
	count = 0
	it2 := newReader.RangeIterator([]byte{0}, []byte{'x'})
	defer func() {
		err := it2.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()
	for it2.Valid() {
		it2.Next()
		count++
	}
	if count != 2 {
		t.Errorf("expected iterator to see 2, saw %d", count)
	}

	// but that the isolated reader does not
	val, err = reader.Get([]byte("b"))
	if err != nil {
		t.Error(err)
	}
	if val != nil {
		t.Errorf("expected nil, got %v", val)
	}

	// and ensure that the iterator on the isolated reader also does not
	count = 0
	it3 := reader.RangeIterator([]byte{0}, []byte{'x'})
	defer func() {
		err := it3.Close()
		if err != nil {
			t.Fatal(err)
		}
	}()
	for it3.Valid() {
		it3.Next()
		count++
	}
	if count != 1 {
		t.Errorf("expected iterator to see 1, saw %d", count)
	}

}


text:
namespace Google.Analytics.Admin.V1Alpha.Snippets
{
    // [START analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetGlobalSiteTag_sync_flattened_resourceNames]
    using Google.Analytics.Admin.V1Alpha;

    public sealed partial class GeneratedAnalyticsAdminServiceClientSnippets
    {
        /// <summary>Snippet for GetGlobalSiteTag</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void GetGlobalSiteTagResourceNames()
        {
            // Create client
            AnalyticsAdminServiceClient analyticsAdminServiceClient = AnalyticsAdminServiceClient.Create();
            // Initialize request argument(s)
            GlobalSiteTagName name = GlobalSiteTagName.FromProperty("[PROPERTY]");
            // Make the request
            GlobalSiteTag response = analyticsAdminServiceClient.GetGlobalSiteTag(name);
        }
    }
    // [END analyticsadmin_v1alpha_generated_AnalyticsAdminService_GetGlobalSiteTag_sync_flattened_resourceNames]
}

redpajama_set_name: RedPajamaGithub


text:
class Vertex
{
public:
    // Constructors
    Vertex();
    explicit Vertex( const QVector3D& position );
    Vertex( const QVector3D& position, const QVector2D& uv );

    // Accessors & Mutators
    const QVector3D& position() const;
    const QVector2D& uv() const;
    void setPosition( const QVector3D& position );
    void setUV( const QVector2D& uv );

    // OpenGL Helpers
    static const int PositionTupleSize = 3;
    static const int UVTupleSize = 2;
    static int positionOffset();
    static int uvOffset();
    static int stride();

private:
    QVector3D m_position;
    QVector2D m_uv;
};

#endif  // VERTEX_H


text:
<?php

if(!isset($GLOBALS['rw_fmeow'])) die();

Model('DBConnect');
Model('Query');

function Vote($user_id, $vote_system, $temp = array()) {
    DBConnect();
    //var_dump($temp);die;
    $vs = addslashes($vote_system);
    $query = "DELETE FROM votes WHERE user_id = '$user_id' AND vote_system = '$vs';";
    Query($query);
    //var_dump($temp);die;
    foreach($temp as $key=>$value) {
        $vote_id = addslashes($key);
        $query = "SELECT id, mult FROM vote_systems WHERE id = '$vote_id'";
        $data = Query($query);
        $var = mysqli_fetch_assoc($data);
        if(isset($var['id']) and $var['id'] = $vote_id) {
            $mult = $var['mult'];
            $query = "SELECT id FROM vote_chooses WHERE vote_system = '$vs';";
            $data = Query($query);
            $chooses = array();
            while($var = mysqli_fetch_row($data)) {
                $chooses[$var[0]] = true;
            }
            if($mult) {
                foreach($value as $k=>$val) {
                    $vote = addslashes($k);
                    if(isset($chooses[$vote])) {
                        $query = "INSERT INTO votes (user_id, vote_system, vote_choose) VALUES ('$user_id', '$vote_id', '$vote');";
                        Query($query);
                    }
                    else{
                        ViewErrorPage("Форма ссылается на несуществующий выбор в голосовании!");
                    }
                }
            }
            else{
                $vote = addslashes($value);
                if(isset($chooses[$vote])) {
                    $query = "INSERT INTO votes (user_id, vote_system, vote_choose) VALUES ('$user_id', '$vote_id', '$vote');";
                    Query($query);
                }
                else{
                    ViewErrorPage("Форма ссылается на несуществующий выбор в голосовании!");
                }
            }
        }
        else{
            ViewErrorPage("Форма ссылается на несуществующее голосование.");
        }
    }
}


text:
/* Code generated by IfcQuery EXPRESS generator, www.ifcquery.com */
#pragma once
#include <vector>
#include <map>
#include <sstream>
#include <string>
#include "ifcpp/model/GlobalDefines.h"
#include "ifcpp/model/BasicTypes.h"
#include "ifcpp/model/BuildingObject.h"
class IFCQUERY_EXPORT IfcLabel;
class IFCQUERY_EXPORT IfcRepresentation;
//ENTITY
class IFCQUERY_EXPORT IfcRepresentationContext : public BuildingEntity
{
public:
	IfcRepresentationContext() = default;
	IfcRepresentationContext( int id );
	~IfcRepresentationContext() = default;
	virtual shared_ptr<BuildingObject> getDeepCopy( BuildingCopyOptions& options );
	virtual void getStepLine( std::stringstream& stream ) const;
	virtual void getStepParameter( std::stringstream& stream, bool is_select_type = false ) const;
	virtual void readStepArguments( const std::vector<std::wstring>& args, const std::map<int,shared_ptr<BuildingEntity> >& map );
	virtual void setInverseCounterparts( shared_ptr<BuildingEntity> ptr_self );
	virtual size_t getNumAttributes() { return 2; }
	virtual void getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const;
	virtual void getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const;
	virtual void unlinkFromInverseCounterparts();
	virtual const char* className() const { return "IfcRepresentationContext"; }
	virtual const std::wstring toString() const;

	// IfcRepresentationContext -----------------------------------------------------------
	// attributes:
	shared_ptr<IfcLabel>						m_ContextIdentifier;		//optional
	shared_ptr<IfcLabel>						m_ContextType;				//optional
	// inverse attributes:
	std::vector<weak_ptr<IfcRepresentation> >	m_RepresentationsInContext_inverse;
};


text:
package io.quarkus.cache.deployment.exception;

import org.jboss.jandex.DotName;

/**
 * This exception is thrown at build time during the validation phase if a class is annotated with
 * {@link io.quarkus.cache.CacheInvalidate @CacheInvalidate}, {@link io.quarkus.cache.CacheInvalidateAll @CacheInvalidateAll} or
 * {@link io.quarkus.cache.CacheResult @CacheResult}. These annotations are only allowed at type level for the caching
 * interceptors from this extension.
 */
@SuppressWarnings("serial")
public class ClassTargetException extends RuntimeException {

    private final DotName className;

    public ClassTargetException(DotName className, DotName annotationName) {
        super("Caching annotations are not allowed on a class [class=" + className + ", annotation=" + annotationName + "]");
        this.className = className;
    }

    public DotName getClassName() {
        return className;
    }
}


text:
<?php
namespace Mopsis\Extensions\Aura\Filter\Rule\Validate\DateTime;

class Concurrent extends AbstractDateTime
{
    public function __invoke($subject, $field, $datetime, $format = 'Y-m-d H:i:s')
    {
        if (is_scalar($datetime)) {
            $datetime = $subject->$datetime;
        }

        return isset($datetime) && $this->castValueToDateTime($subject->$field)->format($format) === $this->castValueToDateTime($datetime)->format($format);
    }
}


text:
package com.dianping.cat.report.page.matrix.service;

import java.util.Date;
import java.util.List;

import org.unidal.lookup.annotation.Inject;
import org.unidal.lookup.annotation.Named;

import com.dianping.cat.consumer.matrix.MatrixAnalyzer;
import com.dianping.cat.consumer.matrix.MatrixReportMerger;
import com.dianping.cat.consumer.matrix.model.entity.MatrixReport;
import com.dianping.cat.consumer.matrix.model.transform.DefaultSaxParser;
import com.dianping.cat.helper.TimeHelper;
import com.dianping.cat.mvc.ApiPayload;
import com.dianping.cat.report.ReportBucket;
import com.dianping.cat.report.ReportBucketManager;
import com.dianping.cat.report.service.LocalModelService;
import com.dianping.cat.report.service.ModelPeriod;
import com.dianping.cat.report.service.ModelRequest;

@Named(type = LocalModelService.class, value = LocalMatrixService.ID)
public class LocalMatrixService extends LocalModelService<MatrixReport> {

	public static final String ID = MatrixAnalyzer.ID;

	@Inject
	private ReportBucketManager m_bucketManager;

	public LocalMatrixService() {
		super(MatrixAnalyzer.ID);
	}

	@Override
	public String buildReport(ModelRequest request, ModelPeriod period, String domain, ApiPayload payload)
							throws Exception {
		List<MatrixReport> reports = super.getReport(period, domain);
		MatrixReport report = null;

		if (reports != null) {
			report = new MatrixReport(domain);
			MatrixReportMerger merger = new MatrixReportMerger(report);

			for (MatrixReport tmp : reports) {
				tmp.accept(merger);
			}
		}

		if ((report == null || report.getMatrixs().isEmpty()) && period.isLast()) {
			long startTime = request.getStartTime();
			report = getReportFromLocalDisk(startTime, domain);
		}
		return new MatrixReportFilter().buildXml(report);
	}

	private MatrixReport getReportFromLocalDisk(long timestamp, String domain) throws Exception {
		MatrixReport report = new MatrixReport(domain);
		MatrixReportMerger merger = new MatrixReportMerger(report);

		report.setStartTime(new Date(timestamp));
		report.setEndTime(new Date(timestamp + TimeHelper.ONE_HOUR - 1));

		for (int i = 0; i < getAnalyzerCount(); i++) {
			ReportBucket bucket = null;
			try {
				bucket = m_bucketManager.getReportBucket(timestamp, MatrixAnalyzer.ID, i);
				String xml = bucket.findById(domain);

				if (xml != null) {
					MatrixReport tmp = DefaultSaxParser.parse(xml);

					tmp.accept(merger);
				}
			} finally {
				if (bucket != null) {
					m_bucketManager.closeBucket(bucket);
				}
			}
		}
		return report;
	}

	public static class MatrixReportFilter extends com.dianping.cat.consumer.matrix.model.transform.DefaultXmlBuilder {
		public MatrixReportFilter() {
			super(true, new StringBuilder(DEFAULT_SIZE));
		}
	}
}


text: I am going to provide some python tools for things I don't want to do manually all the time.


text:
require "google/cloud/ai_platform/v1"

##
# Example demonstrating basic usage of
# Google::Cloud::AIPlatform::V1::MetadataService::Client#create_artifact
#
def create_artifact
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::AIPlatform::V1::MetadataService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::AIPlatform::V1::CreateArtifactRequest.new

  # Call the create_artifact method.
  result = client.create_artifact request

  # The returned object is of type Google::Cloud::AIPlatform::V1::Artifact.
  p result
end
# [END aiplatform_v1_generated_MetadataService_CreateArtifact_sync]