text:
package qbo

import (
	"context"
)

type BillService interface {
	Create(context.Context, *Bill) (*Bill, *Response, error)
	Read(context.Context, string) (*Bill, *Response, error)
	Update(context.Context, *Bill) (*Bill, *Response, error)
	Query(context.Context, string) ([]Bill, *Response, error)
}

type BillServiceClient struct {
	client *Client
}

var _ BillService = &BillServiceClient{}

type Bill struct {
	DueDate     string      `json:"DueDate"`
	Balance     int         `json:"Balance"`
	Domain      string      `json:"domain"`
	Sparse      bool        `json:"sparse"`
	ID          string      `json:"Id"`
	SyncToken   string      `json:"SyncToken"`
	MetaData    MetaData    `json:"MetaData"`
	TxnDate     string      `json:"TxnDate"`
	CurrencyRef CurrencyRef `json:"CurrencyRef"`
	PrivateNote string      `json:"PrivateNote"`
	LinkedTxn   []struct {
		TxnID   string `json:"TxnId"`
		TxnType string `json:"TxnType"`
	} `json:"LinkedTxn"`
	Line []struct {
		ID                            string  `json:"Id"`
		LineNum                       int     `json:"LineNum"`
		Amount                        float64 `json:"Amount"`
		DetailType                    string  `json:"DetailType"`
		AccountBasedExpenseLineDetail struct {
			AccountRef struct {
				Value string `json:"value"`
				Name  string `json:"name"`
			} `json:"AccountRef"`
			BillableStatus string `json:"BillableStatus"`
			TaxCodeRef     struct {
				Value string `json:"value"`
			} `json:"TaxCodeRef"`
		} `json:"AccountBasedExpenseLineDetail"`
	} `json:"Line"`
	VendorRef struct {
		Value string `json:"value"`
		Name  string `json:"name"`
	} `json:"VendorRef"`
	APAccountRef struct {
		Value string `json:"value"`
		Name  string `json:"name"`
	} `json:"APAccountRef"`
	TotalAmt float64 `json:"TotalAmt"`
}

func (a *BillServiceClient) Read(ctx context.Context, entityId string) (*Bill, *Response, error) {
	panic("implement me")
}

func (a *BillServiceClient) Create(ctx context.Context, account *Bill) (*Bill, *Response, error) {
	panic("implement me")
}

func (a *BillServiceClient) Update(context.Context, *Bill) (*Bill, *Response, error) {
	panic("implement me")
}

func (a *BillServiceClient) Query(context.Context, string) ([]Bill, *Response, error) {
	panic("implement me")
}

gha_language: Go


text:
// Copyright 2021 ZUP IT SERVICOS EM TECNOLOGIA E INOVACAO SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package core

type Manager struct {
	APIEndpoint      string `json:"react_app_horusec_endpoint_api"`
	AnalyticEndpoint string `json:"react_app_horusec_endpoint_analytic"`
	AccountEndpoint  string `json:"react_app_horusec_endpoint_account"`
	AuthEndpoint     string `json:"react_app_horusec_endpoint_auth"`
	ManagerEndpoint  string `json:"react_app_horusec_endpoint_manager"`
	ManagerPath      string `json:"react_app_horusec_manager_path"`
}

license_type: permissive

branch_name: refs/heads/main

extension: go


text:
package firebase

import (
	"crypto/rsa"
	"encoding/json"
	"errors"
	"io"

	"github.com/SermoDigital/jose/crypto"
	"golang.org/x/net/context"
	"golang.org/x/oauth2/jwt"
)

// GoogleServiceAccountCredential is the credential for a GCP Service Account.
type GoogleServiceAccountCredential struct {
	// ProjectID is the project ID.
	ProjectID string
	// PrivateKey is the RSA256 private key.
	PrivateKey *rsa.PrivateKey
	// PrivateKeyString is the private key represented in string.
	PrivateKeyString string
	// ClientEmail is the client email.
	ClientEmail string
}

// UnmarshalJSON is the custom unmarshaler for GoogleServiceAccountCredential.
// Private key is parsed from PEM format.
func (c *GoogleServiceAccountCredential) UnmarshalJSON(data []byte) error {
	var aux struct {
		ProjectID   string `json:"project_id"`
		PrivateKey  string `json:"private_key"`
		ClientEmail string `json:"client_email"`
	}
	if err := json.Unmarshal(data, &aux); err != nil {
		return err
	}

	privKey, err := crypto.ParseRSAPrivateKeyFromPEM([]byte(aux.PrivateKey))
	if err != nil {
		return err
	}
	c.PrivateKey = privKey
	c.PrivateKeyString = aux.PrivateKey

	c.ProjectID = aux.ProjectID
	c.ClientEmail = aux.ClientEmail
	return nil
}

// loadCredential loads the Service Account credential from a JSON file.
func loadCredential(r io.Reader) (*GoogleServiceAccountCredential, error) {
	var c GoogleServiceAccountCredential
	if err := json.NewDecoder(r).Decode(&c); err != nil {
		return nil, err
	}
	return &c, nil
}

const (
	// jwtTokenURL is Google's OAuth 2.0 token URL to use with the JWT flow.
	jwtTokenURL = "https://accounts.google.com/o/oauth2/token"
)

var (
	scopes = []string{
		"https://www.googleapis.com/auth/userinfo.email",
		"https://www.googleapis.com/auth/firebase.database",
		"https://www.googleapis.com/auth/firebase.messaging",
		"https://www.googleapis.com/auth/identitytoolkit",
	}
)

func (auth *Auth) ensureTokenSource() error {
	auth.tsLock.Lock()
	defer auth.tsLock.Unlock()
	if auth.ts != nil {
		return nil
	}
	cred := auth.app.options.ServiceAccountCredential
	if cred == nil {
		return errors.New("no service account credential found")
	}

	cfg := &jwt.Config{
		Email:      cred.ClientEmail,
		PrivateKey: []byte(cred.PrivateKeyString),
		Scopes:     append([]string{}, scopes...),
		TokenURL:   jwtTokenURL,
	}
	auth.ts = cfg.TokenSource(context.TODO())
	return nil
}

repository: RetroRabbit/firebase-server-sdk-go

repo_name: RetroRabbit/firebase-server-sdk-go

branch_name: refs/heads/master


text:
include(FetchContent)

set(FETCHCONTENT_QUIET ON)

FetchContent_Declare(
    fmt
    GIT_REPOSITORY https://github.com/fmtlib/fmt
    GIT_TAG        6.2.1
    GIT_PROGRESS   TRUE
    USES_TERMINAL_DOWNLOAD TRUE
    GIT_CONFIG     advice.detachedHead=false
)

FetchContent_MakeAvailable(fmt)

extension: cmake


