<?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 Carmine Zaccagnino on Medium]]></title>
        <description><![CDATA[Stories by Carmine Zaccagnino on Medium]]></description>
        <link>https://medium.com/@carminezaccagnino?source=rss-340b0b69bf32------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RRrUBpfZYm-alT7MtGXfzA.png</url>
            <title>Stories by Carmine Zaccagnino on Medium</title>
            <link>https://medium.com/@carminezaccagnino?source=rss-340b0b69bf32------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 21:07:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carminezaccagnino/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[Does Kubernetes support SELinux?]]></title>
            <link>https://medium.com/@carminezaccagnino/does-kubernetes-support-selinux-36b26e475b8b?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/36b26e475b8b</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 10:48:01 GMT</pubDate>
            <atom:updated>2022-07-07T10:48:35.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*bK5RpVu8yDhGycVpz_dCcQ.png" /></figure><p>In my <a href="https://carmine.dev/posts/kubernetesclusterfcos/">previous post about setting up a Kubernetes cluster using Fedora CoreOS nodes</a> I mentioned the fact that SELinux should not be disabled when creating Kubernetes clusters.</p><p>That is in complete contradiction to what many online tutorials will tell you. But why is that?</p><h3>Generic “SELinux is just a PITA” myth</h3><p>One reason is the idea, common among those who might have jumped across to RedHat-based system administration from other distributions, that SELinux breaks things and it’s just easier to disable it. It isn’t, really, not for servers. Maybe for a workstation that could be an acceptable compromise: you might do unpredictable things on it, so you might end up spending a lot of time troubleshooting a tool that feels like it’s getting in the way of your work most of the time without much of a tangible security benefit.</p><p>But servers are different: you use them to perform a job that is somewhat pre-defined: you’re either running software directly on it, and you should know what that software is supposed to do with the network and the file system, or you’re running containers, in which case what you’re doing is still somewhat predictable, and you should regulate to the extent to which the workload is predictable.</p><h3>The “SELinux doesn’t work with K8S because kubelet doesn’t support it” myth</h3><p>Another reason that originated this idea that one should disable SELinux for Kubernetes clusters is that Kubernetes specifically doesn’t play nice with SELinux because the Kubernetes official kubeadm setup tutorial <a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl">says so in the tab about RedHat-based distributions</a> which states, talking about disabling SELinux, that</p><blockquote>This is required to allow containers to access the host filesystem, which is needed by pod networks for example.</blockquote><p>Digging deeper, one will find, however, that SELinux is being used by people in production Kubernetes clusters, and there really aren’t many issues, at most what is reported is the need to set SELinux labels on a few files and directories on some setups, but other setups may not even require any additional work. You can test this yourself with the <a href="https://carmine.dev/posts/kubernetesclusterfcos/">example Kubernetes setup tutorial I wrote and mentioned at the start of this post</a>.</p><p>As <a href="https://medium.com/cri-o/cri-o-has-builtin-selinux-support-6ff45b707cf0">Daniel Walsh himself wrote in a blog post</a>, CRI-O integrates very well with SELinux and prevents dangerous actions like a container loading an old, unmaintained and therefore potentially vulnerable kernel module and breaking out of the isolation. Additionally, the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#selinuxoptions-v1-core">Kubernetes API itself</a> contains resources to specifically configure SELinux labels for containers. Doesn’t sound like something they would do for a tool that “doesn’t work with Kubernetes”, according to some. Also, <a href="https://github.com/cncf/tag-security/blob/main/security-whitepaper/v2/cloud-native-security-whitepaper.md">the CNCF security whitepaper</a> mentions SELinux as a tool that can be used to provide isolation and limit privileges, which is as much as we could expect from an high-level, architecturally-minded document.</p><h3>Kubernetes DOES work with SELinux enabled, so you shouldn’t disable it, certainly not before even trying</h3><p>In conclusion, try things for yourself before giving up on a tool that could end up providing a critical security benefit. If you want to share a story about your own experience with SELinux and Kubernetes, it would be really appreciated <a href="https://dev.to/carminezacc/does-kubernetes-support-selinux-3oop">in the comments to this post on dev.to</a>, here on Medium or directly <a href="/service/mailto:carmine@carminezacc.com">to my email carmine@carminezacc.com</a></p><p><em>Originally published at </em><a href="https://carmine.dev/posts/kubernetesselinux/"><em>https://carmine.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36b26e475b8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Kubernetes Cluster with Fedora CoreOS 36]]></title>
            <link>https://medium.com/@carminezaccagnino/creating-a-kubernetes-cluster-with-fedora-coreos-36-3d786e50a0ec?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d786e50a0ec</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[fedora]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 09:19:45 GMT</pubDate>
            <atom:updated>2022-07-02T09:19:45.016Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEzuu_MahDPjsAUOyQJY8A.jpeg" /></figure><p>In this post I’m going to explain how to create a Kubernetes 1.24 cluster on Fedora CoreOS 36 nodes.</p><p>I will assume that, if you’re reading this, you already know that Fedora CoreOS is a great choice as a Kubernetes node OS because of both the ease of maintenance provided by RPM-OSTree and Zincati and the really easy way to automate provisioning of new nodes thanks to the use of Butane and Ignition.</p><p>I believe it is necessary to write a tutorial on this because existing tutorials on this topic are somewhat outdated and, in my opinion, fail to address some aspects, even though they’re really good in many ways ( <a href="https://www.matthiaspreu.com/posts/fedora-coreos-kubernetes-basic-setup/">the one linked here is very good in my opinion for example</a>).</p><p>In particular, I’m going to show a multi-node cluster that keeps the taint on the control plane and, to give an example that can be directly replicated, I’ll provide scripts that aid in creating virtual machines for the nodes using libvirt. You can, of course, apply just Ignition scripts and node configuration steps to your environment if that&#39;s what you&#39;re looking to get from this tutorial.</p><h3>Preliminary considerations about container runtimes and SELinux</h3><p>The aforementioned existing tutorial on creating Kubernetes clusters with Fedora CoreOS chooses to use CRI-O instead of the preinstalled containerd runtime. I believe this choice merits some further attention, even though I agree that it’s the correct choice.</p><p>CRI-O’s strengths are in added features, particularly the integration with SELinux (but that is disabled in that tutorial) and the fact it’s the same runtime used by OpenShift, <a href="https://www.researchgate.net/publication/341483813_Performance_Evaluation_of_Container_Runtimes">but it is slower than containerd, even if marginally, as the linked paper shows</a>, so one could be tempted to just stick with containerd.</p><p>My experience with the exact setup that will be shown in this tutorial, even if one disables SELinux by overriding /etc/selinux/config in the Ignition file, is that the choice to use containerd results in a really unstable and unusable cluster, and that&#39;s why I&#39;ll be showing steps to install and enable CRI-O instead in this tutorial.</p><p>I <em>will not</em> be disabling SELinux, on the other hand. That’s because, in the current state and for what I’ve seen, there’s no need for that and I’ll gladly take the increased security, even if it means having to troubleshoot the few instances in which it gets overzealous, and doing that with setroubleshootd (that can be installed on Fedora CoreOS using rpm-ostree as part of the setroubleshoot package) it&#39;s not hard at all.</p><p>For the full example, we are going to create a three-node cluster with one control plane and two workers, which is the least demanding sensible (even though it misses out on HA) virtualized setup that even a mid-range laptop could run, as long as it runs a (ideally RedHat-based) Linux distribution with podman, libvirt and virt-install.</p><p>Another prerequisite is an extracted qcow2 image of Fedora CoreOS, which can be downloaded as an XZ archive from <a href="https://getfedora.org/en/coreos/download?tab=metal_virtualized&amp;stream=stable&amp;arch=x86_64">the Fedora CoreOS official website</a>, or retrieved by coreos-installer.</p><p>The steps have been tested on x86 systems with Fedora Workstation 36 and Red Hat Enterprise Linux 9 as the host operating system.</p><h3>Create an Ignition script</h3><p>To inizialize the VM, a JSON Ignition script is used, which can be derived from the following fcos.bu YAML file using Butane:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/380a3af6daa4a86a94ba48873aaba082/href">https://medium.com/media/380a3af6daa4a86a94ba48873aaba082/href</a></iframe><p>Before doing that, generate an SSH key pair using ssh-keygen or locate an existing one you&#39;d like to use for the VMs we&#39;re about to create and replace &lt;PASTE YOUR SSH PUBLIC KEY HERE&gt; in fcos.bu with the public key content, all on one line.</p><p>Use the butane OCI container to generate the Ignition file by running</p><pre>podman run --interactive --rm \ quay.io/coreos/butane:release \ --pretty --strict &lt; fcos.bu &gt; fcos.ign</pre><p>Take note of the path of the generated fcos.ign file, and set it as the value assigned to the IGN_CONFIG variable in the following file, which I&#39;ll refer to as start_fcos.sh from now on:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d49560c97f23fb1f60746a06f6f9b472/href">https://medium.com/media/d49560c97f23fb1f60746a06f6f9b472/href</a></iframe><p>In that file, also change the IMAGE variable to the path to the downloaded QCOW2 Fedora CoreOS image (e.g. $HOME/Downloads/fedora-coreos-36.20220505.3.2-qemu.x86_64.qcow2).</p><p>In three different terminals or tmux panes or windows run ./start_fcos.sh 1, ./start_fcos.sh 2 and ./start_fcos.sh 3 to create three nodes called node1, node2 and node3. The Virtual Machine Manager ( virt-manager) GUI tool can be used to manage these three VMs after the initial setup.</p><p>Look for lines like</p><pre>Fedora CoreOS 36.20220505.3.2 Kernel 5.17.5-300.fc36.x86_64 on an x86_64 (ttyS0) SSH host key: SHA256:70h+0L1lAfXChOpmBH1odArSLRCMJY2v9sOM45XThyM (ECDSA) SSH host key: SHA256:M3Tcq1tebp+uFKAXqo6kD+PWIzzz03ndwreIEhFR5IQ (ED25519) SSH host key: SHA256:EnywjztiwTBK9nLy47wj/gaus3wgAflI11j2ckXE0QM (RSA) enp1s0: 192.168.122.146 fe80::cc38:c8c:7c38:c0fc</pre><p>in the three terminals and add the IP addresses to /etc/hosts on the host system like in this example:</p><pre>192.168.122.146 node1 192.168.122.96 node2 192.168.122.87 node3</pre><p>to then be able to more easily access the nodes from the host PC.</p><p>Log in via SSH as the core user on the three nodes (for example in three panes in another tmux window) using ssh core@node1, ssh core@node2 and ssh core@node3.</p><p>Set the hostname on each node to node1, node2 and node3 by creating the /etc/hostname file on each as root, for example like this in the first node (run the two commands one by one or it won&#39;t work):</p><pre>sudo -i # become root echo &quot;node1&quot; &gt; /etc/hostname # set the hostname</pre><p>On the first node (which will be the cluster’s control plane) install CRI-O and the required tools to create and manage the cluster with:</p><pre>sudo rpm-ostree install kubelet kubeadm kubectl cri-o</pre><p>On the other nodes, only the CRI-O runtime, kubelet and kubeadm are needed, and they can be installed with:</p><pre>sudo rpm-ostree install kubelet kubeadm cri-o</pre><p>reboot using sudo systemctl reboot to apply the hostname change and the updates (Fedora CoreOS uses OSTree which only updates system files on reboot to ensure atomic updates).</p><p>After the reboot, log in to all the nodes again and start CRI-O and kubelet using</p><pre>sudo systemctl enable --now crio kubelet</pre><p>Create a clusterconfig.yml on the control plane just like the following (using vi in the SSH console for example):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71a77b042ea2279c96267204af3e9cdd/href">https://medium.com/media/71a77b042ea2279c96267204af3e9cdd/href</a></iframe><p>and then run:</p><pre>kubeadm init --config clusterconfig.yml</pre><p>to initialize the cluster.</p><p>After it’s done, configure kubectl on the control plane by running the suggested commands:</p><pre>mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config</pre><p>The ~/.kube/config file can be copied to the host system as well to be able to run kubectl commands on the host directly instead of logging in to the control plane via SSH.</p><p>Set up Pod networking with kube-router, which is on the simpler side of CNI plugins without missing out on important features, by running:</p><pre>kubectl apply -f \ <a href="https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml">https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml</a></pre><p>Add the other nodes ( node2 and node3 in our example) as workers to the cluster by running on each (as root, therefore with sudo) the kubeadm join command shown at the end of the kubeadm init output. If it was lost, you can run:</p><pre>kubeadm token create --print-join-command</pre><p>to have kubeadm generate a new token and get a new join command.</p><p>If all was done correctly, the cluster should be ready for action. Confirm this by running kubectl get nodes and verifying that all three nodes are shown as <em>Ready</em>.</p><p>You can create a test deployment of three NGINX instances with:</p><pre>kubectl create deployment test --image nginx --replicas 3</pre><p>and a Service to be able to access it externally (in a file called testsvc.yml, for example):</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: testsvc<br>  spec:<br>    type: NodePort<br>    selector:<br>      app: test<br>      ports:<br>        - port: 80<br>          nodePort: 30001</pre><p>that can be added to the cluster with kubectl create -f testsvc.yml and that allows us to test that everything works correctly by navigating to node1:30001 with a browser or cURL and verifying we get the NGINX welcome page.</p><p>I have a few containers and Kubernetes example files of varying complexity in a <a href="https://github.com/carzacc/thesis-files">GitHub repository (github.com/carzacc/thesis-files)</a>, maybe you’ll find something of interest there to complement reading the official Kubernetes documentation.</p><p>In particular, <a href="https://github.com/carzacc/thesis-files/tree/main/3/morra">in the README for directory </a><a href="https://github.com/carzacc/thesis-files/tree/main/3/morra">3/morra</a> I show an example deployment of a REST API that interacts with a Redis store and a MySQL cluster. For production applications, remember to use namespaces and create accounts that follow the principle of least privilege.</p><p>In the past, I’ve been very happy to write tutorials after having a topic requested or suggested in an email. In those cases, they were Flutter tutorial ideas. The same could happen with Kubernetes as well, so <a href="/service/mailto:carmine@carminezacc.com">feel free to write to me at carmine@carminezacc.com to ask anything</a>.</p><p><em>Originally published at </em><a href="http://carmine.dev/posts/kubernetesclusterfcos"><em>http://carmine.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d786e50a0ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Flutter Networking Part 1: Uploading a File to a REST API from Flutter Using a Multi-Part…]]></title>
            <link>https://medium.com/@carminezaccagnino/advanced-flutter-networking-part-1-uploading-a-file-to-a-rest-api-from-flutter-using-a-multi-part-86812d98e010?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/86812d98e010</guid>
            <category><![CDATA[multipart-form-data]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[file-upload]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Mon, 03 Feb 2020 17:42:32 GMT</pubDate>
            <atom:updated>2020-02-03T17:42:32.148Z</atom:updated>
            <content:encoded><![CDATA[<h3>Advanced Flutter Networking Part 1: Uploading a File to a REST API from Flutter Using a Multi-Part (form-data) POST Request</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/0*WtelLPVlNuiFv9IK.png" /></figure><p>My Flutter book is pretty light on advanced HTTP networking topics, focusing instead on giving a more well-rounded approach that, when it comes to networking, explains how to use the http networking package for basic requests, shows an example of an app that makes GET requests, and then goes a bit more specific with Firebase.</p><p>My blog is here for those who need more than that, and the first topic I’m going to cover is how to upload a file using a multi-part/form-data POST request.</p><p>You can find all of the code contained in this example in <a href="https://github.com/carzacc/form-data-post">this GitHub repository</a>.</p><h3>What is a Multi-Part POST Request</h3><p>Usually, the body of a POST request is made of textual key-value pairs. With a multipart POST request, you can also include files with binary content (images, various documents, etc.), in addition to the regular text values.</p><h3>Making Multi-Part POST Requests with Flutter’s HTTP Library</h3><p>This little section is going to focus on one thing: creating a function that, given a file path and an URL, is able to send that file to that URL with that multipart POST request.</p><p>The next section is going to focus on how to build an app that lets the user insert the URL to which to send the request, pick an image and send it to the server, getting back the status of the request.</p><p>This means we’re not going to worry about dependencies in this section. All you need to know for this section is that we’ve got this at the top of our main.dart:</p><pre>import &#39;package:http/http.dart&#39; as http;</pre><p>This allows us to <em>create</em> (not send) a multipart POST request using</p><pre>var req = http.MultipartRequest(&#39;POST&#39;, Uri.parse(url));</pre><p>This req object has a member Map called fields for textual values and a List called files to which you can add MultipartFiles.</p><h3>The MultipartFile</h3><p>The most important element of this whole thing is the MultipartFile. It can be constructed in a few ways:</p><ul><li>the default MultipartFile(key, stream, length) constructor, which you can use if you need to create the file from a Stream of bytes of which we know the length;</li><li>the MultipartFile.fromBytes(key, bytes) factory method, which attaches a file obtained from a List of bytes;</li><li>the MultipartFile.fromString(key, string) factory method, which attaches a text file containing the string passed to it;</li><li>the MultipartFile.fromPath(key, path) factory method, which attaches the file found at the given path.</li></ul><p>In case you’re wondering, <em>bytes</em> simply means <em>integers</em>. That’s all a byte is. An 8-bit integer value. A list of integers, coupled with an encoding (that can usually be inferred with the help of the extension that’s part of the file name) is all you need to get images, documents, videos, music or text.</p><p>If you’re using one of the first two constructors for the MultipartFile, remember to set a filename using the specific named filename argument, as not doing that will cause issues with our back-end.</p><p>Here are a few examples: if you have a file and a path to it, here’s how you create a multipart POST request and attach that file to the request:</p><ul><li>Using the default constructor you could write a function like the following:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9ac95ee286f6a710a05cb30969458c6/href">https://medium.com/media/d9ac95ee286f6a710a05cb30969458c6/href</a></iframe><ul><li>UsingMultipartFile.fromBytes() you could write a function like the following:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/759d5b3d33bc2e57a56f7dcd5aedc60e/href">https://medium.com/media/759d5b3d33bc2e57a56f7dcd5aedc60e/href</a></iframe><ul><li>UsingMultipartFile.fromPath() you could write a function like the following:</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6497cb2a75618dc59efc77856d347e7a/href">https://medium.com/media/6497cb2a75618dc59efc77856d347e7a/href</a></iframe><h3>Adding Regular Text Fields</h3><p>You could add regular text fields to a Multipart POST requests simply by adding, after settomg initialized the MultipartRequest object, an item in the fields member Map:</p><pre>var request = http.MultipartRequest(&#39;POST&#39;, Uri.parse(url)); request.fields[&#39;key&#39;] = &#39;value&#39;;</pre><h3>Building an App Around That</h3><p>Now, to see it in action, let’s write an app that allows the user to insert an URL, pick an image, and then upload the image to the server at that URL. We’ll write the very simple back-end code required to accept files this way in Node after we’re done with the app. Feel free to skip ahead if you’re more interested in that.</p><p>Let’s start, as we must, with an evaluation of the dependencies and the pubspec.yaml file. We&#39;ll use two packages from Dart Pub: the image_picker Flutter package that will handle the image selection dialog for us, about which <a href="https://medium.com/@carminezaccagnino/taking-and-or-using-pictures-in-flutter-apps-using-the-image-picker-package-b8e366654a0">I wrote a tutorial on Medium a year ago (not part of the metered paywall in case you&#39;re wondering)</a> and the <a href="https://pub.dev/packages/http">Dart </a><a href="https://pub.dev/packages/http">http package</a> that provides the networking features we need.</p><p>Add both the dependencies in pubspec.yaml (check the GitHub repo I linked at the start of the post if you don&#39;t know how to do that) and import them both into the lib/main.dart file along with the usual Flutter Material Design API:</p><pre>import &#39;package:flutter/material.dart&#39;; import &#39;package:http/http.dart&#39; as http; import &#39;package:image_picker/image_picker.dart&#39;;</pre><h3>The Start Page</h3><p>Now let’s think about the actions the user needs to take in our app: in order to upload images, we first need an URL, so let’s show a screen that allows the user to set the URL first, and then we allow them to upload images. We’ll call this first screen StartPage. This is the usual Flutter code used to initialize an app, this tutorial really is meant for those who don&#39;t need much explanation as to what it does and why (that&#39;s more the realm of introductory tutorials and books like the one I&#39;ve written):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db30e261bebdbec7bd2efdb1509893b6/href">https://medium.com/media/db30e261bebdbec7bd2efdb1509893b6/href</a></iframe><p>We use a TextEditingController to let the user both submit the value from the Android keyboard or press our cusdtom FlatButton below the TextField.</p><h3>The Upload Page</h3><p>Here’s the code for the upload page, I’ll explain it down below after the code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b2eecb09c41b5783f916ebfd47f6565/href">https://medium.com/media/2b2eecb09c41b5783f916ebfd47f6565/href</a></iframe><p>uploadImage() is the simplest of the functions we saw earlier to upload images: we use MultipartFile.fromPath() directly and return the status string of the request. That&#39;s going to be the state variable, which is what is shown in the middle of the screen to the user. The URL is the one we get from the StartPage.</p><p>The FloatingActionButton is fairly simple: ImagePicker.pickImage() shows the familiar image picking screen to the user returns (through a Future) the path to the file the user picks.</p><p>We use that (as part of the floating action button’s onPressed callback) together with the URL passed by the StartPage to call the uploadImage function and re-render the view using setState to show the state of the request to the user.</p><h3>Writing a Simple Back-End in Node to Handle Multi-Part POST Requests</h3><p>For this section, the tools we’re going to use are Node, Express and Multer. There’s not going to be much code involved, this is a fairly simple affair.</p><p>First of all, install Node and NPM according to the instructions for your operating system on <a href="https://nodejs.org/en/">Node’s official website</a>.</p><p>After that, create a directory, run the command</p><p>and fill out to your preference the choices given to you (the default values are fine in case of doubt)</p><p>and then</p><pre>$ npm --save install express multer</pre><p>Create a file called index.js with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39a06c4a8a6bab37dc6041cc903c2cd7/href">https://medium.com/media/39a06c4a8a6bab37dc6041cc903c2cd7/href</a></iframe><p>As you can see it’s not much code, but I’m going to explain it nonetheless.</p><p>The first 4 lines are simply dealing with dependencies: the first three are straight-up imports of dependencies, whereas line 4 sets up the Multer middleware (the one that handles file uploads) to save uploaded files to the uploads directory.</p><p>Line 6 instantiates an Express server object, as the Express API documentation requires.</p><h3>Creating an Express Rule for Handling Multipart POST requests</h3><p>After that, on lines 8 to 19, we define a rule for incoming POST requests to the /upload path (in other words, it responds to POST requests sent to &lt;server IP&gt;:&lt;port&gt;/upload), it takes one file on the picture key, and it fires the callback function we defined as (req, res) {...} in the lines 8 to 19.</p><p>The callback prints to the console the name of the file that was received (on line 9), it then renames the file to the original file name.</p><p>It does that on lines 10 to 16 by creating, as is done using Node’s fs interface, streams (much like FILE* variables in C) that allow our script to read from an input file ( req.file.path is the path Multer saved the received file to) and write to an output file (using the passed req.file.originalname, which is the filename specified in the POST request by the sender, which is our Flutter app). When this is finished (lines 13 to 16) we delete ( unlinkSync) the temporary file created by Multer (which has a name that ensures there aren&#39;t two files with the same name but doesn&#39;t even keep the same extension as the original file) and send back a response saying everything was OK.</p><p>If an error happens (often because no file name was specified, on line 17) we will inform the sender of that.</p><p>On lines 22 and 23 we start the server on the port specified by the PORT environment variable or on port 3000 if no port was specified using environment variables.</p><p>That’s it.</p><h3>Making Our Example Work</h3><p>To use the example code, start the server by running node index.js. Then, fire up the Flutter app on a phone/emulator, get your PC&#39;s local IP (if the phone is connected to the same local network or it&#39;s running on an emulator) to substitute to &lt;server_ip&gt; in http://&lt;server_ip&gt;:3000/upload, which is what you need to type into the TextField in the app. For example, if your PC&#39;s IP is 192.168.1.2, you&#39;d type in http://192.168.1.2:3000/upload. After that, press the + icon, pick an image, and you&#39;ll see the Node script will print out a message like Received image_picker&lt;gibberish&gt;.jpg. By opening the uploads subdirectory in the directory where you have the back-end Node script, you&#39;ll find a file called image_picker&lt;gibberish&gt;.jpg.</p><p>I hope you found this tutorial useful and I invite you to tell me what topic I should cover next.</p><p><em>Originally published on my blog at </em><a href="https://carmine.dev/posts/multipartpost/"><em>https://carmine.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86812d98e010" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google’s Flutter Framework Could Change Software Forever]]></title>
            <link>https://medium.com/@carminezaccagnino/googles-flutter-framework-could-change-software-forever-331dd4172926?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/331dd4172926</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 21:01:00 GMT</pubDate>
            <atom:updated>2019-11-19T21:01:00.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*sqpHA2E14Y8HCPs6" /></figure><p>Google is known for moonshot projects. Often they’re just that, without much hope of being brought to fruition in the near future. But Flutter is not one of those: it’s here now and it works, wonderfully.</p><p>Flutter was released back in 2017 as a mobile development framework aiming to seamlessly bridge Android and iOS development without taking away any control over the hardware and low-level operating system features from the hands of the software developer, like many other frameworks do. It got lots of attention because Google showed impressive performance results, which are achieved thanks to the use of a low-level rendering engine that doesn’t rely on the operating system’s native interface elements like similar technologies such as Facebook’s React Native do.</p><p>It also got so much attention because it is being pointed to as the primary way of developing apps for Google’s upcoming Fuchsia OS, which is set to replace Google’s current operating systems. Developers also loved the top-notch developer tools allowing, among other things, to instantly preview the result of changes to the code without having to compile the app.</p><p>In addition to being one of the main topics of many conferences dedicated to Dart, the Google-developed programming language used to develop Flutter apps, Flutter has been discussed, presented and advertised for a significant amount of time at Google I/O ever since Flutter’s initial release in 2017, and we saw that especially in 2018, when Flutter was really being pushed by Google in anticipation of its 1.0 release in late 2018.</p><p>Google I/O 2019 went one step further: experimental support for desktop and web platforms was released, setting forward a vision for a world in which a piece of software doesn’t have to be exclusive to one platform: it doesn’t matter what platform you need to support if Flutter is powering your app: it doesn’t matter whether they’re phones, tablets, computers, TVs or embedded devices.</p><h3>Notable Examples of Flutter Use</h3><p>Flutter is not just a big tech preview: it is being used in production today by big companies. Google themselves recently released the official app for Google Stadia, their well-known upcoming game streaming platform. Google also lists companies such as eBay, BMW, AliBaba, Tencent and other companies worth several billion dollars as Flutter users and one of the early adopters of Flutter in early 2018 was the Hamilton musical’s app.</p><p>Away from mobile platforms, “The New York Times” has built some of its web-based digital puzzles in Flutter, that you can see at <a href="https://www.nytimes.com/games/prototype/kenken">this link</a>.</p><p>Flutter is reality and it ought to be exciting for everyone: it could be about to bring down the last of the barriers stopping us from forgetting about the underlying interface entirely and think of applications in a way that is only dependent on the choices of the programmer and the requests of the users.</p><h3>What You Can Do With It</h3><p>You might be wondering what exactly you can expect to be built with it. The answer can be found in more than one way: the first is by taking an inductive approach, looking at what has been built with Flutter.</p><p>The most obvious example is something like the Hamilton app I mentioned above as the first major app using Flutter because it’s what most people think of when talking about a typical Flutter app. It’s an app that takes up-to-date information from the Internet and shows the information to the user with an unique aesthetic style in multiple layers, mixing everything from news-like sections to trivia quizzes.</p><p>This is a mix of some of the most common features in mobile apps, but we can highlight Flutter’s flexibility further: it has control over the screen, so games with custom graphics and animations (like the New York Times puzzle linked above) can be built with it, with the same framework that implements easy-to-use classes for all of the components of Material Design and the iOS design language.</p><h3>The Low-Level Interfaces: C++, Swift/Objective-C and Java/Kotlin</h3><p>So Flutter can do anything visually. But we haven’t talked about what it can do with the hardware and low-level OS interfaces. To find that out, we are going to take the deductive approach.</p><p>The short answer is: anything a native app can do, and the reason for that is that Android Flutter apps can run Java/Kotlin or native C++ code just like regular Android SDK apps, Flutter iOS or macOS apps can run native Swift or Objective-C code and Linux apps can run native C++.</p><p>To any programmer, this simply means that the app has full access to the device’s capabilities. An example of that is a project of mine that aims to build a Flutter app that can manage filesystems on Linux by interfacing with Stratis, a Red Hat-developed storage management utility.</p><p>Flutter is even starting to be considered by Linux GUI developers as a potential solution to the inconsistency among different desktop environments, and the people in charge of putting together Linux distributions are taking note and starting to consider putting some effort into making Flutter desktop support even better.</p><p>Flutter’s unparalleled flexibility means there will be no duplication of effort in software development teams, increasing their productivity and eliminating any feature gap between versions of the same app developed for different platforms.</p><p>This is revolutionary and is already taking over market share in the mobile world, all that’s left to see is whether it can adapt and succeed on the other platforms, but with Google behind it and after seeing how many companies are investing heavily into it, it looks like it will change the way software is developed, making it easier for everyone to find high-quality software for any platform, be it a phone, a tablet, a computer or even a completely different kind of device, such as a car’s infotainment system, a smart home device or a smart TV.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/0*ojNr1bab3bYAuofM" /></figure><p><a href="https://pragprog.com/book/czflutr/programming-flutter">Check it Out Here</a></p><p><em>Originally published at </em><a href="https://carmine.dev/posts/flutterdesktopweb/"><em>https://carmine.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=331dd4172926" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Full-Featured Python CLI Tool With argparse]]></title>
            <link>https://medium.com/@carminezaccagnino/building-a-full-featured-python-cli-tool-with-argparse-86476ca4ca2e?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/86476ca4ca2e</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 20:56:52 GMT</pubDate>
            <atom:updated>2019-11-19T20:56:52.118Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is the third out of four in a series of posts about automating everyday tasks using scripting languages. The <a href="https://carmine.dev/posts/bashautomation/">first one</a> was an introduction to the hypothetical problem of having to take images divided into subfolders and dump all of them in one folder while altering their name and adding text over them to know what folder they came from (hypotheticall revealing the location where the pictures were taken) to solve and a first simple solution using Bash and ImageMagick.</p><p>In <a href="https://carmine.dev/posts/wandpython/">the second post</a> we switched to Python and solved the <a href="https://carmine.dev/posts/wandpython/">https://carmine.dev/posts/wandpython/</a> same problem in a better way. With the Python version we can specify input and output directories and the code is much easier to understand.</p><p>In this post we’re going to take that Python code and make it work within a proper CLI tool built with the aid of argparse.</p><p>We’re going to implement the tool in three files:</p><ul><li>imageprocessor.py, which contains the code we wrote in the previous post and that provides an easy-to-use interface to Wand and ImageMagick in the form of a class called ImageProcessor, I&#39;m not going to explain it line-by-line in this post, so you should read my previous post (linked at the start of this post) if you want to know how it came together;</li><li>actions.py, which processes the arguments provided by argparse and uses the ImageProcessor to process the pictures.</li><li>myclitool.py, which is the executable that configures argparse to make it do what we want it to do.</li></ul><h3>The Commands We Need to Implement</h3><p>Our tool is going to respond to two subcommands:</p><ul><li>generate dir save_dir which takes the pictures from dir, processes them in the way I talked about in the first two posts in the series, and saves the output to save_dir</li><li>copy dir save_dir, which does the same but without adding text over the images, it only renames them and dumps them in the save_dir.</li></ul><p>Let’s implement the tool starting from the code that actually performs the actions and then we’ll work our way through the abstraction layers and eventually get to the part that actually implements the CLI interface using argparse.</p><h3>myclitool.py</h3><h3>An Introduction to argparse</h3><p>As we learned in the previous post, it is possible to build a perfectly functional CLI tool in Python without having to use any third-party package.</p><p>Actually, that might not be completely true. It depends on your definition of <em>perfectly functional</em>. Without argparse, you need to have your own help and usage responses and you need to parse arguments one by one as they are provided to the tool. Doing anything that&#39;s a bit more complex requires writing lots of code: having many subcommands, each with their own subcommands and usage strings, and perhaps different option would make the app very long and unreadable very quickly.</p><p>That’s where argparse helps: you define what you want your tool to respond to, write the functions that interact with the arguments in a logical and simple way, and it&#39;s done in a tenth (or less) of the lines of code it would have taken in plain Python!</p><h4>How to Use argparse</h4><p>The first element in the chain of objects used to configure argparse to do what we want is the ArgumentParser, which is the top level object all other objects should report to.</p><p>It is initialized with something like:</p><pre>parser = argparse.ArgumentParser( description=&quot;Improve the way you look at your picture collection with this simple CLI tool&quot; )</pre><p>Further down the chain we’re going to have subparsers, the pre-requisite for which is an object you can generate like this:</p><pre>subparsers = parser.add_subparsers()</pre><p>and that you can then use to add subparsers that will be linked to the original parser, optionally with an help text that will be used if the user requests usage information:</p><pre>generate = subparser.add_parser( &quot;generate&quot;, help=&quot;Generate the pictures&quot; )</pre><p>Arguments are very easy to add, we’ll see how we get them and how to use them later, and the help text is there for the same purpose as all other help text, as a way to give more information to the user when they request usage information:</p><pre>generate.add_argument(&quot;dir&quot;, type=str, help=&quot;The directory where the tree of input picture starts&quot;) generate.add_argument(&quot;save_dir&quot;, type=str, help=&quot;The directory where to save the output pictures&quot;)</pre><p>Now we need to define a function to process the directories, which we’ll talk about when we come to the action.py file. Meanwhile, let&#39;s say we&#39;ll call it process_dir and let&#39;s set it as the function to be called when the user calls the generate command:</p><pre>generate.set_defaults(func=actions.process_dir)</pre><p>Let’s do the same things we did for generate with copy:</p><pre>copy = subparser.add_parser(&quot;copy&quot;, help=&quot;Copy the pictures to the output path without adding text&quot;) copy.add_argument(&quot;dir&quot;, type=str, help=&quot;The directory where the tree of input picture starts&quot;) copy.add_argument(&quot;save_dir&quot;, type=str, help=&quot;The directory where to save the output pictures&quot;) copy.set_defaults(func=actions.copy)</pre><p>The last two lines we need to add to myclitool.py are those that actually parse the arguments the user actually provided and call the corresponding function with the corresponding arguments:</p><pre>args = parser.parse_args() args.func(args)</pre><p>argparse passes its arguments to the functions as a single structure that contains the arguments passed by the user.</p><p>For example, if we are passing an argument called arg1 and another called arg2, an hypothetical handle_call function that prints the arguments as passed by argparse is</p><pre>def handle_call(args): print(args.arg1) # prints arg1 print(args.arg2) # prints arg2</pre><h3>Handling the generate Command</h3><p>The function to handle the generate CLI subcommand is going to be called process_dir to further underline the fact it&#39;s the one meant to process the pictures and not just copy them.</p><p>Given that we are getting arguments called dir and save_dir</p><pre>def process_dir(args): image_processor = ImageProcessor(args.dir, args.save_dir) image_processor.process_dir()</pre><h3>Handling the copy Command</h3><p>The difference between these two functions is very subtle because of the way we implemented the ImageProcessor&#39;s constructor, which takes an optional boolean value that tells the process method whether or not it&#39;s supposed to process the images.</p><pre>def copy(args): image_processor = ImageProcessor(args.dir, args.save_dir, process=False) image_processor.process_dir()</pre><p>In the end, the actions.py file is</p><h3>imageprocessor.py</h3><p>We also need the ImageProcessor code which, as I said, is explained in the previous post and you can find here with some useful comments so that you can work out how it&#39;s put together without having to read that:</p><p>If python3 is the name of the command you use to run Python scripts (depends on your environment, it may be just python) you can use</p><pre>python3 myclitool.py generate /path/to/input /path/to/output</pre><p>to run the generate command and have /path/to/input as the input path and /path/to/output as the output path.</p><p>The copy subcommand can be used in the same way.</p><p>You can see usage information by running</p><pre>python3 myclitool.py -h</pre><p>and you can have help text specific to the generate command with</p><pre>python3 myclitool.py generate -h</pre><p>The same applies to copy obviously.</p><h3>Making the Script Executable</h3><p>As with any script ran by a scripting language, it can be made executable on Linux/macOS/Unix with</p><pre>chmod +x myclitool.py</pre><p>and, after adding the shebang line</p><pre>#!/usr/bin/env python3</pre><p>to the top of the file, you can execute it with</p><pre>./myclitool.py {command} [arguments]</pre><p>On Windows you need to use <a href="https://www.python.org/dev/peps/pep-0397/">the Python Launcher for Windows</a>.</p><p>We’re done! We’ve built a full CLI tool with usage strings, help commands and two subcommands each taking two arguments.</p><p>The next step is to go back to Bash and take advantage of its great completion infrastructure to provide a completion script that works on Linux and macOS. No such feature is available in Windows’s CMD. Even though there is PSReadline on Windows, I’m not going to write about it because I have no experience with it, as is the case woth most of the Windows-specific programming interfaces and tools. As always, remember <a href="https://carmine.dev/programmingflutter/">to check out my Flutter book</a> and <a href="https://twitter.com/carminezacc">follow me on Twitter</a>.</p><p><em>Originally published at </em><a href="https://carmine.dev/posts/argparse/"><em>https://carmine.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86476ca4ca2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bash scripting for everyday actions]]></title>
            <link>https://medium.com/@carminezaccagnino/bash-scripting-for-everyday-actions-6e8e29bb086b?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e8e29bb086b</guid>
            <category><![CDATA[terminal]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Wed, 13 Nov 2019 08:06:58 GMT</pubDate>
            <atom:updated>2019-11-13T08:06:58.941Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is the first in a series of posts about automating everyday actions. We’ll start with Bash shell scripting, which allows you to write scripts to automate dull, repetitive tasks.</p><p>The great advantage of Bash shell scripting compared to writing a full CLI tool to do what we need is that it is very easy to do, especially for those familiar with the Bash shell already, but it is only feasible to build Bash scripts that can be used for a very limited range of applications.</p><h3>The problem to solve</h3><p>Let’s identify a problem anyone can have at some point in life: editing some files according to the folder they’re stored in.</p><p>A relatable, if not too specific, story of someone who needs to learn Bash scripting</p><p>Let’s say you spend your summer vacation in Italy because you love when the weather is extremely hot, have heard there are beautiful cities, ancient churches, Roman Empire ruins and you want to taste typical Italian food in the place where it all started. However much time you decide to spend, Italy isn’t too big, there are fast trains, and you decide to visit several cities. Just like any tourist, you take pictures everywhere and, by the time you’re back home, you organize your pictures in folders.</p><h3>The current situation</h3><p>At this point you can at least figure out where you were when each picture was taken from the date on which it was taken from the hotel/rail/bus/domestic plane reservations you must have because rental cars with automatic transmissions are very expensive and less than 20% of Americans can drive a manual. You arrange your pictures into subfolders: you have folders for each place you visited and you put those folders in three folders called North, Center and South because it’s nice to be able to know that when you’ll look at the pictures in the future.</p><h4>The problem</h4><p>That in particular is a problem: looking at the pictures will now require you to browse and select pictures in each subfolder manually, and that’s especially painful on some less advanced I/O devices like TV remotes.</p><p>It would be ideal to be able to take all of those neatly organized pictures you have, put them all in one folder with a watermark telling you where you’ve taken them so it won’t look like you would have been better off just downloading some pictures from the Web when you show them to your friends (or kids) 10 years after you’ve been there.</p><p>Doing that by hand will require another 10 years and your friends or kids will already have visited all of the places you’ve visited fifty times by the time you are done. Fortunately, there is a way to make that quick and easy, and that is by embracing Bash shell scripting.</p><h3>Solving the problem</h3><p>Solving this problem requires two different levels of difficulty depending on what operating system you’re running. If you’re running most GNU/Linux distributions or macOS, Bash is your default shell, so it’s already installed and you can go on with the next section without having to install anything else. If you’re running any other Unix or Unix-like operating system that doesn’t install Bash by default, installing Bash is generally very easy and you can find specific instructions online in the very unlikely case you don’t already know how to install a package or port called bash on your OS of choice.</p><h4>Running Bash on Windows</h4><p>If you’re running Windows, you’ll have to install the WSL (Windows Subsystem for Linux) by installing one of the packages available in the Windows Store that include Bash. You just need to open the Windows Store, search for Ubuntu (for example) and install it. When starting for the first time, it will prompt you to enter a username and password you’ll need to remember. The password won’t even be shown to you in the form of asterisks, in case you’re confused by the fact it seems like you’re not actually typing anything in.</p><p>After that, you’ll be able to access Bash in any directory on your PC by running the</p><p>bash</p><p>command. You can exit the Bash shell by running the</p><p>exit</p><p>command.</p><p>More details about how to use it will be provided in the rest of the article.</p><h3>Bash scripting: the basics</h3><p>At its simplest, a Bash script is just a list of shell commands separated by newlines or concatenated together using pipes or some of the many script-oriented constructs Bash includes.</p><h4>A quick introduction to Bash and the Unix command line</h4><p>This section will be a very quick introduction to the usage of the Bash shell and the Unix command line in general, given that most shells are very similar when it comes to the most basic tasks. There are plenty of books available online that will teach you how to use it, many of which are aimed directly at Linux users, but they also apply to other Unix-like operating systems and to the Windows Subsystem for Linux.</p><p>The first thing to understand about any command line interface is that it’s like using a file manager: at any point you’re operating in a specific directory, called the working directory. Running the command (by typing it in and then pressing enter)</p><p>pwd</p><p>will return the current working directory.</p><p>The directory structure of Unix-like operating systems is a tree that branches out from the single root directory, the path of which is simply the character /. Other directories are chained after that separated by forward slashes. For example, the home directory at the root of the tree is found at path</p><p>/home</p><p>and a hypothetical user directory inside that would be at path</p><p>/home/user</p><p>Paths can be also expressed as relative paths, based on the current CLI working directory. The current working directory is expressed as ./ and the parent directory (the directory that contains the working directory) is expressed as ../.</p><p>You can change the working directory using the cd command followed by the path of the directory, expressed either as a relative path or an absolute path. For example, if you want to change the working directory to the parent directory, you’d write</p><p>cd ../</p><p>The trailing slash can be omitted and, if you’re moving into a subdirectory you can omit the ./ at the start, making the commands</p><p>cd ./Pictures/italy_pics/</p><p>and</p><p>cd Pictures/italy_pics</p><p>equivalent.</p><p>Files can be copied using the cp command, which takes two arguments: the path to the file to be copied and the path where you want the copy to be created, including the file name if you want the copy to have a different name: if you have a file called pic001.png in the italy_pics subdirectory and you want to copy it to the current working directory retaining the original file name, you’d run one of the following three commands (in decreasing order of command length)</p><p>cp italy_pics/pic001.png ./pic001.png cp italy_pics/pic001.png ./ cp italy_pics/pic001.png .</p><p>The command to move files is mv and you use it just like cp, except for the fact that it can be used to rename files by trying to move a file into the same directory it came from but with a different file name:</p><p>mv italy_pics/pic001.png italy_pics/pic1.png</p><p>While using the interactive shell, you can use the Tab keyboard button to get automatic completion of commands and arguments when there is only one choice or get a list of possible option. This is not relevant for Bash scripting, but will be more relevant in the coming articles.</p><h3>Running a Bash script</h3><p>Bash is an interpreted language and Bash scripts are ran mostly just like .py files.</p><p>To run a bash script saved in a file called script.sh, open a terminal window in the same directory as the script and run</p><p>bash script.sh</p><p>But there is actually a better way: just like with Python scripts, you can add a line at the top of the file, called the shebang line.</p><p>The shebang line consists of the two characters #! followed by the path to the interpreter to be used to run the script. In the case of bash, it is found at (or symlinked to) /bin/bash in pretty much every environment in which Bash installed, so you can add</p><p>#!/bin/bash</p><p>at the very top of your script so that the shell knows what interpreter to run.</p><p>This is useful because you can make the script executable with</p><p>chmod +x script.sh</p><p>and then run it just like any executable with</p><p>./script.sh</p><p>~/bin</p><p>If it’s a script you think you’ll need to use often, you can either add it to the systemwide binary file paths (where the packages you download are installed) or create a bin folder in your home directory and copy the script there. For example, rename the script file to the command to the name you want to give to the command, for example myfirstscript using mv and then create the ~/bin directory and copy the file there with the following three commands (in an interactive Unix shell or Bash shell on Windows):</p><p>mv script.sh myfirstscript mkdir ~/bin cp myfirstscript ~/bin/</p><p>and you can run the script simply by running</p><p>myfirstscript</p><p>from any working directory as long as you’re using the same user account you used to copy the file.</p><h3>Writing a basic Bash script</h3><p>Let’s start writing a Bash script by making a script that copies all of our organized pictures into a single directory and renameames them according to the place where they were taken. This is not quite as good as the watermark we wanted, but let’s do one thing at a time</p><p>Open any text editor and create a file called picorganizer in the ~/bin directory. The first thing you’ll need to add is the shebang line</p><p>#!/bin/bash</p><p>Make it executable right away by opening a terminal and running</p><p>chmod +x ~/bin/picorganizer</p><p>What our script will actually need to do</p><p>To solve the problem we have, we need to list the files in the directories we need to copy the files from and for each file we need to take the following three actions:</p><ul><li>Copy the files in the target folder</li><li>rename the file to a progressive number</li><li>add a watermark of the place where it was taken</li></ul><h3>Finding the files we need to copy</h3><p>The example directory tree we’ll be working with (that you can get by running the tree command) will be the following</p><p>italy_pics/ ├── Center │ ├── Assisi │ ├── Florence │ ├── Marche │ ├── Pisa │ ├── Rome_Lazio │ └── Siena ├── North │ ├── EmiliaRomagna │ ├── Genoa_CinqueTerre │ ├── Milan_Lombardy │ ├── Trentino │ ├── Turin │ └── Venice └── South ├── Bari_Apulia ├── Basilicata ├── Calabria ├── Campobasso ├── Naples_Campania └── Sicily</p><p>where each city/region name is a directory containing the pictures taken in that place. These are example places in Italy and do not necessarily represent places I would recommend going to, don’t judge me for a semi-pseudo-random selection of places.</p><p>To make the script aware of what we’re working with, we need to get a list of files and directories and store them in a Bash variable. Let’s start by learning the command to list files and directories.</p><p>In the Bash interactive shell, we can use the</p><p>ls</p><p>command to simply list the files and directories contained in the working directory, or you can run it with a path argument, like this:</p><p>ls /path/to/dir</p><p>to list the files and directories contained in /path/to/dir.</p><p>We can save the output of the ls command to a variable called list by writing, in our Bash script, the following:</p><p>list=$(ls)</p><p>where $(command) means whatever command prints to standard output. You can then use that variable just by prefixing the variable name with $ or by prefixing it with $ and enclosing the variable name in square brackets: just</p><p>ls</p><p>is equivalent to</p><p>files = $(ls) echo &quot;$files&quot;</p><p>and to</p><p>files = $(ls) echo &quot;${files}&quot;</p><p>This is not actually what we need right now, though: Bash’s for in loop is able to iterate over files in the working directory very easily, and we can just nest them and get to the pictures very quickly:</p><p>for area in *; do for city in ${area}/*; do for picture in ${area}/${city}/*; do # do something with ${area}/${city}/${picture} done done done</p><p>We can simply copy them all to another directory renamed to reflect where they were taken by adding the cp command to the innermost for loop:</p><p>mkdir ../italy_pics_organized i=1 for area in *; do for city in ${area}/*; do for picture in ${city}/*; do extension=${picture##*.} cityname=&quot;${city##*/}&quot; cp ${picture} &quot;../italy_pics_organized/${i}-${cityname}(${area}).${extension}&quot; ((i++)) done done done</p><p>There are a few things I haven’t yet explained and used here. Now I’ll explain them.</p><p>First of all, Bash doesn’t have variable types: every variable is a string and it doesn’t implement any mathematical operators or commands directly, so we need to use arithmetic expansion, which supports some specific <a href="https://www.gnu.org/software/bash/manual/html_node/Shell-Arithmetic.html">Shell Arithmetic operators</a>.</p><p>The ${parameter##word} expression used to get the city name and extension in the following way: it looks inside the parameter for the pattern (word in this notation) we specify after ## (in our case it’s *. for the extension and */ for the city name) and only returns the rest of the parameter, deleting the pattern (but keeping it in the original variable). You can find more information about this and the rest of what can be done with parameter expansion using the $ sign <a href="https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html">here</a>.</p><h3>Using ImageMagick to Add a Watermark</h3><p>We are doing something, and the script isn’t going to get much more complicated than that, but we aren’t adding a watermark yet. That’s because there isn’t a built-in tool to do that. No worries, though: the shell is expandable in the easiest way possible: by installing some software that provides a CLI interface.</p><p>The tool for the job when it comes to image manipulation is ImageMagick, which you can install by following the instructions on its own <a href="https://imagemagick.org/script/download.php">official download page</a>.</p><p>On Linux, what I actually recommend you to do is to install the ImageMagick package on Fedora/RHEL/CentOS by running</p><p>sudo dnf install ImageMagick</p><p>on Fedora or RHEL/CentOS 8 or by running</p><p>sudo yum install ImageMagick</p><p>on RHEL/CentOS 7 or earlier.</p><p>On Ubuntu, you can install the imagemagick package using APT by running</p><p>sudo apt install imagemagick</p><p>When using WSL with Ubuntu installed on top of Windows, you need to follow instructions for installation on Ubuntu while inside the Bash shell interface.</p><p>ImageMagick provides, among other things, a command called convert, which can be used, in conjunction with the annotate functionality, to add watermarks to images by running a command that looks like the following:</p><p>convert input.png -fill &quot;textcolor&quot; -pointsize textsize -gravity WhereTheTextWillBe -annotate +offsetHorizontal+offsetVertical &quot;watermark text&quot; output.png</p><p>where you need to replace textcolor with either a color name or an RGB hexadecimal color code (e.g. green or #76ff03), textsize with a number specifying the size of the font (e.g. 10 for a small font, 100 for a big font), WhereTheText will have to be replaced with something along the lines of NorthEast or SouthWest according to where you want the text to be, and paddingHorizontal and paddingVertical are offsets that can be used to move the text around or, more often, away from the edges. input.png and output.png have to be replaced with paths to the input and output pictures.</p><p>For our example, the command I chose, with ${picture}, ${watermarktext} and ${saveto} being variables, is:</p><p>convert ${picture} -fill &quot;white&quot; -pointsize 90 -gravity SouthEast -annotate +30+30 &quot;${watermarktext}&quot; &quot;${saveto}&quot;</p><p>So the final script is:</p><p>#!/bin/bash mkdir ../italy_pics_organized i=1 for area in *; do for city in ${area}/*; do for picture in ${city}/*.jpg; do cityname=&quot;${city##*/}&quot; extension=&quot;${picture##*.}&quot; saveto=&quot;../italy_pics_organized/${i}-${cityname}(${area}).${extension}&quot; watermark=&quot;${cityname} (${area})&quot; convert ${picture} -fill &quot;white&quot; -pointsize 90 -gravity SouthEast -annotate +30+30 &quot;${watermark}&quot; &quot;${saveto}&quot; ((i++)) done done done</p><p>Tips For the Future</p><p>Here are a few things I didn’tell you you might need to know in the future when working with Bash or browsing Bash-related documentation.</p><h4>The Difference Between # and $</h4><p>Usually, when reading documentation about Unix command line usage (including the sections of my <a href="http://carmine.dev/programmingflutter/">book about cross-platform mobile app development</a> that concern Linux installation or CLI usage, for example) you might find that the commands are prefixed with the character $, like in the following example:</p><p>$ ls -alh</p><p>or are prefixed with #, like in the following example:</p><p># vim /etc/fstab</p><p>Those prefixed with $ are meant to be executed as an unprivileged, regular user. Those prefixed with # are meant to be executed by the root account or by using sudo.</p><h4>Don’t Delete Your Stuff: a (Not So) Funny Anecdote</h4><p>You might want to clean up and use the command</p><p>rm -rf *</p><p>if you know the working directory is going to be each of the directories in which you have pictures organized the old way, for example. Only use such a destructive command if you’re 100% sure there is no way for it to get executed in the wrong folder. Make sure to at least turn it into something that only deletes files with the extension you want to delete like this</p><p>rm -rf *.jpg rm -rf *.jpeg</p><p>If you’re thinking nobody would be so dumb not to think of it, there is at least one exception in the world. Some years ago I was a bit too confident and wrote a shell script that did some cleaning up afterwards. At some point during the execution of the script, it executed rm -rf * in my home folder. That’s not great.</p><p>I only figured it out when it was halfway through deleting the Documents folder, and it had already deleted the ~/bin folder containing, ironically, most of my commonly used (and harmless) bash scripts (some of which I already was using on some remote servers and that I was able to recover) and itself in the process. I had recent backups of most of the important stuff, so it wasn’t the end of the world for me, but I can’t say it wasn’t annoying.</p><p>The Bash if</p><p>Bash has an if clause, I just didn’t feel like adding more complication to the script (even though it would have been better for it) by adding functionality that requires its use, its basic syntax is</p><p>if [[ condition ]]; then # do something fi</p><p>You can find more information about it online, and online you’ll also find a lot more information on Bash than what it’s made sense to include in this post.</p><p>Stay in touch with me <a href="https://twitter.com/carminezacc">on Twitter @carminezacc</a> or follow this blog to know when the next post (about making a full-featured CLI tool with Python) comes out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e8e29bb086b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Flutter Book]]></title>
            <link>https://medium.com/@carminezaccagnino/my-flutter-book-8c1f0d69e203?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c1f0d69e203</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 20:25:24 GMT</pubDate>
            <atom:updated>2019-07-25T07:45:57.744Z</atom:updated>
            <content:encoded><![CDATA[<h4>PSA: this Medium page will be back to an active state soon, as a mirror of <a href="https://www.carmine.dev/">the blog I’ll make public soon,</a> with new web and mobile development stories coming very soon!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-jU8JV47awE2bGB9tkEVw.jpeg" /><figcaption>The cover of the book</figcaption></figure><p>I’ve been teasing the release of the book for a while, now it’s available as a <a href="https://pragprog.com/book/czflutr/programming-flutter">beta book from the Pragmatic Bookshelf</a> and you can buy it, mostly content complete. There you can also find extracts and read those instead of reading this boring description of it.</p><h3>Why Flutter Matters</h3><p>Flutter allows you to write apps for Android, iOS and Fuchsia without having to manage three different codebases, while being able to write UIs in a declarative way without the need for external UI files. Flutter supports hot reload, meaning you can see the effects of changes to the code instantly, and it is developed by Google themselves with support from Apple.</p><p>It also allows you to write regular Android Java/Kotlin code or iOS Objective-C/Swift code and it has great support for Firebase.</p><h3>Why Books Matter</h3><p>Articles, videos and wikis can go very far, but a book really helps get the big picture and get the information in a more organic and complete way. A book can show bigger examples that go on for several pages, it can get a reader from zero to full knowledge a step at a time, and it can make assumptions of the reader’s previous knowledge based on the content of the previous chapters and nothing else.</p><h3>Why My Book Matters</h3><p>Obviously you don’t just buy any book you see online, so you need to know about what makes the book I’m talking about good.</p><h4>The Approach</h4><p>You don’t need a reference manual, you need something that gives real, concrete examples of how to do something you actually want to do. You want to know about what can be done with Flutter, how it’s done and what it will look like, while having your hand held every step of the way as much as you need: if you are confused by Dart syntax, there will be an appendix that will clear it up for you; if you don’t need as much help, the book will flow very quickly, given that, in the body of the book, there isn’t as much focus on the language and there’s a greater focus on Flutter and on creating beautiful and, more importantly, useful apps.</p><h4>The Content</h4><p>Obviously you need to know about all of the different widgets and layout options, but you’ll certainly want an example of how to use each in an app and what it will look like. That’s what the book provides: concrete examples, some shorter and some longer, depending on the range and depth of applications of the given feature or widget.</p><p>You’ll get to know about how to use and make your own packages and plugins, how to integrate your own native platform-specific code into a Flutter app and how to interact with HTTP Web APIs, something that integrates perfectly with <a href="https://medium.com/@carminezaccagnino/how-to-build-a-simple-web-api-in-a-few-minutes-using-python-and-flask-f5f6b9e2c761">this guide</a> I wrote a while ago on how to make an HTTP Web API in a few minutes.</p><p>You’ll get to know how to test and debug Flutter apps and, finally, how to create a nice-looking chat app using Firebase as a back-end!</p><p>Finally, you’ll learn about animations and transitions and about Cupertino (iOS-like) widgets and how to make your app seamlessly switch between Material and Cupertino widgets based on the platform it runs on.</p><h3>Still not sure? Here’s what will convince you</h3><p>There are two things you need to know: the first is that at the moment there is a site-wide 40% discount on all ebooks on pragprog.com using the coupon code you can find <a href="https://pragprog.com/news/christmas-in-july-save-40-on-pragprog-com-today">here,</a> the second thing is that there are some freebies: a total of almost 60 pages of the book are available as extracts <a href="https://pragprog.com/book/czflutr/programming-flutter">on its official page at pragprog.com,</a> so you can start with those and eventually consider buying the full book whenever you feel like it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c1f0d69e203" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking and/or using pictures in Flutter apps using the image_picker package]]></title>
            <link>https://medium.com/@carminezaccagnino/taking-and-or-using-pictures-in-flutter-apps-using-the-image-picker-package-b8e366654a0?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8e366654a0</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Sat, 09 Feb 2019 21:37:57 GMT</pubDate>
            <atom:updated>2019-02-09T21:37:57.244Z</atom:updated>
            <content:encoded><![CDATA[<h4>You know the basics of Flutter programming, now it’s time to explain one of the most common and useful Flutter packages because the standard library isn’t enough for you anymore.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8AzEfiPwTAtNtkJhvW7IGQ.jpeg" /></figure><p>One of the packages I highlighted in <a href="https://medium.com/@carminezaccagnino/a-tour-of-the-best-flutter-packages-on-pub-eb302a4d8d14">my recent tour of the best Flutter packages on Pub</a> is the <a href="https://pub.dartlang.org/packages/image_picker">image_picker package</a>, which allows you to add an image selection dialog to a Flutter app.</p><p>For example, let’s suppose you want to have an app to showcase the best pictures you have taken, so you need to have two things: a screen to show the pictures and a dialog to add a picture, either by selecting an existing picture or by taking a picture.</p><p>What we’ll be building is an app that will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4U-lLn1ZCBwXPvzZlYB00A.png" /><figcaption>These are the picture the Android emulator pretends to take when you use its camera. Very interesting.</figcaption></figure><h3>Installing the image_picker package</h3><p>Installation of a Flutter package is done in two steps: edit pubspec.yaml to include the dependency on image_picker:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99c3616c152bbeda692f6c949785bab2/href">https://medium.com/media/99c3616c152bbeda692f6c949785bab2/href</a></iframe><p>And then run the</p><pre>$ flutter packages get</pre><p>command to actually download and install the package.</p><h3>Building the showcase interface</h3><p>The showcase interface will be composed of a <a href="https://docs.flutter.io/flutter/widgets/ListView/ListView.builder.html">ListView.builder</a> that takes each element of a <a href="https://api.dartlang.org/stable/2.1.0/dart-core/List-class.html">List</a> we’ll be creating to store the <a href="https://docs.flutter.io/flutter/widgets/Image/Image.file.html">Image</a>s that need to be shown and displays them separated by a <a href="https://material.io/design/components/dividers.html">Divider</a> (a thin and padded horizontal line).</p><p>We’ll start building the app by importing both the Flutter standard Material library and the image_picker package in the main app code (main.dart file):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59cf9292bf2fb9b00387f4f3b425d9fc/href">https://medium.com/media/59cf9292bf2fb9b00387f4f3b425d9fc/href</a></iframe><p>After doing that, we’ll need to write a main method to run a MaterialApp that will load a Stateful PictureShowcaseHome home page.</p><p>This is fairly basic Flutter programming, so it shouldn’t require further explanation in a guide like this aimed at the Flutter developer that already knows the basics and is looking into more advanced topics like packages.</p><p>For more basic tutorials, check out my Twitter <a href="https://twitter.com/carminezacc">@carminezacc</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fce8ef87beaf78ce02aa30c955bbed0/href">https://medium.com/media/8fce8ef87beaf78ce02aa30c955bbed0/href</a></iframe><p>The next step is to build a stateful home page for our app.</p><p>The StatefulWidget contains just the definition of some static data, while the state definition is where the fun stuff happens:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d02a4ae98879aba0c89d6acacbc78771/href">https://medium.com/media/d02a4ae98879aba0c89d6acacbc78771/href</a></iframe><p>In the state definition we have a regular Scaffold with a simple AppBar and a ListView.builder (which is a scrollable list of dynamically built widgets) that displays, for each element of the imgs List, a Column (vertically stacked widgets) composed of the image we want to display and a Divider to divide it from the next image in the list.</p><p>The FloatingActionButton will be used for adding other images, but that’s what we will be implementing in the next paragraph</p><h3>Using image_picker to implement picking</h3><p>To set the onPressed attribute of the FAB, we need to take advantage of the image_picker package to take pictures using the camera (or the gallery).</p><p>If you wanted to add pictures from the camera, you would use the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/705305c36600bcd7e74e24e20166a11d/href">https://medium.com/media/705305c36600bcd7e74e24e20166a11d/href</a></iframe><p>ImagePicker.pickImage() is the main method of the image_picker package: it is used to fire up the camera or the gallery picture picking dialog.</p><p>The source attribute can be one of either ImageSource.camera or ImageSource.gallery (depening on where you want to take the pictures from), which are the possible values of the enum ImageSource .</p><p>Then we call setState() to re-render the app while adding the newly picked image to the imgs List.</p><h3>The complete code</h3><p>The full code for this app is the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e3fe8a2947d54a9739b3c845b55361a/href">https://medium.com/media/7e3fe8a2947d54a9739b3c845b55361a/href</a></iframe><h3>More Flutter stuff from me</h3><p>I’m working on a Flutter book that covers both the basic, some intermediate concepts like this and some more advanced topics.</p><p>I (somewhat) regularly post tips, tricks, guides and posts, so make sure to follow me on Twitter at <a href="https://twitter.com/carminezacc">@carminezacc</a> to be sure to stay updated on all of that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8e366654a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A tour of the best Flutter packages on Pub]]></title>
            <link>https://medium.com/@carminezaccagnino/a-tour-of-the-best-flutter-packages-on-pub-eb302a4d8d14?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb302a4d8d14</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Sun, 03 Feb 2019 16:00:22 GMT</pubDate>
            <atom:updated>2019-02-03T16:06:02.297Z</atom:updated>
            <content:encoded><![CDATA[<h4>A compilation of the most useful packages you can find on Dart Pub</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*VcfRrzWYvXmfOWHEYufpWQ.jpeg" /></figure><p>One of the things Flutter makes easier and better when compared to all other mobile development frameworks and SDKs is using third-party and Google-developed libraries.</p><h3>An introduction to packages</h3><p>90% of the time you just need to go on <a href="https://pub.dartlang.org/flutter">https://pub.dartlang.org/flutter</a>, find the package you want and add the <em>Installing </em>section to the <strong>pubspec.yaml</strong> file in the root of the app’s source tree.</p><p>Many of the packages might eventually make it into the Flutter standard library, but most of them are stable, complete and dependable even in their current state on Dart Pub.</p><h3>My personal selection of the best and most essential packages</h3><p>There are some packages on Pub that are needed for many apps, here’s a list of the ones I personally consider most important and useful.</p><h4>Launching URLs and apps using the url_launcher package</h4><p>This package provides a cross-platform way to launch URLs, including non-Web links like sms: and mailto: links.</p><p>A guide about how to use this package is coming on my Medium, so follow me on Twitter to make sure you know when that or other posts or guides are published.</p><h4>Navigating to paths in the local storage using the path_provider package</h4><p>The path_provider package is used together with the dart:io library to access the phone’s local app storage, providing paths for both the cache (volatile) and documents (persistent data) directories.</p><h4>Making HTTP POST, GET and other requests using the http package</h4><p>The http package is probably the most important package: it makes making HTTP requests very easy and it supports all types of HTTP requests.</p><h4>Taking and loading pictures using <strong>image_picker package</strong></h4><p>The image_picker package is used to take pictures or select them from local storage in an intuitive way.</p><p>There is an article about using this package coming out on my Medium page as well. You can follow me on Twitter (link in my Medium bio, follow me on Medium while you’re there) to know when it comes out.</p><h4>The Firebase and Firestore packages</h4><p>Google Firestore and Firebase are some of the best companions to Flutter apps and there are packages to make working with them easier and more intuitive.</p><h4>The Google Sign-In package</h4><p>There is a package on Pub that provides a simple interface to the Google Sign-In system, making authentication easier and safer for the user.</p><p>The Flutter library isn’t really complete, but with these packages the process of building an app will surely be made easier!</p><p>Follow me on Twitter <a href="https://twitter.com/carminezacc">@carminezacc</a> for more tips, trick, thoughts and posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb302a4d8d14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Being a Mobile Developer in 2019 and beyond]]></title>
            <link>https://medium.com/@carminezaccagnino/being-a-mobile-developer-in-2019-and-beyond-1c8f35bea891?source=rss-340b0b69bf32------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c8f35bea891</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Carmine Zaccagnino]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 18:49:39 GMT</pubDate>
            <atom:updated>2019-01-08T18:49:39.156Z</atom:updated>
            <content:encoded><![CDATA[<h4>What you need to do to stay updated as a developer in this ever-changing industry</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*JoVIIF8mn4DKzx1LegvmWg.jpeg" /></figure><p>The world of technology and software is ever-changing and that means you need to stay on top of the news in order to avoid being caught out only being able to work with outdated technologies and frameworks.</p><h3>We’re still in the app “bubble” apparently</h3><p>Good news: yes, it looks like the biggest market for software development is still the mobile app market.</p><p>More and more people are doing more of their computing on mobile devices and using their desktop computers less, so the need for a mobile-specific experience, so you don’t need to worry about</p><p>But it’s not the same as it was a few years ago: the tools you use for it have radically changed.</p><h4>The iOS side of things</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*SpJNBNBlX77xKQLHeBFt5Q.png" /><figcaption>The Swift logo is a trademark of Apple Inc.</figcaption></figure><p>iOS an ever-shrinking, but relevant, section of the mobile market, since iOS users still tend to spend more money to buy apps that most Android users would, and it is still not very far from having half of the market share, especially in the United States.</p><p>It’s a shrinking market but it has also gotten easier to developer for over the years in many aspects.</p><p>First off, Objective-C is dying off, last year its successor Swift surpassed it in terms of popularity in the entire professional development market, so learning Objective-C now would be rather counter-productive unless it’s a specific requirement for something you need to do.</p><p>Also, Swift is a lot simpler to pick up than Objective-C and it has a much simpler and concise syntax, making it more readable and maintainable after the code has been written.</p><p>The macOS requirement is still there and will probably stay there since it looks like it isn’t enough to deter most developers from building apps for iOS.</p><h4>The Android side</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*SXPpl4cRIgxNcIWGfKXvSQ.png" /><figcaption>“The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons </a>3.0 Attribution License.”</figcaption></figure><p>Over here the revolution hasn’t happened yet, but that doesn’t mean Java is still unchallenged in the Android world.</p><p>On the Android side, things aren’t quite as clear as in the iOS: Java is still alive and well (at least mostly) and Kotlin is really new and isn’t nearly as popular as Swift is on the other side: Kotlin might be hot for start-ups and independent/freelance developers, but the established companies are still relying on Java to do the job.</p><p>Also, Google doesn’t actually look like they’re too interested in pushing Kotlin for too much longer as they seem to be intent on moving people over to their own new Flutter framework, perhaps to help with making moving from Android to Fuchsia smoother, as Flutter is natively compatible with Fuchsia.</p><h4>Fuchsia</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*xctfo5QqqYk6fl3fZGL7eA.jpeg" /></figure><p>Fuchsia is the (rather funny coloured) elephant in the room.</p><p>Google is working on a new operating system called Fuchsia running on a Google-developed kernel (ditching Linux) to replace both Android and Chrome OS to give better performance and an unified experience, which might sound great until you think about how terrible app compatibility might end up being for a brand new platform.</p><p>There are many rumors about it: while it is probable that it will also support Android applications and some think it may support apps written in the Swift language, the only thing that’s certain is that it will natively support apps written using Flutter.</p><p>This gives us a great chance to talk about just that: let’s talk about Flutter!</p><h3>Flutter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NZv63ArM9xRolRYyewcfA.png" /><figcaption>“The Flutter logo is reproduced or modified from work created and shared by Google and used according to terms described in the <a href="https://creativecommons.org/licenses/by/3.0/">Creative Commons </a>3.0 Attribution License.”</figcaption></figure><p>Flutter reached 1.0 in December and I have repeatedly shown excitement and interest in its developments, especially because it has been developed by Google themselves and officially supported by Apple too.</p><p>Flutter is here right now and you can build apps that work on both iOS and Android without having to write the same app twice and without having to rely on web-based tools like Microsoft’s Xamarin or Facebook’s React Native.</p><p>You can run Java/Kotlin and Swift/Obj-C code effortlessly within Flutter apps to run lower-level or legacy code, but you can easily get away with just using standard Flutter and the great collection of third-party (but also first-party) libraries already available for it.</p><p>If you are as excited about Flutter as I am, make sure to follow me on Twitter <a href="https://twitter.com/carminezacc">@carminezacc</a> and check out my Medium profile for more mobile and web development advice and information from yours truly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c8f35bea891" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>