jcristol / Joshs-Json-Machine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Joshs JSON Machine

Install

  • $ git clone https://github.com/jcristol/Joshs-Json-Machine

Run

  • $ cd Joshs-Json-Machine; python3 Main.py

Sample Result

{  
   "your_email_address":"joshcristol@gmail.com",
   "unique_emails":[  
      "walter.elwyn@yahoo.com",
      "helyn67@cruickshankmckenzie.com",
      "salvatore21@hintz.com",
      "wyman.junious@gmail.com",
      "red.beatty@yahoo.com",
      "manilla.west@hotmail.com",
      "chad.armstrong@yahoo.com",
      "letta.larkin@quitzon.net",
      "helma91@hotmail.com",
      "isaac.nolan@hotmail.com",
      "kuvalis.dewitt@wolfschaefer.com",
      "inolan@hotmail.com",
      "thiel.cassie@hodkiewicz.info",
      "zschuppe@hotmail.com",
      "vernon.fadel@denesik.com",
      "clotilda26@goodwinlind.info",
      "sharde.murazik@hotmail.com",
      "gail34@reichel.com",
      "georgiann.mertz@moen.net",
      "tryan@fishercremin.com",
      "ubradtke@hotmail.com",
      "lfranecki@hotmail.com",
      "mclaughlin.desi@gmail.com",
      "nakia.larkin@gmail.com",
      "mrath@ruecker.com ",
      "lizette.walker@stanton.com",
      "maxxx.waters@sauer.biz",
      "adams77@yahoo.com",
      "yschneider@jacobson.biz",
      "hconsidine@bernhardhills.info",
      "hhaag@swaniawskiterry.info",
      "infant80@yahoo.com",
      "wiegand.lynnette@beer.com",
      "sdaugherty@gmail.com",
      "erdman.icy@hotmail.com",
      "channing.cremin@toy.org",
      " johns.sonji@lakinwalker.info",
      "britny60@gmail.com",
      "birdman@quitzon.net ",
      "troy67@yahoo.com",
      "vicy.predovic@gmail.com",
      "burnice.feest@yahoo.com",
      "sonia.ruecker@schmidt.info",
      "arice@greenholtconsidine.com",
      "tobin.schuppe@gmail.com",
      "glubowitz@yahoo.com",
      "parisian.linda@hotmail.com",
      "hettinger.kamari@hotmail.com",
      "henery76@yahoo.com",
      "zulauf.olympia@gmail.com",
      "johntyree69@greendale.edu",
      "dollie49@hotmail.com",
      "raven53@yahoo.com",
      "cecilia.kerluke@gmail.com",
      "lindgren.merry@howe.com",
      "alysha.gibson@hotmail.com",
      "arland.koepp@hotmail.com",
      "hayley27@koelpin.com",
      "ed.hilpert@hansen.com",
      "fmann@yahoo.com",
      "crona.meredith@gmail.com",
      "dean94@hotmail.com",
      "owindler@strosin.info",
      "abshire.charmaine@schusterlabadie.com",
      "odalys.dubuque@ebertrunte.net",
      "angelica.klocko@ankunding",
      "douglyass.dickinson@hotmail.com",
      "uoberbrunner@hotmail.com",
      "pkoch@yahoo.com",
      "hhirthe@yahoo.com",
      "mosciski.destany@hotmail.com",
      "mrath@ruecker.com",
      "hoy.kozey@gmail.com",
      "ymoore@cristhalvorson.org",
      "reichel.tamatha@gmail.com",
      "jquitzon@gmail.com",
      "kozey.luciana@collins.biz",
      "shanahan.anders@yahoo.com",
      "jones.kyree@auer.net",
      "terry.ezekiel@hotmail.com",
      "cheyenne84@lehneroconner.com",
      "fjaskolski@hotmail.com",
      "floretta39@volkmanrosenbaum.net",
      "jchamplin@hotmail.com ",
      "harber.gisele@gmail.com",
      "gerlach.villa@koelpinfeeney.net",
      "jkoch@hotmail.com",
      "brandi.klein@hotmail.com",
      "emelia54@yahoo.com",
      "miller.hana@gmail.com",
      "elberta.o'connell@yahoo.com",
      "wilderman.nyree@heidenreich.com",
      "vrippin@gmail.com",
      "eileen.gusikowski@oreilly.info",
      "cstehr@keebler.com",
      "onolan@gmail.com",
      "ygoyette@yahoo.com",
      "vblanda@gmail.com",
      " ybartoletti@littel.biz",
      "woodie.crooks@kozey.com",
      "emilia16@block.com",
      "bahringer.karl@yahoo.com",
      "morissette.lalla@kuhicmuller.com"
   ],
   "user_domain_counts":{  
      "yahoo.com":18,
      "gmail.com":18,
      "hotmail.com":22
   },
   "april_emails":[  
      "walter.elwyn@yahoo.com",
      "helyn67@cruickshankmckenzie.com",
      "wyman.junious@gmail.com",
      "red.beatty@yahoo.com",
      "manilla.west@hotmail.com",
      "chad.armstrong@yahoo.com",
      "letta.larkin@quitzon.net",
      "helma91@hotmail.com",
      "kuvalis.dewitt@wolfschaefer.com",
      "inolan@hotmail.com",
      "thiel.cassie@hodkiewicz.info",
      "zschuppe@hotmail.com",
      "vernon.fadel@denesik.com",
      "georgiann.mertz@moen.net",
      "tryan@fishercremin.com",
      "ubradtke@hotmail.com",
      "lfranecki@hotmail.com",
      "mclaughlin.desi@gmail.com",
      "mrath@ruecker.com ",
      "lizette.walker@stanton.com",
      "adams77@yahoo.com",
      "yschneider@jacobson.biz",
      "hhaag@swaniawskiterry.info",
      "infant80@yahoo.com",
      "erdman.icy@hotmail.com",
      "channing.cremin@toy.org",
      "britny60@gmail.com",
      "birdman@quitzon.net ",
      "troy67@yahoo.com",
      "vicy.predovic@gmail.com",
      "sonia.ruecker@schmidt.info",
      "arice@greenholtconsidine.com",
      "tobin.schuppe@gmail.com",
      "glubowitz@yahoo.com",
      "henery76@yahoo.com",
      "dollie49@hotmail.com",
      "raven53@yahoo.com",
      "lindgren.merry@howe.com",
      "alysha.gibson@hotmail.com",
      "arland.koepp@hotmail.com",
      "hayley27@koelpin.com",
      "fmann@yahoo.com",
      "crona.meredith@gmail.com",
      "owindler@strosin.info",
      "abshire.charmaine@schusterlabadie.com",
      "douglyass.dickinson@hotmail.com",
      "pkoch@yahoo.com",
      "hhirthe@yahoo.com",
      "mrath@ruecker.com",
      "kozey.luciana@collins.biz",
      "jones.kyree@auer.net",
      "terry.ezekiel@hotmail.com",
      "floretta39@volkmanrosenbaum.net",
      "jchamplin@hotmail.com ",
      "jkoch@hotmail.com",
      "emelia54@yahoo.com",
      "miller.hana@gmail.com",
      "elberta.o'connell@yahoo.com",
      "wilderman.nyree@heidenreich.com",
      "eileen.gusikowski@oreilly.info",
      "onolan@gmail.com",
      "ygoyette@yahoo.com",
      "vblanda@gmail.com",
      "woodie.crooks@kozey.com",
      "emilia16@block.com",
      "bahringer.karl@yahoo.com",
      "morissette.lalla@kuhicmuller.com"
   ]
}
  • Submitted is the JSON submitted to the server.
  • The Response code is logged at the bottom.
  • Errors are logged to stderr