text:
/*
	Copyright 2019 Netfoundry, Inc.

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	https://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

package predicate

import (
	"fmt"
	"gopkg.in/Masterminds/squirrel.v1"
)

//type Sqlizer interface {
//	Parts() (string, []interface{}, error)
//}

type binaryOp struct {
	Identifier string
	LeftValue  interface{}
	RightValue interface{}
}

type unaryOp struct {
	Identifier string
	value      interface{}
}

type Between binaryOp

func newBetween(identifier string, leftValue, rightValue interface{}) Between {
	return Between{
		Identifier: identifier,
		LeftValue:  leftValue,
		RightValue: rightValue,
	}
}

func (b Between) ToSql() (string, []interface{}, error) {
	args := []interface{}{b.LeftValue, b.RightValue}
	sql := fmt.Sprintf("%s BETWEEN %s AND %s", b.Identifier, "?", "?")
	return sql, args, nil
}

type NotBetween binaryOp

func newNotBetween(identifier string, leftValue, rightValue interface{}) NotBetween {
	return NotBetween{
		Identifier: identifier,
		LeftValue:  leftValue,
		RightValue: rightValue,
	}
}

func (b NotBetween) ToSql() (string, []interface{}, error) {
	args := []interface{}{b.LeftValue, b.RightValue}
	sql := fmt.Sprintf("%s NOT BETWEEN %s AND %s", b.Identifier, "?", "?")
	return sql, args, nil
}

type Contains unaryOp

func newContains(identifier, value string) Contains {
	return Contains{
		Identifier: identifier,
		value:      value,
	}
}

func (c Contains) ToSql() (string, []interface{}, error) {
	v := fmt.Sprintf("%%%s%%", c.value)

	args := []interface{}{v}

	sql := fmt.Sprintf("%s LIKE %s", c.Identifier, "?")

	return sql, args, nil
}

type NotContains unaryOp

func newNotContains(identifier, value string) NotContains {
	return NotContains{
		Identifier: identifier,
		value:      value,
	}
}

func (c NotContains) ToSql() (string, []interface{}, error) {
	v := fmt.Sprintf("%%%s%%", c.value)

	args := []interface{}{v}

	sql := fmt.Sprintf("%s NOT LIKE %s", c.Identifier, "?")

	return sql, args, nil
}

type InSubSelect struct {
	Column string
	Select squirrel.SelectBuilder
}

func (ss InSubSelect) ToSql() (string, []interface{}, error) {
	s, b, err := ss.Select.ToSql()
	return fmt.Sprintf("%s IN (%s)", ss.Column, s), b, err
}

repository: triplekill/ziti-edge

repo_name: triplekill/ziti-edge


text:
# This recipe tracks the 'bleeding edge' linux-xlnx repository.
# Since this tree is frequently updated, AUTOREV is used to track its contents.
#
# To enable this recipe, set PREFERRED_PROVIDER_virtual/kernel = "linux-digilent-dev"

include linux-digilent.inc

license: MIT

repository: socnix-lab/meta-xilinx

repo_name: socnix-lab/meta-xilinx

extension: bb


text:
package main

import (
	"errors"
	"fmt"
	"github.com/Symantec/Dominator/imageserver/client"
	"github.com/Symantec/Dominator/lib/filesystem"
	"github.com/Symantec/Dominator/lib/objectclient"
	"github.com/Symantec/Dominator/lib/srpc"
	"github.com/Symantec/Dominator/proto/imageserver"
	"net/rpc"
	"os"
)

func addReplaceImageSubcommand(args []string) {
	imageClient, imageSClient, objectClient := getClients()
	err := addReplaceImage(imageClient, imageSClient, objectClient, args[0],
		args[1], args[2:])
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error adding image: \"%s\"\t%s\n", args[0], err)
		os.Exit(1)
	}
	os.Exit(0)
}

func addReplaceImage(imageClient *rpc.Client, imageSClient *srpc.Client,
	objectClient *objectclient.ObjectClient,
	name, baseImageName string, layerImageNames []string) error {
	var request imageserver.AddImageRequest
	var reply imageserver.AddImageResponse
	imageExists, err := checkImage(imageClient, name)
	if err != nil {
		return errors.New("error checking for image existance: " + err.Error())
	}
	if imageExists {
		return errors.New("image exists")
	}
	request.ImageName = name
	request.Image, err = getImage(imageSClient, baseImageName)
	if err != nil {
		return err
	}
	baseFilenameToInodeTable := buildFilenameToInodeTable(
		request.Image.FileSystem)
	for _, layerImageName := range layerImageNames {
		fs, err := buildImage(objectClient, request.Image.Filter, layerImageName)
		if err != nil {
			return err
		}
		if err := layerImages(request.Image.FileSystem, baseFilenameToInodeTable,
			fs); err != nil {
			return err
		}
	}
	request.Image.FileSystem.InodeToFilenamesTable = nil
	err = client.CallAddImage(imageSClient, request, &reply)
	if err != nil {
		return errors.New("remote error: " + err.Error())
	}
	return nil
}

func buildFilenameToInodeTable(fs *filesystem.FileSystem) map[string]uint64 {
	fs.BuildInodeToFilenamesTable()
	table := make(map[string]uint64)
	for inum, filenames := range fs.InodeToFilenamesTable {
		for _, filename := range filenames {
			table[filename] = inum
		}
	}
	return table
}

func layerImages(baseFS *filesystem.FileSystem,
	baseFilenameToInodeTable map[string]uint64,
	layerFS *filesystem.FileSystem) error {
	layerFilenameToInodeTable := buildFilenameToInodeTable(layerFS)
	for filename, layerInum := range layerFilenameToInodeTable {
		layerInode := layerFS.InodeTable[layerInum]
		if _, ok := layerInode.(*filesystem.DirectoryInode); ok {
			continue
		}
		baseInum, ok := baseFilenameToInodeTable[filename]
		if !ok {
			return errors.New(filename + " missing in base image")
		}
		baseInode := baseFS.InodeTable[baseInum]
		sameType, sameMetadata, sameData := filesystem.CompareInodes(baseInode,
			layerInode, nil)
		if !sameType {
			return errors.New(filename + " changed type")
		}
		if sameMetadata && sameData {
			continue
		}
		baseFS.InodeTable[baseInum] = layerInode
	}
	return nil
}

repository: kp-hk/Dominator

repo_name: kp-hk/Dominator


text:
package main_test

import (
	"os/user"
	"testing"
)

// TestMain : check to see if user exist
func TestMain(t *testing.T) {

	t.Run("User should exist",
		func(t *testing.T) {
			usr, errCurr := user.Current()
			if errCurr != nil {
				t.Errorf("Unable to get user %v [unexpected]", errCurr)
			}

			if usr != nil {
				t.Logf("Current user exist: %v  [expected]\n", usr.HomeDir)
			} else {
				t.Error("Unable to get user [unexpected]")
			}
		},
	)
}

repository: warrensbox/terraform-switcher

repo_name: warrensbox/terraform-switcher

gha_license_id: MIT

gha_language: HTML


text:
package main

import (
	"github.com/georgi-bozhinov/auth-server/server"
	"github.com/georgi-bozhinov/auth-server/server/api"
	"github.com/georgi-bozhinov/auth-server/server/config"
	"github.com/georgi-bozhinov/auth-server/server/storage"
	"log"
)

func BuildAuthServer(db storage.Storage) *server.Server {
	a := api.NewAPI(db)
	s := server.NewServer(server.Config{Port: "8000"}, a)

	return s
}

func main() {
	// config := readConfigFromFile(file)
	// config.DB
	// config.Server

	cfg := config.Config{DB: storage.Config{
		User:     "postgres",
		Password: "postgres",
		Host:     "localhost",
		DbName:   "authserver",
		Type:     "postgres",
	}}

	db, err := storage.New(cfg.DB)

	if err != nil {
		log.Fatalf("Unable to initialize db: %v", err)
	}

	srv := BuildAuthServer(db)

	if err := srv.Start(); err != nil {
		log.Fatalf("Unable to initialize auth server: %v", err)
	}
}

repository: georgi-bozhinov/auth-server

repo_name: georgi-bozhinov/auth-server


text:
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/jackc/pgx/v5 (interfaces: Row,Rows)

// Package mocks is a generated GoMock package.
package mocks

import (
	reflect "reflect"

	pgx "github.com/jackc/pgx/v5"
	pgconn "github.com/jackc/pgx/v5/pgconn"
	gomock "go.uber.org/mock/gomock"
)

// Row is a mock of Row interface.
type Row struct {
	ctrl     *gomock.Controller
	recorder *RowMockRecorder
}

// RowMockRecorder is the mock recorder for Row.
type RowMockRecorder struct {
	mock *Row
}

// NewRow creates a new mock instance.
func NewRow(ctrl *gomock.Controller) *Row {
	mock := &Row{ctrl: ctrl}
	mock.recorder = &RowMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *Row) EXPECT() *RowMockRecorder {
	return m.recorder
}

// Scan mocks base method.
func (m *Row) Scan(arg0 ...interface{}) error {
	m.ctrl.T.Helper()
	varargs := []interface{}{}
	for _, a := range arg0 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "Scan", varargs...)
	ret0, _ := ret[0].(error)
	return ret0
}

// Scan indicates an expected call of Scan.
func (mr *RowMockRecorder) Scan(arg0 ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*Row)(nil).Scan), arg0...)
}

// Rows is a mock of Rows interface.
type Rows struct {
	ctrl     *gomock.Controller
	recorder *RowsMockRecorder
}

// RowsMockRecorder is the mock recorder for Rows.
type RowsMockRecorder struct {
	mock *Rows
}

// NewRows creates a new mock instance.
func NewRows(ctrl *gomock.Controller) *Rows {
	mock := &Rows{ctrl: ctrl}
	mock.recorder = &RowsMockRecorder{mock}
	return mock
}

// EXPECT returns an object that allows the caller to indicate expected use.
func (m *Rows) EXPECT() *RowsMockRecorder {
	return m.recorder
}

// Close mocks base method.
func (m *Rows) Close() {
	m.ctrl.T.Helper()
	m.ctrl.Call(m, "Close")
}

// Close indicates an expected call of Close.
func (mr *RowsMockRecorder) Close() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*Rows)(nil).Close))
}

// CommandTag mocks base method.
func (m *Rows) CommandTag() pgconn.CommandTag {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "CommandTag")
	ret0, _ := ret[0].(pgconn.CommandTag)
	return ret0
}

// CommandTag indicates an expected call of CommandTag.
func (mr *RowsMockRecorder) CommandTag() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommandTag", reflect.TypeOf((*Rows)(nil).CommandTag))
}

// Conn mocks base method.
func (m *Rows) Conn() *pgx.Conn {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Conn")
	ret0, _ := ret[0].(*pgx.Conn)
	return ret0
}

// Conn indicates an expected call of Conn.
func (mr *RowsMockRecorder) Conn() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Conn", reflect.TypeOf((*Rows)(nil).Conn))
}

// Err mocks base method.
func (m *Rows) Err() error {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Err")
	ret0, _ := ret[0].(error)
	return ret0
}

// Err indicates an expected call of Err.
func (mr *RowsMockRecorder) Err() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Err", reflect.TypeOf((*Rows)(nil).Err))
}

// FieldDescriptions mocks base method.
func (m *Rows) FieldDescriptions() []pgconn.FieldDescription {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "FieldDescriptions")
	ret0, _ := ret[0].([]pgconn.FieldDescription)
	return ret0
}

// FieldDescriptions indicates an expected call of FieldDescriptions.
func (mr *RowsMockRecorder) FieldDescriptions() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FieldDescriptions", reflect.TypeOf((*Rows)(nil).FieldDescriptions))
}

// Next mocks base method.
func (m *Rows) Next() bool {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Next")
	ret0, _ := ret[0].(bool)
	return ret0
}

// Next indicates an expected call of Next.
func (mr *RowsMockRecorder) Next() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Next", reflect.TypeOf((*Rows)(nil).Next))
}

// RawValues mocks base method.
func (m *Rows) RawValues() [][]byte {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "RawValues")
	ret0, _ := ret[0].([][]byte)
	return ret0
}

// RawValues indicates an expected call of RawValues.
func (mr *RowsMockRecorder) RawValues() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RawValues", reflect.TypeOf((*Rows)(nil).RawValues))
}

// Scan mocks base method.
func (m *Rows) Scan(arg0 ...interface{}) error {
	m.ctrl.T.Helper()
	varargs := []interface{}{}
	for _, a := range arg0 {
		varargs = append(varargs, a)
	}
	ret := m.ctrl.Call(m, "Scan", varargs...)
	ret0, _ := ret[0].(error)
	return ret0
}

// Scan indicates an expected call of Scan.
func (mr *RowsMockRecorder) Scan(arg0 ...interface{}) *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Scan", reflect.TypeOf((*Rows)(nil).Scan), arg0...)
}

// Values mocks base method.
func (m *Rows) Values() ([]interface{}, error) {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Values")
	ret0, _ := ret[0].([]interface{})
	ret1, _ := ret[1].(error)
	return ret0, ret1
}

// Values indicates an expected call of Values.
func (mr *RowsMockRecorder) Values() *gomock.Call {
	mr.mock.ctrl.T.Helper()
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Values", reflect.TypeOf((*Rows)(nil).Values))
}

repository: ViBiOh/ketchup

repo_name: ViBiOh/ketchup


text:
package yamltopara

import (
    "io/ioutil"
    "log"
	// "fmt"
    // "sort"
    // "strings"
    // "strconv"

    "gopkg.in/yaml.v2"
)

// Get dataset info
func GetDataSetInfo(dir string) DatasetInfo {
    var datasetinfo Yaml2GoDatasetInfo
    path := "../slice-requests/" + dir + "/DataSet-parameter.yaml"
    yamlFile, err := ioutil.ReadFile(path)
    if err != nil {
        log.Printf("yamlFile.Get err   #%v ", err)
    }
    err = yaml.Unmarshal(yamlFile, &datasetinfo)
    if err != nil {
        panic(err)
    }
    return datasetinfo.DatasetInfo
}


text:
// Code generated by go-swagger; DO NOT EDIT.

// Copyright 2017-2020 Authors of Cilium
// SPDX-License-Identifier: Apache-2.0

package core_v1

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command

import (
	"net/http"

	"github.com/go-openapi/runtime/middleware"
)

// WatchCoreV1PersistentVolumeListHandlerFunc turns a function with the right signature into a watch core v1 persistent volume list handler
type WatchCoreV1PersistentVolumeListHandlerFunc func(WatchCoreV1PersistentVolumeListParams) middleware.Responder

// Handle executing the request and returning a response
func (fn WatchCoreV1PersistentVolumeListHandlerFunc) Handle(params WatchCoreV1PersistentVolumeListParams) middleware.Responder {
	return fn(params)
}

// WatchCoreV1PersistentVolumeListHandler interface for that can handle valid watch core v1 persistent volume list params
type WatchCoreV1PersistentVolumeListHandler interface {
	Handle(WatchCoreV1PersistentVolumeListParams) middleware.Responder
}

// NewWatchCoreV1PersistentVolumeList creates a new http.Handler for the watch core v1 persistent volume list operation
func NewWatchCoreV1PersistentVolumeList(ctx *middleware.Context, handler WatchCoreV1PersistentVolumeListHandler) *WatchCoreV1PersistentVolumeList {
	return &WatchCoreV1PersistentVolumeList{Context: ctx, Handler: handler}
}

/*WatchCoreV1PersistentVolumeList swagger:route GET /api/v1/watch/persistentvolumes core_v1 watchCoreV1PersistentVolumeList

watch individual changes to a list of PersistentVolume. deprecated: use the 'watch' parameter with a list operation instead.

*/
type WatchCoreV1PersistentVolumeList struct {
	Context *middleware.Context
	Handler WatchCoreV1PersistentVolumeListHandler
}

func (o *WatchCoreV1PersistentVolumeList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
	route, rCtx, _ := o.Context.RouteInfo(r)
	if rCtx != nil {
		r = rCtx
	}
	var Params = NewWatchCoreV1PersistentVolumeListParams()

	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
		o.Context.Respond(rw, r, route.Produces, route, err)
		return
	}

	res := o.Handler.Handle(Params) // actually handle the request

	o.Context.Respond(rw, r, route.Produces, route, res)

}

repository: cilium/kube-apate

repo_name: cilium/kube-apate


text:
package lvmserver

import (
	"fmt"
	"github.com/tidb-incubator/Serverlessdb-for-HTAP/pkg/he3local/util"
	"os"
	//"errors"
	"context"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
	"k8s.io/utils/mount"
	"strings"
)

const (
	// NsenterCmd is the nsenter command
	NsenterCmd = "nsenter --mount=/proc/1/ns/mnt"
)

func CreateSnap(ctx context.Context, snapshotID string, volumeID string, vgName string, size string, s3env string,fstype string) error {

	err := createSnapVolume(ctx, snapshotID, volumeID, vgName, size)

	if err != nil {
		fmt.Printf("create snapvoluem is %s \n", err)
		return err
	}

	transnapid := strings.ReplaceAll(snapshotID, "-", "--")

	snapdevicepath := fmt.Sprintf("/dev/mapper/%s-%s", vgName, transnapid)

	mountspappath := fmt.Sprintf("/csi-data-dir/%s-snap", snapshotID)

	if _, err := os.Stat(mountspappath); os.IsNotExist(err) {
		if err := os.MkdirAll(mountspappath, 0750); err != nil {
			return status.Error(codes.Internal, err.Error())
		}
	}
	fmt.Printf("mount vol %s,%s \n", snapdevicepath, mountspappath)
	err = util.MountVolforDeviceForSnap(ctx, snapdevicepath, mountspappath, fstype)

	if err != nil {
		fmt.Printf("mountVolforDevice is %s \n", err)
		mount.New("").Unmount(mountspappath)
		deletesnapvolume(snapdevicepath)
		//add code to delet s3 resource
		return err
	}

	fmt.Printf("mirror to s3 %s,%s,%s \n", mountspappath, snapshotID, s3env)
	err = util.MirrorDevicetoS3(ctx, mountspappath, snapshotID, s3env)

	if err != nil {
		fmt.Printf("mirrorfiletoS3 is %s \n", err)
		//add code to delet s3 resource
		mount.New("").Unmount(mountspappath)
		deletesnapvolume(snapdevicepath)
		return err
	}

	fmt.Printf("unmout %s \n", mountspappath)
	err = mount.New("").Unmount(mountspappath)
	if err != nil {
		fmt.Printf("err is %s \n", err)
		deletesnapvolume(snapdevicepath)
		return status.Error(codes.Internal, err.Error())
		//add code to delet s3 resource
	}

	fmt.Printf("delete snap vilume %s \n", snapdevicepath)
	err = deletesnapvolume(snapdevicepath)

	if err != nil {
		return status.Error(codes.Internal, err.Error())
		//add code to delet s3 resource
	}

	fmt.Printf("remove %s \n", mountspappath)
	// Delete the mount point.
	// Does not return error for non-existent path, repeated calls OK for idempotency.
	if err = os.RemoveAll(mountspappath); err != nil {
		return status.Error(codes.Internal, err.Error())
		//add code to delet s3 resource
	}
	return nil
}
func deletesnapvolume(snapdevice string) error {

	cmd := fmt.Sprintf("%s lvremove  %s -y", NsenterCmd, snapdevice)
	_, err := util.Runcmd(cmd)
	if err != nil {
		return err
	}
	return nil
}

// create lvm volume
func createSnapVolume(ctx context.Context, snapID, volumeID, vgName, size string) error {

	var err error

	// check vg exist
	ckCmd := fmt.Sprintf("%s vgck %s", NsenterCmd, vgName)
	_, err = util.Runcmd(ckCmd)
	if err != nil {
		fmt.Printf("createVolume:: VG is not exist: %s \n", vgName)
		return err
	}

	cmd := fmt.Sprintf("%s lvcreate -L %s --snapshot --name %s %s/%s", NsenterCmd, size, snapID, vgName, volumeID)
	_, err = util.Runcmd(cmd)
	if err != nil {
		return err
	}

	fmt.Printf("Successful Create Linear LVM volume: %s, Size: %s, vgName: %s", volumeID, size, vgName)

	return nil
}

repository: shenzhengcmss/Serverlessdb-for-HTAP

repo_name: shenzhengcmss/Serverlessdb-for-HTAP


text:
@MISC{Cardoso07KeynotePNIS,
author = {Cardoso, Jorge},
title = {Quality Metrics for Business Processes},
year = {2007},
address = {Zaragoza, Spain},
date = {September 11, 2007},
keywords = {Keynote},
owner = {Jorge Cardoso},
publisher = {I Taller sobre Procesos de Negocio e Ingenieria del Software (PNIS	2007)},
refid = {69},
timestamp = {2010.08.26},
url = {Keynotes/PNIS07-Keynote.pdf}}

extension: bib


text:
@article{bloom,
    author    = "Bloom, Burton H.",
    title     = "Space/Time Trade-offs in Hash Coding with Allowable Errors",
    journal =      "Communications of the ACM",
    volume =       "13",
    number =       "7",
    pages =        "422--426",
    year =         "1970",
}

repository: monadplus/bloom-filter

repo_name: monadplus/bloom-filter


text:
// Copyright (c) 2018-2022, R.I. Pienaar and the Choria Project contributors
//
// SPDX-License-Identifier: Apache-2.0

package agent

import (
	"bytes"
	"encoding/json"
	"fmt"
	"math"
	"os"
	"reflect"
	"sort"
	"strings"
	"text/template"
	"time"

	"github.com/choria-io/go-choria/internal/fs"
	"github.com/choria-io/go-choria/providers/agent/mcorpc/ddl/common"
	"github.com/choria-io/go-choria/server/agents"
)

// DDL represents the schema of a mcorpc agent and is at a basic level
// compatible with the mcollective agent ddl format
type DDL struct {
	Schema         string           `json:"$schema"`
	Metadata       *agents.Metadata `json:"metadata"`
	Actions        []*Action        `json:"actions"`
	SourceLocation string           `json:"-"`
}

