<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Francis Bergin</title><link>https://francisbergin.net/</link><description>Recent content on Francis Bergin</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 26 Jul 2020 00:00:00 +0000</lastBuildDate><atom:link href="https://francisbergin.net/index.xml" rel="self" type="application/rss+xml"/><item><title>A first go at Go</title><link>https://francisbergin.net/posts/2020/07/26/a-first-go-at-go/</link><pubDate>Sun, 26 Jul 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/07/26/a-first-go-at-go/</guid><description>&lt;p&gt;This month, I wrote a first Go program. I had played around with the features of
the programming language a few times before but had never put together something
actually useful. Coming from a Python background, I thought it would be useful
to share my process and experience with others.&lt;/p&gt;
&lt;p&gt;The app itself is a CLI RSS and Atom feed lister. It reads a file containing a
list of feed URLs and displays the posts from the last month. In this simple
project, I was able to use and understand &lt;a href="https://tour.golang.org/concurrency/1"&gt;Goroutines&lt;/a&gt; and &lt;a href="https://tour.golang.org/concurrency/2"&gt;Channels&lt;/a&gt; more in
depth.&lt;/p&gt;</description></item><item><title>fakesocial: Fake social network using generated content</title><link>https://francisbergin.net/posts/2020/06/06/fakesocial-fake-social-network-using-generated-content/</link><pubDate>Sat, 06 Jun 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/06/06/fakesocial-fake-social-network-using-generated-content/</guid><description>&lt;p&gt;Last weekend, I released &lt;a href="https://fakesocial.net"&gt;fakesocial&lt;/a&gt; (&lt;a href="https://github.com/francisbergin/fakesocial"&gt;source code&lt;/a&gt;) after working on it for
the last few weeks and am pretty pleased with the result. Here, I will discuss a
few things about the project.&lt;/p&gt;
&lt;p&gt;To start with, fakesocial is a simple social network consisting of fake users
which have connections, make posts and also like and comment on these posts.
These user profiles use generated images as profile pictures and generated text
as posts and comments. The social network is then packaged as a website and
served on the internet.&lt;/p&gt;</description></item><item><title>Execution time experiment</title><link>https://francisbergin.net/posts/2020/04/30/execution-time-experiment/</link><pubDate>Thu, 30 Apr 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/04/30/execution-time-experiment/</guid><description>&lt;p&gt;Consider this Python program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python3" data-lang="python3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# num_add.py&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;123456789&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;ans&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ans&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It runs in a little over 10 seconds:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; &lt;span class="nb"&gt;time&lt;/span&gt; python num_add.py
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;123456789
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="err"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;real 0m12.896s
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;user 0m12.868s
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;sys 0m0.008s
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This result is expected; it takes a certain amount of time to perform more than
one hundred million additions. During this, my computer was working hard; the
fans started going pretty fast.&lt;/p&gt;
&lt;p&gt;Now consider this Python program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python3" data-lang="python3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# sleep.py&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;time&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;12.8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;123456789&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It executes in about the same amount of time and outputs the same thing:&lt;/p&gt;</description></item><item><title>watch-diff: Watch command output and get notified on changes</title><link>https://francisbergin.net/posts/2020/03/01/watch-diff-watch-command-output-and-get-notified-on-changes/</link><pubDate>Sun, 01 Mar 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/03/01/watch-diff-watch-command-output-and-get-notified-on-changes/</guid><description>&lt;p&gt;For a few months now, I have been using my
&lt;a href="https://github.com/francisbergin/watch-diff"&gt;&lt;code&gt;watch-diff&lt;/code&gt;&lt;/a&gt; project to get notified on
command output changes. The beauty of this simple tool is that it works with any
command that can be executed in the shell. This means that once you figure out
the exact command you need to monitor, you simply plug it into &lt;code&gt;watch-diff&lt;/code&gt; and
you automatically get email notifications on updates.&lt;/p&gt;
&lt;h2 id="example-monitoring-current-releases"&gt;Example: monitoring current releases&lt;/h2&gt;
&lt;p&gt;Here is the output for monitoring the current version of this package on the
PyPI website while a release is being made:&lt;/p&gt;</description></item><item><title>Deploying to S3 with Sourcehut</title><link>https://francisbergin.net/posts/2020/02/05/deploying-to-s3-with-sourcehut/</link><pubDate>Wed, 05 Feb 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/02/05/deploying-to-s3-with-sourcehut/</guid><description>&lt;p&gt;In this article, we will go through the process of automatically building and
deploying this &lt;a href="https://gohugo.io"&gt;Hugo&lt;/a&gt; website to &lt;a href="https://aws.amazon.com/s3"&gt;Amazon S3&lt;/a&gt; using &lt;a href="https://sourcehut.org"&gt;Sourcehut&lt;/a&gt;
&lt;a href="https://builds.sr.ht"&gt;builds.sr.ht&lt;/a&gt;. This post assumes you already have a static website that is
hosted on S3; there are plenty of guides online concerning this if it is not the
case.&lt;/p&gt;
&lt;h2 id="iam-policy-for-s3-bucket-access"&gt;IAM policy for S3 bucket access&lt;/h2&gt;
&lt;p&gt;The first step is to create an &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html"&gt;IAM user&lt;/a&gt; with an &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html"&gt;IAM policy&lt;/a&gt; that can only
modify the contents of the specific S3 bucket. This will ensure that if the user
credentials are compromised, only the specific bucket is affected and not your
complete AWS account. This is important since this user secret key will be saved
on Sourcehut which is not immune to security bugs and breaches.&lt;/p&gt;</description></item><item><title>Commit history data analysis</title><link>https://francisbergin.net/posts/2020/01/10/commit-history-data-analysis/</link><pubDate>Fri, 10 Jan 2020 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2020/01/10/commit-history-data-analysis/</guid><description>&lt;p&gt;In this post, I will describe the
&lt;a href="https://github.com/francisbergin/commit-history-data-analysis"&gt;francisbergin/commit-history-data-analysis&lt;/a&gt;
tools and results as well as a few thoughts on version control hosting and
commit histories. There are many tools out there with the purpose of extracting
insights from single code repositories; this one has the goal of analyzing the
many repositories of a single user.&lt;/p&gt;
&lt;h2 id="commit-aggregation"&gt;Commit aggregation&lt;/h2&gt;
&lt;p&gt;The main script found in the repository mentioned above simply outputs a &lt;code&gt;git log&lt;/code&gt; in comma separated values (CSV) format for all the Git repositories found
under a given path and for a specified author. For example, if all your
repositories are under &lt;code&gt;~/code&lt;/code&gt; and your email is &lt;code&gt;a@abc.com&lt;/code&gt;, you can execute
the script with &lt;code&gt;./get-data.sh ~/code a@abc.com&lt;/code&gt;. The resulting CSV log will
then be found at &lt;code&gt;data/results.csv&lt;/code&gt;. It is also possible to give multiple emails
or names; they will be prepended with &lt;code&gt;--author&lt;/code&gt; when passed to the &lt;code&gt;git&lt;/code&gt;
command. The included &lt;code&gt;git-csvlog&lt;/code&gt; script can be used on its own in Git
projects.&lt;/p&gt;</description></item><item><title>Getting started with the STM32F4 and FreeRTOS</title><link>https://francisbergin.net/posts/2019/12/27/getting-started-with-the-stm32f4-and-freertos/</link><pubDate>Fri, 27 Dec 2019 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2019/12/27/getting-started-with-the-stm32f4-and-freertos/</guid><description>&lt;p&gt;In this post, I&amp;rsquo;ll simply share a few observations on setting up a FreeRTOS
project for the STM32F4 Discovery board. This guide is based on the
&lt;a href="https://github.com/francisbergin/stm32f4discovery"&gt;francisbergin/stm32f4discovery&lt;/a&gt; repository
which is fully configured and ready to use. The specific commands mentioned in
this post are noted in the &lt;code&gt;README&lt;/code&gt; or the &lt;code&gt;CMakeLists&lt;/code&gt; files of the project.&lt;/p&gt;
&lt;h2 id="hardware"&gt;Hardware&lt;/h2&gt;
&lt;p&gt;The STM32F4 Discovery board has the following core components:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;STM32F407VGT6 Microcontroller
&lt;ul&gt;
&lt;li&gt;32-bit ARM Corex-M4 with FPU Core
&lt;ul&gt;
&lt;li&gt;ARMv7E-M Architecture&lt;/li&gt;
&lt;li&gt;Thumb-1, Thumb-2, DSP, FPU (Single Precision) instruction sets&lt;/li&gt;
&lt;li&gt;Single Precision FPU: fpv4-sp-d16&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;16 MHz High Speed Internal (HSI) RC Oscillator&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;ST-LINK/V2 used for programming and debugging&lt;/li&gt;
&lt;li&gt;8 MHz High Speed External (HSE) Oscillator&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="clock-configuration"&gt;Clock configuration&lt;/h2&gt;
&lt;p&gt;On start up, the 16 MHz internal oscillator is selected as CPU clock. Through
software, we can select to use an external oscillator as clock source. This
clock source is fed to a phase lock loop (PLL) which can increase the frequency
up to 168 MHz. The clock is set up using the &lt;code&gt;SystemCoreClockUpdate&lt;/code&gt; function
from the &lt;code&gt;system_stm32f4xx.c&lt;/code&gt; file. By default, for this MCU, the clock speed is
configured using the HSE and PLL to output 168 MHz. However, the default HSE
value is 25 MHz and so we need to modify it to 8 MHz. The &lt;code&gt;PLL_M&lt;/code&gt; is also
modified from 25 to 8. The calculation for the &lt;code&gt;SYSCLK&lt;/code&gt; value is as follows:&lt;/p&gt;</description></item><item><title>About this blog</title><link>https://francisbergin.net/posts/2019/12/20/about-this-blog/</link><pubDate>Fri, 20 Dec 2019 00:00:00 +0000</pubDate><guid>https://francisbergin.net/posts/2019/12/20/about-this-blog/</guid><description>&lt;p&gt;Throughout the years, I have learned a tremendous amount by reading various
blogs on the internet. These are sites I regularly go to or that pop up in
search results when researching a specific topic. The information I find useful
ranges from low level details to high level wisdom. I believe all these sources
are part of my education and I appreciate the authors very much for it. With
this blog, I hope to share some ideas and insights so that other people may
benefit the way I still do every day.&lt;/p&gt;</description></item></channel></rss>