text:
@article{zou2019mldeepre,
 author = {Zou, Zhenzhen and Tian, Shuye and Gao, Xin and Li, Yu},
 journal = {Frontiers in Genetics},
 pages = {714},
 publisher = {Frontiers},
 title = {mlDEEPre: Multi-functional enzyme function prediction with hierarchical multi-label deep learning},
 volume = {9},
 year = {2019}
}

license: MIT

license_type: permissive

branch_name: refs/heads/master

extension: bib


text:
package filematcher

import (
	"fmt"
	"io/fs"
	"path/filepath"
	"sort"
	"strings"
)

// Match returns a sorted list of files and dirs matching a glob pattern
func Match(pattern string) ([]string, error) {
	if IsRemoteFile(pattern) {
		return []string{pattern}, nil
	}
	files, err := filepath.Glob(pattern)
	if err != nil {
		return nil, err
	}
	// files is nil when pattern does not match any files
	if files == nil {
		return nil, fmt.Errorf("%s: %w", pattern, fs.ErrNotExist)
	}
	var envFiles []string
	for _, f := range files {
		abs, err := filepath.Abs(f)
		if err != nil {
			return nil, err
		}
		envFiles = append(envFiles, abs)
	}
	sort.Strings(envFiles)
	return envFiles, nil
}

// IsRemoteFile distinguishes remote files from local files
func IsRemoteFile(file string) bool {
	return strings.HasPrefix(file, "http://") || strings.HasPrefix(file, "https://")
}

repository: matteo-grella/qbec

repo_name: matteo-grella/qbec

branch_name: refs/heads/main

extension: go


text:
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you 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 oauth2

import (
	"errors"
	"time"

	"github.com/apache/pulsar-client-go/oauth2/clock"
	"github.com/apache/pulsar-client-go/oauth2/clock/testing"
	"golang.org/x/oauth2"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

type MockDeviceCodeProvider struct {
	Called                     bool
	CalledWithAudience         string
	CalledWithAdditionalScopes []string
	DeviceCodeResult           *DeviceCodeResult
	ReturnsError               error
}

func (cp *MockDeviceCodeProvider) GetCode(audience string, additionalScopes ...string) (*DeviceCodeResult, error) {
	cp.Called = true
	cp.CalledWithAudience = audience
	cp.CalledWithAdditionalScopes = additionalScopes
	return cp.DeviceCodeResult, cp.ReturnsError
}

type MockDeviceCodeCallback struct {
	Called           bool
	DeviceCodeResult *DeviceCodeResult
	ReturnsError     error
}

func (c *MockDeviceCodeCallback) Callback(code *DeviceCodeResult) error {
	c.Called = true
	c.DeviceCodeResult = code
	if c.ReturnsError != nil {
		return c.ReturnsError
	}
	return nil
}

var _ = Describe("DeviceCodeFlow", func() {

	Describe("Authorize", func() {
		const audience = "test_clientID"

		var mockClock clock.Clock
		var mockCodeProvider *MockDeviceCodeProvider
		var mockTokenExchanger *MockTokenExchanger
		var mockCallback *MockDeviceCodeCallback
		var flow *DeviceCodeFlow

		BeforeEach(func() {
			mockClock = testing.NewFakeClock(time.Unix(0, 0))

			mockCodeProvider = &MockDeviceCodeProvider{
				DeviceCodeResult: &DeviceCodeResult{
					DeviceCode:              "test_deviceCode",
					UserCode:                "test_userCode",
					VerificationURI:         "http://verification_uri",
					VerificationURIComplete: "http://verification_uri_complete",
					ExpiresIn:               10,
					Interval:                5,
				},
			}

			expectedTokens := TokenResult{AccessToken: "accessToken", RefreshToken: "refreshToken", ExpiresIn: 1234}
			mockTokenExchanger = &MockTokenExchanger{
				ReturnsTokens: &expectedTokens,
			}

			mockCallback = &MockDeviceCodeCallback{}

			opts := DeviceCodeFlowOptions{
				IssuerEndpoint:   "http://issuer",
				ClientID:         "test_clientID",
				AdditionalScopes: nil,
				AllowRefresh:     true,
			}
			flow = newDeviceCodeFlow(
				opts,
				oidcEndpoints,
				mockCodeProvider,
				mockTokenExchanger,
				mockCallback.Callback,
				mockClock,
			)
		})

		It("invokes DeviceCodeProvider", func() {
			_, _ = flow.Authorize(audience)
			Expect(mockCodeProvider.Called).To(BeTrue())
			Expect(mockCodeProvider.CalledWithAdditionalScopes).To(ContainElement("offline_access"))
		})

		It("invokes callback with returned code", func() {
			_, _ = flow.Authorize(audience)
			Expect(mockCallback.Called).To(BeTrue())
			Expect(mockCallback.DeviceCodeResult).To(Equal(mockCodeProvider.DeviceCodeResult))
		})

		It("invokes TokenExchanger with returned code", func() {
			_, _ = flow.Authorize(audience)
			Expect(mockTokenExchanger.CalledWithRequest).To(Equal(&DeviceCodeExchangeRequest{
				TokenEndpoint: oidcEndpoints.TokenEndpoint,
				ClientID:      "test_clientID",
				PollInterval:  time.Duration(5) * time.Second,
				DeviceCode:    "test_deviceCode",
			}))
		})

		It("returns an authorization grant", func() {
			grant, _ := flow.Authorize(audience)
			Expect(grant).ToNot(BeNil())
			Expect(grant.Audience).To(Equal(audience))
			Expect(grant.ClientID).To(Equal("test_clientID"))
			Expect(grant.ClientCredentials).To(BeNil())
			Expect(grant.TokenEndpoint).To(Equal(oidcEndpoints.TokenEndpoint))
			expected := convertToOAuth2Token(mockTokenExchanger.ReturnsTokens, mockClock)
			Expect(*grant.Token).To(Equal(expected))
		})
	})
})

var _ = Describe("DeviceAuthorizationGrantRefresher", func() {

	Describe("Refresh", func() {
		var mockClock clock.Clock
		var mockTokenExchanger *MockTokenExchanger
		var refresher *DeviceAuthorizationGrantRefresher
		var grant *AuthorizationGrant

		BeforeEach(func() {
			mockClock = testing.NewFakeClock(time.Unix(0, 0))

			mockTokenExchanger = &MockTokenExchanger{}

			refresher = &DeviceAuthorizationGrantRefresher{
				exchanger: mockTokenExchanger,
				clock:     mockClock,
			}

			token := oauth2.Token{AccessToken: "gat", RefreshToken: "grt", Expiry: time.Unix(1, 0)}
			grant = &AuthorizationGrant{
				Type:          GrantTypeDeviceCode,
				ClientID:      "test_clientID",
				TokenEndpoint: oidcEndpoints.TokenEndpoint,
				Token:         &token,
			}
		})

		It("invokes the token exchanger", func() {
			mockTokenExchanger.ReturnsTokens = &TokenResult{
				AccessToken: "new token",
			}

			_, _ = refresher.Refresh(grant)
			Expect(*mockTokenExchanger.RefreshCalledWithRequest).To(Equal(RefreshTokenExchangeRequest{
				TokenEndpoint: oidcEndpoints.TokenEndpoint,
				ClientID:      grant.ClientID,
				RefreshToken:  "grt",
			}))
		})

		It("returns the refreshed access token from the TokenExchanger", func() {
			mockTokenExchanger.ReturnsTokens = &TokenResult{
				AccessToken: "new token",
			}

			grant, _ = refresher.Refresh(grant)
			Expect(grant.Token.AccessToken).To(Equal(mockTokenExchanger.ReturnsTokens.AccessToken))
		})

		It("preserves the existing refresh token from the TokenExchanger", func() {
			mockTokenExchanger.ReturnsTokens = &TokenResult{
				AccessToken: "new token",
			}

			grant, _ = refresher.Refresh(grant)
			Expect(grant.Token.RefreshToken).To(Equal("grt"))
		})

		It("returns the refreshed refresh token from the TokenExchanger", func() {
			mockTokenExchanger.ReturnsTokens = &TokenResult{
				AccessToken:  "new token",
				RefreshToken: "new token",
			}

			grant, _ = refresher.Refresh(grant)
			Expect(grant.Token.RefreshToken).To(Equal("new token"))
		})

		It("returns a meaningful expiration time", func() {
			mockTokenExchanger.ReturnsTokens = &TokenResult{
				AccessToken: "new token",
				ExpiresIn:   60,
			}

			grant, _ = refresher.Refresh(grant)
			Expect(grant.Token.Expiry).To(Equal(mockClock.Now().Add(time.Duration(60) * time.Second)))
		})

		It("returns an error when TokenExchanger does", func() {
			mockTokenExchanger.ReturnsError = errors.New("someerror")

			_, err := refresher.Refresh(grant)
			Expect(err.Error()).To(Equal("could not exchange refresh token: someerror"))
		})
	})
})

repository: apache/pulsar-client-go

repo_name: apache/pulsar-client-go

gha_language: Go


text:
// Copyright 2020 tsuru 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 auth

import (
	"github.com/pkg/errors"
	"github.com/tsuru/tsuru/permission"
	"github.com/tsuru/tsuru/storage"
	authTypes "github.com/tsuru/tsuru/types/auth"
)

var (
	_ authTypes.GroupService = &groupService{}

	errGroupNameEmpty = errors.New("group name cannot be empty")
)

func GroupService() (authTypes.GroupService, error) {
	dbDriver, err := storage.GetCurrentDbDriver()
	if err != nil {
		dbDriver, err = storage.GetDefaultDbDriver()
		if err != nil {
			return nil, err
		}
	}
	return &groupService{
		storage: dbDriver.AuthGroupStorage,
	}, nil
}

type groupService struct {
	storage authTypes.GroupStorage
}

func (s *groupService) List(filter []string) ([]authTypes.Group, error) {
	return s.storage.List(filter)
}

func (s *groupService) AddRole(name, roleName, contextValue string) error {
	if name == "" {
		return errGroupNameEmpty
	}
	_, err := permission.FindRole(roleName)
	if err != nil {
		return err
	}
	return s.storage.AddRole(name, roleName, contextValue)
}

func (s *groupService) RemoveRole(name, roleName, contextValue string) error {
	if name == "" {
		return errGroupNameEmpty
	}
	return s.storage.RemoveRole(name, roleName, contextValue)
}

repository: tsuru/tsuru

repo_name: tsuru/tsuru


text:
package embeddedShell

import (
	"context"
	"fmt"

	"github.com/ipfs/go-ipfs/core/coreapi"
	dag "github.com/ipfs/go-merkledag"
	"github.com/ipfs/go-unixfs"
	"github.com/ipfs/interface-go-ipfs-core/options"
	"github.com/ipfs/interface-go-ipfs-core/path"
)

func (s *Shell) NewObject(template string) (string, error) {
	node := new(dag.ProtoNode)
	switch template {
	case "":
		break
	case "unixfs-dir":
		node.SetData(unixfs.FolderPBData())
	default:
		return "", fmt.Errorf("unknown template %s", template)
	}
	err := s.node.DAG.Add(s.ctx, node)
	if err != nil {
		return "", err
	}

	return node.Cid().String(), nil
}

// TODO: extract all this logic from the core/commands/object.go to avoid dupe code
func (s *Shell) Patch(root, action string, args ...string) (string, error) {
	api, err := coreapi.NewCoreAPI(s.node)
	if err != nil {
		return "", err
	}

	insertpath := args[0]
	childhash := path.New(args[1])

	switch action {
	case "add-link":
		h, err := api.Object().AddLink(context.Background(), path.New(root), insertpath, childhash)
		if err != nil {
			return "", err
		}

		return h.Cid().String(), nil
	default:
		return "", fmt.Errorf("unsupported action (impl not complete)")
	}
}

//TODO: hrm, maybe this interface could be better
func (s *Shell) PatchLink(root, npath, childhash string, create bool) (string, error) {
	api, err := coreapi.NewCoreAPI(s.node)
	if err != nil {
		return "", err
	}

	h, err := api.Object().AddLink(context.Background(), path.New(root), npath, path.New(childhash), options.Object.Create(create))
	if err != nil {
		return "", err
	}

	return h.Cid().String(), nil
}

repository: whyrusleeping/ipfs-embedded-shell

repo_name: whyrusleeping/ipfs-embedded-shell

gha_license_id: MIT


text:
package models

import (
	"bytes"
	"encoding/binary"
	"fmt"
	"strings"
)

type memDelta struct {
	addr  uint64
	last  []byte
	data  []byte
	write bool
	tag   byte
}

type MemLog struct {
	order  binary.ByteOrder
	log    []*memDelta
	frozen bool
}

func NewMemLog(order binary.ByteOrder) *MemLog {
	return &MemLog{order: order}
}

func (m *MemLog) Empty() bool {
	return len(m.log) == 0
}

func (m *MemLog) Reset() {
	m.log = nil
	m.frozen = false
}

func (m *MemLog) Freeze() {
	m.frozen = true
}

func (m *MemLog) Flush(bits int) string {
	tmp := m.String(bits)
	m.Reset()
	return tmp
}

func (m *MemLog) Adjacent(addr uint64, p []byte, write bool) (delta *memDelta, dup bool) {
	for _, delta := range m.log {
		if delta.write != write {
			continue
		}
		if addr == delta.addr && bytes.Equal(p, delta.last) {
			return delta, true
		}
		if addr == delta.addr+uint64(len(delta.data)) || addr == delta.addr-uint64(len(p)) {
			return delta, false
		}
	}
	return nil, false
}

func (m *MemLog) UpdateBytes(addr uint64, p []byte, write bool) {
	if m.frozen {
		return
	}
	var delta *memDelta
	var dup, before bool
	if delta, dup = m.Adjacent(addr, p, write); delta != nil {
		// adjacent to old memory delta
		if dup {
			return
		}
		if addr < delta.addr {
			delta.addr -= uint64(len(p))
			before = true
		}
		var tag byte
		if before {
			tag = '<'
		} else {
			tag = '>'
		}
		if delta.tag == ' ' {
			delta.tag = tag
		} else if delta.tag != tag {
			delta.tag = '~'
		}
	} else {
		// entirely new memory delta
		delta = &memDelta{addr, nil, nil, write, ' '}
		m.log = append(m.log, delta)
	}
	if before {
		data := make([]byte, len(p), len(p)+len(delta.data))
		copy(data, p)
		copy(data[len(p):], delta.data)
		delta.data = data
		delta.last = delta.data[:len(p)]
	} else {
		delta.data = append(delta.data, p...)
		delta.last = delta.data[len(delta.data)-len(p):]
	}
}

func (m *MemLog) Update(addr uint64, size int, value int64, write bool) {
	var tmp [8]byte
	switch size {
	case 1:
		tmp[0] = byte(value)
	case 2:
		m.order.PutUint16(tmp[:], uint16(value))
	case 4:
		m.order.PutUint32(tmp[:], uint32(value))
	case 8:
		m.order.PutUint64(tmp[:], uint64(value))
	}
	m.UpdateBytes(addr, tmp[:size], write)
}

func (m *MemLog) String(bits int) string {
	var out []string
	for _, d := range m.log {
		t := "R"
		if d.write {
			t = "W"
		}
		for i, line := range HexDump(d.addr, d.data, bits) {
			if i == 0 {
				out = append(out, fmt.Sprintf("%s%c %s %s%c\n", t, d.tag, line, t, d.tag))
			} else {
				out = append(out, fmt.Sprintf("   %s\n", line))
			}
		}
	}
	return strings.Join(out, "")
}

repository: Grazfather/usercorn

repo_name: Grazfather/usercorn


text:
package main

import (
	"flag"
	"fmt"
	"log"
	"net"
	"net/http"

	"github.com/c0va23/go-proxyprotocol"
)

func main() {
	var addr string
	flag.StringVar(&addr, "bind", ":8080", "Bind address")
	flag.Parse()

	rawList, err := net.Listen("tcp", addr)
	if err != nil {
		log.Fatal(err)
	}

	list := proxyprotocol.NewDefaultListener(rawList).WithLogger(proxyprotocol.LoggerFunc(log.Printf))

	handler := http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
		log.Printf("Remote Addr: %s, URI: %s", req.RemoteAddr, req.RequestURI)
		fmt.Fprintf(res, "Hello, %s!\n", req.RemoteAddr)
	})

	log.Printf("Start listen on %s", rawList.Addr())
	if err := http.Serve(list, handler); err != nil {
		log.Fatal(err)
	}
}