func NewFromBytes(dat []byte) (*DDL, error) {
	ddl := &DDL{}

	err := json.Unmarshal(dat, ddl)
	if err != nil {
		return nil, fmt.Errorf("could not parse DDL JSON data: %s", err)
	}

	ddl.normalize()

	return ddl, nil
}

// New creates a new DDL from a JSON file
func New(file string) (*DDL, error) {
	dat, err := os.ReadFile(file)
	if err != nil {
		return nil, fmt.Errorf("could not load DDL data: %s", err)
	}

	ddl, err := NewFromBytes(dat)
	if err != nil {
		return nil, err
	}

	ddl.SourceLocation = file

	return ddl, nil
}

// FindLocally looks in the supplied libdirs for a DDL file for a specific agent
// TODO: remove
func FindLocally(agent string, libdirs []string) (*DDL, error) {
	ddl, _ := CachedDDL(agent)
	if ddl != nil {
		return ddl, nil
	}

	var err error
	common.EachFile("agent", libdirs, func(n string, f string) bool {
		if n == agent {
			ddl, err = New(f)
			return true
		}

		return false
	})

	if err != nil {
		return nil, fmt.Errorf("could not load agent %s: %s", agent, err)
	}

	if ddl == nil {
		return nil, fmt.Errorf("could not find DDL file for agent %s", agent)
	}

	return ddl, nil
}

func (d *DDL) normalize() {
	for _, action := range d.Actions {
		if action.Display == "" {
			action.Display = "failed"
		}
	}
}

// ActionNames is a list of known actions defined by a DDL
func (d *DDL) ActionNames() []string {
	actions := []string{}

	if d.Actions != nil {
		for _, act := range d.Actions {
			actions = append(actions, act.Name)
		}
	}

	sort.Strings(actions)

	return actions
}

// ActionInterface looks up an Action by name
func (d *DDL) ActionInterface(action string) (*Action, error) {
	for _, act := range d.Actions {
		if act.Name == action {
			return act, nil
		}
	}

	return nil, fmt.Errorf("unknown action %s#%s", d.Metadata.Name, action)
}

// HaveAction determines if an action is known
func (d *DDL) HaveAction(action string) bool {
	_, err := d.ActionInterface(action)
	return err == nil
}

// Timeout is the timeout for this agent
func (d *DDL) Timeout() time.Duration {
	if d.Metadata.Timeout == 0 {
		return 10 * time.Second
	}

	return time.Second * time.Duration(d.Metadata.Timeout)
}

// ValidateAndConvertToDDLTypes converts args to the correct data types as declared in the DDL and validates everything
func (d *DDL) ValidateAndConvertToDDLTypes(action string, args map[string]string) (result map[string]any, warnings []string, err error) {
	acti, err := d.ActionInterface(action)
	if err != nil {
		return result, warnings, err
	}

	return acti.ValidateAndConvertToDDLTypes(args)
}

// ToRuby generates a ruby DDL from a go DDL
func (d *DDL) ToRuby() (string, error) {
	var out bytes.Buffer

	funcs := template.FuncMap{
		"fmtAggregateArguments": func(output string, v json.RawMessage) string {
			var args []any
			err := json.Unmarshal(v, &args)
			if err != nil {
				return fmt.Sprintf(":%s", output)
			}

			switch len(args) {
			case 1:
				return fmt.Sprintf(":%v", args[0])
			case 2:
				opts := ""
				margs, ok := args[1].(map[string]any)
				if ok {
					for k, v := range margs {
						vs, ok := v.(string)
						if ok {
							opts = fmt.Sprintf(":%s => %q", k, vs)
						}
					}
					return fmt.Sprintf(":%v, %s", args[0], opts)
				}

				return fmt.Sprintf(":%v", args[0])

			default:
				return fmt.Sprintf(":%s", output)
			}
		},
		"validatorStr": func(v string) string {
			if v == "" {
				return `"."`
			}

			switch v {
			case "shellsafe", "ipv4address", "ipv6address", "ipaddress":
				return ":" + v
			default:
				return `'` + v + `'`
			}
		},

		"enum2list": func(v []string) string {
			if len(v) == 0 {
				return "[]"
			}

			return `["` + strings.Join(v, `", "`) + `"]`
		},

		"goval2rubyval": func(typedef string, v any) string {
			if v == nil {
				return `nil`
			}

			switch typedef {
			case "string", "list":
				if v == nil {
					return `""`
				}

				return fmt.Sprintf(`"%s"`, v.(string))
			case "float", "number":
				if v == nil {
					return "0.0"
				}

				switch val := reflect.ValueOf(v); val.Kind() {
				case reflect.Int:
					return fmt.Sprintf("%d", v.(int))

				case reflect.Int16:
					return fmt.Sprintf("%d", v.(int16))

				case reflect.Int32:
					return fmt.Sprintf("%d", v.(int32))

				case reflect.Int64:
					return fmt.Sprintf("%d", v.(int64))

				case reflect.Float32:
					return fmt.Sprintf("%f", math.Round(float64(v.(float32))))

				case reflect.Float64:
					return fmt.Sprintf("%f", math.Round(v.(float64)))

				default:
					panic(fmt.Sprintf("unknown value type %v found in %s field", val.Kind(), typedef))
				}

			case "integer":
				if v == nil {
					return "0"
				}

				switch val := reflect.ValueOf(v); val.Kind() {
				case reflect.Int:
					return fmt.Sprintf("%d", v.(int))

				case reflect.Int16:
					return fmt.Sprintf("%d", v.(int16))

				case reflect.Int32:
					return fmt.Sprintf("%d", v.(int32))

				case reflect.Int64:
					return fmt.Sprintf("%d", v.(int64))

				case reflect.Float32:
					return fmt.Sprintf("%.0f", math.Round(float64(v.(float32))))

				case reflect.Float64:
					return fmt.Sprintf("%.0f", math.Round(v.(float64)))

				default:
					panic(fmt.Sprintf("unknown value type %v found in %s field", val.Kind(), typedef))
				}

			case "boolean":
				if v == nil {
					return "false"
				}

				return fmt.Sprintf("%v", v.(bool))
			}

			return `nil`
		},
	}

	rubyDDLTemplate, err := fs.FS.ReadFile("ddl/agent_ruby_ddl.templ")
	if err != nil {
		return "", err
	}

	tpl := template.Must(template.New(d.Metadata.Name).Funcs(funcs).Parse(string(rubyDDLTemplate)))
	err = tpl.Execute(&out, d)
	return out.String(), err
}

repository: choria-io/go-choria

repo_name: choria-io/go-choria


text:
SUMMARY = "RADIUS tools"
SECTION = "devel/python"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=debd8dc49cd9a7d58c7fffc771efed4f"

PYPI_PACKAGE = "pyrad"
SRC_URI[sha256sum] = "89c4d9b2cab1746c48dc0d93898d278e34a40acedf6f511aeaa748bcd4490295"

inherit pypi setuptools3

repository: zsp-test/meta-openembedded

repo_name: zsp-test/meta-openembedded


text:
@Proceedings{BuntineACML2012,
  booktitle = {Asian Conference on Machine Learning},
  editor = {Steven C. H. Hoi and Wray Buntine},
  publisher = {JMLR Workshop and Conference Proceedings},
  volume = {25},
  year = {2012},
  shortname = {ACML 2012},
  sections = {preface=Preface|default=Accepted Papers}
}

repository: mreid/papersite

repo_name: mreid/papersite

gha_language: TeX


text:
// run

// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

type T struct{ A, B int } // TODO: fields should be unexported

func println(x, y int) {}

func f(x interface{}) interface{} {
	type T struct{ A, B int } // TODO: fields should be unexported

	if x == nil {
		return T{2, 3}
	}

	t := x.(T)
	println(t.A, t.B)
	return x
}

func main() {
	inner_T := f(nil)
	f(inner_T)

	shouldPanic(p1)
}

func p1() {
	outer_T := T{5, 7}
	f(outer_T)
}

func shouldPanic(f func()) {
	defer func() {
		if recover() == nil {
			panic("function should panic")
		}
	}()
	f()
}

/*
This prints:

2 3
5 7

but it should crash: The type assertion on line 18 should fail
for the 2nd call to f with outer_T.
*/


text:
// generated by go run gen.go; DO NOT EDIT

package atom

