Search Gear Notes

Search Gear #20 Cleaning Up

Cleaning up those nasty files func (tw *twitter) cleanUp(entity string) (string, error) { if entity == “” { entity = “myHome” } cleanTime := time.Now().AddDate(0, 0, -2) fileName := strings.Join([]string{entity, “_”, cleanTime.Format(“2006-01-02”), “.json”}, “”) if err := os.Remove(fileName); err != nil { log.Println(“Failed to”, err) } return fileName, nil }   So why not have…

Search Gear Notes

Search Gear #19 Regular Expressions

func getItem(entries toml.Value) func() (string, error) { i := -1 return func() (string, error) { rExpression := regexp.MustCompile(“(-([A-Z]+|[A-Z]+[1-9])-)”) i += 1 if i < len(entries.AsArray()) { if rExpression.FindString(entries.AsArray()[i].AsString()) != "" { foundString := rExpression.FindString(entries.AsArray()[i].AsString()) switch foundString { case "-YY-": replaceWith := strconv.Itoa(time.Now().Year()) entity := rExpression.ReplaceAllLiteralString(entries.AsArray()[i].AsString(), replaceWith[2:4]) return entity, nil case "-YY1-": replaceWith := strconv.Itoa(time.Now().Year() +…

Search Gear Notes

Search Gear #17 – TEST the TWITTER COLLECTOR

First run Starts at: Wed Aug 27 03:44:15 +0000 2014 Ends at: Wed Aug 27 07:49:42 +0000 2014 19 records at 09:21 August 27th 2014 Removed file.Sync() after each tweet is written to ‘disk’ (buffer I expect) which makes things much quicker. Second run Starts at: Wed Aug 27 10:33:48 +0000 2014 Ends at: Wed…