Bugs Become Features

  • Home
  • About
  • Research
  • Projects
  • Publications
  • Teaching
  • Blog
  • Archives

Gophers

7 posts tagged with "Gophers"

  • 22 Sep 2014
    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 this as a cloud service, and why not allow the grouping of people you follow? Also investigate twitter security better, especially around the developer api.

  • 19 Sep 2014
    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() + 1) entity := rExpression.ReplaceAllLiteralString(entries.AsArray()[i].AsString(), replaceWith[2:4]) return entity, nil case "-YYYY-": replaceWith := strconv.Itoa(time.Now().Year()) entity := rExpression.

  • 09 Sep 2014
    Search Gear 18 - Anonymous Functions and Closures

    Now, I also need a function to process wildcards out of hashtags maybe creating multiple requests from a single tag. Let’s go with anonymous functions and closures, which in flirted with on day 7, what seems like years ago now! https://gobyexample.com/closures func getItem(entries toml.Value) func() string { i := -1 return func() string { i += 1 if i Then a function to loop ‘collect’ for each tag, user, and home.

  • 08 Sep 2014
    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 Aug 27 13:38:09 +0000 2014 20 records at 14:51 August 27th 2014 DO NOT APPEND

  • 29 Aug 2014
    Search Gear 16 - json Decoder Encoder

    OK OK my test worked locally it seems but not via drone. No idea why - at this point I don’t much care long as they work for me. Now code changes to encode and decode tweets, efficiency be damned - lets just move on. https://dev.twitter.com/docs/working-with-timelines Tweets returned in reverse chronological order - so not optimal for writing to a file. func (tw *twitter) collect(toGet string) (string, error) { var searchResult []anaconda.

  • 28 Aug 2014
    Search Gear 15 - Half Way - Interfaces

    I’m half way through my 30 days of code, it wont all be contiguous but I hope the 30 day sprint will get me much further forward with go. Then it will be back to a day a week of gophering. My third week of gophering suggests that if you don’t know about interfaces then you are screwed. You can get by without them but all the cool kids are using them, and documentation being what it is; BAD I mean, without being able to investigate the package code directly you only hope is to code without reuse.

  • 27 Aug 2014
    Search Gear 14 - Pseudo Constructors!

    Changed the config twitter caller to a pseudo constructor thus func NewTwitter(file string) (*twitter, error) { tw := new(twitter) var parser toml.Parser if _, err := ioutil.ReadFile(file); err != nil { tw.errors = errors.New(co.Lang("could not find the configuration file, you'll need to provide these setting for twitter to work")) } else { toml := parser.ParseFile(file) tw.userKey = toml.GetString("twitter.user-key") tw.userSecret = toml.GetString("twitter.user-secret") tw.apiKey = toml.GetString("twitter.api-key", "26276391-gtihvXIuNXzCD4HTOjx8630O8IPq19m810TxkLMmd") tw.apiSecret = toml.GetString("twitter.api-secret", "bYkulR93l70elsjZysjjDpxQT69RVF2GIUcjoMIkrADoc") tw.users, _ = toml.

← All Tags

Simon Harper

Professor of Computer Science, University of Manchester

© 2026 Simon Harper. All rights reserved.

Connect

Built with Hugo