const (
	A                Atom = 0x1
	Abbr             Atom = 0x4
	Accept           Atom = 0x2106
	AcceptCharset    Atom = 0x210e
	Accesskey        Atom = 0x3309
	Action           Atom = 0x21b06
	Address          Atom = 0x5d507
	Align            Atom = 0x1105
	Alt              Atom = 0x4503
	Annotation       Atom = 0x18d0a
	AnnotationXml    Atom = 0x18d0e
	Applet           Atom = 0x2d106
	Area             Atom = 0x31804
	Article          Atom = 0x39907
	Aside            Atom = 0x4f05
	Async            Atom = 0x9305
	Audio            Atom = 0xaf05
	Autocomplete     Atom = 0xd50c
	Autofocus        Atom = 0xe109
	Autoplay         Atom = 0x10c08
	B                Atom = 0x101
	Base             Atom = 0x11404
	Basefont         Atom = 0x11408
	Bdi              Atom = 0x1a03
	Bdo              Atom = 0x12503
	Bgsound          Atom = 0x13807
	Big              Atom = 0x14403
	Blink            Atom = 0x14705
	Blockquote       Atom = 0x14c0a
	Body             Atom = 0x2f04
	Border           Atom = 0x15606
	Br               Atom = 0x202
	Button           Atom = 0x15c06
	Canvas           Atom = 0x4b06
	Caption          Atom = 0x1e007
	Center           Atom = 0x2df06
	Challenge        Atom = 0x23e09
	Charset          Atom = 0x2807
	Checked          Atom = 0x33f07
	Cite             Atom = 0x9704
	Class            Atom = 0x3d905
	Code             Atom = 0x16f04
	Col              Atom = 0x17603
	Colgroup         Atom = 0x17608
	Color            Atom = 0x18305
	Cols             Atom = 0x18804
	Colspan          Atom = 0x18807
	Command          Atom = 0x19b07
	Content          Atom = 0x42c07
	Contenteditable  Atom = 0x42c0f
	Contextmenu      Atom = 0x3480b
	Controls         Atom = 0x1ae08
	Coords           Atom = 0x1ba06
	Crossorigin      Atom = 0x1c40b
	Data             Atom = 0x44304
	Datalist         Atom = 0x44308
	Datetime         Atom = 0x25b08
	Dd               Atom = 0x28802
	Default          Atom = 0x5207
	Defer            Atom = 0x17105
	Del              Atom = 0x4d603
	Desc             Atom = 0x4804
	Details          Atom = 0x6507
	Dfn              Atom = 0x8303
	Dialog           Atom = 0x1b06
	Dir              Atom = 0x9d03
	Dirname          Atom = 0x9d07
	Disabled         Atom = 0x10008
	Div              Atom = 0x10703
	Dl               Atom = 0x13e02
	Download         Atom = 0x40908
	Draggable        Atom = 0x1a109
	Dropzone         Atom = 0x3a208
	Dt               Atom = 0x4e402
	Em               Atom = 0x7f02
	Embed            Atom = 0x7f05
	Enctype          Atom = 0x23007
	Face             Atom = 0x2dd04
	Fieldset         Atom = 0x1d508
	Figcaption       Atom = 0x1dd0a
	Figure           Atom = 0x1f106
	Font             Atom = 0x11804
	Footer           Atom = 0x5906
	For              Atom = 0x1fd03
	ForeignObject    Atom = 0x1fd0d
	Foreignobject    Atom = 0x20a0d
	Form             Atom = 0x21704
	Formaction       Atom = 0x2170a
	Formenctype      Atom = 0x22c0b
	Formmethod       Atom = 0x2470a
	Formnovalidate   Atom = 0x2510e
	Formtarget       Atom = 0x2660a
	Frame            Atom = 0x8705
	Frameset         Atom = 0x8708
	H1               Atom = 0x13602
	H2               Atom = 0x29602
	H3               Atom = 0x2c502
	H4               Atom = 0x30e02
	H5               Atom = 0x4e602
	H6               Atom = 0x27002
	Head             Atom = 0x2fa04
	Header           Atom = 0x2fa06
	Headers          Atom = 0x2fa07
	Height           Atom = 0x27206
	Hgroup           Atom = 0x27a06
	Hidden           Atom = 0x28606
	High             Atom = 0x29304
	Hr               Atom = 0x13102
	Href             Atom = 0x29804
	Hreflang         Atom = 0x29808
	Html             Atom = 0x27604
	HttpEquiv        Atom = 0x2a00a
	I                Atom = 0x601
	Icon             Atom = 0x42b04
	Id               Atom = 0x5102
	Iframe           Atom = 0x2b406
	Image            Atom = 0x2ba05
	Img              Atom = 0x2bf03
	Inert            Atom = 0x4c105
	Input            Atom = 0x3f605
	Ins              Atom = 0x1cd03
	Isindex          Atom = 0x2c707
	Ismap            Atom = 0x2ce05
	Itemid           Atom = 0x9806
	Itemprop         Atom = 0x57e08
	Itemref          Atom = 0x2d707
	Itemscope        Atom = 0x2e509
	Itemtype         Atom = 0x2ef08
	Kbd              Atom = 0x1903
	Keygen           Atom = 0x3906
	Keytype          Atom = 0x51207
	Kind             Atom = 0xfd04
	Label            Atom = 0xba05
	Lang             Atom = 0x29c04
	Legend           Atom = 0x1a806
	Li               Atom = 0x1202
	Link             Atom = 0x14804
	List             Atom = 0x44704
	Listing          Atom = 0x44707
	Loop             Atom = 0xbe04
	Low              Atom = 0x13f03
	Malignmark       Atom = 0x100a
	Manifest         Atom = 0x5b608
	Map              Atom = 0x2d003
	Mark             Atom = 0x1604
	Marquee          Atom = 0x5f207
	Math             Atom = 0x2f704
	Max              Atom = 0x30603
	Maxlength        Atom = 0x30609
	Media            Atom = 0xa205
	Mediagroup       Atom = 0xa20a
	Menu             Atom = 0x34f04
	Meta             Atom = 0x45604
	Meter            Atom = 0x26105
	Method           Atom = 0x24b06
	Mglyph           Atom = 0x2c006
	Mi               Atom = 0x9b02
	Min              Atom = 0x31003
	Mn               Atom = 0x25402
	Mo               Atom = 0x47a02
	Ms               Atom = 0x2e802
	Mtext            Atom = 0x31305
	Multiple         Atom = 0x32108
	Muted            Atom = 0x32905
	Name             Atom = 0xa004
	Nav              Atom = 0x3e03
	Nobr             Atom = 0x7404
	Noembed          Atom = 0x7d07
	Noframes         Atom = 0x8508
	Noscript         Atom = 0x28b08
	Novalidate       Atom = 0x2550a
	Object           Atom = 0x21106
	Ol               Atom = 0xcd02
	Onabort          Atom = 0x16007
	Onafterprint     Atom = 0x1e50c
	Onbeforeprint    Atom = 0x21f0d
	Onbeforeunload   Atom = 0x5c90e
	Onblur           Atom = 0x3e206
	Oncancel         Atom = 0xb308
	Oncanplay        Atom = 0x12709
	Oncanplaythrough Atom = 0x12710
	Onchange         Atom = 0x3b808
	Onclick          Atom = 0x2ad07
	Onclose          Atom = 0x32e07
	Oncontextmenu    Atom = 0x3460d
	Oncuechange      Atom = 0x3530b
	Ondblclick       Atom = 0x35e0a
	Ondrag           Atom = 0x36806
	Ondragend        Atom = 0x36809
	Ondragenter      Atom = 0x3710b
	Ondragleave      Atom = 0x37c0b
	Ondragover       Atom = 0x3870a
	Ondragstart      Atom = 0x3910b
	Ondrop           Atom = 0x3a006
	Ondurationchange Atom = 0x3b010
	Onemptied        Atom = 0x3a709
	Onended          Atom = 0x3c007
	Onerror          Atom = 0x3c707
	Onfocus          Atom = 0x3ce07
	Onhashchange     Atom = 0x3e80c
	Oninput          Atom = 0x3f407
	Oninvalid        Atom = 0x3fb09
	Onkeydown        Atom = 0x40409
	Onkeypress       Atom = 0x4110a
	Onkeyup          Atom = 0x42107
	Onload           Atom = 0x43b06
	Onloadeddata     Atom = 0x43b0c
	Onloadedmetadata Atom = 0x44e10
	Onloadstart      Atom = 0x4640b
	Onmessage        Atom = 0x46f09
	Onmousedown      Atom = 0x4780b
	Onmousemove      Atom = 0x4830b
	Onmouseout       Atom = 0x48e0a
	Onmouseover      Atom = 0x49b0b
	Onmouseup        Atom = 0x4a609
	Onmousewheel     Atom = 0x4af0c
	Onoffline        Atom = 0x4bb09
	Ononline         Atom = 0x4c608
	Onpagehide       Atom = 0x4ce0a
	Onpageshow       Atom = 0x4d90a
	Onpause          Atom = 0x4e807
	Onplay           Atom = 0x4f206
	Onplaying        Atom = 0x4f209
	Onpopstate       Atom = 0x4fb0a
	Onprogress       Atom = 0x5050a
	Onratechange     Atom = 0x5190c
	Onreset          Atom = 0x52507
	Onresize         Atom = 0x52c08
	Onscroll         Atom = 0x53a08
	Onseeked         Atom = 0x54208
	Onseeking        Atom = 0x54a09
	Onselect         Atom = 0x55308
	Onshow           Atom = 0x55d06
	Onstalled        Atom = 0x56609
	Onstorage        Atom = 0x56f09
	Onsubmit         Atom = 0x57808
	Onsuspend        Atom = 0x58809
	Ontimeupdate     Atom = 0x1190c
	Onunload         Atom = 0x59108
	Onvolumechange   Atom = 0x5990e
	Onwaiting        Atom = 0x5a709
	Open             Atom = 0x58404
	Optgroup         Atom = 0xc008
	Optimum          Atom = 0x5b007
	Option           Atom = 0x5c506
	Output           Atom = 0x49506
	P                Atom = 0xc01
	Param            Atom = 0xc05
	Pattern          Atom = 0x6e07
	Ping             Atom = 0xab04
	Placeholder      Atom = 0xc70b
	Plaintext        Atom = 0xf109
	Poster           Atom = 0x17d06
	Pre              Atom = 0x27f03
	Preload          Atom = 0x27f07
	Progress         Atom = 0x50708
	Prompt           Atom = 0x5bf06
	Public           Atom = 0x42706
	Q                Atom = 0x15101
	Radiogroup       Atom = 0x30a
	Readonly         Atom = 0x31908
	Rel              Atom = 0x28003
	Required         Atom = 0x1f508
	Reversed         Atom = 0x5e08
	Rows             Atom = 0x7704
	Rowspan          Atom = 0x7707
	Rp               Atom = 0x1eb02
	Rt               Atom = 0x16502
	Ruby             Atom = 0xd104
	S                Atom = 0x2c01
	Samp             Atom = 0x6b04
	Sandbox          Atom = 0xe907
	Scope            Atom = 0x2e905
	Scoped           Atom = 0x2e906
	Script           Atom = 0x28d06
	Seamless         Atom = 0x33308
	Section          Atom = 0x3dd07
	Select           Atom = 0x55506
	Selected         Atom = 0x55508
	Shape            Atom = 0x1b505
	Size             Atom = 0x53004
	Sizes            Atom = 0x53005
	Small            Atom = 0x1bf05
	Source           Atom = 0x1cf06
	Spacer           Atom = 0x30006
	Span             Atom = 0x7a04
	Spellcheck       Atom = 0x33a0a
	Src              Atom = 0x3d403
	Srcdoc           Atom = 0x3d406
	Srclang          Atom = 0x41a07
	Start            Atom = 0x39705
	Step             Atom = 0x5bc04
	Strike           Atom = 0x50e06
	Strong           Atom = 0x53406
	Style            Atom = 0x5db05
	Sub              Atom = 0x57a03
	Summary          Atom = 0x5e007
	Sup              Atom = 0x5e703
	Svg              Atom = 0x5ea03
	System           Atom = 0x5ed06
	Tabindex         Atom = 0x45c08
	Table            Atom = 0x43605
	Target           Atom = 0x26a06
	Tbody            Atom = 0x2e05
	Td               Atom = 0x4702
	Textarea         Atom = 0x31408
	Tfoot            Atom = 0x5805
	Th               Atom = 0x13002
	Thead            Atom = 0x2f905
	Time             Atom = 0x11b04
	Title            Atom = 0x8e05
	Tr               Atom = 0xf902
	Track            Atom = 0xf905
	Translate        Atom = 0x16609
	Tt               Atom = 0x7002
	Type             Atom = 0x23304
	Typemustmatch    Atom = 0x2330d
	U                Atom = 0xb01
	Ul               Atom = 0x5602
	Usemap           Atom = 0x4ec06
	Value            Atom = 0x4005
	Var              Atom = 0x10903
	Video            Atom = 0x2a905
	Wbr              Atom = 0x14103
	Width            Atom = 0x4e205
	Wrap             Atom = 0x56204
	Xmp              Atom = 0xef03
)

const hash0 = 0xc17da63e

const maxAtomLen = 16

var table = [1 << 9]Atom{
	0x1:   0x4830b, // onmousemove
	0x2:   0x5a709, // onwaiting
	0x4:   0x5bf06, // prompt
	0x7:   0x5b007, // optimum
	0x8:   0x1604,  // mark
	0xa:   0x2d707, // itemref
	0xb:   0x4d90a, // onpageshow
	0xc:   0x55506, // select
	0xd:   0x1a109, // draggable
	0xe:   0x3e03,  // nav
	0xf:   0x19b07, // command
	0x11:  0xb01,   // u
	0x14:  0x2fa07, // headers
	0x15:  0x44308, // datalist
	0x17:  0x6b04,  // samp
	0x1a:  0x40409, // onkeydown
	0x1b:  0x53a08, // onscroll
	0x1c:  0x17603, // col
	0x20:  0x57e08, // itemprop
	0x21:  0x2a00a, // http-equiv
	0x22:  0x5e703, // sup
	0x24:  0x1f508, // required
	0x2b:  0x27f07, // preload
	0x2c:  0x21f0d, // onbeforeprint
	0x2d:  0x3710b, // ondragenter
	0x2e:  0x4e402, // dt
	0x2f:  0x57808, // onsubmit
	0x30:  0x13102, // hr
	0x31:  0x3460d, // oncontextmenu
	0x33:  0x2ba05, // image
	0x34:  0x4e807, // onpause
	0x35:  0x27a06, // hgroup
	0x36:  0xab04,  // ping
	0x37:  0x55308, // onselect
	0x3a:  0x10703, // div
	0x40:  0x9b02,  // mi
	0x41:  0x33308, // seamless
	0x42:  0x2807,  // charset
	0x43:  0x5102,  // id
	0x44:  0x4fb0a, // onpopstate
	0x45:  0x4d603, // del
	0x46:  0x5f207, // marquee
	0x47:  0x3309,  // accesskey
	0x49:  0x5906,  // footer
	0x4a:  0x2d106, // applet
	0x4b:  0x2ce05, // ismap
	0x51:  0x34f04, // menu
	0x52:  0x2f04,  // body
	0x55:  0x8708,  // frameset
	0x56:  0x52507, // onreset
	0x57:  0x14705, // blink
	0x58:  0x8e05,  // title
	0x59:  0x39907, // article
	0x5b:  0x13002, // th
	0x5d:  0x15101, // q
	0x5e:  0x58404, // open
	0x5f:  0x31804, // area
	0x61:  0x43b06, // onload
	0x62:  0x3f605, // input
	0x63:  0x11404, // base
	0x64:  0x18807, // colspan
	0x65:  0x51207, // keytype
	0x66:  0x13e02, // dl
	0x68:  0x1d508, // fieldset
	0x6a:  0x31003, // min
	0x6b:  0x10903, // var
	0x6f:  0x2fa06, // header
	0x70:  0x16502, // rt
	0x71:  0x17608, // colgroup
	0x72:  0x25402, // mn
	0x74:  0x16007, // onabort
	0x75:  0x3906,  // keygen
	0x76:  0x4bb09, // onoffline
	0x77:  0x23e09, // challenge
	0x78:  0x2d003, // map
	0x7a:  0x30e02, // h4
	0x7b:  0x3c707, // onerror
	0x7c:  0x30609, // maxlength
	0x7d:  0x31305, // mtext
	0x7e:  0x5805,  // tfoot
	0x7f:  0x11804, // font
	0x80:  0x100a,  // malignmark
	0x81:  0x45604, // meta
	0x82:  0x9305,  // async
	0x83:  0x2c502, // h3
	0x84:  0x28802, // dd
	0x85:  0x29804, // href
	0x86:  0xa20a,  // mediagroup
	0x87:  0x1ba06, // coords
	0x88:  0x41a07, // srclang
	0x89:  0x35e0a, // ondblclick
	0x8a:  0x4005,  // value
	0x8c:  0xb308,  // oncancel
	0x8e:  0x33a0a, // spellcheck
	0x8f:  0x8705,  // frame
	0x91:  0x14403, // big
	0x94:  0x21b06, // action
	0x95:  0x9d03,  // dir
	0x97:  0x31908, // readonly
	0x99:  0x43605, // table
	0x9a:  0x5e007, // summary
	0x9b:  0x14103, // wbr
	0x9c:  0x30a,   // radiogroup
	0x9d:  0xa004,  // name
	0x9f:  0x5ed06, // system
	0xa1:  0x18305, // color
	0xa2:  0x4b06,  // canvas
	0xa3:  0x27604, // html
	0xa5:  0x54a09, // onseeking
	0xac:  0x1b505, // shape
	0xad:  0x28003, // rel
	0xae:  0x12710, // oncanplaythrough
	0xaf:  0x3870a, // ondragover
	0xb1:  0x1fd0d, // foreignObject
	0xb3:  0x7704,  // rows
	0xb6:  0x44707, // listing
	0xb7:  0x49506, // output
	0xb9:  0x3480b, // contextmenu
	0xbb:  0x13f03, // low
	0xbc:  0x1eb02, // rp
	0xbd:  0x58809, // onsuspend
	0xbe:  0x15c06, // button
	0xbf:  0x4804,  // desc
	0xc1:  0x3dd07, // section
	0xc2:  0x5050a, // onprogress
	0xc3:  0x56f09, // onstorage
	0xc4:  0x2f704, // math
	0xc5:  0x4f206, // onplay
	0xc7:  0x5602,  // ul
	0xc8:  0x6e07,  // pattern
	0xc9:  0x4af0c, // onmousewheel
	0xca:  0x36809, // ondragend
	0xcb:  0xd104,  // ruby
	0xcc:  0xc01,   // p
	0xcd:  0x32e07, // onclose
	0xce:  0x26105, // meter
	0xcf:  0x13807, // bgsound
	0xd2:  0x27206, // height
	0xd4:  0x101,   // b
	0xd5:  0x2ef08, // itemtype
	0xd8:  0x1e007, // caption
	0xd9:  0x10008, // disabled
	0xdc:  0x5ea03, // svg
	0xdd:  0x1bf05, // small
	0xde:  0x44304, // data
	0xe0:  0x4c608, // ononline
	0xe1:  0x2c006, // mglyph
	0xe3:  0x7f05,  // embed
	0xe4:  0xf902,  // tr
	0xe5:  0x4640b, // onloadstart
	0xe7:  0x3b010, // ondurationchange
	0xed:  0x12503, // bdo
	0xee:  0x4702,  // td
	0xef:  0x4f05,  // aside
	0xf0:  0x29602, // h2
	0xf1:  0x50708, // progress
	0xf2:  0x14c0a, // blockquote
	0xf4:  0xba05,  // label
	0xf5:  0x601,   // i
	0xf7:  0x7707,  // rowspan
	0xfb:  0x4f209, // onplaying
	0xfd:  0x2bf03, // img
	0xfe:  0xc008,  // optgroup
	0xff:  0x42c07, // content
	0x101: 0x5190c, // onratechange
	0x103: 0x3e80c, // onhashchange
	0x104: 0x6507,  // details
	0x106: 0x40908, // download
	0x109: 0xe907,  // sandbox
	0x10b: 0x42c0f, // contenteditable
	0x10d: 0x37c0b, // ondragleave
	0x10e: 0x2106,  // accept
	0x10f: 0x55508, // selected
	0x112: 0x2170a, // formaction
	0x113: 0x2df06, // center
	0x115: 0x44e10, // onloadedmetadata
	0x116: 0x14804, // link
	0x117: 0x11b04, // time
	0x118: 0x1c40b, // crossorigin
	0x119: 0x3ce07, // onfocus
	0x11a: 0x56204, // wrap
	0x11b: 0x42b04, // icon
	0x11d: 0x2a905, // video
	0x11e: 0x3d905, // class
	0x121: 0x5990e, // onvolumechange
	0x122: 0x3e206, // onblur
	0x123: 0x2e509, // itemscope
	0x124: 0x5db05, // style
	0x127: 0x42706, // public
	0x129: 0x2510e, // formnovalidate
	0x12a: 0x55d06, // onshow
	0x12c: 0x16609, // translate
	0x12d: 0x9704,  // cite
	0x12e: 0x2e802, // ms
	0x12f: 0x1190c, // ontimeupdate
	0x130: 0xfd04,  // kind
	0x131: 0x2660a, // formtarget
	0x135: 0x3c007, // onended
	0x136: 0x28606, // hidden
	0x137: 0x2c01,  // s
	0x139: 0x2470a, // formmethod
	0x13a: 0x44704, // list
	0x13c: 0x27002, // h6
	0x13d: 0xcd02,  // ol
	0x13e: 0x3530b, // oncuechange
	0x13f: 0x20a0d, // foreignobject
	0x143: 0x5c90e, // onbeforeunload
	0x145: 0x3a709, // onemptied
	0x146: 0x17105, // defer
	0x147: 0xef03,  // xmp
	0x148: 0xaf05,  // audio
	0x149: 0x1903,  // kbd
	0x14c: 0x46f09, // onmessage
	0x14d: 0x5c506, // option
	0x14e: 0x4503,  // alt
	0x14f: 0x33f07, // checked
	0x150: 0x10c08, // autoplay
	0x152: 0x202,   // br
	0x153: 0x2550a, // novalidate
	0x156: 0x7d07,  // noembed
	0x159: 0x2ad07, // onclick
	0x15a: 0x4780b, // onmousedown
	0x15b: 0x3b808, // onchange
	0x15e: 0x3fb09, // oninvalid
	0x15f: 0x2e906, // scoped
	0x160: 0x1ae08, // controls
	0x161: 0x32905, // muted
	0x163: 0x4ec06, // usemap
	0x164: 0x1dd0a, // figcaption
	0x165: 0x36806, // ondrag
	0x166: 0x29304, // high
	0x168: 0x3d403, // src
	0x169: 0x17d06, // poster
	0x16b: 0x18d0e, // annotation-xml
	0x16c: 0x5bc04, // step
	0x16d: 0x4,     // abbr
	0x16e: 0x1b06,  // dialog
	0x170: 0x1202,  // li
	0x172: 0x47a02, // mo
	0x175: 0x1fd03, // for
	0x176: 0x1cd03, // ins
	0x178: 0x53004, // size
	0x17a: 0x5207,  // default
	0x17b: 0x1a03,  // bdi
	0x17c: 0x4ce0a, // onpagehide
	0x17d: 0x9d07,  // dirname
	0x17e: 0x23304, // type
	0x17f: 0x21704, // form
	0x180: 0x4c105, // inert
	0x181: 0x12709, // oncanplay
	0x182: 0x8303,  // dfn
	0x183: 0x45c08, // tabindex
	0x186: 0x7f02,  // em
	0x187: 0x29c04, // lang
	0x189: 0x3a208, // dropzone
	0x18a: 0x4110a, // onkeypress
	0x18b: 0x25b08, // datetime
	0x18c: 0x18804, // cols
	0x18d: 0x1,     // a
	0x18e: 0x43b0c, // onloadeddata
	0x191: 0x15606, // border
	0x192: 0x2e05,  // tbody
	0x193: 0x24b06, // method
	0x195: 0xbe04,  // loop
	0x196: 0x2b406, // iframe
	0x198: 0x2fa04, // head
	0x19e: 0x5b608, // manifest
	0x19f: 0xe109,  // autofocus
	0x1a0: 0x16f04, // code
	0x1a1: 0x53406, // strong
	0x1a2: 0x32108, // multiple
	0x1a3: 0xc05,   // param
	0x1a6: 0x23007, // enctype
	0x1a7: 0x2dd04, // face
	0x1a8: 0xf109,  // plaintext
	0x1a9: 0x13602, // h1
	0x1aa: 0x56609, // onstalled
	0x1ad: 0x28d06, // script
	0x1ae: 0x30006, // spacer
	0x1af: 0x52c08, // onresize
	0x1b0: 0x49b0b, // onmouseover
	0x1b1: 0x59108, // onunload
	0x1b2: 0x54208, // onseeked
	0x1b4: 0x2330d, // typemustmatch
	0x1b5: 0x1f106, // figure
	0x1b6: 0x48e0a, // onmouseout
	0x1b7: 0x27f03, // pre
	0x1b8: 0x4e205, // width
	0x1bb: 0x7404,  // nobr
	0x1be: 0x7002,  // tt
	0x1bf: 0x1105,  // align
	0x1c0: 0x3f407, // oninput
	0x1c3: 0x42107, // onkeyup
	0x1c6: 0x1e50c, // onafterprint
	0x1c7: 0x210e,  // accept-charset
	0x1c8: 0x9806,  // itemid
	0x1cb: 0x50e06, // strike
	0x1cc: 0x57a03, // sub
	0x1cd: 0xf905,  // track
	0x1ce: 0x39705, // start
	0x1d0: 0x11408, // basefont
	0x1d6: 0x1cf06, // source
	0x1d7: 0x1a806, // legend
	0x1d8: 0x2f905, // thead
	0x1da: 0x2e905, // scope
	0x1dd: 0x21106, // object
	0x1de: 0xa205,  // media
	0x1df: 0x18d0a, // annotation
	0x1e0: 0x22c0b, // formenctype
	0x1e2: 0x28b08, // noscript
	0x1e4: 0x53005, // sizes
	0x1e5: 0xd50c,  // autocomplete
	0x1e6: 0x7a04,  // span
	0x1e7: 0x8508,  // noframes
	0x1e8: 0x26a06, // target
	0x1e9: 0x3a006, // ondrop
	0x1ea: 0x3d406, // srcdoc
	0x1ec: 0x5e08,  // reversed
	0x1f0: 0x2c707, // isindex
	0x1f3: 0x29808, // hreflang
	0x1f5: 0x4e602, // h5
	0x1f6: 0x5d507, // address
	0x1fa: 0x30603, // max
	0x1fb: 0xc70b,  // placeholder
	0x1fc: 0x31408, // textarea
	0x1fe: 0x4a609, // onmouseup
	0x1ff: 0x3910b, // ondragstart
}

