text stringlengths 11 6.3k | embedding listlengths 768 768 |
|---|---|
func (h *MaxHeap) Extract() int {
size := len(h.array) - 1
if size == -1 {
return -1
}
root := h.array[0]
h.array[0] = h.array[size]
h.array = h.array[:size]
h.heapifyDown()
return root
} | [
-0.12390179187059402,
0.11719293892383575,
0.8605263829231262,
0.4935048818588257,
-0.8000817894935608,
-0.5031861662864685,
0.3206929862499237,
0.5629190802574158,
0.5430227518081665,
0.43384310603141785,
-0.39048999547958374,
0.36936479806900024,
-1.434196949005127,
0.6282958984375,
1.... |
func (h *MaxHeap) swap(index1, index2 int) {
h.array[index1], h.array[index2] = h.array[index2], h.array[index1]
} | [
-1.5054950714111328,
-0.6530432105064392,
0.5000868439674377,
0.5431613922119141,
0.1440756618976593,
0.6984568238258362,
-0.8874046802520752,
0.46215134859085083,
0.1208663284778595,
-0.18136800825595856,
-0.49680161476135254,
1.313967227935791,
0.038246460258960724,
-0.7805975079536438,
... |
func parent(index int) int {
return (index - 1) / 2
} | [
-0.5192861557006836,
0.5843376517295837,
0.5665486454963684,
0.14751353859901428,
-0.9333712458610535,
-0.3149368166923523,
1.4904948472976685,
-1.3355674743652344,
0.006553283892571926,
-0.1815524846315384,
0.038201071321964264,
-0.5729656219482422,
-0.07251667976379395,
-0.09789881110191... |
func left(index int) int {
return 2*index + 1
} | [
-0.1822344958782196,
0.27402403950691223,
0.34391921758651733,
0.09126977622509003,
-0.0036796294152736664,
0.6522108316421509,
0.4025108218193054,
-0.7316906452178955,
0.9483661651611328,
-0.31048014760017395,
-0.9520618915557861,
0.09152700006961823,
-0.4219892621040344,
0.44143202900886... |
func right(index int) int {
return 2*index + 2
} | [
-0.375143438577652,
0.7762488126754761,
0.4451470375061035,
0.6617370247840881,
-0.5081610679626465,
0.2480585128068924,
-0.24895843863487244,
-0.7500576376914978,
-0.028193868696689606,
-0.3445403575897217,
-0.5773464441299438,
0.40498238801956177,
0.1582929641008377,
0.09187959134578705,... |
func forbiddenHTTPHandler(w http.ResponseWriter, r *http.Request) {
incMetric(metricAPIReq)
utils.DebugHTTPDump(r, settingsmgr.DebugHTTP(settings.ServiceAdmin, settings.NoEnvironment), true)
// Send response
utils.HTTPResponse(w, "", http.StatusForbidden, []byte(errorContent))
incMetric(metricAPIErr)
} | [
0.20356354117393494,
0.5303983092308044,
0.43184301257133484,
0.10882231593132019,
-0.619717538356781,
1.6533734798431396,
0.45747658610343933,
-1.411752700805664,
-1.0857526063919067,
0.3948860168457031,
0.5547065138816833,
0.6110306978225708,
-0.9844551682472229,
0.3856387734413147,
-0... |
func (r *Resource) NewDeletePatch(ctx context.Context, azureConfig, current, desired interface{}) (*crud.Patch, error) {
d, err := toVPNGatewayConnections(desired)
if err != nil {
return nil, microerror.Mask(err)
}
patch := r.newDeletePatch(d)
return patch, nil
} | [
-0.2120334506034851,
-0.80882328748703,
0.30000534653663635,
-0.3858709931373596,
-0.7756656408309937,
0.1517854630947113,
-0.5866235494613647,
0.07043422758579254,
0.6947005987167358,
0.42498236894607544,
0.888331413269043,
0.4380551874637604,
-0.6445964574813843,
0.375446617603302,
0.3... |
func (r *Resource) newDeletePatch(desired connections) *crud.Patch {
patch := crud.NewPatch()
patch.SetDeleteChange(desired)
return patch
} | [
-0.17971396446228027,
-1.0167688131332397,
0.32209885120391846,
-0.6855966448783875,
-0.8493567705154419,
0.21537864208221436,
-1.1543980836868286,
0.4922548830509186,
0.5787503123283386,
-0.3680729866027832,
0.27318936586380005,
0.476315438747406,
-0.6518064737319946,
0.08736318349838257,... |
func (r *Resource) ApplyDeleteChange(ctx context.Context, azureConfig, change interface{}) error {
c, err := toVPNGatewayConnections(change)
if err != nil {
return microerror.Mask(err)
}
err = r.applyDeleteChange(ctx, c)
if err != nil {
return microerror.Mask(err)
}
return nil
} | [
-0.18820421397686005,
-0.20727890729904175,
0.4054468274116516,
0.46189796924591064,
-0.19366636872291565,
0.38241124153137207,
-0.363333135843277,
0.15215536952018738,
0.86525559425354,
0.7273112535476685,
0.9819786548614502,
-0.2528827488422394,
-0.056824877858161926,
1.6452546119689941,... |
func ModuleFactoryAdaptor(factory ModuleFactory) blueprint.ModuleFactory {
return func() (blueprint.Module, []interface{}) {
module := factory()
return module, module.GetProperties()
}
} | [
-1.4600648880004883,
-1.0425081253051758,
0.31412002444267273,
-0.46960774064064026,
-0.8664498925209045,
-0.6043676137924194,
-0.34789642691612244,
0.25333499908447266,
0.6914589405059814,
-0.16295304894447327,
0.42418840527534485,
0.8553354144096375,
0.8484925627708435,
0.410111695528030... |
func SingletonFactoryAdaptor(factory SingletonFactory) blueprint.SingletonFactory {
return func() blueprint.Singleton {
singleton := factory()
if makevars, ok := singleton.(SingletonMakeVarsProvider); ok {
registerSingletonMakeVarsProvider(makevars)
}
return &singletonAdaptor{Singleton: singleton}
}
} | [
-1.5420950651168823,
0.1694096475839615,
0.3566751480102539,
-0.2212553471326828,
-1.0131391286849976,
-0.4968116879463196,
1.127740502357483,
0.8556053638458252,
1.722049355506897,
-0.25288626551628113,
0.1889372169971466,
0.9793863296508789,
0.42287757992744446,
-0.23775114119052887,
0... |
func NewParser(dir string) *Parser {
return &Parser{
dir: dir,
}
} | [
-0.4081382155418396,
-1.2909290790557861,
-0.20603737235069275,
-0.16318407654762268,
-0.7443773150444031,
0.06204741820693016,
-0.2443651556968689,
0.16651266813278198,
0.29253873229026794,
-1.003114938735962,
-0.08481009304523468,
1.015421986579895,
-0.271696537733078,
0.4208419919013977... |
func (p *Parser) getPackage() {
pkg, err := build.Default.ImportDir(p.dir, build.ImportComment)
if err != nil {
log.Fatalf("cannot process directory %s: %s", p.dir, err)
}
p.pkg = pkg
} | [
0.3131348192691803,
0.43206971883773804,
0.5255048871040344,
0.5170692205429077,
1.6533124446868896,
-0.2184198796749115,
0.9854498505592346,
0.8882976174354553,
-0.5672244429588318,
-0.6187188625335693,
0.2611638009548187,
0.35901305079460144,
0.012703110463917255,
0.7016586661338806,
0... |
func (p *Parser) parseGoFiles() {
var parsedFiles []*ast.File
fs := token.NewFileSet()
for _, file := range p.pkg.GoFiles {
file = p.dir + "/" + file
parsedFile, err := parser.ParseFile(fs, file, nil, 0)
if err != nil {
log.Fatalf("parsing package: %s: %s\n", file, err)
}
parsedFiles = append(parsedFile... | [
-0.3019508123397827,
0.7082303166389465,
0.24528008699417114,
-0.5607236623764038,
1.134548306465149,
0.17054232954978943,
0.30881941318511963,
0.6248561143875122,
-1.0861849784851074,
0.5068325996398926,
-0.42979001998901367,
-0.9065593481063843,
-0.5907384157180786,
0.5739617943763733,
... |
func (p *Parser) parseTypes(file *ast.File) (ret []structConfig) {
ast.Inspect(file, func(n ast.Node) bool {
decl, ok := n.(*ast.GenDecl)
if !ok || decl.Tok != token.TYPE {
return true
}
for _, spec := range decl.Specs {
var (
data structConfig
)
typeSpec, _ok := spec.(*ast.TypeSpec)
if !_o... | [
-0.5884379744529724,
0.34647268056869507,
0.7360286116600037,
-1.2699384689331055,
0.3164372146129608,
0.3281581401824951,
-0.3190513551235199,
-0.6307573914527893,
-1.035346269607544,
1.00379478931427,
-0.5682141184806824,
-0.48927170038223267,
0.0743241086602211,
0.8634098768234253,
0.... |
func (p *Parser) Parse() (ret []structConfig) {
var (
data []structConfig
)
p.getPackage()
p.parseGoFiles()
for _, f := range p.parsedFiles {
data = append(data, p.parseTypes(f)...)
}
return data
} | [
-0.8930362462997437,
0.6326806545257568,
0.4561416804790497,
0.24894177913665771,
0.8846703767776489,
0.3500019311904907,
-0.27942439913749695,
-0.2322436422109604,
-1.0479074716567993,
0.24521897733211517,
-0.5836461186408997,
-0.8122962713241577,
-0.6419059038162231,
0.9919254183769226,
... |
func TestMinDifficultyReduction(t *testing.T) {
// Create chain params based on regnet params, but set the fields related to
// proof-of-work difficulty to specific values expected by the tests.
params := chaincfg.RegNetParams
params.ReduceMinDifficulty = true
params.TargetTimePerBlock = time.Minute * 2
params.Mi... | [
-0.3963836431503296,
0.160636767745018,
0.7014860510826111,
-0.29343152046203613,
0.9506380558013916,
-0.15006926655769348,
1.3491493463516235,
-0.6622651219367981,
0.199345663189888,
-0.46838662028312683,
-0.6703338027000427,
0.10331825911998749,
-0.5264663100242615,
0.5288183689117432,
... |
func TestSomethingElse(t *testing.T) {
mock.AddResponse(&mock.Client, "GET", "/job/mycustomjobpath/api/json", mock.Response{
StatusCode: 200,
Bytes: nil,
})
// now do something with mock.Client
} | [
0.013571275398135185,
-0.21470583975315094,
0.6936473250389099,
-0.42881348729133606,
0.5846633315086365,
-0.0414438433945179,
-0.31726929545402527,
-0.3781932592391968,
0.1320008486509323,
-0.9405518770217896,
-0.8347488045692444,
-0.316415399312973,
-0.9422972798347473,
-0.23466430604457... |
func FindTransformer(transformerName string) func(Segment) Segment {
var innerTransformer func(*Segment)
switch {
// Catch special colors early
case transformerName == "default":
innerTransformer = func(s *Segment) { s.Foreground = "" }
case transformerName == "bg-default":
innerTransformer = func(s *Segment)... | [
-0.9324967861175537,
-0.5675627589225769,
0.8218523263931274,
-1.0271533727645874,
-0.3089240491390228,
-1.3703449964523315,
-0.08284338563680649,
-0.6081461906433105,
-0.3277156352996826,
-0.5126973986625671,
-0.4501350224018097,
-0.440792053937912,
-0.5059887766838074,
0.6824026107788086... |
func (is *instructionSet) inspect() string {
var out bytes.Buffer
for _, i := range is.instructions {
out.WriteString(i.Inspect())
out.WriteString("\n")
}
return out.String()
} | [
-0.7123615741729736,
-0.04724624752998352,
0.5695599913597107,
-0.9121977686882019,
-0.5659165978431702,
-0.50941401720047,
0.3964740037918091,
-0.9197067618370056,
-0.380700945854187,
0.35543927550315857,
0.9786381125450134,
0.4223385453224182,
-0.4633241593837738,
0.28968411684036255,
... |
func GetCredentialsFile() (*CredentialsFile, error) {
home := func() string {
if runtime.GOOS == "windows" {
return os.Getenv("USERPROFILE")
}
return os.Getenv("HOME")
}
path := filepath.Join(home(), ".aws", "credentials")
if p := os.Getenv("AWS_SHARED_CREDENTIALS_FILE"); len(p) > 0 {
path = p
}
ini.De... | [
0.8151401877403259,
-0.06402819603681564,
0.7470695972442627,
0.07858168333768845,
0.08971851319074631,
0.7914183735847473,
0.699167788028717,
0.1805640310049057,
-1.2413643598556519,
-0.452052503824234,
-0.07403296232223511,
0.07368196547031403,
-0.5158448219299316,
0.24813829362392426,
... |
func (f *CredentialsFile) GetProfilesNames() (names []string) {
if f.Content != nil {
for _, p := range f.Content.SectionStrings() {
if strings.ToLower(p) != "default" {
names = append(names, p)
}
}
}
sort.Strings(names)
return
} | [
0.7297619581222534,
-0.13513334095478058,
0.6302213668823242,
0.3831968903541565,
0.7573608756065369,
0.8750110268592834,
-0.7551129460334778,
-0.969878077507019,
-0.8716686367988586,
0.9373776316642761,
0.1835583746433258,
0.07879697531461716,
-1.0527198314666748,
0.19249476492404938,
-... |
func profilesEqual(s, d *Profile) bool {
if len(s.keys) != len(d.keys) {
return false
}
for k, v := range s.keys {
if d.keys[k] != v {
return false
}
}
return true
} | [
-0.10246611386537552,
-0.4348144829273224,
0.5059764981269836,
0.31522679328918457,
0.4993160367012024,
0.040742427110672,
-0.6701090931892395,
-0.6820974349975586,
-0.13056083023548126,
1.3582664728164673,
-1.1965142488479614,
0.012211092747747898,
-0.48460128903388977,
-0.660681068897247... |
func (f *CredentialsFile) GetUsedProfileNameAndIndex() (string, int, error) {
d, _ := f.GetProfileBy("default") // default always exists
if len(d.keys) < 1 {
return "no default", -2, nil
}
for idx, n := range f.GetProfilesNames() {
if s, err := f.GetProfileBy(n); err == nil {
if profilesEqual(s, d) {
ret... | [
-0.7195937633514404,
-0.5454002618789673,
0.7302771806716919,
-0.10876111686229706,
0.32736095786094666,
-0.6662673950195312,
0.49700209498405457,
-0.5042152404785156,
-0.1535099893808365,
0.3006078600883484,
-0.22896450757980347,
-0.13432057201862335,
-0.5210571885108948,
0.64550352096557... |
func (f *CredentialsFile) GetUsedID() (string, error) {
d, _ := f.GetProfileBy("default")
if len(d.AccessKeyID) == 0 { // empty default section
return "", fmt.Errorf("AWS_ACCESS_KEY_ID is not set inside the default section")
}
return d.AccessKeyID, nil
} | [
0.6266092658042908,
-0.03348860144615173,
0.6924494504928589,
0.06580785661935806,
0.6627868413925171,
0.04914816841483116,
0.03850928694009781,
-0.3025776445865631,
-0.38593465089797974,
-0.027321500703692436,
0.8308700919151306,
0.5555240511894226,
-0.637909471988678,
1.1172008514404297,... |
func (f *CredentialsFile) GetUsedKey() (string, error) {
d, _ := f.GetProfileBy("default")
if len(d.SecretAccessKey) == 0 { // empty default section
return "", fmt.Errorf("AWS_SECRET_ACCESS_KEY is not set inside the default section")
}
return d.SecretAccessKey, nil
} | [
0.470239520072937,
0.21823158860206604,
0.7937928438186646,
0.228643000125885,
0.8392940759658813,
-0.5026859045028687,
0.4557241201400757,
-0.3919092118740082,
-0.8347617983818054,
-0.21703308820724487,
0.3371042311191559,
0.42394307255744934,
-0.43289947509765625,
1.0343319177627563,
0... |
func (f *CredentialsFile) GetProfileBy(name string) (*Profile, error) {
p := &Profile{keys: make(map[string]string)}
s, err := f.Content.GetSection(name)
if err != nil {
return p, err
}
_ = s.MapTo(p) // error cannot happen; p is always a pointer
for _, k := range s.Keys() {
p.keys[k.Name()] = k.Value()
}
r... | [
0.22282877564430237,
-0.568828821182251,
0.7249900102615356,
-0.2972252666950226,
-0.17692649364471436,
-0.6887310147285461,
-0.45727136731147766,
-0.7735356688499451,
-0.8587325811386108,
0.8278047442436218,
0.025001516565680504,
-0.9240416288375854,
-0.3947070240974426,
-0.15428803861141... |
func (f *CredentialsFile) SetDefaultTo(profileName string) error {
p, err := f.GetProfileBy(profileName)
if err != nil {
return err
}
_ = f.Content.Section("default").ReflectFrom(p) // error cannot happen; p is always a pointer
return f.Content.SaveTo(f.Path)
} | [
-0.20526151359081268,
0.1124638244509697,
0.5273160338401794,
-0.4227907657623291,
1.09959876537323,
0.00411002803593874,
0.2806110084056854,
-0.274967759847641,
-1.1699343919754028,
-0.2974359691143036,
-1.2474327087402344,
-0.10984271764755249,
-0.4936530888080597,
0.19462846219539642,
... |
func (f *CredentialsFile) UnSetDefault() error {
f.Content.DeleteSection("default")
return f.Content.SaveTo(f.Path)
} | [
0.3063148260116577,
0.5018571019172668,
0.5570717453956604,
-0.2378096878528595,
1.1941139698028564,
-0.1415126770734787,
0.4107103645801544,
0.9501225352287292,
-1.5151889324188232,
-0.06627529859542847,
-0.1016702950000763,
0.24475355446338654,
-0.48515376448631287,
0.07584542036056519,
... |
func (fi bindataFileInfo) Name() string {
return fi.name
} | [
0.08166918903589249,
-1.4572765827178955,
0.4833078384399414,
0.14237014949321747,
-0.3545391261577606,
0.8819460272789001,
0.010945647954940796,
-0.2467803955078125,
-1.2708252668380737,
-0.10601194947957993,
-0.3917791545391083,
-0.41195377707481384,
0.39125633239746094,
0.16644497215747... |
func (fi bindataFileInfo) Size() int64 {
return fi.size
} | [
0.16575103998184204,
-0.1223422959446907,
0.17271094024181366,
-0.07949239760637283,
0.3543928861618042,
0.7548951506614685,
0.5927076935768127,
0.07495921850204468,
-1.0578577518463135,
-1.1731369495391846,
-0.10568573325872421,
-0.17690835893154144,
-0.33118754625320435,
0.30395281314849... |
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
} | [
-0.41162919998168945,
-0.9577594995498657,
0.44155263900756836,
-0.13144180178642273,
0.5922524929046631,
1.610377311706543,
0.009310288354754448,
0.2884019613265991,
-1.065315842628479,
-1.1910521984100342,
0.4981614947319031,
-0.2990283668041229,
-0.17645005881786346,
0.4694020748138428,... |
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
} | [
-0.2685695290565491,
-0.8271465301513672,
0.35384321212768555,
-0.4112885892391205,
0.37963899970054626,
0.6579224467277527,
-0.6294410824775696,
0.37015482783317566,
-0.2557626962661743,
0.014167135581374168,
0.4302074909210205,
-0.03708653151988983,
-0.8495825529098511,
0.746182441711425... |
func (fi bindataFileInfo) IsDir() bool {
return fi.mode&os.ModeDir != 0
} | [
0.10024337470531464,
-1.1714235544204712,
0.4835644066333771,
1.0096218585968018,
0.10103324800729752,
1.1084051132202148,
0.2600550055503845,
0.2042960673570633,
-0.43129751086235046,
-1.1601366996765137,
0.3743494749069214,
0.08362120389938354,
-0.2748109698295593,
0.8501272797584534,
... |
func (fi bindataFileInfo) Sys() interface{} {
return nil
} | [
-0.18937675654888153,
-0.91487056016922,
0.4192674458026886,
0.23279045522212982,
0.01389834750443697,
-0.11405561864376068,
0.5312886238098145,
-0.4064529240131378,
-0.1416921764612198,
-1.7679998874664307,
-0.9565558433532715,
0.39589381217956543,
0.34836944937705994,
0.461544007062912,
... |
func Asset(name string) ([]byte, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
}
return nil, fmt.Errorf("Asset %s not foun... | [
-0.7961482405662537,
-1.2313158512115479,
0.6331650614738464,
-0.6093901991844177,
-1.546920895576477,
-0.11101029813289642,
0.129714235663414,
-1.3390333652496338,
-1.135871410369873,
0.4855230152606964,
0.30901390314102173,
0.3249545693397522,
-0.6009676456451416,
-0.44264793395996094,
... |
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
} | [
-0.012778956443071365,
0.11985661834478378,
0.4091298282146454,
-0.5268413424491882,
-0.8276715278625488,
0.4719155430793762,
-0.8186293840408325,
-1.5736604928970337,
0.16388541460037231,
0.6357062458992004,
-0.5354578495025635,
0.35693347454071045,
0.0057142809964716434,
-0.0248885955661... |
func AssetInfo(name string) (os.FileInfo, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("Asset... | [
0.3719695508480072,
-1.1052989959716797,
0.5630441904067993,
-0.9225736260414124,
-1.356386423110962,
0.003355572931468487,
0.6777525544166565,
-0.8006678819656372,
-1.274828553199768,
0.311536967754364,
0.26360753178596497,
0.26388123631477356,
0.06357761472463608,
-0.39880770444869995,
... |
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
} | [
-0.7293784618377686,
-0.8460342288017273,
0.7321816682815552,
-0.39323121309280396,
-0.48951536417007446,
0.7661203145980835,
-0.5028699636459351,
-0.8655748963356018,
-0.4145073890686035,
0.8099913597106934,
0.16903363168239594,
1.163049578666687,
-0.028152840211987495,
0.0342608317732811... |
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), d... | [
0.34371325373649597,
-0.3622533082962036,
0.6770349144935608,
-1.2592034339904785,
-0.00613967701792717,
-0.044532135128974915,
-0.00726317847147584,
-0.43950432538986206,
-0.2061910331249237,
-0.2510174810886383,
0.17843623459339142,
0.1356850564479828,
-0.2362709492444992,
-0.56985044479... |
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
} | [
0.4226192533969879,
0.3001989424228668,
0.5813396573066711,
-0.20641714334487915,
-0.23828980326652527,
-0.24414613842964172,
0.5739712119102478,
-0.029911452904343605,
0.061882976442575455,
-0.43923527002334595,
0.5113739371299744,
0.3275964856147766,
-0.612514853477478,
0.035165321081876... |
func (ci *Circuit) GenMNA() (A Matrix, Z Matrix) {
// The A matrix can be made of 4 smaller submatrices
// A = [G B]
// [C D]
G := ci.genG()
B := ci.genB()
C := ci.genC()
D := ci.genD()
A = ci.mergeMatrices("GB;CD", G, B, C, D)
ci.cleanupMatrix(A)
// The Z matrix can be made of 2 smaller submatrices
// ... | [
-0.3542640209197998,
0.47627437114715576,
0.6856560111045837,
-0.08904264122247696,
0.10928148776292801,
-0.1344158947467804,
1.5209574699401855,
0.21566937863826752,
0.4331773817539215,
-0.3467864692211151,
-0.7637354135513306,
-0.118137426674366,
-0.13634458184242249,
0.9084771871566772,... |
func stripBearer(tok string) (string, error) {
if len(tok) > 6 && strings.ToLower(tok[0:7]) == "bearer " {
return tok[7:], nil
}
return tok, nil
} | [
0.3712954521179199,
-0.5781612396240234,
0.6932976245880127,
-0.7136732935905457,
-1.104749321937561,
0.015617972239851952,
-0.21559980511665344,
0.35653045773506165,
1.1957811117172241,
-0.6132140159606934,
-0.214227095246315,
-0.3066358268260956,
-0.5085241794586182,
0.3907066881656647,
... |
func RequireLoggedIn(jwtSecret string) gin.HandlerFunc {
return func(c *gin.Context) {
token, err := stripBearer(c.Request.Header.Get("Authorization"))
if err != nil {
controllers.HTTPRes(c, http.StatusUnauthorized, err.Error(), nil)
c.Abort()
return
}
tokenClaims, err := jwt.ParseWithClaims(
tok... | [
-0.05612926557660103,
-0.3048912584781647,
0.6301882863044739,
-0.016447652131319046,
-0.5898392796516418,
0.3266318738460541,
-0.1653963327407837,
-0.5981318950653076,
0.2125168889760971,
0.05756818875670433,
-0.25590258836746216,
0.5931239128112793,
-0.04271038994193077,
-0.1251614689826... |
func (b *backend) SubscribeLogFilter(ctx context.Context, query ethereum.FilterQuery, consumer LogConsumer) (Subscription, error) {
id, err := b.newLogFilter(query)
if err != nil {
return nil, err
}
s := newSub(
func() (bool, error) {
logs, err := b.getFilterLogs(id)
if err != nil {
return false, err... | [
0.38463094830513,
-0.14378073811531067,
0.6223548650741577,
-0.06977622956037521,
-0.8603513240814209,
-0.742724597454071,
-0.7001863121986389,
-0.880125105381012,
-0.01854741759598255,
0.5638886094093323,
-0.1295384168624878,
1.0327000617980957,
-0.550834059715271,
0.0845881849527359,
0... |
func (l Label) Label() string { return string(l) } | [
-0.5379208922386169,
-0.6971460580825806,
-0.27162596583366394,
0.03146405890583992,
-0.04087750241160393,
1.7627203464508057,
-0.9075437188148499,
-0.06645046919584274,
1.395027995109558,
0.4883292615413666,
0.24866695702075958,
-0.46870219707489014,
-0.438656210899353,
-0.137951016426086... |
func NameLabels(fs []Feature) []Labeler {
l := make([]Labeler, len(fs))
for i, f := range fs {
if fl, ok := f.(locater); ok {
l[i] = fl
} else {
l[i] = featLabel{f}
}
}
return l
} | [
-1.0507290363311768,
-1.015666127204895,
0.42579543590545654,
0.07095419615507126,
-0.7786407470703125,
0.09665396064519882,
-0.21096770465373993,
-0.20355072617530823,
0.5148977041244507,
0.7759077548980713,
0.030992425978183746,
-0.49895209074020386,
0.29668307304382324,
0.99702155590057... |
func NewLabels(base Arcer, r vg.Length, ls ...Labeler) (*Labels, error) {
var b ArcOfer
switch base := base.(type) {
case ArcOfer:
for _, l := range ls {
var err error
switch l := l.(type) {
case locater:
_, err = base.ArcOf(l.location(), nil)
case Feature:
_, err = base.ArcOf(l, nil)
defaul... | [
-0.46462124586105347,
-0.8889703750610352,
0.41442373394966125,
-0.2790302634239197,
-0.2912883460521698,
-0.29821673035621643,
-0.25668931007385254,
-1.160994529724121,
-0.08182600140571594,
0.440118670463562,
0.5568269491195679,
-0.09572354704141617,
0.04630390554666519,
0.39424625039100... |
func (r *Labels) DrawAt(ca draw.Canvas, cen vg.Point) {
for _, l := range r.Labels {
var sty draw.TextStyle
if ts, ok := l.(TextStyler); ok {
sty = ts.TextStyle()
} else {
sty = r.TextStyle
}
if sty.Color == nil || sty.Font.Size == 0 {
continue
}
var (
arc Arc
err error
)
switch l := ... | [
-0.9769341945648193,
-0.6181143522262573,
0.6201541423797607,
-1.6981329917907715,
0.31216418743133545,
0.5909428596496582,
0.09206724166870117,
-1.330949306488037,
-0.15577636659145355,
0.3439676761627197,
0.5167844891548157,
-0.27138277888298035,
0.5450934767723083,
0.12875673174858093,
... |
func (r *Labels) Plot(ca draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&ca)
r.DrawAt(ca, vg.Point{trX(r.X), trY(r.Y)})
} | [
-0.0529216006398201,
0.44492021203041077,
-0.03466326370835304,
-1.092953085899353,
-0.046541593968868256,
0.747054398059845,
0.4122768044471741,
-0.6435264945030212,
0.09306886792182922,
-0.18076512217521667,
0.2668408155441284,
0.823376476764679,
0.654262125492096,
-0.6248597502708435,
... |
func (r *Labels) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
return []plot.GlyphBox{{
X: plt.X.Norm(r.X),
Y: plt.Y.Norm(r.Y),
Rectangle: vg.Rectangle{
Min: vg.Point{-r.Radius, -r.Radius},
Max: vg.Point{r.Radius, r.Radius},
},
}}
} | [
-0.16289006173610687,
-0.27248743176460266,
0.4778359532356262,
-1.0963016748428345,
-0.18536701798439026,
0.4872485399246216,
0.9390225410461426,
-1.1020376682281494,
0.482037752866745,
0.41874274611473083,
-1.2891002893447876,
0.8136221170425415,
-0.30938759446144104,
-0.2711863815784454... |
func (mu mainUC) Delete(id uint) (interface{}, error) {
cat, err := mu.recipeRepo.Find(id)
if err != nil {
return nil, errors.New("recipe data not found")
}
now := time.Now()
cat.DeletedAt = &now
tx := mu.recipeRepo.DBConn().Begin()
err = mu.recipeRepo.Update(cat, tx)
if err != nil {
tx.Rollback()
return... | [
0.02625182643532753,
0.5200653076171875,
0.9493042230606079,
-0.17847511172294617,
-0.02158363349735737,
-0.274575412273407,
-0.5208479166030884,
1.0221203565597534,
-0.3515230417251587,
0.30223363637924194,
0.2617846429347992,
-0.556506872177124,
-0.31634315848350525,
0.5019744038581848,
... |
func containsOnlyDigits(s string) bool {
isNotDigit := func(c rune) bool { return c < '0' || c > '9' }
return strings.IndexFunc(s, isNotDigit) == -1
} | [
-0.008280773647129536,
0.37412378191947937,
0.027708565816283226,
-0.4159303307533264,
-0.8774794936180115,
0.032587721943855286,
0.030140381306409836,
0.27341771125793457,
0.2470524162054062,
-0.4491350054740906,
-0.18727348744869232,
0.5736634731292725,
-0.37658756971359253,
0.9745749235... |
func generateChecksum(s string) (string, error) {
// compute the Luhn value of the query
l := checkdigit.NewLuhn()
lcd, err := l.Generate(s)
if err != nil {
return "", fmt.Errorf("Failed to generate Luhn check digit")
}
v := checkdigit.NewVerhoeff()
vcd, err := v.Generate(s)
if err != nil {
return "", fmt.... | [
0.1998216062784195,
0.05243142321705818,
0.5052736401557922,
-0.32411637902259827,
-0.05970164015889168,
-0.02411160059273243,
0.2235064059495926,
0.0161997452378273,
0.7502336502075195,
-0.30040088295936584,
0.21371126174926758,
-0.33144569396972656,
-0.6009711623191833,
0.378574877977371... |
func IsValid(matricule string) (bool, error) {
r := true
if len([]rune(matricule)) != 13 {
// Matricule is of wrong size
r = false
} else if !containsOnlyDigits(matricule) {
// Matricule contains non-digit character
r = false
} else {
// compute the checksum of the matricule's root
checksum, err := gen... | [
0.6941771507263184,
-0.13715064525604248,
0.6535162329673767,
-0.6514202356338501,
0.10133259743452072,
1.0165002346038818,
-0.10595957189798355,
0.284996896982193,
0.852724552154541,
0.5545598864555359,
0.3137233853340149,
0.5163983702659607,
-0.6429773569107056,
-0.30075424909591675,
-... |
func (a Atomic) Apply(ctx Context, c Change) Value {
switch c := c.(type) {
case nil:
return a
case Replace:
if !c.IsCreate() {
return c.After
}
}
return c.(Custom).ApplyTo(ctx, a)
} | [
0.17630574107170105,
0.7652925252914429,
0.4211238920688629,
0.4889143705368042,
-0.04344579577445984,
-0.34437668323516846,
0.05644528195261955,
0.13286367058753967,
0.30119356513023376,
-0.13149887323379517,
-0.009294714778661728,
0.7848440408706665,
0.23622916638851166,
0.68323057889938... |
func TestMemory_SearchMeta(t *testing.T) {
storage := NewMemoryStorage([]shared.Feature{
{
Meta: shared.FeatureMeta{
Name: "FeatureA",
Author: "SomeAuthor",
Dependencies: []string{"FeatureB", "FeatureC"},
},
Snippet: "",
},
{
Meta: shared.FeatureMeta{
Name: "FeatureB",... | [
0.2993471920490265,
0.2819250226020813,
0.6125309467315674,
0.5729794502258301,
0.6225162744522095,
0.06242262199521065,
-0.09470731765031815,
-0.07436992973089218,
-0.5699173808097839,
-0.20470914244651794,
-0.5869343876838684,
0.2263137549161911,
-0.6279765367507935,
0.11626269668340683,... |
func NewImageProxyHandler(logger *log.Logger) *ImageProxyHandler {
stopChan := make(chan struct{})
return &ImageProxyHandler{
logger: logger,
loader: NewLoader(logger, stopChan),
stopChan: stopChan,
}
} | [
-0.8374667167663574,
-0.5501525402069092,
0.27826207876205444,
-1.311915636062622,
-1.4294142723083496,
-0.5448831915855408,
-0.04572789743542671,
-0.11580300331115723,
-0.355715274810791,
0.33528685569763184,
-0.5116198062896729,
-0.4349263310432434,
-1.046826720237732,
0.5990346074104309... |
func (h *ImageProxyHandler) getRequestStopChan(w http.ResponseWriter) <-chan struct{} {
if cn, ok := w.(http.CloseNotifier); ok {
stopChan := make(chan struct{})
closeConnChan := cn.CloseNotify()
go func() {
select {
case <-h.stopChan:
h.logger.Println("processing interrupted")
case <-closeConnChan... | [
-0.6808211207389832,
-0.43826213479042053,
0.8710699677467346,
-0.8651155233383179,
0.21000151336193085,
0.4038578271865845,
0.3617348074913025,
-1.2734661102294922,
-0.4619791805744171,
-1.083709716796875,
0.9184531569480896,
-0.3673451840877533,
-0.8432135581970215,
-0.09488021582365036,... |
func (h *ImageProxyHandler) Stop() {
close(h.stopChan)
} | [
-0.8737343549728394,
-0.07156266272068024,
0.17594388127326965,
-1.4348642826080322,
-0.007019050884991884,
0.6069300174713135,
0.565804123878479,
0.35763540863990784,
-1.2834129333496094,
-0.09561574459075928,
-0.45815718173980713,
0.038295164704322815,
-1.0251426696777344,
0.853593647480... |
func (h *ImageProxyHandler) imagesHTML(w http.ResponseWriter, dataURLChan <-chan *dataurl.DataURL) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
w.WriteHeader(http.StatusOK)
if err := imagesPageTmpl.Execute(w, dataURLChan); err != nil {
h.logger.Println("writing html response error:", err)
}
} | [
-1.2216535806655884,
0.8325914144515991,
0.2304076999425888,
-1.1602097749710083,
0.11855756491422653,
-0.3820611834526062,
0.09904992580413818,
0.2936965525150299,
-0.7681148052215576,
0.4707573652267456,
0.08194959163665771,
-0.05687360838055611,
-0.12272155284881592,
0.16232623159885406... |
func (pg *PGClient) CreateLoginToken(email string, language string) (string, error) {
// We deliberately don't validate the email address here. Email
// addresses are a mess, and the simplest thing to do is just to
// send an email to the address. If it doesn't work, then the entry
// in the login_tokens table we c... | [
-0.3904712200164795,
0.3173908591270447,
0.8002611994743347,
-0.9453192949295044,
-0.4819377362728119,
-0.14928996562957764,
-0.6158652305603027,
-0.04122191295027733,
-0.22098888456821442,
0.03454821929335594,
-0.28181809186935425,
0.05934334173798561,
-0.8662478923797607,
-1.100293278694... |
func (pg *PGClient) CheckLoginToken(token string) (string, string, error) {
// In a transaction...
tx, err := pg.DB.Beginx()
if err != nil {
return "", "", err
}
defer func() {
switch err {
case nil:
err = tx.Commit()
default:
tx.Rollback()
}
}()
// Look up token.
tokInfo := TokenInfo{}
err = ... | [
-0.43339625000953674,
-0.492252916097641,
0.8966994881629944,
-0.8533633947372437,
-0.7915821671485901,
-0.4105075001716614,
-0.8298905491828918,
-0.44248080253601074,
-0.5939775705337524,
0.7227771878242493,
-0.29955345392227173,
0.3326433002948761,
-0.6406567692756653,
-0.502829670906066... |
func (pg *PGClient) CreateSession(thID int) (string, error) {
// In a transaction...
tx, err := pg.DB.Beginx()
if err != nil {
return "", err
}
defer func() {
switch err {
case nil:
err = tx.Commit()
default:
tx.Rollback()
}
}()
// Look up existing session.
token := ""
err = tx.Get(&token, ses... | [
-0.0026424110401421785,
0.04170345142483711,
0.7689185738563538,
-0.7208874821662903,
0.3386451005935669,
-0.43901005387306213,
0.4901382029056549,
-1.4303758144378662,
-0.19947628676891327,
0.8700451254844666,
-0.06505504995584488,
-0.7037301063537598,
-0.6128709316253662,
-0.772973120212... |
func (pg *PGClient) LookupSession(token string) (*int, error) {
sess := model.Session{}
err := pg.DB.Get(&sess, lookupSession, token)
if err == sql.ErrNoRows {
return nil, ErrSessionNotFound
}
if err != nil {
return nil, err
}
return sess.TherapistID, nil
} | [
-0.537513792514801,
0.08189801871776581,
0.7709023952484131,
-1.545449137687683,
-0.657450258731842,
-0.6871585249900818,
0.3038919270038605,
-1.1359446048736572,
0.8231619596481323,
0.1234695091843605,
-0.052253492176532745,
-0.14636343717575073,
-0.6320028901100159,
-0.2952876091003418,
... |
func (pg *PGClient) DeleteSessions(thID int) error {
_, err := pg.DB.Exec(`DELETE FROM sessions WHERE therapist_id = $1`, thID)
if err != nil {
return err
}
return nil
} | [
0.5001882910728455,
0.17585057020187378,
0.001988649368286133,
-0.5289027094841003,
0.8764692544937134,
-0.18148599565029144,
1.2042402029037476,
-1.4057321548461914,
0.6424492597579956,
0.24208660423755646,
-0.1266060471534729,
-0.5378094911575317,
-0.940941333770752,
0.1685856431722641,
... |
func RandToken() string {
return RandString(dChars, dCharIdxBits, dCharIdxMask, dCharIdxMax,
tokenLen)
} | [
0.26882871985435486,
0.3250944912433624,
0.19823329150676727,
-0.8599168062210083,
0.3025050461292267,
0.1014585942029953,
-0.06605320423841476,
0.24559535086154938,
0.31717804074287415,
-0.9657142162322998,
-0.6045699715614319,
0.9550243020057678,
0.25730565190315247,
-0.40702080726623535... |
func (a *Sortable) Len() int {
return len(a.List)
} | [
-0.01493507344275713,
0.025087323039770126,
0.03318336233496666,
-0.16306930780410767,
0.1839245706796646,
-0.2502219080924988,
0.6422190070152283,
0.8092698454856873,
0.012943404726684093,
-0.5675653219223022,
-1.039617657661438,
0.23589852452278137,
0.49268749356269836,
0.203092575073242... |
func (a *Sortable) Less(i, j int) bool {
return a.Cmp(a.List[i], a.List[j]) < 0
} | [
-0.1827014535665512,
-0.19106771051883698,
0.3530488908290863,
-0.3638300597667694,
-0.595718264579773,
-0.01656670682132244,
-0.3830089569091797,
-1.2359322309494019,
-0.6021763682365417,
-0.5496125817298889,
-0.8510319590568542,
-0.49909013509750366,
-0.5154064297676086,
0.62451130151748... |
func (a *Sortable) Swap(i, j int) {
a.List[i], a.List[j] = a.List[j], a.List[i]
} | [
-1.6806567907333374,
-0.3239084780216217,
0.2868380546569824,
-0.07403254508972168,
0.04561552405357361,
0.3170318305492401,
-0.10929884016513824,
0.18635134398937225,
-0.691119909286499,
-0.29099416732788086,
-0.715053141117096,
0.040810391306877136,
0.30572590231895447,
-0.32703757286071... |
func ShowPreferencesDialog(parent gtk.IWindow, onMpdReconnect, onQueueColumnsChanged, onPlayerSettingChanged func()) {
// Create the dialog
d := &PrefsDialog{
onQueueColumnsChanged: onQueueColumnsChanged,
onPlayerSettingChanged: onPlayerSettingChanged,
}
// Load the dialog layout and map the widgets
builder,... | [
0.46592289209365845,
0.2134590893983841,
0.7655931711196899,
-0.38892051577568054,
-0.5787244439125061,
0.024808356538414955,
0.29774463176727295,
0.21705320477485657,
-0.03407201170921326,
0.22060562670230865,
0.2395269125699997,
0.5686426162719727,
-0.05361340567469597,
0.390046209096908... |
func (d *PrefsDialog) addQueueColumn(attrID, width int, selected bool) {
// Add an entry to queue columns slice
d.queueColumns = append(d.queueColumns, queueCol{selected: selected, id: attrID, width: width})
// Add a new list box row
row, err := gtk.ListBoxRowNew()
if errCheck(err, "ListBoxRowNew() failed") {
r... | [
-0.24203352630138397,
-0.6011990904808044,
0.946896493434906,
-0.9738088250160217,
0.01487462967634201,
0.0011766542447730899,
-0.02885737083852291,
-0.6293694376945496,
0.2513465881347656,
0.02619670145213604,
-0.684598445892334,
0.6950621604919434,
0.7845267653465271,
0.32807856798171997... |
func (d *PrefsDialog) columnCheckboxToggled(id int, selected bool, row *gtk.ListBoxRow) {
// Find and toggle the column for the attribute
if i := d.indexOfColumnWithAttrID(id); i >= 0 {
d.queueColumns[i].selected = selected
// Select the row
d.ColumnsListBox.SelectRow(row)
// Update the queue columns
d.no... | [
-0.3397684395313263,
-0.7217854261398315,
0.4467388987541199,
-0.29494380950927734,
0.7230983972549438,
-0.048491545021533966,
0.16742952167987823,
0.1562717705965042,
0.6329607963562012,
0.401354044675827,
-0.46109187602996826,
0.7542636394500732,
0.7316774129867554,
-0.2434820681810379,
... |
func (d *PrefsDialog) indexOfColumnWithAttrID(id int) int {
for i := range d.queueColumns {
if id == d.queueColumns[i].id {
return i
}
}
return -1
} | [
0.17003650963306427,
-1.2950024604797363,
0.18933267891407013,
-1.1662427186965942,
-0.741219162940979,
-0.7884131669998169,
0.46314769983291626,
-1.1854681968688965,
-0.1934860497713089,
0.2850140333175659,
-0.28348246216773987,
1.0079376697540283,
0.8859516978263855,
-0.42316651344299316... |
func (d *PrefsDialog) moveSelectedColumnRow(up bool) {
// Get and check the selection
row := d.ColumnsListBox.GetSelectedRow()
if row == nil {
return
}
// Get the row's index in the list
index := row.GetIndex()
if index < 0 || (up && index == 0) || (!up && index >= len(d.queueColumns)-1) {
return
}
// Re... | [
-0.37394633889198303,
-0.262825608253479,
0.7162697911262512,
0.29789888858795166,
-0.38991039991378784,
-0.6109238862991333,
0.6561564803123474,
-0.0761633813381195,
0.6940866112709045,
-0.1680077463388443,
-0.3624133765697479,
0.6230663061141968,
0.4534938931465149,
-0.010323302820324898... |
func (d *PrefsDialog) notifyColumnsChanged() {
// Collect IDs of selected attributes
var colSpecs []config.ColumnSpec
for _, col := range d.queueColumns {
if col.selected {
colSpecs = append(colSpecs, config.ColumnSpec{ID: col.id, Width: col.width})
}
}
// Save the IDs in the config
config.GetConfig().Que... | [
-0.16541647911071777,
-0.5510106682777405,
0.07304788380861282,
-0.45327383279800415,
0.01568903587758541,
-0.3597256541252136,
-0.2566799223423004,
-0.19435493648052216,
0.18623656034469604,
0.7173448204994202,
-1.1406596899032593,
1.1676418781280518,
1.1168426275253296,
0.745195150375366... |
func (d *PrefsDialog) onColumnMoveUp() {
d.moveSelectedColumnRow(true)
} | [
-0.17520977556705475,
-0.795031726360321,
0.3483303487300873,
0.39737269282341003,
-0.6438713669776917,
-0.8636406660079956,
0.42620232701301575,
0.02565561793744564,
0.540086030960083,
0.8676455020904541,
-0.24389362335205078,
0.3604412376880646,
0.8114107251167297,
-0.6972103118896484,
... |
func (d *PrefsDialog) onColumnMoveDown() {
d.moveSelectedColumnRow(false)
} | [
0.5603919625282288,
-1.1594773530960083,
0.26039206981658936,
0.48528510332107544,
-0.3812587261199951,
-0.4361959397792816,
0.9165745973587036,
0.08494537323713303,
0.43768075108528137,
-0.06505347788333893,
-0.3738161027431488,
0.33865270018577576,
0.33039966225624084,
0.0451473444700241... |
func (d *PrefsDialog) onSettingChange() {
// Ignore if the dialog is not initialised yet
if !d.initialised {
return
}
log.Debug("onSettingChange()")
// Collect settings
cfg := config.GetConfig()
// General page
cfg.MpdNetwork = d.MpdNetworkComboBox.GetActiveID()
cfg.MpdSocketPath = util.EntryText(d.MpdPathE... | [
-0.35351037979125977,
-0.40248990058898926,
0.6449817419052124,
-0.21966272592544556,
0.02528233639895916,
-0.10138432681560516,
0.29091817140579224,
0.12295740842819214,
0.06183849275112152,
0.8096635937690735,
-0.02251158282160759,
0.13907380402088165,
-0.05178380012512207,
1.28596031665... |
func (d *PrefsDialog) populateColumns() {
// First add selected columns
selColSpecs := config.GetConfig().QueueColumns
for _, colSpec := range selColSpecs {
d.addQueueColumn(colSpec.ID, colSpec.Width, true)
}
// Add all unselected columns
for _, id := range config.MpdTrackAttributeIds {
// Check if the ID is... | [
-0.31024035811424255,
0.0430806428194046,
0.5952195525169373,
-0.7939732670783997,
0.9976363182067871,
0.03168775886297226,
0.09559320658445358,
-0.3502967655658722,
0.14714986085891724,
-0.09310698509216309,
-0.6429231762886047,
0.7702537775039673,
0.7484737038612366,
0.5210478901863098,
... |
func (d *PrefsDialog) updateGeneralWidgets() {
network := d.MpdNetworkComboBox.GetActiveID()
unix, tcp := network == "unix", network == "tcp"
d.MpdPathEntry.SetVisible(unix)
d.MpdPathLabel.SetVisible(unix)
d.MpdHostEntry.SetVisible(tcp)
d.MpdHostLabel.SetVisible(tcp)
d.MpdHostLabelRemark.SetVisible(tcp)
d.MpdPo... | [
-0.7436214089393616,
-0.13363482058048248,
0.5329588651657104,
-0.8712735772132874,
-0.43689149618148804,
1.0033985376358032,
-0.13465608656406403,
1.262367606163025,
0.009500818327069283,
0.5656418800354004,
0.06726191192865372,
1.0715411901474,
-0.41083040833473206,
0.7914839386940002,
... |
func SpiderLoad(URL string, ch chan *imgNode) error {
resp, err := http.Get(URL)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return err
}
n, err := html.Parse(resp.Body)
if err != nil {
return err
}
forEachNode(resp, n, ch)
return nil
} | [
-0.4084562063217163,
0.2014523595571518,
1.006719946861267,
-1.0194262266159058,
-0.016376907005906105,
0.18086577951908112,
-0.5596693158149719,
-0.009360117837786674,
-0.1866648644208908,
0.4029609262943268,
-0.668100893497467,
0.5649412870407104,
-0.14575617015361786,
-0.320050954818725... |
func NewReporter(c config.Config) (*Reporter, error) {
conn, err := storage.NewMySQL(c)
if err != nil {
return nil, err
}
r := &Reporter{db: conn, Config: c}
return r, nil
} | [
0.3704896867275238,
-0.2639778256416321,
0.19491896033287048,
0.16291682422161102,
0.022518452256917953,
-0.07955291122198105,
-0.26818761229515076,
0.15223102271556854,
-0.2868213355541229,
-0.1550663709640503,
-0.7770724296569824,
-0.68656325340271,
-0.6806389093399048,
1.048312902450561... |
func (r *Reporter) StandupReportByProject(channel model.Channel, dateFrom, dateTo time.Time) (string, error) {
reportHead := fmt.Sprintf(r.Config.Translate.ReportOnProjectHead, channel.ChannelName, dateFrom.Format("2006-01-02"), dateTo.Format("2006-01-02"))
dateFromBegin, numberOfDays, err := r.setupDays(dateFrom, da... | [
-0.47243666648864746,
0.16124649345874786,
0.7736556529998779,
-0.4681958854198456,
-0.06142035499215126,
0.3564437925815582,
0.586873471736908,
-0.7885926961898804,
-0.8360559344291687,
0.46572309732437134,
-0.0019356681732460856,
-0.0754314437508583,
-0.4056415259838104,
0.32031801342964... |
func (r *Reporter) StandupReportByUser(slackUserID string, dateFrom, dateTo time.Time) (string, error) {
reportHead := fmt.Sprintf(r.Config.Translate.ReportOnUserHead, slackUserID, dateFrom.Format("2006-01-02"), dateTo.Format("2006-01-02"))
reportBody := ""
dateFromBegin, numberOfDays, err := r.setupDays(dateFrom, ... | [
-0.11688125878572464,
0.3052016496658325,
1.0663342475891113,
-0.3754841089248657,
-0.06902223825454712,
-0.10107207298278809,
0.5965715646743774,
-0.8198314309120178,
-0.9520750641822815,
0.19020554423332214,
-0.09462608397006989,
-0.07061542570590973,
0.28126388788223267,
0.2184228897094... |
func (r *Reporter) StandupReportByProjectAndUser(channel model.Channel, slackUserID string, dateFrom, dateTo time.Time) (string, error) {
reportHead := fmt.Sprintf(r.Config.Translate.ReportOnProjectAndUserHead, slackUserID, channel.ChannelName, dateFrom.Format("2006-01-02"), dateTo.Format("2006-01-02"))
dateFromBegin... | [
-0.11643367260694504,
0.14762720465660095,
0.8502976894378662,
-0.5526480674743652,
0.0002847568830475211,
0.3432207405567169,
0.3337984085083008,
-0.6950242519378662,
-1.073494553565979,
-0.14282739162445068,
0.1764947921037674,
0.14402805268764496,
-0.17865531146526337,
0.204920426011085... |
func (r *Reporter) setupDays(dateFrom, dateTo time.Time) (time.Time, int, error) {
if dateTo.Before(dateFrom) {
return time.Now(), 0, errors.New(r.Config.Translate.DateError1)
}
if dateTo.After(time.Now()) {
return time.Now(), 0, errors.New(r.Config.Translate.DateError2)
}
dateFromRounded := time.Date(dateFrom... | [
-0.2531391978263855,
0.9271824359893799,
0.6904354095458984,
-1.3326202630996704,
-0.19181405007839203,
-0.2821727395057678,
-0.1701716184616089,
-0.03431035205721855,
-0.48066556453704834,
-0.0073419553227722645,
0.15386322140693665,
0.025712652131915092,
0.6447723507881165,
0.68166750669... |
func AssignFinishingLabel(node *GraphNode, graph *DirGraph, nodeArray *[]*GraphNode) {
node.visited = true
var neighborLabel int
for _, neighborLabel = range node.rEdges {
if graph.graphNodes[neighborLabel].visited == false {
AssignFinishingLabel(graph.graphNodes[neighborLabel], graph, nodeArray)
}
}
(*node... | [
-1.4835478067398071,
-0.6062794923782349,
0.6246216893196106,
-0.2805839478969574,
0.35973525047302246,
0.7494108080863953,
0.11434607207775116,
-0.6278576850891113,
-0.4105387032032013,
1.173519492149353,
0.32462358474731445,
0.509771466255188,
-0.2653302848339081,
1.1786023378372192,
0... |
func MarkStrongConnections(node *GraphNode, graph *DirGraph, id int) {
node.visited = true
node.ID = id
var neighborLabel int
for _, neighborLabel = range node.graphEdges {
if graph.graphNodes[neighborLabel].visited == false {
MarkStrongConnections(graph.graphNodes[neighborLabel], graph, id)
}
}
} | [
-0.09210090339183807,
-0.1221766322851181,
0.4020686745643616,
-0.05083974078297615,
0.8155508637428284,
-0.2854861319065094,
1.0660122632980347,
-0.11085949093103409,
0.1324140727519989,
-0.1891622692346573,
-0.4750657379627228,
0.886277973651886,
-0.0977778211236,
0.44775912165641785,
... |
func (graph *DirGraph) createStrongConnections() {
var l int
l = 0
var nodes []*GraphNode
nodes = graph.setFinishingOrder()
graph.reset()
var i int
for i = len(nodes) - 1; i >= 0; i-- {
var node *GraphNode
node = nodes[i]
if node.visited == false {
var m int
m = l
l++
MarkStrongConnections(node... | [
-0.4670986533164978,
0.4618127942085266,
0.466890811920166,
0.18454308807849884,
1.0103821754455566,
-0.7189030051231384,
1.4903393983840942,
-0.11354635655879974,
-0.012132394127547741,
-0.4430997371673584,
-0.5234920382499695,
0.3111475110054016,
-0.10178789496421814,
0.19912125170230865... |
func (graph *DirGraph) showTopFiveStrongConnections() {
var aMap map[int]int
aMap = make(map[int]int)
var node *GraphNode
for _, node = range graph.graphNodes {
if node.ID == -1 {
panic(fmt.Sprintf("Error - Expected ID to be set (> -1), actual value is %d.", node.ID))
}
aMap[node.ID]++
}
var id int
var... | [
-0.03537796065211296,
-0.3128076493740082,
0.712313711643219,
-0.418438583612442,
-0.03499942645430565,
-0.6166809797286987,
1.2262475490570068,
-0.7348809242248535,
-0.3846169412136078,
0.16024149954319,
-0.4354885220527649,
0.3989882469177246,
-0.40072622895240784,
-0.04345352202653885,
... |
func loadConfiguration() Config {
var conf Config
_, b, _, _ := runtime.Caller(0)
basepath := filepath.Dir(b)
filename := fmt.Sprintf("%s/config.json", basepath)
configFile, err := os.Open(filename)
defer configFile.Close()
if err != nil {
log.Println(err.Error())
}
jsonParser := json.NewDecoder(configFile)
... | [
-0.9631060361862183,
-0.6276717185974121,
0.811038076877594,
-0.15588143467903137,
-0.00923195667564869,
-0.19200153648853302,
-0.47275328636169434,
0.04036334156990051,
-1.0050663948059082,
0.855281412601471,
-0.659060001373291,
-0.06507723033428192,
-0.08188632130622864,
1.48977100849151... |
func newAssert(t *testing.T) func(args ...interface{}) *rpcAssert {
return func(args ...interface{}) *rpcAssert {
return &rpcAssert{
t: t,
args: args,
}
}
} | [
0.20343638956546783,
-1.3084920644760132,
0.5872977375984192,
-0.47479647397994995,
-0.91904616355896,
0.33029699325561523,
0.30418258905410767,
-0.47008195519447327,
-0.19735287129878998,
-0.1779126524925232,
0.37870413064956665,
0.47396475076675415,
-1.2287551164627075,
0.468499571084976... |
func InitConfig() (err error) {
Conf = NewConfig()
gconf = goconf.New()
if err = gconf.Parse(confFile); err != nil {
return err
}
if err = gconf.Unmarshal(Conf); err != nil {
return err
}
var serverIDi int64
for _, serverID := range gconf.Get("comet.addrs").Keys() {
addr, err := gconf.Get("comet.addrs").S... | [
0.13676877319812775,
0.1027057021856308,
0.642768919467926,
-1.2661139965057373,
0.4444344639778137,
0.5113540291786194,
0.16286501288414001,
1.2282395362854004,
-1.2304887771606445,
0.6290978193283081,
-1.2746695280075073,
0.7139760255813599,
-0.15216997265815735,
1.1467865705490112,
1.... |
func Multicase(cases interface{}, function interface{}) func() {
arr := reflect.ValueOf(cases)
if arr.Kind() != reflect.Array && arr.Kind() != reflect.Slice {
panic("cases must be an array")
}
if arr.Len() <= 0 {
panic("there is at least one value in cases")
}
f := reflect.ValueOf(function)
if f.Kind() != re... | [
0.05612364783883095,
-0.08761467784643173,
1.1098893880844116,
1.0555163621902466,
-0.29673120379447937,
0.14951127767562866,
0.40057313442230225,
-0.141588494181633,
0.38505053520202637,
0.6274495124816895,
0.763719379901886,
0.055559396743774414,
0.19538496434688568,
1.0054975748062134,
... |
func NewShellTask(name string, cmd string, args []string) *ShellTask {
return NewShellTaskWithUser(name, "", cmd, args)
} | [
0.7130659222602844,
-0.658726692199707,
0.35367363691329956,
0.8780079483985901,
-0.9904173612594604,
-0.056376755237579346,
-1.0474704504013062,
-0.16158489882946014,
-0.3237668573856354,
-0.25228750705718994,
-1.6523499488830566,
1.1397145986557007,
0.31652212142944336,
0.447678804397583... |
func NewShellTaskWithUser(name string, user string, cmd string, args []string) *ShellTask {
return &ShellTask{
name: name,
user: user,
cmd: cmd,
args: args,
exitCode: &atomic.Value{},
stdout: util.NewBuffer(MaxBufferCapacity),
stderr: util.NewBuffer(MaxBufferCapacity),
}
} | [
0.7149178385734558,
-0.8121402263641357,
0.43295037746429443,
0.8625696897506714,
-1.3164215087890625,
-0.11726386100053787,
-0.6145498752593994,
-0.2987590432167053,
-0.6690759062767029,
-0.1881605088710785,
-1.2506073713302612,
0.8973362445831299,
0.3574828505516052,
0.2565668523311615,
... |
func (s *ShellTask) TaskName() string {
return s.name
} | [
0.04568934068083763,
-0.4741104543209076,
0.30886515974998474,
0.4048130214214325,
-0.8661091923713684,
0.37665659189224243,
0.9913061261177063,
0.5626031756401062,
-0.45831099152565,
0.07369363307952881,
-0.6534179449081421,
0.5628311634063721,
0.7861104607582092,
0.23384952545166016,
-... |
func (s *ShellTask) Command(ctx context.Context, name string, arg ...string) (*exec.Cmd, error) {
userDetail, err := util.UserInfo(s.user)
if err != nil {
return nil, err
}
util.FileLogger().Debugf(ctx, "Using user: %s, uid: %d, gid: %d",
userDetail.User.Username, userDetail.UserID, userDetail.GroupID)
env := ... | [
-0.07168737798929214,
-0.38293325901031494,
0.71880042552948,
0.4768640398979187,
0.32767200469970703,
1.3821431398391724,
-0.07809245586395264,
-0.08876130729913712,
-0.06835808604955673,
-0.15985502302646637,
0.05127786844968796,
0.9891389012336731,
0.5838655829429626,
0.4396975040435791... |
func (s *ShellTask) Process(ctx context.Context) (*TaskStatus, error) {
util.FileLogger().Debugf(ctx, "Starting the command - %s", s.name)
taskStatus := &TaskStatus{Info: s.stdout, ExitStatus: &ExitStatus{Code: 1, Error: s.stderr}}
cmd, err := s.Command(ctx, s.cmd, s.args...)
if err != nil {
util.FileLogger().Err... | [
-0.276615709066391,
-0.3319253921508789,
0.9427300691604614,
-0.08641570061445236,
-0.08828829973936081,
0.05993352457880974,
-0.08365808427333832,
0.46920862793922424,
0.3574488162994385,
-0.058702897280454636,
-0.30459722876548767,
0.4095602333545685,
0.7680902481079102,
1.26525449752807... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.