{"id":235,"date":"2018-02-24T18:35:19","date_gmt":"2018-02-24T17:35:19","guid":{"rendered":"http:\/\/blog.balazspocze.me\/?p=235"},"modified":"2026-11-10T05:52:00","modified_gmt":"2026-11-10T05:52:00","slug":"what-to-do-with-the-one-shot-scripts","status":"publish","type":"post","link":"https:\/\/banyek.net\/?p=235&lang=en","title":{"rendered":"What to do with the one-shot scripts"},"content":{"rendered":"<p>I can&#8217;t really answer this question, but I am really curious.<\/p>\n<p>During work, I often have small(ish) tasks to solve, and when it is possible I rather write small one-shot scripts instead of doing some manual labor.<\/p>\n<p>These scripts are rough, they are not made perfect because they don&#8217;t have to, they have one purpose, and they have to do it right. Sometimes they have small mistakes in them, sometimes they just aren&#8217;t perfect, sometimes they are awful. There are always compromises when creating these like &#8216;does this task worth that plus hours to put them, or just aim for the solvable problem&#8217;.<\/p>\n<p>Let me show this in an example. Today I am working on a script what copies big amounts of data between two servers, I want to do it multithreaded, but I also want to limit the number of threads.<\/p>\n<p>My quick and dirty solution looks like this:<br \/>\n<code> for row in cursor:<br \/>\nwhile len(threading.enumerate()) &gt; MAXTHREADS + 1:<br \/>\ntime.sleep(.1)<br \/>\nworker = Worker(row)<\/code><\/p>\n<p>Yes, I know, civilized people don&#8217;t use &#8216;sleep&#8217;, because that is a waste of CPU, but hey, I will run this script on an ephemeral EC2 instance, so I really don&#8217;t care. This will do it, so deal with it.<\/p>\n<p>But after the migration, I do want to keep this script somewhere because it is possible that I&#8217;ll need something like this in the future, and I don&#8217;t want to reinvent the wheel then.<\/p>\n<p>My GitHub account would be a perfect place for them, but I am not sure if I can put them there. I mean GitHub account is like a business card (remember Patrick Bateman), I don&#8217;t want to put ugly code them &#8211; I mean if I want to find a new workplace, then it will be possible that they will check my GitHub stuff, and I don&#8217;t want them to think if I am a bad coder.<\/p>\n<p>If I had a paid account (which I don&#8217;t have) then I&#8217;d put these into a private repo.<\/p>\n<p>Nowadays I put these into gists, but gists are not easy to search, so that is not perfect as well.<\/p>\n<p>I am not sure what would be the best.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I can&#8217;t really answer this question, but I am really curious. During work, I often have small(ish) tasks to solve, and when it is possible I rather write small one-shot scripts instead of doing some manual labor. These scripts are rough, they are not made perfect because they don&#8217;t have to, they have one purpose, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[134],"tags":[148,150,126,130],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-tech-en","tag-coding-en","tag-devops-en","tag-oldblog-en","tag-work-env-en"],"_links":{"self":[{"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/banyek.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=235"}],"version-history":[{"count":1,"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":408,"href":"https:\/\/banyek.net\/index.php?rest_route=\/wp\/v2\/posts\/235\/revisions\/408"}],"wp:attachment":[{"href":"https:\/\/banyek.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/banyek.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/banyek.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}