text:
// Copyright 2016 The Vanadium 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 vdltest

import (
	"fmt"
	"math/rand"
	"sort"
	"strconv"
	"strings"
	"time"

	"golang.org/x/text/cases"
	"golang.org/x/text/language"
	"v.io/v23/vdl"
)

// TypeGenerator generates types.
type TypeGenerator struct {
	// NamePrefix is the type name prefix for named types.
	NamePrefix string
	// BaseTypesPerKind is the number of base types of each kind to use when
	// generating composite types at each depth.  Numbers are considered to be a
	// single kind.
	//
	// Each element corresponds to the value at that depth, starting at depth 1.
	// Use -1 to indicate "unlimited".
	BaseTypesPerKind []int
	// FieldsPerKind is like BaseTypesPerKind, but limits the number of fields to
	// generate for structs and unions.
	FieldsPerKind []int
	// MaxArrayLen is the maximum array length; the actual length is chosen
	// randomly up to this max.
	MaxArrayLen int

	rng *rand.Rand
}

// NewTypeGenerator returns a new TypeGenerator, which uses a random number
// generator seeded to the current time.
func NewTypeGenerator() *TypeGenerator {
	return &TypeGenerator{
		NamePrefix:       "V",
		BaseTypesPerKind: []int{3, 1},
		FieldsPerKind:    []int{-1, 2, 1},
		MaxArrayLen:      3,
		rng:              rand.New(rand.NewSource(time.Now().Unix())), //nolint:gosec
	}
}

// RandSeed sets the seed for the random number generator used by g.
func (g *TypeGenerator) RandSeed(seed int64) {
	g.rng.Seed(seed)
}

var ttBuiltIn = []*vdl.Type{
	vdl.AnyType,
	vdl.BoolType,
	vdl.StringType,
	vdl.TypeObjectType,
	vdl.ByteType,
	vdl.Uint16Type,
	vdl.Uint32Type,
	vdl.Uint64Type,
	vdl.Int8Type,
	vdl.Int16Type,
	vdl.Int32Type,
	vdl.Int64Type,
	vdl.Float32Type,
	vdl.Float64Type,
}

// Gen generates types up to and including the given maxDepth.
//
// Depth 0 only includes scalar types.  Depth N>0 includes composite types built
// out of types from depth N-1.  Optional types are considered to be at the same
// depth as their elem type, except for depth 0; optional types are not scalar.
//
// See the TypeGenerator exported fields for additional configuration options.
func (g *TypeGenerator) Gen(maxDepth int) []*vdl.Type {
	if maxDepth < 0 {
		return nil
	}
	depth0 := append([]*vdl.Type(nil), ttBuiltIn...)
	depth0 = append(depth0, g.genNamed(depth0...)...)
	unnamedEnums := []*vdl.Type{
		vdl.EnumType("A", "B", "C"),
		vdl.EnumType("B", "C", "D"),
	}
	depth0 = append(depth0, g.genNamed(unnamedEnums...)...) // enums must be named
	// Depth 0 only includes scalars.
	if maxDepth == 0 {
		return joinTypes(splitDepth0Types(depth0))
	}
	// Special-cases that would have been included in depth 0, had we not
	// special-cased depth 0 to only include scalars.  We include a named empty
	// struct and the error type.
	depth0 = append(depth0, vdl.NamedType(g.NamePrefix+"StructEmpty", vdl.StructType()))
	depth0 = append(depth0, vdl.ErrorType)
	// NamedError is a type that is compatible with the built-in error type.  It
	// intentionally doesn't have the RetryCode or ParamList fields, to test error
	// compatibility with other types.
	depth0 = append(depth0, vdl.NamedType(g.NamePrefix+"NamedError", vdl.StructType(
		vdl.Field{Name: "Id", Type: vdl.StringType},
		vdl.Field{Name: "Msg", Type: vdl.StringType})))
	// Generate composite types for each depth N, based on the base types from
	// depth N-1.  We keep the base types in separate buckets per kind, so that
	// when we prune types we get a good distribution of different kinds.
	base := splitDepth0Types(depth0)
	base = append(base, g.genOptional(base, 1))
	result := joinTypes(base)
	for depth := 1; depth <= maxDepth; depth++ {
		var next [][]*vdl.Type
		next = append(next, g.genArray(base, depth))
		next = append(next, g.genList(base, depth))
		next = append(next, g.genSetMap(vdl.Set, base, depth))
		next = append(next, g.genSetMap(vdl.Map, base, depth))
		next = append(next, g.genStructUnion(vdl.Struct, base, depth))
		next = append(next, g.genStructUnion(vdl.Union, base, depth))
		// Make optionals out of all the composite types we've generated.  We
		// consider optionals to be at the same depth as their elem type.
		next = append(next, g.genOptional(next, depth))
		// Append to our running result, and update our next base types.
		result = append(result, joinTypes(next)...)
		base = next
	}
	return result
}

func joinTypes(buckets [][]*vdl.Type) []*vdl.Type {
	var types []*vdl.Type
	for _, bucket := range buckets {
		types = append(types, bucket...)
	}
	return types
}

// splitDepth0Types splits depth0 into separate buckets grouped by kind.  All
// numbers are grouped together into a single bucket.  The relative ordering of
// types is maintained in each bucket.
func splitDepth0Types(depth0 []*vdl.Type) [][]*vdl.Type {
	// split[1] holds buckets for numbers, while split[0] holds buckets for
	// everything else.
	var split [2][][]*vdl.Type
CollectLoop:
	for _, tt := range depth0 {
		kind, isNum := tt.Kind(), 0
		// We special-case byte, to ensure byte lists and arrays are generated.
		if kind.IsNumber() && kind != vdl.Byte {
			isNum = 1
		}
		for ix, bucket := range split[isNum] {
			if kind == bucket[0].Kind() {
				// We've seen a type of this kind before, add it to this bucket
				split[isNum][ix] = append(split[isNum][ix], tt)
				continue CollectLoop
			}
		}
		// This is the first time we've seen a type of this kind, add a new bucket.
		split[isNum] = append(split[isNum], []*vdl.Type{tt})
	}
	// Add all numbers at the end in their own bucket.
	return append(split[0], joinTypes(split[1]))
}

func valueAtDepth(values []int, depth int) int {
	depth-- // values starts at depth 1
	switch len := len(values); {
	case len == 0:
		return -1
	case depth < len:
		return values[depth]
	default:
		return values[len-1] // use last element for subsequent depths.
	}
}

func (g *TypeGenerator) basePerKind(depth int) int {
	return valueAtDepth(g.BaseTypesPerKind, depth)
}

// randomChoose returns x sorted values out of [0,n).
// REQUIRES: x <= n
func (g *TypeGenerator) randomChoose(n, x int) []int {
	perm := g.rng.Perm(n)[:x]
	sort.Ints(perm)
	return perm
}

// prune returns maxPerBucket randomly picked types from each slice in buckets.
// The returned types remain in the same relative order.
func (g *TypeGenerator) prune(buckets [][]*vdl.Type, maxPerBucket int) []*vdl.Type {
	if maxPerBucket == 0 {
		return nil
	}
	var result []*vdl.Type
	for _, bucket := range buckets {
		if maxPerBucket < 0 || maxPerBucket >= len(bucket) {
			result = append(result, bucket...)
			continue
		}
		max := maxPerBucket
		// INVARIANT: max > 0 && max < len(bucket)
		if k := bucket[0].Kind(); k == vdl.Struct || k == vdl.Union {
			// Pick the first struct or union, which is the "all fields" type.
			// Picking this type increases the odds that we'll be able to mimic values
			// that are convertible.
			result = append(result, bucket[0])
			bucket = bucket[1:]
			max--
		}
		// Choose the remaining types randomly, maintaining the relative order.
		for _, p := range g.randomChoose(len(bucket), max) {
			result = append(result, bucket[p])
		}
	}
	return result
}

func typeName(tt *vdl.Type) string {
	// Handle the special-cases.
	switch {
	case tt == vdl.TypeObjectType:
		return "TypeObject" // by default we'd get Typeobject
	case tt == vdl.ErrorType:
		return "Error" // by default we'd get Opterror
	case tt.Kind() == vdl.Optional:
		return "Opt" + typeName(tt.Elem())
	case tt.Name() != "":
		return tt.Name()
	}
	caser := cases.Title(language.English)
	name := caser.String(tt.Kind().String())
	switch tt.Kind() {
	case vdl.Enum:
		var tmp string
		for i := 0; i < tt.NumEnumLabel(); i++ {
			tmp += tt.EnumLabel(i)
		}
		// VDL prohibits acronyms in identifiers, so we use Abc rather than ABC.
		name += caser.String(strings.ToLower(tmp))
	case vdl.Array:
		name += strconv.Itoa(tt.Len()) + "_" + typeName(tt.Elem())
	case vdl.List:
		name += "_" + typeName(tt.Elem())
	case vdl.Set:
		name += "_" + typeName(tt.Key())
	case vdl.Map:
		name += "_" + typeName(tt.Key()) + "_" + typeName(tt.Elem())
	case vdl.Struct, vdl.Union:
		panic(fmt.Errorf("vdltest: structs must be named in genStructUnion: %v", tt))
	}
	return name
}

func (g *TypeGenerator) genNamed(base ...*vdl.Type) []*vdl.Type {
	var named []*vdl.Type
	for _, tt := range base {
		// TODO(toddw): Resolve bug in vdl to disallow Optional from being named.
		if !tt.CanBeNamed() || tt.Kind() == vdl.Optional {
			continue
		}
		named = append(named, vdl.NamedType(g.NamePrefix+typeName(tt), tt))
	}
	return named
}

func (g *TypeGenerator) genArray(base [][]*vdl.Type, depth int) []*vdl.Type {
	// Create arrays out of pruned buckets.  There's no need to collect all arrays
	// that can be created first, since all types may be used as array elems.
	var unnamed []*vdl.Type
	for _, tt := range g.prune(base, g.basePerKind(depth)) {
		len := 1 + g.rng.Intn(g.MaxArrayLen)
		unnamed = append(unnamed, vdl.ArrayType(len, tt))
	}
	return g.genNamed(unnamed...) // arrays must be named
}

func (g *TypeGenerator) genList(base [][]*vdl.Type, depth int) []*vdl.Type {
	// Create lists out of pruned buckets.  There's no need to collect all lists
	// that can be created first, since all types may be used as list elems.
	var unnamed, named []*vdl.Type
	for _, tt := range g.prune(base, g.basePerKind(depth)) {
		unnamed = append(unnamed, vdl.ListType(tt))
	}
	for _, tt := range g.prune(base, g.basePerKind(depth)) {
		named = append(named, g.genNamed(vdl.ListType(tt))...)
	}
	return append(unnamed, named...)
}

func (g *TypeGenerator) genSetMap(kind vdl.Kind, base [][]*vdl.Type, depth int) []*vdl.Type {
	// First collect all sets and maps that can be created, by bucket.  We can't
	// prune before this, since many types can't be used as keys.
	var allUnnamed, allNamed [][]*vdl.Type
	for _, bucket := range base {
		var unnamed []*vdl.Type
		for _, tt := range bucket {
			if tt.CanBeKey() {
				if kind == vdl.Set {
					unnamed = append(unnamed, vdl.SetType(tt))
				} else {
					unnamed = append(unnamed, vdl.MapType(tt, tt))
				}
			}
		}
		allUnnamed = append(allUnnamed, unnamed)
		allNamed = append(allNamed, g.genNamed(unnamed...))
	}
	// Return pruned types.
	max := g.basePerKind(depth)
	return append(g.prune(allUnnamed, max), g.prune(allNamed, max)...)
}

func (g *TypeGenerator) genStructUnion(kind vdl.Kind, base [][]*vdl.Type, depth int) []*vdl.Type {
	var res []*vdl.Type
	prefix := g.NamePrefix
	caser := cases.Title(language.English)
	prefix += fmt.Sprintf("%sDepth%d_", caser.String(kind.String()), depth)
	// First collect all fields, with sequentially numbered field names.  Using
	// the same field names between the single-field and all-fields types ensures
	// that the values are convertible.
	var allFields []vdl.Field
	fieldsPerKind := valueAtDepth(g.FieldsPerKind, depth)
	for i, tt := range g.prune(base, fieldsPerKind) {
		field := vdl.Field{Name: "F" + strconv.Itoa(i), Type: tt}
		allFields = append(allFields, field)
	}
	// Create a type with all fields.  We do this first so that subsequent depths
	// will prefer to choose this type in g.prune.
	if numAll := len(allFields); numAll > 1 {
		name := prefix + "All"
		res = append(res, vdl.NamedType(name, makeStructUnion(kind, allFields...)))
	}
	// Create single-field types.
	for _, field := range allFields {
		name := prefix + typeName(field.Type)
		res = append(res, vdl.NamedType(name, makeStructUnion(kind, field)))
	}
	return res
}

func makeStructUnion(kind vdl.Kind, fields ...vdl.Field) *vdl.Type {
	if kind == vdl.Struct {
		return vdl.StructType(fields...)
	}
	return vdl.UnionType(fields...)
}

func (g *TypeGenerator) genOptional(base [][]*vdl.Type, depth int) []*vdl.Type {
	// First collect all optionals that can be created, by bucket.  We can't prune
	// before this, since many types can't be optional.  Optionals are unnamed.
	var allUnnamed [][]*vdl.Type
	for _, bucket := range base {
		var unnamed []*vdl.Type
		for _, tt := range bucket {
			if tt.CanBeOptional() {
				unnamed = append(unnamed, vdl.OptionalType(tt))
			}
		}
		allUnnamed = append(allUnnamed, unnamed)
	}
	// Return pruned items.
	return g.prune(allUnnamed, g.basePerKind(depth))
}

repository: vanadium/core

repo_name: vanadium/core

branch_name: refs/heads/main

gha_language: Go


text:
DESCRIPTION = "A module to control Raspberry Pi GPIO channels"
HOMEPAGE = "https://sourceforge.net/projects/raspberry-gpio-python/"
SECTION = "devel/python"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENCE.txt;md5=9b95630a648966b142f1a0dcea001cb7"

PYPI_PACKAGE = "RPi.GPIO"

inherit pypi setuptools3

SRC_URI += "file://0001-Remove-nested-functions.patch \
            file://0001-setup.py-Use-setuptools-instead-of-distutils.patch \
           "
SRC_URI[sha256sum] = "7424bc6c205466764f30f666c18187a0824077daf20b295c42f08aea2cb87d3f"

COMPATIBLE_MACHINE = "^rpi$"

# ignore issues with -fno-common from gcc-10 until it's fixed in upstream:
# https://sourceforge.net/p/raspberry-gpio-python/tickets/187/
CFLAGS += "-fcommon"

license: MIT

repository: schnitzeltony/meta-raspi-light

license_type: permissive

repo_name: schnitzeltony/meta-raspi-light

