text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func isLetter(s string) bool {
//should be just one
if len(s) > 1 {
return false
}
//should not be a strange character
for _, r := range s {
if (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') {
return false
}
}
return true
} | [
-1.3253217935562134,
-0.3539777994155884,
0.4719010293483734,
-0.16239413619041443,
-0.5937747359275818,
0.7286598086357117,
-0.36839041113853455,
0.8074713349342346,
1.520707368850708,
-0.19940190017223358,
-0.7038785815238953,
0.3624476194381714,
-0.5821179747581482,
0.708128809928894,
... |
func (g *Game) PrettyPrint() string {
return fmt.Sprintf("ID: %v\n%v", g.ID.String(), g.Board.GetCurrentState())
} | [
0.329473078250885,
-0.43241751194000244,
0.6044573187828064,
-0.7295849919319153,
0.44635751843452454,
1.0268487930297852,
-1.0428190231323242,
-0.7104038596153259,
-0.5402330160140991,
0.6333785057067871,
0.5430554151535034,
0.33624812960624695,
-0.2377542406320572,
-0.47155043482780457,
... |
func Evaluate(ctx context.Context, proposals []*pb.MatchObject) ([]string, error) {
// Map of approved and overloaded proposals. Using maps for easier lookup.
approvedProposals := map[string]bool{}
overloadedProposals := map[string]bool{}
// Map of all the players encountered in the proposals. Each entry maps a pl... | [
-0.6685442924499512,
-0.5305160284042358,
1.0242046117782593,
-0.8557504415512085,
0.030201483517885208,
0.012655386701226234,
-0.16025900840759277,
-0.5467014312744141,
-0.43164747953414917,
0.916098952293396,
0.2874607443809509,
-0.030459944158792496,
-0.9882627725601196,
0.0443366430699... |
func chooseProposals(overloaded []string) ([]string, error) {
// As a basic example, we pick the first overloaded proposal for approval.
approved := []string{}
if len(overloaded) > 0 {
approved = append(approved, overloaded[0])
}
return approved, nil
} | [
-0.8320449590682983,
0.04056381806731224,
0.4843652546405792,
-0.24611425399780273,
-0.08931377530097961,
-0.40401962399482727,
-0.700311541557312,
-0.8735624551773071,
0.003267068648710847,
0.5078263282775879,
0.652134120464325,
0.12256675213575363,
-1.0208920240402222,
0.3170936405658722... |
func DPrintf(format string, a ...interface{}) (n int, err error) {
if Debug > 0 {
log.Printf(format, a...)
}
return
} | [
-0.31200921535491943,
0.5421631336212158,
0.6115473508834839,
0.2754957377910614,
0.13464491069316864,
-0.5352667570114136,
-0.162339985370636,
0.0729418694972992,
-0.43004685640335083,
-0.8056594729423523,
0.07604675740003586,
0.5494731664657593,
-0.028605660423636436,
1.0471186637878418,... |
func main() {
// Attempt to initialize the termbox.
// TODO: contain inside ugcli run method.
if err := tb.Init(); err != nil {
os.Exit(1)
}
// Clear the termbox.
if err := tb.Clear(tb.ColorDefault, tb.ColorDefault); err != nil {
panic(err)
}
// Create a new console taking the size of the terminal.
w, h... | [
0.5390568375587463,
0.05214236304163933,
0.9633679986000061,
-0.22739540040493011,
-0.04519997537136078,
-0.1098313108086586,
0.6869918704032898,
-0.12334331125020981,
-0.2230057716369629,
0.30191555619239807,
-0.09366282820701599,
0.3762147128582001,
0.4086920917034149,
-0.238009005784988... |
func (s *SharemeService) ThumbnailURL(c *gae.Context, key string) string {
return s.Stat(c, key).Thumbnail
} | [
-0.7777736186981201,
0.28655683994293213,
0.25550952553749084,
0.5487586259841919,
-0.0000652699891361408,
-0.3497980237007141,
0.3380295932292938,
0.8111110329627991,
0.1206282451748848,
1.2009690999984741,
-0.25107434391975403,
-0.4185153543949127,
0.5307385325431824,
-0.2385956943035125... |
func (s *SharemeService) ImageURL(c *gae.Context, key string) string {
obj := s.Get(c, key)
if bb, ok := obj.(*BlobBinary); ok && strings.HasPrefix(bb.MimeType(), "image") {
if url, _, err := imgurl.UrlifyR(bb, bb.MimeType(), 0, 0); err == nil {
return url
} else {
panic(err)
}
}
return ""
} | [
-0.5953916311264038,
-0.32893481850624084,
0.6432452201843262,
0.45048120617866516,
-0.1380944401025772,
-0.390085369348526,
-0.4811830520629883,
-0.025885839015245438,
0.16852305829524994,
1.819639801979065,
0.37405630946159363,
0.13634714484214783,
-0.46054744720458984,
0.434611022472381... |
func (s *SharemeService) MyShares(c *gae.Context, session *Session) []Share {
ret := make([]Share, 0, len(session.Properties))
for k, name := range session.Properties {
if strings.HasPrefix(k, KeySessionPrefix) {
key := strings.TrimLeft(k, KeySessionPrefix)
share := s.Stat(c, key)
share.Name = name
if ... | [
-0.9525748491287231,
-0.9145756363868713,
0.6057252883911133,
-0.12320428341627121,
0.06500555574893951,
-0.923553466796875,
-0.40370360016822815,
-0.18427661061286926,
0.49532827734947205,
0.4031587839126587,
-0.27071961760520935,
-0.5309773683547974,
-0.12973546981811523,
0.2760839760303... |
func (s *SharemeService) Delete(c *gae.Context, session *Session, key string) (ret Share) {
stat := s.Stat(c, key)
if stat.IsError() {
return stat
}
err := stat.Delete(c)
if err != nil {
return *noShare(err)
}
c.HTTPContext.ReturnStatus = http.StatusOK
session.Delete(fmt.Sprintf("%s%s", KeySessionPrefix, ... | [
0.1546882539987564,
-0.22710436582565308,
0.684089720249176,
0.4361407160758972,
-0.2758682668209076,
-0.14098010957241058,
0.4045533239841461,
0.04943427816033363,
0.4888899028301239,
0.5246987342834473,
0.19654643535614014,
-0.0007002482889220119,
-0.8549579977989197,
-0.3200659453868866... |
func (s *SharemeService) UploadURL(c *gae.Context, cont *Container) string {
url, err := s.storageService.UploadURL(c)
log.Printf("Generated url :'%s'", url.String())
if err != nil {
log.Printf("Could not generate UpladURL %s", err)
}
return url.String()
} | [
-0.16629619896411896,
0.27590513229370117,
0.8005292415618896,
0.5249902606010437,
0.49631035327911377,
0.40955203771591187,
-0.04630028456449509,
0.0849386528134346,
-0.4799627363681793,
0.6135477423667908,
0.26809829473495483,
0.2001173198223114,
0.2624284327030182,
0.09689375013113022,
... |
func (s *SharemeService) Get(c *gae.Context, key string) interface{} { // Return either Share in case of Error or Binary.
st := s.Stat(c, key)
if st.IsError() {
return noShare(fmt.Errorf(st.Error))
}
/* retrieve blob */
rc, err := s.storageService.Get(c, st.StorageKey)
if err != nil {
c.HTTPContext.ReturnSta... | [
-0.2657040059566498,
-0.6996360421180725,
0.7968668937683105,
0.1290881186723709,
0.3019254505634308,
-0.06916302442550659,
0.09630931168794632,
-0.47636622190475464,
-0.35643091797828674,
0.2138921320438385,
-0.11230295896530151,
0.4607004225254059,
-0.44135111570358276,
-0.23038941621780... |
func (s *SharemeService) Add(c *gae.Context, session *Session, key string) (stat Share) {
stat = s.Stat(c, key)
if stat.IsError() {
return
}
session.Set(fmt.Sprintf("%s%s", KeySessionPrefix, key), stat.Name)
return
} | [
-0.5366129279136658,
-0.5700457692146301,
0.44163742661476135,
-0.3291493058204651,
-0.316743403673172,
0.04734544828534126,
-0.03801313415169716,
-0.3104705810546875,
1.0572807788848877,
0.29971829056739807,
-0.049646858125925064,
0.23043537139892578,
-0.244362935423851,
0.147761359810829... |
func (s *SharemeService) Stat(c *gae.Context, key string) Share {
dsk, err := datastore.DecodeKey(key)
if err != nil {
c.HTTPContext.ReturnStatus = http.StatusNotFound
return *noShare(fmt.Errorf("Error decoding key '%s': %s", key, err))
}
stat := &Share{DSK: dsk}
err = datastore.Get(c, dsk, stat)
switch err {... | [
-0.48009923100471497,
0.2515610158443451,
0.6509668827056885,
-0.21582140028476715,
0.11674077063798904,
-0.7699287533760071,
0.530451774597168,
-0.08686970919370651,
0.18133369088172913,
-0.3094924986362457,
0.1730039268732071,
0.10872460901737213,
0.008068949915468693,
0.7296741604804993... |
func (s *SharemeService) HandleUpload(hc *HTTPContext, c *gae.Context, session *Session) []*Share {
ret := make([]*Share, 0)
bis := s.storageService.HandleUpload(hc)
for _, stat := range bis {
dsk, err := datastore.Put(c, datastore.NewIncompleteKey(c, "Share", nil), stat)
if err != nil {
//TODO: delete blob
... | [
-0.9784227609634399,
0.4268054962158203,
0.7403137683868408,
0.38577961921691895,
1.0402923822402954,
-0.5194459557533264,
0.897183895111084,
-0.21071898937225342,
-0.2190473973751068,
0.37950608134269714,
-0.7031273245811462,
-1.2899558544158936,
-0.2532563805580139,
-0.07505582273006439,... |
func HandleCleanup(w http.ResponseWriter, r *http.Request) {
hc := NewHTTPContext(r, w) // HTTPContext
c := gae.NewContext(hc) //GAE Context
stamp := int64(time.Now().UnixNano() / Msec)
q := datastore.NewQuery("Share").Filter("expires >", stamp)
var shares []Share
keys, err := q.GetAll(c, &shares)
if err != ... | [
-0.49619147181510925,
0.3929426670074463,
0.863699197769165,
-0.11950594186782837,
0.22172780334949493,
-0.28215575218200684,
0.01903882808983326,
0.6563955545425415,
-0.06865484267473221,
0.384878545999527,
0.605489194393158,
-0.8730460405349731,
0.2886292040348053,
-0.3125193119049072,
... |
func NewSharemeService(ak ...string) (ret *SharemeService) {
ret = &SharemeService{
storageService: &BlobstoreStorageService{},
}
return
} | [
0.05822400376200676,
-0.131535142660141,
0.3279914855957031,
1.1036145687103271,
0.08614455163478851,
-0.41028308868408203,
-0.24753764271736145,
-0.661608874797821,
0.24464446306228638,
0.4208599030971527,
-0.3952874541282654,
0.21539480984210968,
-0.9348847270011902,
0.6070310473442078,
... |
func RestrictToAdmin(c *gae.Context) bool {
if c == nil {
c.HTTPContext.ReturnStatus = http.StatusInternalServerError
log.Printf("Could not retrieve context.")
return false
}
if u := user.Current(c); u != nil {
return user.IsAdmin(c)
} else {
c.HTTPContext.ReturnStatus = http.StatusForbidden
return fal... | [
-0.3962021768093109,
0.5319762825965881,
0.4362717568874359,
-0.3068467080593109,
-0.18495309352874756,
0.4540935754776001,
0.20174263417720795,
-1.5565059185028076,
0.6809741258621216,
-0.03818764537572861,
0.5496200919151306,
0.5743687748908997,
-0.5810868740081787,
0.26630449295043945,
... |
func init() {
log.Printf("INIT()")
// This key must be the same across all GAE instances in order to decrypt session data
c := NewContainer(Properties{P_APPLICATIONKEY: "APPKEY_CHANGEME_________________"})
c.Redirect("/", "/p/")
sms := NewSharemeService()
c.ExposeInterface(sms, InterfaceName)
c.ExposeInterface... | [
0.1424427479505539,
0.19910314679145813,
0.758729875087738,
0.027445504441857338,
0.346416711807251,
0.5612744688987732,
1.0726118087768555,
0.1612691432237625,
0.4273032546043396,
-0.08231516927480698,
-0.031905218958854675,
-0.1290809065103531,
0.17204368114471436,
1.5138061046600342,
... |
func (inp itemFrom) itemPipeSeen() (out itemFrom) {
cha := make(chan item)
go inp.pipeitemSeenAttr(cha, nil)
return cha
} | [
-0.6083623766899109,
-0.9664573669433594,
0.47374868392944336,
-1.0933712720870972,
-0.40526774525642395,
0.2697809040546417,
0.10743071138858795,
0.10574394464492798,
-0.43284931778907776,
-0.24225521087646484,
-0.44579729437828064,
1.1035258769989014,
0.6836733222007751,
-0.8690713047981... |
func (inp itemFrom) itemPipeSeenAttr(attr func(a item) interface{}) (out itemFrom) {
cha := make(chan item)
go inp.pipeitemSeenAttr(cha, attr)
return cha
} | [
-0.8737298250198364,
-0.9003945589065552,
0.4414128065109253,
-1.4742666482925415,
-0.880817174911499,
-0.0714111253619194,
0.10551252216100693,
-0.03044665791094303,
-0.513871967792511,
0.1613646000623703,
0.2390577495098114,
0.8993424773216248,
0.9553271532058716,
-0.605250358581543,
0... |
func (inp itemFrom) itemForkSeen() (new, old itemFrom) {
cha1 := make(chan item)
cha2 := make(chan item)
go inp.forkitemSeenAttr(cha1, cha2, nil)
return cha1, cha2
} | [
-0.2398519665002823,
-0.8595445156097412,
0.4854290783405304,
0.29288339614868164,
-0.1953439861536026,
-0.9460662603378296,
0.002657876582816243,
-1.162576675415039,
-0.6655089855194092,
-0.3215489983558655,
-0.9072278141975403,
1.1858235597610474,
0.5603702068328857,
0.21822163462638855,... |
func (inp itemFrom) itemForkSeenAttr(attr func(a item) interface{}) (new, old itemFrom) {
cha1 := make(chan item)
cha2 := make(chan item)
go inp.forkitemSeenAttr(cha1, cha2, attr)
return cha1, cha2
} | [
-0.4589225649833679,
-0.9254529476165771,
0.4929596781730652,
0.004829441662877798,
-0.7886225581169128,
-1.34181547164917,
0.6074045300483704,
-0.9825781583786011,
-0.3715345561504364,
-0.07392197102308273,
-0.22901619970798492,
0.9875084161758423,
0.5872442722320557,
0.4325839579105377,
... |
func (inp itemFrom) itemTubeSeen() (tube func(inp itemFrom) (out itemFrom)) {
return func(inp itemFrom) (out itemFrom) {
return inp.itemPipeSeen()
}
} | [
-0.6580010652542114,
-0.869145929813385,
0.6444147825241089,
-0.24921609461307526,
-0.14529632031917572,
-0.46593397855758667,
0.26832589507102966,
0.15484091639518738,
-0.41845038533210754,
0.11014770716428757,
-0.7696748971939087,
0.3781183362007141,
0.6279939413070679,
-1.46745789051055... |
func (inp itemFrom) itemTubeSeenAttr(attr func(a item) interface{}) (tube func(inp itemFrom) (out itemFrom)) {
return func(inp itemFrom) (out itemFrom) {
return inp.itemPipeSeenAttr(attr)
}
} | [
-0.788101851940155,
-1.0628149509429932,
0.5456847548484802,
-0.6620769500732422,
-0.4122005105018616,
-0.9369224905967712,
0.6220134496688843,
0.36916354298591614,
-0.01581100933253765,
0.6599021553993225,
0.11703764647245407,
0.10901222378015518,
0.8807299733161926,
-0.7638927698135376,
... |
func (a Int) Less(b Item) bool {
return a < b.(Int)
} | [
-0.32877451181411743,
-0.22377613186836243,
0.2569558918476105,
-0.4139893651008606,
-0.17078229784965515,
0.37220433354377747,
-0.36843550205230713,
-0.8186357021331787,
0.16350498795509338,
-0.49574628472328186,
-1.2596473693847656,
-0.4685647487640381,
-0.44036945700645447,
0.1798759102... |
func (a Afero) WriteReader(path string, r io.Reader) (err error) {
return WriteReader(a.Fs, path, r)
} | [
-0.5049404501914978,
-1.3143978118896484,
0.41597387194633484,
-0.0005522579303942621,
-0.20553146302700043,
-0.004682458937168121,
0.5304946303367615,
-0.2805686891078949,
0.13391341269016266,
-0.4321424663066864,
1.2342966794967651,
-0.9044174551963806,
0.7101984024047852,
0.125445649027... |
func (a Afero) SafeWriteReader(path string, r io.Reader) (err error) {
return SafeWriteReader(a.Fs, path, r)
} | [
-0.3266412913799286,
-1.1056052446365356,
0.35400232672691345,
0.13214491307735443,
-0.6467334032058716,
-0.08120445162057877,
0.4796478748321533,
-0.32472383975982666,
0.22417478263378143,
-0.17690330743789673,
1.0084277391433716,
-0.8764688372612,
0.19103120267391205,
-0.2282792031764984... |
func GetTempDir(fs Fs, subPath string) string {
addSlash := func(p string) string {
if FilePathSeparator != p[len(p)-1:] {
p = p + FilePathSeparator
}
return p
}
dir := addSlash(os.TempDir())
if subPath != "" {
// preserve windows backslash :-(
if FilePathSeparator == "\\" {
subPath = strings.Repla... | [
-0.05200120806694031,
0.10876147449016571,
1.0836683511734009,
0.020323961973190308,
-0.08656278252601624,
0.011248388327658176,
0.3638409972190857,
-0.004998600576072931,
0.058003019541502,
-0.7879587411880493,
-0.07885796576738358,
-0.4910688102245331,
0.06799814105033875,
-0.14947292208... |
func UnicodeSanitize(s string) string {
source := []rune(s)
target := make([]rune, 0, len(source))
for _, r := range source {
if unicode.IsLetter(r) ||
unicode.IsDigit(r) ||
unicode.IsMark(r) ||
r == '.' ||
r == '/' ||
r == '\\' ||
r == '_' ||
r == '-' ||
r == '%' ||
r == ' ' ||
r ==... | [
-0.8683301210403442,
-0.16663412749767303,
0.5726760625839233,
-0.26780572533607483,
-0.11389701068401337,
-0.5015703439712524,
-0.0138891926035285,
-0.2571849822998047,
0.18086838722229004,
-0.27262184023857117,
-0.438170850276947,
0.11127530783414841,
-0.6759616732597351,
-0.558386445045... |
func NeuterAccents(s string) string {
t := transform.Chain(norm.NFD, runes.Remove(runes.In(unicode.Mn)), norm.NFC)
result, _, _ := transform.String(t, string(s))
return result
} | [
-0.26187196373939514,
-0.8104571104049683,
0.2730925679206848,
-1.3956871032714844,
-1.3968836069107056,
-0.4095800518989563,
0.5962862968444824,
-0.7275351881980896,
0.2352607101202011,
-0.12923114001750946,
0.5284132957458496,
0.16947543621063232,
-0.18704411387443542,
-0.471127271652221... |
func FileContainsBytes(fs Fs, filename string, subslice []byte) (bool, error) {
f, err := fs.Open(filename)
if err != nil {
return false, err
}
defer f.Close()
return readerContainsAny(f, subslice), nil
} | [
0.4712879955768585,
-0.033748701214790344,
0.7639564275741577,
0.22942675650119781,
-0.09943075478076935,
0.06993331760168076,
-0.23204244673252106,
-0.19597329199314117,
-1.040771245956421,
-0.259096622467041,
-0.2964438498020172,
-0.42863884568214417,
0.5675520896911621,
0.42879042029380... |
func FileContainsAnyBytes(fs Fs, filename string, subslices [][]byte) (bool, error) {
f, err := fs.Open(filename)
if err != nil {
return false, err
}
defer f.Close()
return readerContainsAny(f, subslices...), nil
} | [
0.2803284525871277,
0.03637375310063362,
0.7035952210426331,
0.2921289801597595,
-0.5991196036338806,
0.15772190690040588,
-0.10796072334051132,
0.11140978336334229,
-0.738017201423645,
-0.1807563751935959,
0.01744527742266655,
-0.4696154296398163,
0.5388919711112976,
0.923323929309845,
... |
func readerContainsAny(r io.Reader, subslices ...[]byte) bool {
if r == nil || len(subslices) == 0 {
return false
}
largestSlice := 0
for _, sl := range subslices {
if len(sl) > largestSlice {
largestSlice = len(sl)
}
}
if largestSlice == 0 {
return false
}
bufflen := largestSlice * 4
halflen :=... | [
0.1682281792163849,
-0.022400395944714546,
0.9819338321685791,
-0.017504660412669182,
-0.9184311032295227,
-0.1582968384027481,
0.6472864151000977,
-0.6348382234573364,
0.34215685725212097,
-0.15438663959503174,
0.018068384379148483,
-0.38959836959838867,
-0.4124755263328552,
0.72063690423... |
func DirExists(fs Fs, path string) (bool, error) {
fi, err := fs.Stat(path)
if err == nil && fi.IsDir() {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
} | [
-1.143222451210022,
-0.5790113210678101,
0.8535633087158203,
0.34175920486450195,
0.2732086479663849,
0.6416675448417664,
-0.6491215229034424,
-0.0736578181385994,
0.3816988468170166,
-0.6821579933166504,
-0.16531501710414886,
-0.09419538080692291,
0.5353862643241882,
-0.4812878668308258,
... |
func IsDir(fs Fs, path string) (bool, error) {
fi, err := fs.Stat(path)
if err != nil {
return false, err
}
return fi.IsDir(), nil
} | [
-0.23891781270503998,
-0.5362766981124878,
0.5199854969978333,
1.0535292625427246,
-0.748099684715271,
0.311865895986557,
-0.33194786310195923,
0.17743998765945435,
0.4390605390071869,
-1.0222960710525513,
0.23024454712867737,
0.028738198801875114,
0.1754833161830902,
-0.013310938142240047... |
func IsEmpty(fs Fs, path string) (bool, error) {
if b, _ := Exists(fs, path); !b {
return false, fmt.Errorf("%q path does not exist", path)
}
fi, err := fs.Stat(path)
if err != nil {
return false, err
}
if fi.IsDir() {
f, err := fs.Open(path)
if err != nil {
return false, err
}
defer f.Close()
li... | [
-1.0987924337387085,
-0.18891312181949615,
1.0591784715652466,
0.010672005824744701,
0.3034321069717407,
-0.015210048295557499,
-0.042958274483680725,
0.25784724950790405,
0.5225972533226013,
0.1274336278438568,
-0.1877475082874298,
0.012396411038935184,
0.15724895894527435,
0.013014927506... |
func Exists(fs Fs, path string) (bool, error) {
_, err := fs.Stat(path)
if err == nil {
return true, nil
}
if os.IsNotExist(err) {
return false, nil
}
return false, err
} | [
-0.8405994176864624,
-0.805673360824585,
0.7568970918655396,
-0.1901455521583557,
0.36622190475463867,
0.25906863808631897,
-0.8604775667190552,
0.047383833676576614,
-0.10676749050617218,
-0.7469733953475952,
-0.17467130720615387,
-0.4935982823371887,
0.44063475728034973,
-0.2709473967552... |
func NewProvider(api *API, vin string, cache time.Duration) *Provider {
impl := &Provider{
chargerG: provider.Cached(func() (ChargerResponse, error) {
return api.Charger(vin)
}, cache),
statusG: provider.Cached(func() (StatusResponse, error) {
return api.Status(vin)
}, cache),
climateG: provider.Cached... | [
-1.0831458568572998,
-0.5721097588539124,
0.21516413986682892,
0.4008345603942871,
-0.7963047027587891,
-0.3902476727962494,
-0.2544632852077484,
-0.49835944175720215,
0.9945814609527588,
0.607893705368042,
0.30294281244277954,
0.036622874438762665,
-0.3289009928703308,
0.382565975189209,
... |
func (v *Provider) Soc() (float64, error) {
res, err := v.chargerG()
if err == nil {
return float64(res.Charger.Status.BatteryStatusData.StateOfCharge.Content), nil
}
return 0, err
} | [
0.28015753626823425,
0.698726236820221,
0.5710937976837158,
0.12976562976837158,
-0.3528503477573395,
-0.6631338596343994,
-0.5002373456954956,
-0.9322765469551086,
-0.13204877078533173,
0.3831353783607483,
-0.06934718042612076,
-0.18429414927959442,
0.8189061880111694,
-0.3064074516296386... |
func (v *Provider) Status() (api.ChargeStatus, error) {
status := api.StatusA // disconnected
res, err := v.chargerG()
if err == nil {
if res.Charger.Status.PlugStatusData.PlugState.Content == "connected" {
status = api.StatusB
}
if res.Charger.Status.ChargingStatusData.ChargingState.Content == "charging" ... | [
-0.2498251497745514,
-1.297336220741272,
0.4576106667518616,
0.22071217000484467,
0.3362746834754944,
-0.530743420124054,
-1.0620449781417847,
0.7293176651000977,
0.6404528617858887,
0.5475588440895081,
-0.5798556208610535,
0.3409633934497833,
-0.10002721846103668,
0.8780794739723206,
0.... |
func (v *Provider) FinishTime() (time.Time, error) {
res, err := v.chargerG()
if err == nil {
rct := res.Charger.Status.BatteryStatusData.RemainingChargingTime
// estimate not available
if rct.Content == 65535 {
return time.Time{}, api.ErrNotAvailable
}
return time.Now().Add(time.Duration(rct.Content) ... | [
-0.27642324566841125,
0.0898963212966919,
0.7066479921340942,
0.15414471924304962,
0.004528893157839775,
0.02367641218006611,
-1.1089993715286255,
-0.08615089952945709,
-0.8096134066581726,
1.615718126296997,
0.04695297032594681,
-0.6765738725662231,
-1.1876840591430664,
1.066213846206665,... |
func (v *Provider) Range() (rng int64, err error) {
res, err := v.chargerG()
if err == nil {
crsd := res.Charger.Status.CruisingRangeStatusData
rng = int64(crsd.PrimaryEngineRange.Content)
if crsd.EngineTypeFirstEngine.Content != "typeIsElectric" {
rng = int64(crsd.SecondaryEngineRange.Content)
}
}
ret... | [
-1.1829074621200562,
0.33755266666412354,
0.420240193605423,
0.4406580924987793,
0.520804226398468,
-0.4141075015068054,
-0.05764899030327797,
0.38072678446769714,
-0.4286666512489319,
0.2678201198577881,
0.1424250453710556,
0.6626299619674683,
-0.3374890685081482,
0.3182450830936432,
0.... |
func (v *Provider) Odometer() (float64, error) {
res, err := v.statusG()
if err == nil {
err = api.ErrNotAvailable
if sd := res.ServiceByID(ServiceOdometer); sd != nil {
if fd := sd.FieldByID(ServiceOdometer); fd != nil {
if val, err := strconv.ParseFloat(fd.Value, 64); err == nil {
return val, nil
... | [
-1.0940157175064087,
-0.01788846030831337,
0.5657846331596375,
-0.2083493322134018,
-0.479438453912735,
0.045617081224918365,
-0.15355488657951355,
-0.28065112233161926,
-0.07032740861177444,
0.3688810467720032,
0.27988070249557495,
0.3680363893508911,
-0.9424290060997009,
0.75736284255981... |
func (v *Provider) Climater() (bool, error) {
res, err := v.climateG()
if err == nil {
state := strings.ToLower(res.Climater.Status.ClimatisationStatusData.ClimatisationState.Content)
active := state != "off" && state != "invalid" && state != "error"
return active, nil
}
return false, err
} | [
-0.7482635974884033,
-0.489050030708313,
0.5402369499206543,
0.23449000716209412,
-1.2112963199615479,
0.5932354927062988,
-0.5742912888526917,
0.8072643280029297,
-0.45333021879196167,
1.0261788368225098,
0.4265376329421997,
-0.36282142996788025,
-0.7367366552352905,
0.31291958689689636,
... |
func (v *Provider) Position() (float64, float64, error) {
res, err := v.positionG()
if err == nil {
coord := res.FindCarResponse.Position.CarCoordinate
return float64(coord.Latitude) / 1e6, float64(coord.Longitude) / 1e6, nil
}
return 0, 0, err
} | [
-1.0471819639205933,
-0.5921646952629089,
0.5207058191299438,
-0.4419160783290863,
1.034048080444336,
-0.6634202003479004,
-0.23056356608867645,
-0.02316531166434288,
-0.3429788053035736,
0.710719108581543,
-0.2770979404449463,
-0.5907478332519531,
-0.7727314829826355,
0.5584213733673096,
... |
func (v *Provider) StartCharge() error {
return v.action(ActionCharge, ActionChargeStart)
} | [
0.12943042814731598,
-0.26420268416404724,
0.327481746673584,
1.386487603187561,
0.5158153176307678,
-0.5052886605262756,
-0.12776075303554535,
0.5382978320121765,
0.3622242212295532,
0.7746083736419678,
0.17198652029037476,
0.8760843276977539,
-0.5428969860076904,
0.9215620756149292,
-0... |
func (v *Provider) StopCharge() error {
return v.action(ActionCharge, ActionChargeStop)
} | [
-1.230544090270996,
-0.3488343060016632,
0.14036065340042114,
0.3385726809501648,
0.2462838739156723,
-0.22255907952785492,
0.06322459876537323,
0.2596607804298401,
-0.2459515631198883,
1.0005862712860107,
0.24341702461242676,
-0.04878494516015053,
-0.7787823677062988,
0.12706038355827332,... |
func (v *Provider) Diagnose() {
rr, err := v.rr()
if err != nil {
return
}
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
sort.Slice(rr.OperationList.ServiceInfo, func(i, j int) bool {
return rr.OperationList.ServiceInfo[i].ServiceId < rr.OperationList.ServiceInfo[j].ServiceId
})
for _, si := range... | [
-0.24414418637752533,
0.15678560733795166,
0.840937614440918,
-0.357998251914978,
0.13621221482753754,
-0.10240650922060013,
0.6147149205207825,
0.03502589091658592,
-0.10346341878175735,
-0.1577741801738739,
0.41382578015327454,
0.23274385929107666,
-0.027458431199193,
0.7986164689064026,... |
func NewForest(forestFile *os.File) *Forest {
f := new(Forest)
f.numLeaves = 0
f.height = 0
if forestFile == nil {
// for in-ram
f.data = new(ramForestData)
} else {
// for on-disk
d := new(diskForestData)
d.f = forestFile
f.data = d
}
f.data.resize(1)
f.positionMap = make(map[MiniHash]uint64)
re... | [
0.6838735938072205,
-0.7079687714576721,
0.31546297669410706,
0.7321051955223083,
-0.4623953700065613,
-0.3856140375137329,
0.6330034732818604,
-0.0935814157128334,
-0.2169431746006012,
-1.019197940826416,
-0.157416433095932,
0.4166593849658966,
-0.4247075021266937,
0.34205055236816406,
... |
func (f *Forest) removev3(dels []uint64) error {
if uint64(len(dels)) > f.numLeaves {
return fmt.Errorf("%d deletions but forest has %d leaves",
len(dels), f.numLeaves)
}
nextNumLeaves := f.numLeaves - uint64(len(dels))
// check that all dels are there
for _, dpos := range dels {
if dpos > f.numLeaves {
... | [
-0.3782397210597992,
-0.526469886302948,
0.770626962184906,
0.16106931865215302,
-0.5529380440711975,
-0.17299267649650574,
-0.12391699850559235,
0.7741449475288391,
0.7756413221359253,
-0.3679373860359192,
0.11453860253095627,
-0.041899919509887695,
-0.21724683046340942,
-0.24858774244785... |
func (f *Forest) reHash(dirt []uint64) error {
if f.height == 0 || len(dirt) == 0 { // nothing to hash
return nil
}
tops, topheights := getTopsReverse(f.numLeaves, f.height)
// fmt.Printf("nl %d f.h %d tops %v\n", f.numLeaves, f.height, tops)
dirty2d := make([][]uint64, f.height)
h := uint8(0)
dirtyRemaining ... | [
-0.08855172246694565,
-0.0715491995215416,
0.9986501932144165,
1.1812090873718262,
0.1273084580898285,
-0.07955645769834518,
0.7562072277069092,
-0.13498792052268982,
-0.3632618486881256,
0.07811662554740906,
0.028380004689097404,
0.4968302845954895,
-0.35860905051231384,
1.457250475883483... |
func (f *Forest) cleanup(overshoot uint64) {
for p := f.numLeaves; p < f.numLeaves+overshoot; p++ {
delete(f.positionMap, f.data.read(p).Mini()) // clear position map
// TODO ^^^^ that probably does nothing
f.data.write(p, empty) // clear forest
}
} | [
-0.12885983288288116,
-0.7365657687187195,
0.4425545334815979,
0.115472711622715,
0.08807086944580078,
-0.21465837955474854,
0.5108035206794739,
-0.14789040386676788,
0.4308514893054962,
-0.8124677538871765,
0.33281153440475464,
-0.29999107122421265,
0.19158467650413513,
0.4588458240032196... |
func (f *Forest) Add(adds []LeafTXO) {
f.addv2(adds)
} | [
-0.7718918323516846,
-0.6745006442070007,
0.3313222825527191,
1.504285454750061,
0.6965190172195435,
0.42131757736206055,
-0.6219355463981628,
0.268886923789978,
-0.4886150360107422,
-0.4496504068374634,
-0.26526540517807007,
0.15830650925636292,
0.3661649227142334,
0.6086207628250122,
-... |
func (f *Forest) addv2(adds []LeafTXO) {
for _, add := range adds {
// fmt.Printf("adding %x pos %d\n", add.Hash[:4], f.numLeaves)
f.positionMap[add.Mini()] = f.numLeaves
tops, _ := getTopsReverse(f.numLeaves, f.height)
pos := f.numLeaves
n := add.Hash
f.data.write(pos, n)
for h := uint8(0); (f.numLeav... | [
-0.45946893095970154,
-0.834750771522522,
0.7996676564216614,
0.5440929532051086,
0.07662086933851242,
0.08483210951089859,
0.12068695574998856,
-0.1432618647813797,
-0.3920024335384369,
-0.3788749873638153,
-0.14939403533935547,
-0.0005759727209806442,
0.6576073169708252,
0.38006919622421... |
func (f *Forest) Modify(adds []LeafTXO, dels []uint64) (*undoBlock, error) {
numdels, numadds := uint64(len(dels)), uint64(len(adds))
delta := numadds - numdels // watch 32/64 bit
// remap to expand the forest if needed
for f.numLeaves+delta > 1<<f.height {
// fmt.Printf("current cap %d need %d\n",
// 1<<f.heig... | [
-0.7069859504699707,
-0.232594296336174,
1.057100772857666,
0.29759272933006287,
-0.09637600183486938,
-0.09099917858839035,
-0.24486953020095825,
0.4770233631134033,
0.4782339632511139,
-0.5074671506881714,
0.49559521675109863,
-0.09622444212436676,
-0.1306743621826172,
0.0662610903382301... |
func (f *Forest) reMap(destHeight uint8) error {
if destHeight == f.height {
return fmt.Errorf("can't remap %d to %d... it's the same",
destHeight, destHeight)
}
if destHeight > f.height+1 || (f.height > 0 && destHeight < f.height-1) {
return fmt.Errorf("changing by more than 1 height not programmed yet")
... | [
-0.5110547542572021,
0.3330596387386322,
1.0260236263275146,
0.4955120086669922,
-0.3407999277114868,
-0.10972938686609268,
0.5467345118522644,
0.18111391365528107,
-0.30624061822891235,
0.5386808514595032,
-0.19042782485485077,
-0.03858752176165581,
0.36604753136634827,
0.0241314470767974... |
func (f *Forest) sanity() error {
if f.numLeaves > 1<<f.height {
return fmt.Errorf("forest has %d leaves but insufficient height %d",
f.numLeaves, f.height)
}
tops, _ := getTopsReverse(f.numLeaves, f.height)
for _, t := range tops {
if f.data.read(t) == empty {
return fmt.Errorf("Forest has %d leaves %d ... | [
-0.6280615925788879,
-0.2117072194814682,
0.8202672600746155,
-0.2637702524662018,
0.5997573733329773,
0.22219495475292206,
-0.24079442024230957,
-0.013853423297405243,
0.2947649657726288,
-1.1604983806610107,
0.8913291692733765,
-0.7425891160964966,
-0.18726572394371033,
0.311513304710388... |
func (f *Forest) PosMapSanity() error {
for i := uint64(0); i < f.numLeaves; i++ {
if f.positionMap[f.data.read(i).Mini()] != i {
return fmt.Errorf("positionMap error: map says %x @%d but @%d",
f.data.read(i).Prefix(), f.positionMap[f.data.read(i).Mini()], i)
}
}
return nil
} | [
-0.3519175052642822,
-1.0264133214950562,
0.5266738533973694,
0.3179154694080353,
0.5947813391685486,
-0.24148757755756378,
-0.5310713648796082,
-0.09971015155315399,
0.6047812700271606,
-0.06064720079302788,
0.3250141441822052,
-0.8118466734886169,
-0.4822932481765747,
-0.0423366911709308... |
func (f *Forest) RestoreForest(miscForestFile *os.File, forestFile *os.File) error {
// This restores the numLeaves
var byteLeaves [8]byte
_, err := miscForestFile.Read(byteLeaves[:])
if err != nil {
return err
}
f.numLeaves = BtU64(byteLeaves[:])
fmt.Println("Forest leaves:", f.numLeaves)
// This restores ... | [
0.6572480201721191,
-0.9272703528404236,
0.7543048858642578,
0.023423759266734123,
0.23284487426280975,
-0.05690965801477432,
0.10988052189350128,
0.5297461748123169,
-0.5015484690666199,
-0.7463126182556152,
-0.16020028293132782,
0.23539575934410095,
-0.7144230008125305,
-0.19674582779407... |
func (f *Forest) WriteForest(miscForestFile *os.File) error {
fmt.Println("numLeaves=", f.numLeaves)
fmt.Println("f.height=", f.height)
_, err := miscForestFile.WriteAt(append(U64tB(f.numLeaves), U8tB(f.height)...), 0)
if err != nil {
return err
}
return nil
} | [
-0.03427162021398544,
-0.20058642327785492,
0.6829526424407959,
0.23559771478176117,
0.7727815508842468,
0.1587599217891693,
0.32940101623535156,
0.10731779783964157,
-0.8522831797599792,
-0.7310563921928406,
-0.6762498021125793,
0.03677191957831383,
-0.18522493541240692,
0.954957187175750... |
func (f *Forest) GetTops() []Hash {
topposs, _ := getTopsReverse(f.numLeaves, f.height)
tops := make([]Hash, len(topposs))
for i := range tops {
tops[i] = f.data.read(topposs[i])
}
return tops
} | [
-0.8279282450675964,
0.06710340827703476,
0.6612560749053955,
0.27614280581474304,
0.0721994936466217,
-0.3223399221897125,
-1.1106845140457153,
-0.23953190445899963,
-1.0995583534240723,
0.3850824534893036,
-0.5507471561431885,
-0.3630397319793701,
0.15491147339344025,
-0.3317107260227203... |
func (f *Forest) ToString() string {
fh := f.height
// tree height should be 6 or less
if fh > 6 {
return "forest too big to print "
}
output := make([]string, (fh*2)+1)
var pos uint8
for h := uint8(0); h <= fh; h++ {
rowlen := uint8(1 << (fh - h))
for j := uint8(0); j < rowlen; j++ {
var valstring s... | [
-0.05048263818025589,
-0.7948350310325623,
0.9405268430709839,
-0.0874730721116066,
-0.4590013921260834,
-0.1606585532426834,
-0.09325914084911346,
-0.7995731234550476,
-0.99577796459198,
0.14454157650470734,
-0.11447589099407196,
-0.3027766942977905,
0.061350829899311066,
0.46175354719161... |
func issue26725(x interface{}) int {
switch v := x.(type) {
case int, int32:
if v, ok := x.(int); ok {
return v
}
case int64:
return int(v)
}
return 0
} | [
-1.0094938278198242,
-0.20653557777404785,
0.3712710440158844,
0.03407130762934685,
-1.0729683637619019,
-0.29866716265678406,
0.022606413811445236,
-0.7784005999565125,
0.48931941390037537,
-0.4253193140029907,
0.1859288364648819,
0.9731171131134033,
-0.43080249428749084,
0.54577958583831... |
func shadowTypeSwitch(a interface{}) {
switch t := a.(type) {
case int:
{
t := 0 // want "declaration of .t. shadows declaration at line 78"
_ = t
}
_ = t
case uint:
{
t := uint(0) // OK because t is not mentioned later in this function
_ = t
}
}
} | [
-0.015038319863379002,
-0.05455281212925911,
0.6915556192398071,
-0.24438691139221191,
0.7061814665794373,
0.45230385661125183,
1.2327326536178589,
-0.40624600648880005,
0.7437471747398376,
0.37095069885253906,
-0.22122587263584137,
1.1669740676879883,
0.4231572449207306,
0.730080842971801... |
func (s GlobalSignOutInput) String() string {
return awsutil.Prettify(s)
} | [
0.2765507400035858,
-0.21434685587882996,
0.1735277771949768,
-0.17241080105304718,
-0.6233472228050232,
1.3633307218551636,
0.9758694767951965,
-0.17290586233139038,
-0.07941446453332901,
0.46900057792663574,
-0.3546043932437897,
0.02216511406004429,
-0.29507070779800415,
-0.5453598499298... |
func (s *GlobalSignOutInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "GlobalSignOutInput"}
if s.AccessToken == nil {
invalidParams.Add(aws.NewErrParamRequired("AccessToken"))
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
} | [
-0.19054313004016876,
0.2930314242839813,
0.39116454124450684,
0.3245629072189331,
0.07540223747491837,
0.631817638874054,
0.14422303438186646,
0.406554639339447,
-0.37945860624313354,
0.6244314908981323,
0.43149274587631226,
-0.08941278606653214,
-1.1293375492095947,
0.5299921035766602,
... |
func (s GlobalSignOutOutput) String() string {
return awsutil.Prettify(s)
} | [
0.7179208397865295,
-0.5379045009613037,
0.20034506916999817,
-0.2663727104663849,
-1.1684269905090332,
0.798215925693512,
0.8519343137741089,
-0.21823613345623016,
-0.6162838339805603,
0.47799018025398254,
-0.261803537607193,
-0.032852716743946075,
-0.19838815927505493,
-0.325866758823394... |
func (r GlobalSignOutRequest) Send(ctx context.Context) (*GlobalSignOutResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &GlobalSignOutResponse{
GlobalSignOutOutput: r.Request.Data.(*GlobalSignOutOutput),
response: &aws.Response{Request... | [
-0.5670785903930664,
-0.0930185467004776,
0.3118640184402466,
-0.013617895543575287,
-0.12520858645439148,
0.676115870475769,
0.13123075664043427,
0.08625335991382599,
-0.13859747350215912,
0.548232913017273,
-0.48059362173080444,
0.23159159719944,
-1.0519249439239502,
0.010561767965555191... |
func (r *GlobalSignOutResponse) SDKResponseMetdata() *aws.Response {
return r.response
} | [
0.06262471526861191,
-0.5774649381637573,
0.20829537510871887,
-0.4163359999656677,
-0.7197162508964539,
0.9066475033760071,
-0.38299301266670227,
0.41090935468673706,
0.7230692505836487,
0.23190276324748993,
-0.5585256218910217,
-0.46858957409858704,
-0.4230010509490967,
-1.13204264640808... |
func GetFirewallSettings(paramsReader params.Reader) (settings Firewall, err error) {
settings.AllowedSubnets, err = paramsReader.GetExtraSubnets()
if err != nil {
return settings, err
}
settings.Enabled, err = paramsReader.GetFirewall()
if err != nil {
return settings, err
}
settings.Debug, err = paramsRead... | [
-0.1501196175813675,
0.9440436959266663,
0.47097277641296387,
1.0959869623184204,
-0.13537484407424927,
-0.4867272973060608,
0.44460755586624146,
-0.6761295199394226,
-0.19736172258853912,
0.37143343687057495,
-0.10649824142456055,
0.13867376744747162,
-0.9172113537788391,
1.19429826736450... |
func GetStore() StoreIf {
return metadataStore
} | [
0.769208550453186,
0.6993374228477478,
0.07414776086807251,
1.197940468788147,
0.02482694573700428,
0.029962481930851936,
-0.08342619985342026,
0.03313722461462021,
1.1239292621612549,
-1.3009555339813232,
0.6540011167526245,
0.42992839217185974,
-0.4998184144496918,
0.4154243767261505,
... |
func (s Store) AddApplication(metadata utils.Metadata) error {
title := metadata.Title
version := metadata.Version
s.lock.Lock()
defer s.lock.Unlock()
if exists, _ := s.isApplicationPresent(title, version); exists {
return messages.DuplicateMetadata
}
if _, ok := s.appToDetails[title]; !ok {
s.appToDetails... | [
-0.8134640455245972,
-0.1367250382900238,
0.8141667246818542,
-0.1489643007516861,
0.2760451138019562,
1.3247623443603516,
-0.18176187574863434,
0.09551941603422165,
0.3127136826515198,
0.9092309474945068,
0.09166838228702545,
-0.15550905466079712,
0.12241850048303604,
0.2921462953090668,
... |
func (s Store) UpdateApplicationForVersion(metadata utils.Metadata) error {
title := metadata.Title
version := metadata.Version
s.lock.Lock()
defer s.lock.Unlock()
if exists, err := s.isApplicationPresent(title, version); !exists {
return err
}
s.appToDetails[title][version] = metadata
return nil
} | [
-0.7649629712104797,
-1.0919275283813477,
0.5822808146476746,
-0.16625617444515228,
-0.423075795173645,
1.1787458658218384,
-0.20582948625087738,
0.028234869241714478,
-0.3368302583694458,
1.5292850732803345,
-0.0059126936830580235,
0.20251834392547607,
0.2339773178100586,
0.20703202486038... |
func (s Store) GetAllMetadata() ([]utils.Metadata, error) {
var listMetadata []utils.Metadata
s.lock.Lock()
defer s.lock.Unlock()
if len(s.appToDetails) == 0 {
return listMetadata, messages.EmptyStore
}
for _, application := range s.appToDetails {
for _, metadata := range application {
listMetadata = ap... | [
0.16494885087013245,
0.059247154742479324,
0.5340476036071777,
1.0211118459701538,
0.4102056920528412,
0.6039949655532837,
-1.1235305070877075,
0.2437869906425476,
0.6260256767272949,
0.40700316429138184,
0.009730246849358082,
1.0928611755371094,
-0.019812388345599174,
0.8835506439208984,
... |
func (s Store) GetApplication(title string) ([]utils.Metadata, error) {
var listMetadata []utils.Metadata
s.lock.Lock()
defer s.lock.Unlock()
if !s.isTitlePresent(title) {
return listMetadata, messages.MetadataTitleAbsent
}
for _, metadata := range s.appToDetails[title] {
listMetadata = append(listMetadata... | [
-0.8578284978866577,
-0.049069441854953766,
0.7797521948814392,
0.2711276710033417,
0.22654058039188385,
0.5273761749267578,
-0.9985805153846741,
-0.4188351035118103,
0.31952619552612305,
1.5370482206344604,
0.16524620354175568,
0.597337007522583,
0.15868179500102997,
0.45284825563430786,
... |
func (s Store) GetApplicationWithVersion(title, version string) (utils.Metadata, error) {
var metadata utils.Metadata
s.lock.Lock()
defer s.lock.Unlock()
if exists, err := s.isApplicationPresent(title, version); !exists {
return metadata, err
}
return s.appToDetails[title][version], nil
} | [
-0.12319400161504745,
-0.8889758586883545,
0.6173707246780396,
0.26659077405929565,
-0.6697627902030945,
0.33475494384765625,
-0.6820068359375,
-0.6467077732086182,
0.052373286336660385,
1.3958382606506348,
0.26934024691581726,
0.5204435586929321,
0.025690769776701927,
-0.29177361726760864... |
func (s Store) DeleteApplication(title string) error {
s.lock.Lock()
defer s.lock.Unlock()
if !s.isTitlePresent(title) {
return messages.MetadataTitleAbsent
}
delete(s.appToDetails, title)
return nil
} | [
-0.36488211154937744,
0.09829750657081604,
0.5753668546676636,
0.11371994018554688,
-0.2591847777366638,
0.8658405542373657,
0.13260695338249207,
-0.13271014392375946,
0.6792125105857849,
0.8021653294563293,
0.4770565629005432,
-0.1940748244524002,
-0.24023596942424774,
0.5712804198265076,... |
func (s Store) DeleteApplicationWithVersion(title, version string) error {
s.lock.Lock()
defer s.lock.Unlock()
if exists, err := s.isApplicationPresent(title, version); !exists {
return err
}
delete(s.appToDetails[title], version)
return nil
} | [
0.1354980766773224,
-1.145890474319458,
0.56904536485672,
0.49427151679992676,
-0.9226304888725281,
0.6967653036117554,
-0.3125075399875641,
-0.015208831988275051,
0.431231290102005,
1.3632946014404297,
-0.28868567943573,
-0.1275886744260788,
-0.1096171885728836,
0.23640765249729156,
-0.... |
func parseFlags6Mirroring(flags byte) Mirroring {
// Right-most bit position
return Mirroring(flags & 0x01)
} | [
0.10973889380693436,
0.5354119539260864,
0.26015615463256836,
0.3379446268081665,
-0.8376082181930542,
-0.29166749119758606,
0.11480846256017685,
-0.07915705442428589,
0.322822630405426,
0.462454617023468,
-1.0443662405014038,
-0.24047638475894928,
-0.5325338244438171,
0.30316099524497986,... |
func parseFlags7VSUnisystem(flags byte) bool {
// Right-most bit position
return (uint8(flags) & 0x01) == 1
} | [
-0.5670289993286133,
0.4077394902706146,
0.4681519865989685,
0.7570688724517822,
-0.07550781220197678,
0.15586651861667633,
-0.34528833627700806,
-0.44290971755981445,
1.0962505340576172,
-0.33965572714805603,
-0.13144885003566742,
-0.23557539284229279,
-0.8721989393234253,
0.6962237954139... |
func parseFlags9TVSystem(flags byte) TVSystem {
return TVSystem(uint8(flags) & 0x01)
} | [
0.4836386740207672,
0.41863197088241577,
0.2544223368167877,
-0.17440278828144073,
-0.4214499592781067,
-0.20904789865016937,
-0.3326401114463806,
-1.32163667678833,
1.3166100978851318,
-0.929620623588562,
-0.40960779786109924,
0.3120824098587036,
-0.7715849280357361,
0.5406956076622009,
... |
func RecoverPublicKey(sig, hash []byte) (tmcrypt.PubKey, sdk.AccAddress, error) {
// Recover public key
pubKey, _, err := btcec.RecoverCompact(btcec.S256(), sig, hash)
if err != nil {
return nil, nil, err
}
// Create tendermint public key type and return with address.
tmKey := tmcurve.PubKey{} // .PubKeySecp256... | [
0.9018011689186096,
-0.16484364867210388,
0.2189149111509323,
0.31528255343437195,
-0.18085062503814697,
-0.7753233909606934,
0.25003892183303833,
-0.37085023522377014,
-0.4538971185684204,
0.28988268971443176,
-0.9911203384399414,
-0.0007907478138804436,
-0.07817693054676056,
0.3462937474... |
func ParsePublicKey(data []byte) (tmcrypt.PubKey, sdk.AccAddress, error) {
// Parse the secp256k1 public key.
pk, err := btcec.ParsePubKey(data, btcec.S256())
if err != nil {
return nil, nil, err
}
// Create tendermint public key type and return with address.
tmKey := tmcurve.PubKey(pk.SerializeCompressed()) //... | [
0.8254374861717224,
0.24530409276485443,
0.2625909447669983,
0.24709130823612213,
-0.14008156955242157,
-0.5580247044563293,
0.5406343936920166,
-0.5886046886444092,
-0.11303647607564926,
0.8775227069854736,
-0.7245091199874878,
0.16002580523490906,
-0.45364490151405334,
0.4214469790458679... |
func GenerateRandomBytes(n int) ([]byte, error) {
buf := make([]byte, n)
rv := C.GenerateRandomBytes((*C.byte)(unsafe.Pointer(&buf[0])), C.int(n))
if rv != 1 {
return nil, fmt.Errorf("Unable to GenerateRandomBytes")
}
return buf, nil
} | [
-0.6134713292121887,
0.9648446440696716,
0.43908461928367615,
0.6476852893829346,
-0.045770641416311264,
0.20289112627506256,
-0.06476972997188568,
-1.1691535711288452,
1.02519690990448,
-0.28192034363746643,
-1.5696909427642822,
-0.7781216502189636,
-1.1409275531768799,
1.4922562837600708... |
func addToBasketHandler(w http.ResponseWriter, r *http.Request) {
log.Println("addToBasketHandler entry")
vars := mux.Vars(r)
userId := vars["userId"]
err := r.ParseForm()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
} else {
productId := r.FormValue("productId")
quantityStr := r.FormValue... | [
-0.2245805561542511,
-0.8410069346427917,
0.7557008862495422,
0.23956282436847687,
-0.1580122858285904,
1.039319396018982,
0.96611088514328,
-0.3424895107746124,
0.7277564406394958,
-0.37259355187416077,
-0.18274611234664917,
0.12078604102134705,
0.254761666059494,
0.5788704752922058,
0.... |
func (c *QueryContext) Unmarshal(b []byte) (size uint32) {
n := binary.BigEndian.Uint32(b)
b = b[4:]
c.Query = b[:n]
size = n
b = b[n:]
n = binary.BigEndian.Uint32(b)
b = b[4:]
c.User = b[:n]
size += n
b = b[n:]
n = binary.BigEndian.Uint32(b)
b = b[4:]
c.Client = b[:n]
size += n
b = b[n:]
n = binary... | [
0.05991227552294731,
0.8480015993118286,
0.7608460187911987,
-1.2820159196853638,
-0.21780958771705627,
-0.07112261652946472,
0.3767889440059662,
-0.5685892701148987,
0.5583583116531372,
0.012260815128684044,
-0.4092276990413666,
-0.0901394635438919,
-1.2657841444015503,
-0.355170696973800... |
func (c *QueryContext) Marshal() []byte {
buf := bufPool.Get().(*bytes.Buffer)
defer bufPool.Put(buf)
buf.Reset()
l := make([]byte, 4)
binary.BigEndian.PutUint32(l, uint32(len(c.Query)))
buf.Write(l)
buf.Write(c.Query)
binary.BigEndian.PutUint32(l, uint32(len(c.User)))
buf.Write(l)
buf.Write(c.User)
binary... | [
0.7884476184844971,
0.47157448530197144,
0.639781653881073,
-0.7599461078643799,
-0.12181240320205688,
0.9530677199363708,
-0.5399309992790222,
-1.0251612663269043,
0.07611364871263504,
-0.5874437093734741,
-0.30225419998168945,
0.9183644652366638,
-1.0830535888671875,
0.3062036335468292,
... |
func Pattern(query []byte) []byte {
tokenizer := sqlparser.NewStringTokenizer(string(query))
buf := bytes.Buffer{}
l := make([]byte, 4)
for {
typ, val := tokenizer.Scan()
switch typ {
case sqlparser.ID: //table, database, variable & ... names
buf.Write(val)
case 0: //End of query
return buf.Bytes()
... | [
-0.9668567776679993,
0.786540687084198,
0.3048703074455261,
-0.21495375037193298,
-0.49937355518341064,
0.3380909264087677,
-0.9070664048194885,
-0.8292859196662903,
0.23074711859226227,
0.036247991025447845,
-0.3236713409423828,
-0.44486942887306213,
-0.7772282958030701,
0.400310605764389... |
func Detect(input string, candiates []string) []string {
var output []string
lowerInput := strings.ToLower(input)
sortedInput := sortString(lowerInput)
for _, s := range candiates {
if len(input) != len(s) {
continue
}
if lowerInput == strings.ToLower(s) {
continue
}
if sortedInput == sortString(s... | [
0.15218856930732727,
-1.4481679201126099,
0.5133518576622009,
0.4948351979255676,
-0.6706700325012207,
0.3303423523902893,
-0.7284673452377319,
-0.32748064398765564,
0.08079610764980316,
0.21433301270008087,
0.37099403142929077,
0.4413997232913971,
-0.8820538520812988,
1.0075359344482422,
... |
func (pointerToPerson *person) updateName(newFirstName string) {
(*pointerToPerson).firstName = newFirstName // *p get the value from memory address p
} | [
-0.3307371437549591,
-1.204359769821167,
0.47441720962524414,
-0.5801275372505188,
-0.8872799277305603,
0.20474107563495636,
-0.02668527327477932,
0.36209040880203247,
0.014389444142580032,
0.9690893888473511,
-0.13145281374454498,
0.152979776263237,
-0.9925697445869446,
0.5407257080078125... |
func New() *DynMap {
return &DynMap{make(map[string]interface{})}
} | [
-1.1490360498428345,
-0.7202937006950378,
0.1931019127368927,
0.1928478330373764,
-0.40495797991752625,
-0.24671392142772675,
0.30916503071784973,
-0.36508843302726746,
-0.4021221995353699,
-1.2366437911987305,
-0.32931074500083923,
0.2492581307888031,
0.836249828338623,
0.5005561113357544... |
func NewDynMap() *DynMap {
return &DynMap{make(map[string]interface{})}
} | [
-0.31738772988319397,
-0.6610199213027954,
0.24585208296775818,
0.6097251772880554,
-0.5452210307121277,
-0.7874057292938232,
0.4904060363769531,
-0.4636874496936798,
-0.007869303226470947,
-1.2162785530090332,
-1.0068283081054688,
0.5529102087020874,
0.008392421528697014,
0.35222470760345... |
func (this *DynMap) ToMap() map[string]interface{} {
mp := make(map[string]interface{})
for k, v := range(this.Map) {
submp, ok := ToDynMap(this.Map[k])
if ok {
v = submp.ToMap()
}
mp[k] = v
}
return mp
} | [
-1.542340636253357,
-0.22805462777614594,
0.8999837636947632,
0.6350628137588501,
-0.09063088893890381,
-0.2979331910610199,
-0.22644712030887604,
-0.20164498686790466,
0.8069903254508972,
-0.19000276923179626,
-0.33086076378822327,
-0.5152575969696045,
0.2957651615142822,
0.04528660699725... |
func (this *DynMap) Clone() *DynMap {
mp := New()
for k, v := range(this.Map) {
submp, ok := ToDynMap(this.Map[k])
if ok {
v = submp.Clone()
}
mp.Put(k, v)
}
return mp
} | [
-1.0003310441970825,
-0.6139411330223083,
0.8019794821739197,
0.8355423808097839,
-0.3879748284816742,
0.16084535419940948,
-0.2053905576467514,
-0.9403817057609558,
0.3083931505680084,
-0.4828610420227051,
-0.1645611822605133,
-0.2761916220188141,
-0.46623316407203674,
-0.0930031910538673... |
func (this *DynMap) ToDynMap() *DynMap {
return this
} | [
-0.7366275787353516,
-0.5462803244590759,
0.5078849196434021,
0.13287775218486786,
0.5329097509384155,
-0.14772315323352814,
1.197758436203003,
-0.08117811381816864,
0.8068117499351501,
-1.8180445432662964,
-0.9477267861366272,
0.017131730914115906,
0.8785502314567566,
0.07103471457958221,... |
func (this *DynMap) MarshalURL() (string, error) {
vals := &url.Values{}
for key, value := range this.Map {
err := this.urlEncode(vals, key, value)
if err != nil {
return "", err
}
}
str := vals.Encode()
log.Printf(str)
return vals.Encode(), nil
} | [
-0.7102530002593994,
-0.2834049463272095,
0.3954556882381439,
0.3351053297519684,
-0.0054535334929823875,
0.24566948413848877,
-0.5738632678985596,
0.29540562629699707,
-0.008751438930630684,
-0.3275648057460785,
0.3298834562301636,
-0.033609483391046524,
-0.059352435171604156,
0.833231329... |
func (this *DynMap) UnmarshalURL(urlstring string) error {
//TODO: split on ?
values, err := url.ParseQuery(urlstring)
if err != nil {
return err
}
return this.UnmarshalURLValues(values)
} | [
-1.3090341091156006,
0.04615365341305733,
0.6088595986366272,
-0.1755206435918808,
-0.12840311229228973,
-0.4390619397163391,
0.29400989413261414,
1.0740572214126587,
0.4592495560646057,
-0.6518076062202454,
0.061631761491298676,
-0.710687518119812,
0.16023096442222595,
-0.1929306238889694... |
func (this *DynMap) UnmarshalURLValues(values url.Values) error {
for k := range values {
var v = values[k]
key := strings.Replace(k, "[", ".", -1)
key = strings.Replace(key, "]", "", -1)
if len(v) == 1 {
this.PutWithDot(key, v[0])
} else {
this.PutWithDot(key, v)
}
}
return nil
} | [
-1.2470591068267822,
0.1275373101234436,
0.6513313055038452,
-0.6854158639907837,
0.2125348448753357,
-0.5013521313667297,
0.2848421037197113,
0.9723143577575684,
0.40635356307029724,
-0.46979960799217224,
-0.1324668526649475,
-0.3300267159938812,
0.601235568523407,
0.558451235294342,
-0... |
func (this *DynMap) urlEncode(vals *url.Values, key string, value interface{}) error {
if DynMapConvertable(value) {
mp, ok := ToDynMap(value)
if !ok {
return fmt.Errorf("Unable to convert %s", mp)
}
for k, v := range mp.Map {
//encode in rails style key[key2]=value
this.urlEncode(vals, fmt.Sprintf("... | [
-1.090462327003479,
0.5032327175140381,
0.6706937551498413,
0.7984647750854492,
-0.10126340389251709,
-0.8556298017501831,
-0.02115580253303051,
0.2706822156906128,
0.35128119587898254,
-0.32338061928749084,
0.12838149070739746,
0.07746853679418564,
-0.42354607582092285,
1.1827176809310913... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.