Ejemplo n.º 1
0
func TestDownloadCampaignPerformaceReport(t *testing.T) {
	ru := testReportUtils(t)

	predicates := []Predicate{
		{"CampaignId", "EQUALS", []string{"246257700"}},
	}

	reportDefinition := &ReportDefinition{
		Selector: Selector{
			Fields: []string{
				"CampaignId",
				"AverageCpc",
				"AverageCpm",
				"Cost",
				"Clicks",
				"Impressions",
				"Week", //Quarter, Month , Year, Week, Date
			},
			Predicates: predicates,
			DateRange: &DateRange{
				Min: "20150411", //YYYYMMDD
				Max: "20150621", //YYYYMMDD
			},
		},
		ReportName: "Report #553f5265b3d84",
		//		DateRangeType:          DATE_RANGE_ALL_TIME,
		DateRangeType:          DATE_RANGE_CUSTOM_DATE,
		IncludeZeroImpressions: true,
	}
	report, err := ru.DownloadCampaignPerformaceReport(reportDefinition)
	pretty.Println(report)
	pretty.Println(err)
}
Ejemplo n.º 2
0
func TestDownloadBudgetPerformanceReport(t *testing.T) {
	ru := testReportUtils(t)

	predicates := []Predicate{
		{"AssociatedCampaignId", "EQUALS", []string{"246257700"}},
	}

	reportDefinition := &ReportDefinition{
		Selector: Selector{
			Fields: []string{
				"AssociatedCampaignId",
				"AverageCpc",
				"AverageCpm",
				"Cost",
				"Clicks",
				"Impressions",
				"Conversions",
			},
			Predicates: predicates,
		},
		ReportName:             "Report #553f5265b3d84",
		DateRangeType:          DATE_RANGE_ALL_TIME,
		IncludeZeroImpressions: true,
	}
	report, err := ru.DownloadBudgetPerformanceReport(reportDefinition)
	pretty.Println(report)
	pretty.Println(err)
}
Ejemplo n.º 3
0
func FindVideos(searchfield string, searchcondition string) []Videos {

	session, err := mgo.Dial("mongodb://*****:*****@ds047335.mongolab.com:47335/heroku_wd4cw55m") //session is a session
	if err != nil {
		panic(err)
	}
	defer session.Close()

	var videos []Videos
	// Optional. Switch the session to a monotonic behavior.
	//session.SetMode(mgo.Monotonic, true)
	videos_collection := session.DB("heroku_wd4cw55m").C("videos") //videos is the collection
	fmt.Printf("inside FindVideos: %s and %s\n", searchfield, searchcondition)

	//err = videos_collection.Find(bson.M{"title": "my video"}).All(&videos)
	err = videos_collection.Find(bson.M{searchfield: searchcondition}).All(&videos)

	pretty.Println("inside FindVideos error:%s ", err)

	//     if err != nil {
	//              return err
	//       }
	fmt.Printf("inside FindVideos: %v  \n", videos)
	pretty.Println("Videos:", videos)

	for _, res := range videos {
		fmt.Printf("res: %v\n", res)
	}
	return videos
} // end of FindVideos
Ejemplo n.º 4
0
// @Swagger
// @Title Api
// @Description Super api
// @Term Dont use
// @Contact name="witoo harianto" url=http://www.plimble.com [email protected]
// @License name="Apache 2.0" url=http://google.com
// @Version 1.1.1
// @Schemes http https ws
// @Consumes json xml
// @Produces json xml
// @Security petstore_auth=write:pets,read:pets
//
// @SecurityDefinition petstore_auth
// @Type oauth2
// @Flow password
// @TokenUrl http://swagger.io/api/oauth/token
// @Scopes write:pets="modify pets in your account" read:pets="read your pets"
//
// @GlobalParam 	userParam		 name=user		required description="sadsadsad"		in=body schema.$ref=arlong.Hello9
// @GlobalParam 	userParam2		 name=user		required description="sadsadsad"		in=body schema.$ref=arlong.Hello9
//
// @GlobalResponse notFound desc="Entity not found." schema.$ref=arlong.Hello9
// @GlobalResponse notFound2 desc="Entity not found." schema.$ref=arlong.Hello9
//
// @Path /attempts
// @Method GET
// @Description Get Array of attempts
// @OperationId GetAttempts
// @Param $ref=limitQuery
// @Param $ref=skipQuery
// @Param $ref=spokenQuery
// @Param $ref=practiseQuery
// @Param $ref=userLangQuery
// @Tags attempts
// @Response 200 schema.type=array schema.items.$ref=arlong.Hello9
//
// @Path /user/jack/{id}
// @Method GET
// @Param name=id required description="sadsadsad" in=path type=string
// @Param name=user required description="sadsadsad" in=body schema.$ref=arlong.Hello9
// @Produces json
// @Consumes json
// @Summary this is summary
// @Description this is description
// @Deprecated
// @Schemes http https
// @OperationId GetStart
// @Tags a b c
// @Security petstore_auth=write:pets,read:pets
// @Response 200 desc=123123 schema.$ref=arlong.Hello9
func TestAnnotation(t *testing.T) {
	basePath := "/Users/witooh/dev/go/src/github.com/plimble/arlong"
	parser := NewParser(basePath)
	b, _ := parser.JSON()
	pretty.Println(string(b))
	pretty.Println(swagger.Definitions)
}
Ejemplo n.º 5
0
func (manager *Config) Debug() {
	fmt.Println("Flags:")
	pretty.Println(manager.pflags)
	fmt.Println("Env:")
	pretty.Println(manager.env)
	fmt.Println("Config file attributes:")
	pretty.Println(manager.attributes)
}
Ejemplo n.º 6
0
func Debug() {
	fmt.Println("Config:")
	pretty.Println(config)
	fmt.Println("Defaults:")
	pretty.Println(defaults)
	fmt.Println("Override:")
	pretty.Println(override)
}
Ejemplo n.º 7
0
func TestParse(t *testing.T) {
	p, _ := os.Getwd()
	dir := path.Join(p, "testparse")
	pretty.Println(dir)
	parser := NewParser()
	parser.ParseDir(dir)
	pretty.Println(parser.Types)
	// parser.ParseDir("/Users/witooh/dev/go/src/github.com/hyperworks/langfight/src/models")
}
Ejemplo n.º 8
0
func main() {
	client, err := redis.Dial("tcp", "192.168.59.103:6379")
	if err != nil {
		log.Fatal(err)
	}

	pretty.Println(client.Do("SET", "hola", "booom"))
	pretty.Println(redis.String(client.Do("GET", "hola")))
}
Ejemplo n.º 9
0
func prettyPrint(encrypted []byte, key string, label string) {
	var decrypted, err = decrypt(encrypted, key, label)

	if err != nil {
		return
	}

	var model1 models.DesiredLRPRunInfo
	err = model1.Unmarshal(decrypted)
	if err != nil {
		// NOP
	} else {
		pretty.Println(model1)
		return
	}

	var model2 models.DesiredLRPSchedulingInfo
	err = model2.Unmarshal(decrypted)
	if err != nil {
		// NOP
	} else {
		pretty.Println(model2)
		return
	}

	var model3 models.ActualLRP
	err = model3.Unmarshal(decrypted)
	if err != nil {
		// NOP
	} else {
		pretty.Println(model3)
		return
	}

	var model4 models.Task
	err = model4.Unmarshal(decrypted)
	if err != nil {
		// NOP
	} else {
		pretty.Println(model4)
		return
	}

	var model5 models.DesiredLRP
	err = model5.Unmarshal(decrypted)
	if err != nil {
		log.Println("Unknown data type: ", string(decrypted))
	} else {
		pretty.Println(model5)
		return
	}
}
Ejemplo n.º 10
0
func DeleteUser(searchfield string, searchcondition string) bool {

	err = MColusers.Remove(bson.M{searchfield: searchcondition})

	pretty.Println("inside DeleteUser error:%s ", err)

	if err != nil {
		pretty.Println("inside FindUsers error:%s ", err)
		return false
	}
	fmt.Printf("inside DeleteUser/n")

	return true
} // end of DeleteUser
Ejemplo n.º 11
0
func TestValueScanOk(t *testing.T) {
	s := testScanner(testValueInput)
	var values []MozValue
	for s.ScanValue() {
		values = append(values, s.Value())
	}
	if err := s.ScanValueError(); err != nil {
		t.Fatal("Unexpected error", err)
	}
	if !reflect.DeepEqual(valScanTestExpected, values) {
		pretty.Println("expected", valScanTestExpected)
		pretty.Println("actual  ", values)
		t.Error("Did not receive expected values")
	}
}
Ejemplo n.º 12
0
func testAdapter(messages <-chan string, done <-chan bool) {

	// create a new nsqadapter
	queue := nsqAdapter.New("test", nsqlookupd)

	// initialize the ability to handle responses
	queue.InitializeResponseHandling()

	// subscribe to a certain topic
	webserverChan := make(chan nsqAdapter.Message)
	queue.Subscribe("webserver", "requests", webserverChan)

	for {
		select {
		case info := <-webserverChan:
			pretty.Println("WEBSERVER:", info.Payload)

			if info.MessageType == nsqAdapter.MessageTypeRequest {
				queue.RespondTo(info, "this is a response")
			}

		case message := <-messages:
			data := strings.Split(message, ".")

			if data[1] == "request" {

				go func() {
					pretty.Println("REQUEST:", data[0], data[2])
					// create a request  a request
					result, err := queue.SendRequest(data[0], data[2], time.Second*10)

					if err != nil {
						pretty.Println("RESPONSE:", err.Error())
					} else {
						pretty.Println("RESPONSE:", result)
					}
				}()

			} else {
				pretty.Println("PUBLISH:", data[0], data[1])
				queue.Publish(data[0], data[1])
			}

		case <-done:
			fmt.Println("STOPPING QUEUE")
		}
	}
}
Ejemplo n.º 13
0
func dump(fn string) {
	fmt.Println("===", fn, "===")
	defer fmt.Println()

	f, err := os.Open(fn)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()

	g, err := gzip.NewReader(f)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer g.Close()

	var data interface{}
	err = gob.NewDecoder(g).Decode(&data)
	if err != nil {
		fmt.Println(err)
		return
	}

	pretty.Println(data)
}
Ejemplo n.º 14
0
Archivo: cfg.go Proyecto: nwlucas/cfg
func (c *Config) Debug() {
	fmt.Println("Aliases:")
	pretty.Println(c.aliases)
	// fmt.Println("Override:")
	// pretty.Println(c.override)
	// fmt.Println("PFlags")
	// pretty.Println(c.pflags)
	// fmt.Println("Env:")
	// pretty.Println(c.env)
	// fmt.Println("Key/Value Store:")
	// pretty.Println(c.kvstore)
	fmt.Println("Config:")
	pretty.Println(c.config)
	fmt.Println("Defaults:")
	pretty.Println(c.defaults)
}
Ejemplo n.º 15
0
// Start runs a go routine which is ready for accepting tasks
func (w Worker) Start() {
	go func() {
		for {
			// Add ourselves into the worker queue.
			w.WorkerQueue <- w.Work
			select {
			case work := <-w.Work:
				// Receive a work request.
				var uProfile jesus.UProfile
				remoteDBConn, err := RemoteDB()
				pretty.Println(work)
				if err != nil {
					w.Stop()
				}
				for _, v := range work {
					fmt.Println("working on deposits for ", v.SenderNumber)
					uProfile = jesus.UProfile{}
					err = remoteDBConn.Where(&jesus.UProfile{Phone: v.SenderNumber}).First(&uProfile).Error
					if err != nil {
						w.Stop()
					}
					uProfile.PrepareDeposit(&v)
					remoteDBConn.Save(&uProfile)
					fmt.Println("====done===")
				}

			case <-w.QuitChan:
				fmt.Printf("worker%d stopping\n", w.ID)
				return
			}
		}
	}()
}
Ejemplo n.º 16
0
Archivo: main.go Proyecto: abh/v6test
func saveHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "text/javascipt")
	w.Header().Set("Cache-Control", "private, no-cache, no-store, must-revalidate")

	w.WriteHeader(204)

	err := r.ParseForm()
	if err != nil {
		log.Printf("Could not parse form: %s", err)
	}

	data := LogData{}
	err = decoder.Decode(&data, r.Form)
	if err != nil {
		log.Printf("Could decode form: %s", err)
	}

	data.RemoteIP = remoteIP(r)
	data.Time = time.Now().Unix()

	data.Referrer = r.Header.Get("Referer")
	data.UserAgent = r.Header.Get("User-Agent")
	data.Host = r.Host
	if idx := strings.Index(data.Host, ":"); idx > 0 {
		data.Host = data.Host[0:idx]
	}

	js, err := json.Marshal(&data)
	if err != nil {
		log.Printf("Could not marshal json: %s", err)
	}

	pretty.Println(string(js))
	beanCh <- js
}
Ejemplo n.º 17
0
func TestClientResolveVersions(t *testing.T) {
	t.Skip()

	dockerCli, err := dockerclient.New()
	if err != nil {
		t.Fatal(err)
	}

	client, err := NewClient(&DockerClient{
		Docker: dockerCli,
	})
	if err != nil {
		t.Fatal(err)
	}

	containers := []*Container{
		&Container{
			Name:  config.NewContainerName("test", "test"),
			Image: imagename.NewFromString("golang:1.4.*"),
		},
	}

	if err := client.resolveVersions(true, true, template.Vars{}, containers); err != nil {
		t.Fatal(err)
	}

	pretty.Println(containers)
}
Ejemplo n.º 18
0
func speak(grammarPath string) error {
	// Parse the grammar.
	f, err := os.Open(grammarPath)
	if err != nil {
		return errutil.Err(err)
	}
	defer f.Close()
	grammar, err := ebnf.Parse(filepath.Base(grammarPath), f)
	if err != nil {
		return errutil.Err(err)
	}
	if err = ebnf.Verify(grammar, "Program"); err != nil {
		return errutil.Err(err)
	}

	pretty.Println(grammar)

	terms := Terminals(grammar)

	_ = pretty.Print

	//fmt.Println("=== [ Grammar ] ===")
	//pretty.Println(grammar)

	//fmt.Println("=== [ Terminals ] ===")
	//pretty.Println(terms)

	fmt.Println("=== [ Regular expressions ] ===")
	for _, term := range terms {
		//pretty.Println(term)
		fmt.Println("term:", RegexpString(grammar, term))
	}

	return nil
}
Ejemplo n.º 19
0
func TestPluralIdentifyingRootField_Configuration_ArgNames_WrongArgNameSpecified(t *testing.T) {

	t.Skipf("Pending `validator` implementation")
	query := `{
      usernames(usernamesMisspelled:["dschafer", "leebyron", "schrockn"]) {
        username
        url
      }
    }`
	expected := &graphql.Result{
		Data: nil,
		Errors: []gqlerrors.FormattedError{
			gqlerrors.FormattedError{
				Message: `Unknown argument "usernamesMisspelled" on field "usernames" of type "Query".`,
				Locations: []location.SourceLocation{
					location.SourceLocation{Line: 2, Column: 17},
				},
			},
			gqlerrors.FormattedError{
				Message: `Field "usernames" argument "usernames" of type "[String!]!" is required but not provided.`,
				Locations: []location.SourceLocation{
					location.SourceLocation{Line: 2, Column: 7},
				},
			},
		},
	}
	result := graphql.Do(graphql.Params{
		Schema:        pluralTestSchema,
		RequestString: query,
	})
	pretty.Println(result)
	if !reflect.DeepEqual(result, expected) {
		t.Fatalf("wrong result, graphql result diff: %v", testutil.Diff(expected, result))
	}
}
Ejemplo n.º 20
0
func main() {
	flag.Usage = func() {
		fmt.Fprintf(os.Stderr, "usage: %s [options]  Location-Alias\n", path.Base(os.Args[0]))
		flag.PrintDefaults()
		os.Exit(0)
	}
	flag.Parse()

	if flag.NArg() != 1 {
		flag.Usage()
		os.Exit(1)
	}

	client, err := clcv2.NewCLIClient()
	if err != nil {
		exit.Fatal(err.Error())
	}

	capa, err := client.GetBareMetalCapabilities(flag.Arg(0))
	if err != nil {
		exit.Fatalf("failed to query bare-metal capabilities of %s: %s", flag.Arg(0), err)
	}

	fmt.Printf("Datacenter %s:\n", flag.Arg(0))
	pretty.Println(capa)
}
Ejemplo n.º 21
0
func main() {
	flag.Parse()

	var client *maps.Client
	var err error
	if *apiKey != "" {
		client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
	} else if *clientID != "" || *signature != "" {
		client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
	} else {
		usageAndExit("Please specify an API Key, or Client ID and Signature.")
	}
	check(err)

	r := &maps.QueryAutocompleteRequest{
		Input:    *input,
		Language: *language,
		Radius:   *radius,
		Offset:   *offset,
	}

	parseLocation(*location, r)

	resp, err := client.QueryAutocomplete(context.Background(), r)
	check(err)

	pretty.Println(resp)
}
Ejemplo n.º 22
0
func main() {
	flag.Parse()

	var client *maps.Client
	var err error
	if *apiKey != "" {
		client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
	} else if *clientID != "" || *signature != "" {
		client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
	} else {
		usageAndExit("Please specify an API Key, or Client ID and Signature.")
	}
	check(err)

	r := &maps.GeocodingRequest{
		Address:  *address,
		Language: *language,
		Region:   *region,
	}

	parseComponents(*components, r)
	parseBounds(*bounds, r)
	parseLatLng(*latlng, r)
	parseResultType(*resultType, r)
	parseLocationType(*locationType, r)

	resp, err := client.Geocode(context.Background(), r)
	check(err)

	pretty.Println(resp)
}
Ejemplo n.º 23
0
func TestAddressbookMonitor(t *testing.T) {
	conn, err := Dial(server+":7778", true)
	if err != nil {
		t.Fatal(err)
	}
	defer conn.Close()

	_, err = conn.Login("martint", "01103", "Mobile", "iPhone")
	if err != nil {
		t.Error(err)
	}
	abmonitor, err := conn.StartABMonitor()
	if err != nil {
		t.Error(err)
	}

	go func() {
		for abupdate := range abmonitor {
			pretty.Println(abupdate)
			// _ = abupdate
		}
		fmt.Println("abupdate closed")
	}()
	time.Sleep(time.Second)
	err = conn.SetPresence(StatusBusy, "test note")
	if err != nil {
		t.Error(err)
	}
	time.Sleep(time.Second * 2)
	err = conn.StopABMonitor()
	if err != nil {
		t.Error(err)
	}
	time.Sleep(time.Second)
}
Ejemplo n.º 24
0
func TestParse(t *testing.T) {
	data, err := Parse(reqStr)
	if err != nil {
		t.Fatal(err)
	}
	pretty.Println(data)
}
func main() {
	flag.Parse()

	var client *maps.Client
	var err error
	if *apiKey != "" {
		client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
	} else if *clientID != "" || *signature != "" {
		client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
	} else {
		usageAndExit("Please specify an API Key, or Client ID and Signature.")
	}
	check(err)

	r := &maps.TextSearchRequest{
		Query:    *query,
		Language: *language,
		Radius:   *radius,
		OpenNow:  *opennow,
	}

	parseLocation(*location, r)
	parsePriceLevels(*minprice, *maxprice, r)
	parsePlaceType(*placeType, r)

	resp, err := client.TextSearch(context.Background(), r)
	check(err)

	pretty.Println(resp)
}
Ejemplo n.º 26
0
func TestConfigFile(t *testing.T) {
	config, err := LoadConfig("config.yaml")
	if err != nil {
		t.Fatal(err)
	}
	pretty.Println(config)
}
Ejemplo n.º 27
0
func ShowAllVideos() []Videos {

	session, err := mgo.Dial("mongodb://*****:*****@ds047335.mongolab.com:47335/heroku_wd4cw55m") //session is a session
	if err != nil {
		panic(err)
	}
	defer session.Close()

	var videos []Videos
	// Optional. Switch the session to a monotonic behavior.
	//session.SetMode(mgo.Monotonic, true)
	videos_collection := session.DB("heroku_wd4cw55m").C("videos") //videos is the collection

	err = videos_collection.Find(bson.M{}).All(&videos)
	//     if err != nil {
	//              return err
	//       }
	pretty.Println("Videos:", videos)

	for _, res := range videos {
		fmt.Printf("res: %v\n", res)

	}
	return videos
} //end of ShowAllVideos
func main() {
	flag.Parse()

	var client *maps.Client
	var err error
	if *apiKey != "" {
		client, err = maps.NewClient(maps.WithAPIKey(*apiKey))
	} else if *clientID != "" || *signature != "" {
		client, err = maps.NewClient(maps.WithClientIDAndSignature(*clientID, *signature))
	} else {
		usageAndExit("Please specify an API Key, or Client ID and Signature.")
	}
	check(err)

	r := &maps.NearbySearchRequest{
		Radius:    *radius,
		Keyword:   *keyword,
		Language:  *language,
		Name:      *name,
		OpenNow:   *openNow,
		PageToken: *pageToken,
	}

	parseLocation(*location, r)
	parsePriceLevels(*minPrice, *maxPrice, r)
	parseRankBy(*rankBy, r)
	parsePlaceType(*placeType, r)

	resp, err := client.NearbySearch(context.Background(), r)
	check(err)

	pretty.Println(resp)
}
Ejemplo n.º 29
0
func main() {
	flag.Parse()
	if *apiKey == "" {
		usageAndExit("Please specify an API Key.")
	}
	client, err := maps.NewClient(maps.WithAPIKey(*apiKey))
	if err != nil {
		log.Fatalf("error %v", err)
	}
	r := &maps.SpeedLimitsRequest{}

	if *units == "KPH" {
		r.Units = maps.SpeedLimitKPH
	}
	if *units == "MPH" {
		r.Units = maps.SpeedLimitMPH
	}

	if *path == "" && *placeIDs == "" {
		usageAndExit("Please specify either a path to be snapped, or a list of Place IDs.")
	}
	parsePath(*path, r)
	parsePlaceIDs(*placeIDs, r)

	resp, err := client.SpeedLimits(context.Background(), r)
	if err != nil {
		log.Fatalf("error %v", err)
	}

	pretty.Println(resp)
}
Ejemplo n.º 30
0
Archivo: main.go Proyecto: rakoo/MMAS
func downloadDict(url string) {
	log.Println("Getting dict", path.Base(url))
	resp, err := http.Get(url)
	if err != nil {
		log.Println("Error getting dict:", err)
		return
	}
	f, err := os.Create(path.Join("dicts", path.Base(url)))
	if err != nil {
		log.Println(err)
		return
	}
	defer f.Close()

	buffered := bufio.NewReader(resp.Body)
	tr := textproto.NewReader(buffered)
	sdchHeader, err := tr.ReadMIMEHeader()
	if err != nil {
		log.Println(err)
		return
	}
	pretty.Println("Decoded sdch header:", sdchHeader)

	_, err = io.Copy(f, buffered)
	if err != nil {
		log.Println(err)
		return
	}
	dictName = path.Base(url)
	log.Println("Got dict", dictName)
}