branch_name: refs/heads/master

extension: bb


text:
@book{NLA,
    author={James E. Gentle},
    title={Numerical Linear Algebra for Applications in Statistics},
    year={1998},
    publisher={Springer Science and Business Media},
    address={New York}
}

@book{NME,
    author={Seffen B{\"o}rm and Christian Mehl},
    title={Numerical Methods for Eigenvalue Problems},
    year={2012},
    publisher={Walter de Gruyter GmbH \& Co.KG},
    address={Berlin/Boston}

}

@book{MVA,
    author={Wolfgang K. H{\"a}rdle and L{\'e}opold Simar},
    title={Applied Multivariate Statistical Analysis},
    year={2015},
    publisher={Springer-Verlag Gmbh},
    address={Berlin, Heidelberg}
}

@Article{matplotlib,
  Author    = {Hunter, J. D.},
  Title     = {Matplotlib: A 2D graphics environment},
  Journal   = {Computing In Science \& Engineering},
  Volume    = {9},
  Number    = {3},
  Pages     = {90--95},
  abstract  = {Matplotlib is a 2D graphics package used for Python
  for application development, interactive scripting, and
  publication-quality image generation across user
  interfaces and operating systems.},
  publisher = {IEEE COMPUTER SOC},
  doi       = {10.1109/MCSE.2007.55},
  year      = 2007
}

@InProceedings{scipy,
  author    = {Wes McKinney},
  title     = {Data Structures for Statistical Computing in Python},
  booktitle = {Proceedings of the 9th Python in Science Conference},
  pages     = {51 - 56},
  year      = {2010},
  editor    = {St\'efan van der Walt and Jarrod Millman}
}

@Techreport{python,
  title= {Python tutorial},
  author = {G. van Rossum},
  number={CS-R9526},
  institution= {Centrum voor Wiskunde en Informatica (CWI)},
  year= {1995},
  address={Amsterdam},
  month={May}
}

@BOOK{laug,
      AUTHOR = {Anderson, E. and Bai, Z. and Bischof, C. and
                Blackford, S. and Demmel, J. and Dongarra, J. and
                Du Croz, J. and Greenbaum, A. and Hammarling, S. and
                McKenney, A. and Sorensen, D.},
      TITLE = {{LAPACK} Users' Guide},
      EDITION = {Third},
      PUBLISHER = {Society for Industrial and Applied Mathematics},
      YEAR = {1999},
      ADDRESS = {Philadelphia, PA},
      ISBN = {0-89871-447-8 (paperback)} }

gha_license_id: MIT

gha_language: TeX

extension: bib


text:
%% Saved with string encoding Unicode (UTF-8)

@article{sheppard2012introduction,
	Author = {Sheppard, Kevin},
	Date-Added = {2021-01-04 22:00:29 +0000},
	Date-Modified = {2021-01-04 22:02:19 +0000},
	Edition = {4},
	Journal = {Self-published, University of Oxford},
	Title = {Introduction to Python for econometrics, statistics and data analysis},
	Url = {https://www.kevinsheppard.com/files/teaching/python/notes/python_introduction_2020.pdf},
	Year = {2012}}

@article{jax2018github,
  author = {James Bradbury and Roy Frostig and Peter Hawkins and Matthew James Johnson and Chris Leary and Dougal Maclaurin and George Necula and Adam Paszke and Jake Vander{P}las and Skye Wanderman-{M}ilne and Qiao Zhang},
  title = {{JAX}: composable transformations of {P}ython+{N}um{P}y programs},
  url = {http://github.com/google/jax},
  journal = {none},
  version = {0.2.5},
  year = {2018},
}

@article{vallat2018pingouin,
  title={Pingouin: statistics in Python},
  author={Vallat, Raphael},
  journal={Journal of Open Source Software},
  volume={3},
  number={31},
  pages={1026},
  year={2018}
}

@InProceedings{niels_bantilan-proc-scipy-2020,
  author    = { {N}iels {B}antilan },
  title     = { pandera: {S}tatistical {D}ata {V}alidation of {P}andas {D}ataframes },
  booktitle = { {P}roceedings of the 19th {P}ython in {S}cience {C}onference },
  pages     = { 116 - 124 },
  year      = { 2020 },
  editor    = { {M}eghann {A}garwal and {C}hris {C}alloway and {D}illon {N}iederhut and {D}avid {S}hupe },
  doi       = { 10.25080/Majora-342d178e-010 }
}

@article{bellemare2020elasticities,
  title={Elasticities and the inverse hyperbolic sine transformation},
  author={Bellemare, Marc F and Wichman, Casey J},
  journal={Oxford Bulletin of Economics and Statistics},
  volume={82},
  number={1},
  pages={50--61},
  year={2020},
  publisher={Wiley Online Library}
}

@article{balli2013interaction,
  title={Interaction effects in econometrics},
  author={Balli, Hatice Ozer and S{\o}rensen, Bent E},
  journal={Empirical Economics},
  volume={45},
  number={1},
  pages={583--603},
  year={2013},
  publisher={Springer}
}

@article{silberzahn2018many,
  title={Many analysts, one data set: Making transparent how variations in analytic choices affect results},
  author={Silberzahn, Raphael and Uhlmann, Eric L and Martin, Daniel P and Anselmi, Pasquale and Aust, Frederik and Awtrey, Eli and Bahn{\'\i}k, {\v{S}}t{\v{e}}p{\'a}n and Bai, Feng and Bannard, Colin and Bonnier, Evelina and others},
  journal={Advances in Methods and Practices in Psychological Science},
  volume={1},
  number={3},
  pages={337--356},
  year={2018},
  publisher={Sage Publications Sage CA: Los Angeles, CA}
}

@article{simonsohn2020specification,
  title={Specification curve analysis},
  author={Simonsohn, Uri and Simmons, Joseph P and Nelson, Leif D},
  journal={Nature Human Behaviour},
  volume={4},
  number={11},
  pages={1208--1214},
  year={2020},
  publisher={Nature Publishing Group}
}

@article{orben2019association,
  title={The association between adolescent well-being and digital technology use},
  author={Orben, Amy and Przybylski, Andrew K},
  journal={Nature Human Behaviour},
  volume={3},
  number={2},
  pages={173--182},
  year={2019},
  publisher={Nature Publishing Group}
}

@article{akiyama2019first,
  title={First M87 event horizon telescope results. IV. Imaging the central supermassive black hole},
  author={Akiyama, Kazunori and Alberdi, Antxon and Alef, Walter and Asada, Keiichi and Azulay, Rebecca and Baczko, Anne-Kathrin and Ball, David and Balokovi{\'c}, Mislav and Barrett, John and Bintley, Dan and others},
  journal={The Astrophysical Journal Letters},
  volume={875},
  number={1},
  pages={L4},
  year={2019},
  publisher={IOP Publishing}
}

@article{abbott2016observation,
  title={Observation of gravitational waves from a binary black hole merger},
  author={Abbott, Benjamin P and Abbott, Richard and Abbott, TD and Abernathy, MR and Acernese, Fausto and Ackley, Kendall and Adams, Carl and Adams, Thomas and Addesso, Paolo and Adhikari, RX and others},
  journal={Physical review letters},
  volume={116},
  number={6},
  pages={061102},
  year={2016},
  publisher={APS}
}

@article{boeing2017osmnx,
  title={OSMnx: New methods for acquiring, constructing, analyzing, and visualizing complex street networks},
  author={Boeing, Geoff},
  journal={Computers, Environment and Urban Systems},
  volume={65},
  pages={126--139},
  year={2017},
  publisher={Elsevier}
}

@inproceedings{jupyter2018binder,
  title={Binder 2.0-Reproducible, interactive, sharable environments for science at scale},
  author={Jupyter, PMJF and Bussonnier, Matthias and Forde, Jessica and Freeman, J and Granger, B and Head, T and Holdgraf, C and Kelley, K and Nalvarte, G and Osheroff, A and others},
  booktitle={Proceedings of the 17th python in science conference},
  volume={113},
  pages={120},
  year={2018}
}

@book{diez2012openintro,
  title={OpenIntro statistics},
  author={Diez, David M and Barr, Christopher D and Cetinkaya-Rundel, Mine},
  year={2012},
  publisher={OpenIntro}
}

@article{cook2011inventing,
  title={Inventing social capital: Evidence from African American inventors, 1843--1930},
  author={Cook, Lisa D},
  journal={Explorations in Economic History},
  volume={48},
  number={4},
  pages={507--518},
  year={2011},
  publisher={Elsevier}
}

repository: bsllee/coding-for-economists

repo_name: bsllee/coding-for-economists


text:
package service_test

import (
	"testing"

	"github.com/icrowley/fake"
	"github.com/influx6/wordies/internal"
	"github.com/influx6/wordies/service"
)

var (
	sample300Words   = lexSentenceWithSplicer(fake.SentencesN(300))
	sample3000Words  = lexSentenceWithSplicer(fake.SentencesN(3000))
	sample10000Words = lexSentenceWithSplicer(fake.SentencesN(10000))
	sample50000Words = lexSentenceWithSplicer(fake.SentencesN(50000))
)

func benchmarkLetterFrequency(b *testing.B, samples []string) {
	b.StopTimer()
	b.ReportAllocs()

	counter := service.NewLetterCounter()

	b.StartTimer()
	for i := 0; i < b.N; i++ {
		for _, word := range samples {
			counter.Compute(word)
		}
	}
	b.StopTimer()
}

func benchmarkCountFrequency(b *testing.B, samples []string) {
	b.StopTimer()
	b.ReportAllocs()

	wordCounter := service.NewWordCounter()

	b.StartTimer()
	for i := 0; i < b.N; i++ {
		for _, word := range samples {
			wordCounter.Compute(word)
		}
	}
	b.StopTimer()
}

func BenchmarkLetterFrequency300(b *testing.B) {
	benchmarkLetterFrequency(b, sample300Words)
}

func BenchmarkLetterFrequency3000(b *testing.B) {
	benchmarkLetterFrequency(b, sample3000Words)
}

func BenchmarkLetterFrequency10000(b *testing.B) {
	benchmarkLetterFrequency(b, sample10000Words)
}

func BenchmarkLetterFrequency50000(b *testing.B) {
	benchmarkLetterFrequency(b, sample50000Words)
}

func BenchmarkCountFrequency300(b *testing.B) {
	benchmarkCountFrequency(b, sample300Words)
}

func BenchmarkCountFrequency3000(b *testing.B) {
	benchmarkCountFrequency(b, sample3000Words)
}

func BenchmarkCountFrequency10000(b *testing.B) {
	benchmarkCountFrequency(b, sample10000Words)
}

func BenchmarkCountFrequency50000(b *testing.B) {
	benchmarkCountFrequency(b, sample50000Words)
}

// lexSentenceWithSplicer transforms giving sentences into individual
// words using WordSplicer undeneath.
func lexSentenceWithSplicer(sentences string) []string {
	var words []string
	res := make(chan string, 0)
	go internal.WordSplicer(sentences, res)
	for word := range res {
		words = append(words, word)
	}
	return words
}

extension: go


text:
package ravenworker

import (
	"bytes"
	"fmt"
	"testing"

	"github.com/cenkalti/backoff/v3"
	"github.com/dutchsec/raven-worker/workflow"
	"github.com/gofrs/uuid"
	"github.com/google/go-cmp/cmp"
)

var (
	TestProduceMessage = Message{
		MetaData: []Metadata{
			Metadata{
				Key:   "test",
				Value: "test",
			},
		},
		Content: Content("content"),
	}
)

func StopBackOff() backoff.BackOff {
	return &backoff.StopBackOff{}
}

func TestProduce(t *testing.T) {
	srvr, err := testServer(&workflowServer{
		putEvent: func(putEvent workflow.Workflow_putEvent) error {
			if v, err := putEvent.Params.FlowID(); err != nil {
				return err
			} else if _, err := uuid.FromBytes(v); err != nil {
				return fmt.Errorf("FlowID is not a valid UUID: %s", err)
			}

			evt, err := putEvent.Params.Event()
			if err != nil {
				return err
			}

			meta, err := evt.Meta()
			if err != nil {
				return err
			}

			metadata := transformMeta(meta)

			if diff := cmp.Diff(metadata, TestProduceMessage.MetaData); diff != "" {
				return fmt.Errorf("putEvent() metadata mismatch (-want +got):\n%s", diff)
			}

			content, err := evt.Content()
			if err != nil {
				return err
			}

			if !bytes.Equal(content, TestProduceMessage.Content) {
				return fmt.Errorf("putEvent() content mismatch want:%s got:%s", string(content), string(TestProduceMessage.Content))
			}

			return nil
		},
	})
	if err != nil {
		t.Fatalf("Could not start test server: %s", err.Error())
	}

	defer srvr.Close()

	w, err := New(
		MustWithRavenURL(fmt.Sprintf("capnproto://%s", srvr.Addr().String())),
		MustWithFlowID(flowID.String()),
		MustWithWorkerID(workerID.String()),
		MustWithLogger(DefaultLogger),
		WithBackOff(StopBackOff),
	)
	if err != nil {
		t.Fatalf("Could not initialize new raven worker: %s", err.Error())
	}

	if err := w.Produce(TestProduceMessage); err != nil {
		t.Fatalf("Could not consume message: %s", err.Error())
	}
}

repository: sammynx/raven-worker

repo_name: sammynx/raven-worker

gha_license_id: NOASSERTION


text:
// Copyright 2016 The Periph Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.

package nrzled

import (
	"errors"
	"fmt"
	"image"
	"image/color"
	"image/draw"

	"periph.io/x/periph/conn/display"
	"periph.io/x/periph/conn/physic"
	"periph.io/x/periph/conn/spi"
)

// SPIDev represents a strip of WS2812b LEDs as a strip connected over a SPI port.
// It accepts a stream of raw RGB pixels and converts it to a bit pattern consistent
// with the WS812b protocol.
// Includes intensity and temperature correction.
type SPIDev struct {
	s         spi.Conn        //
	numPixels int             //
	rawBuf    []byte          // Raw buffer sent over SPI. Cached to reduce heap fragmentation.
	pixels    []byte          // Double buffer of pixels, to enable partial painting via Draw(). Effectively points inside rawBuf.
	rect      image.Rectangle // Device bounds
	pixelMap  map[image.Point]int
}

// NewSPI returns a strip that communicates over SPI to NRZ encoded LEDs.
//
// Due to the tight timing demands of these LEDs,
// the SPI port speed must be a reliable 2.5MHz
//
// Note that your SPI buffer should be at least 12*num_pixels+2 bytes long
func NewSPI(p spi.Port, o *Opts) (*SPIDev, error) {
	c, err := p.Connect(2500*physic.KiloHertz, spi.Mode3|spi.NoCS, 8)
	if err != nil {
		return nil, err
	}
	rawBCt := 4 * (3 * o.NumPixels) //3 bytes per pixel, 4 symbol bytes per byte
	buf := make([]byte, rawBCt+3)   //3 bytes for latch. 24*400ns = 9600ns.
	tail := buf[rawBCt:]
	for i := range tail {
		tail[i] = 0x00
	}

	return &SPIDev{
		s:         c,
		numPixels: o.NumPixels,
		rawBuf:    buf,
		pixels:    buf[:rawBCt],
		rect:      image.Rect(0, 0, o.NumPixels, 1),
	}, nil
}

func (d *SPIDev) String() string {
	return fmt.Sprintf("nrzled: {%d, %s}", d.numPixels, d.s)
}

// ColorModel implements display.Drawer. There's no surprise, it is
// color.NRGBAModel.
func (d *SPIDev) ColorModel() color.Model {
	return color.NRGBAModel
}

// Bounds implements display.Drawer. Min is guaranteed to be {0, 0}.
func (d *SPIDev) Bounds() image.Rectangle {
	return d.rect
}

// Draw implements display.Drawer.
//
// Using something else than image.NRGBA is 10x slower. When using image.NRGBA,
// the alpha channel is ignored.
func (d *SPIDev) Draw(r image.Rectangle, src image.Image, sp image.Point) error {
	if r = r.Intersect(d.rect); r.Empty() {
		return nil
	}
	srcR := src.Bounds()
	srcR.Min = srcR.Min.Add(sp)
	if dX := r.Dx(); dX < srcR.Dx() {
		srcR.Max.X = srcR.Min.X + dX
	}
	if dY := r.Dy(); dY < srcR.Dy() {
		srcR.Max.Y = srcR.Min.Y + dY
	}
	if srcR.Empty() {
		return nil
	}
	d.rasterImg(d.pixels, r, src, srcR)
	return d.s.Tx(d.rawBuf, nil)
}

// Write accepts a stream of raw RGB pixels and sends it as WS2812b encoded
// stream.
func (d *SPIDev) Write(pixels []byte) (int, error) {
	if len(pixels)%3 != 0 || len(pixels)/3 > d.numPixels {
		return 0, errors.New("ws2812b: invalid RGB stream length")
	}
	// Do not touch footer.
	d.raster(d.pixels, pixels, false)
	err := d.s.Tx(d.rawBuf, nil)
	return len(pixels), err
}

// Halt turns off all the lights.
func (d *SPIDev) Halt() error {
	// Zap out the buffer.
	for i := range d.pixels {
		d.pixels[i] = 0x88
	}
	return d.s.Tx(d.rawBuf, nil)
}

// raster serializes a buffer of RGB bytes to the WS2812b SPI format.
//
// It is expected to be given the part where pixels are, not the header nor
// footer.
//
// dst is in WS2812b SPI 32 bits word format. src is in RGB 24 bits, or 32 bits
// word format when srcHasAlpha is true. The src alpha channel is ignored in
// this case.
//
// src cannot be longer in pixel count than dst.
func (d *SPIDev) raster(dst []byte, src []byte, srcHasAlpha bool) {
	pBytes := 3
	if srcHasAlpha {
		pBytes = 4
	}
	length := len(src) / pBytes
	if l := len(dst) / 4; l < length {
		length = l
	}
	if length == 0 {
		// Save ourself some unneeded processing.
		return
	}
	stride := 4 //number of spi-bytes in color-byte
	for i := 0; i < length; i++ {
		sOff := pBytes * i
		dOff := 3 * stride * i //3 channels * stride
		r, g, b := src[sOff], src[sOff+1], src[sOff+2]
		//grb color order, msb first
		copy(dst[dOff+stride*0:dOff+stride*1], bitlut[r])
		copy(dst[dOff+stride*1:dOff+stride*2], bitlut[g])
		copy(dst[dOff+stride*2:dOff+stride*3], bitlut[b])
	}
}

// rasterImg is the generic version of raster that converts an image instead of raw RGB values.
//
// It has 'fast paths' for image.RGBA and image.NRGBA that extract and convert the RGB values
// directly.  For other image types, it converts to image.RGBA and then does the same.  In all
// cases, alpha values are ignored.
//
// rect specifies where into the output buffer to draw.
//
// srcR specifies what portion of the source image to use.
func (d *SPIDev) rasterImg(dst []byte, rect image.Rectangle, src image.Image, srcR image.Rectangle) {
	// Render directly into the buffer for maximum performance and to keep
	// untouched sections intact.
	switch im := src.(type) {
	case *image.RGBA:
		start := im.PixOffset(srcR.Min.X, srcR.Min.Y)
		// srcR.Min.Y since the output display has only a single column
		end := im.PixOffset(srcR.Max.X, srcR.Min.Y)
		// Offset into the output buffer using rect
		d.raster(dst[4*rect.Min.X:], im.Pix[start:end], true)
	case *image.NRGBA:
		// Ignores alpha
		start := im.PixOffset(srcR.Min.X, srcR.Min.Y)
		// srcR.Min.Y since the output display has only a single column
		end := im.PixOffset(srcR.Max.X, srcR.Min.Y)
		// Offset into the output buffer using rect
		d.raster(dst[4*rect.Min.X:], im.Pix[start:end], true)
	default:
		// Slow path.  Convert to RGBA
		b := im.Bounds()
		m := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
		draw.Draw(m, m.Bounds(), src, b.Min, draw.Src)
		start := m.PixOffset(srcR.Min.X, srcR.Min.Y)
		// srcR.Min.Y since the output display has only a single column
		end := m.PixOffset(srcR.Max.X, srcR.Min.Y)
		// Offset into the output buffer using rect
		d.raster(dst[4*rect.Min.X:], m.Pix[start:end], true)
	}
}

var _ display.Drawer = &Dev{}

// The bit lookup table converts a single byte into its 4 byte SPI symbol
// 0 => 1000 and 1 => 1110
var bitlut = [][]byte{
	{0x88, 0x88, 0x88, 0x88}, //  0 | 0x00 | 10001000100010001000100010001000
	{0x88, 0x88, 0x88, 0x8E}, //  1 | 0x01 | 10001000100010001000100010001110
	{0x88, 0x88, 0x88, 0xE8}, //  2 | 0x02 | 10001000100010001000100011101000
	{0x88, 0x88, 0x88, 0xEE}, //  3 | 0x03 | 10001000100010001000100011101110
	{0x88, 0x88, 0x8E, 0x88}, //  4 | 0x04 | 10001000100010001000111010001000
	{0x88, 0x88, 0x8E, 0x8E}, //  5 | 0x05 | 10001000100010001000111010001110
	{0x88, 0x88, 0x8E, 0xE8}, //  6 | 0x06 | 10001000100010001000111011101000
	{0x88, 0x88, 0x8E, 0xEE}, //  7 | 0x07 | 10001000100010001000111011101110
	{0x88, 0x88, 0xE8, 0x88}, //  8 | 0x08 | 10001000100010001110100010001000
	{0x88, 0x88, 0xE8, 0x8E}, //  9 | 0x09 | 10001000100010001110100010001110
	{0x88, 0x88, 0xE8, 0xE8}, // 10 | 0x0A | 10001000100010001110100011101000
	{0x88, 0x88, 0xE8, 0xEE}, // 11 | 0x0B | 10001000100010001110100011101110
	{0x88, 0x88, 0xEE, 0x88}, // 12 | 0x0C | 10001000100010001110111010001000
	{0x88, 0x88, 0xEE, 0x8E}, // 13 | 0x0D | 10001000100010001110111010001110
	{0x88, 0x88, 0xEE, 0xE8}, // 14 | 0x0E | 10001000100010001110111011101000
	{0x88, 0x88, 0xEE, 0xEE}, // 15 | 0x0F | 10001000100010001110111011101110
	{0x88, 0x8E, 0x88, 0x88}, // 16 | 0x10 | 10001000100011101000100010001000
	{0x88, 0x8E, 0x88, 0x8E}, // 17 | 0x11 | 10001000100011101000100010001110
	{0x88, 0x8E, 0x88, 0xE8}, // 18 | 0x12 | 10001000100011101000100011101000
	{0x88, 0x8E, 0x88, 0xEE}, // 19 | 0x13 | 10001000100011101000100011101110
	{0x88, 0x8E, 0x8E, 0x88}, // 20 | 0x14 | 10001000100011101000111010001000
	{0x88, 0x8E, 0x8E, 0x8E}, // 21 | 0x15 | 10001000100011101000111010001110
	{0x88, 0x8E, 0x8E, 0xE8}, // 22 | 0x16 | 10001000100011101000111011101000
	{0x88, 0x8E, 0x8E, 0xEE}, // 23 | 0x17 | 10001000100011101000111011101110
	{0x88, 0x8E, 0xE8, 0x88}, // 24 | 0x18 | 10001000100011101110100010001000
	{0x88, 0x8E, 0xE8, 0x8E}, // 25 | 0x19 | 10001000100011101110100010001110
	{0x88, 0x8E, 0xE8, 0xE8}, // 26 | 0x1A | 10001000100011101110100011101000
	{0x88, 0x8E, 0xE8, 0xEE}, // 27 | 0x1B | 10001000100011101110100011101110
	{0x88, 0x8E, 0xEE, 0x88}, // 28 | 0x1C | 10001000100011101110111010001000
	{0x88, 0x8E, 0xEE, 0x8E}, // 29 | 0x1D | 10001000100011101110111010001110
	{0x88, 0x8E, 0xEE, 0xE8}, // 30 | 0x1E | 10001000100011101110111011101000
	{0x88, 0x8E, 0xEE, 0xEE}, // 31 | 0x1F | 10001000100011101110111011101110
	{0x88, 0xE8, 0x88, 0x88}, // 32 | 0x20 | 10001000111010001000100010001000
	{0x88, 0xE8, 0x88, 0x8E}, // 33 | 0x21 | 10001000111010001000100010001110
	{0x88, 0xE8, 0x88, 0xE8}, // 34 | 0x22 | 10001000111010001000100011101000
	{0x88, 0xE8, 0x88, 0xEE}, // 35 | 0x23 | 10001000111010001000100011101110
	{0x88, 0xE8, 0x8E, 0x88}, // 36 | 0x24 | 10001000111010001000111010001000
	{0x88, 0xE8, 0x8E, 0x8E}, // 37 | 0x25 | 10001000111010001000111010001110
	{0x88, 0xE8, 0x8E, 0xE8}, // 38 | 0x26 | 10001000111010001000111011101000
	{0x88, 0xE8, 0x8E, 0xEE}, // 39 | 0x27 | 10001000111010001000111011101110
	{0x88, 0xE8, 0xE8, 0x88}, // 40 | 0x28 | 10001000111010001110100010001000
	{0x88, 0xE8, 0xE8, 0x8E}, // 41 | 0x29 | 10001000111010001110100010001110
	{0x88, 0xE8, 0xE8, 0xE8}, // 42 | 0x2A | 10001000111010001110100011101000
	{0x88, 0xE8, 0xE8, 0xEE}, // 43 | 0x2B | 10001000111010001110100011101110
	{0x88, 0xE8, 0xEE, 0x88}, // 44 | 0x2C | 10001000111010001110111010001000
	{0x88, 0xE8, 0xEE, 0x8E}, // 45 | 0x2D | 10001000111010001110111010001110
	{0x88, 0xE8, 0xEE, 0xE8}, // 46 | 0x2E | 10001000111010001110111011101000
	{0x88, 0xE8, 0xEE, 0xEE}, // 47 | 0x2F | 10001000111010001110111011101110
	{0x88, 0xEE, 0x88, 0x88}, // 48 | 0x30 | 10001000111011101000100010001000
	{0x88, 0xEE, 0x88, 0x8E}, // 49 | 0x31 | 10001000111011101000100010001110
	{0x88, 0xEE, 0x88, 0xE8}, // 50 | 0x32 | 10001000111011101000100011101000
	{0x88, 0xEE, 0x88, 0xEE}, // 51 | 0x33 | 10001000111011101000100011101110
	{0x88, 0xEE, 0x8E, 0x88}, // 52 | 0x34 | 10001000111011101000111010001000
	{0x88, 0xEE, 0x8E, 0x8E}, // 53 | 0x35 | 10001000111011101000111010001110
	{0x88, 0xEE, 0x8E, 0xE8}, // 54 | 0x36 | 10001000111011101000111011101000
	{0x88, 0xEE, 0x8E, 0xEE}, // 55 | 0x37 | 10001000111011101000111011101110
	{0x88, 0xEE, 0xE8, 0x88}, // 56 | 0x38 | 10001000111011101110100010001000
	{0x88, 0xEE, 0xE8, 0x8E}, // 57 | 0x39 | 10001000111011101110100010001110
	{0x88, 0xEE, 0xE8, 0xE8}, // 58 | 0x3A | 10001000111011101110100011101000
	{0x88, 0xEE, 0xE8, 0xEE}, // 59 | 0x3B | 10001000111011101110100011101110
	{0x88, 0xEE, 0xEE, 0x88}, // 60 | 0x3C | 10001000111011101110111010001000
	{0x88, 0xEE, 0xEE, 0x8E}, // 61 | 0x3D | 10001000111011101110111010001110
	{0x88, 0xEE, 0xEE, 0xE8}, // 62 | 0x3E | 10001000111011101110111011101000
	{0x88, 0xEE, 0xEE, 0xEE}, // 63 | 0x3F | 10001000111011101110111011101110
	{0x8E, 0x88, 0x88, 0x88}, // 64 | 0x40 | 10001110100010001000100010001000
	{0x8E, 0x88, 0x88, 0x8E}, // 65 | 0x41 | 10001110100010001000100010001110
	{0x8E, 0x88, 0x88, 0xE8}, // 66 | 0x42 | 10001110100010001000100011101000
	{0x8E, 0x88, 0x88, 0xEE}, // 67 | 0x43 | 10001110100010001000100011101110
	{0x8E, 0x88, 0x8E, 0x88}, // 68 | 0x44 | 10001110100010001000111010001000
	{0x8E, 0x88, 0x8E, 0x8E}, // 69 | 0x45 | 10001110100010001000111010001110
	{0x8E, 0x88, 0x8E, 0xE8}, // 70 | 0x46 | 10001110100010001000111011101000
	{0x8E, 0x88, 0x8E, 0xEE}, // 71 | 0x47 | 10001110100010001000111011101110
	{0x8E, 0x88, 0xE8, 0x88}, // 72 | 0x48 | 10001110100010001110100010001000
	{0x8E, 0x88, 0xE8, 0x8E}, // 73 | 0x49 | 10001110100010001110100010001110
	{0x8E, 0x88, 0xE8, 0xE8}, // 74 | 0x4A | 10001110100010001110100011101000
	{0x8E, 0x88, 0xE8, 0xEE}, // 75 | 0x4B | 10001110100010001110100011101110
	{0x8E, 0x88, 0xEE, 0x88}, // 76 | 0x4C | 10001110100010001110111010001000
	{0x8E, 0x88, 0xEE, 0x8E}, // 77 | 0x4D | 10001110100010001110111010001110
	{0x8E, 0x88, 0xEE, 0xE8}, // 78 | 0x4E | 10001110100010001110111011101000
	{0x8E, 0x88, 0xEE, 0xEE}, // 79 | 0x4F | 10001110100010001110111011101110
	{0x8E, 0x8E, 0x88, 0x88}, // 80 | 0x50 | 10001110100011101000100010001000
	{0x8E, 0x8E, 0x88, 0x8E}, // 81 | 0x51 | 10001110100011101000100010001110
	{0x8E, 0x8E, 0x88, 0xE8}, // 82 | 0x52 | 10001110100011101000100011101000
	{0x8E, 0x8E, 0x88, 0xEE}, // 83 | 0x53 | 10001110100011101000100011101110
	{0x8E, 0x8E, 0x8E, 0x88}, // 84 | 0x54 | 10001110100011101000111010001000
	{0x8E, 0x8E, 0x8E, 0x8E}, // 85 | 0x55 | 10001110100011101000111010001110
	{0x8E, 0x8E, 0x8E, 0xE8}, // 86 | 0x56 | 10001110100011101000111011101000
	{0x8E, 0x8E, 0x8E, 0xEE}, // 87 | 0x57 | 10001110100011101000111011101110
	{0x8E, 0x8E, 0xE8, 0x88}, // 88 | 0x58 | 10001110100011101110100010001000
	{0x8E, 0x8E, 0xE8, 0x8E}, // 89 | 0x59 | 10001110100011101110100010001110
	{0x8E, 0x8E, 0xE8, 0xE8}, // 90 | 0x5A | 10001110100011101110100011101000
	{0x8E, 0x8E, 0xE8, 0xEE}, // 91 | 0x5B | 10001110100011101110100011101110
	{0x8E, 0x8E, 0xEE, 0x88}, // 92 | 0x5C | 10001110100011101110111010001000
	{0x8E, 0x8E, 0xEE, 0x8E}, // 93 | 0x5D | 10001110100011101110111010001110
	{0x8E, 0x8E, 0xEE, 0xE8}, // 94 | 0x5E | 10001110100011101110111011101000
	{0x8E, 0x8E, 0xEE, 0xEE}, // 95 | 0x5F | 10001110100011101110111011101110
	{0x8E, 0xE8, 0x88, 0x88}, // 96 | 0x60 | 10001110111010001000100010001000
	{0x8E, 0xE8, 0x88, 0x8E}, // 97 | 0x61 | 10001110111010001000100010001110
	{0x8E, 0xE8, 0x88, 0xE8}, // 98 | 0x62 | 10001110111010001000100011101000
	{0x8E, 0xE8, 0x88, 0xEE}, // 99 | 0x63 | 10001110111010001000100011101110
	{0x8E, 0xE8, 0x8E, 0x88}, //100 | 0x64 | 10001110111010001000111010001000
	{0x8E, 0xE8, 0x8E, 0x8E}, //101 | 0x65 | 10001110111010001000111010001110
	{0x8E, 0xE8, 0x8E, 0xE8}, //102 | 0x66 | 10001110111010001000111011101000
	{0x8E, 0xE8, 0x8E, 0xEE}, //103 | 0x67 | 10001110111010001000111011101110
	{0x8E, 0xE8, 0xE8, 0x88}, //104 | 0x68 | 10001110111010001110100010001000
	{0x8E, 0xE8, 0xE8, 0x8E}, //105 | 0x69 | 10001110111010001110100010001110
	{0x8E, 0xE8, 0xE8, 0xE8}, //106 | 0x6A | 10001110111010001110100011101000
	{0x8E, 0xE8, 0xE8, 0xEE}, //107 | 0x6B | 10001110111010001110100011101110
	{0x8E, 0xE8, 0xEE, 0x88}, //108 | 0x6C | 10001110111010001110111010001000
	{0x8E, 0xE8, 0xEE, 0x8E}, //109 | 0x6D | 10001110111010001110111010001110
	{0x8E, 0xE8, 0xEE, 0xE8}, //110 | 0x6E | 10001110111010001110111011101000
	{0x8E, 0xE8, 0xEE, 0xEE}, //111 | 0x6F | 10001110111010001110111011101110
	{0x8E, 0xEE, 0x88, 0x88}, //112 | 0x70 | 10001110111011101000100010001000
	{0x8E, 0xEE, 0x88, 0x8E}, //113 | 0x71 | 10001110111011101000100010001110
	{0x8E, 0xEE, 0x88, 0xE8}, //114 | 0x72 | 10001110111011101000100011101000
	{0x8E, 0xEE, 0x88, 0xEE}, //115 | 0x73 | 10001110111011101000100011101110
	{0x8E, 0xEE, 0x8E, 0x88}, //116 | 0x74 | 10001110111011101000111010001000
	{0x8E, 0xEE, 0x8E, 0x8E}, //117 | 0x75 | 10001110111011101000111010001110
	{0x8E, 0xEE, 0x8E, 0xE8}, //118 | 0x76 | 10001110111011101000111011101000
	{0x8E, 0xEE, 0x8E, 0xEE}, //119 | 0x77 | 10001110111011101000111011101110
	{0x8E, 0xEE, 0xE8, 0x88}, //120 | 0x78 | 10001110111011101110100010001000
	{0x8E, 0xEE, 0xE8, 0x8E}, //121 | 0x79 | 10001110111011101110100010001110
	{0x8E, 0xEE, 0xE8, 0xE8}, //122 | 0x7A | 10001110111011101110100011101000
	{0x8E, 0xEE, 0xE8, 0xEE}, //123 | 0x7B | 10001110111011101110100011101110
	{0x8E, 0xEE, 0xEE, 0x88}, //124 | 0x7C | 10001110111011101110111010001000
	{0x8E, 0xEE, 0xEE, 0x8E}, //125 | 0x7D | 10001110111011101110111010001110
	{0x8E, 0xEE, 0xEE, 0xE8}, //126 | 0x7E | 10001110111011101110111011101000
	{0x8E, 0xEE, 0xEE, 0xEE}, //127 | 0x7F | 10001110111011101110111011101110
	{0xE8, 0x88, 0x88, 0x88}, //128 | 0x80 | 11101000100010001000100010001000
	{0xE8, 0x88, 0x88, 0x8E}, //129 | 0x81 | 11101000100010001000100010001110
	{0xE8, 0x88, 0x88, 0xE8}, //130 | 0x82 | 11101000100010001000100011101000
	{0xE8, 0x88, 0x88, 0xEE}, //131 | 0x83 | 11101000100010001000100011101110
	{0xE8, 0x88, 0x8E, 0x88}, //132 | 0x84 | 11101000100010001000111010001000
	{0xE8, 0x88, 0x8E, 0x8E}, //133 | 0x85 | 11101000100010001000111010001110
	{0xE8, 0x88, 0x8E, 0xE8}, //134 | 0x86 | 11101000100010001000111011101000
	{0xE8, 0x88, 0x8E, 0xEE}, //135 | 0x87 | 11101000100010001000111011101110
	{0xE8, 0x88, 0xE8, 0x88}, //136 | 0x88 | 11101000100010001110100010001000
	{0xE8, 0x88, 0xE8, 0x8E}, //137 | 0x89 | 11101000100010001110100010001110
	{0xE8, 0x88, 0xE8, 0xE8}, //138 | 0x8A | 11101000100010001110100011101000
	{0xE8, 0x88, 0xE8, 0xEE}, //139 | 0x8B | 11101000100010001110100011101110
	{0xE8, 0x88, 0xEE, 0x88}, //140 | 0x8C | 11101000100010001110111010001000
	{0xE8, 0x88, 0xEE, 0x8E}, //141 | 0x8D | 11101000100010001110111010001110
	{0xE8, 0x88, 0xEE, 0xE8}, //142 | 0x8E | 11101000100010001110111011101000
	{0xE8, 0x88, 0xEE, 0xEE}, //143 | 0x8F | 11101000100010001110111011101110
	{0xE8, 0x8E, 0x88, 0x88}, //144 | 0x90 | 11101000100011101000100010001000
	{0xE8, 0x8E, 0x88, 0x8E}, //145 | 0x91 | 11101000100011101000100010001110
	{0xE8, 0x8E, 0x88, 0xE8}, //146 | 0x92 | 11101000100011101000100011101000
	{0xE8, 0x8E, 0x88, 0xEE}, //147 | 0x93 | 11101000100011101000100011101110
	{0xE8, 0x8E, 0x8E, 0x88}, //148 | 0x94 | 11101000100011101000111010001000
	{0xE8, 0x8E, 0x8E, 0x8E}, //149 | 0x95 | 11101000100011101000111010001110
	{0xE8, 0x8E, 0x8E, 0xE8}, //150 | 0x96 | 11101000100011101000111011101000
	{0xE8, 0x8E, 0x8E, 0xEE}, //151 | 0x97 | 11101000100011101000111011101110
	{0xE8, 0x8E, 0xE8, 0x88}, //152 | 0x98 | 11101000100011101110100010001000
	{0xE8, 0x8E, 0xE8, 0x8E}, //153 | 0x99 | 11101000100011101110100010001110
	{0xE8, 0x8E, 0xE8, 0xE8}, //154 | 0x9A | 11101000100011101110100011101000
	{0xE8, 0x8E, 0xE8, 0xEE}, //155 | 0x9B | 11101000100011101110100011101110
	{0xE8, 0x8E, 0xEE, 0x88}, //156 | 0x9C | 11101000100011101110111010001000
	{0xE8, 0x8E, 0xEE, 0x8E}, //157 | 0x9D | 11101000100011101110111010001110
	{0xE8, 0x8E, 0xEE, 0xE8}, //158 | 0x9E | 11101000100011101110111011101000
	{0xE8, 0x8E, 0xEE, 0xEE}, //159 | 0x9F | 11101000100011101110111011101110
	{0xE8, 0xE8, 0x88, 0x88}, //160 | 0xA0 | 11101000111010001000100010001000
	{0xE8, 0xE8, 0x88, 0x8E}, //161 | 0xA1 | 11101000111010001000100010001110
	{0xE8, 0xE8, 0x88, 0xE8}, //162 | 0xA2 | 11101000111010001000100011101000
	{0xE8, 0xE8, 0x88, 0xEE}, //163 | 0xA3 | 11101000111010001000100011101110
	{0xE8, 0xE8, 0x8E, 0x88}, //164 | 0xA4 | 11101000111010001000111010001000
	{0xE8, 0xE8, 0x8E, 0x8E}, //165 | 0xA5 | 11101000111010001000111010001110
	{0xE8, 0xE8, 0x8E, 0xE8}, //166 | 0xA6 | 11101000111010001000111011101000
	{0xE8, 0xE8, 0x8E, 0xEE}, //167 | 0xA7 | 11101000111010001000111011101110
	{0xE8, 0xE8, 0xE8, 0x88}, //168 | 0xA8 | 11101000111010001110100010001000
	{0xE8, 0xE8, 0xE8, 0x8E}, //169 | 0xA9 | 11101000111010001110100010001110
	{0xE8, 0xE8, 0xE8, 0xE8}, //170 | 0xAA | 11101000111010001110100011101000
	{0xE8, 0xE8, 0xE8, 0xEE}, //171 | 0xAB | 11101000111010001110100011101110
	{0xE8, 0xE8, 0xEE, 0x88}, //172 | 0xAC | 11101000111010001110111010001000
	{0xE8, 0xE8, 0xEE, 0x8E}, //173 | 0xAD | 11101000111010001110111010001110
	{0xE8, 0xE8, 0xEE, 0xE8}, //174 | 0xAE | 11101000111010001110111011101000
	{0xE8, 0xE8, 0xEE, 0xEE}, //175 | 0xAF | 11101000111010001110111011101110
	{0xE8, 0xEE, 0x88, 0x88}, //176 | 0xB0 | 11101000111011101000100010001000
	{0xE8, 0xEE, 0x88, 0x8E}, //177 | 0xB1 | 11101000111011101000100010001110
	{0xE8, 0xEE, 0x88, 0xE8}, //178 | 0xB2 | 11101000111011101000100011101000
	{0xE8, 0xEE, 0x88, 0xEE}, //179 | 0xB3 | 11101000111011101000100011101110
	{0xE8, 0xEE, 0x8E, 0x88}, //180 | 0xB4 | 11101000111011101000111010001000
	{0xE8, 0xEE, 0x8E, 0x8E}, //181 | 0xB5 | 11101000111011101000111010001110
	{0xE8, 0xEE, 0x8E, 0xE8}, //182 | 0xB6 | 11101000111011101000111011101000
	{0xE8, 0xEE, 0x8E, 0xEE}, //183 | 0xB7 | 11101000111011101000111011101110
	{0xE8, 0xEE, 0xE8, 0x88}, //184 | 0xB8 | 11101000111011101110100010001000
	{0xE8, 0xEE, 0xE8, 0x8E}, //185 | 0xB9 | 11101000111011101110100010001110
	{0xE8, 0xEE, 0xE8, 0xE8}, //186 | 0xBA | 11101000111011101110100011101000
	{0xE8, 0xEE, 0xE8, 0xEE}, //187 | 0xBB | 11101000111011101110100011101110
	{0xE8, 0xEE, 0xEE, 0x88}, //188 | 0xBC | 11101000111011101110111010001000
	{0xE8, 0xEE, 0xEE, 0x8E}, //189 | 0xBD | 11101000111011101110111010001110
	{0xE8, 0xEE, 0xEE, 0xE8}, //190 | 0xBE | 11101000111011101110111011101000
	{0xE8, 0xEE, 0xEE, 0xEE}, //191 | 0xBF | 11101000111011101110111011101110
	{0xEE, 0x88, 0x88, 0x88}, //192 | 0xC0 | 11101110100010001000100010001000
	{0xEE, 0x88, 0x88, 0x8E}, //193 | 0xC1 | 11101110100010001000100010001110
	{0xEE, 0x88, 0x88, 0xE8}, //194 | 0xC2 | 11101110100010001000100011101000
	{0xEE, 0x88, 0x88, 0xEE}, //195 | 0xC3 | 11101110100010001000100011101110
	{0xEE, 0x88, 0x8E, 0x88}, //196 | 0xC4 | 11101110100010001000111010001000
	{0xEE, 0x88, 0x8E, 0x8E}, //197 | 0xC5 | 11101110100010001000111010001110
	{0xEE, 0x88, 0x8E, 0xE8}, //198 | 0xC6 | 11101110100010001000111011101000
	{0xEE, 0x88, 0x8E, 0xEE}, //199 | 0xC7 | 11101110100010001000111011101110
	{0xEE, 0x88, 0xE8, 0x88}, //200 | 0xC8 | 11101110100010001110100010001000
	{0xEE, 0x88, 0xE8, 0x8E}, //201 | 0xC9 | 11101110100010001110100010001110
	{0xEE, 0x88, 0xE8, 0xE8}, //202 | 0xCA | 11101110100010001110100011101000
	{0xEE, 0x88, 0xE8, 0xEE}, //203 | 0xCB | 11101110100010001110100011101110
	{0xEE, 0x88, 0xEE, 0x88}, //204 | 0xCC | 11101110100010001110111010001000
	{0xEE, 0x88, 0xEE, 0x8E}, //205 | 0xCD | 11101110100010001110111010001110
	{0xEE, 0x88, 0xEE, 0xE8}, //206 | 0xCE | 11101110100010001110111011101000
	{0xEE, 0x88, 0xEE, 0xEE}, //207 | 0xCF | 11101110100010001110111011101110
	{0xEE, 0x8E, 0x88, 0x88}, //208 | 0xD0 | 11101110100011101000100010001000
	{0xEE, 0x8E, 0x88, 0x8E}, //209 | 0xD1 | 11101110100011101000100010001110
	{0xEE, 0x8E, 0x88, 0xE8}, //210 | 0xD2 | 11101110100011101000100011101000
	{0xEE, 0x8E, 0x88, 0xEE}, //211 | 0xD3 | 11101110100011101000100011101110
	{0xEE, 0x8E, 0x8E, 0x88}, //212 | 0xD4 | 11101110100011101000111010001000
	{0xEE, 0x8E, 0x8E, 0x8E}, //213 | 0xD5 | 11101110100011101000111010001110
	{0xEE, 0x8E, 0x8E, 0xE8}, //214 | 0xD6 | 11101110100011101000111011101000
	{0xEE, 0x8E, 0x8E, 0xEE}, //215 | 0xD7 | 11101110100011101000111011101110
	{0xEE, 0x8E, 0xE8, 0x88}, //216 | 0xD8 | 11101110100011101110100010001000
	{0xEE, 0x8E, 0xE8, 0x8E}, //217 | 0xD9 | 11101110100011101110100010001110
	{0xEE, 0x8E, 0xE8, 0xE8}, //218 | 0xDA | 11101110100011101110100011101000
	{0xEE, 0x8E, 0xE8, 0xEE}, //219 | 0xDB | 11101110100011101110100011101110
	{0xEE, 0x8E, 0xEE, 0x88}, //220 | 0xDC | 11101110100011101110111010001000
	{0xEE, 0x8E, 0xEE, 0x8E}, //221 | 0xDD | 11101110100011101110111010001110
	{0xEE, 0x8E, 0xEE, 0xE8}, //222 | 0xDE | 11101110100011101110111011101000
	{0xEE, 0x8E, 0xEE, 0xEE}, //223 | 0xDF | 11101110100011101110111011101110
	{0xEE, 0xE8, 0x88, 0x88}, //224 | 0xE0 | 11101110111010001000100010001000
	{0xEE, 0xE8, 0x88, 0x8E}, //225 | 0xE1 | 11101110111010001000100010001110
	{0xEE, 0xE8, 0x88, 0xE8}, //226 | 0xE2 | 11101110111010001000100011101000
	{0xEE, 0xE8, 0x88, 0xEE}, //227 | 0xE3 | 11101110111010001000100011101110
	{0xEE, 0xE8, 0x8E, 0x88}, //228 | 0xE4 | 11101110111010001000111010001000
	{0xEE, 0xE8, 0x8E, 0x8E}, //229 | 0xE5 | 11101110111010001000111010001110
	{0xEE, 0xE8, 0x8E, 0xE8}, //230 | 0xE6 | 11101110111010001000111011101000
	{0xEE, 0xE8, 0x8E, 0xEE}, //231 | 0xE7 | 11101110111010001000111011101110
	{0xEE, 0xE8, 0xE8, 0x88}, //232 | 0xE8 | 11101110111010001110100010001000
	{0xEE, 0xE8, 0xE8, 0x8E}, //233 | 0xE9 | 11101110111010001110100010001110
	{0xEE, 0xE8, 0xE8, 0xE8}, //234 | 0xEA | 11101110111010001110100011101000
	{0xEE, 0xE8, 0xE8, 0xEE}, //235 | 0xEB | 11101110111010001110100011101110
	{0xEE, 0xE8, 0xEE, 0x88}, //236 | 0xEC | 11101110111010001110111010001000
	{0xEE, 0xE8, 0xEE, 0x8E}, //237 | 0xED | 11101110111010001110111010001110
	{0xEE, 0xE8, 0xEE, 0xE8}, //238 | 0xEE | 11101110111010001110111011101000
	{0xEE, 0xE8, 0xEE, 0xEE}, //239 | 0xEF | 11101110111010001110111011101110
	{0xEE, 0xEE, 0x88, 0x88}, //240 | 0xF0 | 11101110111011101000100010001000
	{0xEE, 0xEE, 0x88, 0x8E}, //241 | 0xF1 | 11101110111011101000100010001110
	{0xEE, 0xEE, 0x88, 0xE8}, //242 | 0xF2 | 11101110111011101000100011101000
	{0xEE, 0xEE, 0x88, 0xEE}, //243 | 0xF3 | 11101110111011101000100011101110
	{0xEE, 0xEE, 0x8E, 0x88}, //244 | 0xF4 | 11101110111011101000111010001000
	{0xEE, 0xEE, 0x8E, 0x8E}, //245 | 0xF5 | 11101110111011101000111010001110
	{0xEE, 0xEE, 0x8E, 0xE8}, //246 | 0xF6 | 11101110111011101000111011101000
	{0xEE, 0xEE, 0x8E, 0xEE}, //247 | 0xF7 | 11101110111011101000111011101110
	{0xEE, 0xEE, 0xE8, 0x88}, //248 | 0xF8 | 11101110111011101110100010001000
	{0xEE, 0xEE, 0xE8, 0x8E}, //249 | 0xF9 | 11101110111011101110100010001110
	{0xEE, 0xEE, 0xE8, 0xE8}, //250 | 0xFA | 11101110111011101110100011101000
	{0xEE, 0xEE, 0xE8, 0xEE}, //251 | 0xFB | 11101110111011101110100011101110
	{0xEE, 0xEE, 0xEE, 0x88}, //252 | 0xFC | 11101110111011101110111010001000
	{0xEE, 0xEE, 0xEE, 0x8E}, //253 | 0xFD | 11101110111011101110111010001110
	{0xEE, 0xEE, 0xEE, 0xE8}, //254 | 0xFE | 11101110111011101110111011101000
	{0xEE, 0xEE, 0xEE, 0xEE}, //255 | 0xFF | 11101110111011101110111011101110
}

repository: dougray/periph

repo_name: dougray/periph


text:
@article{Mohan1998b,
 abstract = {In normal individuals, novel or noxious stimuli commonly evoke the pattern of the alerting or defence response which includes cutaneous vasoconstriction, but vasodilatation in forearm skeletal muscle. We have compared cardiovascular responses evoked by sound and by indirect cooling in 60 patients with homozygous sickle cell (SS) disease and in 30 control subjects with normal haemoglobin genotype (AA). A sound of 90 dB, 1 kHz for 30s evoked an increase in hand and forearm cutaneous vascular resistance (HCVR and FCVR) in SS patients and an increase in HCVR in AA subjects, as assessed from Doppler flowmetry. Meanwhile, a decrease in forearm vascular resistance (FVR) assessed by venous occlusion plethysmography, occurred in 14 out of 30 AA subjects and 25 out of 60 SS patients, indicating vasodilatation in forearm muscle; an increase in FVR occurred in the remainder. The proportions of SS patients and AA subjects who showed an increase in FVR (53% vs 57%) were not significantly different. Cooling increased HCVR and FCVR in SS patients and increased FCVR in AA subjects; a decrease in FVR indicating vasodilatation, occurred in 12 out of 30 AA subjects, but in only 10 out of 60 SS patients. The proportion of SS patients who showed an increase in FVR to cooling was greater than in AA subjects (83% vs 60%, P < 0.05). Thus, SS patients are just as capable of showing the muscle vasodilatation of the alerting response to sound as AA subjects. That few SS patients showed muscle vasodilatation in response to cooling is consistent with the view that reflex vasoconstrictor responses to cooling are particularly strong in SS patients. This, in turn, is consistent with our hypothesis that the reflex vasoconstrictor response to cooling acts as a trigger for the painful crisis of SS disease by diverting blood flow away from active bone marrow.},
 address = {Germany},
 author = {Mohan, J. S. and Marshall, J. M. and Reid, H. L. and Thomas, P. W. and Hambleton, I. and Serjeant, G. R.},
 completed = {19980527},
 doi = {10.1007/BF02267600},
 history = {1998/04/09 00:00 [entrez]},
 issue = {1},
 journal = {Clinical autonomic research : official journal of the Clinical Autonomic Research Society},
 keywords = {Acoustic Stimulation, Adolescent, Adult, Anemia, Sickle Cell/*genetics/physiopathology, *Cold Temperature, Forearm/*blood supply, Genotype, Hemoglobins/*genetics, *Homozygote, Humans, Male, Vasoconstriction/*physiology, Vasodilation/physiology},
 language = {eng},
 linking-issn = {0959-9851},
 month = {Feb},
 nlm-unique-id = {9106549},
 owner = {NLM},
 pages = {25-30},
 print-issn = {0959-9851},
 publication-status = {ppublish},
 registry-number = {0 (Hemoglobins)},
 revised = {20200420},
 source = {Clin Auton Res. 1998 Feb;8(1):25-30. doi: 10.1007/BF02267600.},
 status = {MEDLINE},
 subset = {IM},
 title = {Comparison of responses evoked by mild indirect cooling and by sound in the forearm vasculature in patients with homozygous sickle cell disease and in normal subjects.},
 title-abbreviation = {Clin Auton Res},
 volume = {8},
 year = {1998}
}


text:
% Encoding: UTF-8

@Book{Helgaker-Jorgensen.Wiley.2013,
  title     = {Molecular Electronic-Structure Theory},
  publisher = {Wiley-Blackwell},
  year      = {2013},
  author    = {Helgaker, Trygve and Olsen, Jeppe and Jorgensen, Poul},
  isbn      = {1118531477},
  comment   = {PostHF - Textbook},
  date      = {2013-02-01},
  ean       = {9781118531471},
  file      = {:TheoriticalChemistry/Helgaker-Jorgensen.Wiley.2013.pdf:PDF},
  pagetotal = {940},
  timestamp = {2018-08-02},
  url       = {https://www.ebook.de/de/product/19812715/trygve_helgaker_jeppe_olsen_poul_jorgensen_molecular_electronic_structure_theory.html},
}

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


text:
package functions

import (
	"fmt"
	"strings"

	"github.com/gandrille/go-commons/result"
)

// Function interface
type Function interface {
	Infos() FunctionInfos
	Run() result.Result
}

// FunctionInfos type
type FunctionInfos struct {
	Title            string
	ShortDescription string
	LongDescription  string
}

func (info FunctionInfos) Describe() {
	result.Describe(info.Title, info.ShortDescription)
	if info.LongDescription != "" {
		fmt.Println(info.LongDescription)
	}
}

type Executor func() result.Result

func execute(title string, executors ...Executor) result.Result {
	onlySkip := true
	for _, exe := range executors {

		res := exe()

		msg := res.Message()
		if strings.Contains(msg, "\n") {
			msg = "\n" + msg
			msg = strings.ReplaceAll(msg, "\n", "\n* ")
		}

		if !res.IsSuccess() {
			result.PrintRed(msg)
			return result.NewError(title + " " + msg)
		} else {
			if !res.IsUnchanged() {
				onlySkip = false
			}
			fmt.Println("[" + strings.ToUpper(res.Status().String()) + "] " + msg)
		}
	}

	if onlySkip {
		return result.NewUnchanged(title)
	} else {
		return result.NewUpdated(title)
	}
}

repository: gandrille/postinstall

repo_name: gandrille/postinstall


text:
% This file was created with Citavi 6.3.0.0

@article{Brewer.2012,
 author = {Brewer, E.},
 year = {2012},
 title = {CAP twelve years later: How the rules have changed},
 pages = {23--29},
 volume = {45},
 number = {2},
 issn = {0018-9162},
 journal = {Computer},
 doi = {10.1109/MC.2012.37}
}

@online{dbkeyvalue,
    author = {solid IT gmbh},
    title = {Key-Value Stores},
    year = 2019,
    url = {https://db-engines.com/de/article/Key-Value+Stores},
    urldate = {2019-04-04}
}

@online{fulmanskikeyvalue,
    author = {Fulmanski},
    title = {Key-Value Stores},
    year = 2017,
    url = {http://fulmanski.pl/tutorials/computer-science/nosql/key-value-stores/},
    urldate = {2019-04-04}
}

@online{introredis,
    author = {redislabs},
    title = {Introduction to Redis},
    year = 2019,
    url = {https://redis.io/topics/introduction},
    urldate = {2019-04-04}
}

@online{clientredis,
    author = {redislabs},
    title = {Introduction to Redis},
    year = 2019,
    url = {https://redis.io/clients},
    urldate = {2019-04-04}
}

@online{russoredis,
    author = {Russo, Michael},
    title = {Redis, from the Ground Up},
    year = 2010,
    url = {https://mjrusso.com/redis-from-the-ground-up/},
    urldate = {2019-04-04}
}

@online{wikiredis,
    author = {Wikipedia},
    title = {Redis},
    year = 2019,
    url = {https://en.wikipedia.org/wiki/Redis},
    urldate = {2019-04-04}
}

@online{datatypesredis,
    author = {redislabs},
    title = {Data types},
    year = 2019,
    url = {https://redis.io/topics/data-types},
    urldate = {2019-04-04}
}

@online{replicaredis,
    author = {redislabs},
    title = {Data types},
    year = 2019,
    url = {https://redis.io/topics/replication},
    urldate = {2019-04-04}
}

@online{partitionredis,
    author = {redislabs},
    title = {Data types},
    year = 2019,
    url = {https://redis.io/topics/partitioning},
    urldate = {2019-04-04}
}

@online{persistenceredis,
    author = {redislabs},
    title = {Data types},
    year = 2019,
    url = {https://redis.io/topics/persistence},
    urldate = {2019-04-04}
}

repository: Joghurtdrop/database-ebook-template

repo_name: Joghurtdrop/database-ebook-template


text:
package parallel

import (
	"testing"
	"time"
)

func TestWorkerHelper(t *testing.T) {
	p := New()
	w, err := p.NewWorker("TestWorker", &WorkerConfig{Parallelism: 1})
	if err != nil {
		t.Fatalf("Failed to create new worker: %v", err)
	}
	err = p.NewDataChannel("TestChannel")
	if err != nil {
		t.Fatalf("Failed to create new data channel: %v", err)
	}
	t.Run("Initialization", func(t *testing.T) {
		wh := newWorkerHelper(w)
		testNotNil(t, wh)
		testNotNil(t, wh.worker)
		testNotNil(t, wh.wg)
	})
	t.Run("PublishData", func(t *testing.T) {
		wh := newWorkerHelper(w)
		err := wh.PublishData("TestChannel", "testdata")
		testNil(t, err)
	})
	t.Run("PublishDataChanDoesntExist", func(t *testing.T) {
		wh := newWorkerHelper(w)
		err := wh.PublishData("DoesntExist", "testdata")
		testNotNil(t, err)
	})
	t.Run("ConsumeData", func(t *testing.T) {
		wh := newWorkerHelper(w)
		data, err := wh.ConsumeData("TestChannel")
		testNil(t, err)
		testEquals(t, data.(string), "testdata")
	})
	t.Run("ConsumeDataDoesntExist", func(t *testing.T) {
		wh := newWorkerHelper(w)
		_, err := wh.ConsumeData("DoesntExist")
		testNotNil(t, err)
	})
	t.Run("ConsumeDataInBatches", func(t *testing.T) {
		wh := newWorkerHelper(w)
		for i := 0; i < 100; i++ {
			err := wh.PublishData("TestChannel", "testdata")
			testNil(t, err)
		}
		for i := 0; i < 5; i++ {
			data, err := wh.ConsumeDataInBatches("TestChannel", 20)
			testNil(t, err)
			testAssert(t, len(data) == 20, "length of batch isn't 20 (value: %v)", len(data))
		}
	})
	t.Run("ConsumeDataInBatchesDoesntExist", func(t *testing.T) {
		wh := newWorkerHelper(w)
		for i := 0; i < 5; i++ {
			_, err := wh.ConsumeDataInBatches("DoesntExist", 20)
			testNotNil(t, err)
		}
	})
	t.Run("ConsumeDataCloseChan", func(t *testing.T) {
		wh := newWorkerHelper(w)
		go func() {
			time.Sleep(50 * time.Millisecond)
			err = p.CloseDataChannel("TestChannel")
			testNil(t, err)
		}()
		_, err := wh.ConsumeData("TestChannel")
		testNotNil(t, err)
	})
	t.Run("ConsumeDataInBatchesCloseChan", func(t *testing.T) {
		wh := newWorkerHelper(w)
		go func() {
			time.Sleep(50 * time.Millisecond)
			err = p.CloseDataChannel("TestChannel")
			testNil(t, err)
		}()
		_, err := wh.ConsumeDataInBatches("TestChannel", 20)
		testNotNil(t, err)
	})
}

repository: ryanskidmore/parallel

repo_name: ryanskidmore/parallel


text:
require minidlna_1.0.inc

PR = "${INC_PR}.0"

SRC_URI[md5sum] = "be9b4c91e3fcde592dc3f9828098ca0f"
SRC_URI[sha256sum] = "840ac2303c23d63066912750391d1ebef7761b5b23493e590624a17670ceb942"

gha_language: C


text:
require ffmpeg.inc

LICENSE = "LGPLv2.1+"

DEPENDS += "schroedinger libgsm"

PE = "1"
PR = "r0"

DEFAULT_PREFERENCE = "1"

SRC_URI = "http://ffmpeg.org/releases/ffmpeg-${PV}.tar.bz2"

FULL_OPTIMIZATION_armv7a = "-fexpensive-optimizations  -ftree-vectorize -fomit-frame-pointer -O4 -ffast-math"
BUILD_OPTIMIZATION = "${FULL_OPTIMIZATION}"

EXTRA_FFCONF_armv7a = "--cpu=cortex-a8"
EXTRA_FFCONF_mipsel = "--arch=mips"
EXTRA_FFCONF_sh4 = "--arch=sh4"
EXTRA_FFCONF ?= ""

EXTRA_OECONF = " \
		--disable-static \
		--disable-ffserver \
		--disable-altivec \
		--disable-debug \
		--disable-asm \
		--disable-amd3dnow \
		--disable-amd3dnowext \
		--disable-mmx \
		--disable-mmx2 \
		--disable-sse \
		--disable-ssse3 \
		--disable-armv5te \
		--disable-armv6 \
		--disable-armv6t2 \
		--disable-armvfp \
		--disable-iwmmxt \
		--disable-mmi \
		--disable-neon \
		--disable-vis \
		--disable-yasm \
		--disable-indevs \
		--disable-outdevs \
		--disable-muxers \
		--enable-muxer=ogg \
		--enable-muxer=flac \
		--enable-muxer=aac \
		--enable-muxer=mp3 \
		--enable-muxer=h261 \
		--enable-muxer=h263 \
		--enable-muxer=h264 \
		--enable-muxer=mpeg1video \
		--enable-muxer=image2 \
		--disable-encoders \
		--enable-encoder=aac \
		--enable-encoder=mp3 \
		--enable-encoder=theora \
		--enable-encoder=h261 \
		--enable-encoder=h263 \
		--enable-encoder=h263p \
		--enable-encoder=ljpeg \
		--enable-encoder=mjpeg \
		--enable-encoder=png \
		--enable-encoder=mpeg1video \
		--disable-decoders \
		--enable-decoder=aac \
		--enable-decoder=mp3 \
		--enable-decoder=theora \
		--enable-decoder=h261 \
		--enable-decoder=h263 \
		--enable-decoder=h263i \
		--enable-decoder=h264 \
		--enable-decoder=mpeg2video \
		--enable-decoder=png \
		--enable-decoder=ljpeg \
		--enable-decoder=mjpeg \
		--enable-decoder=vorbis \
		--enable-decoder=flac \
		--enable-small \
		--enable-shared \
        --enable-pthreads \
        --disable-stripping \
        --cross-prefix=${TARGET_PREFIX} \
        --prefix=${prefix}/ \
        --enable-libgsm \
        --enable-libmp3lame \
        --enable-libschroedinger \
        --enable-libtheora  \
        --enable-libvorbis \
        --enable-swscale \
        --arch=${TARGET_ARCH} \
        --enable-cross-compile \
        --extra-cflags="${TARGET_CFLAGS} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" \
        --extra-ldflags="${TARGET_LDFLAGS}" \
		--target-os=linux \
        ${EXTRA_FFCONF} \
"

do_configure() {
	./configure ${EXTRA_OECONF}
}

repository: popazerty/openembedded-cuberevo

repo_name: popazerty/openembedded-cuberevo


text:
package api

import (
	"database/sql"
	"encoding/base64"
	"errors"
	"log"

	"crypto/rand"

	"github.com/rs/xid"
	"golang.org/x/crypto/bcrypt"
)

type User struct {
	Id             string
	Username       string
	Token          string
	Role           int
	HashedPassword string
	Verified       bool
}

func (user User) checkPassword(password string) bool {
	err := bcrypt.CompareHashAndPassword([]byte(user.HashedPassword), []byte(password))
	correct := err == nil
	return correct
}

func UsernameInUse(username string) (bool, error) {
	row := db.QueryRow("SELECT COUNT(*) FROM users WHERE lower(username) = lower($1)", username)
	var count int
	switch err := row.Scan(&count); err {
	case sql.ErrNoRows:
		return false, nil
	case nil:
		return count > 0, nil
	default:
		log.Print(err)
		return false, errors.New("Internal server error :^(")
	}
}

func ValidateUsername(username string) error {
	usernameLength := len(username)
	if usernameLength == 0 {
		return errors.New("Username cannot be 0 characters")
	}

	if usernameLength > 16 {
		return errors.New("Username cannot be longer than 16 characters")
	}

	return nil
}

func ValidatePassword(password string) error {
	passwordLength := len(password)
	if passwordLength < 5 {
		return errors.New("Password cannot be less than 5 characters")
	}

	if passwordLength > 64 {
		return errors.New("Password cannot be longer than 64 characters")
	}

	return nil
}

func HashPasswordBcrypt(password string) (string, error) {
	bytes, err := bcrypt.GenerateFromPassword([]byte(password), 10)
	if err != nil {
		log.Print(err)
		return "", errors.New("Internal server error :^(")
	}
	return string(bytes), nil
}

func GetNewToken() (string, error) {
	cryptoBytes := make([]byte, 64)
	_, err := rand.Read(cryptoBytes)
	if err != nil {
		log.Print(err)
		return "", errors.New("Internal server error :^(")
	}

	token := base64.URLEncoding.EncodeToString(cryptoBytes)
	return token, nil
}

// returns token, error
func CreateUser(username string, password string) (string, error) {
	err := ValidateUsername(username)
	if err != nil {
		return "", err
	}

	err = ValidatePassword(password)
	if err != nil {
		return "", err
	}

	usernameInUse, err := UsernameInUse(username)
	if err != nil {
		return "", err
	}

	if usernameInUse == true {
		return "", errors.New("Username in use")
	}

	hashedPassword, err := HashPasswordBcrypt(password)
	if err != nil {
		return "", err
	}

	id := xid.New().String()
	token, err := GetNewToken()
	if err != nil {
		return "", err
	}

	sql := "INSERT INTO users (id, username, token, password) VALUES ($1, $2, $3, $4)"
	_, err = db.Exec(sql, id, username, token, hashedPassword)
	if err != nil {
		log.Print(err)
		return "", errors.New("Internal server error :^(")
	}

	return token, nil
}

func getUserByKeyValue(key string, value string) (User, error) { // stops code duplication for GetUserById and GetUserByUsername
	user := User{}
	row := db.QueryRow("SELECT id, username, token, role, password, verified FROM users WHERE "+key+" = $1", value)
	switch err := row.Scan(&user.Id, &user.Username, &user.Token, &user.Role, &user.HashedPassword, &user.Verified); err {
	case sql.ErrNoRows:
		return user, errors.New("User not found")
	case nil:
		return user, nil
	default:
		log.Print(err)
		return user, errors.New("Internal server error :^(")
	}
}

func GetUserById(id string) (User, error) {
	user, err := getUserByKeyValue("id", id)
	return user, err
}

func GetUserByUsername(username string) (User, error) {
	user, err := getUserByKeyValue("username", username)
	return user, err
}

func GetUserByToken(token string) (User, error) {
	user, err := getUserByKeyValue("token", token)
	return user, err
}

repository: KowalaCo/site

repo_name: KowalaCo/site


text:
@article{RN579,
 author = {Cheng, A. C. and Johnson, D. F.},
 doi = {10.1086/505308},
 issn = {1537-6591 (Electronic)
1058-4838 (Linking)},
 journal = {Clin Infect Dis},
 number = {2},
 pages = {264-5},
 title = {Multiloculated hepatosplenic abscesses},
 type = {Journal Article},
 volume = {43},
 year = {2006}
}


text:
# Put your BibTeX entries in this file.
@TECHREPORT {priedhorskyrrandlestc2016,
    author      = "Priedhorsky, R and Randles, TC",
    title       = "Charliecloud: Unprivileged containers for user-defined
software stacks in HPC",
    institution = "Los Alamos National Laboratory",
    year        = "2016",
    number      = "LA-UR-16-22370",
    note        = "available as
\url{http://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-UR-16-22370}"
}

@MISC {dockerinc,
    author       = "Docker Inc.",
    title        = "Docker",
    howpublished = "\url{https://www.docker.com}"
}

@MISC {pfsefigithub,
    author	 = "PFSEFI",
    title        = "{Parallel Fine-grained Soft Error Fault Injector (P-FSEFI)}",
    howpublished = "\url{https://github.com/lanl/PFSEFI"}"
}

@MISC {beeproject,
    author       = "BEE",
    title       = "{BEE}",
    howpublished = "\url{http://bee.dsscale.org}"
}

@INPROCEEDINGS {canonrsjacobsend,
    author    = "RS Canon and D Jacobsen",
    title     = "Shifter: Containers for HPC",
    booktitle = "Proceedings of the Cray User's Group",
    year      = "2016"
}

@ARTICLE {kurtzergmsochatvbauermw,
    author  = "Kurtzer GM, Sochat V, Bauer MW",
    title   = "Singularity: Scientific containers for mobility of compute",
    journal = "PLoS ONE",
    year    = "2017",
    month   = "may",
    note    = "available as \url{https://doi.org/10.1371/journal.pone.0177459}"
}

@INPROCEEDINGS{6877352,
author={Q. Guan and N. Debardeleben and S. Blanchard and S. Fu},
booktitle={2014 IEEE 28th International Parallel and Distributed Processing Symposium},
title={F-SEFI: A Fine-Grained Soft Error Fault Injection Tool for Profiling Application Vulnerability},
year={2014},
volume={},
number={},
pages={1245-1254},
keywords={fault tolerant computing;operating systems (computers);parallel
processing;program compilers;public domain software;virtual machines;F-SEFI;HPC
applications;QEMU;application source code;compilers;data corruption;design
constraints;exascale computing;feature size;fine-grained soft error fault
injection tool;high performance computing community;open source virtual machine
hypervisor;operating systems;operating voltage;profiling application
vulnerability;soft errors;software robustness profiling;Benchmark
testing;Circuit faults;Hardware;Probes;Registers;Virtual machine
monitors;Virtual machining;High Performance Computing;fault
injection;resilience;soft error;vulnerability},
doi={10.1109/IPDPS.2014.128},
ISSN={1530-2075},
month={May},}

@inproceedings{DBLP:conf-ppopp-MenonM18,
  author    = {Harshitha Menon and
               Kathryn Mohror},
  title     = {DisCVar: discovering critical variables using algorithmic differentiation for transient faults},
  booktitle = {Proceedings of the 23rd {ACM} {SIGPLAN} Symposium on Principles
and
               Practice of Parallel Programming, PPoPP 2018, Vienna, Austria,
February
               24-28, 2018},
  pages     = {195--206},
  year      = {2018},
  url       = {https://doi.org/10.1145/3178487.3178502},
  doi       = {10.1145/3178487.3178502},
  timestamp = {Tue, 06 Nov 2018 16:57:28 +0100},
  biburl    = {https://dblp.org/rec/bib/conf/ppopp/MenonM18},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

repository: curfman/ECP-ST-CAR-PUBLIC

repo_name: curfman/ECP-ST-CAR-PUBLIC


text:
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(Kokkos REQUIRED)
find_dependency(KokkosKernels REQUIRED)

if(NOT TARGET pairg::libpairg)
  include("${CMAKE_CURRENT_LIST_DIR}/pairg-targets.cmake")
endif()

check_required_components(pairg)

include("${CMAKE_CURRENT_LIST_DIR}/pairg-config-version.cmake")
message(STATUS "Found PairG (version ${PACKAGE_VERSION})")

repository: cartoonist/PairG

repo_name: cartoonist/PairG

extension: in


text:
package object

import (
	"strconv"
	"testing"
)

func TestStringMapKey(t *testing.T) {
	testCases := []struct {
		val1  Mappable
		val2  Mappable
		diff1 Mappable
		diff2 Mappable
	}{
		{
			val1:  &String{Value: "Hello World"},
			val2:  &String{Value: "Hello World"},
			diff1: &String{Value: "My name is johnny"},
			diff2: &String{Value: "My name is johnny"},
		},
		{
			val1:  &Integer{Value: 1},
			val2:  &Integer{Value: 1},
			diff1: &Integer{Value: 10},
			diff2: &Integer{Value: 10},
		},
		{
			val1:  &Boolean{Value: true},
			val2:  &Boolean{Value: true},
			diff1: &Boolean{Value: false},
			diff2: &Boolean{Value: false},
		},
	}

	for i, tc := range testCases {
		t.Run(strconv.Itoa(i), func(t *testing.T) {
			if tc.val1.MapKey() != tc.val2.MapKey() {
				t.Errorf("Case %d: Variables with same content have different hash keys", i)
			}

			if tc.diff1.MapKey() != tc.diff2.MapKey() {
				t.Errorf("Case %d: Variables with same content have different hash keys", i)
			}

			if tc.val1.MapKey() == tc.diff1.MapKey() {
				t.Errorf("Case %d: Variables with different content have same hash keys", i)
			}
		})
	}
}

repository: axbarsan/doggo

repo_name: axbarsan/doggo


text:
package river

import (
	"reflect"
	"strings"

	"github.com/ehalpern/go-mysql/canal"
	"github.com/ehalpern/go-mysql/schema"
	"github.com/ehalpern/mysql2es/config"
	"github.com/juju/errors"
	"github.com/siddontang/go/log"

	"gopkg.in/olivere/elastic.v3"
)

var (
	ErrIgnoredEvent = errors.New("ignoring event for unexpected database or table")
)

const (
	fieldTypeList = "list"
)

// Converts database replication row events to elasticsearch bulk actions
func Convert(rules *config.Runtime, e *canal.RowsEvent) ([]elastic.BulkableRequest, error) {
	rule := rules.GetRule(e.Table.Schema, e.Table.Name)
	if rule == nil {
		return nil, errors.Errorf("no rule found for %s.%s", e.Table.Schema, e.Table.Name )
	}

	log.Debugf("Converting %v", rule)
	var reqs []elastic.BulkableRequest
	var err error

	switch e.Action {
	case canal.InsertAction:
		reqs, err = convertInsert(rule, e.Rows)
	case canal.DeleteAction:
		reqs, err = convertDelete(rule, e.Rows)
	case canal.UpdateAction:
		log.Debugf("Converting update: %+v", e.Rows)
		reqs, err = convertUpdate(rule, e.Rows)
		log.Debugf("Converted update: %+v", reqs)
	default:
		return nil, errors.Errorf("Unrecognized action action %s", e.Action)
	}

	if err != nil {
		return nil, errors.Errorf("Error adding %s to bulk request: %v", e.Action, err)
	}

	return reqs, nil
}

// for insert and delete
func convertAction(rule *config.Rule, action string, rows [][]interface{}) ([]elastic.BulkableRequest, error) {
	reqs := make([]elastic.BulkableRequest, 0, len(rows))

	for _, values := range rows {
		if id, err := rule.DocId(values); err != nil {
			log.Warnf("skipping row %s due to: %v\n", action, err)
			continue
		} else {
			var req elastic.BulkableRequest

			if parentId, err := rule.ParentId(values); err != nil {
				return nil, err
			} else if action == canal.DeleteAction {
				req = elastic.NewBulkDeleteRequest().Index(rule.Index).Type(rule.Type).Id(id).Routing(parentId)
			} else {
				doc := convertRow(rule, values)
				req = elastic.NewBulkIndexRequest().Index(rule.Index).Type(rule.Type).Id(id).Parent(parentId).Doc(doc)
			}
			reqs = append(reqs, req)
		}
	}

	return reqs, nil
}

func convertInsert(rule *config.Rule, rows [][]interface{}) ([]elastic.BulkableRequest, error) {
	return convertAction(rule, canal.InsertAction, rows)
}

func convertDelete(rule *config.Rule, rows [][]interface{}) ([]elastic.BulkableRequest, error) {
	return convertAction(rule, canal.DeleteAction, rows)
}

func convertUpdate(rule *config.Rule, rows [][]interface{}) ([]elastic.BulkableRequest, error) {
	if len(rows) % 2 != 0 {
		return nil, errors.Errorf("invalid update rows event, must have 2x rows, but %d", len(rows))
	}

	reqs := make([]elastic.BulkableRequest, 0, len(rows))
	var err error = nil

	for i := 0; i < len(rows); i += 2 {
		beforeID, err := rule.DocId(rows[i])
		if err != nil {
			log.Warnf("skipping row update due to problem with before update values: %v\n", err)
			continue
		}

		afterID, err := rule.DocId(rows[i+1])
		if err != nil {
			log.Warnf("skipping row update due to problem with update values: %v\n", err)
			continue
		}

		beforeParentID, afterParentID := "", ""
		beforeParentID, err = rule.ParentId(rows[i])
		if err != nil {
			return nil, errors.Trace(err)
		}
		afterParentID, err = rule.ParentId(rows[i+1])
		if err != nil {
			return nil, errors.Trace(err)
		}

		var req elastic.BulkableRequest
		req = elastic.NewBulkUpdateRequest().Index(rule.Index).Type(rule.Type).Parent(beforeParentID).Id(beforeID).Routing(beforeParentID)

		if beforeID != afterID || beforeParentID != afterParentID {
			// if an id is changing, delete the old document and insert a new one
			req = elastic.NewBulkDeleteRequest().Index(rule.Index).Type(rule.Type).Id(beforeID).Routing(beforeParentID)
			reqs = append(reqs, req)
			temp, err := convertInsert(rule, [][]interface{}{rows[i+1]})
			if err == nil {
				req = temp[0]
			}
		} else {
			doc := convertUpdateRow(rule, rows[i], rows[i+1])
			req = elastic.NewBulkUpdateRequest().Index(rule.Index).Type(rule.Type).Parent(beforeParentID).Id(beforeID).Routing(beforeParentID).Doc(doc)
		}
		reqs = append(reqs, req)
	}

	return reqs, err
}

func convertColumnData(col *schema.TableColumn, value interface{}) interface{} {
	switch col.Type {
	case schema.TYPE_ENUM:
		switch value := value.(type) {
		case int64:
			// for binlog, ENUM may be int64, but for dump, enum is string
			eNum := value - 1
			if eNum < 0 || eNum >= int64(len(col.EnumValues)) {
				// the column value is null
				return ""
			}

			return col.EnumValues[eNum]
		}
	case schema.TYPE_SET:
		switch value := value.(type) {
		case int64:
			// for binlog, SET may be int64, but for dump, SET is string
			bitmask := value
			sets := make([]string, 0, len(col.SetValues))
			for i, s := range col.SetValues {
				if bitmask&int64(1<<uint(i)) > 0 {
					sets = append(sets, s)
				}
			}
			return strings.Join(sets, ",")
		}
	case schema.TYPE_STRING:
		switch value := value.(type) {
		case []byte:
			return string(value[:])
		}
	case schema.TYPE_FLOAT:
		switch value := value.(type) {
		case int64:
			return float64(value)
		}
	}
	return value
}

func convertRow(rule *config.Rule, values []interface{}) map[string]interface{} {
	doc := make(map[string]interface{}, len(values))

	for i, c := range rule.TableInfo.Columns {
		fname, value := convertField(rule, &c, values[i])
		doc[fname] = value
	}
	return doc
}

func convertUpdateRow(rule *config.Rule, before []interface{}, after []interface{}) map[string]interface{} {
	doc := make(map[string]interface{}, len(after))
	for i, c := range rule.TableInfo.Columns {
		if len(after) <= i {
			// New column may have been to schema before update was processed. This is due
			// to design flaw in go-mysql that reads most recent schema when restarting
			// replication rather than updating schema based on replication log contents.
			break;
		}
		if len(before) <= i || !reflect.DeepEqual(before[i], after[i]) {
			// Update doc if field wasn't in or is different from original row
			field, value := convertField(rule, &c, after[i])
			doc[field] = value
		}
	}
	return doc
}

func convertField(rule *config.Rule, column *schema.TableColumn, value interface{}) (string, interface{}) {
	v := convertColumnData(column, value)
	for cname, s := range rule.FieldMapping {
		if cname == column.Name {
			fname, ftype := parseFieldMapping(cname, s)
			str, ok := v.(string)
			if ok == false {
				return cname, v
			} else if ftype == fieldTypeList {
				return fname, strings.Split(str, ",")
			} else {
				return fname, str
			}
		}
	}
	return column.Name, v
}

func parseFieldMapping(cname string, value string) (string, string) {
	fname := cname
	ftype := ""

	split := strings.Split(value, ",")

	if (split[0] != "") {
		fname = split[0]
	}
	if len(split) == 2 {
		ftype = split[1]
	}

	return fname, ftype
}


text:
# SPDX-Licence-Identifier: MIT

SUMMARY = "Example recipe for compiling a helloworld C++ application"
LICENSE = "MIT"

# The SRC_URI is a tool with many talents. It's purpose is to bring in files
# from different sources into the build tree for the recipe. It can bring in
# ordinary files, pull git repositories, unpack tar achives, and apply patches.
#
# In this case, we are only interested in files.
#
# The paths of files specified here are, by default, relative to a directory
# named with the name of the recipe, and within the recipe directory.
#
# In this case, the directory search here subdirectory called "helloworld".
#
# It is possible to specify a different directory, which is a common pattern
# within mion recipes. This is done as follows:
#
#    FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
#

SRC_URI = " \
	file://main.cpp \
	file://LICENSE \
"

# The licence checksum is required in mion. It's goal is to make sure that any
# software pulled hasn't had any license changes.

LIC_FILES_CHKSUM = "file://LICENSE;md5=c6640a3f1119eaec9540d5a4c69d5aef"

# The "S" variable represents the source directory, and is the relative path by
# which many operations are performed. The "WORKDIR" represents the top of the
# recipe's build tree. In many cases, these are different. Tar archives may have
# their packed files with some directory prefix, which would be expanded upon
# unpacking into the WORKDIR. Git repositories are pulled into a "git" directory
# within WORKDIR.
#
# In this case, because we are copying plain files, which are placed directly
# into the WORKDIR, the source directory S needs to be the same.

S = "${WORKDIR}"

# The build system will already have a set of flags defined for things like
# hardening, hashing etcetera. Because of this, we don't want to clobber what
# has already been set, and instead append to it. If you discover that there is
# some flag provided by default that is not desirable, it can be removed via
#
#    CXXFLAGS_remove = " -someflag"
#
# However, this is probably not something you should be doing.

CXXFLAGS += " -std=c++17 -O2"

# `do_compile` is the function responsible for compileing a recipe.
#
# Just like CPPFLAGS, LDFLAGS is already helpfully set by the build system.
#
# Here we also have a new variable, B. This is the build directory, and is where
# all artefacts produced by recipe should be placed. As is common practice these
# days, source and build output directories are separated.
#
# While there is a variable called "CPP" do not make the mistake of using it
# in place of "CXX"! "CPP" is the minimal command and arguments to run the
# C pre-processor!

do_compile() {
    ${CXX} ${CPPFLAGS} ${LDFLAGS} ${WORKDIR}/main.cpp -o ${B}/helloworld
}

# `do_install` is the function responsible for installing build artefacts into
# the destination directory.
#
# Funnily enough, "D" stands for the destination path, in which all artefacts
# are staged prior to building a package.
#
# There is also the "bindir" variable. This is the standard filesystem path for
# the location of executables on a Linux system. This is typically "/usr/bin",
# but it can be overriden.
#
# What is basically happening is that all of the artefacts are being staged in
# directory structure representative of the target system.
#
# You might expext that "bindir" should already exist, however, because all
# packages stage their results in their own directory, it does still need to
# be created. However, any other recipes dependent on the package this recipe
# produces will be able to see them.

do_install() {
    install -d ${D}${bindir}
    install -m 0755 ${B}/helloworld ${D}${bindir}/helloworld
}

# Finally, FILES indicates which directories and files should be included in
# the finished package. In mion, if the build directory contains a file which
# isn't listed here, an error will be produced.

FILES_${PN} = "${bindir}"

repository: NetworkGradeLinux/meta-mion

repo_name: NetworkGradeLinux/meta-mion

branch_name: refs/heads/dunfell


text:
LINUX_VERSION ?= "4.1.0"

SRCREV = "07009cab090ade3dd180e8a55d590b1a00072eed"
SRC_URI = "git://github.com/anholt/linux.git;protocol=git;branch=vc4-kms-v3d-rpi2 \
           file://0001-rpi2-setup.patch \
           file://0002-drm-vc4-Use-the-fbdev_cma-helpers.patch \
           file://0003-drm-vc4-Allow-vblank-to-be-disabled.patch \
           file://rpi2-defconfig.patch \
           file://HULK_SMASH.patch \
          "

require linux-raspberrypi.inc

repository: rzr/meta-raspberrypi

repo_name: rzr/meta-raspberrypi


text:
package codebase

import (
    "math"
    "time"
)

type WorkingDays time.Time

func (w WorkingDays) time() time.Time {
    return time.Time(w)
}

func (w WorkingDays) SinceUnix() int64 {
    beginningOfDay := w.time().UTC().Truncate(24 * time.Hour)

    days := beginningOfDay.UnixNano() / int64(24*time.Hour)
    days += 3 // Move day to Sunday

    working_days := float64((days / 7) * 5)
    working_days += math.Min(float64(days%7), 5)

    return int64(working_days - 3) // Move back
}

repository: mrfuxi/go-codebase

repo_name: mrfuxi/go-codebase


text:
@article{,
urldate = {2020-04-17},
abstract = {An electronic reporting system for a network of 22 laboratories was implemented in Kansas City, Missouri, with an independent organization acting as a data clearinghouse between the reporting laboratories and public health departments. The system ran in tandem with conventional reporting methods. Laboratory test orders and results were aggregated and mapped to a common nomenclature. Reports were delivered through a secure Internet connection to the Kansas City Health Department (KCHD); during the first 200 days of operation, 359 qualified results were delivered electronically to KCHD. Data were received more quickly than they were with conventional reporting methods: notification of chlamydia cases arrived 2 days earlier, invasive group A streptococcal disease cases arrived 2.3 days sooner, and salmonellosis cases arrived 2.7 days sooner. Data were more complete for all demographic fields, including address, age, sex, race, and date of birth. Two hundred fourteen cases reported electronically were not received by conventional means.},
annote = {A nice example of collaboration and data harmonization to improve reporting of public health threats.},
author = {Mark A. Hoffman and Tiffany H. Wilkinson and Aaron Bush and Wayne Myers and Ron G. Griffin},
doi = {10.3201/eid0910.030060},
isbn-issn = {1080-6059},
issue = {10},
keywords = {Electronic Health Records},
primary-date = {2020-03-22},
primary-title = {Multijurisdictional Approach to Biosurveillance, Kansas City},
secondary-title = {Emerging Infectious Disease journal},
start-page = {1281},
type = {JOUR},
url = {https://wwwnc.cdc.gov/eid/article/9/10/03-0060_article},
volume = {9},
year = {2003},
}

repository: pmean/build-website

repo_name: pmean/build-website


text:
/*
Triangolo
---------

Scrivere un programma triangolo.go che verifica l'appartenenza
(cioè all'interno o sul suo perimetro) di un punto (x,y) a un triangolo ABC,
la cui base AB si trova sull'asse delle ascisse e di cui sono date
le equazioni delle rette su cui stanno i lati AC e BC (vedi figura).

       r2\  /r1
   y|     \/
    |   C /\  .pE
    |    /  \
    |   / .pI\
    |__/______\________
	   A       B     x

Nota: Una retta è specificata attraverso il coefficiente angolare m
e il termine noto (intercetta) q della sua equazione y = m·x+q.

In particolare il programma stampa il punto e uno dei messaggi
(vedi anche esempi sotto)

- fuori
- dentro

a seconda che il punto appartenga o no.

Il programma deve essere dotato di

- una struttura Punto con due campi float64
per le coordinate x e y del punto

- una struttura Retta con due campi float64
per il coefficiente angolare m e l'intercetta q della retta

- una funzione
	Sotto(p Punto, r Retta) bool
che restituisce 'true' se il Punto p è sotto o sulla Retta r,
'false' altrimenti

- una funzione main()
che legge da standard input, nell'ordine,
	la m e la q della prima retta
	la m e la q della seconda retta
	la x e la y di un punto
verifica se il punto appartiene o no
al triangolo e stampa il messaggio opportuno.

Non si devono fare controlli sulle rette, si assuma cioè che definiscano un triangolo,
come mostrato nella figura sopra.

ESEMPI

go run triangolo.go
2 -2
-2 20
3 5
{3 5} fuori

go run triangolo.go
1 4
-1 12
1 1
{1 1} dentro

*/
package main

import (
	"fmt"
	"os/exec"
	"strings"

	//"log"
	"testing"
)

func TestMainMultiplo(t *testing.T) {
	lanciaEcontrolla("1 0 -1 4 .2 .1", "{0.2 0.1} dentro\n", t)
	lanciaEcontrolla("1 0 -1 5 1 .5", "{1 0.5} dentro\n", t)
	lanciaEcontrolla("1 0 -1 10 3 2", "{3 2} dentro\n", t)
	lanciaEcontrolla("1 0 -1 10 13 2", "{13 2} fuori\n", t)
}

func TestMainSottoAscisse(t *testing.T) {
	lanciaEcontrolla("1 0 -1 4 .2 -.1", "{0.2 -0.1} fuori\n", t)
	lanciaEcontrolla("1 0 -1 5 1 -.5", "{1 -0.5} fuori\n", t)
	lanciaEcontrolla("1 0 -1 10 3 -2", "{3 -2} fuori\n", t)
}

func lanciaEcontrolla(in string, out string, t *testing.T) {
	fmt.Println("-----------------------------------")
	subproc := exec.Command("./triangolo", in) // presuppone che sia già stato compilato
	subproc.Stdin = strings.NewReader(in)
	stdout, stderr := subproc.CombinedOutput()

	if stderr != nil {
		t.Errorf("Fallito: %s\n", stderr)
	}
	fmt.Printf("Output:\n%s\n", string(stdout))
	fmt.Printf("Expected output:\n%s\n", out)
	if string(stdout) != out {
		fmt.Println(">>> FAIL!")
		t.Fail()
	}
	subproc.Process.Kill()
}

func TestSotto1(t *testing.T) {
	p := Punto{1, 1}
	r := Retta{1, 10}
	if !Sotto(p, r) {
		t.Fail()
	}
}

func TestSotto2(t *testing.T) {
	p := Punto{11, 11}
	r := Retta{0, 10}
	if Sotto(p, r) {
		t.Fail()
	}
}

func TestSotto3(t *testing.T) {
	p := Punto{3, 3}
	r := Retta{1, 0}
	if !Sotto(p, r) {
		t.Fail()
	}
}

repository: samdsk/lab-go

repo_name: samdsk/lab-go


text:
SUMMARY = "Support for bookmarks and the XBEL format"
LICENSE = "GPL-2.0-or-later & LGPL-2.0-only & LGPL-2.0-or-later & LGPL-2.0-or-later"
LIC_FILES_CHKSUM = " \
    file://LICENSES/GPL-2.0-or-later.txt;md5=fed54355545ffd980b814dab4a3b312c \
    file://LICENSES/LGPL-2.0-only.txt;md5=6d2d9952d88b50a51a5c73dc431d06c7 \
    file://LICENSES/LGPL-2.0-or-later.txt;md5=6d2d9952d88b50a51a5c73dc431d06c7 \
    file://LICENSES/LGPL-3.0-only.txt;md5=c51d3eef3be114124d11349ca0d7e117 \
"

inherit kde-kf5

DEPENDS += " \
    kcoreaddons-native \
    kauth-native \
    kconfig-native kconfig \
    kconfigwidgets \
    kiconthemes \
    kxmlgui  \
"

PV = "${KF5_VERSION}"
SRC_URI[sha256sum] = "b5b82d3fda366a2bcada2500ee7f727c1eda0c4218330511ae58993893c1686d"


text:
package dao

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jmoiron/sqlx"
	"github.com/sirupsen/logrus"
	"user/utils"
)

type Dao struct {
	DB *sqlx.DB
}

func NewDao() *Dao {
	return &Dao{
		DB: NewDB(),
	}
}

func NewDB() *sqlx.DB {
	daoConfig := utils.Config
	logrus.Infof("init Mysql config: %+v", daoConfig)
	mysqlConfig := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4",
		daoConfig.Mysql.User,
		daoConfig.Mysql.Pwd,
		daoConfig.Mysql.Host,
		daoConfig.Mysql.Port,
		daoConfig.Mysql.Database,
	)
	logrus.Infof("init Mysql config: %s", mysqlConfig)

	Mysql, err := sqlx.Open("mysql", mysqlConfig)
	if err != nil {
		panic(err)
	}
	Mysql.SetMaxOpenConns(10)
	return Mysql
}


text:
const zlib = require('zlib');
const fs = require('fs');

const findMatchObjectFile = async (files, hash) => {
    for(file of files) {
        if(file.substring(0,2) === hash.substr(2,4)){
            return file;
        }
    }
    return null;
}

const catFile = async (...parms) => {
    const hash = parms[1] ? parms[1] : parms[0];
    const opt = parms[1] ? parms[0] : null;

    const base_uri = '.git/objects/' + hash.substring(0,2);
    const files = await fs.readdirSync(base_uri);
    const file = await findMatchObjectFile(files, hash);
    if(file && opt == '-p') {
        const zlib_content = await fs.readFileSync(`${base_uri}/${file}`);
        console.log(await zlib.inflateSync(zlib_content).toString());
    }
    else {
        throw Error('Not a valid object name' + hash)
    }
}

module.exports = catFile;

extension: js


text:
@article{Li2015b,
 abstract = {In this work, we numerically study critical phases in translation-invariant ZN parafermion chains with both nearest- and next-nearest-neighbor hopping terms. The model can be mapped to a ZN spin model with nearest-neighbor couplings via a generalized Jordan-Wigner transformation and translational invariance ensures that the spin model is always self-dual. We first study the low-energy spectrum of chains with only nearest-neighbor coupling, which are mapped onto standard self-dual ZN clock models. For 3$łeq$N$łeq$6, we match the numerical results to the known conformal field theory(CFT) identification. We then analyze in detail the phase diagram of a N=3 chain with both nearest and next-nearest-neighbor hopping and six critical phases with central charges being 4/5, 1, or 2 are found. We find continuous phase transitions between c=1 and 2 phases, while the phase transition between c=4/5 and 1 is conjectured to be of Kosterlitz-Thouless type.},
 author = {Li, Wei and Yang, Shuo and Tu, Hong-Hao and Cheng, Meng},
 doi = {10.1103/PhysRevB.91.115133},
 journal = {Phys. Rev. B},
 month = {March},
 number = {11},
 pages = {115133},
 title = {Criticality in Translation-Invariant Parafermion Chains},
 volume = {91},
 year = {2015}
}

repository: wlibuaa/academic-kickstart

repo_name: wlibuaa/academic-kickstart


text:
// L'act

package main

import (
    "fmt"
    "os"
    "syscall"
    "os/signal"
    "runtime"
    //"net/http"
    //_ "net/http/pprof"

    "sal/network"
    "sal/proto"
)

func handleSig() {
    c := make(chan os.Signal, 1)
    signal.Notify(c, os.Interrupt, syscall.SIGTERM)

    for sig := range c {
        fmt.Println("__handle__signal__", sig)
        return
    }
}

func main() {
    runtime.GOMAXPROCS(runtime.NumCPU())

    //go func() {
    //    log.Println(http.ListenAndServe("localhost:6061", nil))
    //}()

    sal_recv_chan := make(chan *proto.SalPack, 10240)
    sal_send_chan := make(chan *proto.SalPack, 10240)
    sal_bakend := network.NewSalBackend(sal_recv_chan, sal_send_chan)
    go sal_bakend.Start()
    sal_frontend := network.NewSalFrontend(sal_recv_chan, sal_send_chan)
    go sal_frontend.Start()

    handleSig()
}

repository: lsaint/sal

repo_name: lsaint/sal


text:
// +build !longTests

package executable

import (
	"strings"
	"testing"
)

func TestInfiniteRecursion(t *testing.T) {
	var code strings.Builder
	code.WriteString("public static void main(String[] args) {\n")
	code.WriteString("System.out.println(oops(5));\n")
	code.WriteString("}\n")
	code.WriteString("public static int oops(int x){\n")
	code.WriteString("if(x > 0 ){\n")
	code.WriteString("return oops(++x);\n")
	code.WriteString("}else{")
	code.WriteString("return x;\n")
	code.WriteString("}}")
	prog, err := NewExecutable("java", code.String(), nil)
	if err != nil {
		t.Error(err)
	}

	expected := "Exception in thread \"main\" java.lang.StackOverflowError\n"
	_, actual := prog.Run()

	errorMessage := actual.Error()
	newLineIndex := strings.Index(errorMessage, "\n") + 1
	errorMessage = errorMessage[:newLineIndex]

	assertRuntimeError(actual, t)
	assertEquals(expected, errorMessage, t)
}

func TestInfiniteLoop(t *testing.T) {
	var code strings.Builder
	code.WriteString("x = 5\n")
	code.WriteString("while(True):\n")
	code.WriteString("\tx+=1\n")
	prog, _ := NewExecutable("python", code.String(), nil)

	_, actual := prog.Run()
	expected := "Time Limit Exceeded 15s"

	assertTimeLimitError(actual, t)
	assertEquals(expected, actual.Error(), t)
}

repository: joshua-sterner/scheduler

repo_name: joshua-sterner/scheduler


text:
SUMMARY = "Gnuplot is a portable command-line driven graphing utility"
DESCRIPTION = "Gnuplot is a portable command-line driven interactive datafile \
(text or binary) and function plotting utility."
HOMEPAGE = "http://www.gnuplot.info/"
SECTION = "console/scientific"
LICENSE = "gnuplot"
LIC_FILES_CHKSUM = "file://Copyright;md5=243a186fc2fd3b992125d60d5b1bab8f"
DEPENDS = "${BPN}-native virtual/libx11 gd readline"

inherit autotools features_check
# depends on virtual/libx11
REQUIRED_DISTRO_FEATURES = "x11"

SRC_URI = "${SOURCEFORGE_MIRROR}/gnuplot/${BP}.tar.gz;name=archive \
    http://www.mneuroth.de/privat/zaurus/qtplot-0.2.tar.gz;name=qtplot \
    file://gnuplot.desktop \
    file://gnuplot.png \
"
SRC_URI_append_class-target = " \
    file://0002-do-not-build-demos.patch \
    file://0003-Use-native-tools-to-build-docs.patch \
    file://0004-Add-configure-option-to-find-qt5-native-tools.patch \
"

SRC_URI[archive.md5sum] = "2df8767c7399bee57a96296d46b4d5fb"
SRC_URI[archive.sha256sum] = "60a6764ccf404a1668c140f11cc1f699290ab70daa1151bb58fed6139a28ac37"
SRC_URI[qtplot.md5sum] = "0a481885a496092c77eb4017540b5cf6"
SRC_URI[qtplot.sha256sum] = "6df317183ff62cc82f3dcf88207a267cd6478cb5147f55d7530c94f1ad5f4132"

# for building docs (they deserve it) we need *doc2* tools native
BBCLASSEXTEND = "native"
DEPENDS_class-native = "readline-native"
PACKAGECONFIG_class-native = ""

SRC_URI_append_class-native = " file://0001-reduce-build-to-conversion-tools-for-native-build.patch"

do_install_class-native() {
    install -d ${D}${bindir}
	install ${B}/docs/*doc* ${D}${bindir}
    rm ${D}${bindir}/*.o
}

PACKAGECONFIG ??= "cairo"
PACKAGECONFIG[cairo] = "--with-cairo,--without-cairo,cairo pango"
PACKAGECONFIG[lua] = "--with-lua,--without-lua,lua"
PACKAGECONFIG[qt5] = "--with-qt --with-qt5nativesysroot=${STAGING_DIR_NATIVE},--without-qt,qtbase-native qtbase qtsvg qttools-native"

EXTRA_OECONF = "--with-readline=${STAGING_LIBDIR}/.. \
                --without-tutorial \
                --disable-wxwidgets"

do_compile_prepend() {
    install -m 0644 ${WORKDIR}/qtplot-0.2/qtopia.trm ${S}/term/
}

do_install_append_class-target() {
    install -d ${D}${datadir}/applications/
    install -m 0644 ${WORKDIR}/gnuplot.desktop ${D}${datadir}/applications/
    install -d ${D}${datadir}/pixmaps/
    install -m 0644 ${WORKDIR}/gnuplot.png ${D}${datadir}/pixmaps/
}

PACKAGES =+ "${PN}-x11"

RPROVIDES_${PN}-dbg += "${PN}-x11-dbg"

DESCRIPTION_${PN}-x11 = "X11 display terminal for Gnuplot."
SECTION_${PN}-x11 = "x11/scientific"
FILES_${PN}-x11 = "${libexecdir} ${datadir}/applications ${datadir}/pixmaps ${libdir}/X11 "

FILES_${PN} += "${datadir}/texmf"

repository: ni/meta-openembedded

repo_name: ni/meta-openembedded

branch_name: refs/heads/nilrt/master/hardknott

gha_language: BitBake