const atomText = "abbradiogrouparamalignmarkbdialogaccept-charsetbodyaccesskey" +
	"genavaluealtdescanvasidefaultfootereversedetailsampatternobr" +
	"owspanoembedfnoframesetitleasyncitemidirnamediagroupingaudio" +
	"ncancelabelooptgrouplaceholderubyautocompleteautofocusandbox" +
	"mplaintextrackindisabledivarautoplaybasefontimeupdatebdoncan" +
	"playthrough1bgsoundlowbrbigblinkblockquoteborderbuttonabortr" +
	"anslatecodefercolgroupostercolorcolspannotation-xmlcommandra" +
	"ggablegendcontrolshapecoordsmallcrossoriginsourcefieldsetfig" +
	"captionafterprintfigurequiredforeignObjectforeignobjectforma" +
	"ctionbeforeprintformenctypemustmatchallengeformmethodformnov" +
	"alidatetimeterformtargeth6heightmlhgroupreloadhiddenoscripth" +
	"igh2hreflanghttp-equivideonclickiframeimageimglyph3isindexis" +
	"mappletitemrefacenteritemscopeditemtypematheaderspacermaxlen" +
	"gth4minmtextareadonlymultiplemutedoncloseamlesspellcheckedon" +
	"contextmenuoncuechangeondblclickondragendondragenterondragle" +
	"aveondragoverondragstarticleondropzonemptiedondurationchange" +
	"onendedonerroronfocusrcdoclassectionbluronhashchangeoninputo" +
	"ninvalidonkeydownloadonkeypressrclangonkeyupublicontentedita" +
	"bleonloadeddatalistingonloadedmetadatabindexonloadstartonmes" +
	"sageonmousedownonmousemoveonmouseoutputonmouseoveronmouseupo" +
	"nmousewheelonofflinertononlineonpagehidelonpageshowidth5onpa" +
	"usemaponplayingonpopstateonprogresstrikeytypeonratechangeonr" +
	"esetonresizestrongonscrollonseekedonseekingonselectedonshowr" +
	"aponstalledonstorageonsubmitempropenonsuspendonunloadonvolum" +
	"echangeonwaitingoptimumanifestepromptoptionbeforeunloaddress" +
	"tylesummarysupsvgsystemarquee"


text:
DESCRIPTION = "lua-compat53"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
HOMEPAGE = "https://github.com/keplerproject/lua-compat-5.3.git"
DEPENDS += "virtual/lua"
RDEPENDS_${PN} += "virtual/lua"

include ../lua.inc

SRCREV = "${AUTOREV}"

SRC_URI = "git://github.com/keplerproject/lua-compat-5.3.git;protocol=https \
"

S = "${WORKDIR}/git"

SRCREV = "${AUTOREV}"
PV = "v0.9"
SRC = "compat-5.3.c"

CFLAGS += "-I${S}/c-api -I${STAGING_INCDIR}/luajit-2.1 -DLUA_COMPAT_BITLIB"

COMPAT53_LIBS = "lstrlib lutf8lib ltablib lbitlib"

do_compile () {
	for file in ${COMPAT53_LIBS}; do
		${CC} -O2 -fPIC -fomit-frame-pointer -shared -I${STAGING_INCDIR}/luajit-2.1 -c -o $file.o $file.c
		${CC} -shared -fPIC -O2 ${CFLAGS} ${LDFLAGS} -I${STAGING_INCDIR}/luajit-2.1 -o $file.so $file.c
	done
}

do_install () {
	install -d ${D}${libdir}/lua/${LUA_VER}
	install -m 644 ${S}/lstrlib.so ${D}${libdir}/lua/${LUA_VER}/string.so
	install -m 644 ${S}/lutf8lib.so ${D}${libdir}/lua/${LUA_VER}/utf8.so
	install -m 644 ${S}/lbitlib.so ${D}${libdir}/lua/${LUA_VER}/bit32.so
	install -m 644 ${S}/ltablib.so ${D}${libdir}/lua/${LUA_VER}/table.so
}

FILES_${PN} =  "/usr/lib \
"

BBCLASSEXTEND = "native nativesdk"

repository: neutrino-hd/meta-neutrino

repo_name: neutrino-hd/meta-neutrino

gha_language: BitBake


text:
//  Copyright (c) 2019 Couchbase, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// 		http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	_ "expvar"
	"flag"
	"fmt"
	"log"
	"net/http"
	_ "net/http/pprof"
	"os"
	"path"
	"runtime/pprof"
	"runtime/trace"
	"strconv"
	"strings"
	"sync"
	"sync/atomic"
	"time"

	"github.com/blevesearch/bleve"
	"github.com/blevesearch/bleve-bench"

	"github.com/blevesearch/bleve/analysis"
	_ "github.com/blevesearch/bleve/config"
	_ "github.com/blevesearch/bleve/index/store/metrics"
	_ "github.com/blevesearch/bleve/index/store/null"
)

var analyzerName = flag.String("analyzer", "standard", "analyzer to use")
var source = flag.String("source", "../../tmp/enwiki.txt", "wikipedia line file")
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var memprofile = flag.String("memprofile", "", "write memory profile at end")
var readerQueueSize = flag.Int("readerQueueSize", 8, "size of queue output from reader")
var numAnalyzers = flag.Int("numAnalyzers", 8, "number of analyzer goroutines")
var maxTextSize = flag.Int("maxTextSize", 0, "when > 0, text is clipped to this length")
var printTime = flag.Duration("printTime", 5*time.Second, "print stats every printTime")
var bindHTTP = flag.String("bindHttp", ":1234", "http bind port")
var count = flag.Int("count", 100000, "total number of documents to process")
var statsFile = flag.String("statsFile", "", "<stdout>")
var traceprofile = flag.String("traceprofile", "", "write trace profile to file")

var tokensProduced uint64
var lastTokensProduced uint64

var timeStart time.Time
var timeLast time.Time

var statsWriter = os.Stdout

func main() {
	flag.Parse()

	go http.ListenAndServe(*bindHTTP, nil) // For expvar.

	if *statsFile != "" {
		// create all parents if necessary
		dir := path.Dir(*statsFile)
		os.MkdirAll(dir, 0755)

		var err error
		statsWriter, err = os.Create(*statsFile)
		if err != nil {
			log.Fatal(err)
		}
	}

	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		defer f.Close()
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}

	if *traceprofile != "" {
		f, err := os.Create(*traceprofile)
		if err != nil {
			log.Fatal(err)
		}
		defer f.Close()
		trace.Start(f)
		defer trace.Stop()
	}

	defineCustomAnalyzers()

	analyzer, err := bleve.Config.Cache.AnalyzerNamed(*analyzerName)
	if err != nil {
		log.Fatal(err)
	}

	printHeader()
	timeStart = time.Now()
	timeLast = timeStart
	printLine()

	work := make(chan *work, *readerQueueSize)

	// start reading worker
	go readingWorker(work)

	// start print time worker
	if *printTime > 0 {
		go printTimeWorker()
	}

	// start workers
	var wg sync.WaitGroup
	for i := 0; i < *numAnalyzers; i++ {
		wg.Add(1)
		go func() {
			analyzerWorker(analyzer, work, timeStart)
			wg.Done()
		}()
	}

	wg.Wait()

	// print final stats
	printLine()

}

var outputFields = []string{
	"date",
	"tokens",
	"avg_million_tokens_per_second",
	"milllion_tokens_per_second",
}

func printHeader() {
	fmt.Fprintf(statsWriter, "%s\n", strings.Join(outputFields, ","))
}

