<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jorge Riquelme Santana on Medium]]></title>
        <description><![CDATA[Stories by Jorge Riquelme Santana on Medium]]></description>
        <link>https://medium.com/@jriquelme?source=rss-919b39f743eb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ko2zRALtZ6fdZmGg7VU-DQ.png</url>
            <title>Stories by Jorge Riquelme Santana on Medium</title>
            <link>https://medium.com/@jriquelme?source=rss-919b39f743eb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:16:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jriquelme/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[UUID v5 in Redshift]]></title>
            <link>https://medium.com/@jriquelme/uuid-v5-in-redshift-9478fbfa719d?source=rss-919b39f743eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9478fbfa719d</guid>
            <category><![CDATA[uuid]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[redshift]]></category>
            <dc:creator><![CDATA[Jorge Riquelme Santana]]></dc:creator>
            <pubDate>Fri, 24 Apr 2020 00:00:05 GMT</pubDate>
            <atom:updated>2020-04-24T00:03:05.096Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been working in a “data loader” using Redshift, where data can come through a REST API and directly from CSV files stored in S3. The API assigns an id field, autogenerated from a “key” column using UUID v5, so the same functionality would be needed when ingesting data from S3. Redshift doesn’t provide a function out of the box to calculate UUID v5, but luckily it allows us to define functions in Python (among other languages).</p><p>Long story short, the function below returns a UUID v5 from a namespace and a value:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/295be6291cd3bded1ddf67314c1d7b4f/href">https://medium.com/media/295be6291cd3bded1ddf67314c1d7b4f/href</a></iframe><p>Don’t forget to grant privileges on any user executing the function:</p><pre>grant execute on function <em>f_py_uuid5</em>(namespace varchar, name varchar) to data_loader;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9478fbfa719d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Docker images with Python]]></title>
            <link>https://medium.com/larix/building-docker-images-with-python-ed21231df2f3?source=rss-919b39f743eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed21231df2f3</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Jorge Riquelme Santana]]></dc:creator>
            <pubDate>Sat, 24 Mar 2018 04:05:58 GMT</pubDate>
            <atom:updated>2018-03-25T18:31:13.846Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I was creating some Dockerfiles, and all of them shared the same structure. Something like:</p><pre>FROM buildpack-deps:jessie-curl<br>COPY suntechadp /usr/bin/<br>ENTRYPOINT [&quot;/usr/bin/suntechadp&quot;]</pre><p>It was just five small Dockerfiles, but naturally, I wondered if the task could be automated. So, instead of a fast copy-paste and replace it, I spent about an hour playing with the <a href="https://github.com/docker/docker-py">Docker SDK for Python</a> 😅</p><p>The script should:</p><ul><li>Locate a binary in <em>$GOPATH/bin</em>.</li><li>Generate a Dockerfile using the structure shown above.</li><li>Create a .tgz (the Docker build context) with the binary and the Dockerfile.</li><li>Create the new Docker image using the .tgz content.</li></ul><p>The GIST below shows a Python (3.6) implementation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80e51f751a786bfd720ba706876f20c8/href">https://medium.com/media/80e51f751a786bfd720ba706876f20c8/href</a></iframe><p>The script has two positional parameters: the binary and the image tag; also, an optional flag ( <em>— save-ctx</em>) to save the build context as a .tgz file. For example, to create an image using the binary <em>suntechadp</em> tagged as <em>larix/suntechadp</em>:</p><pre>$ python build-img.py suntechadp larix/suntechadp --save-ctx</pre><p>For a simple task like this, some bash scripting would have been enough. However, exploring the <a href="https://github.com/docker/docker-py">Docker SDK for Python</a> is worth to get an idea of what can be automated. On large projects, could be reasonable to build custom tools to support the development workflow or to implement part of a <a href="https://martinfowler.com/bliki/ContinuousDelivery.html">CD pipeline</a> (for example, this script can be extended to upload the Docker image to <a href="https://aws.amazon.com/ecr">ECR</a> without a hassle).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed21231df2f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/larix/building-docker-images-with-python-ed21231df2f3">Building Docker images with Python</a> was originally published in <a href="https://medium.com/larix">larix</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unmarshalling JSON to GO structs with a variable-type property]]></title>
            <link>https://medium.com/larix/unmarshalling-json-to-go-structs-with-a-variable-type-property-72344a57948d?source=rss-919b39f743eb------2</link>
            <guid isPermaLink="false">https://medium.com/p/72344a57948d</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Jorge Riquelme Santana]]></dc:creator>
            <pubDate>Thu, 15 Mar 2018 17:34:45 GMT</pubDate>
            <atom:updated>2018-03-15T17:34:45.123Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently I faced a problem trying to unmarshal a JSON message to GO structs. I’m migrating a nodejs REST service to GO and, in one POST operation, a single property can have two different types of values: a string or an object.</p><p>A simplified example of the situation is shown below. In this case the messages are “job offers”, having only two properties: a business and the position. The property <em>business</em> can be a simple string (the business id):</p><pre>{<br>  &quot;business&quot;: &quot;76261649-1&quot;,<br>  &quot;position&quot;: &quot;Software Developer&quot;<br>}</pre><p>or an object, having the properties <em>id</em> and <em>name</em>:</p><pre>{<br>  &quot;business&quot;:{<br>    &quot;id&quot;: &quot;76261649-1&quot;,<br>    &quot;name&quot;: &quot;Larix Sistemas Informáticos Limitada&quot;<br>  },<br>  &quot;position&quot;: &quot;Software Developer&quot;<br>}</pre><p>To cope with this scenario (easily) in GO, you can implement a custom unmarshaller. The Gist below shows a sample implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f9647adaf9436ed0052554dc6e7328ea/href">https://medium.com/media/f9647adaf9436ed0052554dc6e7328ea/href</a></iframe><p>The business JSON object can be represented as usual with a tagged struct type (<em>Business</em>). Likewise, the job offer can be represented with a tagged struct (<em>JobOffer</em>), however the type of its <em>business</em> property, <em>BusinessRef</em>, has the following characteristics:</p><ul><li>Embeds the <em>Business</em> type.</li><li>Contains a field, <em>IDOnly</em>, that will be true if the value was a string, false otherwise.</li><li>Implements the <em>json.Unmarshaler</em> interface.</li></ul><p>The function (*BusinessRef) UnmarshalJSON([]byte) error tries to unmarshal the <em>business</em> value into a string first and if it succeeds, the id is saved in the embedded <em>Business</em> and the field <em>IDOnly</em> is set to true. Only if an <em>UnmarshalTypeError</em> occurs and the given value is an object, the function tries to unmarshal the value directly into the embedded <em>Business</em>; any other error is returned as-is to the caller.</p><p>The opposite operation can be done using the same strategy (implementing the <em>json.Marshaler</em> interface).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72344a57948d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/larix/unmarshalling-json-to-go-structs-with-a-variable-type-property-72344a57948d">Unmarshalling JSON to GO structs with a variable-type property</a> was originally published in <a href="https://medium.com/larix">larix</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>