<?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 Dominik Jäckle on Medium]]></title>
        <description><![CDATA[Stories by Dominik Jäckle on Medium]]></description>
        <link>https://medium.com/@dominikjaeckle?source=rss-dec04f4e2fb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*a-T8B2SHtqDsdBZ6fvrBTg.jpeg</url>
            <title>Stories by Dominik Jäckle on Medium</title>
            <link>https://medium.com/@dominikjaeckle?source=rss-dec04f4e2fb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:13:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dominikjaeckle/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[A Python Script to Fetch and Process AWS Security Hub Findings Using the AWS CLI]]></title>
            <link>https://python.plainenglish.io/a-python-script-to-fetch-and-process-aws-security-hub-findings-using-the-aws-cli-34bca4933c29?source=rss-dec04f4e2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/34bca4933c29</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws-security-hub]]></category>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Dominik Jäckle]]></dc:creator>
            <pubDate>Sat, 26 Mar 2022 19:43:54 GMT</pubDate>
            <atom:updated>2022-03-30T08:52:30.312Z</atom:updated>
            <content:encoded><![CDATA[<h4>A guide on how to fetch security findings automatically in Python using the AWS CLI, Pydandic, and Pyyaml.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qW54HRErgImEVIj7" /><figcaption>Photo by <a href="https://unsplash.com/@floriankrumm?utm_source=medium&amp;utm_medium=referral">Florian Krumm</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The AWS Security Hub is a service, which serves the sole purpose to make you aware and help track possible security breaches of deployed code and infrastructure. The Security Hub helps you administer such security findings efficiently.</p><p>In this post, I will briefly describe a way to fetch security findings automatically in python using the AWS CLI, Pydandic, and Pyyaml.</p><ul><li>The <strong>AWS CLI </strong>is a command-line interface that helps you to manage your entire set of AWS services. → <a href="https://aws.amazon.com/cli/">https://aws.amazon.com/cli/</a></li><li><strong>Pydandic</strong> introduces powerful means to add typed objects to your python code. → <a href="https://pydantic-docs.helpmanual.io/">https://pydantic-docs.helpmanual.io</a></li><li><strong>Pyyaml</strong> is a neat library to process .yaml/.yml files. → <a href="https://pyyaml.org/">https://pyyaml.org</a></li></ul><p>As a prerequisite, you need at least one AWS account.</p><h3>The AWS CLI</h3><p>To set up the CLI and configure your AWS profiles, follow the instructions on this website:</p><p><a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">Configuring settings for the AWS CLI</a></p><p>The CLI gives you, as an AWS user, full control over all offered services. For the security hub, you can use the following command (all possible arguments are documented <a href="https://docs.aws.amazon.com/cli/latest/reference/securityhub/get-findings.html">here</a>):</p><pre>$ export AWS_PROFILE=XXX<br>$ get-findings --filters JSONFILTER --sort-criteria SORTCRITERIA</pre><p>Where XXX is the profile that you configured in ~/.aws/config. <strong>JSONFILTER</strong> refers to a JSON dictionary that passes a set of filters. The filters are the same you can set them manually in the AWS console. The <strong>SORTCRITERIA</strong> defines how you want the results to be sorted. In the next steps, we will use this very basic command, wrap a configuration around it, and process the results using python.</p><h3>Execute an AWS CLI command from python and parse the results</h3><p>Various python libraries exist that help you access the full-fledged functionality of your shell. However, to execute the AWS CLI <strong>get-findings</strong> command, we keep it simple. The <strong>os</strong> module offers what we need:</p><pre>import os<br>import json</pre><pre>os.environ[&#39;AWS_PROFILE&#39;] = &#39;XXX&#39;</pre><pre>findings_raw = os.popen(f&#39;aws securityhub get-findings --filters {filterstr} --sort-criteria {sortcriteria} --page-size 100 --max-items 1000&#39;)<br>findings_json = json.loads(findings_raw.read())[&#39;Findings&#39;]</pre><p>First, we set the AWS_PROFILE, required to let the current session know, which AWS configuration to use. Note that we use an f-string for the CLI execution. We will construct the used variables later. The result is a JSON, which we need to parse so that we can access that dictionary within our python code. Let’s restrict ourselves only to a subset of the given result attributes:</p><pre>findings: List[Finding] = []<br>for f in findings_json:<br>  finding = Finding()<br>  finding.environment = environment<br>  finding.account_id = f[&#39;AwsAccountId&#39;]<br>  finding.created_at = f[&#39;CreatedAt&#39;]<br>  finding.updated_at = f[&#39;UpdatedAt&#39;]<br>  finding.compliance_status = f[&quot;Compliance&quot;][&quot;Status&quot;] if (&quot;Compliance&quot; in f.keys()) else &#39;&#39;<br>  finding.title = f[&quot;Title&quot;]<br>  finding.description = f[&quot;Description&quot;]<br>  finding.recommendation_text = f[&quot;Remediation&quot;][&quot;Recommendation&quot;][&quot;Text&quot;] if (&quot;Remediation&quot; in f.keys()) else &#39;&#39;<br>  finding.recommendation_url = f[&quot;Remediation&quot;][&quot;Recommendation&quot;][&quot;Url&quot;] if (&quot;Remediation&quot; in f.keys() and &quot;Url&quot; in f[&quot;Remediation&quot;][&quot;Recommendation&quot;].keys()) else &#39;&#39;<br>  finding.workflow_state = f[&quot;WorkflowState&quot;]<br>  finding.workflow_status = f[&quot;Workflow&quot;][&quot;Status&quot;]<br>  finding.record_state = f[&quot;RecordState&quot;]<br>  finding.severity_label = f[&quot;FindingProviderFields&quot;][&quot;Severity&quot;][&quot;Label&quot;]</pre><pre>findings.append(finding)</pre><p>For some of the attributes, a result is not a given, thus, we check if the attribute identifier is part of the result set by checking the list of result keys().</p><p>As you may have noticed, the findings list is typed: <strong>Finding</strong>. This type is introduced using pydantic.</p><p>Yes, you can type your Findings also without pydantic. Yet, I like how it helps you validate types at runtime and how it makes error messages more readable. The definition of a Finding is rather simple, inheriting from the pydantic BaseModel.</p><pre>class Finding(BaseModel):<br>  environment: str = &#39;&#39;<br>  account_id: str = &#39;&#39;<br>  created_at: str = &#39;&#39;<br>  updated_at: str = &#39;&#39;<br>  compliance_status: str = &#39;&#39;<br>  title: str = &#39;&#39;<br>  description: str = &#39;&#39;<br>  recommendation_text: str = &#39;&#39;<br>  recommendation_url: str = &#39;&#39;<br>  workflow_state: str = &#39;&#39;<br>  workflow_status: str = &#39;&#39;<br>  record_state: str = &#39;&#39;<br>  severity_label: str = &#39;&#39;</pre><p>If you are planning to extend this model with additional attributes, feel free to add them to the Finding class.</p><h3>Configuration</h3><p>Remember, that we used two variables in the f-string above when executing the CLI command? Let’s wrap them into a configuration. My favorite data serialization language is YAML, also because of its simplicity.</p><pre>accounts:<br>  - $$profile1$$<br>  - $$profile2$$<br>  - ...</pre><pre>filters:<br>  - filter_name: WorkflowStatus<br>    value: NEW<br>    comparison: EQUALS<br>  - filter_name: SeverityLabel<br>    value: HIGH<br>    comparison: EQUALS<br>  - filter_name: RecordState<br>    value: ACTIVE<br>    comparison: EQUALS</pre><pre>sort_criteria:<br>  field: LastObservedAt<br>  sort_order: desc</pre><p>The first part of <strong>accounts</strong> lets you define all configured AWS accounts from where the Security Hub findings should be fetched. Yes, you are right, using this script, we can concatenate the results from many different AWS accounts, which may come in handy, in particular, for huge projects, where it is common to use multiple accounts.</p><p>The second part lets you define all <strong>filters</strong>. I added three very basic ones.</p><p>The third part simply lets you define how the results should be sorted.</p><p>To read the config (let’s call it <strong>settings.yaml</strong>), we use pyyaml:</p><pre>import yaml</pre><pre>settings = None<br>with open(&#39;settings.yaml&#39;, &#39;r&#39;) as stream:<br>  settings = yaml.safe_load(stream)</pre><h3>Bringing all together</h3><p>Let’s wrap things up: First, we need to use the configuration and extract all environments, then all filters, and then the sorting criteria:</p><pre>environments = settings[&#39;accounts&#39;]</pre><pre>filterstr = &#39;\&#39;{&#39; + &#39;,&#39;.join(f&#39;&quot;{x[&quot;filter_name&quot;]}&quot;: [{{&quot;Value&quot;: &quot;{x[&quot;value&quot;]}&quot;, &quot;Comparison&quot;: &quot;{x[&quot;comparison&quot;]}&quot;}}]&#39; for x in settings[&#39;filters&#39;])+ &#39;}\&#39;&#39;</pre><pre>sortcriteria = f&#39;\&#39;{{&quot;Field&quot;: &quot;{settings[&quot;sort_criteria&quot;][&quot;field&quot;]}&quot;, &quot;SortOrder&quot;: &quot;{settings[&quot;sort_criteria&quot;][&quot;sort_order&quot;]}&quot;}}\&#39;&#39;</pre><p>For the <strong>filterstr</strong> variable, I make use of a join operation in combination with a list comprehension. The result is a nicely formatted JSON as described in the documentation on how to use filters.</p><p>You can find the final code, which will create a .html file of all findings on GitHub:</p><p><a href="https://github.com/dominikjaeckle/aws-fetch-security-hub-findings">GitHub - dominikjaeckle/aws-fetch-security-hub-findings: Small script to fetch security hub findings based on defined aws profiles and filters</a></p><p>That’s it for this topic. Thank you for reading.</p><p><em>More content at</em><strong><em> </em></strong><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><em> and </em><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>. Join our</em><strong><em> </em></strong><a href="https://discord.gg/GtDtUAvyhW"><strong><em>community Discord</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34bca4933c29" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/a-python-script-to-fetch-and-process-aws-security-hub-findings-using-the-aws-cli-34bca4933c29">A Python Script to Fetch and Process AWS Security Hub Findings Using the AWS CLI</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Set Up Python and Poetry]]></title>
            <link>https://python.plainenglish.io/setting-up-python-and-poetry-29de55db9ea0?source=rss-dec04f4e2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/29de55db9ea0</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[pyenv]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Dominik Jäckle]]></dc:creator>
            <pubDate>Tue, 15 Mar 2022 18:41:29 GMT</pubDate>
            <atom:updated>2022-03-22T06:35:32.964Z</atom:updated>
            <content:encoded><![CDATA[<h4>A simple guide to set up Python with pyenv and Poetry as your standard dependency and packaging manager.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LD2nWe9R-RDkDw58" /><figcaption>Photo by <a href="https://unsplash.com/@joshuaryanphoto?utm_source=medium&amp;utm_medium=referral">Joshua Reddekopp</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Being new to Python, did you ever wonder why you are running into so many issues, not only related to installing but also using your Python version 3.x over the preinstalled 2.7? As a Mac user, I also had my encounters … leading to the final solution to use pyenv as a version management library 🚀.</p><p>Another challenge I encountered was writing packages that can be delivered efficiently. With <a href="https://python-poetry.org/">Poetry</a> — a dependency and packaging manager for Python — I found what I was searching for.</p><p>As of now, setting up my Python version with pyenv, and using Poetry for dependency management and packaging, became my standard way of starting any new project.</p><h4>Setting up Python using pyenv</h4><p>First, install pyenv. There are different ways to do so as described <a href="https://github.com/pyenv/pyenv#installation">here</a>. For Mac, I choose the option to go with <a href="https://brew.sh/">Homebrew</a>.</p><pre>$ brew install pyenv</pre><p>And don’t forget to add the following lines to your <strong>.bash_profile</strong> or <strong>.zshrc</strong> file if you are using Zsh.</p><pre>if command -v pyenv 1&gt;/dev/null 2&gt;&amp;1; then<br>  eval &quot;$(pyenv init -)&quot;<br>fi<br>export PATH=&quot;$(pyenv root)/shims:$PATH&quot;</pre><p>Once pyenv is installed, you can choose between any Python versions to install as simple as in:</p><pre>$ pyenv install 3.8.10</pre><p>Now comes the cool stuff: You can set the downloaded Python version either as the <strong>local</strong> version for your project or you can set it as <strong>global</strong> version. But first, check all versions that have been installed already via the following command:</p><pre>$ pyenv versions<br>* system (currently set version)<br>3.10.0<br>3.8.10</pre><p>You can change the globally set python version with the command:</p><pre>$ pyenv global 3.8.10</pre><p>resulting in:</p><pre>$ pyenv versions<br>system<br>3.10.0<br>* 3.8.10 (newly set global Python version)</pre><h4>Setting up Poetry</h4><p>Poetry facilitates maintaining specific Python package dependencies as well as rolling out your final, reusable code. You can install Poetry via:</p><pre>$ curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -</pre><p>Then you are good to go. If you are familiar with other dependency managers such as npm, the following steps may look familiar.</p><p>You can start a new project using:</p><pre>$ poetry new my-app<br>Created package my_app in my-app</pre><p>The created package structure may look similar to the following one:</p><pre>my_app<br>  |-- __init__.py<br>  |-- my_app.py<br>tests<br>  |-- __init__.py<br>  |-- test_my_app.py<br>pyproject.toml<br>README.txt</pre><p>The folder <strong>my_app</strong> contains your modules. Here, you start your awesome coding work. In <strong>tests</strong> you write your unit tests to ensure a good code quality and robust code.</p><p>The file<strong> pyproject.toml</strong> comprises some general information as well as your dependencies. You may want to compare it to something like the <strong>package.json</strong> file generated via npm — the concept is quite similar.</p><pre>[tool.poetry]<br>name = &quot;my-app&quot;<br>version = &quot;0.1.0&quot;<br>description = &quot;&quot;<br>authors = [&quot;dominikjaeckle&quot;]</pre><pre>[tool.poetry.dependencies]<br>python = &quot;^3.8&quot;</pre><pre>[tool.poetry.dev-dependencies]<br>pytest = &quot;^5.2&quot;</pre><pre>[build-system]<br>requires = [&quot;poetry-core&gt;=1.0.0&quot;]<br>build-backend = &quot;poetry.core.masonry.api&quot;</pre><p>In order to add dependencies to your project, you can use the command poetry add . For example:</p><pre>$ poetry add scikit-learn<br>Creating virtualenv my-app-TfYlx7N_-py3.8 in ~/Library/Caches/pypoetry/virtualenvs<br>Using version ^1.0.2 for scikit-learn</pre><pre>Updating dependencies<br>Resolving dependencies... (1.5s)</pre><pre>Writing lock file</pre><pre>Package operations: 13 installs, 0 updates, 0 removals</pre><pre>• Installing numpy (1.22.3)<br>  • Installing pyparsing (3.0.7)<br>  • Installing attrs (21.4.0)<br>  • Installing joblib (1.1.0)<br>  • Installing more-itertools (8.12.0)<br>  • Installing packaging (21.3)<br>  • Installing pluggy (0.13.1)<br>  • Installing py (1.11.0)<br>  • Installing scipy (1.6.1)<br>  • Installing threadpoolctl (3.1.0)<br>  • Installing wcwidth (0.2.5)<br>  • Installing pytest (5.4.3)<br>  • Installing scikit-learn (1.0.2)</pre><p>Note that Poetry creates your own virtual environment based on the python version that has been defined in <strong>pyproject.toml</strong>. After adding a package, the respective dependency will appear in the .toml file:</p><pre>[tool.poetry.dependencies]<br>python = &quot;^3.8&quot;<br>scikit-learn = &quot;^1.0.2&quot;</pre><p>Also, a new file will be generated, called <strong>poetry.lock</strong>. This file needs to be delivered with the project if shared with somebody else. If another developer runs poetry install , this file makes sure that the correct versions are used.</p><p>You can then run your project via:</p><pre># activate the virtual environment<br>$ poetry shell</pre><pre># run a script called your_script.py<br>$ poetry run python your_script.py</pre><p>If you are happy with your work, publishing to Pypy is as easy as:</p><pre>$ poetry build<br>$ poetry publish</pre><p><em>References</em>:</p><ul><li><a href="https://github.com/pyenv/pyenv">GitHub - pyenv/pyenv: Simple Python version management</a></li><li><a href="https://brew.sh/">Homebrew</a></li><li><a href="https://python-poetry.org/docs/basic-usage/">Basic usage</a></li></ul><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a><em> and</em><strong><em> </em></strong><a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>. Join our </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>community Discord</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29de55db9ea0" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/setting-up-python-and-poetry-29de55db9ea0">How to Set Up Python and Poetry</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Svelte and d3.js]]></title>
            <link>https://medium.com/codex/getting-started-with-svelte-and-d3-js-ea915d2c2c2c?source=rss-dec04f4e2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea915d2c2c2c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[svelte]]></category>
            <category><![CDATA[d3js]]></category>
            <dc:creator><![CDATA[Dominik Jäckle]]></dc:creator>
            <pubDate>Sun, 20 Feb 2022 12:57:46 GMT</pubDate>
            <atom:updated>2022-04-05T17:37:25.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Nyi76RKZdGDUTNTy" /><figcaption>Photo by <a href="https://unsplash.com/@flowforfrank?utm_source=medium&amp;utm_medium=referral">Ferenc Almasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have been using <a href="http://idl.cs.washington.edu/files/2011-D3-InfoVis.pdf">d3.js as my standard visualization library since 2013</a>, about 2 years after Mike Bostock introduced it at the <a href="http://ieeevis.org/year/2011/info/infovis-welcome/infovis-welcome">InfoVis 2011</a> conference. First, I created my own Vanilla JS web apps using d3. Eventually, I started using Angular and React, and my programs introduced additional complexity and somehow I spent much more time thinking about how to integrate certain visual elements rather than simply using it and having fun. Yet, that is only my subjective perspective — I am sure many developers out there may contradict me 😜.</p><p>Last year I came across Svelte and I liked its lightweight concept, also that the developers dumped the virtual DOM. This article is hopefully the first of many to come, where I will create a full-fledged visual web application step by step and from scratch.</p><p>Enough words, let’s get started! 🚀</p><p>In this article, I will cover the following steps towards our vis app:</p><ul><li>The instantiation of a basic Svelte app using TypeScript</li><li>The integration of d3.js into the Svelte app</li><li>A first resizable d3.js scatterplot</li></ul><h3>Create a basic Svelte app</h3><p>To get started, we will have to install <a href="https://nodejs.org/en/">Node</a> on our system. Then, open our terminal and execute the following commands:</p><pre>$ npx degit sveltejs/template svelte-d3<br>$ cd svelte-d3<br>$ npm install</pre><p>The first line will create a new project called <strong>/svelte-d3</strong> that is based on a template. Then, we change directory to the project folder and execute <strong>npm install</strong>, which will install all dependencies into the folder <strong>/node_modules </strong>(dependencies defined in package.json). The project folder should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*guMtcj_LSm6-5WC9DuzNcg.png" /><figcaption>Svelte project folder after installing all dependencies.</figcaption></figure><p>Finally, to use the template project as a TypeScript project, we run the following command:</p><pre>$ node scripts/setupTypeScript.js<br>$ npm install. # run a second time to </pre><p>We can now use TypeScript if we add the attribute lang=&quot;ts&quot; to the &lt;script&gt;&lt;/script&gt; tags. Find additional documentation <a href="https://svelte.dev/blog/svelte-and-typescript">here</a>.</p><p>We then run npm run dev in the terminal and open <a href="http://localhost:8080/">http://localhost:8080</a> in the browser. Here we go, our first Svelte website!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q87ny4MEJ1RGQxd0iSEa3w.png" /></figure><h3>Install the d3.js dependency</h3><p>To start with, we run the following two commands in the project folder:</p><pre>$ npm install d3<br>$ npm install @types/d3</pre><p>We will be able to start using d3 the following way in the Svelte app inside of the &lt;script&gt;&lt;/script&gt; tags:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kp0rbrPAL1UcxQjTIaMe7A.png" /></figure><h3>A resizable scatterplot</h3><p>For the sake of simplicity, we will use the main Svelte component <strong>App.svelte</strong>. In this example, we will create a random data array that contains 100 points with random x and y values in the range [0, 10]:</p><pre>let data = [];<br>for (let i = 0; i &lt; 100; ++i) {<br> data.push({x: Math.random() * 10, y: Math.random() * 10})<br>}</pre><p>Also, we will have to create a set of initial variables:</p><pre>let xScale = d3.scaleLinear().domain([0, 10]);<br>let yScale: = d3.scaleLinear().domain([0, 10]);<br>let width: number;<br>let height: number;<br>const margin = {<br>  top: 20,<br>  right: 20,<br>  bottom: 30,<br>  left: 30<br> };</pre><p>Then, to enable resizing, we will add a redraw() function. If you are familiar with any 2D or 3D api, a redraw/repaint/… method is usually called when something changes in the frame, such as a different size. We will adapt the very same concept for this example.</p><pre>onMount(() =&gt; {<br> redraw();<br> window.addEventListener(&#39;resize&#39;, redraw);<br>})</pre><p>Note that <strong>onMount()</strong> is a Svelte specific method that is called automatically after the component has been rendered to the DOM. In addition to the initial <strong>redraw()</strong>, we added an event listener. This listener calls the <strong>redraw()</strong> method whenever the window is resized.</p><p>Let’s have a look at the <strong>redraw()</strong> method:</p><pre>function redraw(): void {<br>  // empty vis div<br>  d3.select(vis).html(null);</pre><pre>  // determine width &amp; height of parent element minus the margin<br>  width = d3.select(vis).node().getBoundingClientRect().width - margin.left - margin.right;<br>  height = d3.select(vis).node().getBoundingClientRect().height - margin.top - margin.bottom;</pre><pre>  // init scales according to new width &amp; height<br>  xScale.range([0, width]);<br>  yScale.range([height, 0]);</pre><pre>  // create svg and group that is translated by the margin<br>  const svg = d3.select(vis)<br>   .append(&#39;svg&#39;)<br>   .attr(&#39;width&#39;, width + margin.left + margin.right)<br>   .attr(&#39;height&#39;, height + margin.top + margin.bottom)<br>   .append(&#39;g&#39;)<br>   .attr(&#39;transform&#39;, `translate(${[margin.left, margin.top]})`)</pre><pre>  // draw x and y axes<br>  svg.append(&quot;g&quot;)<br>   .attr(&quot;transform&quot;, `translate(${[0, height]})`)<br>   .call(d3.axisBottom(xScale));<br>  svg.append(&quot;g&quot;)<br>      .call(d3.axisLeft(yScale));</pre><pre>  // draw data points<br>  svg.append(&#39;g&#39;).selectAll(&#39;circle&#39;)<br>   .data(data)<br>   .enter()<br>   .append(&#39;circle&#39;)<br>   .attr(&#39;cx&#39;, function (d) { <br>    return xScale(d.x); <br>   })<br>   .attr(&#39;cy&#39;, function (d) { <br>    return yScale(d.y); <br>   })<br>   .attr(&#39;r&#39;, 7)<br>   .style(&#39;fill&#39;, &#39;#ff3e00&#39;)<br>   .style(&#39;fill-opacity&#39;, &#39;0.5&#39;)<br>   .style(&#39;stroke&#39;, &#39;#ff3e00&#39;);<br> }</pre><p>Bringing all together, let’s connect a dedicated&lt;div&gt;&lt;/div&gt; with our visualization logic. Note that in the code above, the div is selected via d3.select(vis) .</p><pre>&lt;script lang=”ts”&gt;<br>  let vis;<br>&lt;/script&gt;</pre><pre>&lt;main&gt;<br> &lt;div id=&quot;vis&quot; bind:this{vis}&gt;&lt;/div&gt;<br>&lt;/main&gt;</pre><pre>&lt;style&gt;<br> /* some styles */<br>&lt;/style&gt;</pre><p>The line bind:this{vis} creates a read only binding and gives a reference to this specific div element. An alternative to access this element would be to access the id via d3.select(&#39;#vis&#39;) .</p><p>Here is the code of the <strong>App.svelte </strong>component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7feab7bf8f7278f2e35de6612da40efe/href">https://medium.com/media/7feab7bf8f7278f2e35de6612da40efe/href</a></iframe><p>The end result should look similar to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irE7Fh_yOyJYmcxzEdfiXw.png" /></figure><p>Next, check the window resize feature and observe how the scales adapt to the window size due to the redraw. You may wonder if this makes sense for a scatterplot in particular, and the answer is: probably not. However, there are several use cases out there, where you may want to scale the scales. Stay tuned, more to come soon ;)</p><p><em>References</em>:</p><ul><li><a href="https://svelte.dev/">Svelte</a></li><li><a href="https://d3js.org/">D3.js - Data-Driven Documents</a></li><li><a href="https://svelte.dev/blog/virtual-dom-is-pure-overhead">Virtual DOM is pure overhead</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea915d2c2c2c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/getting-started-with-svelte-and-d3-js-ea915d2c2c2c">Getting Started with Svelte and d3.js</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I carve out a scientific contribution in the broad field of visualization.]]></title>
            <link>https://medium.com/@dominikjaeckle/how-i-carve-out-a-scientific-contribution-in-the-broad-field-of-visualization-342189cd7c07?source=rss-dec04f4e2fb------2</link>
            <guid isPermaLink="false">https://medium.com/p/342189cd7c07</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[contribution]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[scientific-research]]></category>
            <dc:creator><![CDATA[Dominik Jäckle]]></dc:creator>
            <pubDate>Wed, 27 Dec 2017 11:37:18 GMT</pubDate>
            <atom:updated>2017-12-27T11:37:18.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*fh6Z2h6Qrn0eCAk6hZevAQ.png" /><figcaption>General approach towards a scientific contribution</figcaption></figure><p><em>“What is your contribution?”</em> — Raise your hand if you haven’t heard this question at least once during your PhD studies. As a PhD student, eager to succeed in writing research papers, I have heard this question countless times. Like most PhD students, I had trouble framing a crisp contribution. Formulating a contribution is a learning process. The more experience you gain in the field, the easier you will find it to formulate a contribution that tackles a particular scientific problem. You may wonder: Why is it so difficult to formulate a contribution? My short answer is: <em>Thinking about the contribution first, is wrong</em>. If you, the reader, disagree or find it easy to come up with a contribution, I have bad news; most likely, you don’t belong to the target audience of this article. However, I hope this article is still a good read and makes you think about this underestimated problem.</p><p>A few words about myself: I have been working in academic research for about 5 years and recently defended my thesis. When writing up my thesis, I had to think deeply about the contribution, acting as an umbrella for my entire research, in a much broader scope. Yet, the challenge remained the same — it doesn’t matter if it is a workshop paper, a conference paper, a journal paper, or a thesis.</p><h4>What is a contribution?</h4><p>A typical answer might be: A contribution is a <em>new solution</em>, which <em>moves the field forward</em>, and <em>other researchers can learn something</em> from it. While this is all held true, I also like to think of a contribution as a solution to a possibly unsolved scientific problem, expressed by the so called <em>research question</em>. The research question motivates the problem you want to tackle and also provides an idea to what your contribution may look like. Hereby, I take a different angle at the very same problem. Following, I argue that you should carve out the research question before even thinking of the contribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifD97OzuZ5HqF9kaa5-gmQ.png" /></figure><h4>The Golden Circle</h4><p>Let me dwell on this idea by using the golden circle metaphor. The golden circle is often used in marketing and comprises three consecutive questions:</p><p><strong><em>Why? →</em> <em>How? → What?</em></strong></p><p>When advertising a new product, let’s say a simple corkscrew, always think of the <em>Why?</em> first to seek the customers’ attention. For example:</p><p><em>“Do you also find it nearly impossible to open wine bottles without breaking the bottle neck? If so, we have the perfect solution for you!”.</em></p><p>Once you have the customers’ attention and their urge for a solution, provide them with the <em>How?</em>:</p><p><em>“We designed a product that will solve your problem. It removes the cork within seconds by drilling it into the cork and then pulling it effortlessly”.</em></p><p>Finally, the <em>What?</em>:</p><p><em>“We invented the corkscrew and this is what it looks like …”.</em></p><p>Now think of your research, the paper you are writing, or the elevator pitch you try to memorize for conferences. Research has a lot in common with marketing, even though you don’t want to think about it in such way. In order to “sell” your research to a colleague, your advisor, the reviewers of your paper, or any other person, you need to provide consise information about</p><ul><li><em>Why</em> your research is worthwhile to read (problem statement),</li><li><em>How</em> you approached the problem scientifically to provide a solution, and</li><li><em>What</em> you have done.</li></ul><h4>Relation to the research question &amp; contribution</h4><p>Consider the <em>Why</em> as your research question and the <em>What</em> as your contribution. It comes natural to formulate the <em>What</em> once you have defined the <em>Why</em>.</p><p>Consider an example. Think of your grandparents having trouble to operate the new smart TV you got them for Christmas. The <em>research problem</em> is:</p><p><em>“My grandparents can’t operate the smart TV”.</em></p><p>Depending on what you aim to study, you have different options on how to formulate a research question. If you want to evaluate whether your grandparents are capable of operating a smart TV in general, your research question starts with “Can …”. If you want to provide a solution to the problem, your research question starts with “How …”. Based on the research question you can easily formulate the contribution by slightly rephrasing the question:</p><p><em>“Can my grandparents operate the smart TV?”</em></p><p>This is the start for a typical evaluation paper. The contribution may read like: <em>“We conducted a controlled experiment to investigate whether my grandparents can operate the smart TV.”</em></p><p><em>“How can I support my grandparents to effectively operate the smart TV?”</em></p><p>This may be the start for a typical technique paper. The contribution may be: <em>“We contribute a novel remote design that supports my grandparents to effectively operate the smart TV.”</em></p><p>As you can see, once having derived the research question, we can easily formulate a crisp contribution. But how can we derive the research question which best describes the problem we aim at solving?</p><h4>How to derive the research question?</h4><p>During my studies, an article on wikiHow caught my attention. The article’s intention is to provide guidance on how to conduct qualitative research:</p><p><a href="https://www.wikihow.com/Do-Qualitative-Research">How to Do Qualitative Research</a></p><p>While qualitative research may not be relevant to our problem on deriving a research question, this article has a point. The steps you live through in order to decide on which type of qualitative evaluation you carry out are a perfect match to reason about your research question. I summarized the most important steps in the teaser image of this article:</p><p><em>burning question → researchable question → literature review → evaluation</em></p><p>The main idea is to start with a <em>burning question</em>, a question that is very broad an insoluble by your research. Then, you refine this question to one that you can answer with your research, the <em>researchable question</em> (research question). This question should be very specific about the problem you aim to study. Afterwards, you check the <em>literature</em> for a gap that supports the study of the researchable question. Finally, you think about how to evaluate your approach to the researchable question.</p><p>Key to this process is the concept of revisiting the entire pipeline once you have finished working on one step. Therefore, you always start over with the burning question and revisit each step. This process ensures the feasibility of the previous steps and whether all steps are coherent. In case the previous steps deviate from the current step, you need to refine them and live through the pipeline again.</p><p>This pipeline does not only help you to derive a robust research question, but also to focus on relevant related work as well as a good strategy to evaluate your approach.</p><p><em>As mentioned above, you can formulate the contribution by rephrasing the researchable question.</em></p><h4>Example: Visual interpretation of dimensionally reduced data</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jHb0ji5RB2JSx4PnCXpxIA.png" /></figure><p>I published a paper on the visual interpretation of dimensionally reduced high-dimensional data together with colleagues:</p><p><a href="http://dominikjaeckle.com/projects/2017/crime_interpret/">http://dominikjaeckle.com/projects/2017/crime_interpret/</a></p><p>We spend about half a day discussing all steps of the proposed pipeline. Let me guide you through the steps each at a time:</p><p><strong>Burning Question:</strong> <em>“Can we understand the visual depiction of dimensionally reduced data?”</em> This question applies to any user that is confronted with results of dimensionality reduction techniques. As you can see this question is very broad and hard to study. So we have to specify further. Who is “we”? Since we worked with domain experts who never touched dimensionally reduced data before, we speak about “untrained domain experts”. What kind of “dimensionally reduced data”? Well-known approaches under the umbrella of “data projections” are PCA, MDS, or t-SNE. What does “understand” mean? Since our domain experts are untrained, we wondered whether they can use their domain knowledge, apply it to data within their domain and “interpret” the visual depiction.</p><p><strong>Researchable Question:</strong><em> “Can untrained domain experts use their domain knowledge to interpret and steer the visual depiction of a data projection?” </em>Actually, for this question we can provide an anwer.</p><p>→ The research question leads to the <strong>contribution</strong> of the paper: <em>The investigation if untrained domain experts can use their domain knowledge to interpret and steer the visual depiction of a data projection.</em></p><p><strong>Literature Review</strong> comprises the <em>visual analysis of mixed data sets</em> and the <em>visual analysis of projections</em>. How come? The data used by the domain experts is heterogeneous and poses a challenge to unify using high-dimensional data projections. Furthermore, the visual analysis of projections has been studied before, so where is the gap? We encountered that there exists no evaluation that investigates wether domain experts untrained in advanced statistics can interpret dimensionally reduced data. Having found about about this lack of proof, we were forced to refine the researchable question. The final result is stated above.</p><p>We even found out that some research papers claim that for domain experts untrained in advanced statistics or machine learning, it is very difficult to interpret dimensionally reduced data. Yet, no proof was given — this is what surprised us the most. This claim supported our research question even more.</p><p><strong>Evaluation Method:</strong> <em>Phenomenological study</em>. Because of the low number of participants and the broader scope of the study, we decided on a qualitative study. It is always easy to critisize the chosen evaluation method as well as the design and the procedure. Always make sure the evaluation fits your research question and you thoroughly considered the design etc. There exist great guidelines on how to evaluate visualization research. Well-known works are:</p><p>H. Lam, E. Bertini, P. Isenberg, C. Plaisant, S. Carpendale:<br><strong>Empirical Studies in Information Visualization: Seven Scenarios.</strong> <br><em>IEEE Trans. Vis. Comput. Graph. 18(9): 1520–1536 (2012)</em></p><p>T. Munzner:<br><strong>A Nested Process Model for Visualization Design and Validation.</strong> <br><em>IEEE Trans. Vis. Comput. Graph. 15(6): 921–928 (2009)</em></p><p>I am aware that the approach described above reflects my very subjective experience in the field of data analysis and visualization. However, it helped me a lot to conclude my studies and I hope it helps you in the same manner: In the beginning, think broad, then narrow the problem down to an actionable research problem/question. I am more than happy to hear and respond to your feedback.</p><p>Special thanks to my colleagues and <a href="https://medium.com/u/2323d403da7c">Florian Stoffel</a> who provided me with valuable feedback on first drafts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=342189cd7c07" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>