query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceAccountRef.
func (in *ServiceAccountRef) DeepCopy() *ServiceAccountRef { if in == nil { return nil } out := new(ServiceAccountRef) in.DeepCopyInto(out) return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (in *ServiceAccount) DeepCopy() *ServiceAccount {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServiceAccount)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func (in *ServiceRef) DeepCopy() *ServiceRef {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServiceRef)\n\tin.DeepCopyInto(out)\n\treturn...
[ "0.6922871", "0.68160284", "0.65097475", "0.65097475", "0.6234114", "0.6091671", "0.6017589", "0.594521", "0.5911724", "0.58977866", "0.5787274", "0.57625866", "0.57212543", "0.5715463", "0.5705707", "0.56993514", "0.5689972", "0.56890875", "0.5659267", "0.55872035", "0.55768...
0.7754007
0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be nonnil.
func (in *ServiceRef) DeepCopyInto(out *ServiceRef) { *out = *in }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *RunInfo) DeepCopyInto(out *RunInfo) {\n\t*out = *r\n}", "func (in *Base) DeepCopyInto(out *Base) {\n\t*out = *in\n\treturn\n}", "func (in *ForkObject) DeepCopyInto(out *ForkObject) {\n\t*out = *in\n}", "func (in *TargetObjectInfo) DeepCopyInto(out *TargetObjectInfo) {\n\t*out = *in\n}", "func (in ...
[ "0.8216088", "0.8128937", "0.81051093", "0.8086112", "0.80840266", "0.806814", "0.80643326", "0.80272067", "0.8013088", "0.79972315", "0.799318", "0.7988673", "0.79883105", "0.79879236", "0.79879236", "0.7986761", "0.79770774", "0.7973031", "0.7970074", "0.7970074", "0.797007...
0.0
-1
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceRef.
func (in *ServiceRef) DeepCopy() *ServiceRef { if in == nil { return nil } out := new(ServiceRef) in.DeepCopyInto(out) return out }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (in *ServiceReference) DeepCopy() *ServiceReference {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServiceReference)\n\tin.DeepCopyInto(out)\n\treturn out\n}", "func (in *ServiceReference) DeepCopy() *ServiceReference {\n\tif in == nil {\n\t\treturn nil\n\t}\n\tout := new(ServiceReference)\n\tin.Dee...
[ "0.79889023", "0.79889023", "0.71423465", "0.71423465", "0.71423465", "0.71423465", "0.71423465", "0.71423465", "0.71423465", "0.68184793", "0.6766675", "0.67632616", "0.6729097", "0.6706522", "0.6657321", "0.66313547", "0.6480278", "0.6434709", "0.64028084", "0.63402987", "0...
0.8665822
0
Projects lists all the projects that belong to the token holder.
func (c Client) Projects() ([]Project, error) { u := mustParseURL(c.baseURL) u.Path += "projects" projects := make([]Project, 0) // if there's more projects than returned by default by the API, links array will // be provided. The object that has the 'rel' field with the value of 'next' will // also contain the 'href' with the complete link to the next page. for u != nil { resp, err := c.request(http.MethodGet, u, nil) if err != nil { return nil, fmt.Errorf("fetching files failed: %s", err.Error()) } defer resp.Close() var r struct { apiOKResponseTemplate Projects []Project `json:"items"` } if err := json.NewDecoder(resp).Decode(&r); err != nil { return nil, fmt.Errorf("unmarshalling response failed: %s", err.Error()) } projects = append(projects, r.Projects...) u = nil for _, link := range r.Links { if link.Rel == "next" { u = mustParseURL(link.Href) } } } return projects, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (pg *MongoDb) ListProjects(ctx context.Context, filter string, pageSize int, pageToken string) ([]*prpb.Project, string, error) {\n\t//id := decryptInt64(pageToken, pg.PaginationKey, 0)\n\t//TODO\n\treturn nil, \"\", nil\n}", "func (k *Keystone) ListProjectsAPI(c echo.Context) error {\n\tclusterID := c.Requ...
[ "0.71771556", "0.68300486", "0.68204504", "0.68188494", "0.6786697", "0.6783694", "0.6747027", "0.67415625", "0.6694138", "0.66898185", "0.66296756", "0.6558482", "0.65004283", "0.6477567", "0.6470259", "0.6456625", "0.6454959", "0.64408636", "0.64160526", "0.6415494", "0.639...
0.5867073
80
Upload allows users to upload photos, they may be marked as public or private
func Upload(w http.ResponseWriter, r *http.Request) { // Get uploaded file r.ParseMultipartForm(32 << 20) file, _, err := r.FormFile("uploadFile") if err != nil { w.WriteHeader(http.StatusBadRequest) fmt.Println(err) return } defer file.Close() // Get isPublic attribute IsPublicFromValue := r.FormValue("IsPublic") if IsPublicFromValue == "" { w.WriteHeader(http.StatusBadRequest) return } IsPublic, err := strconv.ParseBool(IsPublicFromValue) if err != nil { w.WriteHeader(http.StatusBadRequest) return } // Identify who the user is username := r.Context().Value("username") if username == nil { w.WriteHeader(http.StatusInternalServerError) return } // Get user bucket id bucketID, err := GetUserGUID(username.(string)) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } // Generate a unique ID to identify the photo object photoID := uuid.New().String() // Register photo in photos table photo := Photo{ ID: photoID, IsPublic: IsPublic, UserID: *bucketID, } DB.Create(&photo) // Retrieve user's bucket bkt := Client.Bucket(getBucketForPhoto(photo)) // Verify existence of bucket // Only run in production as Google Cloud Storage emulator for local development does not support metadata retrieval // TODO: Need more robust diaster recovery if !IsDebug { _, err = Client.Bucket(getBucketForPhoto(photo)).Attrs(r.Context()) if err == storage.ErrBucketNotExist { w.WriteHeader(http.StatusInternalServerError) w.Write([]byte("Bucket does not exist: " + err.Error())) return } } // Upload photo to bucket obj := bkt.Object(photoID) objWriter := obj.NewWriter(r.Context()) if _, err := io.Copy(objWriter, file); err != nil { w.WriteHeader(http.StatusInternalServerError) return } if err := objWriter.Close(); err != nil { w.WriteHeader(http.StatusInternalServerError) return } w.Write([]byte(photoID)) w.WriteHeader(http.StatusOK) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IMAGE_PostUploadForm(res http.ResponseWriter, req *http.Request, params httprouter.Params) {\n\tif validPerm, permErr := HasPermission(res, req, image_Make_Permission); !validPerm {\n\t\t// User Must be at least Writer.\n\t\tfmt.Fprint(res, `{\"result\":\"failure\",\"reason\":\"Invalid Authorization: `+permEr...
[ "0.6137154", "0.608181", "0.60776865", "0.5972178", "0.5893536", "0.5838742", "0.5828034", "0.5776307", "0.568447", "0.5679493", "0.5652551", "0.563114", "0.5607", "0.5593149", "0.5588747", "0.5576847", "0.55685544", "0.55474", "0.55472434", "0.5525405", "0.5523969", "0.551...
0.6866995
0
ChangePermissions allows users to change the visibility of photo between public (everyone can see) and private (only you can see)
func ChangePermissions(w http.ResponseWriter, r *http.Request) { // Identify who the user is username := r.Context().Value("username") if username == nil { w.WriteHeader(http.StatusInternalServerError) return } // Get userid for user userID, err := GetUserGUID(username.(string)) if err != nil { w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } // Retrieve PhotoID and IsPublic from JSON request body var requestedPhoto Photo err = json.NewDecoder(r.Body).Decode(&requestedPhoto) if err != nil { w.Write([]byte("Missing PhotoID or IsPublic attribute")) w.WriteHeader(http.StatusBadRequest) return } if requestedPhoto.ID == "" { w.Write([]byte("PhotoID not provided in request body")) w.WriteHeader(http.StatusBadRequest) return } // make sure photo exists var photos []Photo DB.Where(&Photo{ID: requestedPhoto.ID}).Find(&photos) if len(photos) > 1 { w.Write([]byte("Multiple photos returned")) w.WriteHeader(http.StatusInternalServerError) } if len(photos) == 0 { w.Write([]byte("No photos returned")) w.WriteHeader(http.StatusInternalServerError) return } photo := photos[0] // Make sure photo belongs to user if photo.UserID != *userID { w.Write([]byte("photo does not belong to user")) w.WriteHeader(http.StatusBadRequest) return } // If permission has changed photo needs to be updated in photos tabe and object needs to be moved between buckets if photo.IsPublic != requestedPhoto.IsPublic { // If permission has gone from public to private if photo.IsPublic == true && requestedPhoto.IsPublic == false { err = moveBuckets(r.Context(), PUBLIC_BUCKET_NAME, *userID, photo.ID) if err != nil { w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } } // If permission has gone from private to public if photo.IsPublic == false && requestedPhoto.IsPublic == true { err = moveBuckets(r.Context(), *userID, PUBLIC_BUCKET_NAME, photo.ID) if err != nil { w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } } // change permission for photo in photos table photo.IsPublic = requestedPhoto.IsPublic DB.Save(&photo) } w.Write([]byte("photo visibility has been changed")) w.WriteHeader(http.StatusOK) return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (uc *Userclient) iEditPermissions(args *userproto.EditPermissionsArgs, reply *userproto.EditPermissionsReply) error {\r\n\t//if args.permission = nil then we are removing people from the permission list\r\n\t//also gotta check if we are adding a user to the permission list if the user actually exists\r\n\t//o...
[ "0.6386941", "0.61053145", "0.58309543", "0.5733254", "0.57278687", "0.5681798", "0.56737554", "0.56447285", "0.55250835", "0.5524847", "0.55135715", "0.5482064", "0.54747975", "0.5453116", "0.53916466", "0.5386464", "0.5386464", "0.53733885", "0.53500324", "0.5275077", "0.52...
0.77092814
0
Delete allows users to delete photos
func Delete(w http.ResponseWriter, r *http.Request) { // get user info username := r.Context().Value("username") if username == nil { w.WriteHeader(http.StatusInternalServerError) return } // retrieve photo id from api call var requestedPhoto Photo err := json.NewDecoder(r.Body).Decode(&requestedPhoto) if err != nil { w.Write([]byte("Missing PhotoID or IsPublic attribute")) w.WriteHeader(http.StatusBadRequest) return } if requestedPhoto.ID == "" { w.Write([]byte("PhotoID not provided in request body")) w.WriteHeader(http.StatusBadRequest) return } // make sure photo exists var photos []Photo DB.Where(&Photo{ID: requestedPhoto.ID}).Find(&photos) if len(photos) > 1 { w.Write([]byte("Multiple photos returned")) w.WriteHeader(http.StatusInternalServerError) } if len(photos) == 0 { w.Write([]byte("No photos returned")) w.WriteHeader(http.StatusInternalServerError) return } photo := photos[0] // Make sure photo belongs to user userID, err := GetUserGUID(username.(string)) if photo.UserID != *userID { w.Write([]byte("photo does not belong to user")) w.WriteHeader(http.StatusBadRequest) return } // delete photo from photos table DB.Delete(&photo) // delete file from bucket imageFile := Client.Bucket(getBucketForPhoto(photo)).Object(photo.ID) if err = imageFile.Delete(r.Context()); err != nil { err = fmt.Errorf("Object(%q).Delete: %v", photo.ID, err) w.Write([]byte(err.Error())) w.WriteHeader(http.StatusInternalServerError) return } w.Write([]byte("photo deleted")) w.WriteHeader(http.StatusOK) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func DeletePhotos(w http.ResponseWriter, r *http.Request) {\n\tvars := mux.Vars(r)\n\tids := vars[\"ids\"]\n\tstringIDsArray := strings.Split(ids, \",\")\n\tvar array []bson.ObjectId\n\tlog.Println(stringIDsArray)\n\tfor _, id := range stringIDsArray {\n\t\tif bson.IsObjectIdHex(id) {\n\t\t\tarray = append(array, ...
[ "0.7011417", "0.69017696", "0.6777559", "0.67353654", "0.6700946", "0.6612022", "0.6590683", "0.6524534", "0.64540064", "0.6401866", "0.6380001", "0.63725716", "0.63711727", "0.6361337", "0.62740403", "0.6255791", "0.6253453", "0.6214657", "0.6205462", "0.6102082", "0.6092225...
0.7924666
0
Forward declaration of isBadVersion API.
func firstBadVersion(n int) int { return sort.Search(n, func(version int) bool { return isBadVersion(version) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func isBadVersion(version int) bool{\n return false\n}", "func isBadVersion(version int) bool{\n\treturn true\n}", "func IsVersionMismatch(err error) (match bool) {\n\t_, match = err.(*VersionMismatchError)\n\treturn\n}", "func _isValidFileVersion(v FileVersion) bool {\n\tif v.Format == nil {\n\t\treturn ...
[ "0.7800074", "0.7698673", "0.61183864", "0.5984667", "0.59743524", "0.5790841", "0.57839173", "0.57596445", "0.5734349", "0.5708786", "0.5705013", "0.5690198", "0.5686768", "0.5666567", "0.56633246", "0.5652546", "0.5641665", "0.55701846", "0.55573326", "0.55366045", "0.55338...
0.0
-1
NewUsecase is constructor for create default implementation of usecase ShowPostBySlug
func NewUsecase(outputPort Outport) Inport { return &showPostBySlugInteractor{ outport: outputPort, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New(ctx *sweetygo.Context) error {\n\ttitle := ctx.Param(\"title\")\n\tcat := ctx.Param(\"cat\")\n\thtml := ctx.Param(\"html\")\n\tmd := ctx.Param(\"md\")\n\tif title != \"\" && cat != \"\" && html != \"\" && md != \"\" {\n\t\terr := model.NewPost(title, cat, html, md)\n\t\tif err != nil {\n\t\t\treturn ctx.J...
[ "0.58909637", "0.5425699", "0.53912926", "0.53115577", "0.52724636", "0.5240457", "0.519414", "0.51667655", "0.5088023", "0.5032141", "0.5024942", "0.50157803", "0.5003912", "0.49888113", "0.49785644", "0.4961714", "0.49477577", "0.49056473", "0.4904455", "0.48526642", "0.484...
0.67127544
0
Execute the usecase ShowPostBySlug
func (r *showPostBySlugInteractor) Execute(ctx context.Context, req InportRequest) (*InportResponse, error) { res := &InportResponse{} err := repository.WithTransaction(ctx, r.outport, func(ctx context.Context) error { postObj, err := r.outport.FindPostBySlug(ctx, req.Slug) if err != nil { return apperror.ObjectNotFound.Var(postObj) } postObj.UpdateViewCount() err = r.outport.SavePost(ctx, postObj) if err != nil { return err } var vCategories []CategoryResponse for _, v := range postObj.Categories { vCategories = append(vCategories, CategoryResponse{ ID: v.ID, Category: v.Category, }) } var vTags []TagResponse for _, v := range postObj.Tags { vTags = append(vTags, TagResponse{ ID: v.ID, Tag: v.Tag, }) } res = &InportResponse{ ID: postObj.ID, Title: postObj.Title, Description: postObj.Description, Content: json.RawMessage(postObj.Content), Cover: postObj.Cover, Slug: postObj.Slug, ViewCount: postObj.ViewCount, Categories: vCategories, Tags: vTags, UserID: postObj.UserID, AuthorName: postObj.User.Name, CreatedAt: postObj.CreatedAt, UpdatedAt: postObj.UpdatedAt, } return nil }) if err != nil { return nil, err } return res, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Show(ctx *sweetygo.Context) error {\n\tif title := ctx.Param(\"title\"); title != \"\" {\n\t\ttitle := strings.Replace(title, \"-\", \" \", -1)\n\t\tpost, err := model.GetPostByTitle(title)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif post.ID == 0 {\n\t\t\treturn ctx.Text(404, \"404 not found\")\n\t\...
[ "0.63513255", "0.5738546", "0.57292014", "0.55722785", "0.5411228", "0.5343942", "0.53318965", "0.5194136", "0.5159168", "0.49706224", "0.49073952", "0.4837351", "0.478994", "0.47826794", "0.4760586", "0.47508007", "0.4747875", "0.46760988", "0.4666304", "0.46457812", "0.4644...
0.6104211
1
sprintByteHex returns a formatted string of the byte array in hexadecimal with a nicely formatted humanreadable output
func sprintByteHex(b []byte) string { output := "\t" for i, b := range b { output += fmt.Sprintf("%x", b) if (i+1)%16 == 0 { output += "\n\n\t" } else if (i+1)%4 == 0 { output += " " } else { output += " " } } output += "\n" return output }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func hex(bytes []byte) string {\n\t// return number of spaces to print based on i's position in slice s\n\tspaces := func(s []byte, i int) int {\n\t\tif i == len(s)-1 {\n\t\t\treturn 0\n\t\t}\n\t\tif (i+1)%4 == 0 {\n\t\t\treturn 2\n\t\t}\n\t\treturn 1\n\t}\n\n\tsb := strings.Builder{}\n\tfor i := range bytes {\n\t...
[ "0.7051886", "0.69957966", "0.6890688", "0.66078013", "0.66071355", "0.6593887", "0.6553541", "0.6553541", "0.6450825", "0.63917994", "0.63325244", "0.6282256", "0.6254831", "0.62540656", "0.62537855", "0.6201541", "0.6201484", "0.6167006", "0.61478466", "0.61307985", "0.6110...
0.8088775
0
driverArgsToMap turns driver.Value list into a parameter map for neo4j parameters
func driverArgsToMap(args []driver.Value) (map[string]interface{}, error) { output := map[string]interface{}{} for _, arg := range args { argBytes, ok := arg.([]byte) if !ok { return nil, errors.New("You must pass only a gob encoded map to the Exec/Query args") } m, err := encoding.Unmarshal(argBytes) if err != nil { return nil, err } for k, v := range m.(map[string]interface{}) { output[k] = v } } return output, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func mapArgs(rawArgs string) (map[string]string, error) {\n\targMap := make(map[string]string)\n\n\t// split params: param0:<param-val0> paramN:<param-valN> badparam\n\tparams, err := commandSplit(rawArgs)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// for each, split pram:<pram-value> into {param, <param-va...
[ "0.53027666", "0.5219961", "0.5159778", "0.5078906", "0.49744081", "0.49501595", "0.49113458", "0.48044524", "0.4773885", "0.47444138", "0.46754888", "0.46352243", "0.45708403", "0.45623273", "0.45322862", "0.45287666", "0.44981897", "0.4490554", "0.44724736", "0.44593903", "...
0.7387417
0
Fetches scheduled games from the MASTER master base station
func fetchScheduledGames() []gm.Game { uri := viper.GetString("master_URL") + "/api/games" resp, _ := http.Get(uri) defer closeResponse(resp) body, _ := ioutil.ReadAll(resp.Body) var gms []gm.Game jsonErr := json.Unmarshal(body, &gms) if jsonErr != nil { logger.Error().Msg("could not get schedule game from MASTER master base station") } return gms }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func AllGames(w http.ResponseWriter, r *http.Request) {\r\n\tdb, err = gorm.Open(\"sqlite3\", \"collegiateCS.db\")\r\n\t//cStats := make(chan []dbStats)\r\n\t//cPlayers := make(chan []dbPlayer)\r\n\t//cRosters := make(chan []dbRoster)\r\n\r\n\tif err != nil {\r\n\t\tfmt.Println(err.Error())\r\n\t\tpanic(\"Failed t...
[ "0.5648042", "0.55517983", "0.5492142", "0.52553743", "0.5250552", "0.52463615", "0.5244019", "0.52150124", "0.5173499", "0.51730657", "0.51409185", "0.5131815", "0.5131049", "0.5098903", "0.5086736", "0.5056043", "0.5048437", "0.50338256", "0.49914128", "0.49527743", "0.4951...
0.80941576
0
isInLocalDB returns true if this game already exists in the localDB
func isInLocalDB(game gm.Game) bool { dbGames := db.GetGames() for _, g := range dbGames { if game.GameID == g.GameID { return true } } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func pushToLocalDB(games []gm.Game) {\n\tt := time.Now()\n\n\tfor _, game := range games {\n\t\tif int64(t.Unix()) < game.AbsStart+int64(game.Duration) {\n\t\t\tif !isInLocalDB(game) {\n\t\t\t\tdb.ScheduleGame(game)\n\t\t\t}\n\t\t}\n\t}\n}", "func (db *AppDB) Exists(t time.Time) bool {\n\tif _, err := db.Result(...
[ "0.6165867", "0.5681191", "0.56591237", "0.56353617", "0.5559647", "0.5554416", "0.5552465", "0.5522966", "0.54746", "0.5412814", "0.54034585", "0.5390477", "0.53722733", "0.5341808", "0.53362715", "0.5335849", "0.53276443", "0.53212655", "0.5317387", "0.52765626", "0.5235597...
0.8528136
0
pushToLocalDB grabs future games and schedules them in local database
func pushToLocalDB(games []gm.Game) { t := time.Now() for _, game := range games { if int64(t.Unix()) < game.AbsStart+int64(game.Duration) { if !isInLocalDB(game) { db.ScheduleGame(game) } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func DBPushSeasonalAnimes(index int, malID string) {\n\t_, err := r.Table(\"seasonal_animes\").Insert(map[string]interface{}{\n\t\t\"id\": index,\n\t\t\"malID\": malID,\n\t}).RunWrite(dbSession)\n\tif err != nil {\n\t\tlog.Println(err)\n\t\treturn\n\t}\n}", "func fetchScheduledGames() []gm.Game {\n\turi := vi...
[ "0.56290245", "0.54186916", "0.5408968", "0.5404486", "0.53052187", "0.51920897", "0.5188981", "0.5183002", "0.5134982", "0.49880126", "0.49807742", "0.4967738", "0.495166", "0.49266243", "0.49192014", "0.48657754", "0.48431918", "0.4842832", "0.48361173", "0.48208678", "0.48...
0.8595324
0
StartSyncLoop starts a go routine to fetch games from MASTER master base station this runs on an interval
func StartSyncLoop() { interval := time.NewTicker(30 * time.Second) quit := make(chan struct{}) go fetchGames(interval, quit) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (k *KubeBoot) RunSyncLoop() {\n\tctx := context.Background()\n\n\tif k.Master {\n\t\tclient, err := k.Kubernetes.KubernetesClient()\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"could not create kubernetes client: %v\", err))\n\t\t}\n\n\t\tklog.Info(\"polling for apiserver readiness\")\n\t\tfor {\n\t\t\t_, ...
[ "0.6990082", "0.6505114", "0.64570576", "0.63625956", "0.6352401", "0.622634", "0.5981771", "0.59244317", "0.5794886", "0.5771718", "0.57458603", "0.56999516", "0.56738234", "0.566845", "0.5636276", "0.55920625", "0.558578", "0.55855894", "0.55784124", "0.55763596", "0.552615...
0.8255443
0
init ... creates a new GitHub request object with all the gh api urls
func init() { urls = &pluginWebURL{ base: "https://api.github.com", authURL: "/authorizations", assigneeURL: "/repos/%s/%s/issues/%d/assignees", issueURL: "/repos/%s/%s/issues", labelURL: "/repos/%s/%s/issues/%d/labels", repo: "/repos/%s/%s", userRepo: "/user/repos", } info, _ := githandler.Remote() org := info.Organisation repo := info.Repository token := githandler.ConfigGet("token", "phlow") GitHub = &GitHubImpl{ urls, repo, org, token, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (g *GitHubStruct) github_set_url(server string) (err error) {\n\tgh_url := \"\"\n\tif g.github_source.Urls == nil {\n\t\tg.github_source.Urls = make(map[string]string)\n\t}\n\tif !g.maintain_ctxt {\n\t\tif server == \"\" || server == \"api.github.com\" || server == \"github.com\" {\n\t\t\tg.github_source.Urls...
[ "0.62665045", "0.6114478", "0.60820365", "0.60081553", "0.5948533", "0.57346517", "0.5724615", "0.56408477", "0.5497713", "0.54658604", "0.544195", "0.54246414", "0.54128045", "0.5398113", "0.53730345", "0.5361448", "0.5348309", "0.5343398", "0.5334841", "0.5331546", "0.53307...
0.654776
0
Default ... Get default branch of a GitHub issue
func (g *GitHubImpl) Default() (defUrl string, err error) { URL := fmt.Sprintf(g.URLNoEsc(g.pluginWebURL.repo), g.org, g.repo) req, _ := http.NewRequest("GET", URL, nil) q := req.URL.Query() q.Add("access_token", g.token) req.URL.RawQuery = q.Encode() body, err := NewPWRequest().Do(req) if err != nil { return "", err } re := Repo{} if err = json.Unmarshal(body, &re); err != nil { return "", err } return re.DefaultBranch, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getDefaultBranch(client *gitlab.Client, projectID int) (*gitlab.Branch, error) {\n\tproject, _, err := client.Projects.GetProject(projectID, &gitlab.GetProjectOptions{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fetching project failed : %v\", err)\n\t}\n\n\tdefaultBranch := project.DefaultBranch\n\n\t...
[ "0.76395214", "0.72123367", "0.7082229", "0.70578945", "0.6987225", "0.692187", "0.679232", "0.66691875", "0.6630789", "0.64667594", "0.6397041", "0.63649535", "0.6181196", "0.61626583", "0.6102478", "0.59017694", "0.5774812", "0.5746847", "0.56741744", "0.56536037", "0.56517...
0.73888147
1
SetAssignee ... Set assignee on a GitHub Issue
func (g *GitHubImpl) SetAssignee(assignee string, issue int) (err error) { URL := fmt.Sprintf(g.URLNoEsc(urls.assigneeURL), g.org, g.repo, issue) jsonBytes, _ := json.Marshal(Assignee{Assignees: []string{assignee}}) req, _ := http.NewRequest("POST", URL, bytes.NewBuffer(jsonBytes)) req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "token "+g.token) _, err = NewPWRequest().Do(req) if err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (issue *Issue) Assignee(name string) error {\n\tencodedParams, err := json.Marshal(map[string]string{\"name\": name})\n\tif err != nil {\n\t\treturn err\n\t}\n\turl := fmt.Sprintf(\"%s/issue/%s/assignee\", BaseURL, issue.Key)\n\tcode, body := execRequest(\"PUT\", url, bytes.NewBuffer(encodedParams))\n\tif cod...
[ "0.7824912", "0.7743104", "0.73689044", "0.73582506", "0.7141999", "0.68957514", "0.68766004", "0.67772126", "0.6706829", "0.66746527", "0.66430116", "0.6564776", "0.64136", "0.633491", "0.6322022", "0.6214112", "0.61791426", "0.6134709", "0.61321056", "0.610459", "0.60129243...
0.87511265
0
Auth ... Auth request to gh
func (g *GitHubImpl) Auth(user, pass string) (token string, err error) { perm, err := createGHPermissions() if err != nil { return "", err } req, _ := http.NewRequest("POST", g.URLNoEsc(urls.authURL), bytes.NewBuffer([]byte(perm))) req.Header.Set("Content-Type", "application/x-www-form-urlencoded") req.SetBasicAuth(user, pass) body, err := NewPWRequest().Do(req) if err != nil { return "", err } re := Auth{} if err = json.Unmarshal(body, &re); err != nil { return "", err } return re.Token, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Client) Auth() (string, error) {\n\t// First do an empty get to get the auth challenge\n\treq, err := http.NewRequest(http.MethodGet, c.BaseURL+\"/v2/\", nil)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\trsp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed se...
[ "0.6465212", "0.6398342", "0.63612264", "0.6326609", "0.6284491", "0.623715", "0.6218349", "0.62039566", "0.6200897", "0.61832404", "0.6146673", "0.6112144", "0.6095562", "0.6078164", "0.60686564", "0.60548", "0.6046615", "0.6037247", "0.6036029", "0.6015311", "0.59805304", ...
0.62837017
5
CheckAuth ... Checks personal access token validity by requesting private repositories and checking status code
func (g *GitHubImpl) CheckAuth() (bool, error) { URL := fmt.Sprintf(g.URLNoEsc(urls.userRepo)) req, _ := http.NewRequest("GET", URL, nil) q := req.URL.Query() q.Add("access_token", g.token) req.URL.RawQuery = q.Encode() client := http.DefaultClient res, err := client.Do(req) if err != nil { return false, err } if res.StatusCode != http.StatusOK { return false, errors.New(strconv.Itoa(res.StatusCode)) } return true, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckAuth(ctx context.Context, sys *types.SystemContext, username, password, registry string) error {\n\tnewLoginClient, err := newDockerClientWithDetails(sys, registry, username, password, \"\", nil, \"\")\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error creating new docker client\")\n\t}\n\n\tresp, ...
[ "0.64528763", "0.6141813", "0.60356563", "0.5977623", "0.5966018", "0.59558386", "0.5920924", "0.58737713", "0.585327", "0.58436126", "0.5831124", "0.5826388", "0.58148474", "0.579439", "0.57890946", "0.578735", "0.57012784", "0.5695301", "0.5692118", "0.5629942", "0.56271535...
0.71946776
0
get user by id
func (u *UserDAO) Get(id int) User { stmt, err := db.Instance().Prepare("select uid, username, password from userinfo where uid=$1") db.CheckErr(err) rows, err := stmt.Query(id) var usr User for rows.Next() { var uid int var username string var password string err = rows.Scan(&uid, &username, &password) db.CheckErr(err) usr.Id = uid usr.Name = username usr.Pwd = password } return usr }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getUserById(id int) (User, error) {\n\tkeyString := fmt.Sprintf(\"user:%d\", id)\n\tfirstName, _ := redisConn.Hget(keyString, \"firstName\")\n\tlastName, _ := redisConn.Hget(keyString, \"lastName\")\n\temail, _ := redisConn.Hget(keyString, \"email\")\n\tuser := User{id, string(firstName), string(lastName), st...
[ "0.7972601", "0.7964725", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.78521353", "0.7851767", "0.7846159", "0.7841692", "0.773739", "0.773739", "0.771031", "0.7708724", "0.768155", "0.7671836", "0.7657818", "0.7...
0.7363407
53
get user by id
func (u *UserDAO) GetUserByName(uname string) User { stmt, err := db.Instance().Prepare("select uid, username, password from userinfo where username=$1") db.CheckErr(err) rows, err := stmt.Query(uname) var usr User for rows.Next() { var uid int var username string var password string err = rows.Scan(&uid, &username, &password) db.CheckErr(err) usr.Id = uid usr.Name = username usr.Pwd = password } return usr }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getUserById(id int) (User, error) {\n\tkeyString := fmt.Sprintf(\"user:%d\", id)\n\tfirstName, _ := redisConn.Hget(keyString, \"firstName\")\n\tlastName, _ := redisConn.Hget(keyString, \"lastName\")\n\temail, _ := redisConn.Hget(keyString, \"email\")\n\tuser := User{id, string(firstName), string(lastName), st...
[ "0.7972601", "0.7964725", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.7894217", "0.78521353", "0.7851767", "0.7846159", "0.7841692", "0.773739", "0.773739", "0.771031", "0.7708724", "0.768155", "0.7671836", "0.7657818", "0.7...
0.0
-1
OpenPCAP read file as gopacket.PacketSource
func OpenPCAP(file string) (*Pcap, error) { handle, err := pcap.OpenOffline(file) if err != nil { return nil, err } return &Pcap{source: gopacket.NewPacketSource(handle, handle.LinkType())}, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ReadPacketsFromPcap(pcapfile string, filter layers.IPProtocol, raw bool) ([]events.Event, []gopacket.Packet, error) {\n\tvar Events []events.Event\n\tvar rawPackets []gopacket.Packet\n\tvar ret []events.Event\n\tvar rawRet []gopacket.Packet\n\tpcapfilePath := MakeAssetFullPath(pcapfile)\n\n\tf, err := os.Open...
[ "0.6322504", "0.62335175", "0.5824764", "0.56764734", "0.5661583", "0.54498464", "0.5445083", "0.54125637", "0.53544843", "0.5283854", "0.5241161", "0.5231053", "0.52022845", "0.51986253", "0.51750165", "0.51036865", "0.50913", "0.5089517", "0.50672114", "0.5062419", "0.50348...
0.5706543
3
PacketData use channel so it's possible to do range
func (p *Pcap) PacketData() chan PacketData { if p.channel == nil { p.channel = make(chan PacketData, 5) go func() { for gp := range p.source.Packets() { p.channel <- PacketData(gp.Data()) } }() } return p.channel }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (transfer *RawSocketIO) readPacketToChannel() {\n\n\tvar onePkt RawPacket\n\n\tvar err error\n\tfor {\n\n\t}\n}", "func SourceData(data ...int) <-chan int {\n\tfmt.Println(\"num:\", len(data))\n\tch := make(chan int, 80000000)\n\tgo func() {\n\t\tfor _, v := range data {\n\t\t\tch <- v\n\t\t}\n\t\tclose(ch)...
[ "0.5991822", "0.5745444", "0.54106605", "0.5401272", "0.5397141", "0.5369524", "0.5252285", "0.52128696", "0.5182066", "0.51805663", "0.5179238", "0.5121911", "0.5121377", "0.5107385", "0.5102355", "0.50901985", "0.5049237", "0.5045345", "0.5041959", "0.5040263", "0.50279516"...
0.6243957
0
Add Adds a ticker to TickerSet
func (tickerSet TickerSet) Add(ticker string) { tickerSet[ticker] = true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *Probe) AddTicker(ts ...Ticker) {\n\tp.tickers = append(p.tickers, ts...)\n}", "func (m *Manager) AddTicker(w http.ResponseWriter, r *http.Request) {\n\tm.Lock()\n\tdefer m.Unlock()\n\n\tlogger.Debugf(\"Got an API request to add a ticker\")\n\n\t// read body\n\tbody, err := ioutil.ReadAll(r.Body)\n\tif e...
[ "0.6783332", "0.62357235", "0.5940099", "0.57633084", "0.5707226", "0.5516756", "0.5442915", "0.5305915", "0.52769697", "0.5260699", "0.5242574", "0.51552254", "0.51529825", "0.514143", "0.50967014", "0.50883275", "0.50859696", "0.5076476", "0.5075704", "0.5075591", "0.507021...
0.7894736
0
NewTickerSet Creates a new empty TickerSet
func NewTickerSet() TickerSet { return make(TickerSet) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newSet(txn *Transaction, key []byte) *Set {\n\tnow := Now()\n\treturn &Set{\n\t\ttxn: txn,\n\t\tkey: key,\n\t\tmeta: &SetMeta{\n\t\t\tObject: Object{\n\t\t\t\tID: UUID(),\n\t\t\t\tCreatedAt: now,\n\t\t\t\tUpdatedAt: now,\n\t\t\t\tExpireAt: 0,\n\t\t\t\tType: ObjectSet,\n\t\t\t\tEncoding: ObjectEn...
[ "0.6389514", "0.6260035", "0.6255809", "0.62320423", "0.61772984", "0.6169277", "0.6104857", "0.60863173", "0.6085063", "0.6078854", "0.6059124", "0.6054396", "0.6039346", "0.6019574", "0.60120744", "0.5986136", "0.5985384", "0.59849", "0.59237856", "0.59184754", "0.5897813",...
0.811256
0
ToSlice Converts a ticker set to a slice
func (tickerSet TickerSet) ToSlice() []string { tickerSlice := make([]string, 0) for ticker, _ := range tickerSet { tickerSlice = append(tickerSlice, ticker) } return tickerSlice }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (set *SetThreadSafe) ToSlice() []interface{} {\n\tvar ret []interface{}\n\tset.Items.Range(func(k, v interface{}) bool {\n\t\tret = append(ret, k)\n\t\treturn true\n\t})\n\treturn ret\n}", "func SetToSlice(set map[string]struct{}) []string {\n\tdata := make([]string, 0, len(set))\n\tfor key := range set {\n...
[ "0.67249084", "0.66531223", "0.66010636", "0.6582087", "0.6561404", "0.6293133", "0.6234093", "0.6183588", "0.615653", "0.6111297", "0.6103662", "0.6076562", "0.6037316", "0.60323817", "0.5993712", "0.5896494", "0.5833062", "0.5789647", "0.5766862", "0.57595253", "0.5736894",...
0.7821475
0
reads a bulk reply (i.e $5\r\nhello)
func readBulk(reader *bufio.Reader, head string) ([]byte, error) { var err error var data []byte if head == "" { head, err = reader.ReadString('\n') if err != nil { return nil, err } } switch head[0] { case ':': data = []byte(strings.TrimSpace(head[1:])) case '$': size, err := strconv.Atoi(strings.TrimSpace(head[1:])) if err != nil { return nil, err } if size == -1 { return nil, doesNotExist } lr := io.LimitReader(reader, int64(size)) data, err = ioutil.ReadAll(lr) if err == nil { // read end of line _, err = reader.ReadString('\n') } default: return nil, redisError("Expecting Prefix '$' or ':'") } return data, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func readBody(msg []byte, state *readState) error {\n\tline := msg[0 : len(msg)-2]\n\tvar err error\n\tif line[0] == '$' {\n\t\t// bulk reply\n\t\tstate.bulkLen, err = strconv.ParseInt(string(line[1:]), 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.New(\"protocol error: \" + string(msg))\n\t\t}\n\t\tif state.b...
[ "0.65165836", "0.5854756", "0.5806837", "0.5787643", "0.5747598", "0.5715381", "0.5694573", "0.5679438", "0.56494606", "0.5607286", "0.5572244", "0.55594164", "0.5540163", "0.551188", "0.54905564", "0.54719746", "0.54376435", "0.54350746", "0.5413301", "0.5413174", "0.5398423...
0.5633202
9
OpenConnection open a redis connection
func (client *Client) OpenConnection() (c net.Conn, err error) { var addr = defaultAddr if client.Addr != "" { addr = client.Addr } c, err = net.Dial("tcp", addr) if err != nil { return } //handle authentication here authored by @shxsun if client.Password != "" { cmd := fmt.Sprintf("AUTH %s\r\n", client.Password) _, err = client.rawSend(c, []byte(cmd)) if err != nil { return } } if client.Db != 0 { cmd := fmt.Sprintf("SELECT %d\r\n", client.Db) _, err = client.rawSend(c, []byte(cmd)) if err != nil { return } } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cli *RedisClient) open() redis.Conn {\n\tif cli.pool == nil {\n\t\tcli.pool = cli.newPool()\n\t}\n\n\tif cli.redsync == nil {\n\t\tvar pools = []redsync.Pool{cli.pool}\n\t\tcli.redsync = redsync.New(pools)\n\t}\n\n\treturn cli.pool.Get()\n}", "func (p *RedisConnectionPool) Open() error {\n\tp.Close()\n\n\t...
[ "0.77541524", "0.73249066", "0.6974268", "0.6911695", "0.6755781", "0.6648931", "0.66248333", "0.6571725", "0.6532967", "0.64774966", "0.6466399", "0.64509517", "0.6411952", "0.6404125", "0.6399475", "0.63912493", "0.637248", "0.63523704", "0.6339209", "0.6310935", "0.6303661...
0.58127254
61
processCommand encode a cmd to resp and send to c
func (client *Client) processCommand(c net.Conn, cmd string, args ...string) (interface{}, error) { var b []byte b = commandBytes(cmd, args...) data, err := client.rawSend(c, b) return data, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (a *AGI) Command(cmd ...string) (resp *Response) {\n\tresp = &Response{}\n\n\ta.mu.Lock()\n\tdefer a.mu.Unlock()\n\n\tcmdString := strings.Join(cmd, \" \") + \"\\n\"\n\t_, err := a.w.Write([]byte(cmdString))\n\tif err != nil {\n\t\tresp.Error = errors.Wrap(err, \"failed to send command\")\n\t\treturn\n\t}\n\n...
[ "0.69275284", "0.6794906", "0.66107845", "0.63777584", "0.6366521", "0.6356689", "0.6277177", "0.62690353", "0.6268033", "0.6233138", "0.6204899", "0.6158487", "0.6142332", "0.61358976", "0.6122573", "0.6111794", "0.6098564", "0.60894716", "0.608028", "0.6039841", "0.59943223...
0.74848634
0
InputReader read from stdin and output response
func (client *Client) InputReader(c net.Conn) { scanner := bufio.NewScanner(os.Stdin) fmt.Print("> ") for scanner.Scan() { args := strings.Split(scanner.Text(), " ") if args[0] == "exit" { os.Exit(0) } response, err := client.processCommand(c, args[0], args[1:]...) parseResponse(response, err, defaultTag) if args[0] == "subscribe" { subscribePattern(c, scanner) fmt.Printf("\r%s", defaultTag) } } if scanner.Err() != nil { fmt.Printf("%v", scanner.Err()) os.Exit(2) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func StdinReader(input *ringbuffer.RingBuffer) {\n\tin := bufio.NewReader(os.Stdin)\n\tfor {\n\t\tby, err := in.ReadByte()\n\t\tif err == io.EOF {\n\t\t\tbreak\n\t\t}\n\n\t\tinput.Write([]byte{by})\n\t}\n}", "func (reader *testReader) Read(b []byte) (int, error) {\n\tfmt.Print(\"[IN] > \")\n\treturn os.Stdin.Rea...
[ "0.6441028", "0.63901263", "0.62262696", "0.6013053", "0.59019506", "0.58822507", "0.58704776", "0.5861052", "0.5858616", "0.58128464", "0.5801528", "0.57563275", "0.57038724", "0.56415284", "0.55841076", "0.5574646", "0.55571336", "0.5547796", "0.5487941", "0.5450496", "0.54...
0.733204
0
Expose passes up Prometheus metrics to the caller, based on control switches which dictate what metrics the caller wishes to use
func (m Metrics) Expose() []*prometheus.CounterVec { var exposed []*prometheus.CounterVec if m.RequestCounter { exposed = append(exposed, httpReqs) } if m.ProxyCounter { exposed = append(exposed, proxyCount) } return exposed }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ExposeMetrics(options config.Options, stopCh <-chan struct{}, wg *sync.WaitGroup, logger log.Logger) {\n\twg.Add(1)\n\tdefer wg.Done()\n\n\tlogger = log.NewLoggerWith(logger, \"component\", \"metrics\")\n\n\tif options.IsEnableAdditionalSymantecMetrics {\n\t\tregisterCollectors(NewSymantecMetricsCollector(opt...
[ "0.62943596", "0.606935", "0.5983493", "0.5955956", "0.5936195", "0.5896313", "0.5838032", "0.5773502", "0.5761245", "0.5749618", "0.57393074", "0.571998", "0.5669712", "0.5638325", "0.56340677", "0.56271774", "0.55997336", "0.5589016", "0.55862945", "0.5579198", "0.55665874"...
0.57227534
11
RandProxy returns a random proxy from a Provider's list of proxies
func (p Provider) RandProxy() Proxy { s := rand.NewSource(time.Now().Unix()) r := rand.New(s) rand := r.Intn(len(p.Data)) return p.Data[rand].Proxy }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func RandomProxy(hosts ...string) InterceptorFn {\n\tif len(hosts) == 0 {\n\t\tpanic(\"empty hosts list\")\n\t}\n\treturn func(rt http.RoundTripper) http.RoundTripper {\n\t\treturn RoundTripperFn(func(request *http.Request) (*http.Response, error) {\n\t\t\trequest.Host = hosts[rand.Intn(len(hosts))]\n\t\t\treturn ...
[ "0.7494706", "0.7436685", "0.72388667", "0.70245457", "0.6505623", "0.58470386", "0.58146083", "0.5790712", "0.56759715", "0.5599842", "0.5534545", "0.54924244", "0.548021", "0.53984475", "0.5289549", "0.5278287", "0.52765566", "0.5242049", "0.51393646", "0.512822", "0.512818...
0.8410278
0
NewClient returns a retryablehttp.Client configured to use a random proxy
func (p Provider) NewClient(req *retryablehttp.Request, opts RetryOptions) (*retryablehttp.Client, string, error) { proxy := p.RandProxy() proxyURL, err := url.ParseRequestURI(fmt.Sprintf("http://%s:%s", proxy.IP, proxy.PortNum)) if err != nil { return &retryablehttp.Client{}, "", fmt.Errorf("%v", err) } client := retryablehttp.NewClient() client.Logger = nil client.RetryMax = opts.Max client.RetryWaitMax = time.Second * time.Duration(opts.WaitMaxSecs) client.RetryWaitMin = time.Second * time.Duration(opts.WaitMinSecs) client.Backoff = func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { return (time.Second * time.Duration(opts.BackoffStepSecs)) * time.Duration((attemptNum)) } client.HTTPClient = &http.Client{ Timeout: (5 * time.Second), Transport: &http.Transport{ Proxy: http.ProxyURL(proxyURL), ProxyConnectHeader: req.Header, }} return client, proxy.IP, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newHTTPClient(cfg *Config) (*http.Client, error) {\n\t// Configure proxy if needed.\n\tvar dial func(network, addr string) (net.Conn, error)\n\tif cfg.Proxy != \"\" {\n\t\tproxy := &socks.Proxy{\n\t\t\tAddr: cfg.Proxy,\n\t\t\tUsername: cfg.ProxyUser,\n\t\t\tPassword: cfg.ProxyPass,\n\t\t}\n\t\tdial = func...
[ "0.7370434", "0.7068887", "0.7040319", "0.70218575", "0.70028645", "0.69941664", "0.6972483", "0.6954779", "0.69186735", "0.6894859", "0.68834174", "0.68748033", "0.68671155", "0.6855859", "0.68221855", "0.6805804", "0.67977035", "0.6787757", "0.6780016", "0.67786926", "0.676...
0.77210724
0
Get performs an HTTP GET request against the given url, with any headers and retry options provided. It will use a random proxy to do so
func (p Provider) Get(url string, header http.Header, o RetryOptions) (http.Response, error) { req, err := retryablehttp.NewRequest("GET", url, nil) if err != nil { return http.Response{}, err } req.Header = header client, proxyIP, err := p.NewClient(req, o) if err != nil { return http.Response{}, err } resp, err := client.Do(req) if err != nil { return http.Response{}, err } httpReqs.WithLabelValues(fmt.Sprintf("%d", resp.StatusCode), "GET", proxyIP).Inc() return *resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Get(url string, r io.Reader, w io.Writer, clientGenerator func() *http.Client, reqTuner ...func(*http.Request)) error {\n\treturn Request(\"GET\", url, r, w, clientGenerator, reqTuner...)\n}", "func Get(url string) (resp *http.Response, err error) {\n\treturn DefaultClient.Get(url)\n}", "func httpGet(t *t...
[ "0.76761955", "0.74784106", "0.73909163", "0.7381686", "0.73723525", "0.73638225", "0.733259", "0.7258252", "0.72508967", "0.7219954", "0.7204669", "0.7191359", "0.7133742", "0.7132985", "0.7105667", "0.7102535", "0.70445836", "0.7036668", "0.70307475", "0.6976163", "0.696389...
0.82963437
0
NewProvider returns a configured Provider
func NewProvider(key string) (Provider, error) { if key == "" { return Provider{}, fmt.Errorf("empty API key") } p := Provider{} client := &http.Client{Timeout: 10 * time.Second} r, err := client.Get(ghostAPI + "?key=" + key) if err != nil { return Provider{}, err } defer r.Body.Close() json.NewDecoder(r.Body).Decode(&p) for _, v := range p.Data { proxyCount.WithLabelValues( v.Proxy.IP, v.Proxy.Status, v.Proxy.CityName, v.Proxy.RegionName, v.Proxy.CountryCode, ).Inc() } return p, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewProvider(cfg Config) *Provider {\n\treturn &Provider{\n\t\tConfig: cfg,\n\t}\n}", "func NewProvider() *Provider {\n\treturn &Provider{}\n}", "func New(c *Config) *Provider {\n\treturn &Provider{\n\t\tConfig: c,\n\t}\n}", "func New(provider string, p *ProviderData) Provider {\n\tswitch provider {\n\tc...
[ "0.8128935", "0.8107089", "0.7947731", "0.78635544", "0.7845964", "0.7836839", "0.7823974", "0.78217673", "0.781741", "0.7722126", "0.77031696", "0.76603645", "0.76545316", "0.75909805", "0.75908655", "0.75712144", "0.75712144", "0.75712144", "0.75712144", "0.7533229", "0.753...
0.0
-1
NewConfig returns a new RAdam Config. It panics if beta1 or beta2 are not in the range [0.0, 1.0).
func NewConfig(stepSize, beta1, beta2, epsilon float64) Config { if !(beta1 >= 0.0 && beta1 < 1.0) { panic("adam: `beta1` must be in the range [0.0, 1.0)") } if !(beta2 >= 0.0 && beta2 < 1.0) { panic("adam: `beta2` must be in the range [0.0, 1.0)") } return Config{ StepSize: stepSize, Beta1: beta1, Beta2: beta2, Epsilon: epsilon, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newConfig() *bqConfig {\n\treturn &bqConfig{\n\t\tarenaSize: cDefaultArenaSize,\n\t\tmaxInMemArenas: cMinMaxInMemArenas,\n\t}\n}", "func NewConfig() Config {\n\treturn Config{\n\t\t0.0, 0.0,\n\t\t4.0, 4.0,\n\t\t1000, 1000,\n\t\t512,\n\t\t\"ramp.json\",\n\t\t\"default.gob\",\n\t\t\"output.jpg\",\n\t\t\"...
[ "0.58682334", "0.5791714", "0.574422", "0.57309926", "0.56678116", "0.54747754", "0.5453819", "0.5438932", "0.5422589", "0.54104185", "0.5382655", "0.5369698", "0.5325242", "0.530093", "0.5297655", "0.52528226", "0.52506673", "0.5243341", "0.5229364", "0.52185094", "0.5218102...
0.71805686
0
NewDefaultConfig returns a new Config with generically reasonable default values.
func NewDefaultConfig() Config { return Config{ StepSize: 0.001, Beta1: 0.9, Beta2: 0.999, Epsilon: 1.0e-8, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDefault() *Config {\n\tvv := defaultConfig\n\treturn &vv\n}", "func NewDefault() *Config {\n\tvv := defaultConfig\n\treturn &vv\n}", "func NewDefaultConfig() *Config {\n\treturn &Config{\n\t\tDefaultNamespace: \"default\",\n\t\tFileName: \"stdin\",\n\t\tTargetKubernetesVersion: \"...
[ "0.8374629", "0.8374629", "0.8041251", "0.8026334", "0.79116195", "0.7896762", "0.78775716", "0.7861471", "0.78218305", "0.7800303", "0.77709764", "0.7767419", "0.7752707", "0.7750308", "0.7741053", "0.77397543", "0.7711731", "0.76993686", "0.76833934", "0.76833934", "0.76678...
0.8045895
2
New returns a new RAdam optimizer, initialized according to the given configuration.
func New[T float.DType](c Config) *RAdam[T] { adam := &RAdam[T]{ Config: c, RoMax: 2.0/(1.0-c.Beta2) - 1.0, TimeStep: 1.0, } return adam }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewAdam(lr, beta, beta2, epsilon float64) *Adam {\n\treturn &Adam{\n\t\tlr: fparam(lr, 0.001),\n\t\tbeta: fparam(beta, 0.9),\n\t\tbeta2: fparam(beta2, 0.999),\n\t\tepsilon: fparam(epsilon, 1e-8),\n\t}\n}", "func NewAdam(\n\tparams []anyvec.Vector, stepSize, beta1, beta2, epsilon float64) *Adam {\n...
[ "0.5821134", "0.5446745", "0.532845", "0.5318612", "0.5181388", "0.50284636", "0.5003412", "0.49892327", "0.49769872", "0.49739477", "0.49185923", "0.48619148", "0.48398253", "0.4811074", "0.48108375", "0.48083663", "0.47546217", "0.4747193", "0.4737033", "0.4735215", "0.4730...
0.72261465
0
newState returns a new state.
func (o *RAdam[T]) newState(shape ...int) *State { r, c := shape[0], shape[1] return &State{ M: mat.NewDense[T](mat.WithShape(r, c)), V: mat.NewDense[T](mat.WithShape(r, c)), Buf1: mat.NewDense[T](mat.WithShape(r, c)), Buf2: mat.NewDense[T](mat.WithShape(r, c)), Buf3: mat.NewDense[T](mat.WithShape(r, c)), } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newState(initialFmtMsg, format string) (*state, error) {\n\tclifmt, err := polyfmt.NewFormatter(polyfmt.Mode(format))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t\treturn nil, err\n\t}\n\n\tclifmt.Print(initialFmtMsg, polyfmt.Pretty)\n\n\tcfg, err := appcfg.GetConfig()\n\tif err != nil {\n\t\terrText := fmt.Spr...
[ "0.65877527", "0.6180703", "0.6148023", "0.6133315", "0.60690695", "0.59770316", "0.59733754", "0.59265506", "0.58425134", "0.5837373", "0.58263826", "0.582111", "0.5804677", "0.57588863", "0.5746426", "0.57335806", "0.57323164", "0.57227176", "0.5702326", "0.569178", "0.5664...
0.6671592
0
IncBatch beats the occurrence of a new batch.
func (o *RAdam[_]) IncBatch() { o.TimeStep++ }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *GradientDescent) IncBatch() {\n\tif method, ok := o.method.(BatchScheduler); ok {\n\t\tmethod.IncBatch()\n\t}\n}", "func (_m *CIPDClient) BeginBatch(ctx context.Context) {\n\t_m.Called(ctx)\n}", "func (gc *GroupCounter) Inc() {\n\tfor _, c := range gc.counters {\n\t\tc.Inc()\n\t}\n}", "func (c *Cont...
[ "0.7910186", "0.64050967", "0.60608524", "0.5977938", "0.5911247", "0.58961546", "0.58816797", "0.5844141", "0.5826906", "0.58016104", "0.5800821", "0.5772292", "0.57602835", "0.5751012", "0.57464874", "0.5726118", "0.5638479", "0.55962133", "0.5593387", "0.55929357", "0.5574...
0.7497945
1
m = mbeta1 + grads(1.0beta1)
func updateM(grads mat.Matrix, state *State, beta1 float64) { state.M.ProdScalarInPlace(beta1) state.Buf1.ProdMatrixScalarInPlace(grads, 1.0-beta1) state.M.AddInPlace(state.Buf1) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getBeta(fAlpha, fBeta float64) float64 {\n\tvar fA, fB float64\n\tif fAlpha > fBeta {\n\t\tfA = fAlpha\n\t\tfB = fBeta\n\t} else {\n\t\tfA = fBeta\n\t\tfB = fAlpha\n\t}\n\tconst maxGammaArgument = 171.624376956302\n\tif fA+fB < maxGammaArgument {\n\t\treturn math.Gamma(fA) / math.Gamma(fA+fB) * math.Gamma(fB)...
[ "0.57796353", "0.57367676", "0.5704809", "0.56989944", "0.56069046", "0.559405", "0.55066544", "0.54993755", "0.54840624", "0.54680145", "0.5459018", "0.5447254", "0.5434017", "0.5360158", "0.5337586", "0.5206719", "0.5186619", "0.5166022", "0.5152852", "0.51255774", "0.51065...
0.6711675
0
v = vbeta2 + (gradsgrads)(1.0beta2)
func updateV(grads mat.Matrix, state *State, beta2 float64) { state.V.ProdScalarInPlace(beta2) sqGrad := grads.Prod(grads) state.Buf2.ProdMatrixScalarInPlace(sqGrad, 1.0-beta2) state.V.AddInPlace(state.Buf2) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *G1Jac) mulGLV(a *G1Jac, s *big.Int) *G1Jac {\n\n\tvar table [15]G1Jac\n\tvar res G1Jac\n\tvar k1, k2 fr.Element\n\n\tres.Set(&g1Infinity)\n\n\t// table[b3b2b1b0-1] = b3b2*phi(a) + b1b0*a\n\ttable[0].Set(a)\n\ttable[3].phi(a)\n\n\t// split the scalar, modifies +-a, phi(a) accordingly\n\tk := ecc.SplitScala...
[ "0.5586263", "0.5585398", "0.55512506", "0.54982704", "0.5466384", "0.54608387", "0.54496974", "0.5364682", "0.5336382", "0.53347695", "0.5324832", "0.5324584", "0.52760285", "0.52568555", "0.5233749", "0.5223149", "0.5202601", "0.520236", "0.5188375", "0.51773614", "0.517081...
0.6385673
0
GenerateImageMetaData creates some random image data
func GenerateImageMetaData(howMany int) *List { list := &List{} for i := 0; i < howMany; i++ { img := &Image{} img.Name = fmt.Sprintf("IMG_%06d.jpg", i) img.Id = CreateString(16) w, h := Resolution() img.Width = w img.Height = h img.TakenAt = Time(i, 12) img.LastMod = Time(i, 13) img.Sha256 = CreateString(16) img.FileSize = rand.Int63() img.Caption = Caption(i) img.XMP = &XMP{} img.XMP.Camera = Camera() img.XMP.Owner = FaceMe() for f := 0; f < rand.Intn(5); i++ { face := &Face{} face.Name = FaceMe() face.R = rand.NormFloat64() face.X = rand.NormFloat64() face.Y = rand.NormFloat64() img.XMP.Faces = append(img.XMP.Faces, face) } list.Images = append(list.Images, img) } list.Timestamp = Time(1, 1) return list }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (aip *ActiveIPs) GenerateMetaData() {\n\taip.Type = &ActiveIPsType\n\ty, m, d := aip.Date.Date()\n\taip.Link = fmt.Sprintf(\"/research/active_ips/%04d-%02d-%02d\", y, m, d)\n}", "func randomMetadata() Metadata {\n\tmd := Metadata{\n\t\tAggregateHealth: float64(fastrand.Intn(100)),\n\t\tAggregat...
[ "0.64154863", "0.6344503", "0.6223363", "0.6055937", "0.59988976", "0.5983204", "0.58828247", "0.5774375", "0.56949925", "0.56742597", "0.56483966", "0.5647617", "0.5611369", "0.5587889", "0.5495084", "0.54645044", "0.5394243", "0.53794676", "0.532331", "0.52885824", "0.52593...
0.78387123
0
Block returns the block identified on the request as a rosetta encoded block. NOTE: this is part of the BlockAPIServicer interface.
func (s *Server) Block(ctx context.Context, req *rtypes.BlockRequest) (*rtypes.BlockResponse, *rtypes.Error) { _, _, b, err := s.getBlockByPartialId(ctx, req.BlockIdentifier) if err != nil { return nil, types.DcrdError(err) } var prev *wire.MsgBlock // Fetch the previous block when the current block disapproves of its // parent, since we'll need to reverse the transactions in the parent. // We include a special check for the genesis block because it has // VoteBits == 0. approvesParent := b.Header.VoteBits&0x01 == 0x01 if !approvesParent && b.Header.Height > 0 { prev, err = s.c.GetBlock(ctx, &b.Header.PrevBlock) if err != nil { return nil, types.DcrdError(err, types.MapRpcErrCode(-5, types.ErrBlockNotFound)) } } fetchInputs := s.makeInputsFetcher(ctx, nil) rblock, err := types.WireBlockToRosetta(b, prev, fetchInputs, s.chainParams) if err != nil { return nil, types.RError(err) } return &rtypes.BlockResponse{ Block: rblock, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (rs *RosettaService) Block(ctx context.Context, request *rtypes.BlockRequest) (*rtypes.BlockResponse, *rtypes.Error) {\n\tvar block *rtypes.Block\n\tvar err *rtypes.Error\n\tswitch {\n\tcase request.BlockIdentifier.Index != nil:\n\t\tb, ok := rs.cs.BlockAtHeight(stypes.BlockHeight(*request.BlockIdentifier.Ind...
[ "0.8338847", "0.7633274", "0.7504522", "0.72231877", "0.7012322", "0.69668525", "0.6965455", "0.69054824", "0.68715656", "0.6862664", "0.6860121", "0.6781391", "0.6731799", "0.6723696", "0.6716859", "0.6710591", "0.66734666", "0.6613884", "0.6605735", "0.6550756", "0.6537798"...
0.8022571
1
BlockTransaction returns additional transactions related to the specified block, not returned by the Block() call. This is currently unused in Decred given that all relevant transactions are returned by Block(). NOTE: this is part of the BlockAPIServicer interface.
func (s *Server) BlockTransaction(context.Context, *rtypes.BlockTransactionRequest, ) (*rtypes.BlockTransactionResponse, *rtypes.Error) { return nil, types.ErrUnimplemented.RError() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (rs *RosettaService) BlockTransaction(ctx context.Context, request *rtypes.BlockTransactionRequest) (*rtypes.BlockTransactionResponse, *rtypes.Error) {\n\t// all transactions are returned from /block\n\treturn nil, errNotImplemented\n}", "func (ec *Client) TransactionInBlock(ctx context.Context, blockHash c...
[ "0.76878", "0.698557", "0.67671347", "0.6700926", "0.6428531", "0.6424233", "0.64124113", "0.63116837", "0.62905055", "0.6248111", "0.6206847", "0.619386", "0.61346436", "0.61243284", "0.61152464", "0.611218", "0.60812044", "0.6079944", "0.6077914", "0.6076352", "0.605372", ...
0.75958097
1
GetOrganizationSpaces returns a list of spaces in the specified org
func (actor Actor) GetOrganizationSpaces(orgGUID string) ([]Space, Warnings, error) { ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces(ccv2.Query{ Filter: ccv2.OrganizationGUIDFilter, Operator: ccv2.EqualOperator, Values: []string{orgGUID}, }) if err != nil { return []Space{}, Warnings(warnings), err } spaces := make([]Space, len(ccv2Spaces)) for i, ccv2Space := range ccv2Spaces { spaces[i] = Space(ccv2Space) } return spaces, Warnings(warnings), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (actor Actor) GetOrganizationSpaces(orgGUID string) ([]Space, Warnings, error) {\n\tquery := []ccv2.Query{\n\t\t{\n\t\t\tFilter: ccv2.OrganizationGUIDFilter,\n\t\t\tOperator: ccv2.EqualOperator,\n\t\t\tValue: orgGUID,\n\t\t}}\n\tccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces(query)\n\...
[ "0.836347", "0.8151213", "0.7077322", "0.70715684", "0.70504296", "0.65691507", "0.63065076", "0.6275161", "0.6266745", "0.62511164", "0.59974486", "0.5982455", "0.5811778", "0.5715128", "0.5714711", "0.5702683", "0.56988907", "0.5671041", "0.56710315", "0.56426775", "0.56383...
0.83006597
1
GetSpaceByOrganizationAndName returns an Space based on the org and name.
func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) { ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces( ccv2.Query{ Filter: ccv2.NameFilter, Operator: ccv2.EqualOperator, Values: []string{spaceName}, }, ccv2.Query{ Filter: ccv2.OrganizationGUIDFilter, Operator: ccv2.EqualOperator, Values: []string{orgGUID}, }, ) if err != nil { return Space{}, Warnings(warnings), err } if len(ccv2Spaces) == 0 { return Space{}, Warnings(warnings), SpaceNotFoundError{Name: spaceName} } if len(ccv2Spaces) > 1 { return Space{}, Warnings(warnings), MultipleSpacesFoundError{OrgGUID: orgGUID, Name: spaceName} } return Space(ccv2Spaces[0]), Warnings(warnings), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) {\n\tquery := []ccv2.Query{\n\t\t{\n\t\t\tFilter: ccv2.NameFilter,\n\t\t\tOperator: ccv2.EqualOperator,\n\t\t\tValue: spaceName,\n\t\t},\n\t\t{\n\t\t\tFilter: ccv2.OrganizationGUIDFilter,\n\t\t\tOpera...
[ "0.8242939", "0.61442536", "0.603013", "0.5925023", "0.58118176", "0.57149905", "0.5652524", "0.5448941", "0.5424435", "0.53659654", "0.5316954", "0.52566516", "0.523959", "0.5199702", "0.5174425", "0.5162662", "0.51054066", "0.50635743", "0.5060647", "0.50374913", "0.4994271...
0.81762856
1
New initialize Now with time
func New(t time.Time) *Now { return &Now{t} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Now() time.Time { return now() }", "func Now() time.Time { return time.Now().UTC() }", "func Now() time.Time { return time.Now().UTC() }", "func (c stubClocker) Now() time.Time { return c.t }", "func Now() time.Time { return time.Now() }", "func Now() Time {\n\treturn NewTime(time.Now())\n}", "fun...
[ "0.76180404", "0.7385969", "0.7385969", "0.7371018", "0.7280752", "0.7213913", "0.7187263", "0.71849674", "0.71551025", "0.7143852", "0.7143053", "0.71301425", "0.7128633", "0.7120812", "0.7109315", "0.70917165", "0.70683783", "0.70221984", "0.7019913", "0.70187783", "0.69636...
0.73370737
4
BeginningOfYear beginning of year
func BeginningOfYear() time.Time { return New(time.Now()).BeginningOfYear() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (now *Now) BeginningOfYear() time.Time {\n\ty, _, _ := now.Date()\n\treturn time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location())\n}", "func YearStart(dt time.Time) time.Time {\n\treturn time.Date(\n\t\tdt.Year(),\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\ttime.UTC,\n\t)\n}", "func StartYear...
[ "0.7899211", "0.7367037", "0.72628975", "0.7149147", "0.67440516", "0.65811616", "0.6560313", "0.6554245", "0.6499357", "0.648948", "0.6486854", "0.6461929", "0.63560194", "0.63298076", "0.6318857", "0.6294704", "0.628328", "0.6255367", "0.6227002", "0.621877", "0.62150335", ...
0.8250332
0
BeginningOfYear BeginningOfYear beginning of year
func (now *Now) BeginningOfYear() time.Time { y, _, _ := now.Date() return time.Date(y, time.January, 1, 0, 0, 0, 0, now.Location()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func BeginningOfYear() time.Time {\n\treturn New(time.Now()).BeginningOfYear()\n}", "func YearStart(dt time.Time) time.Time {\n\treturn time.Date(\n\t\tdt.Year(),\n\t\t1,\n\t\t1,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0,\n\t\ttime.UTC,\n\t)\n}", "func StartYear(year int, layout string) string {\n\ttimeNow := time.Now()....
[ "0.84461635", "0.7129927", "0.7125371", "0.68977463", "0.67089003", "0.6379925", "0.63039315", "0.6301062", "0.6261816", "0.6249966", "0.6124489", "0.61114603", "0.6101744", "0.6064978", "0.6049439", "0.6020882", "0.6003487", "0.5986194", "0.59538805", "0.59198457", "0.588468...
0.81009567
1
Render : run the code generation
func (r *Ris) Render() { r.render() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *ginRenderJade) Render(w http.ResponseWriter, code int, data ...interface{}) error {\n\twriteHeader(w, code, \"text/html\")\n\tfile := data[0].(string)\n\targs := data[1]\n\treturn this.Template.RenderFileW(w, file, args)\n}", "func render(w http.ResponseWriter, context PageContext) {\n\tfuncMap := te...
[ "0.69906324", "0.6711924", "0.6653557", "0.6548527", "0.64930576", "0.6455168", "0.6452924", "0.6408066", "0.6359203", "0.63572174", "0.6285732", "0.62783897", "0.6215761", "0.6215658", "0.6215658", "0.6214472", "0.62020814", "0.62014455", "0.6174", "0.6165483", "0.6152791", ...
0.6269176
12
NewRateLimiter generates a RateLimiter with a given capacity.
func NewRateLimiter(capacity int) *RateLimiter { semaphore := make(chan bool, capacity) // Fill channel for i := 0; i < capacity; i++ { semaphore <- true } return &RateLimiter{semaphore} }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func newRateLimiter() *rateLimiter {\n\tdecayFactor := 9.0 / 8.0\n\treturn &rateLimiter{\n\t\tstats: info.RateLimiterStats{\n\t\t\tTargetRate: 1,\n\t\t},\n\t\tdecayPeriod: 5 * time.Second,\n\t\tdecayFactor: decayFactor,\n\t\texit: make(chan struct{}),\n\t}\n}", "func NewRateLimiter(rate float64, capacity ...
[ "0.8107297", "0.7961854", "0.7885352", "0.7791581", "0.7787195", "0.7756457", "0.7716399", "0.7656956", "0.759678", "0.75580776", "0.75578725", "0.75571537", "0.7536802", "0.7390164", "0.7362798", "0.7298369", "0.7286124", "0.7258976", "0.72212106", "0.7175126", "0.7154756", ...
0.8463262
0
Limit limits the number of concurrent requests by 1 and blocks if the number of concurrent requests reached a maximum.
func (rater *RateLimiter) Limit() { <-rater.semaphore }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func lockLimitConnections() {\n\tsemaphoreMaxConnections <- struct{}{}\n}", "func LimitGoroutine() {\n\tconcurrency := 5\n\tsem := make(chan bool, concurrency)\n\turls := []string{\"http://jmoiron.net/blog/limiting-concurrency-in-go/\", \"https://github.com/go-sql-driver/mysql/tree/alloc-pool\"}\n\tfor _, url :=...
[ "0.68766797", "0.6779762", "0.67135614", "0.6662659", "0.652928", "0.6507631", "0.64878035", "0.6459614", "0.64153814", "0.63881266", "0.6387182", "0.6327414", "0.6253636", "0.6235691", "0.6194677", "0.6182699", "0.61767733", "0.61741817", "0.61554265", "0.6143212", "0.610488...
0.64634264
7
Free increases the number of concurrent requests by 1 This function must be called after a Limit call or it will block.
func (rater *RateLimiter) Free() { rater.semaphore <- true }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *Pool) Free() int {\n\treturn p.Cap() - p.Running()\n}", "func Free() int {\n\treturn defaultRoutinePool.Free()\n}", "func TestFreelist_free(t *testing.T) {\n\tf := newFreelist()\n\tf.free(100, &page{id: 12})\n\tif !reflect.DeepEqual([]pgid{12}, f.pending[100]) {\n\t\tt.Fatalf(\"exp=%v; got=%v\", []pgi...
[ "0.6866443", "0.6678183", "0.6493432", "0.630607", "0.62864053", "0.6243849", "0.61974216", "0.6071971", "0.6030552", "0.60024", "0.5996387", "0.5909297", "0.5899765", "0.5899695", "0.5894417", "0.58930266", "0.58856153", "0.58820987", "0.58708996", "0.5844449", "0.5824323", ...
0.73970497
0
Create initializes the builder
func (app *applicationBuilder) Create() ApplicationBuilder { return createApplicationBuilder() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter, app.immutableBuilder)\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter)\n}", "func (app *builder) Create() Builder {\n\treturn createBuilder(app.hashAdapter)\n}", "func (app *builder) Create() ...
[ "0.69202626", "0.6912449", "0.6912449", "0.6899315", "0.6793273", "0.67767155", "0.67767155", "0.6755811", "0.6755811", "0.67423236", "0.6639238", "0.6593561", "0.65597653", "0.64317507", "0.63935584", "0.6364446", "0.6348599", "0.63432586", "0.6327977", "0.6309385", "0.63056...
0.59235173
40
WithHead adds an headSection to the builder
func (app *applicationBuilder) WithHead(head HeadSection) ApplicationBuilder { app.head = head return app }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (hb *dsHeadBook) AddHead(t thread.ID, p peer.ID, head cid.Cid) error {\n\treturn hb.AddHeads(t, p, []cid.Cid{head})\n}", "func (b *Builder) Head(url string) *Builder {\n\tb.Url = url\n\tb.Method = http.MethodHead\n\treturn b\n}", "func (app *adapter) ToHead(parsed parsers.HeadSection) (Head, error) {\n\tn...
[ "0.611557", "0.60735554", "0.601188", "0.5821925", "0.56226987", "0.5559988", "0.547994", "0.5464441", "0.54019463", "0.5343665", "0.533313", "0.532674", "0.52113295", "0.51794606", "0.5169951", "0.51491785", "0.5082635", "0.5077762", "0.50730515", "0.50532407", "0.50119066",...
0.8069159
0
WithLabel adds a labelSection to the builder
func (app *applicationBuilder) WithLabel(label LabelSection) ApplicationBuilder { app.label = label return app }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func WithLabel(k string, v interface{}) Option {\n\treturn labelOption{key: k, value: v}\n}", "func WithLabel(key, value string) Option {\n\treturn func(meta metav1.Object) {\n\t\tlabels := meta.GetLabels()\n\t\tlabels = k8slabels.AddLabel(labels, key, value)\n\t\tmeta.SetLabels(labels)\n\t}\n}", "func (g Gen)...
[ "0.7042802", "0.6714825", "0.6645144", "0.6584446", "0.62846386", "0.6190551", "0.6139383", "0.61151904", "0.60762894", "0.60660005", "0.60486287", "0.6003239", "0.596394", "0.5875127", "0.5818254", "0.57637286", "0.57486284", "0.573727", "0.5729538", "0.5707006", "0.56715226...
0.7461231
0
WithMain adds a mainSection to the builder
func (app *applicationBuilder) WithMain(main MainSection) ApplicationBuilder { app.main = main return app }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *targetBuilder) setMain(main string) *targetBuilder {\n\tt.main = &main\n\treturn t\n}", "func (app *mainSectionBuilder) WithInstructions(ins []Instruction) MainSectionBuilder {\n\tapp.instructions = ins\n\treturn app\n}", "func (app *mainSectionBuilder) Create() MainSectionBuilder {\n\treturn createMa...
[ "0.60540175", "0.5744275", "0.5715339", "0.556082", "0.5553542", "0.5511685", "0.5460612", "0.53178746", "0.52588576", "0.5224122", "0.51961803", "0.5177115", "0.5175806", "0.5088678", "0.50730175", "0.50573367", "0.5002134", "0.49979734", "0.49948007", "0.49303952", "0.49156...
0.82291776
0
WithTest adds a testSection to the builder
func (app *applicationBuilder) WithTest(test TestSection) ApplicationBuilder { app.test = test return app }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func WithTestdata() Option {\n\treturn func(c *config) {\n\t\tc.testdata = true\n\t}\n}", "func (m *Main) AddTest(t *Test) {\n\tm.Tests = append(m.Tests, t)\n}", "func WithTestName(ctx context.Context, id string) context.Context {\n\treturn context.WithValue(ctx, testNameKey{}, id)\n}", "func AddGenesisTest(...
[ "0.6369727", "0.5422354", "0.54128635", "0.5392826", "0.5236523", "0.5211328", "0.5191266", "0.5152483", "0.5080173", "0.5068737", "0.501173", "0.49871865", "0.4952959", "0.49069577", "0.49036428", "0.48856345", "0.4885214", "0.48723263", "0.48336744", "0.4815657", "0.4802564...
0.8302626
0
WithVariables add definition to the builder
func (app *applicationBuilder) WithDefinition(def DefinitionSection) ApplicationBuilder { app.def = def return app }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (builder QueryBuilder) Variable(queryBuilder QueryBuilder) QueryBuilder {\n\tbuilder.variables = append(builder.variables, queryBuilder)\n\treturn builder\n}", "func WithVariables(variables []string) CompilerOption {\n\treturn func(c *compiler) {\n\t\tc.variables = variables\n\t}\n}", "func WithVariables(...
[ "0.60826826", "0.5945396", "0.5945396", "0.5622157", "0.5578041", "0.5568355", "0.55566686", "0.5549164", "0.5427744", "0.5359938", "0.5208214", "0.5185076", "0.5166366", "0.5034822", "0.49868807", "0.49719235", "0.4950178", "0.4950178", "0.4889872", "0.478144", "0.47600535",...
0.42398193
66
Now builds a new Application instance
func (app *applicationBuilder) Now() (Application, error) { if app.head == nil { return nil, errors.New("the HeadSection is mandatory in order to build a Application instance") } if app.main == nil { return nil, errors.New("the MainSection is mandatory in order to build a Application instance") } if app.test != nil && app.def != nil && app.label != nil { return createApplicationWithDefinitionAndLabelAndTest(app.head, app.main, app.def, app.label, app.test), nil } if app.def != nil && app.label != nil { return createApplicationWithDefinitionAndLabel(app.head, app.main, app.def, app.label), nil } if app.test != nil && app.label != nil { return createApplicationWithLabelAndTest(app.head, app.main, app.label, app.test), nil } if app.test != nil && app.def != nil { return createApplicationWithDefinitionAndTest(app.head, app.main, app.def, app.test), nil } if app.test != nil { return createApplicationWithTest(app.head, app.main, app.test), nil } if app.def != nil { return createApplicationWithDefinition(app.head, app.main, app.def), nil } if app.label != nil { return createApplicationWithLabel(app.head, app.main, app.label), nil } return createApplication(app.head, app.main), nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateApplication() *Alpha {\n app := &Alpha{}\n app.Request = &Request{}\n app.Response = &Response{}\n app.init()\n return app\n}", "func New(\n\tfactories config.Factories,\n\tappInfo ApplicationStartInfo,\n) (*Application, error) {\n\n\tif err := configcheck.ValidateConfigFromFactories(factories); ...
[ "0.746471", "0.72537917", "0.7247702", "0.7063687", "0.7057017", "0.6966784", "0.69611853", "0.6944947", "0.68381363", "0.68372166", "0.6823613", "0.6797753", "0.67797875", "0.67708886", "0.67537725", "0.67292297", "0.67292297", "0.6720004", "0.67192185", "0.67133147", "0.668...
0.7047488
5
Init initialises the function
func (o *Cos) Init(prms Prms) (err error) { for _, p := range prms { switch p.N { case "a": o.a = p.V case "b": o.b = p.V case "c": o.c = p.V case "b/pi": // b/π => b = b/pi * π o.b = p.V * math.Pi default: return chk.Err("cos: parameter named %q is invalid", p.N) } } return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Init() {}", "func Init() {}", "func Init() error {\n\n}", "func init() {\n\t// init func\n}", "func Init() {\n\n}", "func init() {\n\t//todo...\n}", "func init() {}", "func init() {}", "func init() {}", "func init() {}", "func init() {\n\t// Initialization goes here\n}", "func init(){\n\...
[ "0.7448294", "0.7448294", "0.73375386", "0.7336218", "0.7174763", "0.7160326", "0.71554255", "0.71554255", "0.71554255", "0.71554255", "0.70886326", "0.70496726", "0.7007015", "0.6971261", "0.686479", "0.6837379", "0.6837379", "0.6788343", "0.67447656", "0.6629871", "0.662987...
0.0
-1
F returns y = F(t, x)
func (o Cos) F(t float64, x []float64) float64 { return o.a*math.Cos(o.b*t) + o.c }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (i I) F() F {\n\treturn F{float64(i.X), float64(i.Y)}\n}", "func f(t float64, w float64) float64 {\n\treturn (-1 - 0.02*w + (acc * t))\n}", "func (o Mul) F(t float64, x []float64) float64 {\n\tif o.Fa != nil && o.Fb != nil {\n\t\treturn o.Fa.F(t, x) * o.Fb.F(t, x)\n\t}\n\tchk.Panic(\"mul: fa and fb functi...
[ "0.642726", "0.63500917", "0.6322419", "0.62878615", "0.62501085", "0.6243732", "0.6014716", "0.5920861", "0.5854409", "0.5807788", "0.5751894", "0.56997144", "0.5676256", "0.5650777", "0.56495255", "0.5641937", "0.5522204", "0.549365", "0.548898", "0.54700804", "0.5442039", ...
0.69339114
0
SetName sets the name field.
func (ac *AppCreate) SetName(s string) *AppCreate { ac.mutation.SetName(s) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cli *SetWrapper) SetName(name string) error {\n\treturn cli.set.SetValue(fieldSetName, name)\n}", "func (s UserSet) SetName(value string) {\n\ts.RecordCollection.Set(models.NewFieldName(\"Name\", \"name\"), value)\n}", "func (f *Flow) setName(n string) {\n\tf.Name = n\n}", "func (s *MyTestStruct) SetNa...
[ "0.81129515", "0.78825146", "0.7534317", "0.7523171", "0.73899966", "0.73698646", "0.73400325", "0.73141974", "0.7256551", "0.72248316", "0.7196492", "0.7190641", "0.71832526", "0.71805173", "0.7158975", "0.71449256", "0.7139063", "0.711154", "0.7105229", "0.70985585", "0.705...
0.0
-1
SetVersion sets the version field.
func (ac *AppCreate) SetVersion(s string) *AppCreate { ac.mutation.SetVersion(s) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func SetVersion(ver string) {\n\tversion = ver\n}", "func (info *Metadata) SetVersion(version int32) {\n\tinfo.version = version\n}", "func (s *Server) SetVersion(newVersion uint32) {\n\ts.mu.Lock()\n\tdefer s.mu.Unlock()\n\ts.version = newVersion\n}", "func SetVersion(v string, os string, arch string, commi...
[ "0.8282522", "0.7993682", "0.7818151", "0.7816626", "0.7574834", "0.75651526", "0.7559927", "0.7523605", "0.75083274", "0.74630666", "0.74577516", "0.745642", "0.7442571", "0.7441765", "0.743878", "0.7420126", "0.73809814", "0.7380753", "0.7371691", "0.73631924", "0.7354351",...
0.70406353
46
SetNillableVersion sets the version field if the given value is not nil.
func (ac *AppCreate) SetNillableVersion(s *string) *AppCreate { if s != nil { ac.SetVersion(*s) } return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (lu *LibraryUpdate) SetNillableVersion(s *string) *LibraryUpdate {\n\tif s != nil {\n\t\tlu.SetVersion(*s)\n\t}\n\treturn lu\n}", "func (luo *LibraryUpdateOne) SetNillableVersion(s *string) *LibraryUpdateOne {\n\tif s != nil {\n\t\tluo.SetVersion(*s)\n\t}\n\treturn luo\n}", "func (au *AppUpdate) SetNillab...
[ "0.8551493", "0.8505628", "0.8406956", "0.84064615", "0.832453", "0.8303488", "0.8296725", "0.8289717", "0.82554096", "0.67345166", "0.64931744", "0.60176975", "0.59949774", "0.5966361", "0.5960429", "0.5939814", "0.5910575", "0.5881628", "0.5873669", "0.58630395", "0.5848542...
0.8401697
4
SetBuild sets the build field.
func (ac *AppCreate) SetBuild(s string) *AppCreate { ac.mutation.SetBuild(s) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (e *Executor) SetBuild(v Build) {\n\t// return if Executor type is nil\n\tif e == nil {\n\t\treturn\n\t}\n\n\te.Build = &v\n}", "func (au *AppUpdate) SetBuild(s string) *AppUpdate {\n\tau.mutation.SetBuild(s)\n\treturn au\n}", "func (auo *AppUpdateOne) SetBuild(s string) *AppUpdateOne {\n\tauo.mutation.Se...
[ "0.8008988", "0.76756823", "0.76625735", "0.6384204", "0.62636846", "0.611718", "0.60730314", "0.60614896", "0.6038821", "0.5954646", "0.5927414", "0.5866466", "0.5788885", "0.5745907", "0.5707158", "0.5696907", "0.56841594", "0.5680812", "0.56798065", "0.5637473", "0.561991"...
0.7721887
1
SetNillableBuild sets the build field if the given value is not nil.
func (ac *AppCreate) SetNillableBuild(s *string) *AppCreate { if s != nil { ac.SetBuild(*s) } return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (auo *AppUpdateOne) SetNillableBuild(s *string) *AppUpdateOne {\n\tif s != nil {\n\t\tauo.SetBuild(*s)\n\t}\n\treturn auo\n}", "func (au *AppUpdate) SetNillableBuild(s *string) *AppUpdate {\n\tif s != nil {\n\t\tau.SetBuild(*s)\n\t}\n\treturn au\n}", "func (pu *PendingloanbindingUpdate) SetNillableDateGen...
[ "0.8304011", "0.8224735", "0.5783829", "0.5779206", "0.5730435", "0.5600772", "0.55846643", "0.5577679", "0.55747837", "0.55399686", "0.5527202", "0.55259156", "0.5508183", "0.5485951", "0.5464295", "0.54510814", "0.5450909", "0.54472756", "0.5418234", "0.54154587", "0.541224...
0.8159586
2
SetNamespace sets the namespace field.
func (ac *AppCreate) SetNamespace(s string) *AppCreate { ac.mutation.SetNamespace(s) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t *Tracker) SetNamespace(namespace string) {\n\tt.Namespace = namespace\n}", "func (o *SparseCloudSnapshotAccount) SetNamespace(namespace string) {\n\n\to.Namespace = &namespace\n}", "func (o *SparseClaims) SetNamespace(namespace string) {\n\n\to.Namespace = &namespace\n}", "func (o *GetModerationRules...
[ "0.8266545", "0.82182395", "0.81653154", "0.8156894", "0.8152071", "0.8144666", "0.81119764", "0.80577594", "0.80455834", "0.8020759", "0.79911023", "0.7982452", "0.79671055", "0.7964713", "0.79346156", "0.78891546", "0.78879726", "0.7821699", "0.7776216", "0.77732295", "0.77...
0.8061413
7
SetNillableNamespace sets the namespace field if the given value is not nil.
func (ac *AppCreate) SetNillableNamespace(s *string) *AppCreate { if s != nil { ac.SetNamespace(*s) } return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (auo *AppUpdateOne) SetNillableNamespace(s *string) *AppUpdateOne {\n\tif s != nil {\n\t\tauo.SetNamespace(*s)\n\t}\n\treturn auo\n}", "func (au *AppUpdate) SetNillableNamespace(s *string) *AppUpdate {\n\tif s != nil {\n\t\tau.SetNamespace(*s)\n\t}\n\treturn au\n}", "func (gau *GithubAssetUpdate) SetNilla...
[ "0.83842903", "0.838323", "0.6178913", "0.602143", "0.5942123", "0.5861777", "0.5855511", "0.58375657", "0.5750382", "0.57123023", "0.5694858", "0.567392", "0.5647735", "0.56414014", "0.5624071", "0.5614129", "0.56009907", "0.55871195", "0.5582391", "0.5577921", "0.55773294",...
0.8311508
2
SetProperties sets the properties field.
func (ac *AppCreate) SetProperties(m map[string]interface{}) *AppCreate { ac.mutation.SetProperties(m) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Rietveld) SetProperties(issue, lastPatchset int64, props map[string]string) error {\n\tdata := url.Values{}\n\tfor k, v := range props {\n\t\tdata.Add(k, v)\n\t}\n\tdata.Add(\"last_patchset\", fmt.Sprintf(\"%d\", lastPatchset))\n\treturn r.post(fmt.Sprintf(\"/%d/edit_flags\", issue), data)\n}", "func (m...
[ "0.7214836", "0.72038245", "0.71145713", "0.7034423", "0.70218915", "0.68943685", "0.6838208", "0.67702264", "0.6716018", "0.6649501", "0.6591657", "0.65702873", "0.6552207", "0.6527473", "0.6492894", "0.64357823", "0.6418739", "0.6364624", "0.63023174", "0.6281613", "0.62651...
0.6662494
9
AddEventIDs adds the events edge to Event by ids.
func (ac *AppCreate) AddEventIDs(ids ...uuid.UUID) *AppCreate { ac.mutation.AddEventIDs(ids...) return ac }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *InviteeMutation) AddEventIDs(ids ...int) {\n\tif m.events == nil {\n\t\tm.events = make(map[int]struct{})\n\t}\n\tfor i := range ids {\n\t\tm.events[ids[i]] = struct{}{}\n\t}\n}", "func (au *AppUpdate) AddEventIDs(ids ...uuid.UUID) *AppUpdate {\n\tau.mutation.AddEventIDs(ids...)\n\treturn au\n}", "fun...
[ "0.7959147", "0.7650785", "0.764343", "0.7574909", "0.7552359", "0.74618393", "0.7425623", "0.72158563", "0.72071666", "0.7135826", "0.713082", "0.7017985", "0.6889757", "0.67267936", "0.66681826", "0.6618952", "0.66037005", "0.6595512", "0.65914345", "0.65448225", "0.6507337...
0.7611659
3
AddEvents adds the events edges to Event.
func (ac *AppCreate) AddEvents(e ...*Event) *AppCreate { ids := make([]uuid.UUID, len(e)) for i := range e { ids[i] = e[i].ID } return ac.AddEventIDs(ids...) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func AddEvent(event Event) {\n\tEvents = append(Events, event)\n}", "func (lu *LibraryUpdate) AddEvents(e ...*Event) *LibraryUpdate {\n\tids := make([]uuid.UUID, len(e))\n\tfor i := range e {\n\t\tids[i] = e[i].ID\n\t}\n\treturn lu.AddEventIDs(ids...)\n}", "func (mnuo *MetricNameUpdateOne) AddEvents(e ...*Even...
[ "0.6704259", "0.6652266", "0.6595114", "0.65947115", "0.6588073", "0.65375155", "0.6529956", "0.6430668", "0.637782", "0.63765407", "0.6348559", "0.6312045", "0.62506163", "0.6233655", "0.6188273", "0.6109361", "0.60342705", "0.6020177", "0.59109396", "0.589762", "0.58864474"...
0.67074853
0
Mutation returns the AppMutation object of the builder.
func (ac *AppCreate) Mutation() *AppMutation { return ac.mutation }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (au *AppUpdate) Mutation() *AppMutation {\n\treturn au.mutation\n}", "func (auo *AppUpdateOne) Mutation() *AppMutation {\n\treturn auo.mutation\n}", "func (aru *AppointmentResultsUpdate) Mutation() *AppointmentResultsMutation {\n\treturn aru.mutation\n}", "func (aruo *AppointmentResultsUpdateOne) Mutati...
[ "0.762948", "0.7490448", "0.6560429", "0.654045", "0.6499935", "0.64826035", "0.6443473", "0.64350283", "0.6410878", "0.63917685", "0.6360468", "0.6325174", "0.6325174", "0.6323004", "0.6323004", "0.6321316", "0.63093674", "0.6289354", "0.6258522", "0.6256568", "0.62235224", ...
0.7838271
0
Save creates the App in the database.
func (ac *AppCreate) Save(ctx context.Context) (*App, error) { if err := ac.preSave(); err != nil { return nil, err } var ( err error node *App ) if len(ac.hooks) == 0 { node, err = ac.sqlSave(ctx) } else { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*AppMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } ac.mutation = mutation node, err = ac.sqlSave(ctx) mutation.done = true return node, err }) for i := len(ac.hooks) - 1; i >= 0; i-- { mut = ac.hooks[i](mut) } if _, err := mut.Mutate(ctx, ac.mutation); err != nil { return nil, err } } return node, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (app *App) Save(db *pg.DB) error {\n\t_, err := db.Model(app).\n\t\tOnConflict(\"(id) DO UPDATE\").\n\t\tSet(\"name= ?name\").\n\t\tSet(\"url= ?url\").\n\t\tSet(\"icon= ?icon\").\n\t\tSet(\"kind= ?kind\").\n\t\tSet(\"version= ?version\").\n\t\tSet(\"bundle_id= ?bundle_id\").\n\t\tSet(\"author_id= ?author_id\"...
[ "0.7453346", "0.66413695", "0.649484", "0.6487268", "0.647283", "0.645859", "0.62722695", "0.6225815", "0.62228966", "0.6155802", "0.6148145", "0.61172324", "0.6110149", "0.60899836", "0.6068699", "0.6046805", "0.60159725", "0.6009806", "0.5972341", "0.59609294", "0.59307957"...
0.7422816
1
SaveX calls Save and panics if Save returns an error.
func (ac *AppCreate) SaveX(ctx context.Context) *App { v, err := ac.Save(ctx) if err != nil { panic(err) } return v }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (muo *MedicalfileUpdateOne) SaveX(ctx context.Context) *Medicalfile {\n\tm, err := muo.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn m\n}", "func (fc *FileCreate) SaveX(ctx context.Context) *File {\n\tv, err := fc.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (bc *...
[ "0.74172425", "0.73636734", "0.7356518", "0.73294014", "0.7282916", "0.7188979", "0.71573126", "0.7123369", "0.7083495", "0.7079091", "0.7077559", "0.70773494", "0.70764124", "0.7075264", "0.7073959", "0.7069399", "0.7066063", "0.70648736", "0.7054327", "0.70509976", "0.70497...
0.69970447
39
Save creates the App entities in the database.
func (acb *AppCreateBulk) Save(ctx context.Context) ([]*App, error) { specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) nodes := make([]*App, len(acb.builders)) mutators := make([]Mutator, len(acb.builders)) for i := range acb.builders { func(i int, root context.Context) { builder := acb.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { if err := builder.preSave(); err != nil { return nil, err } mutation, ok := m.(*AppMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } builder.mutation = mutation nodes[i], specs[i] = builder.createSpec() var err error if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, acb.builders[i+1].mutation) } else { // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, acb.driver, &sqlgraph.BatchCreateSpec{Nodes: specs}); err != nil { if cerr, ok := isSQLConstraintError(err); ok { err = cerr } } } mutation.done = true if err != nil { return nil, err } id := specs[i].ID.Value.(int64) nodes[i].ID = int(id) return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { mut = builder.hooks[i](mut) } mutators[i] = mut }(i, ctx) } if len(mutators) > 0 { if _, err := mutators[0].Mutate(ctx, acb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (app *App) Save(db *pg.DB) error {\n\t_, err := db.Model(app).\n\t\tOnConflict(\"(id) DO UPDATE\").\n\t\tSet(\"name= ?name\").\n\t\tSet(\"url= ?url\").\n\t\tSet(\"icon= ?icon\").\n\t\tSet(\"kind= ?kind\").\n\t\tSet(\"version= ?version\").\n\t\tSet(\"bundle_id= ?bundle_id\").\n\t\tSet(\"author_id= ?author_id\"...
[ "0.71042067", "0.70797807", "0.67084944", "0.6399019", "0.6269228", "0.6188564", "0.6159549", "0.60583955", "0.6049131", "0.5908031", "0.58675456", "0.58582735", "0.58488023", "0.58297443", "0.58230525", "0.5806245", "0.5761058", "0.5754687", "0.57519376", "0.57504725", "0.57...
0.6269101
5
SaveX calls Save and panics if Save returns an error.
func (acb *AppCreateBulk) SaveX(ctx context.Context) []*App { v, err := acb.Save(ctx) if err != nil { panic(err) } return v }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (muo *MedicalfileUpdateOne) SaveX(ctx context.Context) *Medicalfile {\n\tm, err := muo.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn m\n}", "func (fc *FileCreate) SaveX(ctx context.Context) *File {\n\tv, err := fc.Save(ctx)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn v\n}", "func (bc *...
[ "0.7415374", "0.7362068", "0.7355115", "0.73282033", "0.7281354", "0.7187514", "0.715555", "0.7121415", "0.70820653", "0.707749", "0.70763016", "0.7076269", "0.70750177", "0.70738536", "0.7072377", "0.70679885", "0.70646185", "0.7063686", "0.7052814", "0.7049591", "0.7048603"...
0.0
-1
InitOsStore init Store as an OpenStack Storer
func InitOsStore() error { if err := context.InitKeyring(viper.GetString("openstack.user"), viper.GetString("openstack.password"), viper.GetString("openstack.tenant.name"), viper.GetString("openstack.authurl"), viper.GetString("openstack.tenant.id"), viper.GetString("openstack.region")); err != nil { return err } if err := identity.DoAuth(); err != nil { return err } // auto update Token each 30 minutes logger := log.New(logger.Log.Writer(), "osstore", 0) Store = Storer(OsStore{}) ///store = &storee identity.AutoUpdate(30, logger) return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func InitStore(s Store) {\n\tstore = s\n}", "func InitStore(s Store) {\n\tstore = s\n}", "func InitStore(s Store) {\n\tstore = s\n}", "func InitStore() {\n\tdb, err := storm.Open(config.DatabaseFile)\n\tif err != nil {\n\t\tpanic(xerrors.Errorf(\"Cannot open database: %w\", err))\n\t}\n\tAuth = newAuthStore(...
[ "0.71370965", "0.71370965", "0.71370965", "0.6942518", "0.684196", "0.68171936", "0.6753748", "0.674269", "0.6553233", "0.6540563", "0.6507531", "0.64896905", "0.64125925", "0.63303596", "0.6284118", "0.62639946", "0.6252602", "0.62092555", "0.6164684", "0.61394686", "0.61376...
0.83667094
0
StoreCopyImageFromURL copy image form URL to Store
func StoreCopyImageFromURL(basePath, fromURL string) (key, URL string, err error) { parts := strings.Split(fromURL, "/") fileName := parts[len(parts)-1] // DL image resp, err := http.Get(fromURL) if err != nil { return } defer resp.Body.Close() key = fmt.Sprintf("%s/%s", basePath, url.QueryEscape(fileName)) URL = viper.GetString("openstack.container.url") + "/" + key // push to object storage filePath := viper.GetString("temppath") + "/image_" + uuid.NewV4().String() fd, err := os.Create(filePath) if err != nil { return } defer fd.Close() _, err = io.Copy(fd, resp.Body) if err != nil { return } fd.Seek(0, 0) if err = Store.Put(key, fd); err != nil { return } // Remove temp file os.Remove(filePath) return }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (d *Dao) Capture(c context.Context, url string) (loc string, size int, err error) {\n\tif err = checkURL(url); err != nil {\n\t\treturn\n\t}\n\tbs, ct, err := d.download(c, url)\n\tif err != nil {\n\t\treturn\n\t}\n\tsize = len(bs)\n\tif size == 0 {\n\t\tlog.Error(\"capture image size(%d)|url(%s)\", size, url...
[ "0.5790747", "0.56708217", "0.5627612", "0.5470807", "0.54444057", "0.52890503", "0.52813643", "0.5211332", "0.51526403", "0.51466984", "0.5146554", "0.51073426", "0.50793624", "0.5038151", "0.5023785", "0.49964434", "0.49963558", "0.49876392", "0.49376187", "0.49367034", "0....
0.7884488
0
Validate validates that the message is valid.
func (m *Message) Validate() bool { return len(m.Key) > 0 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (msg *Message) Validate() error {\n\tswitch {\n\tcase msg == nil:\n\t\treturn ErrInvalidMessage\n\tcase msg.Token == \"\" && len(msg.RegistrationIDs) == 0:\n\t\treturn ErrInvalidToken\n\tcase len(msg.RegistrationIDs) > 1000:\n\t\treturn ErrToManyRegIDs\n\tcase msg.TimeToLive > 2419200:\n\t\treturn ErrInvalidT...
[ "0.7358442", "0.71898216", "0.71188724", "0.70728076", "0.7068548", "0.6982173", "0.6902308", "0.679386", "0.6727855", "0.66492987", "0.66470295", "0.660603", "0.65974987", "0.6574964", "0.64521635", "0.64391905", "0.64344645", "0.6430751", "0.64243865", "0.64128774", "0.6404...
0.6104094
34
write writes data to the connection & then closes.
func (c *context) write(data []byte) error { defer c.close() _, err := c.conn.Write(data) return err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *RESPConn) write(raw []byte) error {\n\tif c.conn == nil {\n\t\treturn ErrConnClosed\n\t}\n\n\tc.conn.SetWriteDeadline(time.Now().Add(c.timeout))\n\t_, err := c.conn.Write(raw)\n\terr = wrapErr(err)\n\tif err == ErrConnClosed {\n\t\tc.close()\n\t}\n\n\treturn err\n}", "func ConnCloseWrite(c *tls.Conn,) e...
[ "0.76194173", "0.7471342", "0.73997265", "0.72639143", "0.72639143", "0.7225192", "0.71538943", "0.71193266", "0.7019101", "0.69907564", "0.6952195", "0.6934218", "0.67729527", "0.67097056", "0.6698059", "0.66804695", "0.6639902", "0.66116256", "0.6572542", "0.65663767", "0.6...
0.76070374
1
close closes the connection.
func (c *context) close() error { if c.Protocol != protocolUDP { return c.conn.Close() } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (c *Conn) Close() error { return nil }", "func (self *Client) close() {\n\t// TODO: Cleanly close connection to remote\n}", "func (c *minecraftConn) close() error {\n\treturn c.closeKnown(true)\n}", "func (c *client) Close() error { return c.c.Close() }", "func (this *Connection) close() {\n\tif kConn...
[ "0.7299285", "0.7268717", "0.720415", "0.691512", "0.68707407", "0.6851059", "0.6849651", "0.68028086", "0.6764501", "0.6764501", "0.67074233", "0.66832507", "0.6660245", "0.6645073", "0.6637454", "0.66290194", "0.66056883", "0.65101445", "0.64646", "0.64549863", "0.6434904",...
0.6431226
21
Write writes a response to the connection.
func (c *context) Write(res Response) error { data, err := json.Marshal(res) if err != nil { return err } return c.write(data) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Response) Write(w io.Writer) error", "func (r *response) Write(b []byte) (int, error) {\n\tr.wrote = true\n\treturn r.rw.Write(b)\n}", "func (cr ConnectResponse) Write(connWriter *bufio.Writer) error {\n\n\terr := connWriter.WriteByte(cr.Ver)\n\tif err != nil {\n\t\treturn err\n\t}\n\terr = connWriter...
[ "0.79967237", "0.7723631", "0.76393795", "0.7597352", "0.75598305", "0.7522643", "0.74341476", "0.74341476", "0.72941643", "0.7269729", "0.7255387", "0.7188882", "0.71846604", "0.7128272", "0.7125962", "0.7093482", "0.70601535", "0.7023675", "0.7008508", "0.6976754", "0.69158...
0.0
-1
NewDefaultConfig initialises default config.
func NewDefaultConfig() Config { return Config{ Server: serverConfig{ UDP: defaultUDPPort, TCP: defaultTCPPort, HTTP: defaultHTTPPort, }, Store: storeConfig{TTL: defaultDuration}, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDefault() *Config {\n\tvv := defaultConfig\n\treturn &vv\n}", "func NewDefault() *Config {\n\tvv := defaultConfig\n\treturn &vv\n}", "func NewDefaultConfig() *Config {\n\treturn &Config{\n\t\tDefaultNamespace: \"default\",\n\t\tFileName: \"stdin\",\n\t\tTargetKubernetesVersion: \"...
[ "0.82165116", "0.82165116", "0.8035891", "0.8004708", "0.7986573", "0.7867194", "0.7859926", "0.77937293", "0.77280927", "0.7680712", "0.7674229", "0.76511985", "0.76475525", "0.7631691", "0.7625517", "0.76140577", "0.76140577", "0.76090723", "0.7561858", "0.7539901", "0.7524...
0.743386
22
this is the initial request we direct the user's browser to. It is sent to the oidc auth endpoint and starts the whole flow.
func GenerateAuthURL(state, redirectURL string) (authUrl string) { base, _ := url.Parse(discoveryCache.AuthEndpoint) // construct query params params := url.Values{} params.Set("response_type", "code") params.Set("scope", "openid foundation_profile") params.Set("client_id", viper.GetString("oidc.client_id")) params.Set("state", state) params.Set("request", createRequestJWT(state, redirectURL)) base.RawQuery = params.Encode() log.Debugf("auth URL was constructed with state: %s", state) return base.String() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Request(wellKnownConfig oidc.WellKnownConfiguration, client OidcClient) error {\n\t// from original code\n\tcodeVerifier := \"\"\n\tcodeChallenge := \"\"\n\n\tstate, stateErr := oidc.GenerateRandomStringURLSafe(24)\n\tif stateErr != nil {\n\t\treturn fmt.Errorf(\"failed to generate random state. Check that yo...
[ "0.6855226", "0.62462103", "0.6234224", "0.6185395", "0.6133289", "0.60019743", "0.5928162", "0.58865625", "0.5875764", "0.58580756", "0.58038515", "0.57983834", "0.57867306", "0.5758774", "0.5740568", "0.5711506", "0.57114923", "0.57037616", "0.5664262", "0.5615334", "0.5576...
0.0
-1
Creates a new empty Tuple of length n
func NewTuple(n int) *Tuple { t := &Tuple{} t.data = make([]interface{}, n) return t }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func New(args ...float64) Tuple {\n\treturn args\n}", "func PyTuple_New(len int) *PyObject {\n\treturn c2go(C.__PyTuple_New(C.Py_ssize_t(len)))\n}", "func CloneValTuple(n ValTuple) ValTuple {\n\tres := make(ValTuple, 0, len(n))\n\tfor _, x := range n {\n\t\tres = append(res, CloneExpr(x))\n\t}\n\treturn res\n}...
[ "0.6322758", "0.6155864", "0.5810423", "0.5676568", "0.5622864", "0.5439409", "0.54283744", "0.5407682", "0.53979015", "0.53659743", "0.53174645", "0.53048897", "0.5283917", "0.5263617", "0.5229603", "0.51696014", "0.5165112", "0.5083791", "0.5040847", "0.5009695", "0.500642"...
0.7744698
0
Creates a new Tuple from an existing slice
func NewTupleFromSlice(slice []interface{}) *Tuple { t := &Tuple{} t.data = slice return t }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Tuple) Slice(start int, end int) *Tuple {\n\tc := this.Copy()\n\tmax := this.Len()\n\tstart = min(c.Offset(start), max)\n\tend = min(c.Offset(end), max)\n\tc.data = c.data[start:end]\n\treturn c\n}", "func CloneTuple(t Tuple) Tuple {\n\tnewTuple := make(Tuple, len(t))\n\tfor i := range t {\n\t\tv := ...
[ "0.67775756", "0.59362", "0.5725369", "0.5587828", "0.545664", "0.5448951", "0.5422909", "0.5401333", "0.5379334", "0.52723455", "0.525213", "0.5218558", "0.5152185", "0.51271045", "0.5120096", "0.51112926", "0.5099456", "0.5089693", "0.5085051", "0.5079558", "0.5077202", "...
0.762169
0
Creates a new tuple from a literal sequence of items
func NewTupleFromItems(items ...interface{}) *Tuple { t := NewTuple(len(items)) for i, item := range items { t.Set(i, item) } return t }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func SequenceTuple(v Object) (Tuple, error) {\n\tswitch x := v.(type) {\n\tcase Tuple:\n\t\treturn x, nil\n\tcase *List:\n\t\treturn Tuple(x.Items).Copy(), nil\n\tdefault:\n\t\tt := Tuple{}\n\t\terr := Iterate(v, func(item Object) bool {\n\t\t\tt = append(t, item)\n\t\t\treturn false\n\t\t})\n\t\tif err != nil {\n...
[ "0.6122976", "0.587197", "0.5459759", "0.5458699", "0.54445183", "0.52178156", "0.5008375", "0.49721578", "0.49097043", "0.4898114", "0.48744923", "0.4856354", "0.48446503", "0.4836814", "0.4760752", "0.4740713", "0.4699276", "0.46946263", "0.46731538", "0.46618026", "0.46540...
0.7194172
0
Returns a new tuple with a copy of this tuple's data
func (this *Tuple) Copy() *Tuple { t := NewTuple(this.Len()) copy(t.data, this.data) return t }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CloneTuple(t Tuple) Tuple {\n\tnewTuple := make(Tuple, len(t))\n\tfor i := range t {\n\t\tv := reflect.New(reflect.TypeOf(t[i]).Elem())\n\t\tv.Elem().Set(reflect.ValueOf(t[i]).Elem())\n\t\tnewTuple[i] = v.Interface()\n\t}\n\treturn newTuple\n}", "func (expr *TupleLiteralExpr) Clone() *TupleLiteralExpr {\n\t...
[ "0.67432994", "0.60998666", "0.58188397", "0.56445384", "0.5599843", "0.5591076", "0.5422837", "0.5415148", "0.5377441", "0.5333629", "0.53312135", "0.5314242", "0.5120695", "0.51174414", "0.5106553", "0.50935715", "0.5092923", "0.5070351", "0.5063902", "0.5044667", "0.503643...
0.7735376
0
Returns the number of elements in the Tuple
func (this *Tuple) Len() int { return len(this.data) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Tuple) Count(item interface{}, start int) int {\n\tctr := 0\n\tfor i := start; i < this.Len(); i++ {\n\t\tif TupleElemEq(this.Get(i), item) {\n\t\t\tctr += 1\n\t\t}\n\t}\n\treturn ctr\n}", "func (td TupleDesc) Count() int {\n\treturn len(td.Types)\n}", "func NumColumns(t sql.Type) int {\n\tv, ok :=...
[ "0.69410515", "0.6893016", "0.6410716", "0.6153475", "0.61361754", "0.610362", "0.6076785", "0.60695654", "0.6045291", "0.6018257", "0.59564084", "0.5934482", "0.58451253", "0.58451253", "0.58451253", "0.58381146", "0.5813469", "0.5806193", "0.5801226", "0.5790625", "0.578660...
0.7210012
0
Returns the internal slice
func (this *Tuple) Data() []interface{} { return this.data }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getSlice(p position) []byte {\n\ts, i := getChunkLocation(p.chunk)\n\tbufStart := int(i)*ChunkSize + p.chunkPos\n\tbufLen := ChunkSize - p.chunkPos\n\treturn slabs[s].memory[bufStart : bufStart+bufLen]\n}", "func (iobuf *buf) slice(free, base, bound uint) *Slice {\n\tatomic.AddInt32(&iobuf.refcount, 1)\n\tr...
[ "0.7117276", "0.70721287", "0.69470376", "0.67563283", "0.6729937", "0.66651917", "0.664598", "0.661597", "0.6594772", "0.65443593", "0.6540125", "0.6516164", "0.64883", "0.6446062", "0.6403788", "0.6391032", "0.63553524", "0.6261668", "0.6251471", "0.6234408", "0.6234408", ...
0.0
-1
Returns a new tuple with copy of n leftmost items
func (this *Tuple) Left(n int) *Tuple { return this.Slice(0, n) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Tuple) Right(n int) *Tuple {\n\tlength := this.Len()\n\tn = max(0, length-n)\n\treturn this.Slice(n, length)\n}", "func shift(n pair, s []pair) (pair, []pair) {\n\tif len(s) == 0 {\n\t\treturn pair{}, append(s, n)\n\t}\n\tif len(s) == cap(s) {\n\t\treturn s[0], append(s[1:], n)\n\t}\n\treturn s[0], a...
[ "0.5799978", "0.56568867", "0.55627984", "0.55599815", "0.54982084", "0.53724915", "0.52624273", "0.51948875", "0.5152906", "0.51211774", "0.5107011", "0.50483096", "0.5029621", "0.50194687", "0.49727842", "0.49342182", "0.49304894", "0.49280798", "0.4927612", "0.49073404", "...
0.702268
0
Returns a new tuple with copy of n rightmost items
func (this *Tuple) Right(n int) *Tuple { length := this.Len() n = max(0, length-n) return this.Slice(n, length) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Tuple) Left(n int) *Tuple {\n\treturn this.Slice(0, n)\n}", "func shift(n pair, s []pair) (pair, []pair) {\n\tif len(s) == 0 {\n\t\treturn pair{}, append(s, n)\n\t}\n\tif len(s) == cap(s) {\n\t\treturn s[0], append(s[1:], n)\n\t}\n\treturn s[0], append(s, n)\n}", "func DropRight[T any](collection [...
[ "0.58376974", "0.5726538", "0.5519268", "0.5385514", "0.5381859", "0.5310312", "0.529799", "0.52790415", "0.5270423", "0.52695614", "0.526774", "0.5189787", "0.5161007", "0.51163256", "0.51103437", "0.5089906", "0.50748026", "0.5026603", "0.5006796", "0.49989578", "0.4968389"...
0.6711538
0
Returns a new tuple with slice of this tuple's data
func (this *Tuple) Slice(start int, end int) *Tuple { c := this.Copy() max := this.Len() start = min(c.Offset(start), max) end = min(c.Offset(end), max) c.data = c.data[start:end] return c }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (this *Tuple) Copy() *Tuple {\n\tt := NewTuple(this.Len())\n\tcopy(t.data, this.data)\n\treturn t\n}", "func NewTupleFromSlice(slice []interface{}) *Tuple {\n\tt := &Tuple{}\n\tt.data = slice\n\treturn t\n}", "func (t *Tuple) Sub(o *Tuple) *Tuple {\n\treturn &Tuple{\n\t\tt.x - o.x,\n\t\tt.y - o.y,\n\t\tt....
[ "0.64027596", "0.6047759", "0.5692293", "0.5661918", "0.54960763", "0.5457293", "0.54339534", "0.5367511", "0.5316403", "0.5278541", "0.51971835", "0.51925355", "0.5191372", "0.5167452", "0.5150317", "0.5085428", "0.5074085", "0.5072393", "0.5060345", "0.5042252", "0.5022979"...
0.74307245
0
Convert n to an index into the internal slice. Negative numbers are supported, e.g. 1 points to the last item
func (this *Tuple) Offset(n int) int { // allow negative indexing as in Python if n < 0 { n = this.Len() + n } return n }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n Nodes) Index(i int) *Node", "func IndexN(b, sep []byte, n int) (index int) {\n\tindex, idx, sepLen := 0, -1, len(sep)\n\tfor i := 0; i < n; i++ {\n\t\tif idx = bytes.Index(b, sep); idx == -1 {\n\t\t\tbreak\n\t\t}\n\t\tb = b[idx+sepLen:]\n\t\tindex += idx\n\t}\n\n\tif idx == -1 {\n\t\tindex = -1\n\t} else...
[ "0.6139645", "0.60067254", "0.5855295", "0.58331335", "0.5774126", "0.5684", "0.56789446", "0.56658876", "0.5651992", "0.5557862", "0.5557862", "0.54764515", "0.54653597", "0.54514575", "0.5435891", "0.54302675", "0.54021513", "0.53586125", "0.53472817", "0.533107", "0.532034...
0.496398
54
Set the item at index n
func (this *Tuple) Set(n int, item interface{}) { this.data[this.Offset(n)] = item }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (n Nodes) SetIndex(i int, node *Node)", "func (aa *Array) Set(idx int, node interface{}) error {\n\t// do not lock if not needed\n\tif idx < 0 || idx >= aa.length {\n\t\treturn fmt.Errorf(\"index %d is larger than array size (%d)\", idx, aa.length)\n\t}\n\n\taa.mutex.Lock()\n\taa.items[idx] = node\n\taa.mut...
[ "0.7097894", "0.6712408", "0.6652571", "0.66395664", "0.63676316", "0.61507577", "0.61393917", "0.6106026", "0.60874915", "0.603987", "0.602419", "0.60147", "0.5999586", "0.58260477", "0.58074677", "0.57984996", "0.5764004", "0.57576597", "0.57326776", "0.57191527", "0.571641...
0.71877056
0
Get the item at index n
func (this *Tuple) Get(n int) interface{} { item := this.data[this.Offset(n)] return item }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (ps *PrimeStore) GetByIndex(nth uint64) (n uint64) {\n\tdefer Tracer(NewTrace(\"GetByIndex\"))\n\n\tn = 0\n\tif nth < ps.base || nth >= (ps.base+ps.count) {\n\t\tlog.Print(\"out of range.\", nth, \" \", ps)\n\t\treturn\n\t}\n\n\tn = ps.index[nth-ps.base]\n\treturn\n}", "func (x IntSlice) Get(i int) interfac...
[ "0.69591784", "0.68500954", "0.6801328", "0.67986214", "0.6686829", "0.6668928", "0.6519483", "0.64061666", "0.6406025", "0.63965154", "0.6371232", "0.6356444", "0.63045317", "0.62474483", "0.6244136", "0.6197162", "0.6170432", "0.61660874", "0.61195743", "0.60703903", "0.606...
0.7399889
0