<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[christopher burke code blog]]></title><description><![CDATA[Christopher Burke, computer programmer, IT Professional]]></description><link>https://cburke.org</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 11:47:54 GMT</lastBuildDate><atom:link href="https://cburke.org/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Automate Data Entry]]></title><description><![CDATA[Needed a script for data entry. System has a GUI and I decided to use pyautogui to type the information in for me. This script was created for a specific purpose but could be adapted if needed.
I created a list of what values I needed to enter. Each ...]]></description><link>https://cburke.org/automate-data-entry</link><guid isPermaLink="true">https://cburke.org/automate-data-entry</guid><category><![CDATA[Python script]]></category><category><![CDATA[automation]]></category><dc:creator><![CDATA[Christopher Burke]]></dc:creator><pubDate>Thu, 18 Aug 2022 14:28:56 GMT</pubDate><content:encoded><![CDATA[<p>Needed a script for data entry. System has a GUI and I decided to use <strong>pyautogui</strong> to type the information in for me. This script was created for a specific purpose but could be adapted if needed.</p>
<p>I created a list of what values I needed to enter. Each item has 3 fields that need to be entered:</p>
<ul>
<li>Code</li>
<li>Description</li>
<li>Min Entry</li>
</ul>
<p>All of the fields are strings and are set in the <code>VALUES</code> variable.</p>
<p>Highlights of the script:</p>
<ul>
<li>Set an interval of 0.5 seconds for <strong>pyautogui</strong></li>
<li>Set a sleep for 10 seconds to place the cursor in the correct spot on the screen for entry</li>
<li>Calls to <code>press('enter', interval=INTERVAL)</code> advance the cursor to the next field and next row in the GUI</li>
<li>A sleep call was added to <code>val_code_entry</code> function as a failsafe if the script needs to be halted via <code>Ctrl+C</code></li>
</ul>
<p>Script:</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-string">"""Add codes to system."""</span>

<span class="hljs-keyword">from</span> time <span class="hljs-keyword">import</span> sleep
<span class="hljs-keyword">from</span> pyautogui <span class="hljs-keyword">import</span> press, typewrite


INTERVAL = <span class="hljs-number">0.5</span>

<span class="hljs-comment"># Sample Code, Description, and Min Entry values</span>
VALUES = [
    [<span class="hljs-string">'Code01'</span>, <span class="hljs-string">'CODE 1'</span>, <span class="hljs-string">'C01'</span>, ],
    [<span class="hljs-string">'Code02'</span>, <span class="hljs-string">'CODE 2'</span>, <span class="hljs-string">'C02'</span>, ],
    [<span class="hljs-string">'Code03'</span>, <span class="hljs-string">'CODE 3'</span>, <span class="hljs-string">'C03'</span>, ],
    [<span class="hljs-string">'Code04'</span>, <span class="hljs-string">'CODE 4'</span>, <span class="hljs-string">'C04'</span>, ],
]


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">val_code_entry</span>(<span class="hljs-params">code: str, description: str, min_entry: str, sleep_: int = <span class="hljs-number">3</span></span>):</span>
    <span class="hljs-string">"""Code entry process."""</span>
    typewrite(code, interval=INTERVAL)
    press(<span class="hljs-string">'enter'</span>, interval=INTERVAL)
    typewrite(description, interval=INTERVAL)
    press(<span class="hljs-string">'enter'</span>, interval=INTERVAL)
    typewrite(min_entry, interval=INTERVAL)
    press(<span class="hljs-string">'enter'</span>, interval=INTERVAL)
    press(<span class="hljs-string">'enter'</span>, interval=INTERVAL)
    press(<span class="hljs-string">'enter'</span>, interval=INTERVAL)
    sleep(sleep_)


<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    <span class="hljs-string">"""Main function."""</span>
    <span class="hljs-keyword">for</span> value <span class="hljs-keyword">in</span> VALUES:
        val_code_entry(code=value[<span class="hljs-number">0</span>],
                       description=value[<span class="hljs-number">1</span>],
                       min_entry=value[<span class="hljs-number">2</span>]
                       )


<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    print(<span class="hljs-string">'Sleeping for 10 seconds for cursor placement...'</span>)
    sleep(<span class="hljs-number">10</span>)
    main()
</code></pre>
<p>Ran the script and it worked. Saved my time and errors.</p>
<p>Enjoy! Happy Coding.</p>
<h2 id="heading-references">REFERENCES</h2>
<ul>
<li><a target="_blank" href="https://pyautogui.readthedocs.io/en/latest/">PyAutoGUI’s documentation</a></li>
<li><a target="_blank" href="https://github.com/asweigart/pyautogui">pyautogui GitHub</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Script creation process]]></title><description><![CDATA[I plan on writing about my process of creating scripts. I think sharing my experience and decisions made during the process could be helpful to many programmers. I shall add the subtitle [script] to signal these types of blog posts. 
Many times for w...]]></description><link>https://cburke.org/script-creation-process</link><guid isPermaLink="true">https://cburke.org/script-creation-process</guid><category><![CDATA[Script]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[Christopher Burke]]></dc:creator><pubDate>Tue, 26 Jul 2022 02:13:19 GMT</pubDate><content:encoded><![CDATA[<p>I plan on writing about my process of creating scripts. I think sharing my experience and decisions made during the process could be helpful to many programmers. I shall add the subtitle <em>[script]</em> to signal these types of blog posts. </p>
<p>Many times for work I create scripts or programs that do amazing things but do not get published. Many programming paradigms and problem-solving techniques can be showcased for others to learn from and discuss. We shall see what comes of these future blog posts, I think they will be beneficial.</p>
<p>The first script I will document is a <strong>Python</strong> script that will be used to update all users of an online system. I will dive into the reasoning for the change, document requirements, and share code samples from the script. </p>
<p>Stay tuned.</p>
]]></content:encoded></item><item><title><![CDATA[Build Python from Source]]></title><description><![CDATA[A good exercise that I feel has great benefits is building Python from the source repo. We will be building Python from CPython. CPython can be found on GitHub at https://github.com/python/cpython. I suggest forking the repo into your GitHub account....]]></description><link>https://cburke.org/build-python-from-source</link><guid isPermaLink="true">https://cburke.org/build-python-from-source</guid><dc:creator><![CDATA[Christopher Burke]]></dc:creator><pubDate>Mon, 14 Mar 2022 20:05:49 GMT</pubDate><content:encoded><![CDATA[<p>A good exercise that I feel has great benefits is building Python from the source repo. We will be building Python from CPython. CPython can be found on GitHub at https://github.com/python/cpython. I suggest forking the repo into your GitHub account. This can be done by simply visiting the CPython Github page and pressing ‘Fork’ on the top right. Choose to fork it to your username and it will be created at <code>"https://github.com/&lt;username&gt;/cpython"</code> (<code>&lt;username&gt;</code>is your Github username).</p>
<p>Your environment will need tools installed to compile the source code. There are countless resources are available online so I will not rehash it here. I suggest researching and looking into the tools you will need as you progress through the steps. Hitting breakpoints may allow for learning something new. </p>
<p>I am compiling to a <strong>macOS</strong> environment. Use a package manager like <strong>Homebrew</strong> for macOS to get the tools and utilities you need.</p>
<h2 id="heading-cpython-source-local-copy">CPython source local copy</h2>
<ol>
<li><p>Clone the CPython repo from your GitHub repositories:</p>
<pre><code class="lang-bash">$ git <span class="hljs-built_in">clone</span> git@github.com:&lt;username&gt;/cpython.git
</code></pre>
</li>
<li>Configure an upstream remote:<pre><code class="lang-bash">$ <span class="hljs-built_in">cd</span> cpython
$ git remote add upstream git@github.com:python/cpython.git
You can verify that your setup is correct using:
$ git remote -v
</code></pre>
</li>
</ol>
<p>After these steps you should have a folder in your environment called <code>cpython</code>. This directory will have source files from the cpython github repo. </p>
<h2 id="heading-compile-andgt-build-andgt-python">Compile &gt; Build &gt; Python</h2>
<ol>
<li>macOS install xcode developer tools:<pre><code class="lang-bash">$ xcode-select --install
</code></pre>
</li>
<li><p>Homebrew install the following, you may need them:</p>
<pre><code class="lang-bash">$ brew install openssl xz gdbm cmake wget pkg-config
</code></pre>
</li>
<li><p>Now configure Python. For this we will configure Python versions &gt;= 3.7:</p>
<pre><code class="lang-bash">$ ./configure --with-pydebug --with-openssl=$(brew --prefix openssl)
</code></pre>
</li>
<li><p>Then make:</p>
<pre><code class="lang-bash">$ make -s -j2
</code></pre>
</li>
</ol>
<h2 id="heading-test-python">Test Python</h2>
<p>You should now have a file python.exe in the cpython folder. Let’s test it:</p>
<ol>
<li>In the cpython folder type:<pre><code class="lang-bash">$ ./python.exe
</code></pre>
</li>
<li><p>Try importing modules. Check the ssl module:</p>
<pre><code class="lang-python">$ <span class="hljs-keyword">import</span> ssl
</code></pre>
<p>If there are no errors it means everything is installed properly. Otherwise, some dependencies were missed during the installation.</p>
</li>
<li><p>Exit the REPL. Type <code>exit()</code> or <code>quit()</code> command.</p>
</li>
<li><p>In the cpython folder type:</p>
<pre><code class="lang-bash">$ ./python.exe -m test_os
Raised RLIMIT_NOFILE: 256 -&gt; 1024
0:00:00 load avg: 2.60 Run tests sequentially
0:00:00 load avg: 2.60 [1/1] test_os
== Tests result: SUCCESS ==
1 <span class="hljs-built_in">test</span> OK.
Total duration: 3.7 sec
Tests result: SUCCESS
</code></pre>
</li>
<li><p>Made it this far with no errors, great! If something went wrong retrace your steps and try to debug the issue.</p>
</li>
</ol>
<h2 id="heading-closing">Closing</h2>
<p>Congratulations! You have a working, complied build of Python in your environment. Play around with the git repo and see if you can build different versions of Python.</p>
<p>Enjoy!
Happy Coding.</p>
<h2 id="heading-references">REFERENCES</h2>
<ol>
<li><a target="_blank" href="​​https://devguide.python.org/setup/#build-dependencies">Getting Started - Python Developer's Guide</a></li>
<li><a target="_blank" href="https://brew.sh/">Homebrew</a></li>
<li><a target="_blank" href="https://cpython-core-tutorial.readthedocs.io/en/latest/build_cpython_macos.html">Build CPython on macOS</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Python boilerplate keyboard shortcut]]></title><description><![CDATA[One thing I strive for is optimization.  Every language has code you have to repeat time and time again. When programming, I want to get to the interesting parts of the code and not have to stress or remember the boilerplate code.
My solution is a ke...]]></description><link>https://cburke.org/python-boilerplate-keyboard-shortcut</link><guid isPermaLink="true">https://cburke.org/python-boilerplate-keyboard-shortcut</guid><category><![CDATA[Python]]></category><category><![CDATA[Script]]></category><category><![CDATA[template]]></category><dc:creator><![CDATA[Christopher Burke]]></dc:creator><pubDate>Mon, 07 Mar 2022 02:46:07 GMT</pubDate><content:encoded><![CDATA[<p>One thing I strive for is optimization.  Every language has code you have to repeat time and time again. When programming, I want to get to the interesting parts of the code and not have to stress or remember the boilerplate code.</p>
<p>My solution is a keyboard shortcut. Quickly and easily, I can get a Python script template in my editor. An added benefit, I get consistency among my Python scripts.</p>
<p>I assign it to the typed shortcut <code>;;pytm</code> (<em>Python template</em>) to expand into:</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-string">""""""</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    <span class="hljs-keyword">pass</span>

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<p>Let's explain each part for better understanding.</p>
<h3 id="heading-shebang">Shebang</h3>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>
</code></pre>
<p>When executing a Python script, the shebang (<code>#!</code>) is used to tell your system what interpreter to use.  Used in Unix/Linux-based operating systems. For more information please visit: <a target="_blank" href="https://bash.cyberciti.biz/guide/Shebang">Shebang</a></p>
<p>Regardless of the operating system, I add in the shebang at the top of the Python script.</p>
<h3 id="heading-empty-docstring">Empty docstring</h3>
<pre><code class="lang-python"><span class="hljs-string">""""""</span>
</code></pre>
<p>When creating modules in Python, it is good practice to add a docstring. Documentation is important in explaining your code<em>indent</em>.</p>
<p>There is a Python Enhancement Proposals (PEP) about docstrings.  <a target="_blank" href="https://www.python.org/dev/peps/pep-0257/">
PEP 257 -- Docstring Conventions</a></p>
<h3 id="heading-main-function">Main function</h3>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    <span class="hljs-keyword">pass</span>
</code></pre>
<p>I define a <code>main</code> function for the module. This clearly indicates to the code reader this is the entry point to the script/program. <em>Most times that reader is me in the future</em>. Although this function could be named anything, many other languages use <code>main</code> as the entry point, so I follow that same convention in my Python scripts. <em>Why reinvent the wheel, right?</em></p>
<h3 id="heading-name-main"><strong>name</strong> == “<strong>main</strong>”</h3>
<pre><code><span class="hljs-keyword">if</span> __name__ <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-string">"__main__"</span>:
    main()
</code></pre><p>Part is Python syntax. This tells the interpreter if this module is executed, run all the statements in this if block. For more information, check out <a target="_blank" href="https://www.geeksforgeeks.org/what-does-the-if-__name__-__main__-do/">What does the if <strong>name</strong> == “<strong>main</strong>”: do?</a></p>
<h3 id="heading-myscript-example">myscript example</h3>
<p>Here is a <code>myscript.py</code> example:</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-string">"""Myscript - prints "Hello, World." to the terminal."""</span>

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    print(<span class="hljs-string">"Hello, World."</span>)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    main()
</code></pre>
<p>Enjoy and happy coding!</p>
<hr />
<p>References:</p>
<ol>
<li><a target="_blank" href="https://bash.cyberciti.biz/guide/Shebang">Linux Bash Shell Scripting Tutorial - Shebang</a></li>
<li><a target="_blank" href="https://www.python.org/dev/peps/pep-0257/">
PEP 257 -- Docstring Conventions</a></li>
<li><a target="_blank" href="https://www.geeksforgeeks.org/what-does-the-if-__name__-__main__-do/">GeeksforGeeks - What does the if <strong>name</strong> == “<strong>main</strong>”: do?</a></li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Code Blog]]></title><description><![CDATA[Greetings all. This is going to be my code blog. A place for me to share my code and thoughts.
Hope you enjoy it.
Thank you.]]></description><link>https://cburke.org/code-blog</link><guid isPermaLink="true">https://cburke.org/code-blog</guid><dc:creator><![CDATA[Christopher Burke]]></dc:creator><pubDate>Fri, 04 Mar 2022 18:51:25 GMT</pubDate><content:encoded><![CDATA[<p>Greetings all. This is going to be my code blog. A place for me to share my code and thoughts.</p>
<p>Hope you enjoy it.</p>
<p>Thank you.</p>
]]></content:encoded></item></channel></rss>