text:
volume =	 54,
  number =	 5,
  pages =	 {1647-1691},
  year =	 1999
}

@Article{SWY:02,
  journal =	 {Journal of Business \& Economic Statistics},
  title =	 {A survey of weak instruments and weak identification
                  in generalized method of moments},
  volume =	 20,
  number =	 4,
  journal =	 {Journal of Business \& Economic Statistics},
  author =	 {James H Stock and Jonathan H Wright and Motohiro
                  Yogo},
  year =	 2002,
  pages =	 {518-29}
}

@Article{Sal:97,
  title =	 {I just ran two million regressions},
  volume =	 87,
  number =	 2,
  journal =	 {The American Economic Review},
  author =	 {Xavier X. {Sala-i-Martin}},
  month =	 may,
  year =	 1997,
  pages =	 {178-183}
}

@Manual{Sar:10,
  title =	 {lattice: Lattice Graphics},
  author =	 {Deepayan Sarkar},
  year =	 2010,
  note =	 {R package version 0.18-5}
}

@Article{ScB:08,
  title =	 {Real-time forecasting of {German} {GDP} based on a
                  large factor model with monthly and quarterly data},
  journal =	 {International Journal of Forecasting},
  volume =	 24,
  number =	 3,
  pages =	 {386-398},
  year =	 2008,
  author =	 {Christian Schumacher and J{\"o}rg Breitung}
}

@Book{Sch:59,
  title =	 {The analysis of variance},
  publisher =	 {John Wiley \& Sons},
  author =	 {Henry Scheff\'e},
  year =	 1959
}

@Book{SeL:03,
  edition =	 {2nd},
  title =	 {Linear regression analysis},
  publisher =	 {{Wiley-Interscience}},
  author =	 {George Seber and Alan Lee},
  year =	 2003,
  pages =	 557
}

@Manual{SeR:09,
  title =	 {rlecuyer: R interface to RNG with multiple streams},
  author =	 {Hana Sevcikova and Tony Rossini},
  year =	 2009,
  note =	 {Available at
                  \url{http://cran.r-project.org/package=rlecuyer}}
}

@Manual{ShB:11:0.6.1,
  title =	 {{tikzDevice}: A Device for {R} Graphics Output in
                  {PGF}/{TikZ} Format},
  author =	 {Charlie Sharpsteen and Cameron Bracken},
  year =	 2011,
  note =	 {R package version 0.6.1, available at
                  \url{http://cran.r-project.org/package=tikzDevice}}
}

@article{Sha:10,
  title =	 {Extended tapered block bootstrap},
  author =	 {Shao, Xiaofeng},
  journal =	 {Statistica Sinica},
  volume =	 20,
  number =	 2,
  pages =	 {807-821},
  year =	 2010
}

@Article{Sil76,
  jstor_articletype ={research-article},
  title =	 {Limit Theorems for Dissociated Random Variables},
  author =	 {Silverman, B.W.},
  journal =	 {Advances in Applied Probability},
  volume =	 8,
  number =	 4,
  pages =	 {806-819},
  year =	 1976
}

@Article{Sil:76,
  title =	 {Limit Theorems for Dissociated Random Variables},
  author =	 {Silverman, B.W.},
  journal =	 {Advances in Applied Probability},
  volume =	 8,
  number =	 4,
  pages =	 {806-819},
  year =	 1976
}

@article{Sil:85,
  title =	 {The smallest eigenvalue of a large dimensional
                  Wishart matrix},
  author =	 {Silverstein, Jack W and others},
  journal =	 {The Annals of Probability},
  volume =	 13,
  number =	 4,
  pages =	 {1364-1368},
  year =	 1985,
  publisher =	 {Institute of Mathematical Statistics}
}

@Article{Sim:10,
  author =	 {Sims, Christopher A.},
  title =	 {But Economics Is Not an Experimental Science},
  journal =	 {Journal of Economic Perspectives},
  volume =	 24,
  number =	 2,
  year =	 2010,
  pages =	 {59-68}
}

@Article{Sim:96,
  title =	 {Macroeconomics and Methodology},
  author =	 {Sims, Christopher A.},
  journal =	 {The Journal of Economic Perspectives},
  volume =	 10,
  number =	 1,
  pages =	 {105-120},
  year =	 1996
}

@TechReport{Son:09,
  year =	 2009,
  title =	 {Testing predictive ability and power
                  robustification},
  author =	 {Kevin Song},
  institution =	 {University of Pennsylvania},
  type =	 {PIER Working Paper}
}

@Article{StS:97,
  title =	 {Instrumental Variables Regression with Weak
                  Instruments},
  author =	 {Staiger, Douglas and Stock, James H.},
  journal =	 {Econometrica},
  volume =	 65,
  number =	 3,
  pages =	 {557-586},
  year =	 1997
}

@Article{StW:02,
  author =	 {Stock, James H. and Watson, Mark W.},
  title =	 {Macroeconomic Forecasting Using Diffusion Indexes},
  journal =	 {Journal of Business and Economic Statistics},
  volume =	 20,
  number =	 2,
  pages =	 {147-162},
  year =	 2002
}

@Article{StW:02b,
  author =	 {Stock, James H. and Watson, Mark W.},
  title =	 {Forecasting Using Principal Components From a Large
                  Number of Predictors},
  journal =	 {Journal of the American Statistical Association},
  volume =	 97,
  number =	 460,
  pages =	 {1167-1179},
  year =	 2002
}

@Article{StW:03,
  title =	 {Forecasting output and inflation: the role of asset
                  prices},
  volume =	 41,
  number =	 3,
  journal =	 {Journal of Economic Literature},
  author =	 {James H. Stock and Mark W. Watson},
  year =	 2003,
  pages =	 {788-829}
}

@InCollection{StW:06,
  author =	 {James H. Stock and Mark W. Watson},
  title =	 {Forecasting with many predictors},
  pages =	 {515-554},
  booktitle =	 {Handbook of Economic Forecasting},
  volume =	 1,
  editor =	 {Graham Elliott and Clive Granger and Allan
                  Timmermann},
  publisher =	 {Elsevier},
  year =	 2006
}

@Article {StW:07,
  author =	 {Stock, James H. and Watson, Mark W.},
  title =	 {Why Has {U.S.} Inflation Become Harder to Forecast?},
  journal =	 {Journal of Money, Credit and Banking},
  volume =	 39,
  publisher =	 {Blackwell Publishing Inc},
  pages =	 {3-33},
  year =	 2007
}

@Unpublished{StW:08,
  address =	 {Boston Federal Reserve},
  title =	 {Phillips curve inflation forecasts},
  author =	 {James H. Stock and Mark W. Watson},
  month =	 jun,
  year =	 2008,
  note =	 {Working Paper}
}

@InCollection{StW:11,
  author =	 {Stock, James H. and Watson, Mark W.},
  title =	 {Dynamic Factor Models},
  editor =	 {Michael P. Clements and David F. Hendry},
  booktitle =	 {Oxford Handbook of Economic Forecasting},
  year =	 2011,
  publisher =	 {Oxford University Press},
  chapter =	 2
}

@Article{StW:99,
  title =	 {Forecasting inflation},
  volume =	 44,
  number =	 2,
  journal =	 {Journal of Monetary Economics},
  author =	 {James H. Stock and Mark W. Watson},
  month =	 oct,
  year =	 1999,
  pages =	 {293-335}
}

@Book{StW:99b,
  author =	 {William Strunk Jr. and E.B. White},
  title =	 {The Elements of Style},
  publisher =	 {Longman},
  year =	 1999,
  edition =	 {4th}
}

@Article{StY:05,
  title =	 {Asymptotic distributions of instrumental variable
                  statistics with many weak instruments},
  journal =	 {Identification and Inference for Econometric Models:
                  Essays in Honor of Thomas J. Rothenberg},
  author =	 {James H. Stock and M. Yogo},
  year =	 2005
}

@Article{Sto:10,
  author =	 {Stock, James H.},
  title =	 {The Other Transformation in Econometric Practice:
                  Robust Tools for Inference},
  journal =	 {Journal of Economic Perspectives},
  volume =	 24,
  number =	 2,
  year =	 2010,
  pages =	 {83-94}
}

@Article{Sto:74,
  title =	 {Cross-Validatory Choice and Assessment of
                  Statistical Predictions},
  author =	 {Stone, M.},
  journal =	 {Journal of the Royal Statistical Society. Series B
                  (Methodological)},
  volume =	 36,
  number =	 2,
  pages =	 {111-147},
  year =	 1974
}

@Article{Sto:77,
  title =	 {An Asymptotic Equivalence of Choice of Model by
                  Cross-Validation and {Akaike}'s Criterion},
  author =	 {Stone, M.},
  journal =	 {Journal of the Royal Statistical Society. Series B
                  (Methodological)},
  volume =	 39,
  number =	 1,
  jstor_formatteddate =1977,
  pages =	 {44-47},
  year =	 1977
}

@manual{Tan:10,
  title =	 {{TikZ} and {PGF} Manual for version 2.10},
  author =	 {Tantau, Till},
  year =	 2010
}

@Article{Tay:80,
  title =	 {Aggregate dynamics and staggered contracts},
  volume =	 88,
  copyright =	 {Copyright 1980 The University of Chicago Press},
  number =	 1,
  journal =	 {The Journal of Political Economy},
  author =	 {John B. Taylor},
  year =	 1980,
  pages =	 {1-23}
}

@InCollection{Ter:06,
  author =	 {Timo Ter{\"a}svirta},
  title =	 {Forecasting Economic Variables with Nonlinear
                  Models},
  pages =	 {413-458},
  booktitle =	 {Handbook of Economic Forecasting},
  volume =	 1,
  editor =	 {Graham Elliott and Clive Granger and Allan
                  Timmermann},
  publisher =	 {Elsevier},
  year =	 2006
}

@Article{Ter:94,
  jstor_articletype ={research-article},
  title =	 {Specification, Estimation, and Evaluation of Smooth
                  Transition Autoregressive Models},
  author =	 {Ter{\"a}svirta, Timo},
  journal =	 {Journal of the American Statistical Association},
  volume =	 89,
  number =	 425,
  pages =	 {208-218},
  year =	 1994
}

@Book{Tho:01,
  author =	 {Thomson, William},
  title =	 {A guide for the young economist},
  publisher =	 {MIT Press},
  year =	 2001
}

@article{Tib:96,
  title =	 {Regression Shrinkage and Selection via the Lasso},
  author =	 {Tibshirani, Robert},
  journal =	 {Journal of the Royal Statistical Society. Series B
                  (Methodological)},
  volume =	 58,
  number =	 1,
  pages =	 {267-288},
  year =	 1996,
}

@article{Tim:08,
  title =	 {Elusive return predictability},
  author =	 {Timmermann, Allan},
  journal =	 {International Journal of Forecasting},
  volume =	 24,
  number =	 1,
  pages =	 {1-18},
  year =	 2008,
  publisher =	 {Elsevier}
}

@Article{ToF:04,
  title =	 {Asymptotic expansion of the null distribution of
                  {LR}-statistic for multivariate linear hypothesis
                  when the dimension is large},
  volume =	 33,
  journal =	 {Communications in Statistics - Theory and Methods},
  author =	 {Tetsuji Tonda and Yasunori Fujikoshi},
  year =	 2004,
  pages =	 1205
}

@Book{Ton:90,
  title =	 {Nonlinear Time Series Analysis: A Dynamical Systems
                  Approach},
  author =	 {Tong, H.},
  year =	 1990,
  publisher =	 {Oxford University Press}
}

@Article{TrT:92,
  author =	 {Trenkler, G. and Toutenburg, H.},
  title =	 {Pre-test procedures and forecasting in the
                  regression model under restrictions},
  journal =	 {Journal of Statistical Planning and Inference},
  year =	 1992,
  volume =	 30,
  number =	 2,
  pages =	 {249-256}
}

@Article{TrW:02,
  title =	 {Distribution functions for largest eigenvalues and
                  their applications},
  author =	 {Craig A Tracy and Harold Widom},
  month =	 oct,
  year =	 2002,
  note =	 {Proceedings of the {ICM,} Beijing 2002, vol. 1,
                  587--596}
}

@article{TrW:96,
  title =	 {On orthogonal and symplectic matrix ensembles},
  author =	 {Tracy, Craig A and Widom, Harold},
  journal =	 {Communications in Mathematical Physics},
  volume =	 177,
  number =	 3,
  pages =	 {727-754},
  year =	 1996,
}

@Article{Tsa:86,
  author =	 {Tsay, Ruey S.},
  title =	 {Nonlinearity tests for time series},
  volume =	 73,
  number =	 2,
  pages =	 {461-466},
  year =	 1986,
  journal =	 {Biometrika}
}

@Book{Tuf:06,
  title =	 {Beautiful evidence},
  author =	 {Tufte, Edward R.},
  year =	 2006,
  publisher =	 {Graphics Press}
}

@Book{Tuf:83,
  title =	 {The visual display of quantitative information},
  author =	 {Tufte, Edward R.},
  year =	 1983,
  publisher =	 {Graphics Press}
}

@Book{Tuf:90,
  title =	 {Envisioning information},
  author =	 {Tufte, Edward R.},
  year =	 1990,
  publisher =	 {Graphics Press}
}

@Book{Tuf:97,
  title =	 {Visual explanations},
  author =	 {Tufte, Edward R.},
  year =	 1997,
  publisher =	 {Graphics Press}
}

@Article{Tuk:72,
  title =	 {Some graphic and semigraphic displays},
  author =	 {Tukey, John W.},
  journal =	 {Statistical papers in honor of George W. Snedecor},
  volume =	 293,
  pages =	 316,
  year =	 1972,
  publisher =	 {Ames, Iowa: The Iowa State University Press}
}

@Book{Tuk:77,
  author =	 {John W. Tukey},
  title =	 {Exploratory Data Analysis},
  publisher =	 {Addison Wesley},
  year =	 1977
}

@Book{UCP:10,
  editor =	 {University of Chicago Press Staff},
  title =	 {The Chicago Manual of Style},
  publisher =	 {University of Chicago Press},
  year =	 2010,
  edition =	 {16th}
}

@Manual{VSR:11,
  title =	 {An Introduction to R},
  author =	 {William N. Venables and D.M. Smith and {R
                  Development Core Team}},
  url =		 {http://cran.r-project.org/doc/manuals}
}

@Book{Vaa:00,
  title =	 {Asymptotic statistics},
  author =	 {Van der Vaart, Aad W.},
  year =	 2000,
  publisher =	 {Cambridge University Press}
}

@Book{VeR:00,
  author =	 {William N. Venables and Brian D. Ripley},
  title =	 {S-Programming},
  publisher =	 {Springer},
  year =	 2000
}

@Book{VeR:02,
  title =	 {Modern Applied Statistics with S},
  author =	 {William N. Venables and Brian D. Ripley},
  publisher =	 {Springer},
  edition =	 {4th},
  address =	 {New York},
  year =	 2002
}

@Article{WaA:06,
  title =	 {Two-way heteroscedastic {ANOVA} when the number of
                  levels is large},
  volume =	 16,
  journal =	 {Statistica Sinica},
  author =	 {L. Wang and M.G. Akritas},
  year =	 2006,
  pages =	 1387
}

@Book{Wai:00,
  title =	 {Visual revelations: Graphical tales of fate and
                  deception from Napoleon Bonaparte to Ross Perot},
  author =	 {Wainer, Howard},
  year =	 2000,
  publisher =	 {Psychology Press}
}

@Book{Wai:05,
  title =	 {Graphic discovery: A trout in the milk and other
                  visual adventures},
  author =	 {Wainer, Howard},
  year =	 2005,
  publisher =	 {Princeton University Press}
}

@Book{Wai:09,
  title =	 {Picturing the uncertain world: how to understand,
                  communicate, and control uncertainty through
                  graphical display},
  author =	 {Wainer, Howard},
  year =	 2009,
  publisher =	 {Princeton University Press}
}

@Article{WeM:98,
  title =	 {Regression-Based Tests of Predictive Ability},
  author =	 {West, Kenneth D. and McCracken, Michael W.},
  journal =	 {International Economic Review},
  volume =	 39,
  number =	 4,
  pages =	 {817-840},
  year =	 1998
}

@Book{WeY:93,
  title =	 {Resampling-based multiple testing: Examples and
                  methods for $p$-value adjustment},
  author =	 {Westfall, Peter H. and Young, S. Stanley},
  volume =	 279,
  year =	 1993,
  series =	 {Wiley series in probability and mathematical
                  statistics},
  publisher =	 {Wiley-Interscience}
}

@Article{Wel:89,
  title =	 {On {$M$-processes} and {$M$-estimation}},
  volume =	 17,
  journal =	 {The Annals of Statistics},
  author =	 {A.H. Welsh},
  month =	 mar,
  year =	 1989,
  pages =	 {337-361}
}

@InCollection{Wes:06,
  title =	 {Forecast Evaluation},
  author =	 {Kenneth D. West},
  pages =	 {99-134},
  booktitle =	 {Handbook of Economic Forecasting},
  volume =	 1,
  editor =	 {Graham Elliott and Clive Granger and Allan
                  Timmermann},
  publisher =	 {Elsevier},
  year =	 2006
}

@Article{Wes:96,
  title =	 {Asymptotic inference about predictive ability},
  volume =	 64,
  number =	 5,
  journal =	 {Econometrica},
  author =	 {Kenneth D. West},
  month =	 sep,
  year =	 1996,
  pages =	 {1067-1084}
}

@Article{Whi:00,
  title =	 {A reality check for data snooping},
  volume =	 68,
  number =	 5,
  journal =	 {Econometrica},
  author =	 {Halbert White},
  year =	 2000,
  pages =	 {1097-1126}
}

@Book{Whi:00b,
  title =	 {Asymptotic theory for econometricians},
  publisher =	 {Academic Press},
  author =	 {Halbert White},
  edition =	 {2nd},
  year =	 2000
}

@Article{Whi:80,
  title =	 {A Heteroskedasticity-Consistent Covariance Matrix
                  Estimator and a Direct Test for Heteroskedasticity},
  author =	 {White, Halbert},
  journal =	 {Econometrica},
  volume =	 48,
  number =	 4,
  pages =	 {817-838},
  year =	 1980,
  publisher =	 {The Econometric Society}
}

@Book{WiC:10,
  author =	 {Joseph M. Williams and Gregory G. Colomb},
  title =	 {Style: The basics of clarity and grace},
  publisher =	 {Longman},
  year =	 2010,
  edition =	 {4th}
}

@Book{WiC:10b,
  author =	 {Joseph M. Williams and Gregory G. Colomb},
  title =	 {Style: Lessons in clarity and grace},
  publisher =	 {Longman},
  year =	 2010,
  edition =	 {10th}
}

@Misc{Wic:10c,
  author =	 {Hadley Wickham},
  title =	 {R style guide},
  howpublished = {Website},
  note =	 {https://github.com/hadley/devtools/wiki/ Style},
  year =	 {6 Nov. 2010}
}

@Article{WoW:88,
  title =	 {Some Invariance Principles and Central Limit
                  Theorems for Dependent Heterogeneous Processes},
  author =	 {Wooldridge, Jeffrey M. and White, Halbert},
  journal =	 {Econometric Theory},
  volume =	 4,
  number =	 2,
  pages =	 {210-230},
  year =	 1988
}

@Article{Wol:87,
  author =	 {Frank A. Wolak},
  title =	 {An exact test for multiple inequality and equality
                  constraints in the linear regression model},
  journal =	 {Journal of the American Statistical Association},
  year =	 1987,
  volume =	 82,
  number =	 399,
  pages =	 {782-793},
}

@Article{Wol:89,
  author =	 {Frank A. Wolak},
  title =	 {Testing inequality constraints in linear econometric
                  models},
  journal =	 {Journal of Econometrics},
  year =	 1989,
  volume =	 41,
  number =	 2,
  pages =	 {205-235},
}

@Article{Wol:89b,
  title =	 {Local and Global Testing of Linear and Nonlinear
                  Inequality Constraints in Nonlinear Econometric
                  Models},
  author =	 {Wolak, Frank A.},
  journal =	 {Econometric Theory},
  volume =	 5,
  number =	 1,
  pages =	 {1-35},
  year =	 1989
}

@Article{Wol:91,
  title =	 {The Local Nature of Hypothesis Tests Involving
                  Inequality Constraints in Nonlinear Models},
  author =	 {Wolak, Frank A.},
  journal =	 {Econometrica},
  volume =	 59,
  number =	 4,
  pages =	 {981-995},
  year =	 1991
}

@Article{Wri:08,
  title =	 {Bayesian model averaging and exchange rate
                  forecasts},
  volume =	 146,
  number =	 2,
  journal =	 {Journal of Econometrics},
  author =	 {Jonathan H. Wright},
  month =	 oct,
  year =	 2008,
  keywords =	 {{Bootstrap,Exchange} {rates,Forecasting,Model}
                  {uncertainty,Shrinkage}},
  pages =	 {329-341}
}

@Article{Yin:86,
  title =	 {{LSD'} for a class of random matrices},
  volume =	 20,
  journal =	 {Journal of Multivariate Analysis},
  author =	 {Yong Q. Yin},
  year =	 1986,
  pages =	 {50-68}
}

@Article{YoM:79,
  title =	 {Asymptotic behavior of {$M$}-estimators for the
                  linear model},
  volume =	 7,
  journal =	 {The Annals of Statistics},
  author =	 {Victor J. Yohai and Ricardo A. Maronna},
  month =	 mar,
  year =	 1979,
  pages =	 {258-268}
}

@Article{Zab:79,
  title =	 {Continous versions of regular conditional
                  distributions},
  volume =	 7,
  number =	 1,
  journal =	 {The Annals of Probability},
  author =	 {Sandy L. Zabell},
  month =	 feb,
  year =	 1979,
  pages =	 {159-165}
}

@Article{Zab:80,
  title =	 {Rates of convergence for conditional expectations},
  volume =	 8,
  number =	 5,
  journal =	 {The Annals of Probability},
  author =	 {Sandy L. Zabell},
  month =	 oct,
  year =	 1980,
  pages =	 {928-941}
}

@Article{Zab:93,
  title =	 {A limit theorem for expectations conditional on a
                  sum},
  volume =	 6,
  number =	 2,
  journal =	 {Journal of Theoretical Probability},
  author =	 {Sandy L. Zabell},
  year =	 1993,
  pages =	 {267-283}
}

@Article{ZeH:02,
  title =	 {Diagnostic Checking in Regression Relationships},
  author =	 {Achim Zeileis and Torsten Hothorn},
  journal =	 {R News},
  year =	 2002,
  volume =	 2,
  number =	 3,
  pages =	 {7-10}
}

@Article{Zei:04,
  title =	 {Econometric Computing with {HC} and {HAC} Covariance
                  Matrix Estimators},
  author =	 {Achim Zeileis},
  year =	 2004,
  journal =	 {Journal of Statistical Software},
  volume =	 11,
  number =	 10,
  pages =	 {1-17}
}

license: MIT

license_type: permissive

branch_name: refs/heads/master

extension: bib


text:
@article{Eilander2023,
    doi = {10.21105/joss.04897},
    url = {https://doi.org/10.21105/joss.04897},
    year = {2023},
    publisher = {The Open Journal},
    volume = {8},
    number = {83},
    pages = {4897},
    author = {Dirk Eilander and Hélène Boisgontier and Laurène J. E. Bouaziz and Joost Buitink and Anaïs Couasnon and Brendan Dalmijn and Mark Hegnauer and Tjalling de Jong and Sibren Loos and Indra Marth and Willem van Verseveld},
    title = {HydroMT: Automated and reproducible model building and analysis},
    journal = {Journal of Open Source Software}
}

repository: Deltares/hydromt

repo_name: Deltares/hydromt

branch_name: refs/heads/main

gha_license_id: MIT

gha_language: Python


text:
package telegram

import (
	"fmt"

	"github.com/containrrr/shoutrrr"
	"github.com/pkg/errors"
	"github.com/projectdiscovery/gologger"
	"github.com/projectdiscovery/notify/pkg/utils"
	"go.uber.org/multierr"
)

type Provider struct {
	Telegram []*Options `yaml:"telegram,omitempty"`
}

type Options struct {
	ID             string `yaml:"id,omitempty"`
	TelegramAPIKey string `yaml:"telegram_api_key,omitempty"`
	TelegramChatID string `yaml:"telegram_chat_id,omitempty"`
	TelegramFormat string `yaml:"telegram_format,omitempty"`
}

func New(options []*Options, ids []string) (*Provider, error) {
	provider := &Provider{}

	for _, o := range options {
		if len(ids) == 0 || utils.Contains(ids, o.ID) {
			provider.Telegram = append(provider.Telegram, o)
		}
	}

	return provider, nil
}

func (p *Provider) Send(message, CliFormat string) error {
	var TelegramErr error
	for _, pr := range p.Telegram {
		msg := utils.FormatMessage(message, utils.SelectFormat(CliFormat, pr.TelegramFormat))

		url := fmt.Sprintf("telegram://%s@telegram?channels=%s", pr.TelegramAPIKey, pr.TelegramChatID)
		err := shoutrrr.Send(url, msg)
		if err != nil {
			err = errors.Wrap(err, fmt.Sprintf("failed to send telegram notification for id: %s ", pr.ID))
			TelegramErr = multierr.Append(TelegramErr, err)
			continue
		}
		gologger.Verbose().Msgf("telegram notification sent for id: %s", pr.ID)
	}
	return TelegramErr
}

repository: IlluminatiFish/notify

repo_name: IlluminatiFish/notify

extension: go


text:
package main

import (
	"fmt"
)

func main() {
	var x, y int
	for {
		fmt.Scan(&x, &y)
		if x == 0 || y == 0 {
			break
		}
		if x > 0 && y > 0 {
			fmt.Println("primeiro")
		}else if x > 0 && y < 0 {
			fmt.Println("quarto")
		}else if x < 0 && y > 0 {
			fmt.Println("segundo")
		}else if x < 0 && y < 0 {
			fmt.Println("terceiro")
		}
	}
}


text:
package repository

import (
	"context"
	"fmt"
	"io/ioutil"
	"os"
	"path/filepath"
	"testing"

	"github.com/colinmarc/hdfs"
	"github.com/stretchr/testify/require"
	"github.com/stretchr/testify/suite"
	"gopkg.in/src-d/go-billy.v4"
	"gopkg.in/src-d/go-billy.v4/memfs"
	"gopkg.in/src-d/go-billy.v4/osfs"
	"gopkg.in/src-d/go-git-fixtures.v3"
	"gopkg.in/src-d/go-git.v4"
	"gopkg.in/src-d/go-git.v4/config"
	"gopkg.in/src-d/go-git.v4/plumbing"
	"gopkg.in/src-d/go-git.v4/plumbing/cache"
	"gopkg.in/src-d/go-git.v4/plumbing/object"
)

const (
	tmpPrefix = "core-retrieval-test"
	hdfsURL   = "localhost:9000"
)

var (
	h1 = plumbing.NewHash("0000000000000000000000000000000000000001")
)

func TestFilesystemSuite(t *testing.T) {
	suite.Run(t, &FilesystemSuite{})
}

type FilesystemSuite struct {
	suite.Suite
	tmpDirs map[string]bool
}

func (s *FilesystemSuite) SetupTest() {
	s.NoError(fixtures.Init())
	s.tmpDirs = make(map[string]bool)
}

func (s *FilesystemSuite) TearDownTest() {
	hc, err := hdfs.New(hdfsURL)
	s.NoError(err)
	err = hc.Remove("/")
	s.NoError(err)

	s.cleanUpTempDirectories()
	s.NoError(fixtures.Clean())
}

func (s *FilesystemSuite) cleanUpTempDirectories() {
	require := require.New(s.T())
	var err error
	for dir := range s.tmpDirs {
		if e := os.RemoveAll(dir); e != nil && err != nil {
			err = e
		}

		delete(s.tmpDirs, dir)
	}

	require.NoError(err)
}

func (s *FilesystemSuite) getPairs() []*fsPair {
	return []*fsPair{
		{
			"mem to mem",
			NewCopier(memfs.New(), NewLocalFs(memfs.New()), 0),
		},
		{
			"mem to os",
			NewCopier(s.newFilesystem(), NewLocalFs(memfs.New()), 0),
		},
		{
			"os to mem",
			NewCopier(s.newFilesystem(), NewLocalFs(memfs.New()), 0),
		},
		{
			"os to os",
			NewCopier(s.newFilesystem(), NewLocalFs(s.newFilesystem()), 0),
		},
		{
			"os to HDFS",
			NewCopier(s.newFilesystem(), NewHDFSFs(hdfsURL, s.newTempPath()), 0),
		},
		{
			"mem to HDFS",
			NewCopier(memfs.New(), NewHDFSFs(hdfsURL, s.newTempPath()), 0),
		},

		{
			"mem to mem with bucketing",
			NewCopier(memfs.New(), NewLocalFs(memfs.New()), 2),
		},
		{
			"mem to os with bucketing",
			NewCopier(s.newFilesystem(), NewLocalFs(memfs.New()), 2),
		},
		{
			"os to mem with bucketing",
			NewCopier(s.newFilesystem(), NewLocalFs(memfs.New()), 2),
		},
		{
			"os to os with bucketing",
			NewCopier(s.newFilesystem(), NewLocalFs(s.newFilesystem()), 2),
		},
		{
			"os to HDFS with bucketing",
			NewCopier(s.newFilesystem(), NewHDFSFs(hdfsURL, s.newTempPath()), 2),
		},
		{
			"mem to HDFS with bucketing",
			NewCopier(memfs.New(), NewHDFSFs(hdfsURL, s.newTempPath()), 2),
		},
	}
}

func (s *FilesystemSuite) Test() {
	fsPairs := s.getPairs()

	for _, fsPair := range fsPairs {
		s.T().Run(fsPair.Name, func(t *testing.T) {
			testRootedTransactioner(t, NewSivaRootedTransactioner(fsPair.Copier))
		})

		s.T().Run(fmt.Sprintf("%s with real repository", fsPair.Name), func(t *testing.T) {
			testWithRealRepository(t, NewSivaRootedTransactioner(fsPair.Copier))
		})
	}
}

func (s *FilesystemSuite) TestWithCache() {
	fsPairs := s.getPairs()

	for _, fsPair := range fsPairs {
		c := cache.NewObjectLRU(16 * cache.MiByte)
		s.T().Run(fmt.Sprintf("%s with cache", fsPair.Name), func(t *testing.T) {
			testRootedTransactioner(t, NewSivaRootedTransactionerWithCache(fsPair.Copier, c))
		})

		c = cache.NewObjectLRU(16 * cache.MiByte)
		s.T().Run(fmt.Sprintf("%s with real repository and cache", fsPair.Name), func(t *testing.T) {
			testWithRealRepository(t, NewSivaRootedTransactionerWithCache(fsPair.Copier, c))
		})
	}
}

func (s *FilesystemSuite) newFilesystem() billy.Filesystem {
	tmpDir := s.newTempPath()
	s.tmpDirs[tmpDir] = true
	return osfs.New(tmpDir)
}

func (s *FilesystemSuite) newTempPath() string {
	tmpDir, err := ioutil.TempDir(os.TempDir(), tmpPrefix)
	s.NoError(err)
	return tmpDir
}

func testWithRealRepository(t *testing.T, s RootedTransactioner) {
	require := require.New(t)

	f := fixtures.Basic().ByTag("worktree").One()

	rTest, err := git.PlainOpen(f.Worktree().Root())
	require.NoError(err)

	oIterTest, err := rTest.CommitObjects()
	require.NoError(err)

	countTest := 0
	err = oIterTest.ForEach(func(o *object.Commit) error {
		countTest++
		return nil
	})
	require.NoError(err)
	require.NotEqual(0, countTest)

	tx, err := s.Begin(context.TODO(), f.Head)
	require.NoError(err)

	r, err := git.Open(tx.Storer(), nil)
	require.NoError(err)
	_, err = r.CreateRemote(&config.RemoteConfig{
		URLs: []string{f.Worktree().Root()},
		Name: git.DefaultRemoteName,
	})
	require.NoError(err)

	err = r.Fetch(&git.FetchOptions{
		RefSpecs: []config.RefSpec{config.RefSpec("+refs/heads/*:refs/heads/*")},
	})
	require.NoError(err)

	cIter, err := r.CommitObjects()
	require.NoError(err)

	count := 0
	err = cIter.ForEach(func(o *object.Commit) error {
		count++
		return nil
	})
	require.NoError(err)
	require.NotEqual(0, count)

	err = tx.Commit(context.TODO())
	require.NoError(err)

	tx2, err := s.Begin(context.TODO(), f.Head)
	require.NoError(err)

	r, err = git.Open(tx2.Storer(), nil)
	require.NoError(err)

	cIter, err = r.CommitObjects()
	require.NoError(err)

	count2 := 0
	err = cIter.ForEach(func(o *object.Commit) error {
		count2++
		return nil
	})
	require.NoError(err)
	require.NotEqual(0, count)

	require.Equal(count, count2)
	err = tx2.Rollback()
	require.NoError(err)
}

func testRootedTransactioner(t *testing.T, s RootedTransactioner) {
	require := require.New(t)

	// begin tx1
	tx1, err := s.Begin(context.TODO(), h1)
	require.NoError(err)
	require.NotNil(tx1)
	r1, err := git.Open(tx1.Storer(), nil)
	require.NoError(err)

	// tx1 -> create ref1
	refName1 := plumbing.ReferenceName("ref1")
	err = r1.Storer.SetReference(plumbing.NewSymbolicReference(refName1, refName1))
	require.NoError(err)

	// begin tx2
	tx2, err := s.Begin(context.TODO(), h1)
	require.NoError(err)
	require.NotNil(tx2)
	r2, err := git.Open(tx2.Storer(), nil)
	require.NoError(err)

	// ref1 not visible in tx2
	_, err = r2.Reference(refName1, false)
	require.Equal(plumbing.ErrReferenceNotFound, err)

	// tx2 -> create ref2
	refName2 := plumbing.ReferenceName("ref2")
	err = r2.Storer.SetReference(plumbing.NewSymbolicReference(refName2, refName2))
	require.NoError(err)

	// ref2 not visible in tx2
	_, err = r1.Reference(refName2, false)
	require.Equal(plumbing.ErrReferenceNotFound, err)

	// commit tx1
	err = tx1.Commit(context.TODO())
	require.NoError(err)

	// ref1 not visible in tx2 (even with tx1 committed)
	_, err = r2.Reference(refName1, false)
	require.Equal(plumbing.ErrReferenceNotFound, err)

	// rollback tx2
	err = tx2.Rollback()
	require.NoError(err)

	// begin tx3
	tx3, err := s.Begin(context.TODO(), h1)
	require.NoError(err)
	require.NotNil(tx3)
	r3, err := git.Open(tx3.Storer(), nil)
	require.NoError(err)

	// ref1 visible in tx3
	_, err = r3.Reference(refName1, false)
	require.NoError(err)
	require.NoError(tx3.Rollback())

	// begin tx4
	tx4, err := s.Begin(context.TODO(), h1)
	require.NoError(err)
	require.NotNil(tx4)
	r4, err := git.Open(tx4.Storer(), nil)
	require.NoError(err)

	// tx4 -> create ref4
	refName4 := plumbing.ReferenceName("ref4")
	err = r4.Storer.SetReference(plumbing.NewSymbolicReference(refName4, refName4))
	require.NoError(err)

	// commit tx4
	err = tx4.Commit(context.TODO())
	require.NoError(err)
}

type fsPair struct {
	Name   string
	Copier *Copier
}

func (s *FilesystemSuite) TestRepositoryTmpDeletion() {
	require := require.New(s.T())

	sivaFiles := s.newFilesystem()
	require.NotNil(sivaFiles)

	sivaFiles = &BrokenFS{
		Filesystem: sivaFiles,
	}

	tmpFiles := s.newFilesystem()
	require.NotNil(tmpFiles)

	tmpFiles = &BrokenFS{
		Filesystem: tmpFiles,
	}

	copier := NewCopier(tmpFiles, NewLocalFs(sivaFiles), 0)
	require.NotNil(copier)

	repo := NewSivaRootedTransactioner(copier)
	require.NotNil(repo)

	permissionsHex := "0000000000000000000000000000000000000001"
	brokenHex := "0000000000000000000000000000000000000002"

	require.NoError(createSiva(sivaFiles, permissionsHex, 0))
	testTmpDeletion(require, tmpFiles, repo, permissionsHex)

	require.NoError(createSiva(sivaFiles, brokenHex, 0444))
	testTmpDeletion(require, tmpFiles, repo, brokenHex)
}

func testTmpDeletion(
	require *require.Assertions,
	tmpFiles billy.Filesystem,
	repo RootedTransactioner,
	hash string,
) {
	tx, err := repo.Begin(context.TODO(), plumbing.NewHash(hash))
	require.Error(err)
	require.Nil(tx)

	files, err := tmpFiles.ReadDir("/")
	require.NoError(err)
	require.Len(files, 0)
}

func createSiva(tmpFS billy.Filesystem, name string, mode os.FileMode) error {
	fileName := fmt.Sprintf("%s.siva", name)
	file, err := tmpFS.Create(fileName)
	if err != nil {
		return err
	}

	_, err = file.Write([]byte("invalid siva contents"))
	file.Close()

	if err != nil {
		return err
	}

	// tmp dir does not have Change interface
	fullPath := filepath.Join(tmpFS.Root(), fileName)
	return os.Chmod(fullPath, mode)
}

func NewBrokenFS(fs billy.Filesystem) billy.Filesystem {
	return &BrokenFS{
		Filesystem: fs,
	}
}

type BrokenFS struct {
	billy.Filesystem
}

func (fs *BrokenFS) OpenFile(
	name string,
	flag int,
	perm os.FileMode,
) (billy.File, error) {
	file, err := fs.Filesystem.OpenFile(name, flag, perm)
	if err != nil {
		return nil, err
	}

	return &BrokenFile{
		File: file,
	}, nil
}

type BrokenFile struct {
	billy.File
}

func (fs *BrokenFile) Read(p []byte) (int, error) {
	return 0, fmt.Errorf("could not read from broken file")
}

func (fs *BrokenFile) Write(p []byte) (int, error) {
	return 0, fmt.Errorf("could not write to broken file")
}


text:
package main

import (
	"bytes"
	"crypto/tls"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"time"

	"github.com/urfave/cli"
	"errors"
)

//configuration params
var (
	gdKey            string
	gdSecret         string
	gdDomain         string
	gdRecord         string
	gdRecordType     string
	gdRecordTTL      int
	gdDaemon         bool
	gdUpdateInterval int
)

func main() {
	app := cli.NewApp()
	app.Name = "nulldaddy-ddns"
	app.Version = "0.0.1"

	app.Usage = "Poor man's DDNS!"
	app.UsageText = "nulldaddy-ddns [global options] (mode)"
	app.Author = "Ioannis Polyzos <i.polyzos@null-box.org>"

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "key, k",
			Usage:       "The developer's 'KEY'.",
			EnvVar:      "GODADDY_KEY",
			Destination: &gdKey,
		},
		cli.StringFlag{
			Name:        "secret, s",
			Usage:       "The developer's 'SECRET'.",
			EnvVar:      "GODADDY_SERCRET",
			Destination: &gdSecret,
		},
		cli.StringFlag{
			Name:        "domain, dn",
			Usage:       "The 'DOMAIN' you would like to update.",
			EnvVar:      "GODADDY_DOMAIN",
			Destination: &gdDomain,
		},
		cli.StringFlag{
			Name:        "record, r",
			Usage:       "The domain 'RECORD' you would like to update.",
			EnvVar:      "GODADDY_RECORD",
			Destination: &gdRecord,
		},
		cli.StringFlag{
			Name:        "record-type, t",
			Value:       "A",
			Usage:       "The 'TYPE' of domain record you would like to update.",
			EnvVar:      "GODADDY_RECORD_TYPE",
			Destination: &gdRecordType,
		},
		cli.IntFlag{
			Name:        "record-ttl, tt",
			Value:       600,
			Usage:       "The 'TTL' of domain record you would like to update.",
			EnvVar:      "GODADDY_RECORD_TTL",
			Destination: &gdRecordTTL,
		},
		cli.BoolFlag{
			Name:        "daemon, d",
			Usage:       "Run godaddy-dns as a'DAEMON'.",
			EnvVar:      "NULLDADDY_DAEMON",
			Destination: &gdDaemon,
		},
		cli.IntFlag{
			Name:        "interval, i",
			Value:       1800,
			Usage:       "The 'INTERVAL' between update in sec.",
			EnvVar:      "NULLDADDY_INTERVAL",
			Destination: &gdUpdateInterval,
		},
	}

	app.Action = func(c *cli.Context) error {

		if gdDaemon {
			log.Println("- Daemon mode enabled.")
		}

		//update domain
		updateDomainRecord(gdKey, gdSecret, gdDomain, gdRecordType, gdRecord)

		//if daemon mode enabled
		if gdDaemon {
			// keep to update the domain periodically
			interval := time.Duration(gdUpdateInterval)
			for range time.Tick(time.Second * interval) {
				updateDomainRecord(gdKey, gdSecret, gdDomain, gdRecordType, gdRecord)
			}
		}
		return nil
	}

	app.Run(os.Args)
}

// update domain record with the new IP address
func updateDomainRecord(gdKey string, gdSecret string, gdDomain string, gdRecordType string, gdRecord string) {
	//get current external IP address
	ip, err := discoverExternalIp()
	if err != nil {
		panic(err.Error())
	}

	//update record
	err = updateRecord(ip)
	if err != nil {
		panic(err.Error())
	}

	log.Printf("- record updated.")

}

//discover current external IP address
func discoverExternalIp() (ip string, err error) {
	ret := &IPAddr{}

	// use ipify.org API to retrieve IP addr
	url := "https://api.ipify.org?format=json"

	var netClient = &http.Client{
		Timeout: time.Second * 10,
	}

	response, _ := netClient.Get(url)

	// read body
	body, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return
	}

	//unmarshal response to return object
	err = json.Unmarshal(body, &ret)
	if err != nil {
		return
	}

	return ret.IP, nil
}

func updateRecord(ip string) error {
	//initiate request data
	ru := &RecordUpdate{
		Data: ip,
		TTL:  gdRecordTTL,
	}

	//marshall record update data
	recordUpdate, err := json.Marshal(ru)
	if err != nil {
		return err
	}

	//create custom transport for httpclient
	transport := &http.Transport{
		///ignore ssl verify
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}

	//instatiate http client
	var netClient = &http.Client{
		Timeout:   time.Second * 10,
		Transport: transport,
	}

	//format godaddy rest api url
	url := fmt.Sprintf("https://api.godaddy.com/v1/domains/%v/records/%v/%v", gdDomain, gdRecordType, gdRecord)

	// create request
	request, err := http.NewRequest("PUT", url, bytes.NewReader(recordUpdate))
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Authorization", fmt.Sprintf("sso-key %v:%v", gdKey, gdSecret))

	response, err := netClient.Do(request)
	if err != nil {
		return err
	}

	if response.StatusCode != 200 {
		return errors.New(response.Status)
	}

	return nil
}

repository: ipolyzos/nulldaddy-ddns

repo_name: ipolyzos/nulldaddy-ddns


text:
package resources

import (
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/ssm"
)

type SSMResourceDataSync struct {
	svc  *ssm.SSM
	name *string
}

func init() {
	register("SSMResourceDataSync", ListSSMResourceDataSyncs)
}

func ListSSMResourceDataSyncs(sess *session.Session) ([]Resource, error) {
	svc := ssm.New(sess)
	resources := []Resource{}

	params := &ssm.ListResourceDataSyncInput{
		MaxResults: aws.Int64(50),
	}

	for {
		output, err := svc.ListResourceDataSync(params)
		if err != nil {
			return nil, err
		}

		for _, resourceDataSyncItem := range output.ResourceDataSyncItems {
			resources = append(resources, &SSMResourceDataSync{
				svc:  svc,
				name: resourceDataSyncItem.SyncName,
			})
		}

		if output.NextToken == nil {
			break
		}

		params.NextToken = output.NextToken
	}

	return resources, nil
}

func (f *SSMResourceDataSync) Remove() error {

	_, err := f.svc.DeleteResourceDataSync(&ssm.DeleteResourceDataSyncInput{
		SyncName: f.name,
	})

	return err
}

func (f *SSMResourceDataSync) String() string {
	return *f.name
}

repository: rebuy-de/aws-nuke

repo_name: rebuy-de/aws-nuke

gha_language: Go


text:
package kde

import "github.com/go-playground/universal-translator"

var calendar = ut.Calendar{Formats: ut.CalendarFormats{Date: ut.CalendarDateFormat{Full: "EEEE, d MMMM y", Long: "d MMMM y", Medium: "d MMM y", Short: "dd/MM/y"}, Time: ut.CalendarDateFormat{Full: "HH:mm:ss zzzz", Long: "HH:mm:ss z", Medium: "HH:mm:ss", Short: "HH:mm"}, DateTime: ut.CalendarDateFormat{Full: "", Long: "", Medium: "", Short: ""}}, FormatNames: ut.CalendarFormatNames{Months: ut.CalendarMonthFormatNames{Abbreviated: ut.CalendarMonthFormatNameValue{7: "Jul", 8: "Ago", 12: "Des", 1: "Jan", 2: "Feb", 3: "Mac", 4: "Apr", 11: "Nov", 5: "Mei", 6: "Jun", 9: "Sep", 10: "Okt"}, Narrow: ut.CalendarMonthFormatNameValue{7: "J", 8: "A", 1: "J", 2: "F", 3: "M", 4: "A", 5: "M", 6: "J", 11: "N", 12: "D", 9: "S", 10: "O"}, Short: ut.CalendarMonthFormatNameValue(nil), Wide: ut.CalendarMonthFormatNameValue{6: "Mwedi wa Nnyano na Umo", 11: "Mwedi wa Nnyano na Nnyano na U", 2: "Mwedi wa Pili", 5: "Mwedi wa Nnyano", 4: "Mwedi wa Nchechi", 7: "Mwedi wa Nnyano na Mivili", 8: "Mwedi wa Nnyano na Mitatu", 9: "Mwedi wa Nnyano na Nchechi", 10: "Mwedi wa Nnyano na Nnyano", 12: "Mwedi wa Nnyano na Nnyano na M", 1: "Mwedi Ntandi", 3: "Mwedi wa Tatu"}}, Days: ut.CalendarDayFormatNames{Abbreviated: ut.CalendarDayFormatNameValue{5: "Ll7", 6: "Ll1", 0: "Ll2", 1: "Ll3", 2: "Ll4", 3: "Ll5", 4: "Ll6"}, Narrow: ut.CalendarDayFormatNameValue{2: "4", 3: "5", 4: "6", 5: "7", 6: "1", 0: "2", 1: "3"}, Short: ut.CalendarDayFormatNameValue(nil), Wide: ut.CalendarDayFormatNameValue{4: "Liduva lyannyano na linji", 5: "Liduva lyannyano na mavili", 6: "Liduva litandi", 0: "Liduva lyapili", 1: "Liduva lyatatu", 2: "Liduva lyanchechi", 3: "Liduva lyannyano"}}, Periods: ut.CalendarPeriodFormatNames{Abbreviated: ut.CalendarPeriodFormatNameValue(nil), Narrow: ut.CalendarPeriodFormatNameValue(nil), Short: ut.CalendarPeriodFormatNameValue(nil), Wide: ut.CalendarPeriodFormatNameValue{"am": "Muhi", "pm": "Chilo"}}}}


text:
PLUGIN_NAME = "evolution2"

require libopensync-plugin.inc
require libopensync-plugin_0.22.inc

DEPENDS += " eds-dbus"

SRC_URI[md5sum] = "c4419dd2451bd1595fe42fcf96a9ba45"
SRC_URI[sha256sum] = "2a309178a1aafaa147b792502a241e0036889e2f4153065a10313e7db3c26e65"

repository: overo/overo-oe-natty

repo_name: overo/overo-oe-natty

branch_name: HEAD

extension: bb


text:
SUMMARY = "HTTP based time synchronization tool"
DESCRIPTION = "The  HTTP Time Protocol (HTP) is used to synchronize a computer's time with\
 web servers as reference time source. This program can be used instead\
 ntpdate or similar, in networks that has a firewall blocking the NTP port.\
 Htpdate will synchronize the computer time to Greenwich Mean Time (GMT),\
 using the timestamps from HTTP headers found in web servers response (the\
 HEAD method will be used to get the information).\
 Htpdate works through proxy servers. Accuracy of htpdate will be usually\
 within 0.5 seconds (better with multiple servers).\
"
HOMEPAGE = "https://github.com/twekkel/htpdate"
BUGTRACKER = "https://github.com/twekkel/htpdate/issues"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://htpdate.c;beginline=26;endline=30;md5=2b6cdb94bd5349646d7e33f9f501eef7"

SRC_URI = "http://www.vervest.org/htp/archive/c/htpdate-${PV}.tar.gz"
SRC_URI[sha256sum] = "88c52fe475308ee95f560fd7cf68c75bc6e9a6abf56be7fed203a7f762fe7ab2"

TARGET_CC_ARCH += "${LDFLAGS}"

do_configure () {
	:
}

do_compile () {
	oe_runmake
}

do_install () {
	oe_runmake install 'INSTALL=install' 'STRIP=echo' 'DESTDIR=${D}'
}

repository: openembedded/meta-openembedded

repo_name: openembedded/meta-openembedded

gha_language: BitBake


text:
package core

import (
	"testing"

	"github.com/stretchr/testify/require"

	"github.com/heedy/pipescript"
)

func TestRand(t *testing.T) {
	s, err := pipescript.Parse("rand")
	require.NoError(t, err)

	iter := &pipescript.SingleDatapointIterator{}

	s.SetInput(iter)
	iter.Set(&pipescript.Datapoint{Timestamp: 1, Data: 1}, nil)

	v1, err := s.Next()
	require.NoError(t, err)
	v2, err := s.Next()
	require.NoError(t, err)

	v1f, err := v1.Float()
	require.NoError(t, err)
	v2f, err := v2.Float()
	require.NoError(t, err)

	require.True(t, v1f != v2f)
}


text:
package network

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func ListFirewallPolicyIdpsSignature(ctx *pulumi.Context, args *ListFirewallPolicyIdpsSignatureArgs, opts ...pulumi.InvokeOption) (*ListFirewallPolicyIdpsSignatureResult, error) {
	var rv ListFirewallPolicyIdpsSignatureResult
	err := ctx.Invoke("azure-native:network:listFirewallPolicyIdpsSignature", args, &rv, opts...)
	if err != nil {
		return nil, err
	}
	return &rv, nil
}

type ListFirewallPolicyIdpsSignatureArgs struct {
	Filters            []FilterItems `pulumi:"filters"`
	FirewallPolicyName string        `pulumi:"firewallPolicyName"`
	OrderBy            *OrderBy      `pulumi:"orderBy"`
	ResourceGroupName  string        `pulumi:"resourceGroupName"`
	ResultsPerPage     *int          `pulumi:"resultsPerPage"`
	Search             *string       `pulumi:"search"`
	Skip               *int          `pulumi:"skip"`
}

type ListFirewallPolicyIdpsSignatureResult struct {
	MatchingRecordsCount *float64                    `pulumi:"matchingRecordsCount"`
	Signatures           []SingleQueryResultResponse `pulumi:"signatures"`
}

repository: bpkgoud/pulumi-azure-native

repo_name: bpkgoud/pulumi-azure-native


text:
@article{_1__2007,
 author = {段志贵, 顾翠红},
 journal = {现代中小学教育},
 shorttitle = {学生发展},
 title = {学生发展: 课堂教学行动指南},
 volume = {12},
 year = {2007}
}

repository: Duckkkky/starter-academic

repo_name: Duckkkky/starter-academic


text:
package hot_fix

import (
	"errors"
	"fmt"
	"github.com/allanpk716/ChineseSubFinder/internal/dao"
	"github.com/allanpk716/ChineseSubFinder/internal/ifaces"
	"github.com/allanpk716/ChineseSubFinder/internal/models"
	"github.com/allanpk716/ChineseSubFinder/internal/pkg/log_helper"
	"github.com/allanpk716/ChineseSubFinder/internal/types"
)

// HotFixProcess 去 DB 中查询 Hotfix 的标记，看有那些需要修复，那些已经修复完毕
func HotFixProcess(param types.HotFixParam) error {

	// -----------------------------------------------------------------------
	// 一共有多少个 HotFix 要修复，需要固定下来
	hotfixCases := []ifaces.IHotFix{
		NewHotFix001(param.MovieRootDir, param.SeriesRootDir),
	}
	// -----------------------------------------------------------------------
	// 找现在有多少个 hotfix 执行过了
	var hotFixes []models.HotFix
	result := dao.GetDb().Find(&hotFixes)
	if result.Error != nil {
		return errors.New(fmt.Sprintf("hotfix query all result failed, %s", result.Error))
	}
	// 数据库中是否有记录，记录了是否有运行都需要判断
	var hotFixRecord = make(map[string]models.HotFix)
	for _, fix := range hotFixes {
		hotFixRecord[fix.Key] = fix
	}
	// 交叉对比，这个执行的顺序又上面 []ifaces.IHotFix 指定
	for _, hotfixCase := range hotfixCases {
		_, bFound := hotFixRecord[hotfixCase.GetKey()]
		if bFound == false {
			// 没有找到那么就需要进行修复
			log_helper.GetLogger().Infoln("hotfix", hotfixCase.GetKey(), "start...")
			processResult, err := hotfixCase.Process()
			// 找到对应的 hotfix 方案进行 interface 数据的转换输出
			switch hotfixCase.GetKey() {
			case "001":
				outStruct := processResult.(OutStruct001)
				if err != nil {
					for i, file := range outStruct.ErrFiles {
						log_helper.GetLogger().Errorln("hotfix 001, rename failed,", i, file)
					}
					// 如果任意故障则跳出后续的修复
					log_helper.GetLogger().Errorln("hotfix 001 failed, break")
					return err
				}
				break
			default:
				continue
			}
			// 执行成功则存入数据库中，标记完成
			markHotFixDone := models.HotFix{Key: hotfixCase.GetKey(), Done: true}
			result = dao.GetDb().Create(&markHotFixDone)
			if result.Error != nil {
				return errors.New(fmt.Sprintf("hotfix %s is done, but record failed, %s", hotfixCase.GetKey(), result.Error))
			}
			log_helper.GetLogger().Infoln("hotfix", hotfixCase.GetKey(), "is done")
		}
		// 找到了，目前的逻辑是成功才插入，那么查询到了，就默认是执行成功了
	}
	return nil

}

repository: ibeyond/ChineseSubFinder

repo_name: ibeyond/ChineseSubFinder


text:
# Simple network "shell" extension for wlan/ethernet
# Project "Berserk", autor Alexander Demachev, site https://berserk.tv
# license -  The MIT License (MIT)

DESCRIPTION = "Simple network shell extension for wlan/ethernet"
SECTION = "nets"
PR = "r1"
LICENSE = "MIT"
MD5_SUM = "md5=0835ade698e0bcf8506ecda2f7b4f302"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;${MD5_SUM}"

SRC_URI = "git://github.com/berserktv/bs-net.git;branch=master"
SRCREV = "2d95807ffd285f66f60eae021baaed645d68fb43"

require recipes-mediacentre/kodi/kodi-dir.inc

NET_DIR = "/etc/network"
UDEV_DIR = "/etc/udev/rules.d"
ETH_CONFIGS = "${KODI_USERDATA}/eths"
WLAN_CONFIGS = "${KODI_USERDATA}/wlans"

S = "${WORKDIR}/git"

PACKAGES = "${PN}"
FILES_${PN} = "${NET_DIR} ${UDEV_DIR} ${KODI_HOME_DIR}"

RDEPENDS_${PN} += "ntp wpa-supplicant iw gawk"

do_install_append() {
    install -d ${D}${UDEV_DIR}
    install -d ${D}${sysconfdir}/network
    install -d ${D}${ETH_CONFIGS}
    install -d ${D}${WLAN_CONFIGS}

    install -m 0755 ${S}${NET_DIR}/dh-func.sh ${D}${sysconfdir}/network
    install -m 0755 ${S}${NET_DIR}/eth-manual ${D}${sysconfdir}/network
    install -m 0755 ${S}${NET_DIR}/tools-wifi.sh ${D}${sysconfdir}/network
    install -m 0755 ${S}${NET_DIR}/wlan ${D}${sysconfdir}/network
    install -m 0755 ${S}${NET_DIR}/wlan-runner ${D}${sysconfdir}/network
    install -m 0644 ${S}${NET_DIR}/eth0 ${D}${ETH_CONFIGS}

    install -m 0644 ${S}${UDEV_DIR}/80-wifi-start.rules ${D}${UDEV_DIR}
    install -m 0644 ${S}${UDEV_DIR}/85-automount.rules  ${D}${UDEV_DIR}
}

repository: berserktv/berserk

repo_name: berserktv/berserk


text:
/*global Hull:true */
Hull.widget("githull", {
  templates: ['githull'],
  refreshEvents: ['model.hull.me.change'],
  initialize: function() {
    // Hack to force credentials refresh...
    this.sandbox.on('hull.currentUser', function() {
      window.location.reload();
    });
  }
});

repository: roachhd/Github-Mobile

repo_name: roachhd/Github-Mobile

extension: js


text:
@article{kasch2017educational,
 author = {Kasch, Julia and Van Rosmalen, Peter and Kalz, Marco},
 title = {Educational Design Analysis Instrument},
 year = {2017}
}

repository: mkalz/mkalz-academic

repo_name: mkalz/mkalz-academic


text:
LICENSE = "GPL"
SECTION = "console/network"
DESCRIPTION = "lsh is a GNU GPL-licensed implementation of the SSH \
(version 2) protocol. It includes a server, a client, and some \
utility programs."
DEPENDS = "zlib gmp liboop"

SRC_URI = "http://www.lysator.liu.se/~nisse/archive/lsh-${PV}.tar.gz;name=src"
SRC_URI[src.md5sum] = "621f4442332bb772b92d397d17ccaf02"
SRC_URI[src.sha256sum] = "614b9d63e13ad3e162c82b6405d1f67713fc622a8bc11337e72949d613713091"
S = "${WORKDIR}/lsh-${PV}"

inherit autotools
configopts = "  --enable-debug-alloc    Enable memory allocation sanity checks \
		--enable-debug-trace    Enable tracing support \
		--enable-gcov           Instrument for gcov (requires a modern gcc) \
		--without-pty           Disable pty support \
		--disable-srp           Disable the (experimental) support for SRP \
		--disable-kerberos      Don't support kerberos \
		--disable-pam           Don't support PAM \
		--disable-datafellows-workarounds \
		--enable-initgroups-workaround \
		--disable-tcp-forward   Disable tcp forwarding \
		--disable-x11-forward   Disable x11 forwarding (proxy only) \
		--disable-agent-forward Disable auth-agent forwarding (proxy only) \
		--disable-ipv6          Disable IPv6 support \
		--disable-utmp          Disable utmp and wtmp support \
		--without-zlib          Don't use zlib compression \
		--with-tcpwrappers      Use tcp-wrappers for filtering connections \
		--with-sshd1=PROGRAM support fallback to SSH1 daemon \
		--with-scheme=PROGRAM Use a particular scheme implementation \
		--without-system-argp   Don't use the system's argp \
		--with-include-path     A colon-separated list of directories to search for \
		--with-lib-path         A colon-separated list of directories to search for \
		--with-x                use the X Window System"
EXTRA_OECONF = "--disable-srp --disable-kerberos --disable-pam \
		--without-x"


text:
package xseq

import (
	"github.com/google/uuid"

	"github.com/leaxoy/x-go/xstrings"
)

var globalId string

func init() {
	var err error
	globalId, err = xstrings.FastRandom(32)
	if err != nil {
		globalId = UUID()
	}
}

func GlobalID() string {
	return globalId
}

func UUID() string {
	return uuid.New().String()
}

repository: leaxoy/x-go

repo_name: leaxoy/x-go


text:
package main

import (
	"encoding/base64"
	"encoding/json"
	"fmt"
	"github.com/blang/crane/auth"
	"github.com/gorilla/mux"
	"io/ioutil"
	"log"
	"net/http"
	"strconv"
	"strings"
	"time"
)

var (
	JsonMsgImageNotFound         = []byte("{\"error\": \"Image not found\"}")
	JsonMsgTagNotFound           = []byte("{\"error\": \"Tag not found\"}")
	JsonMsgTagsNotFound          = []byte("{\"error\": \"No tags found\"}")
	JsonMsgPing                  = []byte("true")
	JsonMsgImageMissingChecksum  = []byte("{\"error\": \"Cannot set this image checksum\"}")
	JsonMsgImageChecksumMissing  = []byte("{\"error\": \"Missing Image's checksum\"}")
	JsonMsgImageChecksumMismatch = []byte("{\"error\": \"Checksum mismatch\"}")
)

type RegistryAPI struct {
	router   *mux.Router
	registry *Registry
}

func NewRegistryAPI(registry *Registry) *RegistryAPI {
	r := &RegistryAPI{
		router:   mux.NewRouter(),
		registry: registry,
	}
	r.registerEndPoints()
	return r
}

func (r *RegistryAPI) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("X-Docker-RegistryAPI-Version", "0.1.0")
	log.Printf("%s: %s", req.Method, req.RequestURI)
	log.Printf("Header: %s", req.Header)
	log.Printf("Content-Length: %d", req.ContentLength)
	r.router.ServeHTTP(w, req)
}

func (r *RegistryAPI) registerEndPoints() {

	r.router.HandleFunc("/v1/_ping", r.handlePing).Methods("GET")

	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/", r.handlePutRepository).Methods("PUT")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/images", r.handlePutRepositoryImages).Methods("PUT")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/images", r.handleGetRepositoryImages).Methods("GET")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}", r.handleDummy).Methods("DELETE")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/tags", r.handleGetRepositoryTags).Methods("GET")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/tags/{tags}", r.handleGetRepositoryTag).Methods("GET")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/tags/{tags}", r.handlePutRepositoryTag).Methods("PUT")
	r.router.HandleFunc("/v1/repositories/{namespace}/{repository}/tags/{tags}", r.handleDummy).Methods("DELETE")

	r.router.HandleFunc("/v1/images/{image_id}/json", r.handleGetImageJson).Methods("GET")
	r.router.HandleFunc("/v1/images/{image_id}/json", r.handlePutImageJson).Methods("PUT")

	r.router.HandleFunc("/v1/images/{image_id}/layer", r.handleGetImageLayer).Methods("GET")
	r.router.HandleFunc("/v1/images/{image_id}/layer", r.handlePutImageLayer).Methods("PUT")

	r.router.HandleFunc("/v1/images/{image_id}/checksum", r.handlePutImageChecksum).Methods("PUT")

	r.router.HandleFunc("/v1/images/{image_id}/ancestry", r.handleGetAncestry).Methods("GET")
	r.router.HandleFunc("/v1/users/", r.handlePostUser).Methods("POST")
	r.router.HandleFunc("/v1/users/", r.handleGetUser).Methods("GET")
	//
}

func (r *RegistryAPI) handleDummy(w http.ResponseWriter, req *http.Request) {
	b, _ := ioutil.ReadAll(req.Body)
	if len(b) < 500 {
		log.Printf("Body: %s (%d)", b, len(b))
	} else {
		log.Printf("Body length: %s", len(b))
	}

}

// Handles User Registration: Returns 400 to redirect docker to GET /v1/users
// Route: POST /v1/users
func (r *RegistryAPI) handlePostUser(w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(http.StatusBadRequest)
	w.Write([]byte("\"Username or email already exists\""))
	//TODO: Maybe give the authenticator a try on this
	r.handleDummy(w, req)
}

// Handles User Login: Returns 200 because Auth is handled by proxy
// Status: 200 : Login successful
// Status: 401 : Wrong login
// Status: 403 : Account inactive
// Route: GET /v1/users
func (r *RegistryAPI) handleGetUser(w http.ResponseWriter, req *http.Request) {
	user, pass, valid := authHeader(req)
	if !valid {
		log.Println("Authheader not valid")
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().Authenticate(user, pass) {
		log.Println("Authentication failed")
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
}

type ImageRef struct {
	ID  string  `json:"id"`
	Tag *string `json:"Tag,omitempty"`
}

func (r ImageRef) String() string {
	return "id:" + r.ID
}

func (r *RegistryAPI) handlePutRepository(w http.ResponseWriter, req *http.Request) {
	log.Println("Put Repository")
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	if !(found1 && found2) {
		log.Println("Put Repository namespace, repository url wrong")
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	user, pass, valid := authHeader(req)
	if !valid {
		log.Printf("Not valid header")
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	var imageRefs []ImageRef
	err := json.NewDecoder(req.Body).Decode(&imageRefs)
	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	var imageIds []string
	for _, imageRef := range imageRefs {
		imageIds = append(imageIds, imageRef.ID)
	}

	token, granted := r.registry.Authenticator().Authorize(user, pass, namespace, repository, imageIds, auth.O_WRONLY)
	if !granted {
		log.Printf("Not granted %s", repository)
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	setTokenHeaders(w, token, namespace, repository, auth.O_WRONLY)

	err = r.registry.SetImages(namespace, repository, imageIds)
	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	w.Header().Set("X-Docker-Endpoints", req.Host) //TODO: Make http host or config
	log.Printf("Put Repository Images: %s:%s %q", namespace, repository, imageRefs)
}

func (r *RegistryAPI) handleGetImageJson(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	imageJSON, found := r.registry.ImageJSON(imageID)
	if !found {
		w.WriteHeader(http.StatusNotFound)
		w.Write(JsonMsgImageNotFound)
		return
	}
	checksum, found := r.registry.Checksum(imageID)
	if !found {
		w.WriteHeader(http.StatusNotFound)
		w.Write(JsonMsgImageNotFound)
		return
	}

	size, found := r.registry.Size(imageID)
	if !found {
		w.WriteHeader(http.StatusNotFound)
		w.Write(JsonMsgImageNotFound)
		return
	}
	w.Header().Set("X-Docker-Payload-Checksum", "sha256:"+checksum)
	w.Header().Set("X-Docker-Size", strconv.FormatInt(size, 10))
	w.Write([]byte(imageJSON))
}

func (r *RegistryAPI) handlePutImageJson(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().HasPermPushImage(token, imageID) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	_, found = r.registry.ImageJSON(imageID)
	if found {
		w.WriteHeader(http.StatusConflict)
		// TODO: Possible to overwrite? I guess
		// Then Reset all other data, checksum, size etc
		return
	}

	var newImage Image
	bImageJSON, err := ioutil.ReadAll(req.Body)
	err = json.Unmarshal(bImageJSON, &newImage)
	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	err = r.registry.SetTmpImageJSON(imageID, string(bImageJSON))
	if err != nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	if newImage.Parent != "" {
		r.registry.SetTmpAncestry(imageID, newImage.Parent)
	}
}

func (r *RegistryAPI) handlePutImageChecksum(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().HasPermPushImage(token, imageID) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	checksumHeader := req.Header.Get("X-Docker-Checksum-Payload")
	if checksumHeader == "" || len(checksumHeader) < 8 { // Naive check if checksum might be ok
		w.WriteHeader(http.StatusBadRequest)
		w.Write(JsonMsgImageChecksumMissing)
		return
	}
	found256 := strings.Index(checksumHeader, "sha256:")

	if found256 == -1 {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	startIndex := found256 + len("sha256:")
	checksum := checksumHeader[startIndex:]

	if !r.registry.ValidateAndCommitLayer(imageID, checksum) {
		w.WriteHeader(http.StatusConflict)
		w.Write(JsonMsgImageChecksumMismatch)
		return
	}
}

func (r *RegistryAPI) handlePutImageLayer(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().HasPermPushImage(token, imageID) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	imageJSON, found := r.registry.TmpImageJSON(imageID)
	if !found {
		w.WriteHeader(http.StatusNotFound)
		return
	}

	err := r.registry.SetTmpLayer(imageID, imageJSON, req.Body)
	if err != nil {
		log.Printf("Could not set layer: %v", err)
		w.WriteHeader(http.StatusBadRequest)
		return
	}

}

func (r *RegistryAPI) handleGetImageLayer(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().HasPermPullImage(token, imageID) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	reader, err := r.registry.Layer(imageID)
	if err != nil {
		log.Printf("Could not set layer: %v", err)
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	http.ServeContent(w, req, "layer.bin", time.Now(), reader)

}

func (r *RegistryAPI) handlePing(w http.ResponseWriter, req *http.Request) {
	w.Write(JsonMsgPing)
}

func (r *RegistryAPI) handlePutRepositoryTag(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	tags, found3 := vars["tags"]
	bImageID, err := ioutil.ReadAll(req.Body)
	if !(found1 && found2 && found3 && err == nil) {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	imageID := strings.Trim(string(bImageID), "\" ")
	if !r.registry.Authenticator().HasPermPushTag(token, namespace, repository, imageID, tags) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	log.Printf("Set Tag: %s/%s: %s:%s", namespace, repository, imageID, tags)
	r.registry.SetTag(namespace, repository, imageID, tags)
}

func (r *RegistryAPI) handleGetRepositoryTag(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	tag, found3 := vars["tags"]
	if !(found1 && found2 && found3) {
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	if !r.registry.Authenticator().HasPermPullTag(token, namespace, repository, tag) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	imageID, found := r.registry.Tag(namespace, repository, tag)
	if !found {
		log.Printf("Get Tag not found: %s/%s: %s", namespace, repository, tag)
		w.WriteHeader(http.StatusNotFound)
		w.Write(JsonMsgTagNotFound)
		return
	}
	log.Printf("Get Tag: %s/%s: %s:%s", namespace, repository, imageID, tag)
	w.Write([]byte("\"" + imageID + "\""))
}

func (r *RegistryAPI) handleGetRepositoryTags(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	if !(found1 && found2) {
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	if !r.registry.Authenticator().HasPermPullTags(token, namespace, repository) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	imageIDs, found := r.registry.Tags(namespace, repository)
	if !found {
		w.WriteHeader(http.StatusNotFound)
		w.Write(JsonMsgTagsNotFound)
		return
	}
	b, err := json.Marshal(&imageIDs)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		return
	}
	w.Write(b)
}

func (r *RegistryAPI) handlePutRepositoryImages(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	if !(found1 && found2) {
		w.WriteHeader(http.StatusBadRequest)
		return
	}

	// No Auth here because it's an empty endpoint result of dockers strange design.

	b, _ := ioutil.ReadAll(req.Body)
	bodyStr := string(b)
	log.Printf("Put Repository Images: %s:%s %v", namespace, repository, string(b))
	if bodyStr == "[]" {
		w.WriteHeader(http.StatusNoContent)
		return
	}
	w.WriteHeader(http.StatusBadRequest)

}

func (r *RegistryAPI) handleGetRepositoryImages(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	namespace, found1 := vars["namespace"]
	repository, found2 := vars["repository"]
	if !(found1 && found2) {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	user, pass, valid := authHeader(req)
	if !valid {
		log.Printf("Not valid header")
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	images, err := r.registry.Images(namespace, repository)
	if err != nil {
		w.WriteHeader(http.StatusNotFound)
		//TODO: Maybe security problem because guessing is possible
		return
	}

	token, granted := r.registry.Authenticator().Authorize(user, pass, namespace, repository, images, auth.O_RDONLY)
	if !granted {
		log.Printf("Not granted %s", repository)
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	setTokenHeaders(w, token, namespace, repository, auth.O_RDONLY)

	w.Header().Set("X-Docker-Endpoints", req.Host) //TODO: Make http host or config

	var imageRefList []*ImageRef
	for _, imageID := range images {
		imageRefList = append(imageRefList, &ImageRef{ID: imageID})
	}
	log.Printf("Get Repository Images: %s:%s %v", namespace, repository, images)
	json.NewEncoder(w).Encode(imageRefList)
}

func (r *RegistryAPI) handleGetAncestry(w http.ResponseWriter, req *http.Request) {
	vars := mux.Vars(req)
	imageID, found := vars["image_id"]
	if !found {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	token, validToken := tokenHeader(req)
	if !validToken {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}
	if !r.registry.Authenticator().HasPermPullImage(token, imageID) {
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	ancestryArr, err := r.registry.Ancestry(imageID)
	if err != nil {
		w.WriteHeader(http.StatusNotFound)
		return
	}
	log.Printf("Ancestry for image %s: %v", imageID, ancestryArr)
	json.NewEncoder(w).Encode(&ancestryArr)
}

func authHeader(req *http.Request) (string, string, bool) {
	const authBasic = "Basic "
	auth := req.Header.Get("Authorization")
	log.Printf("Header is %s", auth)
	if !strings.HasPrefix(auth, authBasic) {
		log.Println("Has no prefx")
		return "", "", false
	}
	str, err := base64.StdEncoding.DecodeString(auth[len(authBasic):])
	if err != nil {
		return "", "", false
	}
	log.Printf("Auth string is: %s", str)

	creds := strings.SplitN(string(str), ":", 2)
	if len(creds) != 2 {
		return "", "", false
	}
	return creds[0], creds[1], true
}

func tokenHeader(req *http.Request) (string, bool) {
	const PREFIX = "Token Token "
	const SIGPREFIX = "signature="
	auth := req.Header.Get("Authorization")
	if auth == "" {
		return "", false
	}

	if !strings.HasPrefix(auth, PREFIX) {
		return "", false
	}

	auth = strings.TrimPrefix(auth, PREFIX)
	parts := strings.Split(auth, ",")
	if len(parts) != 3 {
		return "", false
	}

	signature := ""
	for _, part := range parts {
		if strings.HasPrefix(part, SIGPREFIX) {
			signature = part[len(SIGPREFIX):]
		}
	}
	if signature == "" {
		return "", false
	}

	return signature, true
}

func setTokenHeaders(w http.ResponseWriter, token string, namespace string, repository string, mode auth.Mode) {
	modeStr := ""
	switch mode {
	case auth.O_RDONLY:
		modeStr = "read"
	case auth.O_WRONLY:
		modeStr = "write"
	default:
		modeStr = "read"
	}

	tokenHeader := fmt.Sprintf("Token signature=%s,repository=\"%s/%s\",access=%s", token, namespace, repository, modeStr)
	w.Header().Set("WWW-Authenticate", tokenHeader)
	w.Header().Set("X-Docker-Token", tokenHeader)
}

repository: blang/crane

repo_name: blang/crane


text:
@article{radloff1977ces,
  title={The {CES-D} scale: A self-report depression scale for research in the general population},
  author={Radloff, Lenore Sawyer},
  journal={Applied psychological measurement},
  volume={1},
  number={3},
  pages={385--401},
  year={1977},
  publisher={Sage Publications Sage CA: Thousand Oaks, CA}
}

@article{roeser2019advance,
  title={Advance planning in written and spoken sentence production},
  author={Roeser, Jens and Torrance, Mark and Baguley, Thom},
  journal={Journal of Experimental Psychology: Learning, Memory, and Cognition},
  volume={45},
  number={11},
  pages={1983--2009},
  year={2019},
  publisher={American Psychological Association}
}

@inproceedings{roeser2020amlap,
	Address = {Germany, Potsdam},
	Author = {Jens Roeser and Mark Torrance and Mark Andrews and Thom Baguley},
	Booktitle = {26th {A}rchitectures and {M}echanisms for {L}anguage {P}rocessing ({AMLaP})},
	Organization = {University of Potsdam},
	Title = {No scope for planning -- language pre-planning as mixture process},
	Year = {2020},
	url = {https://amlap2020.github.io/}}

@misc{roeser2021,
	title = {Modelling typing disfluencies using Bayesian mixture models},
	author = {Jens Roeser and Sven {De Maeyer} and Mariëlle Leijten and Luuk {Van Waes}},
	url = {https://osf.io/y3p4d/},
	note = {under review},
	year = {2021}
}

@article{baaijen2012keystroke,
  title={Keystroke analysis: Reflections on procedures and measures},
  author={Baaijen, Veerle M. and Galbraith, David and {de Glopper}, Kees},
  journal={Written Communication},
  volume={29},
  number={3},
  pages={246--277},
  year={2012},
  publisher={SAGE Publications Sage CA: Los Angeles, CA}
}

@article{matzke2009psychological,
  title={Psychological interpretation of the ex-{G}aussian and shifted {W}ald parameters: A diffusion model analysis},
  author={Matzke, Dora and Wagenmakers, Eric-Jan},
  journal={Psychonomic Bulletin \& Review},
  volume={16},
  number={5},
  pages={798--817},
  year={2009},
  publisher={Springer}
}

@techreport{almond2012preliminary,
  title={A preliminary analysis of keystroke log data from a timed writing task},
  author={Almond, Russell and Deane, Paul and Quinlan, Thomas and Wagner, Michael and Sydorenko, Tetyana},
  number = {Research Report No. RR-12-23},
  address = {Princeton, NJ},
  publisher = {Educational Testing Service},
  year={2012},
}

@article{chukharev2014pauses,
  title={Pauses in spontaneous written communication: {A} keystroke logging study},
  author={Chukharev-Hudilainen, Evgeny},
  journal={Journal of Writing Research},
  volume={6},
  number={1},
  pages={61--84},
  year={2014}
}

@book{bag12,
  title={Serious stats: A guide to advanced statistics for the behavioral sciences},
  author={Thomas Baguley},
  year={2012},
  address = {Basingstoke},
  publisher={Palgrave Macmillan}
}

@article{dienes2014using,
  title={Using {B}ayes to get the most out of non-significant results},
  author={Dienes, Zoltan},
  journal={Frontiers in Psychology},
  volume={5},
  number={781},
  pages={1--17},
  year={2014},
  publisher={Frontiers Media SA}
}

@article{dienes2016bayes,
  title={How {B}ayes factors change scientific practice},
  author={Dienes, Zoltan},
  journal={Journal of Mathematical Psychology},
  volume={72},
  pages={78--89},
  year={2016},
  publisher={Elsevier}
}

@article{dienes2018four,
  title={Four reasons to prefer {B}ayesian analyses over significance testing},
  author={Dienes, Zoltan and Mclatchie, Neil},
  journal={Psychonomic Bulletin \& Review},
  volume={25},
  number={1},
  pages={207--218},
  year={2018},
  publisher={Springer}
}

@article{schonbrodt2017sequential,
  title={Sequential hypothesis testing with {B}ayes factors: Efficiently testing mean differences},
  author={Sch{\"o}nbrodt, Felix D. and Wagenmakers, Eric-Jan and Zehetleitner, Michael and Perugini, Marco},
  journal={Psychological Methods},
  volume={22},
  number={2},
  pages={322--339},
  year={2017},
  publisher={American Psychological Association}
}

@article{rouder2016interplay,
  title={The interplay between subjectivity, statistical practice, and psychological science},
  author={Rouder, Jeffrey N. and Morey, Richard D. and Wagenmakers, Eric-Jan},
  journal={Collabra},
  volume={2},
  number={1},
  pages = {1-12},
  year={2016},
  publisher={University of California Press}
}

@book{lee2014bayesian,
  title={Bayesian cognitive modeling: A practical course},
  author={Lee, Michael D. and Wagenmakers, Eric-Jan},
  year={2014},
  publisher={Cambridge University Press}
}

@book{jeffreys1961theory,
	title={The theory of probability},
	author={Jeffreys, Harold},
	volume = {3},
	year={1961},
	publisher={Oxford University Press, Clarendon Press},
	address ={Oxford}
}

@article{dickey1970weighted,
  title={The weighted likelihood ratio, sharp hypotheses about chances, the order of a Markov chain},
  author={Dickey, James M. and Lientz, B.~P. and others},
  journal={The Annals of Mathematical Statistics},
  volume={41},
  number={1},
  pages={214--226},
  year={1970},
  publisher={Institute of Mathematical Statistics}
}

@article{greenland2016statistical,
  title={Statistical tests, p values, confidence intervals, and power: a guide to misinterpretations},
  author={Greenland, Sander and Senn, Stephen J. and Rothman, Kenneth J. and Carlin, John B. and Poole, Charles and Goodman, Steven N. and Altman, Douglas G.},
  journal={European Journal of Epidemiology},
  volume={31},
  number={4},
  pages={337--350},
  year={2016},
  publisher={Springer}
}

@article{colquhoun2017reproducibility,
  title={The reproducibility of research and the misinterpretation of p-values},
  author={Colquhoun, David},
  journal={Royal Society Open Science},
  volume={4},
  number={12},
  pages={171085},
  year={2017},
  publisher={The Royal Society Publishing}
}

@article{morey2016fallacy,
  title={The fallacy of placing confidence in confidence intervals},
  author={Morey, Richard D. and Hoekstra, Rink and Rouder, Jeffrey N and Lee, Michael D. and Wagenmakers, Eric-Jan},
  journal={Psychonomic Bulletin \& Review},
  volume={23},
  number={1},
  pages={103--123},
  year={2016},
  publisher={Springer}
}

@article{hoekstra2014robust,
  title={Robust misinterpretation of confidence intervals},
  author={Hoekstra, Rink and Morey, Richard D. and Rouder, Jeffrey N. and Wagenmakers, Eric-Jan},
  journal={Psychonomic Bulletin \& Review},
  volume={21},
  number={5},
  pages={1157--1164},
  year={2014},
  publisher={Springer}
}

@article{loken2017measurement,
  title={Measurement error and the replication crisis},
  author={Loken, Eric and Gelman, Andrew},
  journal={Science},
  volume={355},
  number={6325},
  pages={584--585},
  year={2017},
  publisher={American Association for the Advancement of Science}
}

@article{amrhein2019inferential,
  title={Inferential statistics as descriptive statistics: There is no replication crisis if we don’t expect replication},
  author={Amrhein, Valentin and Trafimow, David and Greenland, Sander},
  journal={The American Statistician},
  volume={73},
  number={sup1},
  pages={262--270},
  year={2019},
  publisher={Taylor \& Francis}
}

@article{baayen2008mixed,
  title={Mixed-effects modeling with crossed random effects for subjects and items},
  author={Baayen, R. Harald and Davidson, Douglas J. and Bates, Douglas M.},
  journal={Journal of Memory and Language},
  volume={59},
  number={4},
  pages={390--412},
  year={2008},
  publisher={Elsevier}
}

@book{mcelreath2016statistical,
  title={Statistical rethinking: {A} {B}ayesian course with examples in {R} and {Stan}},
  author={McElreath, Richard},
  year={2016},
  publisher={CRC Press}
}

@book{james2013introduction,
  title={An introduction to statistical learning: with applications in {R}},
  author={James, Gareth and Witten, Daniela and Hastie, Trevor and Tibshirani, Robert},
  volume={112},
  year={2014},
  publisher={Springer}
}

@book{montgomery2012introduction,
  title={Introduction to linear regression analysis},
  author={Montgomery, Douglas C and Peck, Elizabeth A and Vining, G Geoffrey},
  volume={5},
  year={2012},
  publisher={John Wiley \& Sons}
}

@book{chatterjee2015regression,
  title={Regression analysis by example},
  author={Chatterjee, Samprit and Hadi, Ali S.},
  year={2012},
  volume = {5},
  publisher={John Wiley \& Sons}
}

@book{fox2018r,
  title={An {R} companion to applied regression},
  author={Fox, John and Weisberg, Sanford},
  year={2018},
  volume = {3},
  publisher={Sage publications}
}

@book{faraway2014linear,
  title={Linear models with {R}},
  author={Faraway, Julian J.},
  year={2015},
  volume = {2},
  publisher={CRC press}
}

@book{baa08book,
  title={Analyzing linguistic data. A practical introduction to statistics using {R}},
  author={R. Harald Baayen},
  year={2008},
  address = {Cambridge},
  publisher={Cambridge University Press}
}

@article{blomkvist2017reference,
  title={Reference data on reaction time and aging using the {Nintendo Wii Balance Board}: A cross-sectional study of 354 subjects from 20 to 99 years of age},
  author={Blomkvist, Andreas W. and Eika, Fredrik and Rahbek, Martin T. and Eikhof, Karin D. and Hansen, Mette D. and S{\o}ndergaard, Malene and Ryg, Jesper and Andersen, Stig and J{\o}rgensen, Martin G.},
  journal={PLoS one},
  volume={12},
  number={12},
  doi = {10.1371/journal.pone.0189598},
  url = {https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0189598},
  pages={e0189598},
  year={2017},
  publisher={Public Library of Science San Francisco, CA USA}
}

@article{wong2001mathematical,
  title={Mathematical models of cognitive recovery},
  author={Wong, Pauline P. and Monette, Georges and Weiner, Neil I.},
  journal={Brain injury},
  volume={15},
  number={6},
  pages={519--530},
  year={2001},
  publisher={Taylor \& Francis}
}

@book{gill2014bayesian,
  title={Bayesian methods: {A} social and behavioral sciences approach},
  author={Gill, Jeff},
  volume={20},
  year={2014},
  publisher={CRC press}
}

@article{schad2020capitalize,
  title={How to capitalize on a priori contrasts in linear (mixed) models: {A} tutorial},
  author={Schad, Daniel J. and Vasishth, Shravan and Hohenstein, Sven and Kliegl, Reinhold},
  journal={Journal of Memory and Language},
  volume={110},
  pages={104038},
  year={2020},
  publisher={Elsevier}
}

@article{wagenmakers2007linear,
  title={On the linear relation between the mean and the standard deviation of a response time distribution},
  author={Wagenmakers, Eric-Jan and Brown, Scott},
  journal={Psychological review},
  volume={114},
  number={3},
  pages={830--841},
  year={2007},
  publisher={American Psychological Association}
}

@article{vehtari2017practical,
  title={Practical Bayesian model evaluation using leave-one-out cross-validation and {WAIC}},
  author={Vehtari, Aki and Gelman, Andrew and Gabry, Jonah},
  journal={Statistics and Computing},
  volume={27},
  number={5},
  pages={1413--1432},
  year={2017},
  publisher={Springer}
}

@article{vehtari2015pareto,
  title={Pareto smoothed importance sampling},
  author={Vehtari, Aki and Gelman, Andrew and Gabry, Jonah},
  journal={arXiv preprint arXiv:1507.02646},
  year={2015}
}

@article{burkner2019bayesian,
  title={Bayesian Item Response Modeling in {R} with brms and {Stan}},
  author={B{\"u}rkner, Paul-Christian},
  journal={arXiv preprint arXiv:1905.09501},
  year={2019}
}

@book{cohn1988statistical,
  title={Statistical power analysis for the behavioral sciences},
  author={Cohn, J.},
  address={Hillsdale, NJ},
  publisher = {Lawrence Earlbam Associates},
  year={1988}
}

@article{wagenmakers2010bayesian,
  title={Bayesian hypothesis testing for psychologists: {A} tutorial on the {S}avage-{D}ickey method},
  author={Wagenmakers, Eric-Jan and Lodewyckx, Tom and Kuriyal, Himanshu and Grasman, Raoul},
  journal={Cognitive Psychology},
  volume={60},
  number={3},
  pages={158--189},
  year={2010},
  publisher={Elsevier}
}

@article{bates2015parsimonious,
  title={Parsimonious mixed models},
  author={Bates, Douglas and Kliegl, Reinhold and Vasishth, Shravan and Baayen, Harald},
  journal={arXiv preprint arXiv:1506.04967},
  year={2015}
}

@article{barr2013random,
  title={Random effects structure for confirmatory hypothesis testing: Keep it maximal},
  author={Barr, Dale J. and Levy, Roger and Scheepers, Christoph and Tily, Harry J.},
  journal={Journal of Memory and Language},
  volume={68},
  number={3},
  pages={255--278},
  year={2013},
  publisher={Elsevier}
}

@article{kruschke2011bayesian,
  title={Bayesian assessment of null values via parameter estimation and model comparison},
  author={Kruschke, John K.},
  journal={Perspectives on Psychological Science},
  volume={6},
  number={3},
  pages={299--312},
  year={2011},
  publisher={Sage Publications Sage CA: Los Angeles, CA}
}

@article{kruschke2010believe,
  title={What to believe: {B}ayesian methods for data analysis},
  author={Kruschke, John K.},
  journal={Trends in Cognitive Sciences},
  volume={14},
  number={7},
  pages={293--300},
  year={2010},
  publisher={Elsevier}
}

@book{gelman2020regression,
  title={Regression and other stories},
  author={Gelman, Andrew and Hill, Jennifer and Vehtari, Aki},
  year={2020},
  publisher={Cambridge University Press}
}

@book{lambert2018student,
  title={A Student's Guide to {B}ayesian Statistics},
  author={Lambert, Ben},
  year={2018},
  publisher={Sage}
}

@article{vasishth2016statistical,
  title={Statistical methods for linguistic research: {F}oundational Ideas -- {Part I}},
  author={Vasishth, Shravan and Nicenboim, Bruno},
  journal={arXiv preprint arXiv:1601.01126},
  year={2016}
}

@article{sorensen2016bayesian,
  title={Bayesian linear mixed models using {Stan}: {A} tutorial for psychologists, linguists, and cognitive scientists},
  author={Sorensen, Tanner and Hohenstein, S. and Vasishth, Shravan},
  journal={Quantitative Methods for Psychology},
  volume = {12},
  number = {3},
  pages = {175--200},
  year = {2016}
}

@book{gelman2014,
   title = {Bayesian data analysis},
   author = {Gelman, Andrew and Carlin, J.~B. and Stern, H.~S. and Dunson, D.~B. and Vehtari, Aki and Rubin, D.~B.},
   year = {2014},
   edition = {3},
   publisher = {Chapman and Hall/CRC}
}

@article{nicenboim2016statistical,
  title={Statistical methods for linguistic research: {Foundational Ideas -- Part II}},
  author={Nicenboim, Bruno and Vasishth, Shravan},
  journal={Language and Linguistics Compass},
  volume={10},
  number={11},
  pages={591--613},
  year={2016},
  publisher={Wiley Online Library}
}

@article{makowski2019bayestestr,
  title={{bayestestR}: {D}escribing effects and their uncertainty, existence and significance within the {B}ayesian framework},
  author={Makowski, Dominique and Ben-Shachar, Mattan S and L{\"u}decke, Daniel},
  journal={Journal of Open Source Software},
  volume={4},
  number={40},
  pages={1541},
  year={2019}
}

@article{baguley2009standardized,
  title={Standardized or simple effect size: What should be reported?},
  author={Baguley, Thom},
  journal={British journal of psychology},
  volume={100},
  number={3},
  pages={603--617},
  year={2009},
  publisher={Wiley Online Library}
}

@article{kruschke2018rejecting,
  title={Rejecting or accepting parameter values in {B}ayesian estimation},
  author={Kruschke, John K.},
  journal={Advances in Methods and Practices in Psychological Science},
  volume={1},
  number={2},
  pages={270--280},
  year={2018},
  publisher={Sage Publications Sage CA: Los Angeles, CA}
}

@Article{brms1,
  title = {{brms}: An {R} Package for {Bayesian} Multilevel Models Using {Stan}},
  author = {Paul-Christian Bürkner},
  journal = {Journal of Statistical Software},
  year = {2017},
  volume = {80},
  number = {1},
  pages = {1--28},
  doi = {10.18637/jss.v080.i01},
  encoding = {UTF-8},
}

@Article{brms2,
  title = {Advanced {Bayesian} Multilevel Modeling with the {R} Package {brms}},
  author = {Paul-Christian Bürkner},
  journal = {The R Journal},
  year = {2018},
  volume = {10},
  number = {1},
  pages = {395--411},
  doi = {10.32614/RJ-2018-017},
  encoding = {UTF-8},
}

@article{gelman1992,
  title={Inference from iterative simulation using multiple sequences},
  author={Gelman, Andrew and Rubin, Donald B.},
  journal={Statistical science},
  volume = {7},
  number = {4},
  pages={457--472},
  year={1992},
  publisher={JSTOR}
}

@article{robinson2018using,
  title={Using multi-item psychometric scales for research and practice in human resource management},
  author={Robinson, Mark A.},
  journal={Human Resource Management},
  volume={57},
  number={3},
  pages={739--750},
  year={2018},
  publisher={Wiley Online Library}
}

@book{coolican2018research,
  title={Research methods and statistics in psychology},
  author={Coolican, Hugh},
  year={2018},
  publisher={Routledge}
}

@article{burkner2019ordinal,
  title={Ordinal regression models in psychology: A tutorial},
  author={B{\"u}rkner, Paul-Christian and Vuorre, Matti},
  journal={Advances in Methods and Practices in Psychological Science},
  volume={2},
  number={1},
  pages={77--101},
  year={2019},
  publisher={SAGE Publications Sage CA: Los Angeles, CA}
}

@article{liddell2018analyzing,
  title={Analyzing ordinal data with metric models: What could possibly go wrong?},
  author={Liddell, Torrin M. and Kruschke, John K.},
  journal={Journal of Experimental Social Psychology},
  volume={79},
  pages={328--348},
  year={2018},
  publisher={Elsevier}
}

@article{kruschke2014doing,
  title={Doing {B}ayesian data analysis: A tutorial with {R, JAGS, and Stan}},
  author={Kruschke, John K.},
  year={2014},
  publisher={Academic Press}
}

@book{matloff2019probability,
  title={Probability and statistics for data science: {Math + R + data}},
  author={Matloff, Norman},
  year={2019},
  publisher={CRC Press}
}

@article{lynn2001iq,
  author={Lynn, Richard and Vanhanen, Tatu},
  title={National {IQ} and economic development: a study of eighty-one nations},
  journal={Mankind Quarterly},
  volume={41},
  number={4},
  pages={415-435},
  year={2001},
  publisher={Council for Social and Economic Studies, Inc.}
}

@book{howitt2007introduction,
  title={Introduction to statistics in psychology},
  author={Howitt, Dennis and Cramer, Duncan},
  year={2014},
  edition = {6},
  publisher={Pearson Education}
}

@book{field2012discovering,
  title={Discovering statistics using {R}},
  author={Field, Andy and Miles, Jeremy and Field, Zo{\"e}},
  year={2012},
  publisher={Sage publications}
}

@book{baguley2012serious,
  title={Serious stats: A guide to advanced statistics for the behavioral sciences},
  author={Baguley, Thom},
  year={2012},
  publisher={Macmillan International Higher Education}
}

repository: jensroes/bayesian-mm-workshop

repo_name: jensroes/bayesian-mm-workshop


text:
// Code generated by "stringer -type=LogStatus"; DO NOT EDIT.

package loglist3

import "strconv"

func _() {
	// An "invalid array index" compiler error signifies that the constant values have changed.
	// Re-run the stringer command to generate them again.
	var x [1]struct{}
	_ = x[UndefinedLogStatus-0]
	_ = x[PendingLogStatus-1]
	_ = x[QualifiedLogStatus-2]
	_ = x[UsableLogStatus-3]
	_ = x[ReadOnlyLogStatus-4]
	_ = x[RetiredLogStatus-5]
	_ = x[RejectedLogStatus-6]
}

const _LogStatus_name = "UndefinedLogStatusPendingLogStatusQualifiedLogStatusUsableLogStatusReadOnlyLogStatusRetiredLogStatusRejectedLogStatus"

var _LogStatus_index = [...]uint8{0, 18, 34, 52, 67, 84, 100, 117}

func (i LogStatus) String() string {
	if i < 0 || i >= LogStatus(len(_LogStatus_index)-1) {
		return "LogStatus(" + strconv.FormatInt(int64(i), 10) + ")"
	}
	return _LogStatus_name[_LogStatus_index[i]:_LogStatus_index[i+1]]
}

repository: google/certificate-transparency-go

repo_name: google/certificate-transparency-go


text:
package versionrepo

import (
	"database/sql"
	"sort"
	"strings"

	"github.com/jmoiron/sqlx"
	"github.com/pkg/errors"
	log "github.com/sirupsen/logrus"
	"golang.org/x/mod/semver"

	"github.com/oidc-mytoken/server/internal/db"
	"github.com/oidc-mytoken/server/internal/db/dbmigrate"
	"github.com/oidc-mytoken/server/internal/model/version"
	"github.com/oidc-mytoken/server/internal/utils/errorfmt"
)

// SetVersionBefore sets that the before db migration commands for the passed version were executed
func SetVersionBefore(tx *sqlx.Tx, version string) error {
	return db.RunWithinTransaction(tx, func(tx *sqlx.Tx) error {
		_, err := tx.Exec(
			`INSERT INTO version (version, bef) VALUES(?, current_timestamp())
                      ON DUPLICATE KEY UPDATE bef=current_timestamp()`,
			version)
		return errors.WithStack(err)
	})
}

// SetVersionAfter sets that the after db migration commands for the passed version were executed
func SetVersionAfter(tx *sqlx.Tx, version string) error {
	return db.RunWithinTransaction(tx, func(tx *sqlx.Tx) error {
		_, err := tx.Exec(
			`INSERT INTO version (version, aft) VALUES(?, current_timestamp())
                      ON DUPLICATE KEY UPDATE aft=current_timestamp()`,
			version)
		return errors.WithStack(err)
	})
}

// UpdateTimes is a type for checking if the db migration commands for different mytoken version have been executed
type UpdateTimes struct {
	Version string
	Before  sql.NullTime `db:"bef"`
	After   sql.NullTime `db:"aft"`
}

// DBVersionState describes the version state of the db
type DBVersionState []UpdateTimes

// Len returns the len of DBVersionState
func (state DBVersionState) Len() int { return len(state) }

// Swap swaps to elements of DBVersionState
func (state DBVersionState) Swap(i, j int) { state[i], state[j] = state[j], state[i] }

// Less checks if a version is less than another
func (state DBVersionState) Less(i, j int) bool {
	a, b := state[i].Version, state[j].Version
	return semver.Compare(a, b) < 0
}

// Sort sorts this DBVersionState by the version
func (state DBVersionState) Sort() {
	sort.Sort(state)
}

// dbHasAllVersions checks that the database is compatible with the current version; assumes that DBVersionState is
// ordered
func (state DBVersionState) dBHasAllVersions() (hasAllVersions bool, missingVersions []string) {
	for v, cmds := range dbmigrate.MigrationCommands {
		if !state.dBHasVersion(v, cmds) {
			missingVersions = append(missingVersions, v)
		}
	}
	hasAllVersions = len(missingVersions) == 0
	return
}

// dbHasVersion checks that the database is compatible with the passed version; assumes that DBVersionState is ordered
func (state DBVersionState) dBHasVersion(v string, cmds dbmigrate.Commands) bool {
	i := sort.Search(len(state), func(i int) bool {
		return semver.Compare(state[i].Version, v) >= 0
	})
	if i >= len(state) || state[i].Version != v { // we have to check that i really points to v
		return false
	}
	ok := true
	if len(cmds.Before) > 0 {
		ok = ok && state[i].Before.Valid
	}
	if len(cmds.After) > 0 {
		ok = ok && state[i].After.Valid
	}
	return ok
}

// GetVersionState returns the DBVersionState
func GetVersionState(tx *sqlx.Tx) (state DBVersionState, err error) {
	err = db.RunWithinTransaction(tx, func(tx *sqlx.Tx) error {
		return errors.WithStack(tx.Select(&state, `SELECT version, bef, aft FROM version`))
	})
	if err != nil && strings.HasPrefix(errorfmt.Error(err), "Error 1146: Table") { // Ignore table does not exist error
		err = nil
	}
	state.Sort()
	return
}

// ConnectToVersion connects to the mytoken database and asserts that the database is up-to-date to the current version
func ConnectToVersion() {
	db.Connect()
	state, err := GetVersionState(nil)
	if err != nil {
		log.WithError(err).Fatal()
	}
	if hasAllVersions, missingVersions := state.dBHasAllVersions(); !hasAllVersions {
		log.WithFields(log.Fields{
			"server_version":         version.VERSION(),
			"missing_versions_in_db": missingVersions,
		}).Fatal("database schema not updated to this server version")
	}
}

repository: DrDaveD/mytoken-server

repo_name: DrDaveD/mytoken-server


text:
package kubeconfig

import (
	"encoding/base64"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"

	"k8s.io/client-go/plugin/pkg/client/auth/exec"
	restclient "k8s.io/client-go/rest"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/transport"

	"github.com/argoproj/argo/pkg/apis/workflow"
)

// get the default one from the filesystem
func DefaultRestConfig() (*restclient.Config, error) {
	rules := clientcmd.NewDefaultClientConfigLoadingRules()
	config := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, &clientcmd.ConfigOverrides{})
	return config.ClientConfig()
}

// convert a bearer token into a REST config
func GetRestConfig(token string) (*restclient.Config, error) {
	version, tokenBody, err := parseToken(token)
	if err != nil {
		return nil, err
	}
	switch version {
	case tokenVersion0:
		restConfigBytes, err := base64.StdEncoding.DecodeString(tokenBody)
		if err != nil {
			return nil, err
		}
		restConfig := &restclient.Config{}
		err = json.Unmarshal(restConfigBytes, restConfig)
		if err != nil {
			return nil, err
		}
		return restConfig, nil
	case tokenVersion1:
		restConfig, err := DefaultRestConfig()
		if err != nil {
			return nil, err
		}
		restConfig.BearerToken = tokenBody
		restConfig.BearerTokenFile = ""
		return restConfig, nil
	case tokenVersion2:
		value, err := getV2TokenBody()
		if err != nil {
			return nil, err
		}
		if tokenBody != value {
			return nil, fmt.Errorf("v2 token invalid")
		}
		restConfig, err := DefaultRestConfig()
		if err != nil {
			return nil, err
		}
		return restConfig, nil
	}
	return nil, fmt.Errorf("invalid token tokenVersion")
}

// convert the REST config into a bearer token
func GetBearerToken(in *restclient.Config) (string, error) {
	switch getDefaultTokenVersion() {
	case tokenVersion0:
		tlsClientConfig, err := tlsClientConfig(in)
		if err != nil {
			return "", err
		}
		clientConfig := &workflow.ClientConfig{
			Host:    in.Host,
			APIPath: in.APIPath,
			ContentConfig: restclient.ContentConfig{
				AcceptContentTypes: in.ContentConfig.AcceptContentTypes,
				ContentType:        in.ContentConfig.ContentType,
				GroupVersion:       in.ContentConfig.GroupVersion,
			},
			Username:        in.Username,
			Password:        in.Password,
			BearerToken:     in.BearerToken,
			Impersonate:     in.Impersonate,
			AuthProvider:    in.AuthProvider,
			TLSClientConfig: tlsClientConfig,
			UserAgent:       in.UserAgent,
			QPS:             in.QPS,
			Burst:           in.Burst,
			Timeout:         in.Timeout,
		}
		configByte, err := json.Marshal(clientConfig)
		if err != nil {
			return "", err
		}
		return formatToken(0, base64.StdEncoding.EncodeToString(configByte)), nil
	case tokenVersion1:
		if in.ExecProvider != nil {
			tc, err := in.TransportConfig()
			if err != nil {
				return "", err
			}

			auth, err := exec.GetAuthenticator(in.ExecProvider)
			if err != nil {
				return "", err
			}

			err = auth.UpdateTransportConfig(tc)
			if err != nil {
				return "", err
			}

			rt, err := transport.New(tc)
			if err != nil {
				return "", err
			}

			req := http.Request{Header: map[string][]string{}}

			_, _ = rt.RoundTrip(&req)

			token := req.Header.Get("Authorization")
			return formatToken(1, strings.TrimPrefix(token, "Bearer ")), nil
		}
		if in.AuthProvider != nil {
			if in.AuthProvider.Name == "gcp" {
				tc, err := in.TransportConfig()
				if err != nil {
					return "", err
				}

				auth, err := restclient.GetAuthProvider(in.Host, in.AuthProvider, in.AuthConfigPersister)
				if err != nil {
					return "", err
				}

				rt, err := transport.New(tc)
				if err != nil {
					return "", err
				}
				rt = auth.WrapTransport(rt)
				req := http.Request{Header: map[string][]string{}}

				_, _ = rt.RoundTrip(&req)

				token := in.AuthProvider.Config["access-token"]
				return formatToken(1, strings.TrimPrefix(token, "Bearer ")), nil
			}
			return "", nil
		}
	case tokenVersion2:
		v2TokenBody, err := getV2TokenBody()
		if err != nil {
			return "", err
		}
		return formatToken(2, v2TokenBody), nil
	}
	return "", fmt.Errorf("invalid token version")
}

func tlsClientConfig(in *restclient.Config) (restclient.TLSClientConfig, error) {
	c := restclient.TLSClientConfig{
		Insecure:   in.TLSClientConfig.Insecure,
		ServerName: in.TLSClientConfig.ServerName,
		CertData:   in.TLSClientConfig.CertData,
		KeyData:    in.TLSClientConfig.KeyData,
		CAData:     in.TLSClientConfig.CAData,
	}
	if in.TLSClientConfig.CAFile != "" {
		data, err := ioutil.ReadFile(in.TLSClientConfig.CAFile)
		if err != nil {
			return c, err
		}
		c.CAData = data
	}
	if in.TLSClientConfig.CertFile != "" {
		data, err := ioutil.ReadFile(in.TLSClientConfig.CertFile)
		if err != nil {
			return c, err
		}
		c.CertData = data
	}
	if in.TLSClientConfig.KeyFile != "" {
		data, err := ioutil.ReadFile(in.TLSClientConfig.KeyFile)
		if err != nil {
			return c, err
		}
		c.KeyData = data
	}
	return c, nil
}

repository: DdMad/argo

repo_name: DdMad/argo


text:
SECTION = "unknown"
DEPENDS = "opensp"
RDEPENDS_${PN} = "sgml-common"
DESCRIPTION = "OpenJade is a suite of tools for validating, \
processing, and applying DSSSL (Document Style Semantics and \
Specification Language) stylesheets to SGML and XML documents."
LICENSE = "BSD"
PR = "r5"
SRC_URI = "${SOURCEFORGE_MIRROR}/openjade/openjade-${PV}.tar.gz \
	   file://configure.patch \
	   file://autoconf.patch \
	   file://makefile.patch \
          "
SRC_URI_append_virtclass-native = " file://oj-native-libosp-fix.patch"

inherit autotools

EXTRA_OECONF = "--enable-spincludedir=${STAGING_INCDIR}/OpenSP \
                --enable-splibdir=${STAGING_LIBDIR}"

acpaths = "-I ${S}/config"

# Trailing whitespace is important. Otherwise compiler arguments will be messed
# up, resulting in a fail in do_configure.
CFLAGS_prepend = "-I${S}/include "

do_configure_append () {
	cp config/configure.in .
}

do_install_append () {
       # Refer to http://www.linuxfromscratch.org/blfs/view/stable/pst/openjade.html
       # for details.
       install -m 0755 ${S}/jade/.libs/openjade ${D}${bindir}/openjade
       ln -sf openjade ${D}${bindir}/jade

       oe_libinstall -a -so -C style libostyle ${D}${libdir}
       oe_libinstall -a -so -C spgrove libospgrove ${D}${libdir}
       oe_libinstall -a -so -C grove libogrove ${D}${libdir}

       install -d ${D}${datadir}/sgml/openjade-${PV}
       install -m 644 dsssl/catalog ${D}${datadir}/sgml/openjade-${PV}
       install -m 644 dsssl/*.{dtd,dsl,sgm} ${D}${datadir}/sgml/openjade-${PV}

       # The catalog must live in the sysroot and it must be there for
       # install-catalog to do its thing.
       install -d ${datadir}/sgml/openjade-${PV}
       install -m 644 dsssl/catalog ${datadir}/sgml/openjade-${PV}/catalog
       install-catalog --add ${sysconfdir}/sgml/openjade-${PV}.cat \
           ${datadir}/sgml/openjade-${PV}/catalog

       install-catalog --add ${sysconfdir}/sgml/sgml-docbook.cat \
           ${sysconfdir}/sgml/openjade-${PV}.cat
}

BBCLASSEXTEND = "native"

SRC_URI[md5sum] = "7df692e3186109cc00db6825b777201e"
SRC_URI[sha256sum] = "1d2d7996cc94f9b87d0c51cf0e028070ac177c4123ecbfd7ac1cb8d0b7d322d1"