text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func (s *RestServer) getEgressDropMetricsHandler(r *http.Request) (interface{}, error) {
log.Infof("Got GET request EgressDropMetrics/%s", mux.Vars(r)["Meta.Name"])
return nil, nil
} | [
-1.2799266576766968,
0.6804620027542114,
0.6590138673782349,
-0.012618053704500198,
0.02200549654662609,
0.6560010313987732,
0.3734256327152252,
-0.7611595392227173,
-0.9413800835609436,
0.34871798753738403,
0.31210431456565857,
0.23180034756660461,
-0.8765299320220947,
0.9307205677032471,... |
func New(logger *log.Logger, cfg Config) (*Scraper, error) {
var errs []error
u, err := url.Parse(cfg.URL)
if err != nil {
errs = append(errs, err)
}
includes, err := compileRegexps(cfg.Includes)
if err != nil {
errs = append(errs, err)
}
excludes, err := compileRegexps(cfg.Excludes)
if err != nil {
e... | [
-0.5361319780349731,
-0.18366466462612152,
0.781409502029419,
0.025950243696570396,
-1.0117297172546387,
0.4380291700363159,
-0.17419514060020447,
0.12843044102191925,
-0.6827146410942078,
0.3687039315700531,
-0.05447331443428993,
0.058637525886297226,
0.13350564241409302,
0.83833998441696... |
func compileRegexps(regexps []string) ([]*regexp.Regexp, error) {
var errs []error
var compiled []*regexp.Regexp
for _, exp := range regexps {
re, err := regexp.Compile(exp)
if err == nil {
compiled = append(compiled, re)
} else {
errs = append(errs, err)
}
}
if len(errs) > 0 {
return nil, errors... | [
-0.26587146520614624,
-1.1708649396896362,
0.30331921577453613,
0.7966092824935913,
0.602346658706665,
0.22328190505504608,
-0.0851738452911377,
0.07310117036104202,
0.7683013081550598,
0.08964505046606064,
0.531883716583252,
-0.3428143262863159,
-0.9419357180595398,
0.03447428345680237,
... |
func (s *Scraper) Start() error {
if s.config.OutputDirectory != "" {
if err := os.MkdirAll(s.config.OutputDirectory, os.ModePerm); err != nil {
return err
}
}
p := s.URL.Path
if p == "" {
p = "/"
}
s.processed[p] = struct{}{}
if s.config.Username != "" {
auth := base64.StdEncoding.EncodeToString([]... | [
-0.8864999413490295,
-0.49951601028442383,
0.5951403379440308,
0.6913843154907227,
-0.3781470060348511,
-0.013167258352041245,
0.34069347381591797,
0.8834759593009949,
-0.7112759351730347,
-0.0548442080616951,
-0.19685928523540497,
0.7583265900611877,
0.22519738972187042,
0.350159883499145... |
func (s *Scraper) storeDownload(u *url.URL, buf *bytes.Buffer, fileExtension string) {
isAPage := false
if fileExtension == "" {
html, fixed, err := s.fixURLReferences(u, buf)
if err != nil {
s.logger.Error("Fixing file references failed",
log.Stringer("url", u),
log.Err(err))
return
}
if fixed... | [
-0.013611765578389168,
-0.6060226559638977,
0.7595297694206238,
0.24241773784160614,
0.03039887361228466,
0.6139707565307617,
0.9715073704719543,
0.34489503502845764,
0.2822224795818329,
-0.5633891224861145,
0.02643316611647606,
0.23343497514724731,
-0.11251891404390335,
0.3801420629024505... |
func LsTask(c *cli.Context) (*gomarathon.Response, error) {
m, _ := MarathonClient(c.GlobalString("host"))
var resp *gomarathon.Response
var err error
//if an arg is supplied, just look for tasks for that app
if len(c.Args()) > 0 {
resp, err = m.GetAppTasks(c.Args().First())
} else {
resp, err = m.ListTasks... | [
0.616696834564209,
0.35613179206848145,
0.6909685134887695,
0.5868710279464722,
0.02053353749215603,
0.08734441548585892,
-0.5261750817298889,
-0.28181159496307373,
-0.214943528175354,
0.2873397171497345,
0.5571418404579163,
0.20256967842578888,
0.29136428236961365,
0.4650139808654785,
-... |
func KillAppTasks(c *cli.Context) (*gomarathon.Response, error) {
m, _ := MarathonClient(c.GlobalString("host"))
var resp *gomarathon.Response
var err error
if len(c.Args()) > 0 {
resp, err = m.KillTasks(c.Args().First(), "", false)
} else {
log.Error("Please provide an app ID")
return nil, errors.New("No... | [
0.5746243596076965,
0.10764826089143753,
0.8555804491043091,
1.8099331855773926,
0.38863545656204224,
0.8500885963439941,
0.22904887795448303,
-0.44572538137435913,
-0.5205339193344116,
0.47796630859375,
0.27888092398643494,
-0.10759254544973373,
-0.14198289811611176,
0.3814318776130676,
... |
func PJW(str []byte) uint32 {
var (
BitsInUnsignedInt uint32 = 4 * 8
ThreeQuarters uint32 = (BitsInUnsignedInt * 3) / 4
OneEighth uint32 = BitsInUnsignedInt / 8
HighBits uint32 = (0xFFFFFFFF) << (BitsInUnsignedInt - OneEighth)
hash uint32 = 0
test uint32 = 0
... | [
0.2550000846385956,
0.3344200849533081,
0.6240658164024353,
0.07741609960794449,
-1.1701931953430176,
0.7984166741371155,
0.092401884496212,
-0.5563236474990845,
0.24636267125606537,
-0.27886682748794556,
-0.39667224884033203,
-0.5282045006752014,
-0.5166985392570496,
0.3588474988937378,
... |
func PJW64(str []byte) uint64 {
var (
BitsInUnsignedInt uint64 = 4 * 8
ThreeQuarters uint64 = (BitsInUnsignedInt * 3) / 4
OneEighth uint64 = BitsInUnsignedInt / 8
HighBits uint64 = (0xFFFFFFFFFFFFFFFF) << (BitsInUnsignedInt - OneEighth)
hash uint64 = 0
test ui... | [
-0.20228311419487,
0.10200536996126175,
0.5976910591125488,
0.5054774284362793,
-1.0016857385635376,
0.5125675201416016,
-0.025493405759334564,
-0.3359791040420532,
0.4976150691509247,
-0.04888411611318588,
-0.2207365781068802,
-0.7035003304481506,
-0.6589612364768982,
0.6032187938690186,
... |
func initService(service *goa.Service) {
// Setup encoders and decoders
service.Encoder.Register(goa.NewJSONEncoder, "application/json")
service.Decoder.Register(goa.NewJSONDecoder, "application/json")
// Setup default encoder and decoder
service.Encoder.Register(goa.NewJSONEncoder, "*/*")
service.Decoder.Regist... | [
-0.7104614973068237,
0.22991874814033508,
0.35907724499702454,
-0.4667642414569855,
0.20444758236408234,
-0.6345656514167786,
-0.6761393547058105,
-0.653590977191925,
0.0001563017867738381,
-0.07766087353229523,
-1.5328956842422485,
0.9755660891532898,
-0.12880443036556244,
1.5688607692718... |
func MountTestServiceController(service *goa.Service, ctrl TestServiceController) {
initService(service)
var h goa.Handler
h = func(ctx context.Context, rw http.ResponseWriter, req *http.Request) error {
// Check if there was an error loading the request
if err := goa.ContextError(ctx); err != nil {
return e... | [
1.2071282863616943,
-0.031785693019628525,
0.8344689011573792,
0.10613727569580078,
0.1443251073360443,
-0.2683177590370178,
0.41433313488960266,
-0.8744063377380371,
0.8128657937049866,
-0.6041262149810791,
0.3667983412742615,
0.4256492853164673,
-0.41597962379455566,
0.6621503233909607,
... |
func NewEncrypter(keys *EEK) (Encrypter, error) {
gcmCipher, err := newGCMCipher(keys.AESKey)
if err != nil {
return nil, err
}
return &encrypter{
gcmCipher: gcmCipher,
pageIVMAC: hmac.New(sha256.New, keys.PageIVSeed),
}, nil
} | [
-0.6446212530136108,
0.006728548556566238,
0.09346579015254974,
0.19601525366306305,
-0.03334815427660942,
-0.04324623569846153,
0.10267000645399094,
-0.38518619537353516,
0.2624939978122711,
1.357129454612732,
-0.5325807929039001,
-0.0736164003610611,
-0.8326912522315979,
1.12567424774169... |
func NewDecrypter(keys *EEK) (Decrypter, error) {
gcmCipher, err := newGCMCipher(keys.AESKey)
if err != nil {
return nil, err
}
return &decrypter{
gcmCipher: gcmCipher,
pageIVMAC: hmac.New(sha256.New, keys.PageIVSeed),
}, nil
} | [
-0.46381875872612,
0.05811832845211029,
0.32553693652153015,
0.17116639018058777,
-0.46853652596473694,
-0.31643107533454895,
-0.1239187940955162,
-0.25131356716156006,
0.3374778628349304,
0.9031082987785339,
-0.33984315395355225,
-0.49203920364379883,
-0.4562298655509949,
1.15838325023651... |
func packagesFromTestName(name string) (string, string) {
if strings.Contains(name, "aws") {
return "@pulumi/aws", test.AwsSchema
} else if strings.Contains(name, "azure-native") {
return "@pulumi/azure-native", test.AzureNativeSchema
} else if strings.Contains(name, "azure") {
return "@pulumi/azure", test.Azu... | [
-0.3074537217617035,
-1.0042904615402222,
0.44519007205963135,
-0.9223198294639587,
-0.20861028134822845,
0.2537556290626526,
-0.5330349206924438,
-0.3054901361465454,
0.9639650583267212,
0.7298226356506348,
-0.4904305934906006,
-0.5755482912063599,
-0.21055461466312408,
0.3338701725006103... |
func IssueSummary(issue *jira.Issue, hasBranch bool) string {
var colouredPriority string
switch issue.Fields.Priority.Name {
case "Low":
colouredPriority = color.GreenString(issue.Fields.Priority.Name)
case "Medium":
colouredPriority = color.HiCyanString(issue.Fields.Priority.Name)
case "High":
colouredPrio... | [
-0.3702848553657532,
0.19076907634735107,
0.7884612083435059,
-1.6771131753921509,
-0.43862834572792053,
-0.48843464255332947,
-0.9334777593612671,
0.18747004866600037,
0.14074572920799255,
0.6250377297401428,
0.09364795684814453,
0.15186788141727448,
0.32639747858047485,
0.074157088994979... |
func JiraKeyFromIssueSummary(summary string) string {
return strings.TrimPrefix(strings.Split(summary, ":")[0], "*")
} | [
-0.12684732675552368,
-0.45121249556541443,
0.7060840129852295,
0.042606618255376816,
-1.1730117797851562,
-0.25100234150886536,
0.07888775318861008,
0.8082619905471802,
0.411545068025589,
1.7957528829574585,
0.6629088521003723,
0.33023470640182495,
0.6246889233589172,
-0.8950678706169128,... |
func RoleKey2Haskey(key string) (hashk int) {
for _, ki := range key {
hashk += int(ki)
}
hashk = hashk % ERedHasKeyTransferMultiNum
if hashk == 0 {
hashk = 1
}
return
} | [
-0.5316938161849976,
-0.6084547638893127,
0.7310945987701416,
-0.16796419024467468,
0.3285350799560547,
0.008943313732743263,
0.4978805482387543,
0.9477764368057251,
-0.11609578877687454,
0.8083334565162659,
0.1526969075202942,
-0.03702522814273834,
-0.16095493733882904,
0.657136082649231,... |
func Download(url string) (ResponseMeta, error) {
// forming a request
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return ResponseMeta{}, err
}
req.Header.Add("Accept-Encoding", "gzip")
// running it into a client
tp := newTimedTransport()
httpClient := &http.Client{Transport: tp}
resp, err... | [
0.4623796045780182,
-0.46040138602256775,
1.1109485626220703,
-0.2437824159860611,
-0.308307945728302,
-0.39175787568092346,
-0.38609418272972107,
-0.11431054025888443,
0.6418390870094299,
0.11463205516338348,
-0.3770662248134613,
0.5814930200576782,
-0.7601253986358643,
-0.127242743968963... |
func TestCertParser(t *testing.T) {
tests := []struct {
name string
certChainName string
Collectors []troubleshootv1beta2.Collect
want []CertCollection
}{
{
name: "expired certificate",
certChainName: "expiredCert",
Collectors: []troubleshootv1beta2.Collect{
{
... | [
0.5063133835792542,
-0.8141513466835022,
0.858025074005127,
-0.24875999987125397,
0.20813389122486115,
0.22013770043849945,
-0.2097848802804947,
-0.9599153995513916,
-0.4451390206813812,
-0.8430822491645813,
-1.0525153875350952,
-0.19298617541790009,
-0.09368634968996048,
0.111225210130214... |
func (sm *ShardMaster) minLoadedGroup(config Config, gidExlcude int64) (int64, int) {
minLoad := -1
var minLoadGID int64 = -1
shards := make(map[int64]int)
// Determine the load on each group
numShards := make(map[int64]int)
// First initialize to 0 for all known groups
// This ensures that we consider known gr... | [
0.049390312284231186,
-0.6029083132743835,
0.8232763409614563,
-0.9355852603912354,
-0.8971967101097107,
-0.32738471031188965,
-0.23956231772899628,
-0.5420818328857422,
0.08987047523260117,
-0.18405242264270782,
-0.03174317255616188,
0.5870546102523804,
-1.2150611877441406,
0.998186945915... |
func (sm *ShardMaster) maxLoadedGroup(config Config) (int64, int) {
maxLoad := -1
var maxLoadGID int64 = -1
shards := make(map[int64]int)
// Determine the load on each group
numShards := make(map[int64]int)
for shard, gid := range config.Shards {
numShards[gid]++
shards[gid] = shard
}
// Determine highest l... | [
-0.18100489675998688,
-0.008738808333873749,
0.6639997959136963,
-0.6600667834281921,
-0.9161078333854675,
-0.3279295861721039,
-0.6850576400756836,
-0.6368793845176697,
-0.04214591532945633,
-0.1344372183084488,
-0.2844680845737457,
0.2057822197675705,
-0.766697347164154,
0.86002659797668... |
func (sm *ShardMaster) haveGroup(config Config, gid int64) bool {
for gidUsed, _ := range config.Groups {
if gid == gidUsed {
return true
}
}
return false
} | [
-0.23873993754386902,
0.8486323356628418,
0.4212234616279602,
-0.36481231451034546,
0.18182897567749023,
-0.18285852670669556,
0.10157658904790878,
0.37086978554725647,
-0.5723908543586731,
0.5451931953430176,
0.06089339405298233,
0.3504592180252075,
-0.5652362704277039,
0.9869698882102966... |
func (sm *ShardMaster) usingGroup(config Config, gid int64) bool {
for _, gidUsed := range config.Shards {
if gid == gidUsed {
return true
}
}
return false
} | [
-0.36712080240249634,
0.8158149123191833,
0.5310506224632263,
-0.3094518184661865,
-0.2774941325187683,
-0.3208460211753845,
0.29343605041503906,
0.06195263937115669,
-0.3119257986545563,
0.7793307304382324,
0.5172106027603149,
-0.07140463590621948,
-0.9996485114097595,
0.8953420519828796,... |
func (sm *ShardMaster) cloneConfig(config Config) Config {
var newConfig Config
newConfig.Groups = make(map[int64][]string)
newConfig.Num = config.Num
for gid, servers := range config.Groups {
newConfig.Groups[gid] = servers
}
for shard, gid := range config.Shards {
newConfig.Shards[shard] = gid
}
return ne... | [
-0.18718205392360687,
-0.13909371197223663,
0.5969061851501465,
0.1496041864156723,
-0.5947080850601196,
0.7138932347297668,
-0.15588881075382233,
0.26894959807395935,
0.45609888434410095,
1.3207697868347168,
-0.9385260939598083,
0.3948184549808502,
-0.5478519797325134,
0.03304162994027138... |
func (sm *ShardMaster) cloneCurrentConfig() Config {
return sm.cloneConfig(sm.configs[len(sm.configs)-1])
} | [
0.1899896115064621,
-0.8883435726165771,
0.802548348903656,
0.7747473120689392,
-0.9382197260856628,
0.8047555088996887,
-0.4277634024620056,
-0.2353467494249344,
0.0174485445022583,
1.1992442607879639,
0.14583908021450043,
0.8900842070579529,
-0.873043417930603,
0.21510328352451324,
0.9... |
func (sm *ShardMaster) addConfig(newConfig Config) {
newList := make([]Config, len(sm.configs)+1)
for index, next := range sm.configs {
newList[index] = sm.cloneConfig(next)
}
newList[len(newList)-1] = sm.cloneConfig(newConfig)
sm.configs = newList
} | [
-0.5765621066093445,
0.5584999918937683,
0.6424567103385925,
0.7378355860710144,
0.037265367805957794,
0.5640827417373657,
-0.24887128174304962,
1.2161598205566406,
0.6677141785621643,
0.9403018951416016,
-0.7638540267944336,
0.3386920392513275,
-0.463529497385025,
1.0757490396499634,
0.... |
func (sm *ShardMaster) update() {
var noop Op
noop.ProposedConfig.Num = 0
// Concatenate first 16 digits of current time with
// first 3 digits of sm.me
// Using 3 digits of sm.me allows for a thousand peers
// Using 16 digits of the time means it won't repeat for about 115 days
// Using both time and "me"... | [
-0.6503143906593323,
0.014869637787342072,
0.7141915559768677,
-0.1622161567211151,
-0.6060394048690796,
-0.15586531162261963,
-0.279222697019577,
0.602680504322052,
-0.04216628521680832,
0.5119898915290833,
-0.3538263142108917,
0.19757457077503204,
-0.9756146669387817,
0.8047899007797241,... |
func (sm *ShardMaster) Kill() {
sm.dead = true
sm.l.Close()
sm.px.Kill()
} | [
0.09839972108602524,
-0.7147015929222107,
0.3361698091030121,
0.3317011296749115,
0.06638233363628387,
1.4828667640686035,
-0.44520533084869385,
0.5004239082336426,
0.15288104116916656,
0.6406500935554504,
-0.1824101358652115,
0.18139846622943878,
-0.11001123487949371,
0.17320947349071503,... |
func StartServer(servers []string, me int) *ShardMaster {
gob.Register(Op{})
sm := new(ShardMaster)
sm.me = me
sm.configs = make([]Config, 1)
sm.configs[0].Groups = map[int64][]string{}
rpcs := rpc.NewServer()
rpcs.Register(sm)
sm.px = paxos.Make(servers, me, rpcs)
os.Remove(servers[me])
l, e := net.List... | [
-0.24933549761772156,
-0.3893630802631378,
0.952064573764801,
0.14859427511692047,
0.16663847863674164,
-0.07446108013391495,
-0.7753300666809082,
0.26942357420921326,
0.30635401606559753,
-0.21731053292751312,
0.0989958643913269,
0.7160585522651672,
-1.270706057548523,
-0.2161234766244888... |
func (news *News) SetCreatedTime() {
news.CreatedTime=time.Now()
} | [
0.29938820004463196,
-0.3046889305114746,
-0.13304661214351654,
-0.03885895013809204,
0.6478414535522461,
0.587556004524231,
-0.7844941020011902,
0.16277943551540375,
-0.7332748770713806,
-0.17715419828891754,
-0.7982022762298584,
-0.7508216500282288,
-0.48982179164886475,
1.70988273620605... |
func GetNewsPaginated(pageId int, pageSize int) ([]News,int) {
var news []News
var count int64
pageId-=1
db.Model(&news).Count(&count)
db.Order("CreatedTime desc").Offset(pageSize*pageId).Limit(pageSize).Find(&news)
pageCount:=int(count)/pageSize
if int(count)%pageSize!=0 {
pageCount++
}
return news,pageC... | [
0.1496659219264984,
-0.33665934205055237,
0.48567718267440796,
0.06041479483246803,
0.011994509026408195,
-0.26896509528160095,
-0.501990020275116,
-0.15215739607810974,
0.16761209070682526,
0.38559311628341675,
-0.2444707453250885,
-0.04291588068008423,
-0.021767962723970413,
1.8586976528... |
func GetNewsById(id int) (News,error) {
var news News
if err:=db.First(&news,id).Error;err!=nil{
return news,err
}
return news,nil
} | [
0.8291261196136475,
1.013251781463623,
-0.1608058512210846,
0.2763591706752777,
0.15934760868549347,
-0.5015015602111816,
-0.6432774662971497,
-1.11578369140625,
0.014894945546984673,
0.16627460718154907,
-0.6224231719970703,
-0.7521092891693115,
-0.49290475249290466,
1.2143189907073975,
... |
func AddNewNews(news News) (int,error) {
if err:=db.Create(&news).Error;err!=nil{
return 0,err
}
return news.ID,nil
} | [
-0.5319151878356934,
0.23911714553833008,
0.38086462020874023,
0.502890944480896,
-0.4844476580619812,
0.5555518865585327,
-0.20947501063346863,
-0.5404351949691772,
-0.02798902802169323,
-0.024006593972444534,
-0.4879625737667084,
-1.5185699462890625,
-1.3102340698242188,
1.41012442111969... |
func UpdateNews(news News) error {
if err:=db.Select("*").Updates(&news).Error;err!=nil{
return err
}
return nil
} | [
-0.8487213850021362,
0.35639509558677673,
0.06812881678342819,
0.7095011472702026,
-0.41853079199790955,
0.37538060545921326,
-0.9421419501304626,
-0.25151950120925903,
0.006889539770781994,
0.3284303545951843,
-0.09797574579715729,
-0.6826270818710327,
-0.4600890576839447,
0.8856853246688... |
func UTF82GBK(src string) ([]byte, error) {
GB18030 := simplifiedchinese.All[0]
return ioutil.ReadAll(transform.NewReader(bytes.NewReader([]byte(src)), GB18030.NewEncoder()))
} | [
-0.23682193458080292,
0.24903766810894012,
0.3680429458618164,
-0.05489635095000267,
0.14298614859580994,
-0.5612804889678955,
0.0972808375954628,
-0.001261867000721395,
-0.05514639616012573,
0.4220569431781769,
-0.4140687584877014,
0.7552658915519714,
0.505172073841095,
-0.160545811057090... |
func TestMarkOffline(t *testing.T) {
suicide := int64(0)
go func() {
s.Join()
atomic.StoreInt64(&suicide, 1)
}()
err := models.SetProxyStatus(conn, conf.productName, conf.proxyId, models.PROXY_STATE_MARK_OFFLINE)
assert.MustNoError(err)
time.Sleep(3 * time.Second)
if atomic.LoadInt64(&suicide) == 0 {
t.... | [
-0.21476534008979797,
0.18005067110061646,
0.48568543791770935,
0.33108922839164734,
1.220687985420227,
0.8768239617347717,
0.510715126991272,
0.655369222164154,
0.530508279800415,
0.05055958405137062,
-1.156179428100586,
0.028763622045516968,
-0.24516288936138153,
-0.30943959951400757,
... |
func (cs commentsByTimestamp) Len() int { return len(cs) } | [
0.29772359132766724,
-0.404389888048172,
0.2184746265411377,
-0.3667488098144531,
0.6099114418029785,
-0.612436056137085,
0.9411903619766235,
-0.055391810834407806,
0.025994203984737396,
-0.19904296100139618,
-0.9651505947113037,
-0.3900355398654938,
0.865361750125885,
-0.20167064666748047... |
func (threads byTimestamp) Len() int { return len(threads) } | [
0.46905842423439026,
-0.2851116359233856,
0.16709545254707336,
-0.06364928930997849,
0.8389801383018494,
-0.4630609452724457,
0.8541399240493774,
0.19716167449951172,
0.7171746492385864,
-0.2835516929626465,
-0.6751133799552917,
0.10999932140111923,
0.34322404861450195,
-0.2077279090881347... |
func (requests requestsByTimestamp) Len() int { return len(requests) } | [
-0.14981316030025482,
0.02768167480826378,
0.0739094689488411,
-0.002193954773247242,
0.3588710129261017,
-0.3479248881340027,
0.24062147736549377,
-0.06776613742113113,
0.5280494093894958,
-0.598722517490387,
-0.6695565581321716,
-0.5711778402328491,
0.9048789143562317,
-0.040783334523439... |
func (summaries summariesWithNewestRequestsFirst) Len() int { return len(summaries) } | [
0.7547928094863892,
0.2722908556461334,
0.0617496557533741,
-0.21375969052314758,
0.7986367344856262,
0.134831503033638,
0.7981063723564148,
0.4165027141571045,
-0.02238626219332218,
-0.9581230878829956,
-0.08966759592294693,
0.13781113922595978,
0.9503984451293945,
0.7791260480880737,
0... |
func updateThreadsStatus(threads []CommentThread) *bool {
sort.Stable(byTimestamp(threads))
noUnresolved := true
var result *bool
for i := range threads {
thread := &threads[i]
thread.updateResolvedStatus()
if thread.Resolved != nil {
noUnresolved = noUnresolved && *thread.Resolved
result = &noUnresolve... | [
-0.5822277665138245,
-0.5734607577323914,
0.7372134923934937,
-0.6192073822021484,
0.5446741580963135,
0.44363874197006226,
-0.763230562210083,
-0.5769383311271667,
0.4374634325504303,
0.7425797581672668,
-0.3417171239852905,
-0.7777988314628601,
-1.5333608388900757,
0.649288535118103,
-... |
func (thread *CommentThread) updateResolvedStatus() {
resolved := updateThreadsStatus(thread.Children)
if resolved == nil {
thread.Resolved = thread.Comment.Resolved
return
}
if !*resolved {
thread.Resolved = resolved
return
}
if thread.Comment.Resolved == nil || !*thread.Comment.Resolved {
thread.Res... | [
0.16660237312316895,
-1.438486099243164,
0.5640631914138794,
-0.5366840958595276,
0.7153617739677429,
-0.45219600200653076,
-0.2568396329879761,
0.42301854491233826,
-0.33240681886672974,
-0.24710941314697266,
-1.3292979001998901,
-0.2707313001155853,
-0.8456737399101257,
0.190331578254699... |
func (thread *CommentThread) Verify() error {
err := gpg.Verify(&thread.Comment)
if err != nil {
hash, _ := thread.Comment.Hash()
return fmt.Errorf("verification of comment [%s] failed: %s", hash, err)
}
for _, child := range thread.Children {
err = child.Verify()
if err != nil {
return err
}
}
retur... | [
0.7816532850265503,
-0.2859313189983368,
0.6519027948379517,
0.66010981798172,
1.5752408504486084,
-0.07782633602619171,
0.24057668447494507,
-0.5488781929016113,
-0.7652119398117065,
-0.1947982758283615,
-1.0489773750305176,
0.3808383047580719,
-0.4423292875289917,
1.0311784744262695,
-... |
func fixMutableThread(mutableThread *mutableThread) CommentThread {
var children []CommentThread
edited := len(mutableThread.Edits) > 0
for _, mutableChild := range mutableThread.Children {
child := fixMutableThread(mutableChild)
if (!edited) && child.Edited {
edited = true
}
children = append(children, c... | [
0.33142539858818054,
-1.4897973537445068,
0.972230076789856,
0.04577983170747757,
-0.09686826914548874,
-0.03427206352353096,
-0.02762206457555294,
-0.1362743079662323,
0.12458104640245438,
0.10168760269880295,
-0.11355143040418625,
0.5497176051139832,
-0.5830090045928955,
0.80182784795761... |
func buildCommentThreads(commentsByHash map[string]comment.Comment) []CommentThread {
threadsByHash := make(map[string]*mutableThread)
for hash, comment := range commentsByHash {
thread, ok := threadsByHash[hash]
if !ok {
thread = &mutableThread{
Hash: hash,
Comment: comment,
}
threadsByHash[h... | [
0.1762169748544693,
-1.4822932481765747,
1.1303759813308716,
0.538486123085022,
0.5708563327789307,
-0.3728562593460083,
0.24759383499622345,
-0.04771356284618378,
0.2580816447734833,
0.1858380138874054,
0.1792503446340561,
0.11750903725624084,
-0.49264633655548096,
0.3619350492954254,
-... |
func getCommentsFromNotes(repo repository.Repo, revision string, commentNotes []repository.Note) ([]CommentThread, *bool) {
commentsByHash := comment.ParseAllValid(commentNotes)
comments := buildCommentThreads(commentsByHash)
resolved := updateThreadsStatus(comments)
return comments, resolved
} | [
0.14323864877223969,
-0.732110857963562,
0.5917147994041443,
0.45941925048828125,
1.0063031911849976,
-0.4349690079689026,
-0.32554128766059875,
-0.47369077801704407,
-0.08617986738681793,
0.2668450176715851,
-0.3679604232311249,
-0.30306312441825867,
-1.1554759740829468,
-0.41271552443504... |
func GetSummaryViaRefs(repo repository.Repo, requestRef, commentRef, revision string) (*Summary, error) {
if err := repo.VerifyCommit(revision); err != nil {
return nil, fmt.Errorf("Could not find a commit named %q", revision)
}
requestNotes := repo.GetNotes(requestRef, revision)
commentNotes := repo.GetNotes(com... | [
0.4278387129306793,
0.19173692166805267,
0.6252023577690125,
-0.9702085256576538,
0.3047153651714325,
-0.08048443496227264,
-0.1315360814332962,
-0.7784210443496704,
0.19151580333709717,
-0.029957229271531105,
0.772325873374939,
0.7860320806503296,
-0.3804117441177368,
0.1559247374534607,
... |
func GetSummary(repo repository.Repo, revision string) (*Summary, error) {
return GetSummaryViaRefs(repo, request.Ref, comment.Ref, revision)
} | [
0.20027078688144684,
0.5514203310012817,
0.5084661841392517,
0.3368060290813446,
0.4290679097175598,
-0.6445282101631165,
-0.3319075107574463,
-0.7951692938804626,
0.05507238581776619,
-0.1829492598772049,
0.17328330874443054,
0.915594756603241,
-0.3497503399848938,
-0.25795796513557434,
... |
func (r *Summary) Details() (*Review, error) {
review := Review{
Summary: r,
}
currentCommit, err := review.GetHeadCommit()
if err == nil {
review.Reports = ci.ParseAllValid(review.Repo.GetNotes(ci.Ref, currentCommit))
review.Analyses = analyses.ParseAllValid(review.Repo.GetNotes(analyses.Ref, currentCommit))... | [
0.49879851937294006,
-0.34327763319015503,
0.2891460359096527,
-1.0820850133895874,
-0.11920712888240814,
-0.059807758778333664,
-0.654082715511322,
-0.36176183819770813,
0.07706984877586365,
-0.11557045578956604,
0.6259490847587585,
-0.24831105768680573,
-0.46159717440605164,
-0.438887327... |
func (r *Summary) IsAbandoned() bool {
return r.Request.TargetRef == ""
} | [
-0.3139735460281372,
-0.31922972202301025,
0.42882949113845825,
-0.3707994818687439,
0.3869580626487732,
1.1178959608078003,
-0.46386346220970154,
-0.09556569904088974,
1.1690794229507446,
0.5547861456871033,
1.0092047452926636,
1.189117193222046,
-0.006351454183459282,
0.8219155669212341,... |
func (r *Summary) IsOpen() bool {
return !r.Submitted && !r.IsAbandoned()
} | [
-0.4707935154438019,
-0.38240885734558105,
0.6226006746292114,
0.2986195981502533,
-1.2034426927566528,
1.1083428859710693,
0.39704617857933044,
0.3664933741092682,
0.06520151346921921,
0.2955455183982849,
0.8706111907958984,
0.5215513110160828,
-0.46232131123542786,
-0.060244299471378326,... |
func (r *Summary) Verify() error {
err := gpg.Verify(&r.Request)
if err != nil {
return fmt.Errorf("couldn't verify request targeting: %q: %s",
r.Request.TargetRef, err)
}
for _, thread := range r.Comments {
err := thread.Verify()
if err != nil {
return err
}
}
return nil
} | [
-0.35991016030311584,
0.10528817027807236,
0.44959262013435364,
0.5125504732131958,
1.6024903059005737,
0.13843050599098206,
0.20480503141880035,
-1.1349753141403198,
-0.5081306099891663,
0.06560686230659485,
0.04001064598560333,
0.7042366862297058,
-0.5259791016578674,
0.7177742123603821,... |
func Get(repo repository.Repo, revision string) (*Review, error) {
summary, err := GetSummary(repo, revision)
if err != nil {
return nil, err
}
if summary == nil {
return nil, nil
}
return summary.Details()
} | [
0.1584923416376114,
-0.04335794225335121,
0.37993884086608887,
-0.5815529823303223,
0.10428939014673233,
0.00579874636605382,
-1.38408362865448,
0.33879271149635315,
-0.5812086462974548,
0.10467565804719925,
0.5044384598731995,
0.651645839214325,
-0.43351760506629944,
-0.608099102973938,
... |
func ListAll(repo repository.Repo) []Summary {
reviews := unsortedListAll(repo)
sort.Stable(summariesWithNewestRequestsFirst(reviews))
return reviews
} | [
-0.09314453601837158,
-0.28623807430267334,
0.48383498191833496,
0.12254371494054794,
0.13780266046524048,
1.1370867490768433,
-1.1613504886627197,
-0.2394130975008011,
0.28786808252334595,
0.2152746319770813,
0.6900509595870972,
0.9525744318962097,
0.3359912931919098,
1.2032440900802612,
... |
func ListOpen(repo repository.Repo) []Summary {
var openReviews []Summary
for _, review := range unsortedListAll(repo) {
if review.IsOpen() {
openReviews = append(openReviews, review)
}
}
sort.Stable(summariesWithNewestRequestsFirst(openReviews))
return openReviews
} | [
-1.2509621381759644,
-0.4617552161216736,
0.6973028779029846,
-0.4976128339767456,
-0.7245616316795349,
0.9262772798538208,
-0.5630961060523987,
0.7182002663612366,
0.5676261782646179,
0.10861337929964066,
0.42050445079803467,
0.1270424723625183,
-0.0458272360265255,
0.09417740255594254,
... |
func GetCurrent(repo repository.Repo) (*Review, error) {
reviewRef, err := repo.GetHeadRef()
if err != nil {
return nil, err
}
var matchingReviews []Summary
for _, review := range ListOpen(repo) {
if review.Request.ReviewRef == reviewRef {
matchingReviews = append(matchingReviews, review)
}
}
if matchin... | [
-0.44314512610435486,
-0.6723446846008301,
0.618112325668335,
-0.4931669533252716,
-0.2657698392868042,
0.29652541875839233,
-0.4881279170513153,
-0.1596861034631729,
-0.42327335476875305,
0.20687271654605865,
1.181915044784546,
0.4636111557483673,
-0.8698336482048035,
0.06162417680025101,... |
func (r *Review) GetBuildStatusMessage() string {
statusMessage := "unknown"
ciReport, err := ci.GetLatestCIReport(r.Reports)
if err != nil {
return fmt.Sprintf("unknown: %s", err)
}
if ciReport != nil {
statusMessage = fmt.Sprintf("%s (%q)", ciReport.Status, ciReport.URL)
}
return statusMessage
} | [
-0.42863020300865173,
-1.0737074613571167,
0.4485592246055603,
-0.18103154003620148,
0.6747466921806335,
0.7379492521286011,
0.06921590864658356,
0.8821926712989807,
0.08379774540662766,
-0.8374565243721008,
-0.2966029644012451,
0.397214412689209,
-1.169918417930603,
0.5930123925209045,
... |
func (r *Review) GetAnalysesNotes() ([]analyses.Note, error) {
latestAnalyses, err := analyses.GetLatestAnalysesReport(r.Analyses)
if err != nil {
return nil, err
}
if latestAnalyses == nil {
return nil, fmt.Errorf("No analyses available")
}
return latestAnalyses.GetNotes()
} | [
0.10061073303222656,
-0.20375026762485504,
0.1579856127500534,
-0.2377985119819641,
0.4639317989349365,
0.18720658123493195,
-0.633758008480072,
-0.9517443776130676,
0.3895050585269928,
-0.22196218371391296,
0.64560467004776,
0.108360156416893,
-0.3427971303462982,
0.295533686876297,
0.2... |
func (r *Review) GetAnalysesMessage() string {
latestAnalyses, err := analyses.GetLatestAnalysesReport(r.Analyses)
if err != nil {
return err.Error()
}
if latestAnalyses == nil {
return "No analyses available"
}
status := latestAnalyses.Status
if status != "" && status != analyses.StatusNeedsMoreWork {
ret... | [
-0.3366250991821289,
-0.16369055211544037,
0.5443356037139893,
-0.8988504409790039,
0.24567529559135437,
-0.09743791818618774,
-0.057604383677244186,
-1.453993320465088,
0.18028180301189423,
0.37293505668640137,
1.2191200256347656,
0.12565229833126068,
-0.22075097262859344,
0.3324181735515... |
func GetCommentsJSON(cs []CommentThread) (string, error) {
jsonBytes, err := json.Marshal(cs)
if err != nil {
return "", err
}
return prettyPrintJSON(jsonBytes)
} | [
-0.08370428532361984,
-1.2197136878967285,
0.49671173095703125,
-0.4667678773403168,
-0.12072743475437164,
-0.3240610659122467,
-0.08639565110206604,
-1.3152363300323486,
0.4520440995693207,
0.9120411276817322,
-0.4538508653640747,
0.4769259989261627,
-0.4591611325740814,
0.486457556486129... |
func (r *Summary) GetJSON() (string, error) {
jsonBytes, err := json.Marshal(*r)
if err != nil {
return "", err
}
return prettyPrintJSON(jsonBytes)
} | [
-0.38589680194854736,
-0.38369253277778625,
0.7433779239654541,
-0.0438871793448925,
-0.8779123425483704,
-0.15134431421756744,
-0.13120435178279877,
-0.41941186785697937,
0.8370567560195923,
0.434037446975708,
0.12491641193628311,
1.4375016689300537,
-0.15009067952632904,
-0.0704016983509... |
func (r *Review) GetJSON() (string, error) {
jsonBytes, err := json.Marshal(*r)
if err != nil {
return "", err
}
return prettyPrintJSON(jsonBytes)
} | [
-0.36315226554870605,
-0.5747525691986084,
0.5590811967849731,
-0.1693081110715866,
-0.8425827622413635,
-0.0953693762421608,
-0.893826425075531,
-0.1555589884519577,
0.46972379088401794,
0.20109902322292328,
0.177024707198143,
1.1193733215332031,
-0.6393426656723022,
0.1175810843706131,
... |
func (r *Review) findLastCommit(startingCommit, latestCommit string, commentThreads []CommentThread) string {
isLater := func(commit string) bool {
if err := r.Repo.VerifyCommit(commit); err != nil {
return false
}
if t, e := r.Repo.IsAncestor(latestCommit, commit); e == nil && t {
return true
}
if t, ... | [
0.9133728742599487,
-1.5664939880371094,
1.1898390054702759,
-0.6371868848800659,
0.2885124981403351,
-0.5909545421600342,
-0.4597267508506775,
-1.0574696063995361,
-0.63042151927948,
0.7454612851142883,
0.541955828666687,
-0.36729058623313904,
-1.46165931224823,
0.846056342124939,
-1.12... |
func (r *Review) GetHeadCommit() (string, error) {
currentCommit := r.getStartingCommit()
if r.Request.ReviewRef == "" {
return currentCommit, nil
}
if r.Submitted {
// The review has already been submitted.
// Go through the list of comments and find the last commented upon commit.
return r.findLastCommit... | [
0.34524500370025635,
-0.8616809844970703,
0.8039098978042603,
-0.21582673490047455,
-0.17381399869918823,
-0.592308521270752,
-0.12343687564134598,
-0.9766605496406555,
-0.042016103863716125,
0.23322822153568268,
1.4395965337753296,
0.2802097499370575,
-1.1737067699432373,
0.40362262725830... |
func (r *Review) GetBaseCommit() (string, error) {
if !r.IsOpen() {
if r.Request.BaseCommit != "" {
return r.Request.BaseCommit, nil
}
// This means the review has been submitted, but did not specify a base commit.
// In this case, we have to treat the last parent commit as the base. This is
// usually w... | [
-0.06797683238983154,
-0.6752392053604126,
0.9383109211921692,
-0.29092100262641907,
0.5205574035644531,
-0.36694809794425964,
-0.6817531585693359,
-0.6961758136749268,
-0.5499420762062073,
0.03402700275182724,
1.2550296783447266,
0.346884548664093,
-1.181168794631958,
0.4670892357826233,
... |
func (r *Review) ListCommits() ([]string, error) {
baseCommit, err := r.GetBaseCommit()
if err != nil {
return nil, err
}
headCommit, err := r.GetHeadCommit()
if err != nil {
return nil, err
}
return r.Repo.ListCommitsBetween(baseCommit, headCommit)
} | [
0.06868091225624084,
-1.320516586303711,
0.3475179076194763,
-0.21153350174427032,
0.1659540832042694,
-0.18585990369319916,
-1.454872488975525,
-1.5368112325668335,
0.04372284933924675,
0.28677526116371155,
0.17170949280261993,
0.7508928179740906,
-1.1440739631652832,
0.3951195776462555,
... |
func (r *Review) GetDiff(diffArgs ...string) (string, error) {
var baseCommit, headCommit string
baseCommit, err := r.GetBaseCommit()
if err == nil {
headCommit, err = r.GetHeadCommit()
}
if err == nil {
return r.Repo.Diff(baseCommit, headCommit, diffArgs...)
}
return "", err
} | [
-0.28598496317863464,
-0.2134580910205841,
0.7396222352981567,
0.48424869775772095,
0.5256413221359253,
0.09239985793828964,
-0.2061174064874649,
-0.5281279683113098,
-0.407231867313385,
-0.282189279794693,
0.23024135828018188,
0.11503477394580841,
-1.0975258350372314,
0.6159597635269165,
... |
func (r *Review) AddComment(c comment.Comment) error {
commentNote, err := c.Write()
if err != nil {
return err
}
r.Repo.AppendNote(comment.Ref, r.Revision, commentNote)
return nil
} | [
0.22786639630794525,
-0.03347437456250191,
0.5256407260894775,
-0.5623117685317993,
0.693786084651947,
0.7462343573570251,
0.3196311295032501,
0.22557033598423004,
-0.22044503688812256,
0.12010084837675095,
0.25626665353775024,
-0.4772675633430481,
-0.7362503409385681,
0.4617466926574707,
... |
func (r *Review) Rebase(archivePrevious bool) error {
if archivePrevious {
orig, err := r.GetHeadCommit()
if err != nil {
return err
}
if err := r.Repo.ArchiveRef(orig, archiveRef); err != nil {
return err
}
}
if err := r.Repo.SwitchToRef(r.Request.ReviewRef); err != nil {
return err
}
err := r.... | [
-0.5064104199409485,
-0.46584123373031616,
0.972204327583313,
-0.29804727435112,
0.9919496178627014,
-0.10515855252742767,
-0.2114322930574417,
-0.12005966156721115,
-0.18491925299167633,
1.17872953414917,
0.27187055349349976,
0.1457732617855072,
-0.9698092341423035,
-0.07059499621391296,
... |
func (r *Review) RebaseAndSign(archivePrevious bool) error {
if archivePrevious {
orig, err := r.GetHeadCommit()
if err != nil {
return err
}
if err := r.Repo.ArchiveRef(orig, archiveRef); err != nil {
return err
}
}
if err := r.Repo.SwitchToRef(r.Request.ReviewRef); err != nil {
return err
}
er... | [
-0.5018442273139954,
-1.0416500568389893,
0.8938921093940735,
-0.008395983837544918,
0.3711988627910614,
-0.004419413860887289,
-0.05675773695111275,
0.18958981335163116,
-0.13677598536014557,
1.1082720756530762,
-0.019883567467331886,
-0.05457872152328491,
-0.5128347277641296,
0.386624813... |
func parseMasterKey(masterkey string, fromStdin bool) []byte {
masterkey = strings.Replace(masterkey, "-", "", -1)
key, err := hex.DecodeString(masterkey)
if err != nil {
tlog.Fatal.Printf("Could not parse master key: %v", err)
os.Exit(exitcodes.MasterKey)
}
if len(key) != cryptocore.KeyLen {
tlog.Fatal.Prin... | [
0.5940061211585999,
-0.39699751138687134,
0.8713393211364746,
0.36804673075675964,
-0.8752029538154602,
0.20833483338356018,
-0.1581074446439743,
1.0645062923431396,
0.05509817227721214,
0.46051573753356934,
-0.03543463349342346,
0.8761252760887146,
-0.22385777533054352,
1.0036994218826294... |
func getMasterKey(pwd *string) (masterkey []byte, confFile *configfile.ConfFile) {
masterkeyFromStdin := false
// "-masterkey=stdin"
if options.masterkey == "stdin" {
options.masterkey = string(readpassword.Once(nil, "", "Masterkey"))
masterkeyFromStdin = true
}
// "-masterkey=941a6029-3adc6a1c-..."
if option... | [
0.20635883510112762,
-0.37317028641700745,
0.7695881128311157,
0.45005008578300476,
-0.5922594666481018,
-0.047438859939575195,
0.570622444152832,
0.7403202056884766,
0.24747848510742188,
0.2726094126701355,
-0.2636350095272064,
0.322714239358902,
-0.798909068107605,
0.566917896270752,
0... |
func loadConfig(pwd *string) (masterkey []byte, cf *configfile.ConfFile, err error) {
// First check if the file can be read at all, and find out if a Trezor should
// be used instead of a password.
cf, err = configfile.Load(options.config)
if err != nil {
tlog.Fatal.Printf("Cannot open config file: %v", err)
r... | [
0.4258745610713959,
-0.16888423264026642,
0.637939453125,
0.6452432870864868,
-0.09685371071100235,
-0.2635425329208374,
0.5650721788406372,
1.304073452949524,
-0.5476190447807312,
0.6137198805809021,
-0.4392898678779602,
-0.5996012687683105,
-0.830696165561676,
0.656494140625,
0.8408329... |
func HandleProfile(writter http.ResponseWriter, request *http.Request) {
fmt.Fprintln(writter, "<b>This is the user profile</b><a href='http://google.com'>this is a link</a>")
} | [
-0.08878324925899506,
0.3024477958679199,
0.4857749938964844,
0.6554040312767029,
0.7121888399124146,
0.10305225104093552,
0.6599030494689941,
0.5284876823425293,
0.058403000235557556,
-0.7788389921188354,
0.3008812367916107,
-0.32170647382736206,
-0.5726145505905151,
0.4431406855583191,
... |
func GenericPostRequest(writter http.ResponseWriter, request *http.Request) {
decoder := json.NewDecoder(request.Body)
var metadata MetaData
err := decoder.Decode(&metadata)
if err != nil {
fmt.Fprintf(writter, "error %v", err)
return
}
fmt.Fprintf(writter, "Payload %v\n", metadata)
} | [
-1.3817168474197388,
-0.9277809858322144,
0.7767099142074585,
-1.0537168979644775,
-0.09588782489299774,
0.3399864137172699,
-1.3391194343566895,
-0.07754584401845932,
-1.379010558128357,
0.43473780155181885,
0.5057246685028076,
0.5572928190231323,
0.6796663403511047,
0.47192519903182983,
... |
func UserPostRequest(writter http.ResponseWriter, request *http.Request) {
decoder := json.NewDecoder(request.Body)
var user User
err := decoder.Decode(&user)
if err != nil {
fmt.Fprintf(writter, "error %v", err)
return
}
response, error := user.ToJSON()
if error != nil {
writter.WriteHeader(http.StatusI... | [
-1.383805274963379,
-1.0654020309448242,
0.8273195028305054,
-0.16032786667346954,
-1.145416259765625,
-0.18440265953540802,
0.18974263966083527,
-0.21734793484210968,
-0.059166498482227325,
0.03433530032634735,
-0.6684359908103943,
0.007970469072461128,
0.20633283257484436,
0.187862500548... |
func init() {
rand.Seed(time.Now().UnixNano())
} | [
0.3500710427761078,
-0.1904304325580597,
0.6106269359588623,
-0.1949213743209839,
0.3213644027709961,
1.0067514181137085,
-0.032394763082265854,
0.7884777784347534,
-0.2932552695274353,
-0.33315524458885193,
-0.656701922416687,
0.8827993273735046,
0.01779796928167343,
0.8177163004875183,
... |
func getErrOrigin() string {
var origin string
if pc, file, line, ok := runtime.Caller(2); ok {
if f := runtime.FuncForPC(pc); f != nil {
if wd, err := os.Getwd(); err == nil {
origin = fmt.Sprintf("%s %s:%d", strings.TrimPrefix(f.Name(), pkgPath), strings.TrimPrefix(file, wd+string(os.PathSeparator)), line)... | [
-0.2662777006626129,
-0.5002614259719849,
0.9475997090339661,
-0.09749458730220795,
-0.22238127887248993,
0.5098515748977661,
0.7659357786178589,
0.8824667930603027,
-0.74388587474823,
-0.22343765199184418,
0.035483475774526596,
0.4888239800930023,
0.14876782894134521,
0.2042437493801117,
... |
func GenerateRandomSentences(count int) string {
if count <= 0 {
return "🙂" // if there is nothing to say, an emoji worths for thousands
}
var random string
for i := 0; i < count; i++ {
n := rand.Int() % len(words)
random += words[n] + " "
}
return random[:len(random)-1] + "."
} | [
-0.015645505860447884,
-0.12401573359966278,
0.8078562617301941,
-0.1898382157087326,
-0.5702348947525024,
-0.1949034035205841,
0.10677100718021393,
-0.592401921749115,
0.6703438758850098,
0.992774486541748,
0.19817714393138885,
-0.9083525538444519,
-0.9331769943237305,
0.8595360517501831,... |
func (conn *Conn) Connect() error {
u := url.URL{Scheme: "wss", Host: IP}
socket, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
if err != nil {
return err
}
if conn.length < 1 {
conn.length = 50
}
if conn.generator == nil {
conn.generator = nonce.WichmannHill
}
conn.socket = socket
conn.done =... | [
-0.16391800343990326,
-0.5077008008956909,
0.6473626494407654,
0.3052739202976227,
-0.15806658565998077,
-0.3197007179260254,
-0.16567763686180115,
-0.9354181885719299,
-0.8004187345504761,
0.14314895868301392,
0.17611809074878693,
-0.2781559228897095,
0.2576727271080017,
0.603113234043121... |
func (conn *Conn) Reconnect() error {
if conn.isConnected {
conn.Close()
}
if err := conn.Connect(); err != nil {
return err
}
for _, f := range conn.onReconnect {
go f()
}
return nil
} | [
0.03314065933227539,
-0.09020844846963882,
0.49141404032707214,
1.1181840896606445,
0.4781021773815155,
-1.2502678632736206,
-0.30751219391822815,
-0.3911685347557068,
-0.609634518623352,
-0.3099374771118164,
-0.2590055763721466,
-0.05757130682468414,
-0.19256746768951416,
0.09096603095531... |
func (conn *Conn) Write(msgType int, data []byte) error {
conn.writer.Lock()
defer conn.writer.Unlock()
return conn.socket.WriteMessage(msgType, data)
} | [
-1.2218999862670898,
0.49221745133399963,
0.33946195244789124,
0.030145594850182533,
1.0441089868545532,
-0.4248524308204651,
-0.23239248991012573,
-0.8293431401252747,
-0.6345841884613037,
0.3094728887081146,
-0.24565811455249786,
0.36090895533561707,
-1.7424871921539307,
0.58887386322021... |
func (conn *Conn) WriteMessage(msgType MessageType, data interface{}) error {
msg := Packet{
Type: msgType,
Data: data,
}
bytes, err := json.Marshal(msg)
if err != nil {
return err
}
return conn.Write(websocket.TextMessage, bytes)
} | [
-1.3843587636947632,
0.35674184560775757,
0.5809265971183777,
-0.5393096208572388,
0.4098224341869354,
-0.7347126007080078,
-0.9866905808448792,
-0.2613711357116699,
0.07492144405841827,
0.3215579688549042,
-0.4795439839363098,
0.6269325613975525,
-1.017865538597107,
0.7193994522094727,
... |
func (conn *Conn) WriteMessageWithNonce(msgType MessageType, nonce string, data interface{}) error {
msg := Packet{
Type: msgType,
Nonce: nonce,
Data: data,
}
bytes, err := json.Marshal(msg)
if err != nil {
return err
}
if err := conn.Write(websocket.TextMessage, bytes); err != nil {
return err
}
co... | [
-0.5609312057495117,
0.058506179600954056,
0.91907799243927,
-0.29216426610946655,
0.12171877920627594,
-1.1680207252502441,
-0.2061804234981537,
-0.7089911699295044,
-0.23063702881336212,
0.20566511154174805,
0.04978441819548607,
-0.32668498158454895,
-1.3603464365005493,
1.05907011032104... |
func (conn *Conn) Close() {
conn.Write(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
timer := time.NewTimer(time.Second)
defer timer.Stop()
select {
case <-conn.done:
case <-timer.C:
conn.socket.Close()
close(conn.done)
}
} | [
-0.16372300684452057,
0.039292044937610626,
0.662922203540802,
0.059810128062963486,
-0.3893391489982605,
-0.1278560310602188,
0.7320737838745117,
-0.49572595953941345,
-0.5577284693717957,
0.009568379260599613,
-0.10117249935865402,
0.828530490398407,
-0.6093021631240845,
1.39844536781311... |
func (conn *Conn) IsConnected() bool {
return conn.isConnected
} | [
-0.30067285895347595,
-1.1551661491394043,
0.34782060980796814,
0.9903796911239624,
0.580633819103241,
-0.49266716837882996,
-1.3281922340393066,
0.6836056709289551,
-0.21339167654514313,
-0.08326777815818787,
-1.2678236961364746,
-0.05659276247024536,
-0.23851275444030762,
-0.187471747398... |
func (conn *Conn) SetNonceGenerator(gen NonceGenerator) error {
if gen == nil {
return ErrInvalidNonceGenerator
}
s := []string{gen()}
if len(s[0]) < 5 {
return ErrInvalidNonceGenerator
}
for i := 0; i < 24; i++ {
str := gen()
for _, a := range s {
if str == a {
return ErrInvalidNonceGenerator
}... | [
-1.3151192665100098,
0.18632802367210388,
0.759499728679657,
-0.12767229974269867,
-1.2247428894042969,
-0.6709359288215637,
0.22819148004055023,
-0.008145882748067379,
-0.6439025402069092,
-0.6334908604621887,
-0.9243061542510986,
-0.566604733467102,
-1.1937377452850342,
1.492918491363525... |
func (conn *Conn) SetMaxTopics(max int) {
if max < 1 {
max = 50
}
conn.length = max
} | [
-0.4765280485153198,
0.13813915848731995,
0.30254873633384705,
0.20618557929992676,
-0.7424535155296326,
0.5085840225219727,
-0.7689244151115417,
0.08807870745658875,
0.3356834352016449,
0.4253123700618744,
-0.9371351003646851,
0.35539519786834717,
-0.5833026766777039,
0.17253084480762482,... |
func (conn *Conn) GetNumTopics() (n int) {
conn.listeners.Lock()
defer conn.listeners.Unlock()
if conn.topics != nil {
for _, topics := range conn.topics {
n += len(topics)
}
}
return
} | [
0.4047294855117798,
0.6748467087745667,
0.45535051822662354,
0.28048279881477356,
0.6843327283859253,
-0.6810422539710999,
0.018191656097769737,
-0.49450552463531494,
0.1682496964931488,
-0.8016065359115601,
-0.9400935173034668,
-0.07668076455593109,
-0.37520632147789,
0.23021507263183594,... |
func (conn *Conn) HasTopic(topic string) bool {
conn.listeners.Lock()
defer conn.listeners.Unlock()
for _, g := range conn.topics {
for _, t := range g {
if topic == t {
return true
}
}
}
return false
} | [
0.3936958909034729,
-0.05288149043917656,
0.5055288672447205,
0.06783286482095718,
0.12407054007053375,
-0.2372014820575714,
-0.8410957455635071,
0.045298151671886444,
-1.0401774644851685,
-0.1473359614610672,
-0.13186384737491608,
-0.9722570776939392,
-0.4989696145057678,
0.03250931948423... |
func (conn *Conn) Listen(topics ...string) error {
return conn.ListenWithAuth("", topics...)
} | [
0.3520605266094208,
-0.6258269548416138,
0.13633431494235992,
0.39212682843208313,
0.33197635412216187,
0.9940335154533386,
-1.020975112915039,
0.05761351436376572,
-0.495024710893631,
-0.41094914078712463,
-0.5088459849357605,
-0.2388668656349182,
-0.43027594685554504,
-0.1554534286260604... |
func (conn *Conn) ListenWithAuth(token string, topics ...string) error {
if conn.GetNumTopics()+len(topics) > conn.length {
return ErrShardTooManyTopics
}
if err := conn.WriteMessageWithNonce(Listen, conn.generator(), TopicData{topics, token}); err != nil {
return err
}
conn.listeners.Lock()
defer conn.listen... | [
0.36492791771888733,
-0.7026792764663696,
0.6453772783279419,
-0.4274066984653473,
0.23822711408138275,
-0.12803930044174194,
-0.4894099533557892,
-0.3900068700313568,
-0.1468321979045868,
-0.25818949937820435,
-0.6682072877883911,
-0.07455890625715256,
-0.3215125799179077,
0.2394911944866... |
func (conn *Conn) Unlisten(topics ...string) error {
var unlisten []string
for _, topic := range topics {
if conn.HasTopic(topic) {
unlisten = append(unlisten, topic)
}
}
if len(unlisten) < 1 {
return nil
}
conn.listeners.Lock()
for token, topics := range conn.topics {
var new []string
for _, topic ... | [
0.42791855335235596,
-0.6229739785194397,
0.8585236668586731,
-0.4627014398574829,
-0.044377680867910385,
0.11503084003925323,
-0.227262482047081,
0.5197603702545166,
-1.0646812915802002,
0.07668228447437286,
-0.302032470703125,
-0.42708784341812134,
-1.2082329988479614,
-0.300975888967514... |
func (conn *Conn) Ping() (time.Duration, error) {
start := time.Now()
conn.ping = make(chan bool, 1)
if err := conn.WriteMessage(Ping, nil); err != nil {
return 0, err
}
timer := time.NewTimer(time.Second*5 + conn.latency)
defer timer.Stop()
select {
case <-conn.ping:
case <-timer.C:
return 0, ErrPingTimeo... | [
-0.522598147392273,
0.3355483412742615,
0.6912657022476196,
0.5005214214324951,
-0.20628684759140015,
-0.6326338648796082,
-0.2711973190307617,
-0.06805351376533508,
-1.108521580696106,
1.1950560808181763,
0.059832941740751266,
-0.2501896321773529,
-0.7725455164909363,
0.5096595287322998,
... |
func (conn *Conn) OnMessage(f func(string, []byte)) {
conn.onMessage = append(conn.onMessage, f)
} | [
-0.3504674434661865,
0.2957878112792969,
0.5689191818237305,
0.28280162811279297,
-0.4432043433189392,
-0.7391753196716309,
-1.419426679611206,
0.26322972774505615,
-0.12054213136434555,
-0.020666033029556274,
-0.591821014881134,
-0.10819704830646515,
-0.439467191696167,
0.9364206790924072... |
func (conn *Conn) OnPong(f func(time.Duration)) {
conn.onPong = append(conn.onPong, f)
} | [
-0.21863064169883728,
0.6680694222450256,
0.6351229548454285,
-0.0876438096165657,
-0.3178263306617737,
-0.12040344625711441,
-0.9999954104423523,
0.5722525715827942,
-1.1808868646621704,
0.7488884925842285,
-1.1892485618591309,
-0.24574892222881317,
0.3530977666378021,
0.5341656804084778,... |
func (conn *Conn) OnReconnect(f func()) {
conn.onReconnect = append(conn.onReconnect, f)
} | [
-0.06471003592014313,
-0.7422109246253967,
0.5922222137451172,
0.2735251784324646,
-0.743164598941803,
-1.2885992527008057,
-0.7925458550453186,
0.5027037858963013,
-0.9680618643760681,
0.2979916036128998,
-1.1022307872772217,
-0.34813666343688965,
0.8409643173217773,
-0.6299788355827332,
... |
func (conn *Conn) OnDisconnect(f func()) {
conn.onDisconnect = append(conn.onDisconnect, f)
} | [
0.5423632860183716,
-0.8541897535324097,
0.5314044952392578,
0.526720404624939,
-0.7568028569221497,
-0.21775642037391663,
-0.9131995439529419,
-0.08795199543237686,
-0.8091168999671936,
0.03545128181576729,
-0.827544629573822,
-0.712547242641449,
0.6733643412590027,
-0.07108079642057419,
... |
func (n *Numbers) GetNumberValues() (numbers []*Number) {
for digitIndex := 0; digitIndex < len(n.TextNumbers[0]) / 3; digitIndex++ {
numbers = append(
numbers,
n.extractTextNumberAt(n.TextNumbers, digitIndex),
)
}
return numbers
} | [
-0.5534762740135193,
0.44102829694747925,
0.6545306444168091,
0.5154537558555603,
0.20663629472255707,
0.13059335947036743,
-0.5730419754981995,
0.1737227886915207,
0.07313448935747147,
-0.7982258796691895,
-1.144849181175232,
-0.418197363615036,
-0.2898368537425995,
0.806450366973877,
0... |
func (n *Numbers) GetByteValues() (byteValues []byte) {
numbers := n.GetNumberValues()
for _, number := range numbers {
if value, e := number.GetByteValue(); e == nil {
byteValues = append(byteValues, value)
} else {
byteValues = append(byteValues, 99)
}
}
return byteValues
} | [
0.22203075885772705,
0.7311602830886841,
0.7962040901184082,
0.6781556606292725,
1.2162346839904785,
0.010652252472937107,
-0.631138026714325,
-0.1970684975385666,
0.2198767513036728,
-0.9321301579475403,
-0.5941928029060364,
-0.051997482776641846,
-0.5867664813995361,
1.0419585704803467,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.