text:
package safe

import (
	"github.com/bndw/pick/backends"
)

func Backup(client backends.Client) error {
	if err := client.Backup(); err != nil {
		return err
	}
	return nil
}

repository: gitter-badger/pick

repo_name: gitter-badger/pick


text:
# this is for emacs file handling -*- mode: cmake; indent-tabs-mode: nil -*-

# -- BEGIN LICENSE BLOCK ----------------------------------------------
# This file is part of the icmaker build system.
#
# This program is free software licensed under the BSD License. You can
# find a copy of this license in the LICENSE folder in the top directory
# of the source code.
#
# © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
# -- END LICENSE BLOCK ------------------------------------------------

#----------------------------------------------------------------------
# \file
#
# \author  Jan Oberlaender <oberlaender@fzi.de>
# \date    2014-08-13
#
# Try to find Smile.  Once done, this will define:
#  Smile_FOUND:          System has Smile
#  Smile_INCLUDE_DIRS:   The '-I' preprocessor flags (w/o the '-I')
#  Smile_LIBRARY_DIRS:   The paths of the libraries (w/o the '-L')
# Variables defined if pkg-config was employed:
#  Smile_DEFINITIONS:    Preprocessor definitions.
#  Smile_LIBRARIES:      only the libraries (w/o the '-l')
#  Smile_LDFLAGS:        all required linker flags
#  Smile_LDFLAGS_OTHER:  all other linker flags
#  Smile_CFLAGS:         all required cflags
#  Smile_CFLAGS_OTHER:   the other compiler flags
#  Smile_VERSION:        version of the module
#  Smile_PREFIX:         prefix-directory of the module
#  Smile_INCLUDEDIR:     include-dir of the module
#  Smile_LIBDIR:         lib-dir of the module
#----------------------------------------------------------------------

include(PrintLibraryStatus)
include(LibFindMacros)

libfind_lib_with_pkg_config(Smile libsmile
  HEADERS smile.h
  LIBRARIES smile
  HINTS /opt/tools/smile
  HEADER_PATHS /opt/tools/smile
  LIBRARY_PATHS /opt/tools/smile
  DEFINE _IC_BUILDER_SMILE_
  )

extension: cmake


