{"id":226,"date":"2012-05-25T19:05:10","date_gmt":"2012-05-25T17:05:10","guid":{"rendered":"http:\/\/acraig.za.net\/blog\/?p=226"},"modified":"2012-05-25T19:05:10","modified_gmt":"2012-05-25T17:05:10","slug":"write-programs-to-automate-your-own-tasks","status":"publish","type":"post","link":"https:\/\/acraig.za.net\/blog\/write-programs-to-automate-your-own-tasks\/","title":{"rendered":"Write programs to automate your own tasks"},"content":{"rendered":"<p>Writing a program to solve or automate a task you do regularly is the best way to learn something new in coding.<\/p>\n<p>Recently I&#8217;ve learnt a little bit about Android, java and regular expressions as a by-product of wanting to simplify and automate tasks I perform related to my podcast listening.<\/p>\n<p>I listen to podcasts a lot, and do so by downloading them via WiFi using my phone, and then transferring them to a USB drive for insertion into my car&#8217;s front-loader. That is for me the most convenient way of listening to them.<\/p>\n<p>I also like to keep track of what I do each day and publish this to my blog in the weekly-update category. This I learnt from <a href=\"http:\/\/www.swimgeek.com\/blog\/\">swimgeek<\/a> who has been doing this for years, and which I find strangely motivating. I record these snippets of information using an Android app called <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.utagoe.momentdiary&amp;hl=en\">MomentDiary<\/a>. The podcasts I listen to I&#8217;ve made part of this stored information.<\/p>\n<p>So here are three things I set out to make as simple and as automated as possible:<\/p>\n<ol>\n<li>transferring podcasts to a USB drive;<\/li>\n<li>including the podcast name as part of my weekly-update;<\/li>\n<li>generating and formatting the weekly-update blog post.<\/li>\n<\/ol>\n<p>To solve 1, I wrote an Android app called <a href=\"http:\/\/acraig.za.net\/src\/move-files.html\">MoveFiles<\/a> to do the copying as a one-click step. All it does is move each file, possibly in a directory structure, from the public Podcast directory to the USB drive. This was an exercise in AsyncTask and the Visitor design pattern.<\/p>\n<p>To solve 2, also using the same app, and as part of the file move operation, I make a diary entry for the copied filenames. So my weekly list contains the podcast filenames copied in that week. In doing this I learnt how to share between two apps.<\/p>\n<p>To solve 3, I wrote another Android app called <a href=\"https:\/\/github.com\/acraig5075\/reformatter\">Reformatter<\/a> to act as an intermediary where the text shared from the diary gets automatically formatted prior to it being shared again to the Android WordPress app. I can then publish in draft form a blog post already formatted the way I like it. In doing this I had some wonderful experience with regular expressions.<\/p>\n<p>The flow of data is as follows:<br \/>\n<a href=\"https:\/\/acraig.za.net\/blog\/wp-content\/uploads\/2012\/05\/uml-blog-solve-problems.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-227\" title=\"uml-blog-solve-problems\" src=\"https:\/\/acraig.za.net\/blog\/wp-content\/uploads\/2012\/05\/uml-blog-solve-problems-300x219.png\" alt=\"\" width=\"300\" height=\"219\" srcset=\"https:\/\/acraig.za.net\/blog\/wp-content\/uploads\/2012\/05\/uml-blog-solve-problems-300x219.png 300w, https:\/\/acraig.za.net\/blog\/wp-content\/uploads\/2012\/05\/uml-blog-solve-problems.png 596w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>I have plenty of projects that I&#8217;m initially very motivated to write. However more frequently than not I either never start it, or I drop it early on. This is because it doesn&#8217;t solve a problem of mine personally. That personal investment is just not there. However these two apps solve problems of mine and were therefore developed to completion. They don&#8217;t do anything complicated, but I rely on them, I use them frequently, and they make my life easier. There&#8217;s a great satisfaction in this.<\/p>\n<p>Write code to solve your own problems or automate tasks you perform frequently.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Writing a program to solve or automate a task you do regularly is the best way to learn something new in coding. Recently I&#8217;ve learnt a little bit about Android, java and regular expressions as a by-product of wanting to &hellip; <a href=\"https:\/\/acraig.za.net\/blog\/write-programs-to-automate-your-own-tasks\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-226","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/posts\/226","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/comments?post=226"}],"version-history":[{"count":3,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions"}],"predecessor-version":[{"id":230,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/posts\/226\/revisions\/230"}],"wp:attachment":[{"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/media?parent=226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/categories?post=226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/acraig.za.net\/blog\/wp-json\/wp\/v2\/tags?post=226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}