func printLine() {
	// get
	timeNow := time.Now()
	nowTokensProduced := atomic.LoadUint64(&tokensProduced)

	// calculate
	curTokensProduced := nowTokensProduced - lastTokensProduced

	cumTimeTaken := timeNow.Sub(timeStart)
	curTimeTaken := timeNow.Sub(timeLast)

	cumSeconds := float64(cumTimeTaken) / float64(time.Second)
	curSeconds := float64(curTimeTaken) / float64(time.Second)

	dateNow := timeNow.Format(time.RFC3339)
	fmt.Fprintf(statsWriter, "%s,%d,%f,%f\n", dateNow, nowTokensProduced,
		float64(nowTokensProduced/1000000)/cumSeconds, float64(curTokensProduced/1000000)/curSeconds)

	timeLast = timeNow
	lastTokensProduced = nowTokensProduced
}

func printTimeWorker() {
	tickChan := time.NewTicker(*printTime).C
	for range tickChan {
		printLine()
	}
}

type work struct {
	doc            *blevebench.Article
	id             string
	plainTextBytes uint64
}

func readingWorker(w chan *work) {
	wikiReader, err := blevebench.NewWikiReader(*source)
	if err != nil {
		log.Fatal(err)
	}
	defer wikiReader.Close()

	i := 0

	a, err := wikiReader.Next()
	for a != nil && err == nil && i <= *count {
		if *maxTextSize > 0 && len(a.Text) > *maxTextSize {
			a.Text = a.Text[0:*maxTextSize]
		}

		i++
		w <- &work{
			doc:            a,
			id:             strconv.Itoa(i),
			plainTextBytes: uint64(len(a.Title) + len(a.Text)),
		}
		a, err = wikiReader.Next()
	}
	if err != nil {
		log.Fatalf("reading worker fatal: %v", err)
	}

	close(w)
}

func analyzerWorker(analyzer *analysis.Analyzer, workChan chan *work, timeStart time.Time) {
	for work := range workChan {

		ts := analyzer.Analyze([]byte(work.doc.Text))
		atomic.AddUint64(&tokensProduced, uint64(len(ts)))
	}
}

// replicate some analyzers used in luceneutil
func defineCustomAnalyzers() {

	_, err := bleve.Config.Cache.DefineTokenFilter("edgeNGram13", map[string]interface{}{
		"edge": `front`,
		"min":  1.0,
		"max":  3.0,
		"type": `edge_ngram`,
	})
	if err != nil {
		log.Fatal(err)
	}

	_, err = bleve.Config.Cache.DefineAnalyzer("edgeNGrams", map[string]interface{}{
		"type":      "custom",
		"tokenizer": "whitespace",
		"token_filters": []string{
			"edgeNGram13",
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	_, err = bleve.Config.Cache.DefineTokenFilter("shingle22", map[string]interface{}{
		"min":       2.0,
		"max":       2.0,
		"type":      `shingle`,
		"separator": ``,
	})
	if err != nil {
		log.Fatal(err)
	}

	_, err = bleve.Config.Cache.DefineAnalyzer("shingles", map[string]interface{}{
		"type":      "custom",
		"tokenizer": "whitespace",
		"token_filters": []string{
			"shingle22",
		},
	})
	if err != nil {
		log.Fatal(err)
	}
}


text:
package netlink

import (
    "fmt"
    // "syscall"
    "errors"
    "net"
    "strconv"
    "strings"
    "github.com/ndupreez/netlink/nl"
    "golang.org/x/sys/unix"
)

// --------------------------------------------------------------------------------
// Additional Netlink Generic functions to support L2TP tunnel
// operations
// Feb 2018
// Nick du Preez
// --------------------------------------------------------------------------------

//
// 1. Utility functions:
//
// Retrieve the GeNl L2TP driver version supported
func (h *Handle) L2tpGetGenlVersion() (uint32, error) {
    // Read genl driver details
    l2tp, err := GenlFamilyGet(L2TP_GENL_NAME)
    if (err != nil) {
        return 0, err
    }
    // Retrieve the version
    return l2tp.Version, nil
}

func L2tpGetGenlVersion() (uint32, error) {
    return pkgHandle.L2tpGetGenlVersion()
}

// Retrieve the GeNl L2TP family ID
func (h *Handle) L2tpGetGenlFamilyId() (uint16, error) {
    // Read genl driver details
    l2tp, err := GenlFamilyGet(L2TP_GENL_NAME)
    if (err != nil) {
        return 0, err
    }
    // Retrieve the family/driver ID
    return l2tp.ID, nil
}

func L2tpGetGenlFamilyId() (uint16, error) {
    return pkgHandle.L2tpGetGenlFamilyId()
}

// Retrieve the GeNl L2TP family ID and version
func (h *Handle) L2tpGetGenlDetails() (uint32, uint16, error) {
    // Read genl driver details
    l2tp, err := GenlFamilyGet(L2TP_GENL_NAME)
    if (err != nil) {
        return 0, 0, err
    }
    // Retrieve the version and family/driver ID
    return l2tp.Version, l2tp.ID, nil
}

func L2tpGetGenlDetails() (uint32, uint16, error) {
    return pkgHandle.L2tpGetGenlDetails()
}

// Check to see if we can talk to the L2TP netlink driver
func L2tpIsAvailable() (bool, error) {
    L2tpGlNetlinkVer, _, err := pkgHandle.L2tpGetGenlDetails()
    if (err != nil) {
        return false, err
    }
    if (L2tpGlNetlinkVer < 1) {
        return false, errors.New("Unknown driver version")
    }
    return true, nil
}

// Extract port for address
func GetPortFromAddr(addr string) uint16 {
    var portInt uint16
    portInt = 0
    _, port, err := net.SplitHostPort(addr)
    if (err == nil) {
        tempPort, errConv := strconv.ParseUint(port, 10, 16)
        if (errConv == nil) {
            portInt = (uint16)(tempPort)
        }
    }
    return (portInt)
}

// Extract host part from address
func GetHostFromAddr(addr string) string {
    if (!strings.Contains(addr, ":")) {
        return (addr)
    }
    host, _, err := net.SplitHostPort(addr)
    if (err == nil) {
        return (host)
    }
    return ("")
}

func IsIPv6(str string) bool {
  ip := net.ParseIP(str)
  return ip != nil && strings.Contains(str, ":")
}

//
// 2. Context helpers
//

// The APIs use a 'created-on-demand' context struct to keep track of information
// accross invokes, mainly to reduce the overhead of subsequent calls to the driver,
// like driver GeNL ID, version, etc.
func setL2tpContext(tunnel *L2tpTunnel) (error) {
    if (tunnel.ctx.IsSet) {
        // Already loaded
        return nil
    }
    L2tpGlNetlinkVer, L2tpGlNetlinkID, err := pkgHandle.L2tpGetGenlDetails()
    if (err != nil) {
        return err
    }
    tunnel.ctx.Version = uint8(L2tpGlNetlinkVer)
    tunnel.ctx.ProtoID = L2tpGlNetlinkID
    tunnel.ctx.IsSet = true

    return nil
}

//
// 3. Tunnel & Session related APIs
//

//
// Build or add a tunnel using a user space UDP socket for the L2TP driver to
// convert into a L2TP version
//
func (h *Handle) L2tpAddTunnelForConn(tunnel *L2tpTunnel) (uint32, error) {
    //
    // NOTE:
    // Work in Progress!
    //

    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_TUNNEL_CREATE,
        Version: tunnel.ctx.Version,
    }
    var localAddr *net.UDPAddr
    var remoteAddr *net.UDPAddr
    var addrErr error
    // Resolve the 2 endpoint addresses
    if (len(tunnel.LocalAddr) != 0) {
        localAddr, addrErr = net.ResolveUDPAddr("udp", tunnel.LocalAddr)
        if (addrErr != nil) {
            return 1001, addrErr
        }
    }
    if (len(tunnel.PeerAddr) != 0) {
        remoteAddr, addrErr = net.ResolveUDPAddr("udp", tunnel.PeerAddr)
        if (addrErr != nil) {
            return 1002, addrErr
        }
    } else {
        return 1003, errors.New("Peer address not found")
    }
    // Open the socket
    var connErr error
    tunnel.Conn, connErr = net.DialUDP("udp", localAddr, remoteAddr)
    if (connErr != nil) {
        return 1004, connErr
    }
    connFile, _ := tunnel.Conn.File()
    tunnel.Fd = (uint32)(connFile.Fd())
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PEER_CONN_ID, nl.Uint32Attr(tunnel.PeerID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PROTO_VERSION, nl.Uint8Attr(L2TP_PROTO_VERSION)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_ENCAP_TYPE, nl.Uint16Attr(L2TP_ENCAPTYPE_UDP)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_DEBUG, nl.Uint32Attr(tunnel.DebugFlags)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_FD, nl.Uint32Attr(tunnel.Fd)))

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    return 0, err
}

func L2tpAddTunnelForConn(tunnel *L2tpTunnel) (uint32, error) {
    return pkgHandle.L2tpAddTunnelForConn(tunnel)
}

//
// Build or add a tunnel using the 2 endpoints (addresses & ports)
//
func (h *Handle) L2tpAddTunnel(tunnel *L2tpTunnel) (uint32, error) {
    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_TUNNEL_CREATE,
        Version: tunnel.ctx.Version,
    }
    var addrErr error
    // Resolve the 2 endpoint addresses
    if (len(tunnel.LocalAddr) != 0) {
        _, addrErr = net.ResolveUDPAddr("udp", tunnel.LocalAddr)
        if (addrErr != nil) {
            return 1001, addrErr
        }
    }
    if (len(tunnel.PeerAddr) != 0) {
        _, addrErr = net.ResolveUDPAddr("udp", tunnel.PeerAddr)
        if (addrErr != nil) {
            return 1002, addrErr
        }
    } else {
        return 1003, errors.New("Peer address not found")
    }
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PEER_CONN_ID, nl.Uint32Attr(tunnel.PeerID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PROTO_VERSION, nl.Uint8Attr(L2TP_PROTO_VERSION)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_ENCAP_TYPE, nl.Uint16Attr(L2TP_ENCAPTYPE_UDP)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_DEBUG, nl.Uint32Attr(tunnel.DebugFlags)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_UDP_SPORT, nl.Uint16Attr(GetPortFromAddr(tunnel.LocalAddr))))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_UDP_DPORT, nl.Uint16Attr(GetPortFromAddr(tunnel.PeerAddr))))
    // IPv4 or v6?
    localHost := GetHostFromAddr(tunnel.LocalAddr)
    peerHost  := GetHostFromAddr(tunnel.PeerAddr)
    localIP := net.ParseIP(localHost)
    peerIP  := net.ParseIP(peerHost)
    if (IsIPv6(localHost)) {
        req.AddData(nl.NewRtAttr(L2TP_ATTR_IP6_SADDR, localIP.To16()))
        req.AddData(nl.NewRtAttr(L2TP_ATTR_IP6_DADDR, peerIP.To16()))
    } else {
        req.AddData(nl.NewRtAttr(L2TP_ATTR_IP_SADDR, localIP.To4()))
        req.AddData(nl.NewRtAttr(L2TP_ATTR_IP_DADDR, peerIP.To4()))
    }

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    return 0, err
}

func L2tpAddTunnel(tunnel *L2tpTunnel) (uint32, error) {
    return pkgHandle.L2tpAddTunnel(tunnel)
}

//
// Remove a tunnel and in the process remove all associated sessions.
//
func (h *Handle) L2tpDelTunnel(tunnel *L2tpTunnel) (uint32, error) {
    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_TUNNEL_DELETE,
        Version: tunnel.ctx.Version,
    }
    // Is the session nil?
    if (tunnel.Session != nil) {
        L2tpDelSession(tunnel)
    }
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    // Close socket - if open
    if (err == nil) {
        if (tunnel.Conn != nil) {
            tunnel.Conn.Close()
            tunnel.Conn = nil
        }
    }

    return 0, err
}

func L2tpDelTunnel(tunnel *L2tpTunnel) (uint32, error) {
    return pkgHandle.L2tpDelTunnel(tunnel)
}

//
// Add a session to a tunnel (current version supports 1 session per tunnel)
//
func (h *Handle) L2tpAddSession(tunnel *L2tpTunnel, session *L2tpSession) (uint32, error) {
    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_SESSION_CREATE,
        Version: tunnel.ctx.Version,
    }
    if (tunnel.Session != nil) {
        return 2000, errors.New("Tunnel already has session associated")
    }
    if (session.ID == 0) {
        if (session.UniqueIDs) {
            session.ID = tunnel.ID
        } else {
            session.ID = 1
        }
    }
    if (session.PeerID == 0) {
        if (session.UniqueIDs) {
            session.PeerID = tunnel.PeerID
        } else {
            session.PeerID = 1
        }
    }
    if (len(session.IFName) == 0) {
        session.IFName = fmt.Sprintf("l2tpeth%d", tunnel.ID)
    }
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PW_TYPE, nl.Uint16Attr(L2TP_PWTYPE_ETH)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_L2SPEC_TYPE, nl.Uint8Attr(session.L2SpecType)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_L2SPEC_LEN, nl.Uint8Attr(session.L2SpecLen)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_SESSION_ID, nl.Uint32Attr(session.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_PEER_SESSION_ID, nl.Uint32Attr(session.PeerID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_IFNAME, nl.ZeroTerminated(session.IFName)))
    if (session.MTU > 0) {
        req.AddData(nl.NewRtAttr(L2TP_ATTR_MTU, nl.Uint16Attr(session.MTU)))
    }
    if (len(session.Cookie) > 0) {
        req.AddData(nl.NewRtAttr(L2TP_ATTR_COOKIE, session.Cookie))
    }
    if (len(session.PeerCookie) > 0) {
        req.AddData(nl.NewRtAttr(L2TP_ATTR_PEER_COOKIE, session.PeerCookie))
    }
    req.AddData(nl.NewRtAttr(L2TP_ATTR_DEBUG, nl.Uint32Attr(session.DebugFlags)))

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    // OK? Add it to our tunnel
    if (err == nil) {
        tunnel.Session = session
    }

    return 0, err
}

func L2tpAddSession(tunnel *L2tpTunnel, session *L2tpSession) (uint32, error) {
    return pkgHandle.L2tpAddSession(tunnel, session)
}

//
// Remove a session from a tunnel. Current version assumes 1 session per
// tunnel
//
func (h *Handle) L2tpDelSession(tunnel *L2tpTunnel) (uint32, error) {
    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    if (tunnel.Session == nil) {
        return 2001, errors.New("Tunnel has no attached sessions")
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_SESSION_DELETE,
        Version: tunnel.ctx.Version,
    }
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_SESSION_ID, nl.Uint32Attr(tunnel.Session.ID)))

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    // Remove the session from tunnel
    if (err == nil) {
        tunnel.Session = nil
    }

    return 0, err
}