Discussion

Amount of Time Spent

To start I would like to say this took me over two hours. It was really not that difficult of a task but I didn't want to simply write a tiny script that didn't check errors and wasn't organized well. I spent a good amount of my time trying to design a system that I felt was easy to understand. I probably spent a total of 4 hours with most of that time going toward refactoring logic to files and functions.

Big O

The program is O(N) where N is the number of data points I was given. I iterate through a constant number of lists all of size N. The house keeping I do in these iterations are all constant in time complexity.

Interesting Stuff

My solution consists of three separate modules. The first is a Main.py which runs the program at a high level and communicates to the server. The next module is User.py which consists of a class called User that encapsulates everything I think it means to be a User. I made logins a property of each User and created a dictionary that allows Users to be flagged if they visited the site in April. Lastly ApiFunctions.py encapsulates the program logic. The functions defined inside the module both build a dict of Users and query the dict to find out all the different statistics about Users.

Weird Stuff

  1. I didn't want to use any external libraries to avoid a requirements file.
  2. Because of this first constraint I stumbled into an odd problem. Check out the function inside User called timeZoneColonFix(). Look into the link I provided there. The short of the long is the timestamp strings that were provided in the api data do not follow the datetime standard in python3.

I really had fun doing this so I hope you enjoy my code. 😎

About


Languages

Language:Python 100.0%