{"id":737,"date":"2014-12-09T20:33:49","date_gmt":"2014-12-10T01:33:49","guid":{"rendered":"https:\/\/sheldon-hess.org\/coral\/?p=737"},"modified":"2014-12-10T08:22:41","modified_gmt":"2014-12-10T13:22:41","slug":"playing-with-github","status":"publish","type":"post","link":"https:\/\/www.sheldon-hess.org\/coral\/2014\/12\/playing-with-github\/","title":{"rendered":"Playing with GitHub"},"content":{"rendered":"<p><a href=\"https:\/\/sheldon-hess.org\/coral\/wp-content\/uploads\/2014\/12\/githubunicorn.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-739 size-full\" src=\"https:\/\/sheldon-hess.org\/coral\/wp-content\/uploads\/2014\/12\/githubunicorn-e1418172711215.png\" alt=\"this shows up when GitHub has errors\" width=\"200\" height=\"205\" \/><\/a>I had the opportunity, at work (and a bit outside of work), to learn the GitHub API, as wrapped by Python&#8217;s <a title=\"github3.py documentation\" href=\"http:\/\/github3py.readthedocs.org\/en\/master\/\">github3 module<\/a>. I found the documentation really hard to follow, maybe because I don&#8217;t have a lot of experience reading API docs, or because it wasn&#8217;t organized in the way I think about things, or maybe just because my work on this API was part of a larger, much more harrowing project, and I was already discouraged* &#8230; who knows?<\/p>\n<h3>I made a thing! Maybe it&#8217;s helpful!<\/h3>\n<p>Ultimately, I ended up documenting the parts of it I needed to understand in an <a href=\"http:\/\/nbviewer.ipython.org\/github\/csheldonhess\/learn-to-github-api\/blob\/master\/Learn-to-GitHub-API.ipynb\">IPython notebook<\/a>; if you&#8217;d like to play with the GitHub API, then, please, feel free to download and run it, after filling in your own username, your chosen repository name, and <a href=\"https:\/\/github.com\/blog\/1509-personal-api-tokens\">your API token for GitHub<\/a> (which you will want to keep secret, of course).<\/p>\n<p>I&#8217;m not sure the format I used is going to be helpful to others, but I kept referring back to this notebook over and over as I worked, so, at the very least, I&#8217;ve found a format that&#8217;s helpful for me! Since I was trying to mock GitHub objects, I was very interested in return types. I hope it&#8217;s useful for others who want to understand github3&#8230;<\/p>\n<h3>I made a funnier thing! Maybe you&#8217;ll want play with it?<\/h3>\n<p>Now, because I had a funny idea (and I wanted to remind myself that <em>I like programming<\/em>), I also spent most of a Sunday building <a title=\"daily-commit-app\" href=\"https:\/\/github.com\/csheldonhess\/daily-commit-app\">a tool<\/a> to help make GitHub feel less like a game I have to win**. In short, it makes one commit per day on my GitHub account\u00e2\u20ac\u201dactually, to the repository in which it is housed, because I was feeling puckish\u00e2\u20ac\u201dso that I maintain a perfect streak. See? Perfection, since the day I wrote the script!<\/p>\n<p><a href=\"http:\/\/github.com\/csheldonhess\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-738 size-full\" src=\"https:\/\/sheldon-hess.org\/coral\/wp-content\/uploads\/2014\/12\/github-e1418172649490.png\" alt=\"github streak image\" width=\"600\" height=\"242\" \/><\/a><\/p>\n<p>The code itself is pretty short; look at <a href=\"https:\/\/github.com\/csheldonhess\/daily-commit-app\/blob\/master\/do_the_thing.py\">do_the_thing.py<\/a>. You can tell I had fun writing it, though. :) <\/p>\n<p>The trickier (read: way more time-consuming) part ended up being the &#8220;make it run daily&#8221; bit. I had to learn about <a href=\"http:\/\/launchd.info\/\">launchd<\/a>, which Mac seems to prefer to <a href=\"http:\/\/www.maclife.com\/article\/columns\/terminal_101_creating_cron_jobs\">cron<\/a>. That&#8217;s too bad, since I already understood cron, but launchd has some nice features, like running when the machine wakes up if it was sleeping at the appointed time. <\/p>\n<p>Anyway, once I gave in and took the advice of the launchd tutorial linked above and installed LaunchPad, it went better for me. <\/p>\n<p>I&#8217;ve included my plist file <a href=\"https:\/\/github.com\/csheldonhess\/daily-commit-app\">in the repository<\/a>, so nobody else has to write their own; I also gave the directory to put it in and listed the one necessary change, in the <a href=\"https:\/\/github.com\/csheldonhess\/daily-commit-app\/blob\/master\/README.md\">README<\/a>. It shouldn&#8217;t be too hard to get running if you&#8217;ve got a Mac on hand.<\/p>\n<p>I&#8217;d like to deploy this on Heroku at some point, rather than having to keep my laptop on all the time; maybe if I find that doable I&#8217;ll write a follow-up post, or just edit this one. :)<\/p>\n<p>&nbsp;<\/p>\n<p>*We have this big code base, which is built on Flask (which I don&#8217;t know) and MongoDB (which I don&#8217;t know) and which has a RESTful API (which I haven&#8217;t learned yet; that&#8217;s my current project, happily!), which requires some internal routing to build and resolve URLs (which I don&#8217;t really understand, though I can trace through it with <a href=\"https:\/\/www.jetbrains.com\/pycharm\/\">PyCharm<\/a>). My job was to use <a href=\"http:\/\/www.voidspace.org.uk\/python\/mock\/\">mock<\/a> (which I didn&#8217;t know at the time and still have trouble <em>keeping<\/em> my head wrapped around) to write tests (which I have only minimal experience with) on some internal API routes and permissions stuff for the GitHub addon (which was written in a fairly complicated way, in part by necessity, and which I didn&#8217;t understand <em>at all<\/em> at the outset of this project). This was supposed to be a good learning project, and I don&#8217;t doubt the intentions of anyone involved with assigning it, but &#8230; it was a pretty terrible, demoralizing experience, made worse because I was instructed not to ask the more-senior devs any questions, and the time estimate I was given was not realistic. (I did finish, pretty much. I have to redo my pull request in the morning.)<\/p>\n<p>** &#8220;GitHub displays a lot of useless stats about how many followers you have, and some completely psychologically manipulative stats about how often you commit and how many days it is since you had a day off&#8221; &#8211; <a href=\"https:\/\/blog.jcoglan.com\/2013\/11\/15\/why-github-is-not-your-cv\/\">Why GitHub is not your CV, by James Coglan<\/a><br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had the opportunity, at work (and a bit outside of work), to learn the GitHub API, as wrapped by Python&#8217;s github3 module. I found the documentation really hard to follow, maybe because I don&#8217;t have a lot of experience reading API docs, or because it wasn&#8217;t organized in the&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.sheldon-hess.org\/coral\/2014\/12\/playing-with-github\/\">Continue reading<span class=\"screen-reader-text\">Playing with GitHub<\/span><\/a><\/div>\n","protected":false},"author":3,"featured_media":739,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68,53,85,70],"tags":[],"class_list":["post-737","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fails","category-geekery","category-new-developer","category-programming","entry"],"_links":{"self":[{"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/posts\/737","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/comments?post=737"}],"version-history":[{"count":0,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/posts\/737\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/media\/739"}],"wp:attachment":[{"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/media?parent=737"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/categories?post=737"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sheldon-hess.org\/coral\/wp-json\/wp\/v2\/tags?post=737"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}