text:
@article{Caputi062017GoogleSearchesFor,
 author = {Theodore L Caputi},
 doi = {10.1093/ntr/ntx143},
 journal = {Nicotine {\&} Tobacco Research},
 month = {jun},
 number = {6},
 pages = {779--783},
 publisher = {Oxford University Press ({OUP})},
 title = {Google Searches for {\textquotedblleft}Cheap Cigarettes{\textquotedblright} Spike at Tax Increases: Evidence from an Algorithm to Detect Spikes in Time Series Data},
 url = {https://doi.org/10.1093%2Fntr%2Fntx143},
 volume = {20},
 year = {2017}
}

repository: yesiknowjava/theodorecaputihugo

repo_name: yesiknowjava/theodorecaputihugo


text:
package main

import (
	"fmt"
	"io"
	"log"
	"os"
)

type MyReader interface {
	Read([]byte) (int, error)
}

type zeroReader struct{}

func (z zeroReader) Read(p []byte) (int, error) {
	return 0, io.EOF
}

func main() {
	f, err := os.Open("gc.go")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%T %#v\n", f, f)

	var r MyReader
	fmt.Printf("%T %#v\n", r, r)

	r = f
	// b, _ := ioutil.ReadAll(r)
	// fmt.Println(string(b))

	z := zeroReader{}
	r = z

	fmt.Printf("%T %#v\n", r, r)
}

repository: miku/gonotes

repo_name: miku/gonotes


text:
package scraper

import (
	"sync"
)

var (
	lockedFilesMutex sync.Mutex
	lockedFiles      = make(map[string]struct{})
)

func acquireFile(path string) bool {
	lockedFilesMutex.Lock()
	defer lockedFilesMutex.Unlock()

	if _, ok := lockedFiles[path]; ok {
		return false
	}

	lockedFiles[path] = struct{}{}
	return true
}

func releaseFile(path string) {
	lockedFilesMutex.Lock()
	defer lockedFilesMutex.Unlock()

	delete(lockedFiles, path)
}

repository: lhecker/tumblr-scraper

repo_name: lhecker/tumblr-scraper


text:
message("<smake::CompilerChecker> /cmake/FindCompilerChecker.cmake in")

if(NOT CompilerChecker_FOUND)
    add_subdirectory(${smake_ROOT_DIR}/modules/CompilerChecker/)
endif()

set(CompilerChecker_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/modules/CompilerChecker/include)
message("<smake::CompilerChecker> CompilerChecker_INCLUDE_DIRS=${CompilerChecker_INCLUDE_DIRS}")

set(CompilerChecker_LIBRARIES "" CACHE STRING INTERNAL FORCE)
message("<smake::CompilerChecker> CompilerChecker_LIBRARIES=${CompilerChecker_LIBRARIES}")

set(CompilerChecker_FOUND TRUE)
message("<smake::CompilerChecker> CompilerChecker_FOUND=${CompilerChecker_FOUND}")

message("<smake::CompilerChecker> /cmake/FindCompilerChecker.cmake out")


text:
SUMMARY = "Setup additional library paths"

LICENSE = "MIT"

# Ensures that even if USE_LDCONFIG is set to zero, the package will
# still be produced so that pkg_postinst_() works.
ALLOW_EMPTY_${PN} = "1"

do_install_append () {
	if [ "${USE_LDCONFIG}" = "1" ]; then
		mkdir -p ${D}${sysconfdir}/ld.so.conf.d
        echo "include /etc/ld.so.conf.d/*.conf" > ${D}${sysconfdir}/ld.so.conf
	fi
}

pkg_postinst_${PN} () {
    if [ -d $D/lib ] && ! [ -d $D/lib64 ]; then
        ln -s lib $D/lib64
    fi
}

repository: mitchdz/meta-intel-sgx

repo_name: mitchdz/meta-intel-sgx

extension: bb


text:
// Code generated by parcello-typed; DO NOT EDIT.

package resources

// Typed is a struct that represents the embedded parcello filesystem.
// It is a singleton object and is initialized for you, just use it.
var Typed *typedFileSystem

// UnTyped provides a dynamic interface into the embedded parcello filesystem.
func UnTyped(path string) *TypedFile {
	return typedFileFactory(path)
}

type typedFileSystem struct {
	MakefileGeneratedGotmpl *TypedFile
}

func init() {
	Typed = &typedFileSystem{}
	Typed.MakefileGeneratedGotmpl = typedFileFactory("makefile_generated.gotmpl")
}

repository: cliff-wakefield-acurus/gomake

repo_name: cliff-wakefield-acurus/gomake


text:
// generated by github.com/elastic/go-elasticsearch/cmd/generator; DO NOT EDIT

package indices

import (
	"fmt"
	"net/http"
	"net/url"
)

// PutTemplate - index templates allow you to define templates that will automatically be applied when new indices are created. See https://www.elastic.co/guide/en/elasticsearch/reference/5.x/indices-templates.html for more info.
//
// name: the name of the template.
//
// body: the template definition.
//
// options: optional parameters. Supports the following functional options: WithCreate, WithFlatSettings, WithMasterTimeout, WithOrder, WithTimeout, WithErrorTrace, WithFilterPath, WithHuman, WithPretty, WithSourceParam, see the Option type in this package for more info.
func (i *Indices) PutTemplate(name string, body map[string]interface{}, options ...*Option) (*PutTemplateResponse, error) {
	req := &http.Request{
		URL: &url.URL{
			Scheme: i.transport.URL.Scheme,
			Host:   i.transport.URL.Host,
		},
		Method: "PUT",
	}
	methodOptions := supportedOptions["PutTemplate"]
	for _, option := range options {
		if _, ok := methodOptions[option.name]; !ok {
			return nil, fmt.Errorf("unsupported option: %s", option.name)
		}
		option.apply(req)
	}
	resp, err := i.transport.Do(req)
	return &PutTemplateResponse{resp}, err
}

// PutTemplateResponse is the response for PutTemplate
type PutTemplateResponse struct {
	Response *http.Response
	// TODO: fill in structured response
}

repository: hothero/go-elasticsearch

repo_name: hothero/go-elasticsearch


text:
package cmd

import (
	"fmt"

	"github.com/pterm/pterm"
)

func helpText() string {
	description := fmt.Sprintf(
		"%s\n\t\t{{.Usage}}\n\n",
		pterm.Yellow("DESCRIPTION"),
	)
	usage := fmt.Sprintf(
		"%s\n\t\t{{.HelpName}} {{if .UsageText}}{{ .UsageText }}{{end}}\n\n",
		pterm.Yellow("USAGE"),
	)
	author := fmt.Sprintf(
		"{{if len .Authors}}%s\n\t\t{{range .Authors}}{{ . }}{{end}}{{end}}\n\n",
		pterm.Yellow("AUTHOR"),
	)

	version := fmt.Sprintf(
		"{{if .Version}}%s\n\t\t{{.Version}}{{end}}\n\n",
		pterm.Yellow("VERSION"),
	)
	commands := fmt.Sprintf(
		"%s\n{{range .Commands}}{{if not .HideHelp}}   %s{{ `\t`}}{{.Usage}}{{ `\n` }}{{end}}{{end}}\n\n",
		pterm.Yellow("COMMANDS"),
		pterm.Green("{{join .Names `, `}}"),
	)
	options := fmt.Sprintf(
		"%s\n{{range .VisibleFlags}}\t\t{{if .Aliases}}{{range $element := .Aliases}}%s,{{end}}{{end}} %s\n\t\t\t\t{{.Usage}}\n\n{{end}}",
		pterm.Yellow("OPTIONS"),
		pterm.Green("-{{$element}}"),
		pterm.Green("--{{.Name}} {{.DefaultText}}"),
	)

	docs := fmt.Sprintf(
		"%s\n\t\t%s\n\n",
		pterm.Yellow("DOCUMENTATION"),
		"https://github.com/ayoisaiah/focus/wiki",
	)
	website := fmt.Sprintf(
		"%s\n\t\thttps://github.com/ayoisaiah/focus\n",
		pterm.Yellow("WEBSITE"),
	)

	return description + usage + author + version + commands + options + docs + website
}


text:
SUMMARY = "IOTA (Extremely Unsafe) Seed Generator"
DESCRIPTION = "An extremely unsafe way to generate IOTA seeds"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"

SRC_URI = " file://iota_seed_gen"

do_install(){
    install -m 0744 -d ${D}${bindir}
    install -m 0755 ${WORKDIR}/iota_seed_gen ${D}${bindir}
}


text:
/*
Copyright 2021 Red Hat 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 directimagemigration

// PhaseDescriptions are human readable strings that describe a phase
var PhaseDescriptions = map[string]string{
	Prepare:                           "Preparing for Direct Image Migration",
	Started:                           "Direct Image Migration started.",
	MigrationFailed:                   "Direct Image Migration failed.",
	CreateDestinationNamespaces:       "Creating target cluster namespaces for ImageStreams to be migrated into.",
	ListImageStreams:                  "Searching source cluster namespaces for ImageStreams to be migrated.",
	CreateDirectImageStreamMigrations: "Launching DirectImageStreamMigrations for all discovered ImageStreams.",
	WaitingForDirectImageStreamMigrationsToComplete: "Waiting for all DirectImageStreamMigrations to complete.",
	Completed: "Direct Image Migration completed.",
}

repository: pranavgaikwad/mig-controller

repo_name: pranavgaikwad/mig-controller


text:
@INPROCEEDINGS{litmus,
  author={Calandrino, J.M. and Leontyev, H. and Block, A. and Devi, U.C. and Anderson, J.H.},
  booktitle={Proc. RTSS},
  title={{$LITMUS^{RT}$} : A Testbed for Empirically Comparing Real-Time Multiprocessor Schedulers},
  pages={111-126},
  year={2006},
  ISSN={1052-8725},
}


text:
SUMMARY = "Simple application to get MAC address from I2C EEPROM"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://${PN}.c;startline=5;endline=5;md5=fa92ea990d0ea8a4605a441be7df11da"
DEPENDS = "i2c-tools"
PV = "1.1"
PR = "r1"

SRC_URI = "file://${PN}.c"
S = "${WORKDIR}"

do_compile() {
    ${CC} -o ${PN} ${PN}.c ${CFLAGS} ${LDFLAGS}
}

do_install() {
    install -d ${D}${bindir}
    install ${PN} ${D}${bindir}/`echo ${PN} | tr - _`
}

COMPATIBLE_MACHINE = "(olinuxino-a10lime)"

repository: BeeeOn/meta-beeeon

repo_name: BeeeOn/meta-beeeon


text:
DESCRIPTION = "SDK packages"
PR = "r8"
LICENSE = "MIT"
ALLOW_EMPTY = "1"

PACKAGES = "\
    task-sdk-bare \
    "

DEPENDS = "virtual/libc"

LIBC_linux = "glibc"
LIBC_linux-uclibc = "uclibc"
LIBC_linux-gnueabi = "glibc"
LIBC_linux-uclibcgnueabi = "uclibc"

RDEPENDS_task-sdk-bare = "\
    ${LIBC} \
    ${LIBC}-dev \
    libgcc \
    "

repository: jdegges/gumstix-pip-oe

repo_name: jdegges/gumstix-pip-oe


text:
// Author: EmotionalDots @ PTH
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.

package arbitrage

import "time"

type Info struct {
	Version     int                    `yaml:"version"`
	FileHash    string                 `yaml:"file_hash"`
	LastUpdated time.Time              `yaml:"last_updated"`
	Releases    map[string]InfoRelease `yaml:"releases,omitempty"`
}

type InfoRelease struct {
	TorrentId int    `yaml:"torrent_id"`
	Format    string `yaml:"format"`
	FilePath  string `yaml:"file_path"`

	Name            string `yaml:"name"`
	Year            int    `yaml:"year"`
	RecordLabel     string `yaml:"record_label"`
	CatalogueNumber string `yaml:"catalogue_number"`
	Edition         string `yaml:"edition"`

	Composers []string `yaml:"composers,omitempty,flow"`
	Artists   []string `yaml:"artists"`
	With      []string `yaml:"with,omitempty,flow"`
	DJ        []string `yaml:"dj,omitempty,flow"`
	RemixedBy []string `yaml:"remixed_by,omitempty,flow"`
	Producer  []string `yaml:"producer,omitempty,flow"`

	Tags        []string `yaml:"tags,flow"`
	Description string   `yaml:"description,omitempty"`
	Image       string   `yaml:"image,omitempty"`
}

func concat(s, del, extra, pre, suf string) string {
	if extra == "" {
		return s
	}
	if s != "" {
		s += del
	}
	return s + pre + extra + suf
}

func (i InfoRelease) String() string {
	str := ""
	if len(i.Artists) == 1 {
		str = i.Artists[0]
	} else if len(i.Artists) > 1 {
		str = "Various Artists"
	} else {
		str = "Unknown Artist"
	}

	str = concat(str, " - ", i.Name, "", "")
	str = concat(str, " ", i.Format, "[", "]")
	str = concat(str, " ", i.CatalogueNumber, "{", "}")
	return str
}

repository: emotionaldots/arbitrage

repo_name: emotionaldots/arbitrage


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

package models

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

import (
	"context"

	"github.com/go-openapi/errors"
	"github.com/go-openapi/strfmt"
	"github.com/go-openapi/swag"
)

// PublicGroup public group
//
// swagger:model public.Group
type PublicGroup struct {

	// after
	After *PublicAfter `json:"after,omitempty"`

	// before
	Before *PublicBefore `json:"before,omitempty"`
}

// Validate validates this public group
func (m *PublicGroup) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateAfter(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateBefore(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *PublicGroup) validateAfter(formats strfmt.Registry) error {
	if swag.IsZero(m.After) { // not required
		return nil
	}

	if m.After != nil {
		if err := m.After.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("after")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("after")
			}
			return err
		}
	}

	return nil
}

func (m *PublicGroup) validateBefore(formats strfmt.Registry) error {
	if swag.IsZero(m.Before) { // not required
		return nil
	}

	if m.Before != nil {
		if err := m.Before.Validate(formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("before")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("before")
			}
			return err
		}
	}

	return nil
}

// ContextValidate validate this public group based on the context it is used
func (m *PublicGroup) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	var res []error

	if err := m.contextValidateAfter(ctx, formats); err != nil {
		res = append(res, err)
	}

	if err := m.contextValidateBefore(ctx, formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *PublicGroup) contextValidateAfter(ctx context.Context, formats strfmt.Registry) error {

	if m.After != nil {

		if swag.IsZero(m.After) { // not required
			return nil
		}

		if err := m.After.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("after")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("after")
			}
			return err
		}
	}

	return nil
}

func (m *PublicGroup) contextValidateBefore(ctx context.Context, formats strfmt.Registry) error {

	if m.Before != nil {

		if swag.IsZero(m.Before) { // not required
			return nil
		}

		if err := m.Before.ContextValidate(ctx, formats); err != nil {
			if ve, ok := err.(*errors.Validation); ok {
				return ve.ValidateName("before")
			} else if ce, ok := err.(*errors.CompositeError); ok {
				return ce.ValidateName("before")
			}
			return err
		}
	}

	return nil
}

// MarshalBinary interface implementation
func (m *PublicGroup) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *PublicGroup) UnmarshalBinary(b []byte) error {
	var res PublicGroup
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}

repository: CrowdStrike/gofalcon

repo_name: CrowdStrike/gofalcon


text:
@Article{Kastner2022,
  author      = {Kastner, Felix and Rößler, Andreas},
  date        = {2022-01-20},
  title       = {An Analysis of Approximation Algorithms for Iterated Stochastic Integrals and a Julia and MATLAB Simulation Toolbox},
  eprint      = {2201.08424},
  eprintclass = {math.NA},
  eprinttype  = {arXiv},
  keywords    = {Levy Area, Iterated Integrals, Stochastic Differential Equations, Julia},
}

@Software{Kastner2022a,
  author    = {Kastner, Felix and Rößler, Andreas},
  date      = {2022},
  title     = {LevyArea.jl},
  doi       = {10.5281/ZENODO.5883748},
  url       = {https://github.com/stochastics-uni-luebeck/LevyArea.jl},
  copyright = {MIT License},
  keywords  = {Levy Area, Iterated Integrals, Stochastic Differential Equations, Julia},
  publisher = {Zenodo},
}

@Comment{jabref-meta: databaseType:biblatex;}

gha_language: Julia


text:
package main

import (
	"fmt"
	fm "github.com/Bnei-Baruch/mms-file-manager/file_manager"
	"github.com/joho/godotenv"
	"os"
	"os/signal"
	"syscall"
)

func main() {
	watchDir, targetDir := "tmp/source", "tmp/target"

	godotenv.Load(".env")

	fm, err := fm.NewFM("mms_prod")
	if err != nil {
		panic(err)
	}
	defer fm.Destroy()

	fm.Watch(watchDir, targetDir)

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt)
	signal.Notify(c, syscall.SIGTERM)
	go func() {
		<-c
		fmt.Println("Bye Bye")
		fm.Destroy()
		os.Exit(0)
	}()

	quit := make(chan bool, 1)
	/*
		for {
			fmt.Println("sleeping...")
			time.Sleep(10 * time.Second) // or runtime.Gosched() or similar per @misterbee
		}
	*/
	<-quit
}

