//------------------------------------------------------------------------------
195799
func (c *cmdable) MemoryUsage(key string, samples ...int) *IntCmd {
	args := []interface{}{"memory", "usage", key}
	if len(samples) > 0 {
		if len(samples) != 1 {
			panic("MemoryUsage expects single sample count")
		}
		args = append(args, "SAMPLES", samples[0])
	}
	cmd := NewIntCmd(args...)
	c.process(cmd)
	return cmd
}
932911
func main() {
	args := map[string]string{}
	gp := geopattern.URIimage(args)
	fmt.Println(gp)
}
1117443
func Tr(lang, format string, args ...interface{}) string {
	var section string

	idx := strings.IndexByte(format, '.')
	if idx > 0 {
		section = format[:idx]
		format = format[idx+1:]
	}

	value, ok := locales.Get(lang, section, format)
	if ok {
		format = value
	}

	if len(args) > 0 {
		params := make([]interface{}, 0, len(args))
		for _, arg := range args {
			if arg == nil {
				continue
			}

			val := reflect.ValueOf(arg)
			if val.Kind() == reflect.Slice {
				for i := 0; i < val.Len(); i++ {
					params = append(params, val.Index(i).Interface())
				}
			} else {
				params = append(params, arg)
			}
		}
		return fmt.Sprintf(format, params...)
	}
	return format
}
55873
func main() {
	svc := stringService{}

	natsURL := flag.String("nats-url", nats.DefaultURL, "URL for connection to NATS")
	flag.Parse()

	nc, err := nats.Connect(*natsURL)
	if err != nil {
		log.Fatal(err)
	}
	defer nc.Close()

	uppercaseHTTPHandler := httptransport.NewServer(
		makeUppercaseHTTPEndpoint(nc),
		decodeUppercaseHTTPRequest,
		httptransport.EncodeJSONResponse,
	)

	countHTTPHandler := httptransport.NewServer(
		makeCountHTTPEndpoint(nc),
		decodeCountHTTPRequest,
		httptransport.EncodeJSONResponse,
	)

	uppercaseHandler := natstransport.NewSubscriber(
		makeUppercaseEndpoint(svc),
		decodeUppercaseRequest,
		natstransport.EncodeJSONResponse,
	)

	countHandler := natstransport.NewSubscriber(
		makeCountEndpoint(svc),
		decodeCountRequest,
		natstransport.EncodeJSONResponse,
	)

	uSub, err := nc.QueueSubscribe("stringsvc.uppercase", "stringsvc", uppercaseHandler.ServeMsg(nc))
	if err != nil {
		log.Fatal(err)
	}
	defer uSub.Unsubscribe()

	cSub, err := nc.QueueSubscribe("stringsvc.count", "stringsvc", countHandler.ServeMsg(nc))
	if err != nil {
		log.Fatal(err)
	}
	defer cSub.Unsubscribe()

	http.Handle("/uppercase", uppercaseHTTPHandler)
	http.Handle("/count", countHTTPHandler)
	log.Fatal(http.ListenAndServe(":8080", nil))

}
251478
func Status(status int) {
	if r, ok := responseDefinition(); ok {
		r.Status = status
	}
}
1226218
func (ListServiceOfferings) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListServiceOfferingsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListServiceOfferingsResponse was expected, got %T", resp))
		return
	}

	for i := range items.ServiceOffering {
		if !callback(&items.ServiceOffering[i], nil) {
			break
		}
	}
}
968498
func (c *Callbacks) OnCDOTAUserMsg_ReplaceQueryUnit(fn func(*dota.CDOTAUserMsg_ReplaceQueryUnit) error) {
	c.onCDOTAUserMsg_ReplaceQueryUnit = append(c.onCDOTAUserMsg_ReplaceQueryUnit, fn)
}
268241
func (v versionMessage) String() string {
	return console.Colorize("Version", fmt.Sprintf("Version: %s\n", v.Version.Value)) +
		console.Colorize("ReleaseTag", fmt.Sprintf("Release-tag: %s\n", v.ReleaseTag)) +
		console.Colorize("CommitID", fmt.Sprintf("Commit-id: %s", v.CommitID))
}
821553
func T(defaultValue string, args ...int) string {
	if len(args) == 0 {
		return gettext.PGettext("", defaultValue)
	}
	return fmt.Sprintf(gettext.PNGettext("", defaultValue, defaultValue+".plural", args[0]),
		args[0])
}
83108
func init() {
	Skins.db = make(map[string]Skin)

	Skins.AddSkin("default", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(███)═╝"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(███)═╗"},
		},
	})

	Skins.AddSkin("frozen", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(❄❄❄)═╝"},
			Tail: "    ❄    ",
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(❄❄❄)═╗"},
			Tail: "    ❄    ",
		},
	})

	Skins.AddSkin("diagonals", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"\\/(███)\\/", "/\\(███)/\\"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"/\\(███)/\\", "\\/(███)\\/"},
		},
	})

	Skins.AddSkin("corporate", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(©©©)═╝"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(©©©)═╗"},
		},
	})

	Skins.AddSkin("love", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(♥♥♥)═╝"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(♥♥♥)═╗"},
		},
	})

	Skins.AddSkin("musician", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(♫♩♬)═╝"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(♫♩♬)═╗"},
		},
	})

	Skins.AddSkin("bocal", Skin{
		Up: &SkinDirection{
			Head: "  ╚⊙ ⊙╝  ",
			Pede: []string{"╚═(🐟🐟🐟)═╝"},
		},
		Down: &SkinDirection{
			Head: "  ╔⊙ ⊙╗  ",
			Pede: []string{"╔═(🐟🐟🐟)═╗"},
		},
	})

	Skins.AddSkin("ascii", Skin{
		Up: &SkinDirection{
			Head: "  \\o o/  ",
			Pede: []string{"|=(###)=|"},
		},
		Down: &SkinDirection{
			Head: "  /o o\\  ",
			Pede: []string{"|=(###)=|"},
		},
	})

	Skins.AddSkin("inception", Skin{
		Up: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╚═(🐛🐛🐛)═╝"},
		},
		Down: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╔═(🐛🐛🐛)═╗"},
		},
	})

	Skins.AddSkin("humancentipede", Skin{
		Up: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╚═(😷😷😷)═╝"},
		},
		Down: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╔═(😷😷😷)═╗"},
		},
	})

	Skins.AddSkin("finger", Skin{
		Up: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"👈~~~  ~~~👉"},
		},
		Down: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"👈~~~~~~~~👉"},
		},
	})

	Skins.AddSkin("handy", Skin{
		Up: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╚═(👌👌👌)═╝"},
		},
		Down: &SkinDirection{
			Head: "    👀    ",
			Pede: []string{"╔═(👌👌👌)═╗"},
		},
	})

	Skins.AddSkin("human", Skin{
		Up: &SkinDirection{
			Head: " ( ͡° ͜ʖ ͡°)",
			Pede: []string{"👆 ......👆"},
		},
		Down: &SkinDirection{
			Head: " ( ͡° ͜ʖ ͡°)",
			Pede: []string{"👇 ......👇"},
		},
	})
}
543971
func (s *AffinityGroupService) GetAffinityGroupByName(name string, opts ...OptionFunc) (*AffinityGroup, int, error) {
	id, count, err := s.GetAffinityGroupID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetAffinityGroupByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
1133796
func (m *Dialect) Init() {
	if m.inited {
		return
	}
	m.inited = true
	for _, s := range m.Statements {
		s.init()
	}
}
1344265
func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "index.html")
	})

	//When asked to log in, generate a unique state and store the entered values in a cookie to retreive on callback
	http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
		r.ParseForm()
		s := &sessionInformation{
			ClientID:        r.FormValue("client_id"),
			Secret:          r.FormValue("secret"),
			RequestedScopes: r.FormValue("requested_scopes"),
		}
		fmt.Printf("Logging in to %s with secret %s and asking for scopes %s\n", s.ClientID, s.Secret, s.RequestedScopes)

		randombytes := make([]byte, 12) //Multiple of 3 to make sure no padding is added
		rand.Read(randombytes)
		state := base64.URLEncoding.EncodeToString(randombytes)

		serializedSessionInformation, _ := json.Marshal(s)
		sessionCookie := &http.Cookie{
			Name:   state,
			Value:  base64.URLEncoding.EncodeToString(serializedSessionInformation),
			MaxAge: 5 * 60, // 5 minutes
		}
		http.SetCookie(w, sessionCookie)

		u, _ := url.Parse("https://dev.itsyou.online:8443/v1/oauth/authorize")
		q := u.Query()
		q.Add("client_id", s.ClientID)
		q.Add("redirect_uri", "http://localhost:8080/callback")
		q.Add("scope", s.RequestedScopes)
		q.Add("state", state)
		q.Add("response_type", "code")
		u.RawQuery = q.Encode()
		http.Redirect(w, r, u.String(), http.StatusFound)
	})

	http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
		r.ParseForm()
		code := r.FormValue("code")
		fmt.Println("Code: ", code)
		state := r.FormValue("state")

		sessionCookie, err := r.Cookie(state)
		if err != nil || sessionCookie == nil {
			fmt.Println("Failed to retrieve session cookie: ", err)
			fmt.Println("Cookie: ", sessionCookie)
			return
		}

		fmt.Println("Cookie value: ", sessionCookie.Value)

		decodedCookie, err := base64.URLEncoding.DecodeString(sessionCookie.Value)
		if err != nil {
			fmt.Println("Could not decode session cookie value: ", err)
		}
		s := &sessionInformation{}

		err = json.Unmarshal(decodedCookie, s)
		if err != nil {
			fmt.Println("Failed to convert session cookie: ", err)
			return
		}

		fmt.Println(s)

		tr := &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		}
		hc := &http.Client{Transport: tr}
		req, err := http.NewRequest("POST", "https://dev.itsyou.online:8443/v1/oauth/access_token", nil)
		if err != nil {
			return
		}
		q := req.URL.Query()
		q.Add("client_id", s.ClientID)
		q.Add("client_secret", s.Secret)
		q.Add("code", code)
		q.Add("redirect_uri", "http://localhost:8080/callback")
		q.Add("state", state)
		req.URL.RawQuery = q.Encode()

		resp, err := hc.Do(req)
		if err != nil {
			fmt.Println("Error while getting the access token: ", err)
			return
		}
		defer resp.Body.Close()

		body, err := ioutil.ReadAll(resp.Body)

		fmt.Println("Response body: ", string(body))
		return

	})

	log.Fatal(http.ListenAndServe(":8080", nil))

}
159111
func (s *AffinityGroupService) GetAffinityGroupByID(id string, opts ...OptionFunc) (*AffinityGroup, int, error) {
	p := &ListAffinityGroupsParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListAffinityGroups(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	// This is needed because of a bug with the listAffinityGroup call. It reports the
	// number of VirtualMachines in the groups as being the number of groups found.
	l.Count = len(l.AffinityGroups)

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.AffinityGroups[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for AffinityGroup UUID: %s!", id)
}
227197
func init() {
	for k, v := range ChanModeToString {
		StringToChanMode[v] = k
	}
	for k, v := range ChanPrivToString {
		StringToChanPriv[v] = k
	}
	for k, v := range ChanPrivToModeChar {
		ModeCharToChanPriv[v] = k
	}
}
472385
func (gbi *groupByIterator) nextAtIdx(i int) {
	// loop until we find a non-empty row. This is an optimization - the loop and if/break can be removed.
	for {
		nr, rowID, wrapped := gbi.rowIters[i].Next()
		if nr == nil {
			gbi.done = true
			return
		}
		if wrapped && i != 0 {
			gbi.nextAtIdx(i - 1)
		}
		if i == 0 && gbi.filter != nil {
			gbi.rows[i].row = nr.Intersect(gbi.filter)
		} else if i == 0 || i == len(gbi.rows)-1 {
			gbi.rows[i].row = nr
		} else {
			gbi.rows[i].row = nr.Intersect(gbi.rows[i-1].row)
		}
		gbi.rows[i].id = rowID

		if !gbi.rows[i].row.IsEmpty() {
			break
		}
	}
}
1216871
func (ListAccounts) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListAccountsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListAccountsResponse was expected, got %T", resp))
		return
	}

	for i := range items.Account {
		if !callback(&items.Account[i], nil) {
			break
		}
	}
}