func L2tpDelSession(tunnel *L2tpTunnel) (uint32, error) {
    return pkgHandle.L2tpDelSession(tunnel)
}

//
// Modify a session MTU
//
func (h *Handle) L2tpSetSessionMtu(tunnel *L2tpTunnel, mtu uint16) (uint32, error) {
    // Check context
    err := setL2tpContext(tunnel)
    if (err != nil) {
        return 1000, err
    }
    msg := &nl.Genlmsg{
        Command: L2TP_CMD_SESSION_MODIFY,
        Version: tunnel.ctx.Version,
    }
    if (tunnel.Session == nil) {
        return 2001, errors.New("No session associated with tunnel")
    }
    tunnel.Session.MTU = mtu
    // Fire request
    req := h.newNetlinkRequest(int(tunnel.ctx.ProtoID), unix.NLM_F_ACK)
    req.AddData(msg)
    req.AddData(nl.NewRtAttr(L2TP_ATTR_CONN_ID, nl.Uint32Attr(tunnel.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_SESSION_ID, nl.Uint32Attr(tunnel.Session.ID)))
    req.AddData(nl.NewRtAttr(L2TP_ATTR_MTU, nl.Uint16Attr(tunnel.Session.MTU)))

    _, err = req.Execute(unix.NETLINK_GENERIC, 0)

    return 0, err
}

func L2tpSetSessionMtu(tunnel *L2tpTunnel, mtu uint16) (uint32, error) {
    return pkgHandle.L2tpSetSessionMtu(tunnel, mtu)
}

repository: ndupreez/netlink

repo_name: ndupreez/netlink


text:
package webmock

import (
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	record   = false
	local    = false
	port     = 8080
	cacheDir = "cache"
)

type Config struct {
	record   bool
	local    bool
	port     int
	cacheDir string
}

func NewConfig() (*Config, error) {
	if os.Getenv("WEBMOCK_PROXY_RECORD") == "1" {
		record = true
	}
	if os.Getenv("WEBMOCK_PROXY_LOCAL") == "1" {
		local = true
	}
	if portStr := os.Getenv("WEBMOCK_PROXY_PORT"); portStr != "" {
		var err error
		port, err = strconv.Atoi(portStr)
		if err != nil {
			return nil, fmt.Errorf("[ERROR] Illegal value in $WEBMOCK_PROXY_PORT: %v", err)
		}
	}
	if str := os.Getenv("WEBMOCK_PROXY_CACHE_DIR"); str != "" {
		str := strings.TrimRight(str, "/")
		cacheDir = str
	}
	return &Config{
		record:   record,
		local:    local,
		port:     port,
		cacheDir: cacheDir,
	}, nil
}

repository: wantedly/webmock-proxy

repo_name: wantedly/webmock-proxy


text:
@inproceedings{YangKKN16,
 author = {Shuo Yang and
Tushar Khot and
Kristian Kersting and
Sriraam Natarajan},
 booktitle = {Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence},
 pages = {2265--2271},
 title = {Learning Continuous-Time Bayesian Networks in Relational Domains:
A Non-Parametric Approach},
 year = {2016}
}


text:
package states

import (
	"fmt"

	lr0items "github.com/goccmack/gogll/v3/lr1/items"
)

type ConfigGroup struct {
	Item *lr0items.Item
	*ContextSet
	hashKey string
}

func NewConfigGroup(item *lr0items.Item, context ...string) *ConfigGroup {
	ctxt := NewContextSet()
	ctxt.Add(context...)
	return &ConfigGroup{
		Item:       item,
		ContextSet: ctxt,
		hashKey:    item.HashKey(),
	}
}

func (this *ConfigGroup) AddContext(c ...string) *ConfigGroup {
	this.ContextSet.Add(c...)
	return this
}

func (this *ConfigGroup) Core() *lr0items.Item {
	return this.Item
}

func (this *ConfigGroup) Equal(that *ConfigGroup) bool {
	return this.hashKey == that.hashKey && this.ContextSet.Equal(that.ContextSet)
}

func (this *ConfigGroup) HashKey() string {
	return this.hashKey
}

func (this *ConfigGroup) IsNucleus() bool {
	return this.Item.Position > 0
}

/*
Return:
	-1 if this < that
	0 if this == that
	1 if this > that
*/
func (this *ConfigGroup) Compare(that *ConfigGroup) int {
	switch {
	case this.hashKey < that.hashKey:
		return -1
	case this.hashKey == that.hashKey:
		return 0
	}
	return 1
}

func (this *ConfigGroup) String() string {
	return fmt.Sprintf("%s %s", this.Item, this.ContextSet)
}

repository: goccmack/gogll

repo_name: goccmack/gogll


text:
// ClueGetter - Does things with mail
//
// Copyright 2016 Dolf Schimmel, Freeaqingme.
//
// This Source Code Form is subject to the terms of the two-clause BSD license.
// For its contents, please refer to the LICENSE file.
//
package core

import (
	"github.com/scalingdata/gcfg"
)

type config struct {
	ClueGetter struct {
		IPC_Socket                       string
		Instance                         string
		Noop                             bool
		Exit_On_Panic                    bool
		Policy_Listen_Port               string
		Policy_Listen_Host               string
		Rdbms_Driver                     string
		Rdbms_User                       string
		Rdbms_Address                    string
		Rdbms_Password                   string
		Rdbms_Protocol                   string
		Rdbms_Database                   string
		Message_Reject_Score             float64
		Message_Tempfail_Score           float64
		Message_Spamflag_Score           float64
		Breaker_Score                    float64
		Milter_Socket                    string
		Whitelist                        []string
		Add_Header                       []string
		Add_Header_X_Spam_Score          bool
		Insert_Missing_Message_Id        bool
		Archive_Prune_Interval           int
		Archive_Retention_Body           float64
		Archive_Retention_Header         float64
		Archive_Retention_Message_Result float64
		Archive_Retention_Message        float64
		Archive_Retention_Safeguard      float64
		Message_Cache_Size               int
	}
	Redis struct {
		Enabled  bool
		Host     []string
		Method   string
		Dump_Dir string
		Dump_Key []string
	}
	ModuleGroup   map[string]*ConfigModuleGroup
	Elasticsearch struct {
		Enabled bool
		Sniff   bool
		Url     []string
	}
	Http struct {
		Enabled          bool
		Listen_Port      string
		Listen_Host      string
		Google_Analytics string
	}
	HttpFrontend  map[string]*ConfigHttpFrontend
	LuaModule     map[string]*ConfigLuaModule
	BounceHandler struct {
		Enabled     bool
		Listen_Port string
		Listen_Host string
		Dump_Dir    string
	}
	Bayes struct {
		Enabled bool
	}
	MailQueue struct {
		Enabled             bool
		Spool_Dir           string
		Update_Interval     int
		PostsuperExecutable string
		PostcatExecutable   string
	}
	Srs struct {
		Enabled          bool
		Recipient_Header string
	}
	Clamav struct {
		Enabled       bool
		Address       string
		Default_Score float64
		Max_Size      int
	}
	Contacts struct {
		Enabled                 bool
		Whitelist_Address_Score float64
		Whitelist_Domain_Score  float64
		Blacklist_Address_Score float64
		Blacklist_Domain_Score  float64
	}
	Greylisting struct {
		Enabled        bool
		Initial_Score  float64
		Initial_Period uint16
		Whitelist_Spf  []string
	}
	Quotas struct {
		Enabled                  bool
		Account_Sender           bool
		Account_Sender_Domain    bool
		Account_Recipient        bool
		Account_Recipient_Domain bool
		Account_Client_Address   bool
		Account_Sasl_Username    bool
	}
	Rspamd struct {
		Enabled    bool
		Host       string
		Port       int
		Multiplier float64
	}
	SpamAssassin struct {
		Enabled         bool
		Host            string
		Port            int
		Timeout         float64
		Connect_Timeout float64
		Max_Size        int
	}
}

type ConfigHttpFrontend struct {
	Enabled               bool
	Listen_Port           string
	Listen_Host           string
	Enable_Proxy_Protocol bool
}

type ConfigLuaModule struct {
	Enabled        bool
	Script         string
	ScriptContents string
}

type SessionConfig struct {
	ClueGetter struct {
		Message_Reject_Score      float64
		Message_Tempfail_Score    float64
		Message_Spamflag_Score    float64
		Breaker_Score             float64
		Insert_Missing_Message_Id bool
	}
	Clamav struct {
		Enabled       bool
		Default_Score float64
		Max_Size      int
	}
	Contacts struct {
		Enabled                 bool
		Whitelist_Address_Score float64
		Whitelist_Domain_Score  float64
		Blacklist_Address_Score float64
		Blacklist_Domain_Score  float64
	}
	Greylisting struct {
		Enabled        bool
		Initial_Score  float64
		Initial_Period uint16
		Whitelist_Spf  []string
	}
	Quotas struct {
		Enabled bool
	}
	Rspamd struct {
		Enabled    bool
		Multiplier float64
	}
	SpamAssassin struct {
		Enabled         bool
		Timeout         float64
		Connect_Timeout float64
		Max_Size        int
	}
}

type ConfigModuleGroup struct {
	Module []string
}

func (conf *config) sessionConfig() (sconf *SessionConfig) {
	sconf = &SessionConfig{}
	sconf.ClueGetter.Message_Reject_Score = conf.ClueGetter.Message_Reject_Score
	sconf.ClueGetter.Message_Tempfail_Score = conf.ClueGetter.Message_Tempfail_Score
	sconf.ClueGetter.Message_Spamflag_Score = conf.ClueGetter.Message_Spamflag_Score
	sconf.ClueGetter.Breaker_Score = conf.ClueGetter.Breaker_Score
	sconf.ClueGetter.Insert_Missing_Message_Id = conf.ClueGetter.Insert_Missing_Message_Id

	sconf.Clamav.Enabled = conf.Clamav.Enabled
	sconf.Clamav.Default_Score = conf.Clamav.Default_Score
	sconf.Clamav.Max_Size = conf.Clamav.Max_Size

	sconf.Contacts.Enabled = conf.Contacts.Enabled
	sconf.Contacts.Whitelist_Address_Score = conf.Contacts.Whitelist_Address_Score
	sconf.Contacts.Whitelist_Domain_Score = conf.Contacts.Whitelist_Domain_Score
	sconf.Contacts.Blacklist_Address_Score = conf.Contacts.Blacklist_Address_Score
	sconf.Contacts.Blacklist_Domain_Score = conf.Contacts.Blacklist_Domain_Score
	sconf.Contacts.Whitelist_Address_Score = conf.Contacts.Whitelist_Address_Score
	sconf.Contacts.Whitelist_Domain_Score = conf.Contacts.Whitelist_Domain_Score

	sconf.Greylisting.Enabled = conf.Greylisting.Enabled
	sconf.Greylisting.Initial_Score = conf.Greylisting.Initial_Score
	sconf.Greylisting.Initial_Period = conf.Greylisting.Initial_Period
	sconf.Greylisting.Whitelist_Spf = conf.Greylisting.Whitelist_Spf

	sconf.Quotas.Enabled = conf.Quotas.Enabled

	sconf.Rspamd.Enabled = conf.Rspamd.Enabled
	sconf.Rspamd.Multiplier = conf.Rspamd.Multiplier

	sconf.SpamAssassin.Enabled = conf.SpamAssassin.Enabled
	sconf.SpamAssassin.Timeout = conf.SpamAssassin.Timeout
	sconf.SpamAssassin.Connect_Timeout = conf.SpamAssassin.Connect_Timeout
	sconf.SpamAssassin.Max_Size = conf.SpamAssassin.Max_Size

	return
}

func LoadConfig(cfgFile string, cfg *config) {
	err := gcfg.ReadFileInto(cfg, cfgFile)

	if err != nil {
		Log.Fatal("Couldnt read config file: " + err.Error())
	}
}

func DefaultConfig(cfg *config) {
	cfg.ClueGetter.IPC_Socket = "/var/run/cluegetter/ipc.sock"
	cfg.ClueGetter.Instance = "default"
	cfg.ClueGetter.Noop = false
	cfg.ClueGetter.Exit_On_Panic = false
	cfg.ClueGetter.Policy_Listen_Port = "10032"
	cfg.ClueGetter.Policy_Listen_Host = "0.0.0.0"
	cfg.ClueGetter.Rdbms_Driver = "mysql"
	cfg.ClueGetter.Rdbms_User = "root"
	cfg.ClueGetter.Rdbms_Address = "localhost:3306"
	cfg.ClueGetter.Rdbms_Password = ""
	cfg.ClueGetter.Rdbms_Protocol = "tcp"
	cfg.ClueGetter.Rdbms_Database = "cluegetter"
	cfg.ClueGetter.Message_Reject_Score = 5
	cfg.ClueGetter.Message_Tempfail_Score = 8
	cfg.ClueGetter.Message_Spamflag_Score = 4.5
	cfg.ClueGetter.Breaker_Score = 100
	cfg.ClueGetter.Milter_Socket = "inet:10033@127.0.0.1"
	cfg.ClueGetter.Whitelist = []string{} // "127.0.0.0/8", "::1" }
	cfg.ClueGetter.Add_Header = []string{}
	cfg.ClueGetter.Insert_Missing_Message_Id = true
	cfg.ClueGetter.Archive_Prune_Interval = 21600
	cfg.ClueGetter.Archive_Retention_Safeguard = 1.01
	cfg.ClueGetter.Archive_Retention_Body = 2
	cfg.ClueGetter.Archive_Retention_Header = 26
	cfg.ClueGetter.Archive_Retention_Message_Result = 2
	cfg.ClueGetter.Archive_Retention_Message = 52
	cfg.ClueGetter.Message_Cache_Size = 256

	cfg.Redis.Host = []string{}
	cfg.Redis.Method = "standalone"
	cfg.Redis.Dump_Key = []string{}

	cfg.Elasticsearch.Sniff = true
	cfg.Elasticsearch.Url = []string{}

	cfg.Http.Enabled = true
	cfg.Http.Listen_Port = "0"
	cfg.Http.Listen_Host = "127.0.0.1"
	cfg.Http.Google_Analytics = ""

	cfg.BounceHandler.Listen_Port = "10034"
	cfg.BounceHandler.Listen_Host = "127.0.0.1"

	cfg.MailQueue.Spool_Dir = "/var/spool/postfix"
	cfg.MailQueue.Update_Interval = 5

	cfg.Srs.Recipient_Header = "X-Original-To"

	cfg.Clamav.Default_Score = 10.0
	cfg.Clamav.Max_Size = 10485760

	cfg.Contacts.Whitelist_Address_Score = -2.5
	cfg.Contacts.Whitelist_Domain_Score = -0.85
	cfg.Contacts.Blacklist_Address_Score = 6
	cfg.Contacts.Blacklist_Domain_Score = 1

	cfg.Greylisting.Initial_Score = 7.0
	cfg.Greylisting.Initial_Period = 5
	cfg.Greylisting.Whitelist_Spf = []string{}

	cfg.Quotas.Account_Client_Address = true
	cfg.Quotas.Account_Sender = false
	cfg.Quotas.Account_Sender_Domain = false
	cfg.Quotas.Account_Recipient = false
	cfg.Quotas.Account_Recipient_Domain = false
	cfg.Quotas.Account_Sasl_Username = false

	cfg.Rspamd.Host = "127.0.0.1"
	cfg.Rspamd.Port = 11333
	cfg.Rspamd.Multiplier = 0.67

	cfg.SpamAssassin.Host = "127.0.0.1"
	cfg.SpamAssassin.Port = 783
	cfg.SpamAssassin.Timeout = 10
	cfg.SpamAssassin.Connect_Timeout = 0.1
	cfg.SpamAssassin.Max_Size = 500000 // Default SA max file size: 512 KB
}

func GetNewConfig() *config {
	out := &config{}
	DefaultConfig(out)

	return out
}

func SetConfig(config *config) {
	Config = *config
}

repository: daffodil/ClueGetter

repo_name: daffodil/ClueGetter


text:
# liste of file
# new file news to be add in this list
# you can also define your own list and add it to the wall list
#  for exmape : set ( ${WALLFILE} ${my_file_list_to_add})

        file(
                        GLOB
                        source_files
                        ${My_Source}/tb2abstractconstr.cpp
                        ${My_Source}/tb2arithmetic.cpp
                        ${My_Source}/tb2automaton.cpp
                        ${My_Source}/tb2bep.cpp
                        ${My_Source}/tb2binconstr.cpp
                        ${My_Source}/tb2btd.cpp
                        ${My_Source}/tb2btlist.cpp
                        ${My_Source}/tb2btqueue.cpp
                        ${My_Source}/tb2clusters.cpp
                        ${My_Source}/tb2constraint.cpp
                        ${My_Source}/tb2graph.cpp
                        ${My_Source}/tb2globaldecomposable.cpp
                        ${My_Source}/tb2globalconstr.cpp
                        ${My_Source}/tb2flowbasedconstr.cpp
                        ${My_Source}/tb2alldiffconstr.cpp
                        ${My_Source}/tb2globalcardinalityconstr.cpp
                        ${My_Source}/tb2sameconstr.cpp
                        ${My_Source}/tb2regularflowconstr.cpp
                        ${My_Source}/tb2dpglobalconstr.cpp
                        ${My_Source}/tb2regularDPconstr.cpp
                        ${My_Source}/tb2amongconstr.cpp
                        ${My_Source}/tb2grammarconstr.cpp
                        ${My_Source}/tb2wgrammar.cpp
                        ${My_Source}/tb2maxconstr.cpp
                        ${My_Source}/tb2treeconstr.cpp
##                        ${My_Source}/tb2linearconstr.cpp
##                        ${My_Source}/tb2lpsconstr.cpp
##                        ${My_Source}/tb2mipsolver.cpp
                        ${My_Source}/tb2domain.cpp
                        ${My_Source}/tb2enumvar.cpp
                        ${My_Source}/tb2intervar.cpp
                        ${My_Source}/tb2main.cpp
                        ${My_Source}/tb2naryconstr.cpp
                        ${My_Source}/tb2pedigree.cpp
                        ${My_Source}/tb2haplotype.cpp
                        ${My_Source}/tb2queue.cpp
                        ${My_Source}/tb2randomgen.cpp
                        ${My_Source}/tb2reader.cpp
                        ${My_Source}/tb2solver.cpp
                        ${My_Source}/tb2system.cpp
                        ${My_Source}/tb2ternaryconstr.cpp
                        ${My_Source}/tb2vac.cpp
                        ${My_Source}/tb2vacutils.cpp
                        ${My_Source}/tb2variable.cpp
                        ${My_Source}/tb2wcsp.cpp
			${My_Source}/incop/*.cpp
        )

MESSAGE(STATUS "-------------\n")
MESSAGE(STATUS "toulbar file = ${source_files}\n")
MESSAGE(STATUS "-------------\n")

#########################
# file list used for lib building
########################

        file(
                        GLOB
                        LIBTB2FILE
                        ${My_Source}/tb2abstractconstr.*pp
                        ${My_Source}/tb2arithmetic.*pp
                        ${My_Source}/tb2automaton.cpp
                        ${My_Source}/tb2bep.*pp
                        ${My_Source}/tb2binconstr.*pp
                        ${My_Source}/tb2btd.cpp
                        ${My_Source}/tb2btlist.*pp
                        ${My_Source}/tb2btqueue.*pp
                        ${My_Source}/tb2clusters.*pp
                        ${My_Source}/tb2constraint.*pp
                        ${My_Source}/tb2graph.*pp
                        ${My_Source}/tb2globaldecomposable.cpp
                        ${My_Source}/tb2globalconstr.*pp
                        ${My_Source}/tb2flowbasedconstr.*pp
                        ${My_Source}/tb2alldiffconstr.*pp
                        ${My_Source}/tb2globalcardinalityconstr.*pp
                        ${My_Source}/tb2sameconstr.*pp
                        ${My_Source}/tb2regularflowconstr.*pp
                        ${My_Source}/tb2dpglobalconstr.*pp
                        ${My_Source}/tb2regularDPconstr.*pp
                        ${My_Source}/tb2amongconstr.*pp
                        ${My_Source}/tb2grammarconstr.*pp
                        ${My_Source}/tb2wgrammar.*pp
                        ${My_Source}/tb2maxconstr.*pp
                        ${My_Source}/tb2treeconstr.*pp
##                        ${My_Source}/tb2linearconstr.*pp
##                        ${My_Source}/tb2lpsconstr.*pp
##                        ${My_Source}/tb2mipsolver.*pp
                        ${My_Source}/tb2domain.*pp
                        ${My_Source}/tb2enumvar.*pp
                        ${My_Source}/tb2intervar.*pp
                        ${My_Source}/tb2naryconstr.*pp
                        ${My_Source}/tb2pedigree.*pp
                        ${My_Source}/tb2haplotype.cpp
                        ${My_Source}/tb2queue.*pp
                        ${My_Source}/tb2randomgen.*pp
                        ${My_Source}/tb2reader.*pp
                        ${My_Source}/tb2solver.cpp
                        ${My_Source}/tb2system.*pp
                        ${My_Source}/tb2ternaryconstr.*pp
                        ${My_Source}/tb2vac.*pp
                        ${My_Source}/tb2vacutils.*pp
                        ${My_Source}/tb2variable.*pp
                        ${My_Source}/tb2wcsp.*pp
                        ${My_Source}/incop/*.h
			${My_Source}/incop/*.cpp
        )

repository: clinicalml/fw-inference

repo_name: clinicalml/fw-inference


text:
require glib.inc

PR = "r2"
PE = "1"

DEPENDS += "libffi python-argparse-native zlib"
DEPENDS_virtclass-native += "libffi-native python-argparse-native"
DEPENDS_virtclass-nativesdk += "libffi-nativesdk python-argparse-native zlib-nativesdk"

SHRT_VER = "${@d.getVar('PV',1).split('.')[0]}.${@d.getVar('PV',1).split('.')[1]}"

SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
           file://configure-libtool.patch \
           file://60_wait-longer-for-threads-to-die.patch \
           file://g_once_init_enter.patch \
           file://glib-2.0_fix_for_x32.patch \
           file://nodbus.patch \
          "
SRC_URI[md5sum] = "0f9fa329c6c1012d0fd861ad3d8a4520"
SRC_URI[sha256sum] = "e6cbb27c71c445993346e785e8609cc75cea2941e32312e544872feba572dd27"

SRC_URI_append_virtclass-native = " file://glib-gettextize-dir.patch"
BBCLASSEXTEND = "native nativesdk"

PERLPATH = "${bindir}/env perl"
PERLPATH_virtclass-native = "/usr/bin/env perl"
PERLPATH_virtclass-nativesdk = "/usr/bin/env perl"

do_configure_prepend() {
  # missing ${topdir}/gtk-doc.make and --disable-gtk-doc* is not enough, because it calls gtkdocize (not provided by gtk-doc-native)
  sed -i '/^docs/d' ${S}/configure.ac
  sed -i 's/SUBDIRS = . m4macros glib gmodule gthread gobject gio tests po docs/SUBDIRS = . m4macros glib gmodule gthread gobject gio tests po/g' ${S}/Makefile.am
  sed -i -e "s:TEST_PROGS += gdbus-serialization::g"  ${S}/gio/tests/Makefile.am
}

do_install_append() {
  # remove some unpackaged files
  rm -f ${D}${libdir}/gdbus-2.0/codegen/*.pyc
  rm -f ${D}${libdir}/gdbus-2.0/codegen/*.pyo
  # and empty dirs
  rmdir ${D}${libdir}/gio/modules/
  rmdir ${D}${libdir}/gio/

  # Some distros have both /bin/perl and /usr/bin/perl, but we set perl location
  # for target as /usr/bin/perl, so fix it to /usr/bin/perl.
  if [ -f ${D}${bindir}/glib-mkenums ]; then
    sed -i -e '1s,#!.*perl,#! ${PERLPATH},' ${D}${bindir}/glib-mkenums
  fi
}

PACKAGES += "${PN}-codegen"
FILES_${PN}-codegen = "${libdir}/gdbus-2.0/codegen/*.py"
FILES_${PN} += "${datadir}/glib-2.0/gettext/mkinstalldirs ${datadir}/glib-2.0/gettext/po/Makefile.in.in"


text:
package common

import (
	"encoding/json"
	"net/http"

	"github.com/pkg/errors"
)

func JSONResponse(w http.ResponseWriter, respObj interface{}) {
	if err := JSONResponseC(w, respObj); err != nil {
		ErrorResponse(w, err)
	}
}

func JSONResponseC(w http.ResponseWriter, respObj interface{}) error {
	respJson, err := json.Marshal(respObj)
	if err != nil {
		return errors.Wrap(err, "failed to marshal JSON")
	}

	w.Header().Set("Content-Type", "application/json")
	if _, err := w.Write(respJson); err != nil {
		return errors.Wrap(err, "failed to write response")
	}

	return nil
}

func ErrorResponse(w http.ResponseWriter, err error) {
	// TODO: Except in debug mode, don't serve errors to clients.
	http.Error(w, err.Error(), http.StatusInternalServerError)
}

// --------------
// XXX: Code below this line was moved here from `cmd/publisherd/util.go` and probably needs some refactoring.  In
// particular, many things don't seem to be exported.
// --------------

type WebError interface {
	error

	StatusCode() int
}

type webError struct {
	status int
	msg    string
}

func (err *webError) StatusCode() int {
	return err.status
}

func (err *webError) Error() string {
	msg := err.msg
	if msg == "" {
		msg = http.StatusText(err.status)
	}
	return msg
}

var _ WebError = (*webError)(nil)

var (
	ErrMethodNotAllowed = &webError{status: http.StatusMethodNotAllowed}
)

type MyHandlerFunc func(w http.ResponseWriter, req *http.Request) (respObj interface{}, err WebError)

repository: cachecashproject/go-cachecash

repo_name: cachecashproject/go-cachecash


text:
package request_test

import (
	"fmt"
	"net/http"
	"os"

	"github.com/mozillazg/request"
)

func ExampleGet() {
	c := &http.Client{}
	a := request.NewArgs(c)
	url := "http://httpbin.org/get"
	resp, _ := request.Get(url, a)
	d, _ := resp.Json()
	defer resp.Body.Close()
	fmt.Println(resp.Ok())
	fmt.Println(d.Get("url").MustString())
	// Output:
	//true
	//http://httpbin.org/get
}

func ExampleGet_params() {
	c := &http.Client{}
	a := request.NewArgs(c)
	a.Params = map[string]string{
		"a": "1",
		"b": "2",
	}
	url := "http://httpbin.org/get"
	resp, _ := request.Get(url, a)
	d, _ := resp.Json()
	defer resp.Body.Close()
	fmt.Println(d.Get("url").MustString())
	// Output:
	//http://httpbin.org/get?a=1&b=2
}

func ExampleGet_customHeaders() {
	c := &http.Client{}
	a := request.NewArgs(c)
	a.Headers = map[string]string{
		"X-Abc":      "abc",
		"User-Agent": "go-request-test",
	}
	url := "http://httpbin.org/get"
	resp, _ := request.Get(url, a)
	d, _ := resp.Json()
	defer resp.Body.Close()
	fmt.Println(d.Get("headers").Get("User-Agent").MustString())
	fmt.Println(d.Get("headers").Get("X-Abc").MustString())
	// Output:
	//go-request-test
	//abc
}

func ExamplePost() {
	c := &http.Client{}
	a := request.NewArgs(c)
	a.Data = map[string]string{
		"a": "1",
		"b": "2",
	}
	url := "http://httpbin.org/post"
	resp, _ := request.Post(url, a)
	defer resp.Body.Close()
}

func ExampleGet_cookies() {
	c := &http.Client{}
	a := request.NewArgs(c)
	a.Cookies = map[string]string{
		"name": "value",
		"foo":  "bar",
	}
	url := "http://httpbin.org/cookies"
	resp, _ := request.Get(url, a)
	defer resp.Body.Close()
}

func ExamplePost_files() {
	c := &http.Client{}
	a := request.NewArgs(c)
	f, _ := os.Open("test.txt")
	defer f.Close()
	a.Files = []request.FileField{
		request.FileField{"abc", "abc.txt", f},
	}
	url := "http://httpbin.org/post"
	resp, _ := request.Post(url, a)
	defer resp.Body.Close()
}

repository: zchking/request

repo_name: zchking/request