repository: Bnei-Baruch/mms-file-manager-old

repo_name: Bnei-Baruch/mms-file-manager-old


text:
file(REMOVE_RECURSE
  "CMakeFiles/tutorial_video-input-psnr-ssim.dir/tutorial_code/HighGUI/video-input-psnr-ssim/video-input-psnr-ssim.cpp.o"
  "../../bin/cpp-tutorial-video-input-psnr-ssim.pdb"
  "../../bin/cpp-tutorial-video-input-psnr-ssim"
)

# Per-language clean rules from dependency scanning.
foreach(lang CXX)
  include(CMakeFiles/tutorial_video-input-psnr-ssim.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()

repository: rajkataria/ReliableResectioning

repo_name: rajkataria/ReliableResectioning


text:
require totalcross.inc

DESCRIPTION = "TotalCross Virtual Machine"

S = "${WORKDIR}/git/TotalCrossVM/src"
B = "${S}"

inherit lib_package

CXXFLAGS_append = " -I${STAGING_INCDIR}/skia/ -DPNG_ARM_NEON_OPT=0"
CFLAGS_append = " -I${STAGING_INCDIR}/skia/ -DPNG_ARM_NEON_OPT=0"

EXTRA_OEMAKE += "\
    BLDDIR='${B}' \
    SDLDIR='${STAGING_LIBDIR}' \
    SDL_INC='${STAGING_INCDIR}/SDL2' \
    SKIADIR='${STAGING_INCDIR}/skia/include' \
    SRCDIR='${S}' \
"

SECURITY_STRINGFORMAT = ""
do_configure() {
    cp ${S}/../builders/gcc-linux-arm/tcvm/Makefile .
}

do_compile() {
    oe_runmake
}

do_install() {
    install -Dm 0755 ${B}/bin/libtcvm.so ${D}${libdir}/totalcross/libtcvm.so.1
    ln -sf libtcvm.so.1 ${D}${libdir}/totalcross/libtcvm.so
}

#dev package rename
FILES_${PN} += "${libdir}/totalcross/"
INSANE_SKIP_${PN} += "dev-so"

# FIXME: This is a workaround as next release uses CMake and doesn't make sense
# to spend too much time on this.
INSANE_SKIP_${PN} += "ldflags"

repository: TotalCross/meta-totalcross

repo_name: TotalCross/meta-totalcross


text:
# Copyright (C) 2017 Jacob Chen <jacob-chen@iotwrt.com>
# Released under the MIT license (see COPYING.MIT for the terms)

IMAGE_FEATURES += "\
	splash	\
"

require recipes-rk/images/rk-image-multimedia.bb

IMAGE_INSTALL += " \
	ffmpeg \
	mpv \
	packagegroup-fonts-truetype \
"


text:
package main

import (
	"fmt"

	"github.com/blevesearch/bleve/search"
	"github.com/dtylman/connan/db"
	"github.com/dtylman/gowd"
	"github.com/dtylman/gowd/bootstrap"
)

//DocumentCard ...
type DocumentCard struct {
	Element      *gowd.Element
	doc          *db.Document
	hit          *search.DocumentMatch
	linkImage    *gowd.Element
	linkContent  *gowd.Element
	linkDocument *gowd.Element
}

//NewDocumentCard creates a new card
func NewDocumentCard(doc *db.Document, hit *search.DocumentMatch) *DocumentCard {
	card := new(DocumentCard)
	card.doc = doc
	card.hit = hit
	card.Element = bootstrap.NewElement("div", "card m-3 col-md-3")
	header := card.Element.AddElement(bootstrap.NewElement("div", "card-header"))
	card.populateHeader(header)
	subtitle := card.Element.AddElement(bootstrap.NewElement("small", "text-center"))
	subtitle.AddElement(gowd.NewText(doc.GetField("type")))
	cardbody := card.Element.AddElement(bootstrap.NewElement("div", "card-body"))
	card.populateBody(cardbody)
	return card
}

func (dc *DocumentCard) populateHeader(header *gowd.Element) {
	linkTitle := header.AddElement(bootstrap.NewLinkButton(dc.doc.Name()))
	//link.OnEvent(gowd.OnClick)
	linkTitle.SetAttribute("Title", "Open")
	linkTitle.SetAttribute("onclick", fmt.Sprintf(`nw.Shell.openItem('%v');`, dc.doc.Path))

	linkFolder := header.AddElement(bootstrap.NewLinkButton(""))
	linkFolder.SetClass("mx-2")
	linkFolder.AddElement(bootstrap.NewElement("i", "fas fa-folder"))
	linkFolder.SetAttribute("Title", "Show In Folder")
	linkFolder.SetAttribute("onclick", fmt.Sprintf(`nw.Shell.showItemInFolder('%v');`, dc.doc.Path))

	dc.linkContent = header.AddElement(bootstrap.NewLinkButton(""))
	dc.linkContent.SetClass("mx-2")
	dc.linkContent.AddElement(bootstrap.NewElement("i", "fas fa-eye"))
	dc.linkContent.SetAttribute("Title", "View")

	span := header.AddElement(bootstrap.NewElement("span", "badge badge-pill badge-info float-right"))
	span.AddElement(gowd.NewText(fmt.Sprintf("%.2f", dc.hit.Score)))
}

func (dc *DocumentCard) populateBody(cardbody *gowd.Element) {
	if dc.doc.IsImage() {
		dc.linkImage = cardbody.AddElement(bootstrap.NewLinkButton(""))
		dc.linkImage.SetClass("float-right")
		dc.linkImage.SetAttribute("Title", "View Image")

		image := dc.linkImage.AddElement(bootstrap.NewElement("img", "img-thumbnail thumb-search"))
		image.SetAttribute("src", fmt.Sprintf("file:///%s", dc.doc.Path))
	}

	dc.linkDocument = cardbody.AddElement(bootstrap.NewLinkButton(""))
	dc.linkDocument.SetAttribute("Title", "View Content")
	for fragmentField, fragments := range dc.hit.Fragments {
		if fragmentField == "path" || fragmentField == "fields.type" || fragmentField == "fields.mime" {
			continue
		}
		p := dc.linkDocument.AddElement(bootstrap.NewElement("p", "card-text small"))
		for _, fragment := range fragments {
			p.AddHTML(fragment, nil)
		}
	}
}

/*

                baba.doc

                2.34

            open document version 1.0

Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum
                        Lorem ipsum Lorem ipsum

*/

repository: dtylman/connan

repo_name: dtylman/connan


text:
@article{xie2020interactive,
 author = {Xie, Wanze and Liang, Yining and Johnson, Janet and Mower, Andrea and Burns, Samuel and Chelini, Colleen and D’Alessandro, Paul and Weibel, Nadir and Schulze, Jürgen P},
 journal = {Electronic Imaging},
 number = {13},
 pages = {363--1},
 publisher = {Society for Imaging Science and Technology},
 title = {Interactive multi-user 3d visual analytics in augmented reality},
 volume = {2020},
 year = {2020}
}

repository: robinzhx/hxi-website

repo_name: robinzhx/hxi-website


text:
/*
 *
 * Copyright 2020 gRPC authors.
 *
 * 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 client

import (
	"fmt"
	"net"
	"strconv"

	v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
	v3corepb "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
	v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
	v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
	v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
	v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
	v3tlspb "github.com/envoyproxy/go-control-plane/envoy/extensions/transport_sockets/tls/v3"
	v3typepb "github.com/envoyproxy/go-control-plane/envoy/type/v3"
	"github.com/golang/protobuf/proto"
	anypb "github.com/golang/protobuf/ptypes/any"

	"google.golang.org/grpc/internal/grpclog"
	"google.golang.org/grpc/xds/internal"
	"google.golang.org/grpc/xds/internal/version"
)

// UnmarshalListener processes resources received in an LDS response, validates
// them, and transforms them into a native struct which contains only fields we
// are interested in.
func UnmarshalListener(resources []*anypb.Any, logger *grpclog.PrefixLogger) (map[string]ListenerUpdate, error) {
	update := make(map[string]ListenerUpdate)
	for _, r := range resources {
		if !IsListenerResource(r.GetTypeUrl()) {
			return nil, fmt.Errorf("xds: unexpected resource type: %q in LDS response", r.GetTypeUrl())
		}
		lis := &v3listenerpb.Listener{}
		if err := proto.Unmarshal(r.GetValue(), lis); err != nil {
			return nil, fmt.Errorf("xds: failed to unmarshal resource in LDS response: %v", err)
		}
		logger.Infof("Resource with name: %v, type: %T, contains: %v", lis.GetName(), lis, lis)
		routeName, err := getRouteConfigNameFromListener(lis, logger)
		if err != nil {
			return nil, err
		}
		update[lis.GetName()] = ListenerUpdate{RouteConfigName: routeName}
	}
	return update, nil
}

// getRouteConfigNameFromListener checks if the provided Listener proto meets
// the expected criteria. If so, it returns a non-empty routeConfigName.
func getRouteConfigNameFromListener(lis *v3listenerpb.Listener, logger *grpclog.PrefixLogger) (string, error) {
	if lis.GetApiListener() == nil {
		return "", fmt.Errorf("xds: no api_listener field in LDS response %+v", lis)
	}
	apiLisAny := lis.GetApiListener().GetApiListener()
	if !IsHTTPConnManagerResource(apiLisAny.GetTypeUrl()) {
		return "", fmt.Errorf("xds: unexpected resource type: %q in LDS response", apiLisAny.GetTypeUrl())
	}
	apiLis := &v3httppb.HttpConnectionManager{}
	if err := proto.Unmarshal(apiLisAny.GetValue(), apiLis); err != nil {
		return "", fmt.Errorf("xds: failed to unmarshal api_listner in LDS response: %v", err)
	}

	logger.Infof("Resource with type %T, contains %v", apiLis, apiLis)
	switch apiLis.RouteSpecifier.(type) {
	case *v3httppb.HttpConnectionManager_Rds:
		if apiLis.GetRds().GetConfigSource().GetAds() == nil {
			return "", fmt.Errorf("xds: ConfigSource is not ADS in LDS response: %+v", lis)
		}
		name := apiLis.GetRds().GetRouteConfigName()
		if name == "" {
			return "", fmt.Errorf("xds: empty route_config_name in LDS response: %+v", lis)
		}
		return name, nil
	case *v3httppb.HttpConnectionManager_RouteConfig:
		// TODO: Add support for specifying the RouteConfiguration inline
		// in the LDS response.
		return "", fmt.Errorf("xds: LDS response contains RDS config inline. Not supported for now: %+v", apiLis)
	case nil:
		return "", fmt.Errorf("xds: no RouteSpecifier in received LDS response: %+v", apiLis)
	default:
		return "", fmt.Errorf("xds: unsupported type %T for RouteSpecifier in received LDS response", apiLis.RouteSpecifier)
	}
}

// UnmarshalRouteConfig processes resources received in an RDS response,
// validates them, and transforms them into a native struct which contains only
// fields we are interested in. The provided hostname determines the route
// configuration resources of interest.
func UnmarshalRouteConfig(resources []*anypb.Any, logger *grpclog.PrefixLogger) (map[string]RouteConfigUpdate, error) {
	update := make(map[string]RouteConfigUpdate)
	for _, r := range resources {
		if !IsRouteConfigResource(r.GetTypeUrl()) {
			return nil, fmt.Errorf("xds: unexpected resource type: %q in RDS response", r.GetTypeUrl())
		}
		rc := &v3routepb.RouteConfiguration{}
		if err := proto.Unmarshal(r.GetValue(), rc); err != nil {
			return nil, fmt.Errorf("xds: failed to unmarshal resource in RDS response: %v", err)
		}
		logger.Infof("Resource with name: %v, type: %T, contains: %v.", rc.GetName(), rc, rc)

		// Use the hostname (resourceName for LDS) to find the routes.
		u, err := generateRDSUpdateFromRouteConfiguration(rc, logger)
		if err != nil {
			return nil, fmt.Errorf("xds: received invalid RouteConfiguration in RDS response: %+v with err: %v", rc, err)
		}
		update[rc.GetName()] = u
	}
	return update, nil
}

// generateRDSUpdateFromRouteConfiguration checks if the provided
// RouteConfiguration meets the expected criteria. If so, it returns a
// RouteConfigUpdate with nil error.
//
// A RouteConfiguration resource is considered valid when only if it contains a
// VirtualHost whose domain field matches the server name from the URI passed
// to the gRPC channel, and it contains a clusterName or a weighted cluster.
//
// The RouteConfiguration includes a list of VirtualHosts, which may have zero
// or more elements. We are interested in the element whose domains field
// matches the server name specified in the "xds:" URI. The only field in the
// VirtualHost proto that the we are interested in is the list of routes. We
// only look at the last route in the list (the default route), whose match
// field must be empty and whose route field must be set.  Inside that route
// message, the cluster field will contain the clusterName or weighted clusters
// we are looking for.
func generateRDSUpdateFromRouteConfiguration(rc *v3routepb.RouteConfiguration, logger *grpclog.PrefixLogger) (RouteConfigUpdate, error) {
	var vhs []*VirtualHost
	for _, vh := range rc.GetVirtualHosts() {
		routes, err := routesProtoToSlice(vh.Routes, logger)
		if err != nil {
			return RouteConfigUpdate{}, fmt.Errorf("received route is invalid: %v", err)
		}
		vhs = append(vhs, &VirtualHost{
			Domains: vh.GetDomains(),
			Routes:  routes,
		})
	}
	return RouteConfigUpdate{VirtualHosts: vhs}, nil
}

func routesProtoToSlice(routes []*v3routepb.Route, logger *grpclog.PrefixLogger) ([]*Route, error) {
	var routesRet []*Route

	for _, r := range routes {
		match := r.GetMatch()
		if match == nil {
			return nil, fmt.Errorf("route %+v doesn't have a match", r)
		}

		if len(match.GetQueryParameters()) != 0 {
			// Ignore route with query parameters.
			logger.Warningf("route %+v has query parameter matchers, the route will be ignored", r)
			continue
		}

		if caseSensitive := match.GetCaseSensitive(); caseSensitive != nil && !caseSensitive.Value {
			return nil, fmt.Errorf("route %+v has case-sensitive false", r)
		}

		pathSp := match.GetPathSpecifier()
		if pathSp == nil {
			return nil, fmt.Errorf("route %+v doesn't have a path specifier", r)
		}

		var route Route
		switch pt := pathSp.(type) {
		case *v3routepb.RouteMatch_Prefix:
			route.Prefix = &pt.Prefix
		case *v3routepb.RouteMatch_Path:
			route.Path = &pt.Path
		case *v3routepb.RouteMatch_SafeRegex:
			route.Regex = &pt.SafeRegex.Regex
		default:
			logger.Warningf("route %+v has an unrecognized path specifier: %+v", r, pt)
			continue
		}

		for _, h := range match.GetHeaders() {
			var header HeaderMatcher
			switch ht := h.GetHeaderMatchSpecifier().(type) {
			case *v3routepb.HeaderMatcher_ExactMatch:
				header.ExactMatch = &ht.ExactMatch
			case *v3routepb.HeaderMatcher_SafeRegexMatch:
				header.RegexMatch = &ht.SafeRegexMatch.Regex
			case *v3routepb.HeaderMatcher_RangeMatch:
				header.RangeMatch = &Int64Range{
					Start: ht.RangeMatch.Start,
					End:   ht.RangeMatch.End,
				}
			case *v3routepb.HeaderMatcher_PresentMatch:
				header.PresentMatch = &ht.PresentMatch
			case *v3routepb.HeaderMatcher_PrefixMatch:
				header.PrefixMatch = &ht.PrefixMatch
			case *v3routepb.HeaderMatcher_SuffixMatch:
				header.SuffixMatch = &ht.SuffixMatch
			default:
				logger.Warningf("route %+v has an unrecognized header matcher: %+v", r, ht)
				continue
			}
			header.Name = h.GetName()
			invert := h.GetInvertMatch()
			header.InvertMatch = &invert
			route.Headers = append(route.Headers, &header)
		}

		if fr := match.GetRuntimeFraction(); fr != nil {
			d := fr.GetDefaultValue()
			n := d.GetNumerator()
			switch d.GetDenominator() {
			case v3typepb.FractionalPercent_HUNDRED:
				n *= 10000
			case v3typepb.FractionalPercent_TEN_THOUSAND:
				n *= 100
			case v3typepb.FractionalPercent_MILLION:
			}
			route.Fraction = &n
		}

		clusters := make(map[string]uint32)
		switch a := r.GetRoute().GetClusterSpecifier().(type) {
		case *v3routepb.RouteAction_Cluster:
			clusters[a.Cluster] = 1
		case *v3routepb.RouteAction_WeightedClusters:
			wcs := a.WeightedClusters
			var totalWeight uint32
			for _, c := range wcs.Clusters {
				w := c.GetWeight().GetValue()
				clusters[c.GetName()] = w
				totalWeight += w
			}
			if totalWeight != wcs.GetTotalWeight().GetValue() {
				return nil, fmt.Errorf("route %+v, action %+v, weights of clusters do not add up to total total weight, got: %v, want %v", r, a, wcs.GetTotalWeight().GetValue(), totalWeight)
			}
		case *v3routepb.RouteAction_ClusterHeader:
			continue
		}

		route.Action = clusters
		routesRet = append(routesRet, &route)
	}
	return routesRet, nil
}

// TransportSocket proto message has a `name` field which is expected to be set
// to this value by the management server.
const transportSocketName = "envoy.transport_sockets.tls"

// UnmarshalCluster processes resources received in an CDS response, validates
// them, and transforms them into a native struct which contains only fields we
// are interested in.
func UnmarshalCluster(resources []*anypb.Any, logger *grpclog.PrefixLogger) (map[string]ClusterUpdate, error) {
	update := make(map[string]ClusterUpdate)
	for _, r := range resources {
		if !IsClusterResource(r.GetTypeUrl()) {
			return nil, fmt.Errorf("xds: unexpected resource type: %q in CDS response", r.GetTypeUrl())
		}

		cluster := &v3clusterpb.Cluster{}
		if err := proto.Unmarshal(r.GetValue(), cluster); err != nil {
			return nil, fmt.Errorf("xds: failed to unmarshal resource in CDS response: %v", err)
		}
		logger.Infof("Resource with name: %v, type: %T, contains: %v", cluster.GetName(), cluster, cluster)
		cu, err := validateCluster(cluster)
		if err != nil {
			return nil, err
		}

		// If the Cluster message in the CDS response did not contain a
		// serviceName, we will just use the clusterName for EDS.
		if cu.ServiceName == "" {
			cu.ServiceName = cluster.GetName()
		}
		logger.Debugf("Resource with name %v, value %+v added to cache", cluster.GetName(), cu)
		update[cluster.GetName()] = cu
	}
	return update, nil
}

func validateCluster(cluster *v3clusterpb.Cluster) (ClusterUpdate, error) {
	emptyUpdate := ClusterUpdate{ServiceName: "", EnableLRS: false}
	switch {
	case cluster.GetType() != v3clusterpb.Cluster_EDS:
		return emptyUpdate, fmt.Errorf("xds: unexpected cluster type %v in response: %+v", cluster.GetType(), cluster)
	case cluster.GetEdsClusterConfig().GetEdsConfig().GetAds() == nil:
		return emptyUpdate, fmt.Errorf("xds: unexpected edsConfig in response: %+v", cluster)
	case cluster.GetLbPolicy() != v3clusterpb.Cluster_ROUND_ROBIN:
		return emptyUpdate, fmt.Errorf("xds: unexpected lbPolicy %v in response: %+v", cluster.GetLbPolicy(), cluster)
	}

	sc, err := securityConfigFromCluster(cluster)
	if err != nil {
		return emptyUpdate, err
	}
	return ClusterUpdate{
		ServiceName: cluster.GetEdsClusterConfig().GetServiceName(),
		EnableLRS:   cluster.GetLrsServer().GetSelf() != nil,
		SecurityCfg: sc,
	}, nil
}

// securityConfigFromCluster extracts the relevant security configuration from
// the received Cluster resource.
func securityConfigFromCluster(cluster *v3clusterpb.Cluster) (*SecurityConfig, error) {
	// The Cluster resource contains a `transport_socket` field, which contains
	// a oneof `typed_config` field of type `protobuf.Any`. The any proto
	// contains a marshaled representation of an `UpstreamTlsContext` message.
	ts := cluster.GetTransportSocket()
	if ts == nil {
		return nil, nil
	}
	if name := ts.GetName(); name != transportSocketName {
		return nil, fmt.Errorf("xds: transport_socket field has unexpected name: %s", name)
	}
	any := ts.GetTypedConfig()
	if any == nil || any.TypeUrl != version.V3UpstreamTLSContextURL {
		return nil, fmt.Errorf("xds: transport_socket field has unexpected typeURL: %s", any.TypeUrl)
	}
	upstreamCtx := &v3tlspb.UpstreamTlsContext{}
	if err := proto.Unmarshal(any.GetValue(), upstreamCtx); err != nil {
		return nil, fmt.Errorf("xds: failed to unmarshal UpstreamTlsContext in CDS response: %v", err)
	}

	// The `UpstreamTlsContext` has a `CommonTlsContext` which contains a
	// `tls_certificate_certificate_provider_instance` field of type
	// `CertificateProviderInstance`, which contains the provider instance name
	// and the certificate name to fetch identity certs.
	sc := &SecurityConfig{}
	if identity := upstreamCtx.GetCommonTlsContext().GetTlsCertificateCertificateProviderInstance(); identity != nil {
		sc.IdentityInstanceName = identity.GetInstanceName()
		sc.IdentityCertName = identity.GetCertificateName()
	}

	// The `CommonTlsContext` contains a `validation_context_type` field which
	// is a oneof. We can get the values that we are interested in from two of
	// those possible values:
	//  - combined validation context:
	//    - contains a default validation context which holds the list of
	//      accepted SANs.
	//    - contains certificate provider instance configuration
	//  - certificate provider instance configuration
	//    - in this case, we do not get a list of accepted SANs.
	switch t := upstreamCtx.GetCommonTlsContext().GetValidationContextType().(type) {
	case *v3tlspb.CommonTlsContext_CombinedValidationContext:
		combined := upstreamCtx.GetCommonTlsContext().GetCombinedValidationContext()
		if def := combined.GetDefaultValidationContext(); def != nil {
			for _, matcher := range def.GetMatchSubjectAltNames() {
				// We only support exact matches for now.
				if exact := matcher.GetExact(); exact != "" {
					sc.AcceptedSANs = append(sc.AcceptedSANs, exact)
				}
			}
		}
		if pi := combined.GetValidationContextCertificateProviderInstance(); pi != nil {
			sc.RootInstanceName = pi.GetInstanceName()
			sc.RootCertName = pi.GetCertificateName()
		}
	case *v3tlspb.CommonTlsContext_ValidationContextCertificateProviderInstance:
		pi := upstreamCtx.GetCommonTlsContext().GetValidationContextCertificateProviderInstance()
		sc.RootInstanceName = pi.GetInstanceName()
		sc.RootCertName = pi.GetCertificateName()
	default:
		return nil, fmt.Errorf("xds: validation context contains unexpected type: %T", t)
	}
	return sc, nil
}

// UnmarshalEndpoints processes resources received in an EDS response,
// validates them, and transforms them into a native struct which contains only
// fields we are interested in.
func UnmarshalEndpoints(resources []*anypb.Any, logger *grpclog.PrefixLogger) (map[string]EndpointsUpdate, error) {
	update := make(map[string]EndpointsUpdate)
	for _, r := range resources {
		if !IsEndpointsResource(r.GetTypeUrl()) {
			return nil, fmt.Errorf("xds: unexpected resource type: %q in EDS response", r.GetTypeUrl())
		}

		cla := &v3endpointpb.ClusterLoadAssignment{}
		if err := proto.Unmarshal(r.GetValue(), cla); err != nil {
			return nil, fmt.Errorf("xds: failed to unmarshal resource in EDS response: %v", err)
		}
		logger.Infof("Resource with name: %v, type: %T, contains: %v", cla.GetClusterName(), cla, cla)

		u, err := parseEDSRespProto(cla)
		if err != nil {
			return nil, err
		}
		update[cla.GetClusterName()] = u
	}
	return update, nil
}

func parseAddress(socketAddress *v3corepb.SocketAddress) string {
	return net.JoinHostPort(socketAddress.GetAddress(), strconv.Itoa(int(socketAddress.GetPortValue())))
}

func parseDropPolicy(dropPolicy *v3endpointpb.ClusterLoadAssignment_Policy_DropOverload) OverloadDropConfig {
	percentage := dropPolicy.GetDropPercentage()
	var (
		numerator   = percentage.GetNumerator()
		denominator uint32
	)
	switch percentage.GetDenominator() {
	case v3typepb.FractionalPercent_HUNDRED:
		denominator = 100
	case v3typepb.FractionalPercent_TEN_THOUSAND:
		denominator = 10000
	case v3typepb.FractionalPercent_MILLION:
		denominator = 1000000
	}
	return OverloadDropConfig{
		Category:    dropPolicy.GetCategory(),
		Numerator:   numerator,
		Denominator: denominator,
	}
}

func parseEndpoints(lbEndpoints []*v3endpointpb.LbEndpoint) []Endpoint {
	endpoints := make([]Endpoint, 0, len(lbEndpoints))
	for _, lbEndpoint := range lbEndpoints {
		endpoints = append(endpoints, Endpoint{
			HealthStatus: EndpointHealthStatus(lbEndpoint.GetHealthStatus()),
			Address:      parseAddress(lbEndpoint.GetEndpoint().GetAddress().GetSocketAddress()),
			Weight:       lbEndpoint.GetLoadBalancingWeight().GetValue(),
		})
	}
	return endpoints
}

func parseEDSRespProto(m *v3endpointpb.ClusterLoadAssignment) (EndpointsUpdate, error) {
	ret := EndpointsUpdate{}
	for _, dropPolicy := range m.GetPolicy().GetDropOverloads() {
		ret.Drops = append(ret.Drops, parseDropPolicy(dropPolicy))
	}
	priorities := make(map[uint32]struct{})
	for _, locality := range m.Endpoints {
		l := locality.GetLocality()
		if l == nil {
			return EndpointsUpdate{}, fmt.Errorf("EDS response contains a locality without ID, locality: %+v", locality)
		}
		lid := internal.LocalityID{
			Region:  l.Region,
			Zone:    l.Zone,
			SubZone: l.SubZone,
		}
		priority := locality.GetPriority()
		priorities[priority] = struct{}{}
		ret.Localities = append(ret.Localities, Locality{
			ID:        lid,
			Endpoints: parseEndpoints(locality.GetLbEndpoints()),
			Weight:    locality.GetLoadBalancingWeight().GetValue(),
			Priority:  priority,
		})
	}
	for i := 0; i < len(priorities); i++ {
		if _, ok := priorities[uint32(i)]; !ok {
			return EndpointsUpdate{}, fmt.Errorf("priority %v missing (with different priorities %v received)", i, priorities)
		}
	}
	return ret, nil
}


text:
DESCRIPTION = ""Compress::Raw::Lzma" provides an interface to the in-memory \
compression/uncompression functions from the lzma compression library."

SECTION = "libs"
LICENSE = "Artistic-1.0 | GPL-1.0-or-later"
PR = "r0"

MAINTAINER=	"Poky <poky@yoctoproject.org>"
HOMEPAGE=	"https://metacpan.org/release/Compress-Raw-Lzma"

LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Artistic-1.0;md5=cda03bbdc3c1951996392b872397b798 \
file://${COMMON_LICENSE_DIR}/GPL-1.0-or-later;md5=30c0b8a5048cc2f4be5ff15ef0d8cf61"

SRC_URI = "https://cpan.metacpan.org/authors/id/P/PM/PMQS/Compress-Raw-Lzma-2.101.tar.gz"

SRC_URI[md5sum] = "7ba205e1761e0feb6a1efed0899a6b2b"
SRC_URI[sha256sum] = "bb267fd31981eda11f444038f8a0fca4b94a51ae61b2db71246abf6a4d322a36"

DEPENDS += "xz"

S = "${WORKDIR}/Compress-Raw-Lzma-${PV}"

inherit cpan

export LIBLZMA_INCLUDE="-I${STAGING_DIR_HOST}${includedir}"
export LIBLZMA_LIB="-I${STAGING_DIR_HOST}${libdir}"

do_compile() {
	export LIBC="$(find ${STAGING_DIR_TARGET}/${base_libdir}/ -name 'libc-*.so')"
	cpan_do_compile
}

BBCLASSEXTEND = "native"

repository: rehsack/meta-cpan

repo_name: rehsack/meta-cpan

gha_language: BitBake


text:
@article{liu2018observing,
 author = {Liu, Tsung-Li and Upadhyayula, Srigokul and Milkie, Daniel E and Singh, Ved and Wang, Kai and Swinburne, Ian A and Mosaliganti, Kishore R and Collins, Zach M and Hiscock, Tom W and Shea, Jamien and others},
 journal = {Science},
 number = {6386},
 publisher = {American Association for the Advancement of Science},
 title = {Observing the cell in its native state: Imaging subcellular dynamics in multicellular organisms},
 volume = {360},
 year = {2018}
}

repository: dmilkie/starter-academic

repo_name: dmilkie/starter-academic


text:
DESCRIPTION = "Ink Spill is a Flood It Clone by Al Sweigart"
HOMEPAGE = "http://inventwithpython.com/blog/2010/09/09/code-comments-tutorial-ink-spill-a-flood-it-clone/"
LICENSE = "Creative Commons BY-NC-SA 3.0 US"
DEPENDS = "python-pygame"
RDEPENDS_${PN} = "python-pygame"
SRC_URI = "hg://www.jade-hamburg.de/~teythoon/repos;module=${PN};rev=${SRCREV};proto=https"
SRCREV = "897be0fe188a"
PR = "r1"
S = "${WORKDIR}/inkspill"

inherit distutils

FILES_${PN} += " ${datadir}/applications/* ${datadir}/pixmaps/*"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD


text:
package model

import (
	"log"

	"../config"
	"github.com/globalsign/mgo"
)

// DB global session
var DB *mgo.Session

func init() {
	var err error
	DB, err = mgo.Dial(config.DbHost)
	if err != nil {
		log.Fatal(err)
	}

	ProductIndexing()
	CustomerIndexing()
	PricingRulesIndexing()
}

repository: kayrules/jobads-api

repo_name: kayrules/jobads-api


text:
file(REMOVE_RECURSE
  "CMakeFiles/myelements.dir/src/FiniteStrain/FSFbar.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FSgen.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FSgenMixed_voigt.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FSgen_voigt.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FbarMaterial.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FbarReduced.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FbarSpatial.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FiniteStrainDelta.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FiniteStrainGen.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/FiniteStrainSpatial.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/NeumannFiniteStrain.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/NeumannFiniteStrainSpatial.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/NeumannRefTraction.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/constitutiveLib.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/finiteStrainLib.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/finiteStrainNew.f90.o"
  "CMakeFiles/myelements.dir/src/FiniteStrain/materialLib.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/Cell2Point.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/DirichletNode.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/DirichletNodeLag.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/IncrementVariables.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/NodalForce.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/NodalForceLine.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/NullElement.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/PolyElement.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/TrivialElement.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/loadingLib.f90.o"
  "CMakeFiles/myelements.dir/src/otherMaterials/setMaterialParam.f90.o"
  "CMakeFiles/myelements.dir/src/tools/DETERMINANT.f90.o"
  "CMakeFiles/myelements.dir/src/tools/PtosGauss.f90.o"
  "CMakeFiles/myelements.dir/src/tools/SFQuadrilateral.f90.o"
  "CMakeFiles/myelements.dir/src/tools/SFSimplex.f.o"
  "CMakeFiles/myelements.dir/src/tools/executer.f90.o"
  "CMakeFiles/myelements.dir/src/tools/funcAux.f90.o"
  "CMakeFiles/myelements.dir/src/tools/globalVariables.f90.o"
  "CMakeFiles/myelements.dir/src/tools/ptsGaussLib.f90.o"
  "CMakeFiles/myelements.dir/src/tools/ptsGaussLib2.f90.o"
  "libmyelements.pdb"
  "libmyelements.so"
)

# Per-language clean rules from dependency scanning.
foreach(lang Fortran)
  include(CMakeFiles/myelements.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()

repository: felipefr/Piola

repo_name: felipefr/Piola


text:
package teamcity

// Property is a characteristic of a project or build configuration
type Property struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value"`
	Own   bool   `json:"own,omitempty"`
}

// Params is a container for the various properties of a project or build configuration
type Params struct {
	Properties []Property `json:"property,omitempty"`
}

// PropertyFromName returns the Property of the given Params with the given target name if it exists
func (params Params) PropertyFromName(target string) Property {
	for _, property := range params.Properties {
		if property.Name == target {
			return property
		}
	}
	return Property{}
}

repository: yext/teamcity

repo_name: yext/teamcity


text:
@proceedings{ws-2014-interactive,
    title = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    editor = "Chuang, Jason  and
      Green, Spence  and
      Hearst, Marti  and
      Heer, Jeffrey  and
      Koehn, Philipp",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3100",
    doi = "10.3115/v1/W14-31",
}
@inproceedings{oconnor-2014-mitextexplorer,
    title = "{M}i{T}ext{E}xplorer: Linked brushing and mutual information for exploratory text data analysis",
    author = "O{'}Connor, Brendan",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3101",
    doi = "10.3115/v1/W14-3101",
    pages = "1--13",
}
@inproceedings{chang-etal-2014-interactive,
    title = "Interactive Learning of Spatial Knowledge for Text to 3{D} Scene Generation",
    author = "Chang, Angel  and
      Savva, Manolis  and
      Manning, Christopher",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3102",
    doi = "10.3115/v1/W14-3102",
    pages = "14--21",
}
@inproceedings{coppersmith-kelly-2014-dynamic,
    title = "Dynamic Wordclouds and Vennclouds for Exploratory Data Analysis",
    author = "Coppersmith, Glen  and
      Kelly, Erin",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3103",
    doi = "10.3115/v1/W14-3103",
    pages = "22--29",
}
@inproceedings{yang-etal-2014-active,
    title = "Active Learning with Constrained Topic Model",
    author = "Yang, Yi  and
      Pan, Shimei  and
      Downey, Doug  and
      Zhang, Kunpeng",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3104",
    doi = "10.3115/v1/W14-3104",
    pages = "30--33",
}
@inproceedings{chen-etal-2014-glance,
    title = "{GLANCE} Visualizes Lexical Phenomena for Language Learning",
    author = "Chen, Mei-Hua  and
      Huang, Shih-Ting  and
      Kao, Ting-Hui  and
      Chiu, Hsun-wen  and
      Yen, Tzu-Hsi",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3105",
    doi = "10.3115/v1/W14-3105",
    pages = "34--37",
}
@inproceedings{gupta-manning-2014-spied,
    title = "{SPIED}: {S}tanford Pattern based Information Extraction and Diagnostics",
    author = "Gupta, Sonal  and
      Manning, Christopher",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3106",
    doi = "10.3115/v1/W14-3106",
    pages = "38--44",
}
@inproceedings{hoque-etal-2014-interactive,
    title = "Interactive Exploration of Asynchronous Conversations: Applying a User-centered Approach to Design a Visual Text Analytic System",
    author = "Hoque, Enamul  and
      Carenini, Giuseppe  and
      Joty, Shafiq",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3107",
    doi = "10.3115/v1/W14-3107",
    pages = "45--52",
}
@inproceedings{weiss-2014-muck,
    title = "{MUCK}: A toolkit for extracting and visualizing semantic dimensions of large text collections",
    author = "Weiss, Rebecca",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3108",
    doi = "10.3115/v1/W14-3108",
    pages = "53--58",
}
@inproceedings{mccracken-etal-2014-design,
    title = "Design of an Active Learning System with Human Correction for Content Analysis",
    author = "McCracken, Nancy  and
      Liew, Jasy Suet Yan  and
      Crowston, Kevin",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3109",
    doi = "10.3115/v1/W14-3109",
    pages = "59--62",
}
@inproceedings{sievert-shirley-2014-ldavis,
    title = "{LDA}vis: A method for visualizing and interpreting topics",
    author = "Sievert, Carson  and
      Shirley, Kenneth",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3110",
    doi = "10.3115/v1/W14-3110",
    pages = "63--70",
}
@inproceedings{smith-etal-2014-hiearchie,
    title = "{H}iearchie: Visualization for Hierarchical Topic Models",
    author = "Smith, Alison  and
      Hawes, Timothy  and
      Myers, Meredith",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3111",
    doi = "10.3115/v1/W14-3111",
    pages = "71--78",
}
@inproceedings{smith-etal-2014-concurrent,
    title = "Concurrent Visualization of Relationships between Words and Topics in Topic Models",
    author = "Smith, Alison  and
      Chuang, Jason  and
      Hu, Yuening  and
      Boyd-Graber, Jordan  and
      Findlater, Leah",
    booktitle = "Proceedings of the Workshop on Interactive Language Learning, Visualization, and Interfaces",
    month = jun,
    year = "2014",
    address = "Baltimore, Maryland, USA",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W14-3112",
    doi = "10.3115/v1/W14-3112",
    pages = "79--82",
}

repository: emorynlp/nlprankings

repo_name: emorynlp/nlprankings

gha_license_id: NOASSERTION

gha_language: TeX


text:
@proceedings{ws-2018-machine,
    title = "Proceedings of the Workshop on Machine Reading for Question Answering",
    editor = "Choi, Eunsol  and
      Seo, Minjoon  and
      Chen, Danqi  and
      Jia, Robin  and
      Berant, Jonathan",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2600",
}
@inproceedings{gong-bowman-2018-ruminating,
    title = "Ruminating Reader: Reasoning with Gated Multi-hop Attention",
    author = "Gong, Yichen  and
      Bowman, Samuel",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2601",
    doi = "10.18653/v1/W18-2601",
    pages = "1--11",
}
@inproceedings{rondeau-hazen-2018-systematic,
    title = "Systematic Error Analysis of the {S}tanford Question Answering Dataset",
    author = "Rondeau, Marc-Antoine  and
      Hazen, T. J.",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2602",
    doi = "10.18653/v1/W18-2602",
    pages = "12--20",
}
@inproceedings{yu-etal-2018-multi,
    title = "A Multi-Stage Memory Augmented Neural Network for Machine Reading Comprehension",
    author = "Yu, Seunghak  and
      Indurthi, Sathish Reddy  and
      Back, Seohyun  and
      Lee, Haejun",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2603",
    doi = "10.18653/v1/W18-2603",
    pages = "21--30",
}
@inproceedings{ren-etal-2018-tackling,
    title = "Tackling Adversarial Examples in {QA} via Answer Sentence Selection",
    author = "Ren, Yuanhang  and
      Du, Ye  and
      Wang, Di",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2604",
    doi = "10.18653/v1/W18-2604",
    pages = "31--36",
}
@inproceedings{he-etal-2018-dureader,
    title = "{D}u{R}eader: a {C}hinese Machine Reading Comprehension Dataset from Real-world Applications",
    author = "He, Wei  and
      Liu, Kai  and
      Liu, Jing  and
      Lyu, Yajuan  and
      Zhao, Shiqi  and
      Xiao, Xinyan  and
      Liu, Yuan  and
      Wang, Yizhong  and
      Wu, Hua  and
      She, Qiaoqiao  and
      Liu, Xuan  and
      Wu, Tian  and
      Wang, Haifeng",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2605",
    doi = "10.18653/v1/W18-2605",
    pages = "37--46",
}
@inproceedings{franke-etal-2018-robust,
    title = "Robust and Scalable Differentiable Neural Computer for Question Answering",
    author = {Franke, J{\"o}rg  and
      Niehues, Jan  and
      Waibel, Alex},
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2606",
    doi = "10.18653/v1/W18-2606",
    pages = "47--59",
}
@inproceedings{boratko-etal-2018-systematic,
    title = "A Systematic Classification of Knowledge, Reasoning, and Context within the {ARC} Dataset",
    author = "Boratko, Michael  and
      Padigela, Harshit  and
      Mikkilineni, Divyendra  and
      Yuvraj, Pritish  and
      Das, Rajarshi  and
      McCallum, Andrew  and
      Chang, Maria  and
      Fokoue-Nkoutche, Achille  and
      Kapanipathi, Pavan  and
      Mattei, Nicholas  and
      Musa, Ryan  and
      Talamadupula, Kartik  and
      Witbrock, Michael",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2607",
    doi = "10.18653/v1/W18-2607",
    pages = "60--70",
}
@inproceedings{shvartzshanider-etal-2018-recipe,
    title = "{RECIPE}: Applying Open Domain Question Answering to Privacy Policies",
    author = "Shvartzshanider, Yan  and
      Balashankar, Ananth  and
      Wies, Thomas  and
      Subramanian, Lakshminarayanan",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2608",
    doi = "10.18653/v1/W18-2608",
    pages = "71--77",
}
@inproceedings{subramanian-etal-2018-neural,
    title = "Neural Models for Key Phrase Extraction and Question Generation",
    author = "Subramanian, Sandeep  and
      Wang, Tong  and
      Yuan, Xingdi  and
      Zhang, Saizheng  and
      Trischler, Adam  and
      Bengio, Yoshua",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2609",
    doi = "10.18653/v1/W18-2609",
    pages = "78--88",
}
@inproceedings{wadhwa-etal-2018-comparative,
    title = "Comparative Analysis of Neural {QA} models on {SQ}u{AD}",
    author = "Wadhwa, Soumya  and
      Chandu, Khyathi  and
      Nyberg, Eric",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2610",
    doi = "10.18653/v1/W18-2610",
    pages = "89--97",
}
@inproceedings{yang-etal-2018-adaptations,
    title = "Adaptations of {ROUGE} and {BLEU} to Better Evaluate Machine Reading Comprehension Task",
    author = "Yang, An  and
      Liu, Kai  and
      Liu, Jing  and
      Lyu, Yajuan  and
      Li, Sujian",
    booktitle = "Proceedings of the Workshop on Machine Reading for Question Answering",
    month = jul,
    year = "2018",
    address = "Melbourne, Australia",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/W18-2611",
    doi = "10.18653/v1/W18-2611",
    pages = "98--104",
}


text:
@inproceedings{Hjalmarsson&Gustafsson_i:95,
 address = {New Orleans, Louisiana},
 author = {H. Hjalmarsson and F. Gustafsson},
 booktitle = {Proc. 34nd CDC},
 pages = {228-233},
 title = {Composite Modeling of Transfer Functions},
 volume = {1},
 year = {1995}
}

repository: hhjalmars/academic-kickstart

repo_name: hhjalmars/academic-kickstart


text:
package trie

import (
	"errors"
	"reflect"
	"strings"
	"testing"
)

// RuneTrie

func TestRuneTrie(t *testing.T) {
	trie := NewRuneTrie()
	testTrie(t, trie)
}

func TestRuneTrieNilBehavior(t *testing.T) {
	trie := NewRuneTrie()
	testNilBehavior(t, trie)
}

func TestRuneTrieRoot(t *testing.T) {
	trie := NewRuneTrie()
	testTrieRoot(t, trie)
}

func TestRuneTrieWalk(t *testing.T) {
	trie := NewRuneTrie()
	testTrieWalk(t, trie)
}

func TestRuneTrieWalkError(t *testing.T) {
	trie := NewRuneTrie()
	testTrieWalkError(t, trie)
}

func TestRuneSubTrie(t *testing.T) {
	trie := NewRuneTrie()
	testSubTrie(t, trie)
}

// PathTrie

func TestPathTrie(t *testing.T) {
	trie := NewPathTrie()
	testTrie(t, trie)
}

func TestPathTrieNilBehavior(t *testing.T) {
	trie := NewPathTrie()
	testNilBehavior(t, trie)
}

func TestPathTrieRoot(t *testing.T) {
	trie := NewPathTrie()
	testTrieRoot(t, trie)
}

func TestPathTrieWalk(t *testing.T) {
	trie := NewPathTrie()
	testTrieWalk(t, trie)
}

func TestPathTrieWalkError(t *testing.T) {
	trie := NewPathTrie()
	testTrieWalkError(t, trie)
}

func TestPathSubTrie(t *testing.T) {
	trie := NewPathTrie()
	testSubTrie(t, trie)
}

func testTrie(t *testing.T, trie Trier) {
	const firstPutValue = "first put"
	cases := []struct {
		key   string
		value interface{}
	}{
		{"fish", 0},
		{"/cat", 1},
		{"/dog", 2},
		{"/cats", 3},
		{"/caterpillar", 4},
		{"/cat/gideon", 5},
		{"/cat/giddy", 6},
	}

	// get missing keys
	for _, c := range cases {
		if value := trie.Get(c.key); value != nil {
			t.Errorf("expected key %s to be missing, found value %v", c.key, value)
		}

		if node := trie.Node(c.key); node != nil {
			t.Errorf("expected key %s to be missing, found node %v", c.key, node)
		}
	}

	// initial put
	for _, c := range cases {
		if isNew := trie.Put(c.key, firstPutValue); !isNew {
			t.Errorf("expected key %s to be missing", c.key)
		}
	}

	// subsequent put
	for _, c := range cases {
		if isNew := trie.Put(c.key, c.value); isNew {
			t.Errorf("expected key %s to have a value already", c.key)
		}
	}

	// get
	for _, c := range cases {
		if value := trie.Get(c.key); value != c.value {
			t.Errorf("expected key %s to have value %v, got %v", c.key, c.value, value)
		}

		if node := trie.Node(c.key); node.Value() != c.value {
			t.Errorf("expected node %s to have value %v got %v", c.key, c.value, node.Value())
		}
	}

	// get path
	key := cases[6].key
	var expectValues []interface{}
	for _, c := range cases {
		// If c.key is a prefix of key, then expect c.value.
		if strings.HasPrefix(key, c.key) {
			expectValues = append(expectValues, c.value)
		}
	}
	values := trie.GetPath(key)
	if len(values) != len(expectValues) {
		t.Errorf("expected %d values, got %d", len(expectValues), len(values))
	} else {
		for i := range expectValues {
			if values[i] != expectValues[i] {
				t.Errorf("expected value %v at position %d, got %v", expectValues[i], i, values[i])
			}
		}
	}

	// delete, expect Delete to return true indicating a node was nil'd
	for _, c := range cases {
		if deleted := trie.Delete(c.key); !deleted {
			t.Errorf("expected key %s to be deleted", c.key)
		}
	}

	// delete cleaned all the way to the first character
	// expect Delete to return false bc no node existed to nil
	for _, c := range cases {
		if deleted := trie.Delete(string(c.key[0])); deleted {
			t.Errorf("expected key %s to be cleaned by delete", string(c.key[0]))
		}
	}

	// get deleted keys
	for _, c := range cases {
		if value := trie.Get(c.key); value != nil {
			t.Errorf("expected key %s to be deleted, got value %v", c.key, value)
		}
	}
}

func testNilBehavior(t *testing.T, trie Trier) {
	cases := []struct {
		key   string
		value interface{}
	}{
		{"/cat", 1},
		{"/catamaran", 2},
		{"/caterpillar", nil},
	}
	expectNilValues := []string{"/", "/c", "/ca", "/caterpillar", "/other"}

	// initial put
	for _, c := range cases {
		if isNew := trie.Put(c.key, c.value); !isNew {
			t.Errorf("expected key %s to be missing", c.key)
		}
	}

	// get nil
	for _, key := range expectNilValues {
		if value := trie.Get(key); value != nil {
			t.Errorf("expected key %s to have value nil, got %v", key, value)
		}
	}
}

func testTrieRoot(t *testing.T, trie Trier) {
	const firstPutValue = "first put"
	const putValue = "value"

	if value := trie.Get(""); value != nil {
		t.Errorf("expected key '' to be missing, found value %v", value)
	}
	if !trie.Put("", firstPutValue) {
		t.Error("expected key '' to be missing")
	}
	if trie.Put("", putValue) {
		t.Error("expected key '' to have a value already")
	}
	if value := trie.Get(""); value != putValue {
		t.Errorf("expected key '' to have value %v, got %v", putValue, value)
	}
	if !trie.Delete("") {
		t.Error("expected key '' to be deleted")
	}
	if value := trie.Get(""); value != nil {
		t.Errorf("expected key '' to be deleted, got value %v", value)
	}
}

func testTrieWalk(t *testing.T, trie Trier) {
	table := map[string]interface{}{
		"fish":         0,
		"/cat":         1,
		"/dog":         2,
		"/cats":        3,
		"/caterpillar": 4,
		"/notes":       30,
		"/notes/new":   31,
		"/notes/:id":   32,
	}
	// key -> times walked
	walked := make(map[string]int)
	for key := range table {
		walked[key] = 0
	}

	for key, value := range table {
		if isNew := trie.Put(key, value); !isNew {
			t.Errorf("expected key %s to be missing", key)
		}
	}

	walker := func(key string, value interface{}) error {
		// value for each walked key is correct
		if value != table[key] {
			t.Errorf("expected key %s to have value %v, got %v", key, table[key], value)
		}
		walked[key]++
		return nil
	}
	if err := trie.Walk(walker); err != nil {
		t.Errorf("expected error nil, got %v", err)
	}

	// each key/value walked exactly once
	for key, walkedCount := range walked {
		if walkedCount != 1 {
			t.Errorf("expected key %s to be walked exactly once, got %v", key, walkedCount)
		}
	}
}

func testTrieWalkError(t *testing.T, trie Trier) {
	table := map[string]interface{}{
		"/L1/L2A":        1,
		"/L1/L2B/L3A":    2,
		"/L1/L2B/L3B/L4": 42,
		"/L1/L2B/L3C":    4,
		"/L1/L2C":        5,
	}

	walkerError := errors.New("walker error")
	walked := 0

	for key, value := range table {
		trie.Put(key, value)
	}
	walker := func(key string, value interface{}) error {
		if value == 42 {
			return walkerError
		}
		walked++
		return nil
	}
	if err := trie.Walk(walker); err != walkerError {
		t.Errorf("expected walker error, got %v", err)
	}
	if len(table) == walked {
		t.Errorf("expected nodes walked < %d, got %d", len(table), walked)
	}
}

func testSubTrie(t *testing.T, trie Trier) {
	table := map[string]interface{}{
		"/L1/L2A":        1,
		"/L1/L2B":        2,
		"/L1/L2B/L3A":    3,
		"/L1/L2B/L3B/L4": 4,
		"/L1/L2B/L3C":    5,
	}

	for key, value := range table {
		trie.Put(key, value)
	}

	node := trie.Node("/L1/L2B")

	if node == nil {
		t.Fatalf("expected node at path '/L1/L2B' to not be nil")
	}

	if got, want := node.Value().(int), 2; got != want {
		t.Errorf("expected node value at path '/L1/L2B' to be %v, got %v", want, got)
	}

	expectedWalk := map[string]interface{}{
		"":        2,
		"/L3A":    3,
		"/L3B/L4": 4,
		"/L3C":    5,
	}

	actualWalk := map[string]interface{}{}

	walker := func(key string, value interface{}) error {
		actualWalk[key] = value
		return nil
	}

	if err := node.Walk(walker); err != nil {
		t.Fatalf("unexpected error walking trie: %v", err)
	}

	if !reflect.DeepEqual(expectedWalk, actualWalk) {
		t.Errorf("expected walk %v, got: %v", expectedWalk, actualWalk)
	}
}

func TestPathTrieChildren(t *testing.T) {
	cases := []childTest{
		{node: "", want: 1},               // children - /L1
		{node: "/L1", want: 2},            // children - /L2A, /L2B
		{node: "/L1/L2A", want: 0},        // children - none
		{node: "/L1/L2B", want: 3},        // children - /L3A, /L3B, /L3C
		{node: "/L1/L2B/L3A", want: 0},    // children - none
		{node: "/L1/L2B/L3B", want: 1},    // children - /L4
		{node: "/L1/L2B/L3B/L4", want: 0}, // children - none
		{node: "/L1/L2B/L3C", want: 0},    // children - none
	}

	testTrieChildren(t, NewPathTrie(), cases)
}

func TestRuneTrieChildren(t *testing.T) {
	cases := []childTest{
		{node: "", want: 1},
		{node: "/", want: 1},
		{node: "/L", want: 1},
		{node: "/L1", want: 1},
		{node: "/L1/", want: 1},
		{node: "/L1/L", want: 1},
		{node: "/L1/L2", want: 2},
		{node: "/L1/L2A", want: 0},
		{node: "/L1/L2B", want: 1},
		{node: "/L1/L2B/L3", want: 3},
		// Omitting full traversal since the cases
		// are covered above
	}

	testTrieChildren(t, NewRuneTrie(), cases)
}

func testTrieChildren(t *testing.T, trie Trier, cases []childTest) {
	table := map[string]interface{}{
		"/L1/L2A":        1,
		"/L1/L2B":        2,
		"/L1/L2B/L3A":    3,
		"/L1/L2B/L3B/L4": 4,
		"/L1/L2B/L3C":    5,
	}

	for key, value := range table {
		trie.Put(key, value)
	}

	for _, c := range cases {
		t.Run(c.node, func(t *testing.T) {
			node := trie
			if c.node != "" {
				node = trie.Node(c.node)
			}

			if node == nil {
				t.Fatalf("node %q should not be nil", c.node)
			}
			kids := node.Children()

			if got, want := len(kids), c.want; got != want {
				t.Errorf("expected children count to be %v, got %v", want, got)
			}
		})
	}
}

type childTest struct {
	node string
	want int
}

repository: happyrita/infini-framework

repo_name: happyrita/infini-framework


text:
//go:build integration

package cmd

import (
	"fmt"
	"github.com/qiniu/qshell/v2/cmd_test/test"
	"path/filepath"
	"strings"
	"testing"
)

func TestCopy(t *testing.T) {
	copyFile(t, test.Key, "qshell_copy.json")
}

func copyFile(t *testing.T, srcKey, destKey string) {
	_, errs := test.RunCmdWithError("copy", test.Bucket, srcKey, test.Bucket, "-k", destKey, "-w")
	if len(errs) > 0 {
		t.Fail()
	}
}

func TestCopyNoExistSrcBucket(t *testing.T) {
	_, errs := test.RunCmdWithError("copy", test.BucketNotExist, test.Key, test.Bucket, "-k", "qshell_copy.json", "-w")
	if !strings.Contains(errs, "no such bucket") {
		t.Fail()
	}
}

func TestCopyNoExistDestBucket(t *testing.T) {
	_, errs := test.RunCmdWithError("copy", test.Bucket, test.Key, test.BucketNotExist, "-k", "qshell_copy.json", "-w")
	if !strings.Contains(errs, "no such bucket") {
		t.Fail()
	}
}

func TestCopyNoExistSrcKey(t *testing.T) {
	_, errs := test.RunCmdWithError("copy", test.Bucket, test.KeyNotExist, test.Bucket, "-k", "qshell_copy.json", "-w")
	if !strings.Contains(errs, "no such file or directory") {
		t.Fail()
	}
}

func TestCopyNoSrcBucket(t *testing.T) {
	_, errs := test.RunCmdWithError("copy")
	if !strings.Contains(errs, "SourceBucket can't be empty") {
		t.Fail()
	}
}

func TestCopyNoSrcKey(t *testing.T) {
	_, errs := test.RunCmdWithError("copy", test.Bucket)
	if !strings.Contains(errs, "SourceKey can't be empty") {
		t.Fail()
	}
}

func TestCopyNoDestBucket(t *testing.T) {
	_, errs := test.RunCmdWithError("copy", test.Bucket, test.KeyNotExist)
	if !strings.Contains(errs, "DestBucket can't be empty") {
		t.Fail()
	}
}

func TestCopyDocument(t *testing.T) {
	test.TestDocument("copy", t)
}

func TestBatchCopy(t *testing.T) {
	batchConfig := ""
	keys := test.OriginKeys
	for i, key := range keys {
		batchConfig += key + "\t" + test.Keys[i] + "\t" + "\n"
	}
	batchConfig += "\n"
	batchConfig += "hello10.json" + "\t" + "hello10_test.json" + "\t" + "\n"
	resultDir, err := test.ResultPath()
	if err != nil {
		t.Fatal("get result dir error:", err)
	}

	successLogPath := filepath.Join(resultDir, "batch_copy_success.txt")
	failLogPath := filepath.Join(resultDir, "batch_copy_fail.txt")

	path, err := test.CreateFileWithContent("batch_copy.txt", batchConfig)
	if err != nil {
		t.Fatal("create cdn config file error:", err)
	}

	test.RunCmdWithError("batchcopy", test.Bucket, test.Bucket,
		"-i", path,
		"--success-list", successLogPath,
		"--failure-list", failLogPath,
		"--overwrite",
		"--worker", "4",
		"--min-worker", "10",
		"--worker-count-increase-period", "50",
		"-w",
		"-y")
	defer func() {
		test.RemoveFile(successLogPath)
		test.RemoveFile(failLogPath)
	}()

	if !test.IsFileHasContent(successLogPath) {
		t.Fatal("batch result: success log to file error: file empty")
	}

	if !test.IsFileHasContent(failLogPath) {
		t.Fatal("batch result: fail log  to file error: file empty")
	}
}

func TestBatchCopyRecord(t *testing.T) {
	batchConfig := ""
	keys := test.OriginKeys
	for i, key := range keys {
		batchConfig += key + "\t" + test.Keys[i] + "\t" + "\n"
	}
	batchConfig += "\n"
	batchConfig += "hello10.json" + "\t" + "hello10_test.json" + "\t" + "\n"
	path, err := test.CreateFileWithContent("batch_chtype.txt", batchConfig)
	if err != nil {
		t.Fatal("create batch move config file error:", err)
	}

	test.RunCmdWithError("batchcopy", test.Bucket, test.Bucket,
		"-i", path,
		"--enable-record",
		"--worker", "4",
		"-w",
		"-y")

	result, _ := test.RunCmdWithError("batchcopy", test.Bucket, test.Bucket,
		"-i", path,
		"--enable-record",
		"--worker", "4",
		"-y",
		"-w",
		"-d")
	if !strings.Contains(result, "because have done and success") {
		fmt.Println("=========================== result start ===========================")
		fmt.Println(result)
		fmt.Println("=========================== result   end ===========================")
		t.Fatal("batch result: should skip success work")
	}
	if strings.Contains(result, "work redo") {
		fmt.Println("=========================== result start ===========================")
		fmt.Println(result)
		fmt.Println("=========================== result   end ===========================")
		t.Fatal("batch result: shouldn't redo because not set --record-redo-while-error")
	}

	result, _ = test.RunCmdWithError("batchcopy", test.Bucket, test.Bucket,
		"-i", path,
		"--enable-record",
		"--record-redo-while-error",
		"--worker", "4",
		"-y",
		"-w",
		"-d")
	if !strings.Contains(result, "because have done and success") {
		t.Fatal("batch result: should skip success work")
	}
	if !strings.Contains(result, "work redo") {
		fmt.Println("=========================== result start ===========================")
		fmt.Println(result)
		fmt.Println("=========================== result   end ===========================")
		t.Fatal("batch result: should redo because set --record-redo-while-error")
	}
}

func TestBatchCopyDocument(t *testing.T) {
	test.TestDocument("batchcopy", t)
}

repository: qiniu/qshell

repo_name: qiniu/qshell