text:
---
---

@string{aps = {American Physical Society,}}

@article{mccabe2023mors,
  title={Uncertain Waters: Integrated Modeling of Fuel-Constrained Operations in Contested Environments},
  author={McCabe, L. H. and S. Brown and S. Whittle and N. Danneman and B. Cheng and M. Anderson},
  journal={MORS 91st Symposium},
  year={2023},
  abstract={The evolving battlespace has underscored a critical need for de-risked energy supply lines, which warrant innovation in energy demand, fuel production, and contested logistics. Toward the latter end, we introduce COLOGEN (COntested LOGistics ENgine), a library for synthesizing information about the global contestedness landscape and solving constrained routing problems using graph algorithms, and FuelSim, an agent-based simulation application for analyzing fuel-constrained operations and alternative fuel paradigms.  Our integration of these software components provides a robust framework for modeling and simulation of contested maritime logistics, where increased attention has been paid to the operational feasibility of sustainable fuels. We illustrate the coherence of our framework via example, focusing on naval exercises in the Pacific.},
  abbr={MORSS},
  html = {https://www.mors.org/Events/Symposium/91st-Symposium},
}

@article{mccabe2022darpa,
  title= {Network Contagion Source Localization},
  author = {McCabe, L. H.},
  year = {2022},
  journal = {DARPA Forward},
  abbr = {DARPA},
  html = {https://forward.darpa.mil/risers},
  abstract={Core objective: estimate the origin of information in digital media, but this task is limited by complexity at scale. “Information spread” (broadly defined) can be modeled as diffusion processes on graphs: search for the ``patient(s) zero'' of an epidemic, whether natural contagion or biological weapon, estimate origin of information propagating across digital media or cyber networks, and compare the likelihood of hypotheses about malware in computer networks generated by IC analysts. Standard setup: undirected ``substrate graph‘’ "G=(V, E)"  and a source set S⊆V representing the originator(s) of stochastic diffusion and estimate S from some information about the state of the diffusion process at an arbitrary time (e.g. “snapshot” observation).}
}

@article{brown2022mors,
  title={Modeling the Operational Feasibility of Synfuel from Seawater},
  author={Brown, S. and Horio, B. and Anderson, M. and Whittle, S. and McCabe, L. H. and Johnson, C. and Funk, S.},
  journal={MORS 90th Symposium},
  year={2022},
  abstract={A critical factor for deterrence is the ability to resupply our forces to maintain extended physical presence and to support sustained military operations. Given continued National interest in the Pacific, future marine and aviation fuel generated from alternative sources such as seawater, is a potential game changer for naval replenishment logistics. In addition to the engineering challenges for making this technology a reality, the impact on logistics and operations must be fully understood. In this talk, we discuss how modeling and simulation may be used to support feasibility studies of sustainable aviation fuel.},
  abbr={MORSS},
  html = {https://www.mors.org/Events/Symposium/90th-Symposium},
}

@article{mccabe2021neurips,
  title={URChIn and Variants (Unsupervised Representations for Chess Inference)},
  author={McCabe, L. H.},
  journal={Neural Information Processing Systems},
  year={2021},
  abstract={We compare several variations of our core Reconnaissance Blind Chess algorithm, which employs a language model to estimate a plausible state distribution, rather than sampling uniformly over the true state space. We provide experimental evidence that this approach enables multi-hypothesis tracking agents to employ more optimistic action decision rules.},
  abbr={NeurIPS}
}

@article{mccabe2021smc,
  title={Geodesic and Neural Features for Link Prediction in the COVID-19 Biomedical Knowledge Graph},
  author={McCabe, L. H.},
  journal={Smoky Mountains Computational Sciences & Engineering Conference},
  year={2021},
  abstract={Motivated by Challenge 2 of the 5th Annual Smoky Mountains Computational Sciences Data Challenge, we analyze the COVID-19 biomedical knowledge graph. After computing geodesic statistics for all nodes in the network, we present several machine learning pipelines for automated hypothesis generation. Our most performant approach achieves classification results comparable to the state-of-the-art on thematically similar link prediction benchmarks. Relevant source code and data is available in our public GitHub repository, described in Section 5.},
  abbr={SMC},
  pdf={https://nbviewer.org/github/lucasmccabe/covid19-link-prediction/blob/main/paper/smcdc2021%20-%20LMcCabe.pdf},
  poster={https://nbviewer.org/github/lucasmccabe/covid19-link-prediction/blob/main/paper/smcdc2021_poster%20-%20LMcCabe.pdf},
  code={https://github.com/lucasmccabe/covid19-link-prediction},
}

@article{networks2021,
  title= {Preferential Attachment Estimation and Node Immunization Along Random Walks},
  author = {McCabe, L. H. and Woolf, T. B.},
  year = {2021},
  journal= {Networks 2021},
  abstract={The ongoing pandemic has inevitably hastened interest in network epidemiology, resource allocation, and intervention modeling. Perspectives on graph inference and node immunization may be particularly relevant, as municipalities consider appropriate strategies for vaccine distribution, but much of the pertinent literature relies on either complete knowledge of a network's structure or inference via snapshot. Herein we consider a node immunization task whereby network topology is revealed and immunization decisions are made by agent exploration along a finite-length unbiased random walk. For the purposes of this submission, we focus on scale-free graphs.},
  html = {https://drive.google.com/file/d/1gNxVAMD56kfvzehowjw6b0irKUOlM51o/view},
  abbr={Networks}
}

@article{accenture2021,
  title= {Markov Decision Processes for Node Immunization with Imperfect Information},
  author = {McCabe, L. H.},
  year = {2020},
  journal= {Accenture Federal Services},
  abstract={The ongoing COVID-19 pandemic has prompted critical discussion about effective resource allocation strategies, for which perspectives on graph node immunization may inform solutions. One potential limitation, however, is frequent reliance on complete knowledge of a graph's structure, often derived from anonymized surveillance, demographic data, or assumption. While these approaches provide an essential framework for understanding contagion dynamics and vaccination strategies, complete network information is not always reliable or available in practical situations. We consider the challenge of node immunization where information regarding network topology is realized only through agent exploration along a random walk. We formulate this as a Markov decision process problem and derive heuristic-based policies for scale-free and uncorrelated networks. We demonstrate empirical evidence that these policies achieve their objectives near-optimally and provide a policy-of-policies framework for situations where information about network family does not exist. We also introduce our open-source contagion package and use it to illustrate immunization policy performance with network contagion simulations.},
  abbr={Accenture},
}


text:
package bot

import (
	"fmt"
	"path/filepath"
	"sync"
	"time"
)

var pluginsRunning struct {
	count int
	sync.WaitGroup
	paused       bool
	shuttingDown bool
	sync.Mutex
}

// var pluginsRunning.count int
// var pluginsRunning.shuttingDown = false
// var paused = false // For Windows service pause support

// the shutdownMutex protects both the pluginsRunning.count and the pluginsRunning.shuttingDown
// flag
// var shutdownMutex sync.Mutex
// var plugRunningWaitGroup sync.WaitGroup

const keepListeningDuration = 77 * time.Second

// pluginAvailable checks the user and channel against the plugin's
// configuration to determine if the message should be evaluated. Used by
// both handleMessage and the help builtin.
func pluginAvailable(user, channel string, plugin *Plugin) bool {
	directMsg := false
	if len(channel) == 0 {
		directMsg = true
	}
	if !directMsg && plugin.DirectOnly {
		return false
	}
	if directMsg && plugin.DenyDirect {
		return false
	}
	if plugin.DirectOnly && plugin.DenyDirect {
		Log(Error, fmt.Sprintf("Plugin %s has conflicting DirectOnly and DenyDirect both true", plugin.name))
		return false
	}
	if plugin.RequireAdmin {
		isAdmin := false
		robot.RLock()
		for _, adminUser := range robot.adminUsers {
			if user == adminUser {
				isAdmin = true
				break
			}
		}
		robot.RUnlock()
		if !isAdmin {
			return false
		}
	}
	if len(plugin.Users) > 0 {
		userOk := false
		for _, allowedUser := range plugin.Users {
			match, err := filepath.Match(allowedUser, user)
			if match && err == nil {
				userOk = true
			}
		}
		if !userOk {
			return false
		}
	}
	if directMsg && (plugin.AllowDirect || plugin.DirectOnly) {
		return true
	}
	if len(plugin.Channels) > 0 {
		for _, pchannel := range plugin.Channels {
			if pchannel == channel {
				return true
			}
		}
	} else {
		if plugin.AllChannels {
			return true
		}
	}
	return false
}

// checkPluginMatchersAndRun checks either command matchers (for messages directed at
// the robot), or message matchers (for ambient commands that need not be
// directed at the robot), and calls the plugin if it matches. Note: this
// function is called under a read lock on the 'b' struct.
func checkPluginMatchersAndRun(checkCommands bool, bot *Robot, messagetext string) (commandMatched bool) {
	// un-needed, but more clear
	commandMatched = false
	currentPlugins.RLock()
	plugins := currentPlugins.p
	currentPlugins.RUnlock()
	var runPlugin *Plugin
	var matchedMatcher InputMatcher
	var cmdArgs []string
	for _, plugin := range plugins {
		Log(Trace, fmt.Sprintf("Checking availability of plugin \"%s\" in channel \"%s\" for user \"%s\", active in %d channels (allchannels: %t)", plugin.name, bot.Channel, bot.User, len(plugin.Channels), plugin.AllChannels))
		ok := pluginAvailable(bot.User, bot.Channel, plugin)
		if !ok {
			Log(Trace, fmt.Sprintf("Plugin \"%s\" not available for user \"%s\" in channel \"%s\", doesn't meet criteria", plugin.name, bot.User, bot.Channel))
			continue
		}
		Log(Trace, fmt.Sprintf("Plugin \"%s\" is active, will check for matches", plugin.name))
		var matchers []InputMatcher
		if checkCommands {
			matchers = plugin.CommandMatchers
		} else {
			matchers = plugin.MessageMatchers
		}
		for _, matcher := range matchers {
			Log(Trace, fmt.Sprintf("Checking \"%s\" against \"%s\"", messagetext, matcher.Regex))
			matches := matcher.re.FindAllStringSubmatch(messagetext, -1)
			var matched bool
			if matches != nil {
				matched = true
				Log(Trace, fmt.Sprintf("Message \"%s\" matches command \"%s\"", messagetext, matcher.Command))
				cmdArgs = matches[0][1:]
				if len(matcher.Contexts) > 0 {
					// Resolve & store "it" with short-term memories
					ts := time.Now()
					shortTermMemories.Lock()
					for i, contextLabel := range matcher.Contexts {
						if contextLabel != "" {
							key := "context:" + contextLabel
							c := memoryContext{key, bot.User, bot.Channel}
							if len(cmdArgs) > i && (cmdArgs[i] == "it" || cmdArgs[i] == "") {
								s, ok := shortTermMemories.m[c]
								if ok {
									cmdArgs[i] = s.memory
									// TODO: it would probably be best to substitute the value
									// from "it" back in to the original message and re-check for
									// a match. Failing a match, matched should be set to false.
									s.timestamp = ts
									shortTermMemories.m[c] = s
								} else {
									bot.Say(fmt.Sprintf("Sorry, I don't remember which %s we were talking about - please re-enter your command and be more specific", contextLabel))
									shortTermMemories.Unlock()
									return true
								}
							} else {
								s := shortTermMemory{cmdArgs[i], ts}
								shortTermMemories.m[c] = s
							}
						}
					}
					shortTermMemories.Unlock()
				}
			}
			if matched {
				if commandMatched {
					Log(Error, fmt.Sprintf("Message \"%s\" matched multiple plugins: %s and %s", messagetext, runPlugin.name, plugin.name))
					bot.Say("Yikes! Your command matched multiple plugins, so I'm not doing ANYTHING")
					return
				}
				commandMatched = true
				runPlugin = plugin
				matchedMatcher = matcher
				break
			}
		} // end of matcher checking
	} // end of plugin checking
	if commandMatched {
		plugin := runPlugin
		matcher := matchedMatcher
		abort := false
		if plugin.name == "builtInadmin" && matcher.Command == "abort" {
			abort = true
		}
		pluginsRunning.Lock()
		if pluginsRunning.shuttingDown && !abort {
			bot.Say("Sorry, I'm shutting down and can't start any new tasks")
			pluginsRunning.Unlock()
			return
		} else if pluginsRunning.paused && !abort {
			bot.Say("Sorry, I've been paused and can't start any new tasks")
			pluginsRunning.Unlock()
			return
		}
		pluginsRunning.Unlock()
		// Check to see if user issued a new command when a reply was being
		// waited on
		replyMatcher := replyMatcher{bot.User, bot.Channel}
		replies.Lock()
		waiters, waitingForReply := replies.m[replyMatcher]
		if waitingForReply {
			delete(replies.m, replyMatcher)
			replies.Unlock()
			for i, rep := range waiters {
				if i == 0 {
					rep.replyChannel <- reply{false, replyInterrupted, ""}
				} else {
					rep.replyChannel <- reply{false, retryPrompt, ""}
				}
			}
			Log(Debug, fmt.Sprintf("User \"%s\" matched a new command while the robot was waiting for a reply in channel \"%s\"", bot.User, bot.Channel))
		} else {
			replies.Unlock()
		}
		if bot.checkAuthorization(plugins, plugin, matcher.Command, cmdArgs...) != Success {
			return
		}
		if bot.checkElevation(plugins, plugin, matcher.Command) != Success {
			return
		}
		go callPlugin(bot, plugin, true, true, matcher.Command, cmdArgs...)
	}
	return
}

// handleMessage checks the message against plugin commands and full-message matches,
// then dispatches it to all applicable handlers in a separate go routine. If the robot
// was addressed directly but nothing matched, any registered CatchAll plugins are called.
// There Should Be Only One (catchall, in theory (?))
func handleMessage(isCommand bool, channel, user, messagetext string) {
	bot := &Robot{
		User:    user,
		Channel: channel,
		Format:  Variable,
	}
	defer checkPanic(bot, messagetext)
	currentPlugins.RLock()
	plugins := currentPlugins.p
	currentPlugins.RUnlock()
	if len(channel) == 0 {
		Log(Trace, fmt.Sprintf("Bot received a direct message from %s: %s", user, messagetext))
	}
	commandMatched := false
	var catchAllPlugins []*Plugin
	ts := time.Now()
	lastMsgContext := memoryContext{"lastMsg", user, channel}
	var last shortTermMemory
	var ok bool
	// See if the robot got a blank message, indicating that the last message
	// was meant for it (if it was in the keepListeningDuration)
	if isCommand && messagetext == "" {
		shortTermMemories.Lock()
		last, ok = shortTermMemories.m[lastMsgContext]
		shortTermMemories.Unlock()
		if ok && ts.Sub(last.timestamp) < keepListeningDuration {
			messagetext = last.memory
			commandMatched = checkPluginMatchersAndRun(true, bot, messagetext)
		} else {
			commandMatched = true
			bot.Say("Yes?")
		}
	}
	if !commandMatched && isCommand {
		catchAllPlugins = make([]*Plugin, 0, len(plugins))
		for _, plugin := range plugins {
			if plugin.CatchAll {
				catchAllPlugins = append(catchAllPlugins, plugin)
			}
		}
		// See if a command matches (and runs)
		commandMatched = checkPluginMatchersAndRun(true, bot, messagetext)
	}
	// See if the robot was waiting on a reply
	var waiters []replyWaiter
	waitingForReply := false
	if !commandMatched {
		matcher := replyMatcher{user, channel}
		Log(Trace, fmt.Sprintf("Checking replies for matcher: %q", matcher))
		replies.Lock()
		waiters, waitingForReply = replies.m[matcher]
		if !waitingForReply {
			replies.Unlock()
			// Log(Trace, "No matching replyWaiter")
		} else {
			delete(replies.m, matcher)
			replies.Unlock()
			// if the robot was waiting on a reply, we don't want to check for
			// ambient message matches - the plugin will handle it.
			commandMatched = true
			for i, rep := range waiters {
				if i == 0 {
					matched := rep.re.MatchString(messagetext)
					Log(Debug, fmt.Sprintf("Found replyWaiter for user \"%s\" in channel \"%s\", checking if message \"%s\" matches \"%s\": %t", user, channel, messagetext, rep.re.String(), matched))
					rep.replyChannel <- reply{matched, replied, messagetext}
				} else {
					Log(Debug, "Sending retry to next reply waiter")
					rep.replyChannel <- reply{false, retryPrompt, ""}
				}
			}
		}
	}
	// Direct commands were checked above; if a direct command didn't match,
	// and a there wasn't a reply being waited on, then we check ambient
	// MessageMatchers if it wasn't a direct command. Note that ambient
	// commands never match in a DM.
	if !commandMatched && !waitingForReply && !isCommand {
		// check for ambient message matches
		commandMatched = checkPluginMatchersAndRun(false, bot, messagetext)
	}
	if isCommand && !commandMatched { // the robot was spoken too, but nothing matched - call catchAlls
		pluginsRunning.Lock()
		if !pluginsRunning.shuttingDown {
			pluginsRunning.Unlock()
			Log(Debug, fmt.Sprintf("Unmatched command sent to robot, calling catchalls: %s", messagetext))
			for _, plugin := range catchAllPlugins {
				go callPlugin(bot, plugin, true, true, "catchall", messagetext)
			}
		} else {
			// If the robot is shutting down, just ignore catch-all plugins
			pluginsRunning.Unlock()
		}
	}
	if commandMatched || isCommand {
		shortTermMemories.Lock()
		delete(shortTermMemories.m, lastMsgContext)
		shortTermMemories.Unlock()
	} else {
		last = shortTermMemory{messagetext, ts}
		shortTermMemories.Lock()
		shortTermMemories.m[lastMsgContext] = last
		shortTermMemories.Unlock()
	}
}

license: MIT

repository: daachi/gopherbot

license_type: permissive

repo_name: daachi/gopherbot

branch_name: refs/heads/master

extension: go


text:
@Article{Trifonov2012,
  author   = {P. Trifonov},
  title    = {Efficient Design and Decoding of Polar Codes},
  journal  = {IEEE Transactions on Communications (TCOM)},
  year     = {2012},
  volume   = {60},
  number   = {11},
  pages    = {3221--3227},
  month    = nov,
  issn     = {0090-6778},
  abstract = {Polar codes are shown to be instances of both generalized concatenated codes and multilevel codes. It is shown that the performance of a polar code can be improved by representing it as a multilevel code and applying the multistage decoding algorithm with maximum likelihood decoding of outer codes. Additional performance improvement is obtained by replacing polar outer codes with other ones with better error correction performance. In some cases this also results in complexity reduction. It is shown that Gaussian approximation for density evolution enables one to accurately predict the performance of polar codes and concatenated codes based on them.},
  doi      = {10.1109/TCOMM.2012.081512.110872},
  file     = {:pdf/Trifonov2012 - Efficient Design and Decoding of Polar Codes.pdf:PDF},
  groups   = {Polar Codes},
  keywords = {Gaussian processes, concatenated codes, design, maximum likelihood decoding, Gaussian approximation, concatenated codes, density evolution, design, maximum likelihood decoding, multilevel codes, multistage decoding algorithm, polar codes, Approximation algorithms, Concatenated codes, Constellation diagram, Error probability, Maximum likelihood decoding, Vectors, Polar codes, concatenated codes, multilevel codes},
}

@Article{Tal2013,
  author   = {I. Tal and A. Vardy},
  title    = {How to Construct Polar Codes},
  journal  = {IEEE Transactions on Information Theory (TIT)},
  year     = {2013},
  volume   = {59},
  number   = {10},
  pages    = {6562--6582},
  month    = oct,
  issn     = {0018-9448},
  abstract = {A method for efficiently constructing polar codes is presented and analyzed. Although polar codes are explicitly defined, straightforward construction is intractable since the resulting polar bit-channels have an output alphabet that grows exponentially with the code length. Thus, the core problem that needs to be solved is that of faithfully approximating a bit-channel with an intractably large alphabet by another channel having a manageable alphabet size. We devise two approximation methods which {\textquotedblleft}sandwich{\textquotedblright} the original bit-channel between a degraded and an upgraded version thereof. Both approximations can be efficiently computed and turn out to be extremely close in practice. We also provide theoretical analysis of our construction algorithms, proving that for any fixed $\epsilon$ $>$ 0 and all sufficiently large code lengths n, polar codes whose rate is within $\epsilon$ of channel capacity can be constructed in time and space that are both linear in n.},
  doi      = {10.1109/TIT.2013.2272694},
  file     = {:pdf/Tal2013 - How to Construct Polar Codes.pdf:PDF},
  groups   = {Polar Codes},
  keywords = {approximation theory, codes, alphabet size, approximation methods, channel capacity, construction algorithms, polar bit-channels, polar codes, Approximation algorithms, Approximation methods, Complexity theory, Convolutional codes, Decoding, Kernel, Quantization (signal), Channel degrading and upgrading, channel polarization, construction algorithms, polar codes},
}

@misc{3GPP2017,
  title       = {{TS} 38.212, {Multiplexing} and {Channel} {Coding} ({Release} 15)},
  author      = {{3GPP}},
  url         = {http://www.3gpp.org/ftp//Specs/archive/38_series/38.212/},
}

gha_license_id: MIT

extension: bib


text:
@article{Richardson:2015aa,
 abstract = {OBJECTIVES: We estimated trends in drug poisoning death rates by educational attainment and investigated educational inequalities in drug poisoning mortality by race, gender, and region.
METHODS: We linked drug poisoning death counts from the National Vital Statistics System to population denominators from the Current Population Survey to estimate drug poisoning rates by gender, race, region, and educational attainment (less than high school degree, high school degree, some college, college degree) from 1994 to 2010.
RESULTS: There were 372,485 drug poisoning deaths. Education-related inequalities increased during the study among all demographic groups and varied by region. Absolute increases in educational inequalities were higher among Whites than Blacks and men than women. The age-adjusted rate difference between White men with less than a high school degree increased from 8.7 per 100,000 in 1994 to 27.4 in 2010 (change = 18.7). Among Black men, the corresponding increases were 11.7 and 18.3, respectively (change = 6.6).
CONCLUSIONS: We found strong educational patterning in drug poisoning rates, chiefly by region and race. Rates are highest and increasing the fastest among groups with less education.},
 author = {Richardson, Robin and Charters, Thomas and King, Nicholas and Harper, Sam},
 bdsk-url-1 = {https://doi.org/10.2105/AJPH.2015.302697},
 date-added = {2020-09-24 17:40:15 -0400},
 date-modified = {2020-09-24 17:40:15 -0400},
 doi = {10.2105/AJPH.2015.302697},
 journal = {Am J Public Health},
 journal-full = {American journal of public health},
 mesh = {Adult; Aged; Continental Population Groups; Educational Status; Female; Humans; Male; Middle Aged; Poisoning; United States},
 month = {Sep},
 number = {9},
 pages = {1859-65},
 pmc = {PMC4539807},
 pmid = {26180981},
 pst = {ppublish},
 title = {Trends in Educational Inequalities in Drug Poisoning Mortality: United States, 1994-2010},
 volume = {105},
 year = {2015}
}


text:
# this recipe was borrowed from meta-tensorflow
# it was originally written by Hongxu Jia <jiahongxujia@163.com> | <hongxu.jia@windriver.com>
# the original version can be found at:
# http://git.yoctoproject.org/cgit/cgit.cgi/meta-tensorflow/tree/recipes-devtools/bazel/bazel-native_0.21.0.bb

DESCRIPTION = "Bazel build and test tool"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"

SRC_URI[md5sum] = "8c8240b178a35c0f3c1bc03017550270"
SRC_URI[sha256sum] = "6ccb831e683179e0cfb351cb11ea297b4db48f9eab987601c038aa0f83037db4"

SRC_URI = "https://github.com/bazelbuild/bazel/releases/download/${PV}/bazel-${PV}-dist.zip \
           file://0001-HttpDownloader-save-download-tarball-to-distdir.patch \
"

inherit native

INHIBIT_SYSROOT_STRIP = "1"

DEPENDS = "coreutils-native \
           zip-native \
           openjdk-8-native \
          "

S="${WORKDIR}"

TS_DL_DIR ??= "${DL_DIR}"
do_compile () {
    export JAVA_HOME="${STAGING_LIBDIR_NATIVE}/jvm/openjdk-8-native"
    TMPDIR="${TOPDIR}/bazel" \
    VERBOSE=yes \
    EXTRA_BAZEL_ARGS="--distdir=${TS_DL_DIR}" \
    ./compile.sh
}

do_install () {
    install -d ${D}${bindir}
    install -m 0755 ${S}/output/bazel ${D}${bindir}
}

# Explicitly disable uninative
UNINATIVE_LOADER = ""

repository: muffcrusher/meta-iota

repo_name: muffcrusher/meta-iota

extension: bb


text:
require xorg-app-common.inc
DEPENDS += " libxfont libfs libfontenc"
PE = "1"
PR = "${INC_PR}.0"

SRC_URI[archive.md5sum] = "d5d560ea77541591d2a6656991286457"
SRC_URI[archive.sha256sum] = "7fbadfa5cb38f7d754214b792854c4a0cb32fd1c9b5ae8ff05434cb3b3acbe01"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD


text:
@proceedings{emnlp-2019-multilingual,
    title = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    editor = "Mille, Simon  and
      Belz, Anja  and
      Bohnet, Bernd  and
      Graham, Yvette  and
      Wanner, Leo",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6300",
}
@inproceedings{mille-etal-2019-second,
    title = "The Second Multilingual Surface Realisation Shared Task ({SR}{'}19): Overview and Evaluation Results",
    author = "Mille, Simon  and
      Belz, Anja  and
      Bohnet, Bernd  and
      Graham, Yvette  and
      Wanner, Leo",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6301",
    doi = "10.18653/v1/D19-6301",
    pages = "1--17",
}
@inproceedings{du-black-2019-learning,
    title = "Learning to Order Graph Elements with Application to Multilingual Surface Realization",
    author = "Du, Wenchao  and
      Black, Alan W",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6302",
    doi = "10.18653/v1/D19-6302",
    pages = "18--24",
}
@inproceedings{dyer-2019-depdist,
    title = "{D}ep{D}ist: Surface realization via regex and learned dependency-distance tolerance",
    author = "Dyer, William",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6303",
    doi = "10.18653/v1/D19-6303",
    pages = "25--34",
}
@inproceedings{kovacs-etal-2019-bme,
    title = "{BME}-{UW} at {SRST}-2019: Surface realization with Interpreted Regular Tree Grammars",
    author = "Kov{\'a}cs, {\'A}d{\'a}m  and
      {\'A}cs, Evelin  and
      {\'A}cs, Judit  and
      Kornai, Andras  and
      Recski, G{\'a}bor",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6304",
    doi = "10.18653/v1/D19-6304",
    pages = "35--40",
}
@inproceedings{lapalme-2019-realizing,
    title = "Realizing Universal Dependencies Structures",
    author = "Lapalme, Guy",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6305",
    doi = "10.18653/v1/D19-6305",
    pages = "41--49",
}
@inproceedings{yu-etal-2019-imsurreal,
    title = "{IMS}ur{R}eal: {IMS} at the Surface Realization Shared Task 2019",
    author = "Yu, Xiang  and
      Falenska, Agnieszka  and
      Haid, Marina  and
      Vu, Ngoc Thang  and
      Kuhn, Jonas",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6306",
    doi = "10.18653/v1/D19-6306",
    pages = "50--58",
}
@inproceedings{castro-ferreira-krahmer-2019-surface,
    title = "Surface Realization Shared Task 2019 ({MSR}19): The Team 6 Approach",
    author = "Castro Ferreira, Thiago  and
      Krahmer, Emiel",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6307",
    doi = "10.18653/v1/D19-6307",
    pages = "59--62",
}
@inproceedings{farahnak-etal-2019-concordia,
    title = "The Concordia {NLG} Surface Realizer at {SRST} 2019",
    author = "Farahnak, Farhood  and
      Rafiee, Laya  and
      Kosseim, Leila  and
      Fevens, Thomas",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6308",
    doi = "10.18653/v1/D19-6308",
    pages = "63--67",
}
@inproceedings{upasani-etal-2019-osu,
    title = "The {OSU}/{F}acebook Realizer for {SRST} 2019: {S}eq2{S}eq Inflection and Serialized {T}ree2{T}ree Linearization",
    author = "Upasani, Kartikeya  and
      King, David  and
      Rao, Jinfeng  and
      Balakrishnan, Anusha  and
      White, Michael",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6309",
    doi = "10.18653/v1/D19-6309",
    pages = "68--74",
}
@inproceedings{hong-etal-2019-improving,
    title = "Improving Language Generation from Feature-Rich Tree-Structured Data with Relational Graph Convolutional Encoders",
    author = "Hong, Xudong  and
      Chang, Ernie  and
      Demberg, Vera",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6310",
    doi = "10.18653/v1/D19-6310",
    pages = "75--80",
}
@inproceedings{mazzei-basile-2019-dipinfounito,
    title = "The {D}ip{I}nfo{U}ni{T}o Realizer at {SRST}{'}19: Learning to Rank and Deep Morphology Prediction for Multilingual Surface Realization",
    author = "Mazzei, Alessandro  and
      Basile, Valerio",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6311",
    doi = "10.18653/v1/D19-6311",
    pages = "81--87",
}
@inproceedings{shimorina-gardent-2019-loria,
    title = "{LORIA} / Lorraine University at Multilingual Surface Realisation 2019",
    author = "Shimorina, Anastasia  and
      Gardent, Claire",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6312",
    doi = "10.18653/v1/D19-6312",
    pages = "88--93",
}
@inproceedings{sobrevilla-cabezudo-etal-2019-back,
    title = "Back-Translation as Strategy to Tackle the Lack of Corpus in Natural Language Generation from Semantic Representations",
    author = "Sobrevilla Cabezudo, Marco Antonio  and
      Mille, Simon  and
      Pardo, Thiago",
    booktitle = "Proceedings of the 2nd Workshop on Multilingual Surface Realisation (MSR 2019)",
    month = nov,
    year = "2019",
    address = "Hong Kong, China",
    publisher = "Association for Computational Linguistics",
    url = "https://www.aclweb.org/anthology/D19-6313",
    doi = "10.18653/v1/D19-6313",
    pages = "94--103",
}

repository: emorynlp/nlprankings

repo_name: emorynlp/nlprankings

gha_license_id: NOASSERTION

gha_language: TeX


text:
# generated from genmsg/cmake/pkg-msg-paths.cmake.develspace.in

set(custommsg_MSG_INCLUDE_DIRS "/home/arijitnoobstar/Flapping-Wing-MAV/src/custommsg/msg")
set(custommsg_MSG_DEPENDENCIES std_msgs;geometry_msgs)

branch_name: refs/heads/main

extension: cmake


text:
require recipes-bsp/trusted-firmware-m/trusted-firmware-m-1.7.0-src.inc
require recipes-bsp/trusted-firmware-m/trusted-firmware-m-scripts-native.inc

repository: Nuvoton-Israel/openbmc

repo_name: Nuvoton-Israel/openbmc

branch_name: refs/heads/npcm-master

gha_language: Python


text:
@misc{Source,
  Title                    = {Thesis example - hosted on GitHub},
  note                     = {(\url{https://github.com/GPMueller/mwe-tex})}
}

license: Unlicense

repository: GPMueller/mwe-tex

repo_name: GPMueller/mwe-tex


text:
package main

import "github.com/golang/glog"

// MaxPriority means highest score which node can get
const MaxPriority = 10

func balancedResourceScore(requested, allocatable ResourceUsage) float64 {
	cFraction := fractionOfCapacity(requested.CPU, allocatable.CPU)
	mFraction := fractionOfCapacity(requested.Memory, allocatable.Memory)
	pFraction := fractionOfCapacity(requested.Pod, allocatable.Pod)

	if cFraction >= 1 || mFraction >= 1 || pFraction >= 1 {
		return 0
	}

	return getBalancedResourceScore(cFraction, mFraction, pFraction)
}

func leastRequestedScore(requested, allocatable ResourceUsage) float64 {
	cRatio := getLeastRequestedScore(requested.CPU, allocatable.CPU)
	mRatio := getLeastRequestedScore(requested.Memory, allocatable.Memory)
	pRatio := getLeastRequestedScore(requested.Pod, allocatable.Pod)

	return (cRatio + mRatio + pRatio) / 3
}

func priorities(pod *Pod, nodes []*Node) (*Node, error) {

	var bestNode *Node
	nodeScore := make(map[*Node]float64)

	// 获取所有节点
	nodeList, err := getNodes()
	if err != nil {
		glog.Error("failed to get nodes")
		glog.Fatal(err)
	}

	// 获取所有pod
	podList, err := getPods()
	if err != nil {
		glog.Error("failed to get pods")
		glog.Fatal(err)
	}

	requested := requestedResource(pod)
	used := usedResource(nodeList, podList)

	for _, node := range nodeList.Items {
		nodeScore[node] = 0
	}

	for _, node := range nodeList.Items {

		allocatable := allocatableResource(node, used)
		nodeScore[node] += balancedResourceScore(requested, allocatable)
		nodeScore[node] += leastRequestedScore(requested, allocatable)
		nodeScore[node] /= 2
	}

	printNodeScores(nodeScore)

	var maxScore float64
	for node, score := range nodeScore {
		if score > maxScore {
			maxScore = score
			bestNode = node
		}
	}
	return bestNode, nil
}

repository: yinwoods/anchor

repo_name: yinwoods/anchor


text:
@InProceedings{gottlieb16,
  title = {Nearly Optimal Classification for Semimetrics},
  author = {Gottlieb, Lee-Ad and Kontorovich, Aryeh and Nisnevitch, Pinhas},
  pages = {379-388},
  abstract = {We initiate the rigorous study of classification in semimetric spaces, which are point sets with a distance function that is non-negative and symmetric, but need not satisfy the triangle inequality. We define the {\em density dimension} $\dens$ and discover that it plays a central role in the statistical and algorithmic feasibility of learning in semimetric spaces. We compute this quantity for several widely used semimetrics and present nearly optimal sample compression algorithms, which are then used to obtain generalization guarantees, including fast rates.  Our claim of near-optimality holds in both computational and statistical senses. When the sample has radius $R$ and margin $\gamma$, we show that it can be compressed down to roughly $d=(R/\gamma)^{\dens}$ points, and further that finding a significantly better compression is algorithmically intractable unless P=NP. This compression implies generalization via standard Occam-type arguments, to which we provide a nearly matching lower bound.},
}

repository: mreid/papersite

repo_name: mreid/papersite


text:
require wesnoth.inc

RCONFLICTS_${PN} = "wesnoth"

PR = "${INC_PR}.1"

SRC_URI[md5sum] = "2dce83f835ecce1d505ea60e46b7356f"
SRC_URI[sha256sum] = "af29ddf40f83ee016972d6edb8761d7323f8ed5d6bf15005659bff4fd7190eb9"


text:
@article{arora2018small,
  title={Small-variance asymptotics for nonparametric Bayesian overlapping stochastic blockmodels},
  author={Arora, Gundeep and Porwal, Anupreet and Agarwal, Kanupriya and Samdariya, Avani and Rai, Piyush},
  journal={arXiv preprint arXiv:1807.03570},
  year={2018}
}

repository: Anupreet-Porwal/academic-kickstart

repo_name: Anupreet-Porwal/academic-kickstart


text:
package domain

type CreateIssueError struct {
	Msg string
}

func (e *CreateIssueError) Error() string {
	return "Issueの作成に失敗しました。"
}

gha_language: Go


text:
package main

import (
	"fmt"
	"math"
	//"math/bits"
	"sort"
	"strconv"
)

func smallestGoodBase1(n string) string {
	m, _ := strconv.Atoi(n)
	for k := 2; k < m; k++ {
		base, sum := 1, 0
		for {
			sum += base
			base *= k

			if sum == m {
				return strconv.Itoa(k)
			} else if sum > m {
				break
			}
		}
	}
	return ""
}

func smallestGoodBase2(n string) string {
	m, _ := strconv.Atoi(n)
	for k := 2; k < m; k++ {
		a := (m-1)*(k-1) + k
		for a >= k {
			if a == k {
				return strconv.Itoa(k)
			}

			if a%k == 0 {
				a /= k
			} else {
				break
			}
		}
	}
	return ""
}

func smallestGoodBase(n string) string {
	num, _ := strconv.ParseUint(n, 10, 64)
	for bit := uint64(math.Log2(float64(num))); bit >= 1; bit-- {
		low, high := uint64(2), uint64(math.Pow(float64(num), 1.0/float64(bit)))
		for low <= high {
			fmt.Println(low, high, bit)
			mid := uint64(low + (high-low)>>1)
			sum := findBase(mid, bit)
			if sum == num {
				return strconv.FormatUint(mid, 10)
			} else if sum > num {
				high = mid - 1
			} else {
				low = mid + 1
			}
		}
	}
	return strconv.FormatUint(num-1, 10)
}

func findBase(mid, bit uint64) uint64 {
	sum, base := uint64(1), uint64(1)
	for i := uint64(1); i <= bit; i++ {
		base *= mid
		sum += base
	}
	return sum
}

func hammingWeight1(num uint32) int {
	var n int
	for num > 0 {
		if num&1 == 1 {
			n++
		}
		num >>= 1
	}
	return n
}

func hammingWeight2(num uint32) int {
	mask, n := uint32(1), 0
	for i := 0; i < 32; i++ {
		if num&mask != 0 {
			n++
		}
		mask <<= 1
	}
	return n
}

func hammingWeight3(num uint32) int {
	n := 0
	for num > 0 {
		n++
		num &= (num - 1)
	}
	return n
}

func isPowerOfTwo(n int) bool {
	if n <= 0 {
		return false
	}
	return n&(n-1) == 0
}

func isPowerOfTwo2(n int) bool {
	if n <= 0 {
		return false
	}
	return n&(-n) == n
}

func isPowerOfTwo3(n int) bool {
	if n <= 0 {
		return false
	}
	return (1024*1024*1024)%n == 0
}

func findDisappearedNumbers1(nums []int) []int {
	var ns []int
	for i := 0; i < len(nums); i++ {
		if nums[i] != i+1 {
			find := false
			for j := 0; j < len(nums); j++ {
				if nums[j] == i+1 {
					nums[i], nums[j] = nums[j], nums[i]
					find = true
					break
				}
			}

			if !find {
				ns = append(ns, i+1)
			}
		}
	}

	return ns
}

func findDisappearedNumbers2(nums []int) []int {
	sort.Slice(nums, func(i, j int) bool {
		return nums[i] < nums[j]
	})

	var ns []int
	i := 1
	for _, n := range nums {
		if n == i {
			i++
			continue
		} else if n > i {
			for j := i; j < n; j++ {
				ns = append(ns, j)
			}
			i = n + 1
		}
	}

	for j := i; j <= len(nums); j++ {
		ns = append(ns, j)
	}

	return ns
}

func findDisappearedNumbers3(nums []int) []int {
	var ns []int
	m := make(map[int]bool)
	for i := 0; i < len(nums); i++ {
		m[nums[i]] = true
	}

	for i := 1; i <= len(nums); i++ {
		if _, ok := m[i]; !ok {
			ns = append(ns, i)
		}
	}

	return ns
}

func findDisappearedNumbers4(nums []int) []int {
	var ns []int
	arr := make([]int, len(nums))
	for i := 0; i < len(nums); i++ {
		arr[nums[i]-1] = nums[i]
	}

	for i := 0; i < len(arr); i++ {
		if arr[i] != i+1 {
			ns = append(ns, i+1)
		}
	}

	return ns
}

func findDisappearedNumbers5(nums []int) []int {
	i := 0
	for i < len(nums) {
		if nums[i] == i+1 {
			i++
			continue
		}

		if nums[i] == nums[nums[i]-1] {
			i++
			continue
		}

		nums[i], nums[nums[i]-1] = nums[nums[i]-1], nums[i]
		fmt.Println(nums)
	}

	var ns []int
	for i := 0; i < len(nums); i++ {
		if nums[i] != i+1 {
			ns = append(ns, i+1)
		}
	}

	return ns
}

func findDisappearedNumbers6(nums []int) []int {
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n < 0 {
			n = -n
		}

		if nums[n-1] > 0 {
			nums[n-1] = -nums[n-1]
		}
	}

	var ns []int
	for i := 0; i < len(nums); i++ {
		if nums[i] > 0 {
			ns = append(ns, i+1)
		}
	}

	return ns
}

func findErrorNums1(nums []int) []int {
	sort.Slice(nums, func(i, j int) bool {
		return nums[i] < nums[j]
	})

	lost, cpy := 0, 0
	for i := 1; i < len(nums); i++ {
		if nums[i] == nums[i-1] {
			cpy = nums[i]
			break
		}
	}

	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n < 0 {
			n = -n
		}

		if nums[n-1] > 0 {
			nums[n-1] = -nums[n-1]
		}
	}

	for i := 0; i < len(nums); i++ {
		if nums[i] > 0 {
			lost = i + 1
			break
		}
	}

	return []int{cpy, lost}
}

func findErrorNums2(nums []int) []int {
	cpy, lost := 0, 0
	for i := 0; i < len(nums); i++ {
		n := nums[i]
		if n < 0 {
			n = -n
		}
		if nums[n-1] > 0 {
			nums[n-1] = -nums[n-1]
		} else {
			cpy = n
		}
	}
	for i := 0; i < len(nums); i++ {
		if nums[i] > 0 {
			lost = i + 1
			break
		}
	}

	return []int{cpy, lost}
}

func findErrorNums(nums []int) []int {
	xor := 0
	for i := 0; i < len(nums); i++ {
		xor = xor ^ nums[i]
		xor = xor ^ (i + 1)
	}
	//rightmostbit := xor & ^(xor - 1)
	rightmostbit := xor & (-xor)

	xor0, xor1 := 0, 0
	for i := 0; i < len(nums); i++ {
		if nums[i]&rightmostbit != 0 {
			xor1 = xor1 ^ nums[i]
		} else {
			xor0 = xor0 ^ nums[i]
		}

		if (i+1)&rightmostbit != 0 {
			xor1 = xor1 ^ (i + 1)
		} else {
			xor0 = xor0 ^ (i + 1)
		}
	}

	for i := 0; i < len(nums); i++ {
		if nums[i] == xor0 {
			return []int{xor0, xor1}
		}
	}
	return []int{xor1, xor0}
}

func multiply(num1 string, num2 string) string {
	if len(num1) < len(num2) {
		num1, num2 = num2, num1
	}

	mul := make([]byte, len(num1)+len(num2))
	res := make([][]byte, len(num2))
	for i := 0; i < len(res); i++ {
		res[i] = make([]byte, len(num1)+len(num2))
	}

	for i := len(num2) - 1; i >= 0; i-- {
		k := len(res[i]) - 1

		for j := 0; j <= k; j++ {
			res[i][j] = '0'
		}

		for j := 0; j < len(num2)-1-i; j++ {
			k--
		}

		m := byte(0)
		b := num2[i] - '0'
		for j := len(num1) - 1; j >= 0; j-- {
			a := num1[j] - '0'
			c := a*b + m

			res[i][k] = c%10 + '0'
			k--
			m = c / 10
		}

		if m != 0 {
			res[i][k] = m + '0'
		}
	}

	/*	for i := 0; i < len(res); i++ {
		fmt.Println(string(res[i]))
	}*/

	sum := 0
	for i := len(num1) + len(num2) - 1; i >= 0; i-- {
		for j := 0; j < len(num2); j++ {
			sum += int(res[j][i] - '0')
		}
		mul[i] = byte(sum%10) + '0'
		sum = sum / 10
	}

	zero := 0
	for zero < len(mul)-1 {
		if mul[zero] != '0' {
			break
		}
		zero++
	}

	return string(mul[zero:])
}

func addStrings(num1 string, num2 string) string {
	if len(num1) < len(num2) {
		num1, num2 = num2, num1
	}
	res := make([]byte, len(num1)+1)

	i, j := len(num1)-1, len(num2)-1
	sum := 0
	for k := len(res) - 1; k >= 0; k-- {
		if i >= 0 {
			sum += int(num1[i] - '0')
			i--
		}
		if j >= 0 {
			sum += int(num2[j] - '0')
			j--
		}
		res[k] = byte(sum%10) + '0'
		sum /= 10
	}

	zero := 0
	for zero < len(res)-1 {
		if res[zero] != '0' {
			break
		}
		zero++
	}
	return string(res[zero:])
}

var memo map[int]int = map[int]int{}

func numSquares1(n int) int {
	if m, ok := memo[n]; ok {
		return m
	}

	fmt.Println(n)

	sq := int(math.Sqrt(float64(n)))
	if sq*sq == n {
		memo[n] = 1
		return 1
	}

	min := math.MaxInt32
	for i := sq; i >= 1; i-- {
		m := 1 + numSquares1(n-i*i)
		if m < min {
			min = m
		}
	}
	memo[n] = min
	return min
}

func numSquares(n int) int {
	m := n
	for m%4 == 0 {
		m /= 4
	}
	if m%8 == 7 {
		return 4
	}

	q := int(math.Sqrt(float64(n)))
	if q*q == n {
		return 1
	}

	for i := 1; i*i <= n; i++ {
		q := int(math.Sqrt(float64(n - i*i)))
		if q*q == n-i*i {
			return 2
		}
	}
	return 3
}

var sum int

func sumNums1(n int) int {
	sum = 0
	_sumNums1(n)
	return sum
}

func _sumNums1(n int) bool {
	sum += n
	return n > 1 && _sumNums1(n-1)
}

func fm1(a, b int) int {
	m := 0
	for i := 0; b>>i > 0; i++ {
		if (b>>i)&1 == 1 {
			m += (a << i)
		}
	}
	return m
}

func fm(a, b int) int {
	m := 0
	for ; b != 0; b >>= 1 {
		if b&1 == 1 {
			m += a
		}
		a <<= 1
	}
	return m
}

func sumNums2(n int) int {
	a := n + 1
	b := n
	m := 0

	var fn func(x, y int) bool
	fn = func(x, y int) bool {
		m += y
		return x&1 == 1 || fn(1, -y)
	}

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)
	b >>= 1
	a <<= 1

	fn(b, a)

	return m >> 1
}

func sumNums(n int) int {
	a := n + 1
	b := n
	m := 0

	fn := func() bool {
		m += a
		return true
	}

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()
	b >>= 1
	a <<= 1

	_ = (b&1 == 1) && fn()

	return m >> 1
}

func countBits1(num int) []int {
	res := make([]int, num+1)
	for i := 0; i <= num; i++ {
		n := 0
		for j := i; j > 0; j >>= 1 {
			if j&1 == 1 {
				n++
			}
		}
		res[i] = n
	}
	return res
}

func countBits2(num int) []int {
	res := make([]int, num+1)
	for i := 0; i <= num; i++ {
		n := 0
		for j := i; j > 0; j &= (j - 1) {
			n++
		}
		res[i] = n
	}
	return res
}

func countBits3(num int) []int {
	res := make([]int, num+1)
	level := 2
	m := 0
	for i := 1; i <= num; i++ {
		if i == level {
			m <<= 1
			m++
			level *= 2
		}

		res[i] = 1 + res[i&m]
	}
	return res
}

func countBits4(num int) []int {
	res := make([]int, num+1)
	m := 1
	for i := 1; i <= num; i++ {
		if i == m*2 {
			m *= 2
		}
		res[i] = 1 + res[i-m]
	}
	return res
}

func countBits5(num int) []int {
	res := make([]int, num+1)
	m := 0
	for i := 1; i <= num; i++ {
		if i&(i-1) == 0 {
			m = i
		}
		res[i] = 1 + res[i-m]
	}
	return res
}

func countBits6(num int) []int {
	res := make([]int, num+1)
	for i := 1; i <= num; i++ {
		res[i] = i&1 + res[i>>1]
	}
	return res
}

func countBits7(num int) []int {
	res := make([]int, num+1)
	for i := 1; i <= num; i++ {
		res[i] = 1 + res[i&(i-1)]
	}
	return res
}

func main() {

}

repository: harveywangdao/earth

repo_name: harveywangdao/earth


text:
@article{reiss2019deep,
  title={Deep ppg: Large-scale heart rate estimation with convolutional neural networks},
  author={Reiss, Attila and Indlekofer, Ina and Schmidt, Philip and Van Laerhoven, Kristof},
  journal={Sensors},
  volume={19},
  number={14},
  pages={3079},
  year={2019},
  publisher={Multidisciplinary Digital Publishing Institute}
}

@article{salehizadeh2016novel,
  title={A novel time-varying spectral filtering algorithm for reconstruction of motion artifact corrupted heart rate signals during intense physical activities using a wearable photoplethysmogram sensor},
  author={Salehizadeh, Seyed and Dao, Duy and Bolkhovsky, Jeffrey and Cho, Chae and Mendelson, Yitzhak and Chon, Ki H},
  journal={Sensors},
  volume={16},
  number={1},
  pages={10},
  year={2016},
  publisher={Multidisciplinary Digital Publishing Institute}
}

@article{brophy2020optimised,
  title={Optimised convolutional neural networks for heart rate estimation and human activity recognition in wrist worn sensing applications},
  author={Brophy, Eoin and Muehlhausen, Willie and Smeaton, Alan F and Ward, Tomas E},
  journal={arXiv preprint arXiv:2004.00505},
  year={2020}
}

@article{biswas2019cornet,
  title={CorNET: Deep learning framework for PPG-based heart rate estimation and biometric identification in ambulant environment},
  author={Biswas, Dwaipayan and Everson, Luke and Liu, Muqing and Panwar, Madhuri and Verhoef, Bram-Ernst and Patki, Shrishail and Kim, Chris H and Acharyya, Amit and Van Hoof, Chris and Konijnenburg, Mario and others},
  journal={IEEE transactions on biomedical circuits and systems},
  volume={13},
  number={2},
  pages={282--291},
  year={2019},
  publisher={IEEE}
}

@article{panwar2020pp,
  title={PP-Net: A Deep Learning Framework for PPG-Based Blood Pressure and Heart Rate Estimation},
  author={Panwar, Madhuri and Gautam, Arvind and Biswas, Dwaipayan and Acharyya, Amit},
  journal={IEEE Sensors Journal},
  volume={20},
  number={17},
  pages={10000--10011},
  year={2020},
  publisher={IEEE}
}

@article{chang2021deepheart,
  title={DeepHeart: A Deep Learning Approach for Accurate Heart Rate Estimation from PPG Signals},
  author={Chang, Xiangmao and Li, Gangkai and Xing, Guoliang and Zhu, Kun and Tu, Linlin},
  journal={ACM Transactions on Sensor Networks (TOSN)},
  volume={17},
  number={2},
  pages={1--18},
  year={2021},
  publisher={ACM New York, NY, USA}
}

@article{biswas2019heart,
  title={Heart rate estimation from wrist-worn photoplethysmography: A review},
  author={Biswas, Dwaipayan and Sim{\~o}es-Capela, Neide and Van Hoof, Chris and Van Helleputte, Nick},
  journal={IEEE Sensors Journal},
  volume={19},
  number={16},
  pages={6560--6570},
  year={2019},
  publisher={IEEE}
}

@article{kingma2014adam,
  title={Adam: A method for stochastic optimization},
  author={Kingma, Diederik P and Ba, Jimmy},
  journal={arXiv preprint arXiv:1412.6980},
  year={2014}
}

@article{lundberg2017unified,
  title={A unified approach to interpreting model predictions},
  author={Lundberg, Scott and Lee, Su-In},
  journal={arXiv preprint arXiv:1705.07874},
  year={2017}
}

repository: denizhankara/PPG-DaLiA

repo_name: denizhankara/PPG-DaLiA

gha_language: Jupyter Notebook


text:
@InProceedings{celikkaya14,
  title = {Deterministic Anytime Inference for Stochastic Continuous-Time Markov Processes},
  author = {E. Busra Celikkaya and Christian Shelton},
  pages = {1962-1970},
  abstract = {We describe a deterministic anytime method for calculating  filtered and smoothed distributions in large variable-based continuous time  Markov processes.  Prior non-random algorithms do not converge to the true  distribution in the limit of infinite computation time.  Sampling  algorithms give different results each time run, which can lead to  instability when used inside expectation-maximization or other algorithms.  Our method combines the anytime convergent properties of sampling with the  non-random nature of variational approaches.  It is built upon a sum of  time-ordered products, an expansion of the matrix exponential.  We  demonstrate that our method performs as well as or better than the current  best sampling approaches on benchmark problems.},
  section = {cycle-2},
}


text:
SECTION = "x11/libs"
include libxdmcp_${PV}.bb
inherit native
DEPENDS = "xproto-native"
PROVIDES = ""

repository: Terentyev/familiar-linux

repo_name: Terentyev/familiar-linux


text:
package main

import (
	"log"
	"os"

	rungo "github.com/yinyin/go-run-go"
)

const rungoCmdUsage = `Argument: [Action] [Options...]

Action:

  * version
  * env
  * list-pkg [PKG_IMPORT_PATH...]
  * list-mod [MOD_IMPORT_PATH...]

`

func main() {
	if len(os.Args) < 2 {
		log.Print(rungoCmdUsage)
		return
	}
	cmdAction := os.Args[1]
	cmdOptions := os.Args[2:]
	log.Printf("Command: action=%v, options=%v", cmdAction, cmdOptions)
	cmdGo := rungo.CommandGo{}
	switch cmdAction {
	case "version":
		runVersion(&cmdGo)
	case "env":
		runEnv(&cmdGo)
	case "list-pkg":
		runListPackage(&cmdGo, cmdOptions...)
	case "list-mod":
		runListModule(&cmdGo, cmdOptions...)
	case "import-depth":
		runImportDepth(&cmdGo, cmdOptions...)
	}
	return
}

repository: yinyin/go-run-go

repo_name: yinyin/go-run-go


text:
package LinkedListWithoutHead

import (
	"fmt"
	"go-implementation/model/LinkedList"
)

//不含头节点的链表
//头插法创建链表
func CreateHead(n int) *LinkedList.Node {
	head := &LinkedList.Node{
		Val:  0,
		Next: nil,
	}
	for i := 1; i < n; i++ {
		temp := &LinkedList.Node{
			Val:  i,
			Next: nil,
		}
		temp.Next = head
		head = temp
	}
	return head
}

//尾插法创建链表
func CreateTail(n int) *LinkedList.Node {
	head := &LinkedList.Node{
		Val:  0,
		Next: nil,
	}
	p := head
	for i := 1; i < n; i++ {
		temp := &LinkedList.Node{
			Val:  i,
			Next: nil,
		}
		p.Next = temp
		p = temp
	}
	return head
}

func ShowList(head *LinkedList.Node, name string) {
	fmt.Printf("%s :\n", name)
	for temp := head; temp != nil; temp = temp.Next {
		fmt.Printf("%d\t", temp.Val)
	}
	fmt.Println()
}


text:
package mysql

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"reflect"
	"strconv"
	"time"
)

var mDb = make(map[string]*sql.DB)

// InitMySQLPool func init DB pool
func InitMysql(DbName, uri string, max, min int) {
	conn, err := sql.Open("mysql", uri)
	if err != nil {
		panic(err.Error())
	}
	//设置连接池
	conn.SetMaxOpenConns(max)
	conn.SetMaxIdleConns(min)
	conn.SetConnMaxLifetime(10 * time.Minute)
	if err := conn.Ping(); err != nil {
		println(err.Error())
	}
	mDb[DbName] = conn
}

// Close pool
func Close(DbName string) error {
	return mDb[DbName].Close()
}

// Query via pool
func Query(DbName, queryStr string, EntityType reflect.Type, args ...interface{}) ([]map[string]interface{}, error) {
	columnToField := make(map[string]string)
	types := EntityType
	for i := 0; i < types.NumField(); i++ {
		typ := types.Field(i)
		tag := typ.Tag
		if len(tag) > 0 {
			column := tag.Get("column")
			name := typ.Name
			columnToField[column] = name
		}
	}
	rows, err := mDb[DbName].Query(queryStr, args...)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	columns, _ := rows.Columns()
	values := make([]interface{}, len(columns))
	scanArgs := make([]interface{}, len(values))
	for i := range values {
		scanArgs[i] = &values[i]
	}
	rowsMap := make([]map[string]interface{}, 0, 10)
	for rows.Next() {
		//将行数据保存到record字典
		err = rows.Scan(scanArgs...)
		if err != nil {
			return nil, err
		}
		rowMap := make(map[string]interface{})
		obj := reflect.New(EntityType).Interface()
		typ := reflect.ValueOf(obj).Elem()
		for i, col := range values {
			if col != nil {
				name := columnToField[columns[i]]
				field := typ.FieldByName(name)
				switch field.Kind() {
				case reflect.String:
					rowMap[name] = string(col.([]byte))
				case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
					v, _ := strconv.ParseUint(string(col.([]byte)), 10, 0)
					rowMap[name] = v
				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
					v, _ := strconv.ParseInt(string(col.([]byte)), 10, 0)
					rowMap[name] = v
				case reflect.Float32:
					v, _ := strconv.ParseFloat(string(col.([]byte)), 32)
					rowMap[name] = v
				case reflect.Float64:
					v, _ := strconv.ParseFloat(string(col.([]byte)), 64)
					rowMap[name] = v
				case reflect.Struct:
					switch field.Type().String() {
					case "time.Time":
						rowMap[columns[i]] = col
					}
				}
			}
		}
		rowsMap = append(rowsMap, rowMap)
	}
	if err = rows.Err(); err != nil {
		return nil, err
	}
	return rowsMap, nil
}

func execute(DbName, sqlStr string, args ...interface{}) (sql.Result, error) {
	return mDb[DbName].Exec(sqlStr, args...)
}

// Update via pool
func Update(DbName, updateStr string, args ...interface{}) (int64, error) {
	result, err := execute(DbName, updateStr, args...)
	if err != nil {
		return 0, err
	}
	affect, err := result.RowsAffected()
	return affect, err
}

// Insert via pool
func Insert(DbName, insertStr string, args ...interface{}) (int64, error) {
	result, err := execute(DbName, insertStr, args...)
	if err != nil {
		return 0, err
	}
	lastid, err := result.LastInsertId()
	return lastid, err
}

// Delete via pool
func Delete(DbName, deleteStr string, args ...interface{}) (int64, error) {
	result, err := execute(DbName, deleteStr, args...)
	if err != nil {
		return 0, err
	}
	affect, err := result.RowsAffected()
	return affect, err
}

// SQLConnTransaction is for transaction connection
type SQLConnTransaction struct {
	SQLTX *sql.Tx
}

// Begin transaction
func Begin(DbName string) (*SQLConnTransaction, error) {
	var oneSQLConnTransaction = &SQLConnTransaction{}
	var err error
	if pingErr := mDb[DbName].Ping(); pingErr == nil {
		oneSQLConnTransaction.SQLTX, err = mDb[DbName].Begin()
	}
	return oneSQLConnTransaction, err
}

// Rollback transaction
func (t *SQLConnTransaction) Rollback() error {
	return t.SQLTX.Rollback()
}

// Commit transaction
func (t *SQLConnTransaction) Commit() error {
	return t.SQLTX.Commit()
}

// Query via transaction
func (t *SQLConnTransaction) Query(queryStr string, EntityType reflect.Type, args ...interface{}) ([]map[string]interface{}, error) {
	columnToField := make(map[string]string)
	types := EntityType
	for i := 0; i < types.NumField(); i++ {
		typ := types.Field(i)
		tag := typ.Tag
		if len(tag) > 0 {
			column := tag.Get("column")
			name := typ.Name
			columnToField[column] = name
		}
	}
	rows, err := t.SQLTX.Query(queryStr, args...)
	if err != nil {
		panic(err.Error())
		return nil, err
	}
	defer rows.Close()
	columns, _ := rows.Columns()
	values := make([]interface{}, len(columns))
	scanArgs := make([]interface{}, len(values))
	for i := range values {
		scanArgs[i] = &values[i]
	}
	rowsMap := make([]map[string]interface{}, 0, 10)
	for rows.Next() {
		//将行数据保存到record字典
		err = rows.Scan(scanArgs...)
		if err != nil {
			return nil, err
		}
		rowMap := make(map[string]interface{})
		obj := reflect.New(EntityType).Interface()
		typ := reflect.ValueOf(obj).Elem()
		for i, col := range values {
			if col != nil {
				name := columnToField[columns[i]]
				field := typ.FieldByName(name)
				switch field.Kind() {
				case reflect.String:
					rowMap[name] = string(col.([]byte))
				case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
					v, _ := strconv.ParseUint(string(col.([]byte)), 10, 0)
					rowMap[name] = v
				case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
					v, _ := strconv.ParseInt(string(col.([]byte)), 10, 0)
					rowMap[name] = v
				case reflect.Float32:
					v, _ := strconv.ParseFloat(string(col.([]byte)), 32)
					rowMap[name] = v
				case reflect.Float64:
					v, _ := strconv.ParseFloat(string(col.([]byte)), 64)
					rowMap[name] = v
				case reflect.Struct:
					switch field.Type().String() {
					case "time.Time":
						rowMap[columns[i]] = col
					}
				}
			}
		}
		rowsMap = append(rowsMap, rowMap)
	}
	if err = rows.Err(); err != nil {
		return nil, err
	}
	return rowsMap, nil
}

func (t *SQLConnTransaction) execute(sqlStr string, args ...interface{}) (sql.Result, error) {
	return t.SQLTX.Exec(sqlStr, args...)
}

// Update via transaction
func (t *SQLConnTransaction) Update(updateStr string, args ...interface{}) (int64, error) {
	result, err := t.execute(updateStr, args...)
	if err != nil {
		return 0, err
	}
	affect, err := result.RowsAffected()
	return affect, err
}

// Insert via transaction
func (t *SQLConnTransaction) Insert(insertStr string, args ...interface{}) (int64, error) {
	result, err := t.execute(insertStr, args...)
	if err != nil {
		return 0, err
	}
	lastid, err := result.LastInsertId()
	return lastid, err

}

// Delete via transaction
func (t *SQLConnTransaction) Delete(deleteStr string, args ...interface{}) (int64, error) {
	result, err := t.execute(deleteStr, args...)
	if err != nil {
		return 0, err
	}
	affect, err := result.RowsAffected()
	return affect, err
}


text:
@inproceedings{WilEA11_esgf,
  address = {{New Delhi}},
  title = {The {{Earth System Grid Federation}}: {{Delivering}} Globally Accessible Petascale Data for {{CMIP5}}},
  shorttitle = {The {{Earth System Grid Federation}}},
  booktitle = {Proceedings of the 32nd {{Asia}}-{{Pacific Advanced Network Meeting}}},
  doi = {10.7125/APAN.32.15},
  author = {Williams, Dean N. and Lawrence, Bryan N. and Lautenschlager, Michael and Middleton, Don and Balaji, V.},
  month = dec,
  year = {2011},
  keywords = {bnl,bnl-ref12-candidates,bnl-cv,jasmin,p-gmdm41,p-12-iam,jasmin13a,bnl-cv-refconf,bnl-cv-refgen,edata4,PetEA20},
  pages = {121-130},
  file = {/Users/BNL28/zotero_files/WilliamsEA_2011_The_Earth_System_Grid_Federation_-.pdf;/Users/BNL28/zotero_files/WilliamsEA_2011_The_Earth.pdf}
}

@article{Jones2011,
  title = {The {{Coordinated Regional Downscaling Experiment}}: {{CORDEX}} an International Downscaling Link to {{CMIP5}}},
  volume = {56},
  journal = {CLIVAR Exchanges},
  author = {Jones, C. and Giorgi, F. and Asrar, G.},
  year = {2011},
  keywords = {PetEA20},
  pages = {34--39},
  file = {/Users/BNL28/zotero_files/JonesEA_2011_The_Coordinated_Regional_Downscaling.pdf}
}

@inproceedings{Teevan2004,
  title = {The Perfect Search Engine Is Not Enough: A Study of Orienteering Behavior in Directed Search},
  isbn = {1-58113-702-8},
  shorttitle = {The Perfect Search Engine Is Not Enough},
  booktitle = {Proceedings of the {{SIGCHI}} Conference on {{Human}} Factors in Computing Systems},
  author = {Teevan, J. and Alvarado, C. and Ackerman, M. S and Karger, D. R},
  year = {2004},
  keywords = {esdoc,moles,lawea15,context,information seeking,observational study,orienteering,search,teleporting,PetEA20},
  pages = {415--422},
  file = {/Users/BNL28/zotero_files/TeevanEA_2004_The_perfect_search_engine_is_not.pdf;/Users/BNL28/zotero_files/TeevanEA_2004_The_perfect_search_engine_is_not.pdf;/Users/BNL28/zotero-storage/storage/TNJIERIW/citation.html}
}

@incollection{BloEA14,
  series = {Communications in {{Computer}} and {{Information Science}}},
  title = {Understanding {{Climate Data Through Commentary Metadata}}: {{The CHARMe Project}}},
  copyright = {\textcopyright{}2014 Springer International Publishing Switzerland},
  isbn = {978-3-319-08424-4 978-3-319-08425-1},
  shorttitle = {Understanding {{Climate Data Through Commentary Metadata}}},
  abstract = {We describe the CHARMe project, which aims to link climate datasets with publications, user feedback and other items of ``commentary metadata''. The system will help users learn from previous community experience and select datasets that best suit their needs, as well as providing direct traceability between conclusions and the data that supported them. The project applies the principles of Linked Data and adopts the Open Annotation standard to record and publish commentary information. CHARMe contributes to the emerging landscape of ``climate services'', which will provide climate data and information to influence policy and decision-making. Although the project focuses on climate science, the technologies and concepts are very general and could be applied to other fields.},
  language = {en},
  number = {416},
  booktitle = {Theory and {{Practice}} of {{Digital Libraries}} -- {{TPDL}} 2013 {{Selected Workshops}}},
  publisher = {{Springer International Publishing}},
  author = {Blower, Jon D. and Alegre, Raquel and Bennett, Victoria L. and Clifford, Debbie J. and Kershaw, Philip J. and Lawrence, Bryan N. and Lewis, Jane P. and Marsh, Kevin and Nagni, Maurizio and O'Neill, Alan and Phipps, Rhona A.},
  editor = {Bolikowski, {\L}ukasz and Casarosa, Vittore and Goodale, Paula and Houssos, Nikos and Manghi, Paolo and Schirrwagen, Jochen},
  month = jan,
  year = {2014},
  keywords = {bnl-cv,Metadata,Semantic Web,Document Preparation and Text Processing,Information Storage and Retrieval,Information Systems and Communication Service,Artificial Intelligence (incl. Robotics),Climate data,Climate services,Open annotation,Linked data,ParEA15,bnl-cv-refconf,bnl-cv-refgen,KerEA19,PetEA20},
  pages = {28-39},
  file = {/Users/BNL28/zotero-storage/storage/AC9MXJ5C/10.html}
}

@article{Latham2009,
  title = {The {{NERC DataGrid}} Services},
  volume = {367},
  issn = {1364-503X, 1471-2962},
  journal = {Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences},
  doi = {10.1098/rsta.2008.0238},
  author = {Latham, S.E and Cramer, R and Grant, M and Kershaw, P and Lawrence, B.N and Lowry, R and Lowe, D and O'Neill, K and Miller, P and Pascoe, S and Pritchard, M and Snaith, H and Woolf, A},
  month = mar,
  year = {2009},
  keywords = {bnl,bnl-ref12-candidates,bnl-cv,bnl-cv-refgen,bnl-cv-refjnl,PetEA20},
  pages = {1015-1019},
  file = {/Users/BNL28/zotero_files/LathamEA_2009_The_NERC_DataGrid_services.pdf}
}

@article{LawEA09,
  title = {Information in Environmental Data Grids},
  volume = {367},
  issn = {1364-503X, 1471-2962},
  language = {en},
  number = {1890},
  journal = {Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences},
  doi = {10.1098/rsta.2008.0237},
  author = {Lawrence, B. N. and Lowry, R. and Miller, P. and Snaith, H. and Woolf, A.},
  month = mar,
  year = {2009},
  keywords = {bnl,bnl-ref12-candidates,bnl-cv,p-gmdm41,bnl-ref12,charme13a,esdoc,lawea15,ParEA15,bnl-cv-refgen,bnl-cv-refjnl,KerEA19,esdoc19,_tablet,PetEA20},
  pages = {1003-1014},
  file = {/Users/BNL28/zotero_files/LawrenceEA_2009_Information_in_environmental_data_grids.pdf}
}

@article{Shaon2012,
  title = {Opening {{Up Climate Research}}: {{A Linked Data Approach}} to {{Publishing Data Provenance}}},
  volume = {7},
  issn = {1746-8256},
  shorttitle = {Opening {{Up Climate Research}}},
  number = {1},
  journal = {International Journal of Digital Curation},
  doi = {10.2218/ijdc.v7i1.223},
  author = {Shaon, Arif and Callaghan, Sarah and Lawrence, Bryan and Matthews, Brian and Osborn, Timothy and Harpham, Colin and Woolf, Andrew},
  month = mar,
  year = {2012},
  keywords = {bnl-cv,bnl-cv-refconf,bnl-cv-refgen,esdoc19,PetEA20},
  pages = {163-173},
  file = {/Users/BNL28/zotero_files/ShaonEA_2012_Opening_Up_Climate_Research_-_A_Linked.pdf}
}

@unpublished{TayEA12,
  title = {{{CMIP5}} Data Reference Syntax ({{DRS}}) and Controlled Vocabularies},
  author = {Taylor, Karl E. and Balaji, V. and Hankin, Steve and Juckes, Martin and Lawrence, Bryan and Pascoe, Stephen},
  month = jun,
  year = {2012},
  keywords = {bnl-cv2,bnl-cv-white,KerEA19,esdoc19,_tablet,PetEA20},
  file = {/Users/BNL28/zotero_files/TaylorEA_2012_CMIP5_data_reference_syntax_(DRS)_and.pdf}
}

@article{ParEA15,
  title = {{{MOLES3}}: {{Implementing}} an {{ISO}} Standards Driven Data Catalogue},
  volume = {10},
  issn = {1746-8256},
  shorttitle = {{{MOLES3}}},
  number = {1},
  journal = {International Journal of Digital Curation},
  doi = {10.2218/ijdc.v10i1.365},
  author = {Parton, Graham A and Donegan, Steven and Pascoe, Stephen and Stephens, Ag and Ventouras, Spiros and Lawrence, Bryan N},
  month = feb,
  year = {2015},
  keywords = {bnl,bnl-cv,bnl-cv-refconf,bnl-cv-refgen,jasmin18,KerEA19,PetEA20},
  file = {/Users/BNL28/zotero_files/PartonEA_2015_MOLES3_-_Implementing_an_ISO_standards.pdf}
}

@article{GutEA16,
  title = {{{WCRP COordinated Regional Downscaling EXperiment}} ({{CORDEX}}): A Diagnostic {{MIP}} for {{CMIP6}}},
  volume = {9},
  issn = {1991-9603},
  shorttitle = {{{WCRP COordinated Regional Downscaling EXperiment}} ({{CORDEX}})},
  abstract = {The COordinated Regional Downscaling EXperiment (CORDEX) is a diagnostic model intercomparison project (MIP) in CMIP6. CORDEX builds on a foundation of previous downscaling intercomparison projects to provide a common framework for downscaling activities around the world. The CORDEX Regional Challenges provide a focus for downscaling research and a basis for making use of CMIP6 global climate model (GCM) output to produce downscaled projected changes in regional climates and assess sources of uncertainties in the projections, all of which can potentially be distilled into climate change information for vulnerability, impacts and adaptation studies. CORDEX Flagship Pilot Studies advance regional downscaling by targeting one or more of the CORDEX Regional Challenges. A CORDEX-CORE framework is planned that will produce a baseline set of homogeneous high-resolution, downscaled projections for regions worldwide. In CMIP6, CORDEX coordinates with ScenarioMIP and is structured to allow cross comparisons with HighResMIP and interaction with the CMIP6 VIACS Advisory Board.},
  number = {11},
  journal = {Geosci. Model Dev.},
  doi = {10.5194/gmd-9-4087-2016},
  author = {Gutowski Jr., W. J. and Giorgi, F. and Timbal, B. and Frigon, A. and Jacob, D. and Kang, H.-S. and Raghavan, K. and Lee, B. and Lennard, C. and Nikulin, G. and O'Rourke, E. and Rixen, M. and Solman, S. and Stephenson, T. and Tangang, F.},
  month = nov,
  year = {2016},
  keywords = {cmip6,pascoe18,PetEA20},
  pages = {4087-4095},
  file = {/Users/BNL28/zotero_files/Gutowski_Jr.EA_2016_WCRP_COordinated_Regional_Downscaling.pdf}
}

@article{BerEA12,
  series = {The {{Sentinel Missions}} - {{New Opportunities}} for {{Science}}},
  title = {{{ESA}}'s Sentinel Missions in Support of {{Earth}} System Science},
  volume = {120},
  issn = {0034-4257},
  abstract = {The spatial and temporal characteristics of the new Sentinel missions, primarily designed to provide routine multidisciplinary observations for operational services, are also very suitable for addressing some of the challenges associated with advancing Earth System sciences. The Sentinels are ensuring long-term observational commitment and will operate a range of instruments with different spectral bands and spatial resolutions with global coverage and high revisit times. The complexity of Earth System models has been increasing gradually and most simulations of future climate and Earth system evolution are based on coupled models that include aspects of physics, bio/geo-chemistry, anthropogenic impacts and even recently some elements of socioeconomic factors. Sentinels will provide unique observations to describe such coupled atmosphere, oceans, land and cryosphere and the exchanges among them into Earth System models. This paper emphasizes the indispensable value of the data provided by the family of Sentinel constellations in the context of the urgent need for improved process understanding of the Earth system.},
  journal = {Remote Sensing of Environment},
  doi = {10.1016/j.rse.2011.07.023},
  author = {Berger, Michael and Moreno, Jose and Johannessen, Johnny A. and Levelt, Pieternel F. and Hanssen, Ramon F.},
  month = may,
  year = {2012},
  keywords = {Earth system science,jasmin18,ESA,Global Monitoring for Environment and Security (GMES),Sentinel,PetEA20},
  pages = {84-90},
  file = {/Users/BNL28/zotero_files/BergerEA_2012_ESA's_sentinel_missions_in_support_of.pdf;/Users/BNL28/zotero-storage/storage/IGPX6B7G/S003442571200065X.html}
}

@article{HolEA13,
  title = {The {{ESA Climate Change Initiative}}: {{Satellite Data Records}} for {{Essential Climate Variables}}},
  volume = {94},
  issn = {0003-0007},
  shorttitle = {The {{ESA Climate Change Initiative}}},
  abstract = {Observations of Earth from space have been made for over 40 years and have contributed to advances in many aspects of climate science. However, attempts to exploit this wealth of data are often hampered by a lack of homogeneity and continuity and by insufficient understanding of the products and their uncertainties. There is, therefore, a need to reassess and reprocess satellite datasets to maximize their usefulness for climate science. The European Space Agency has responded to this need by establishing the Climate Change Initiative (CCI). The CCI will create new climate data records for (currently) 13 essential climate variables (ECVs) and make these open and easily accessible to all. Each ECV project works closely with users to produce time series from the available satellite observations relevant to users' needs. A climate modeling users' group provides a climate system perspective and a forum to bring the data and modeling communities together. This paper presents the CCI program. It outlines its benefit and presents approaches and challenges for each ECV project, covering clouds, aerosols, ozone, greenhouse gases, sea surface temperature, ocean color, sea level, sea ice, land cover, fire, glaciers, soil moisture, and ice sheets. It also discusses how the CCI approach may contribute to defining and shaping future developments in Earth observation for climate science.},
  number = {10},
  journal = {Bulletin of the American Meteorological Society},
  doi = {10.1175/BAMS-D-11-00254.1},
  author = {Hollmann, R. and Merchant, C. J. and Saunders, R. and Downy, C. and Buchwitz, M. and Cazenave, A. and Chuvieco, E. and Defourny, P. and {de Leeuw}, G. and Forsberg, R. and {Holzer-Popp}, T. and Paul, F. and Sandven, S. and Sathyendranath, S. and {van Roozendael}, M. and Wagner, W.},
  month = mar,
  year = {2013},
  keywords = {KerEA19,PetEA20},
  pages = {1541-1552},
  file = {/Users/BNL28/zotero_files/HollmannEA_2013_The_ESA_Climate_Change_Initiative_-.pdf;/Users/BNL28/zotero-storage/storage/97TXA72R/BAMS-D-11-00254.html}
}

@inproceedings{ClipcEGU2016,
  address = {{Vienna}},
  title = {Developing a {{Metadata Infrastructure}} to Facilitate Data Driven Science Gateway and to Provide {{Inspire}}/{{GEMINI}} Compliance for {{CLIPC}}},
  volume = {18},
  language = {en},
  booktitle = {Geophysical {{Research Abstracts}}},
  author = {Mihajlovski, Andrej and Plieger, Maarten and {de Cerff}, Wim Som and Page, Christian},
  year = {2016},
  keywords = {KerEA19,PetEA20},
  pages = {EGU2016-4667-1},
  file = {/Users/BNL28/zotero-storage/storage/U5A5XA76/Mihajlovski et al. - Developing a Metadata Infrastructure to facilitate.pdf}
}

@inproceedings{Miura2016,
  title = {Earth {{Observation}} Data Access Interoperability Implementation among Space Agencies},
  abstract = {Heterogeneous Earth Observation (EO) satellite data is available from many agencies. In order to make best use of these data, interoperability for data access is very important. In this paper, the importance of data access interoperability and the work of CEOS (Committee on Earth Observation Satellites) WGISS (the Working Group on Information Systems and Services) to improve data access interoperability are described.},
  booktitle = {2016 {{IEEE International Geoscience}} and {{Remote Sensing Symposium}} ({{IGARSS}})},
  doi = {10.1109/IGARSS.2016.7729938},
  author = {Miura, S. H.},
  month = jul,
  year = {2016},
  keywords = {Europe,Metadata,Organizations,Earth,open systems,remote sensing,Best practices,KerEA19,Interoperability,artificial satellites,CEOS,CEOS GISS,Data,Earth Observation data access interoperability,EO satellite data,Observation,Satellites,space agencies,PetEA20},
  pages = {3621-3623},
  file = {/Users/BNL28/zotero-storage/storage/CJZWCMVZ/7729938.html}
}

@article{RaoEA17,
  title = {Climate Service Develops User-Friendly Data Store},
  volume = {151},
  journal = {ECMWF Newsletter},
  doi = {10.21957/p3c285},
  author = {Raoult, Baudouin and Bergeron, Cedric and L{\'o}pez Al{\'o}s, Angel and Th{\'e}paut, Jean-No{\"e}l and Dee, Dick},
  year = {2017},
  keywords = {KerEA19,PetEA20}
}

@article{PasEA19,
  title = {Designing and {{Documenting Experiments}} in {{CMIP6}}},
  issn = {1991-962X},
  abstract = {{$<$}p{$><$}strong{$>$}Abstract.{$<$}/strong{$>$} Earth system modelling relies on contributions from groups who develop models and from those involved in devising, executing, and exploiting numerical experiments. Often these people work in different institutions, and they may communicate primarily via published information (whether journal papers, technical notes, or websites). The complexity of the models, experiments, and methodologies, along with the diversity (and sometimes inexact nature) of information sources can easily lead to misinterpretation of what was actually intended or done. In this paper we introduce a taxonomy of terms for more clearly defining numerical experiments, put it in the context of previous work on experimental ontologies, and describe how we have used it to document the CMIP6 experiments. We describe how this process involved iteration with a range of CMIP6 stakeholders to rationalise multiple sources of information and add clarity to experimental definitions. We demonstrate how this process has added value to CMIP6 itself by a) helping those devising experiments to be clear about their goals and expected methodology, b) making it easier for those executing experiments to know what was intended, c) exposing inter-relationships between experiments, and d) making it clearer for third parties (data users) to understand the CMIP6 experiments. We conclude with some lessons learned, and how these may be applied for any modelling campaign as well as future CMIP phases.{$<$}/p{$>$}},
  language = {en},
  journal = {Geoscientific Model Development Discussions},
  doi = {10.5194/gmd-2019-98},
  author = {Pascoe, Charlotte and Lawrence, Bryan N. and Guilyardi, Eric and Juckes, Martin and Taylor, Karl E.},
  month = jun,
  year = {2019},
  keywords = {esdoc19,_tablet,PetEA20},
  pages = {1-27},
  file = {/Users/BNL28/zotero_files/PascoeEA_2019_Designing_and_Documenting_Experiments.pdf}
}

@article{gmd-2019-219,
  title = {The {{CMIP6 Data Request}} (Version 01.00.31)},
  abstract = {{$<$}p{$><$}strong{$>$}Abstract.{$<$}/strong{$>$} The data request of the Coupled Model Intercomparison Project Phase 6 (CMIP6) defines all the quantities from CMIP6 simulations that should be archived. This includes both quantities of general interest needed from most of the CMIP6-endorsed Model Intercomparison Projects (MIPs) and quantities that are more specialised and only of interest to a single endorsed MIP. The complexity of the data request has increased from the early days of model intercomparisons, as has the data volume. In contrast with CMIP5, CMIP6 requires distinct sets of highly tailored variables to be saved from each of the more than 200 experiments. This places new demands on the data request information base and results in a new requirement for development of software that facilitates automated interrogation of the request and retrieval of its technical specifications. The building blocks and structure of the CMIP6 Data Request (DREQ) which has been constructed to meet these challenges is described in this paper.{$<$}/p{$>$}},
  doi = {10.5194/gmd-2019-219},
  author = {Juckes, Martin and Taylor, Karl E. and Durack, Paul and Lawrence, Bryan and Mizielinski, Matthew and Pamment, Alison and Peterschmitt, Jean-Yves and Rixen, Michel and S{\'e}n{\'e}sis, St{\'e}phane},
  month = aug,
  year = {2019},
  keywords = {pascoe18,PetEA20}
}

@article{Cox2016,
  title = {Ontology for Observations and Sampling Features, with Alignments to Existing Models},
  volume = {8},
  abstract = {We introduce new OWL ontologies for observations and sampling features, based on the O\&M conceptual model from OGC and ISO 19156. Previous efforts, (a) through the W3C SSN project, and (b) following ISO rules for conversion from UML, had dependencies on elaborate pre-existing ontologies and frameworks. The new ontologies, known as om-lite and sam- lite, remove such dependencies, and can therefore be used with minimal ontological commitment beyond the O\&M conceptual model. Time and space concepts, for which there are multiple existing solutions, are implemented as stub-classes, and patterns for linking to the existing ontologies are described. PROV is used to support certain requirements for the description of specimens. A more general alignment of both observation and sampling feature ontologies with PROV is described, as well as mappings to some other observation models and ontologies.},
  journal = {Semantic Web},
  doi = {10.3233/SW-160214},
  author = {Cox, Simon J. D.},
  year = {2016},
  keywords = {esdoc19,PetEA20,Requirement,Bridging (networking),DMZ (computing),Emoticon,Observations and Measurements,Ontology (information science),Run time (program lifecycle phase),Sampling (signal processing),Subscriber identity module,Unified Modeling Language,Upper ontology,Vocabulary,Web Ontology Language},
  pages = {453-470},
  file = {/Users/BNL28/zotero_files/Cox_2016_Ontology_for_observations_and_sampling.pdf}
}

@techreport{Sentinel2019,
  title = {Sentinel {{Data Access}} - {{Annual Report}} 2018},
  number = {COPE-SERCO-RP-19-0389},
  institution = {{SERCO}},
  author = {Knowelden, Richard},
  month = may,
  year = {2019},
  keywords = {PetEA20},
  file = {/Users/BNL28/zotero-storage/storage/EB2NT5DB/COPE-SERCO-RP-19-0389_-_Sentinel_Data_Access_Annual_Report_Y2018_v1.0.pdf}
}

@inproceedings{Leadbetter2012,
  address = {{Vienna, Austria}},
  title = {The {{NERC Vocabulary Server}}: {{Version}} 2.0},
  volume = {14},
  language = {en},
  booktitle = {Geophysical {{Research Abstracts}}},
  publisher = {{EGU}},
  author = {Leadbetter, A and Lowry, R and Clements, O},
  year = {2012},
  keywords = {PetEA20},
  pages = {EGU2012-2943},
  file = {/Users/BNL28/zotero-storage/storage/4G2A9D2C/Leadbetter et al. - The NERC Vocabulary Server Version 2.0.pdf}
}

@techreport{christensen2014cordex,
  title = {{{CORDEX}} Archive Design},
  institution = {{Danish Meteorological Institute}},
  author = {Christensen, OB and Gutowski, WJ and Nikulin, G and Legutke, S},
  year = {2014},
  keywords = {PetEA20},
  file = {/Users/BNL28/zotero-storage/storage/5XR9LMGG/cordex_archive_specifications.pdf}
}

@techreport{Nikulin2016,
  title = {Data {{Reference Syntax}} ({{DRS}}) for Bias-Adjusted {{CORDEX}} Simulations},
  language = {en},
  institution = {{Swedish Meteorological and Hydrological Institute}},
  author = {Nikulin, Grigory and Legutke, Stephanie},
  month = jun,
  year = {2016},
  keywords = {PetEA20},
  pages = {9},
  file = {/Users/BNL28/zotero-storage/storage/X37FBZRF/Nikulin and Legutke - Data Reference Syntax (DRS) for bias-adjusted CORD.pdf}
}

@article{Giorgi2009,
  title = {Addressing Climate Information Needs at the Regional Level: The {{CORDEX}} Framework},
  volume = {58(3)},
  language = {en},
  journal = {WMO Bulletin},
  author = {Giorgi, Filippo and Jones, Colin and Asrar, Ghassem R},
  month = jul,
  year = {2009},
  keywords = {PetEA20},
  pages = {175-183},
  file = {/Users/BNL28/zotero-storage/storage/EPHDQ55C/Giorgi et al. - Addressing climate information needs at the region.pdf}
}

repository: RuthPetrie/drs-paper

repo_name: RuthPetrie/drs-paper


text:
package options

import (
	flag "github.com/spf13/pflag"
	"github.com/yuyicai/kubei/internal/constants"
)

const (
	Key                       = "key"
	ShortKey                  = "k"
	Port                      = "port"
	Password                  = "password"
	ShortPassword             = "p"
	User                      = "user"
	KubernetesVersion         = "kubernetes-version"
	ContainerEngineVersion    = "container-engine-version"
	ControlPlaneEndpoint      = "control-plane-endpoint"
	ImageRepository           = "image-repository"
	Masters                   = "masters"
	ShortMasters              = "m"
	Workers                   = "nodes"
	ShortNodes                = "n"
	PodNetworkCidr            = "pod-network-cidr"
	ServiceCidr               = "service-cidr"
	JumpServer                = "jump-server"
	RemoveContainerEngine     = "remove-container-engine"
	RemoveKubernetesComponent = "remove-kubernetes-component"
	OfflineFile               = "offline-file"
	ShortOfflineFile          = "f"
	CertNotAfterTime          = "cert-time"
	NetworkPlugin             = "network-plugin"
	Online                    = "install-online"
	Command                   = "command"
)

func AddResetFlags(flagSet *flag.FlagSet, options *Reset) {
	flagSet.BoolVar(
		&options.RemoveContainerEngine, RemoveContainerEngine, options.RemoveContainerEngine,
		"If true, remove the container engine from the nodes",
	)

	flagSet.BoolVar(
		&options.RemoveKubeComponent, RemoveKubernetesComponent, options.RemoveKubeComponent,
		"If true, remove the kubernetes component from the nodes",
	)
}

func AddContainerEngineConfigFlags(flagSet *flag.FlagSet, options *ContainerEngine) {
	flagSet.StringVar(
		&options.Version, ContainerEngineVersion, options.Version,
		"The Docker version.",
	)
}

func AddKubeClusterNodesConfigFlags(flagSet *flag.FlagSet, options *ClusterNodes) {
	flagSet.StringSliceVarP(
		&options.Masters, Masters, ShortMasters, options.Masters,
		"The master nodes IP",
	)

	flagSet.StringSliceVarP(
		&options.Workers, Workers, ShortNodes, options.Workers,
		"The worker nodes IP",
	)
}

func AddPublicUserInfoConfigFlags(flagSet *flag.FlagSet, options *PublicHostInfo) {
	flagSet.StringVar(
		&options.User, User, constants.DefaultSSHUser,
		"SSH user of the nodes.",
	)

	flagSet.StringVarP(
		&options.Password, Password, ShortPassword, options.Password,
		"SSH password of the nodes.",
	)

	flagSet.StringVar(
		&options.Port, Port, constants.DefaultSSHPort,
		"SSH port of the nodes.",
	)

	flagSet.StringVarP(
		&options.Key, Key, ShortKey, options.Key,
		"SSH key of the nodes.",
	)
}

func AddKubeadmConfigFlags(flagSet *flag.FlagSet, options *Kubeadm) {
	flagSet.StringVar(
		&options.Networking.ServiceSubnet, ServiceCidr, constants.DefaultServiceSubnet,
		"Use alternative range of IP address for service VIPs",
	)
	flagSet.StringVar(
		&options.Networking.PodSubnet, PodNetworkCidr, constants.DefaultPodNetworkCidr,
		"Specify range of IP addresses for the pod network",
	)

	AddImageMetaFlags(flagSet, &options.ImageRepository)
	AddControlPlaneEndpointFlags(flagSet, options)
}

func AddControlPlaneEndpointFlags(flagSet *flag.FlagSet, options *Kubeadm) {
	flagSet.StringVar(
		&options.ControlPlaneEndpoint, ControlPlaneEndpoint, constants.DefaultControlPlaneEndpoint,
		`Specify a DNS name for the control plane.`,
	)
}

func AddImageMetaFlags(flagSet *flag.FlagSet, imageRepository *string) {
	flagSet.StringVar(imageRepository, ImageRepository, constants.DefaultImageRepository,
		"Choose a container registry to pull control plane images from",
	)
}

func AddJumpServerFlags(flagSet *flag.FlagSet, userInfo *map[string]string) {
	flagSet.StringToStringVar(userInfo, JumpServer, *userInfo,
		"Jump server user info",
	)
}

func AddOfflinePackageFlags(flagSet *flag.FlagSet, pkg *string) {
	flagSet.StringVarP(pkg, OfflineFile, ShortOfflineFile, *pkg,
		"Path to offline file path",
	)
}

func AddCertNotAfterTimeFlags(flagSet *flag.FlagSet, year *int) {
	flagSet.IntVar(year, CertNotAfterTime, constants.DefaultCertNotAfterYear,
		"cert not after time, time units is year",
	)
}

func AddNetworkPluginFlags(flagSet *flag.FlagSet, networkType *string) {
	flagSet.StringVar(networkType, NetworkPlugin, constants.DefaulNetworkPlugin,
		"network plugin",
	)
}

func AddOnlineFlags(flagSet *flag.FlagSet, options *bool) {
	flagSet.BoolVar(
		options, Online, *options,
		"If true, install kubernetes cluster online",
	)
}

func AddKubernetesFlags(flagSet *flag.FlagSet, options *Kubernetes) {
	flagSet.StringVar(
		&options.Version, KubernetesVersion, options.Version,
		"The Kubernetes version",
	)
}

func AddExecCommandFlags(flagSet *flag.FlagSet, cmd *string) {
	flagSet.StringVar(
		cmd, Command, *cmd,
		"The command than will be executed on nodes",
	)
}

repository: yuyicai/kubei

repo_name: yuyicai/kubei


text:
package gtund

import (
	"encoding/binary"
	"encoding/json"
	"fmt"
	"io"
	"net"
	"sync"
	"time"

	"github.com/ICKelin/gtun/internal/logs"
	"github.com/ICKelin/gtun/internal/proto"
	"github.com/ICKelin/optw/transport"
)

var (
	authFailMsg    = "authorize fail"
	authSuccessMsg = "authorize success"
)

type ServerConfig struct {
	Listen         string `yaml:"listen"`
	AuthKey        string `yaml:"authKey"`
	Scheme         string `yaml:"scheme"`
	ListenerConfig string `yaml:"listenerConfig"`
}

type Server struct {
	listener transport.Listener
	udpPool  sync.Pool
	tcpPool  sync.Pool
}

func NewServer(listener transport.Listener) *Server {
	return &Server{
		listener: listener,
		udpPool: sync.Pool{
			New: func() interface{} {
				return make([]byte, 1024*64)
			},
		},
		tcpPool: sync.Pool{
			New: func() interface{} {
				return make([]byte, 1024*8)
			},
		},
	}
}

func (s *Server) Run() error {
	for {
		conn, err := s.listener.Accept()
		if err != nil {
			logs.Error("listener accept fail: %v", err)
			if ne, ok := err.(net.Error); ok {
				if ne.Temporary() {
					time.Sleep(time.Millisecond * 100)
					continue
				}
			}
			return err
		}

		logs.Info("accept connect from remote: %s", conn.RemoteAddr().String())
		go s.onConn(conn)
	}
}

func (s *Server) onConn(conn transport.Conn) {
	defer conn.Close()
	for {
		stream, err := conn.AcceptStream()
		if err != nil {
			logs.Error("accept %s stream fail: %v", conn.RemoteAddr().String(), err)
			break
		}
		go s.handleStream(stream)
	}
}

func (s *Server) handleStream(stream transport.Stream) {
	lenbuf := make([]byte, 2)
	_, err := stream.Read(lenbuf)
	if err != nil {
		logs.Error("read stream len fail: %v", err)
		stream.Close()
		return
	}

	bodylen := binary.BigEndian.Uint16(lenbuf)
	buf := make([]byte, bodylen)
	nr, err := io.ReadFull(stream, buf)
	if err != nil {
		logs.Error("read proxy protocol fail: %v", err)
		stream.Close()
		return
	}

	proxyProtocol := proto.ProxyProtocol{}
	err = json.Unmarshal(buf[:nr], &proxyProtocol)
	if err != nil {
		logs.Error("unmarshal proxy protocol fail: %v", err)
		return
	}

	switch proxyProtocol.Protocol {
	case "tcp":
		s.tcpProxy(stream, &proxyProtocol)
	case "udp":
		s.udpProxy(stream, &proxyProtocol)
	}
}

func (s *Server) tcpProxy(stream transport.Stream, p *proto.ProxyProtocol) {
	addr := fmt.Sprintf("%s:%s", p.DstIP, p.DstPort)
	remoteConn, err := net.DialTimeout("tcp", addr, time.Second*10)
	if err != nil {
		logs.Error("dial server %s fail: %v", addr, err)
		stream.Close()
		return
	}

	go func() {
		defer remoteConn.Close()
		defer stream.Close()
		obj := s.tcpPool.Get()
		defer s.tcpPool.Put(obj)
		buf := obj.([]byte)
		io.CopyBuffer(remoteConn, stream, buf)
	}()

	defer remoteConn.Close()
	defer stream.Close()
	obj := s.tcpPool.Get()
	defer s.tcpPool.Put(obj)
	buf := obj.([]byte)
	io.CopyBuffer(stream, remoteConn, buf)
}

func (s *Server) udpProxy(stream transport.Stream, p *proto.ProxyProtocol) {
	addr := net.JoinHostPort(p.DstIP, p.DstPort)
	raddr, err := net.ResolveUDPAddr("udp", addr)
	if err != nil {
		logs.Error("resolve %s fail: %v", addr, err)
		stream.Close()
		return
	}

	remoteConn, err := net.DialUDP("udp", nil, raddr)
	if err != nil {
		logs.Error("dial %s udp fail: %v", raddr, err)
		return
	}
	defer remoteConn.Close()

	go func() {
		defer remoteConn.Close()
		defer stream.Close()
		hdr := make([]byte, 2)
		for {
			_, err := io.ReadFull(stream, hdr)
			if err != nil {
				logs.Error("read stream fail: %v", err)
				break
			}
			nlen := binary.BigEndian.Uint16(hdr)
			buf := make([]byte, nlen)
			_, err = io.ReadFull(stream, buf)
			if err != nil {
				logs.Error("read stream body fail: %v", err)
				break
			}

			remoteConn.Write(buf)
		}
	}()

	defer remoteConn.Close()
	defer stream.Close()
	obj := s.udpPool.Get()
	defer s.udpPool.Put(obj)
	buf := obj.([]byte)
	for {
		remoteConn.SetReadDeadline(time.Now().Add(time.Minute * 1))
		nr, err := remoteConn.Read(buf)
		remoteConn.SetReadDeadline(time.Time{})
		if err != nil {
			logs.Error("read from remote %s fail: %v", remoteConn.RemoteAddr().String(), err)
			break
		}

		bytes := proto.EncodeData(buf[:nr])
		stream.SetWriteDeadline(time.Now().Add(time.Second * 10))
		nw, err := stream.Write(bytes)
		stream.SetWriteDeadline(time.Time{})
		if err != nil {
			logs.Error("stream write fail: %v", err)
			break
		}

		if nw != len(bytes) {
			logs.Error("bug: stream write %d bytes, expected %d", nw, len(bytes))
		}
	}
}

repository: ICKelin/gtun

repo_name: ICKelin/gtun


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

package maps

import (
	"reflect"
	"sync"
	"testing"

	qt "github.com/frankban/quicktest"
)

func TestScratchAdd(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.Add("int1", 10)
	scratch.Add("int1", 20)
	scratch.Add("int2", 20)

	c.Assert(scratch.Get("int1"), qt.Equals, int64(30))
	c.Assert(scratch.Get("int2"), qt.Equals, 20)

	scratch.Add("float1", float64(10.5))
	scratch.Add("float1", float64(20.1))

	c.Assert(scratch.Get("float1"), qt.Equals, float64(30.6))

	scratch.Add("string1", "Hello ")
	scratch.Add("string1", "big ")
	scratch.Add("string1", "World!")

	c.Assert(scratch.Get("string1"), qt.Equals, "Hello big World!")

	scratch.Add("scratch", scratch)
	_, err := scratch.Add("scratch", scratch)

	m := scratch.Values()
	c.Assert(m, qt.HasLen, 5)

	if err == nil {
		t.Errorf("Expected error from invalid arithmetic")
	}
}

func TestScratchAddSlice(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()

	_, err := scratch.Add("intSlice", []int{1, 2})
	c.Assert(err, qt.IsNil)
	_, err = scratch.Add("intSlice", 3)
	c.Assert(err, qt.IsNil)

	sl := scratch.Get("intSlice")
	expected := []int{1, 2, 3}

	if !reflect.DeepEqual(expected, sl) {
		t.Errorf("Slice difference, go %q expected %q", sl, expected)
	}
	_, err = scratch.Add("intSlice", []int{4, 5})

	c.Assert(err, qt.IsNil)

	sl = scratch.Get("intSlice")
	expected = []int{1, 2, 3, 4, 5}

	if !reflect.DeepEqual(expected, sl) {
		t.Errorf("Slice difference, go %q expected %q", sl, expected)
	}
}

// https://github.com/gohugoio/hugo/issues/5275
func TestScratchAddTypedSliceToInterfaceSlice(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.Set("slice", []any{})

	_, err := scratch.Add("slice", []int{1, 2})
	c.Assert(err, qt.IsNil)
	c.Assert(scratch.Get("slice"), qt.DeepEquals, []int{1, 2})
}

// https://github.com/gohugoio/hugo/issues/5361
func TestScratchAddDifferentTypedSliceToInterfaceSlice(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.Set("slice", []string{"foo"})

	_, err := scratch.Add("slice", []int{1, 2})
	c.Assert(err, qt.IsNil)
	c.Assert(scratch.Get("slice"), qt.DeepEquals, []any{"foo", 1, 2})
}

func TestScratchSet(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.Set("key", "val")
	c.Assert(scratch.Get("key"), qt.Equals, "val")
}

func TestScratchDelete(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.Set("key", "val")
	scratch.Delete("key")
	scratch.Add("key", "Lucy Parsons")
	c.Assert(scratch.Get("key"), qt.Equals, "Lucy Parsons")
}

// Issue #2005
func TestScratchInParallel(t *testing.T) {
	var wg sync.WaitGroup
	scratch := NewScratch()

	key := "counter"
	scratch.Set(key, int64(1))
	for i := 1; i <= 10; i++ {
		wg.Add(1)
		go func(j int) {
			for k := 0; k < 10; k++ {
				newVal := int64(k + j)

				_, err := scratch.Add(key, newVal)
				if err != nil {
					t.Errorf("Got err %s", err)
				}

				scratch.Set(key, newVal)

				val := scratch.Get(key)

				if counter, ok := val.(int64); ok {
					if counter < 1 {
						t.Errorf("Got %d", counter)
					}
				} else {
					t.Errorf("Got %T", val)
				}
			}
			wg.Done()
		}(i)
	}
	wg.Wait()
}

func TestScratchGet(t *testing.T) {
	t.Parallel()
	scratch := NewScratch()
	nothing := scratch.Get("nothing")
	if nothing != nil {
		t.Errorf("Should not return anything, but got %v", nothing)
	}
}

func TestScratchSetInMap(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.SetInMap("key", "lux", "Lux")
	scratch.SetInMap("key", "abc", "Abc")
	scratch.SetInMap("key", "zyx", "Zyx")
	scratch.SetInMap("key", "abc", "Abc (updated)")
	scratch.SetInMap("key", "def", "Def")
	c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []any{0: "Abc (updated)", 1: "Def", 2: "Lux", 3: "Zyx"})
}

func TestScratchDeleteInMap(t *testing.T) {
	t.Parallel()
	c := qt.New(t)

	scratch := NewScratch()
	scratch.SetInMap("key", "lux", "Lux")
	scratch.SetInMap("key", "abc", "Abc")
	scratch.SetInMap("key", "zyx", "Zyx")
	scratch.DeleteInMap("key", "abc")
	scratch.SetInMap("key", "def", "Def")
	scratch.DeleteInMap("key", "lmn") // Do nothing
	c.Assert(scratch.GetSortedMapValues("key"), qt.DeepEquals, []any{0: "Def", 1: "Lux", 2: "Zyx"})
}

func TestScratchGetSortedMapValues(t *testing.T) {
	t.Parallel()
	scratch := NewScratch()
	nothing := scratch.GetSortedMapValues("nothing")
	if nothing != nil {
		t.Errorf("Should not return anything, but got %v", nothing)
	}
}

func BenchmarkScratchGet(b *testing.B) {
	scratch := NewScratch()
	scratch.Add("A", 1)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		scratch.Get("A")
	}
}

repository: bep/hugo

repo_name: bep/hugo


text:
require recipes/uhd/uhd-firmware.inc

PR = "${INC_PR}.0"

SRC_URI[md5sum] = "00bf346a4e6b8fb1f0d1633e4464cd34"
SRC_URI[sha256sum] = "231e8e63b6a3348b36881540e3738912d082a74118fd439feeec32ed76b56ba3"

repository: ynezz/openembedded

repo_name: ynezz/openembedded