<?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[Corollarium - Medium]]></title>
        <description><![CDATA[What is in our minds at Corollarium - Medium]]></description>
        <link>https://medium.com/corollarium?source=rss----9e560158121---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Corollarium - Medium</title>
            <link>https://medium.com/corollarium?source=rss----9e560158121---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:48:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/corollarium" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Secure context for webservers on LANs: a hack]]></title>
            <link>https://medium.com/corollarium/secure-context-for-webservers-on-lans-a-hack-306af30f74c2?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/306af30f74c2</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tls]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 03 Sep 2019 15:14:39 GMT</pubDate>
            <atom:updated>2019-09-03T15:14:39.381Z</atom:updated>
            <content:encoded><![CDATA[<p>Browsers currently require <a href="https://w3c.github.io/webappsec-secure-contexts/">a secure context</a> (<a href="https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts">MDN</a>) for several Web APIs to work, such as opening cameras. In short, that means you need a HTTPS connection with a valid certificate signed by a known CA.</p><p>While it’s simple for public websites to add a CA-signed certificate, it’s much more difficult for intranets and computers with only private IPs. Testing software that requires secure context, despite the exception for localhost, is a source of pain and frustration; anyone who wanted to test on a real phone or any device that was not your own computer can attest to that. And when you’re releasing web applications for production that will run on private networks that you have no control at all, it’s just a nightmare.</p><p>We needed a solution to have secure contexts in LANs or one of our products, the <a href="https://softwarevideowall.com/">Corollarium Videowall</a>, wouldn’t work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GF2woGG3RLwfUyDUDcVO6Q.jpeg" /><figcaption>We needed an image for this post, so here’s the video wall in action.</figcaption></figure><p>What we did to solve it was a simple DNS server to provide TLS to webservices on local addresses. In short, it resolves addresses such as ‘192–168–0–1.yourdomain.net’ to 192.168.0.1 provides a valid wildcard TLS certificate for that domain.</p><p>It’s called <a href="https://github.com/Corollarium/localtls">localtls and it’s available on Github</a>.</p><p>For the user this is transparent. They open a simple URL. The local webserver can 301-forward a request to 192.168.0.1 to https://192–168–0–1.yourdomain.net transparently.</p><p>Technically it’s a very simple DNS server written in Python, which uses <a href="https://letsencrypt.org/">Let’s Encrypt</a> to generate a wildcard certificate for *.yourdomain.net on a real server on a public IP. This certificate, both private and public keys, is available for download via a REST call. When the local server app is started, it downloads the keys from the public server and starts a HTTPS server using those keys. So it’s composed of:</p><ol><li>a simple DNS server that resolves to IP.yourdomain.net (for local IPs, see below) to IP and runs on a public internet server.</li><li>an embedded simple HTTP server serving an index.html and a REST endpoint with the certificate keys, including the private key.</li><li>a one-liner to generate and renew a valid certificate with LetsEncrypt, using DNS authentication. This script should be run once a month.</li></ol><p>We only resolve private IPs and the naked domain:</p><ul><li>yourdomain.net: resolves to your server IP, both A and AAAA (if it exists) records. _acme-challenge.yourdomain.net also resolves like this, since it’s necessary for the certbot authentication.</li><li>a-b-c-d.yourdomain.net, where a.b.c.d is a valid private network IPV4 (192.168.0.0–192.168.255.255, 172.16.0.0–172.31.255.255 and 10.0.0.0–10.255.255.255): resolves to A record of a.b.c.d. In other words, replace `.` by `-`.</li><li>fe80-[xxx].yourdomain.net: resolves to AAAA record of fe80:[xxx]. In other words, replace any `:` by `-`.</li><li>anything else: falls back to another DNS server.</li></ul><p>We don’t use the wildcard TLS keys for the naked domain, but a separate certificate that is kept private.</p><h4>Security considerations</h4><p>“But if you publish the public and the private key, someone can do a man-in-the-middle attack!” Yes, that is correct. This is <strong>as safe as a plain HTTP website if you release the private key</strong>.</p><p>Our aim was to solve the requirement of browsers with secure contexts in LANs with a minimum fuss: as mentioned when you are developing an app that requires it, for example, and want to test it on several devices in your LAN. Or when you want to deploy a web application on private customer networks that have no expertise to setup a nameserver and TLS.</p><p>Restricting features to a secure context is a move in the right direction, but unfortunately self signed certificates are considered unsafe by browsers, even if you accept them. Adding a certificate as trusted is a complicated task that one cannot expect regular users to do.</p><p>Hopefully web committees and browser makers will come up with a solution that makes secure contexts in intranets easier (and safer) in the future, but it has been a problem for years and it’s still unsolved at this time. Perhaps self signed certificates could be handled differently for private IPs, letting people accept them with a warning but a simple procedure could work.</p><p>Meanwhile we are still running local web apps in plain HTTP without a hitch, but the change to force secure context for sensitive access created a void that is currently hard to solve. This means that IoT devices, routers, printers and any other device that provides a web server locally does not use HTTPS.</p><p>In short, we have two possible scenarios.</p><p>The first: you understand that with this solution you may be prone for a MITM attack, but you need a secure context in the browser to run your local app and you don’t need absolute certainty that your traffic will not be snooped or your application won’t be spoofed. This works for most webservices running in a LAN, and again, is as safe as running them on pure HTTP.</p><p>The second: you need not only a secure context for the browser, but actual safety of a private TLS certificate validated by the browser. In this case you can run the localtls DNS server yourself and not publish the private keys, but find someway to distribute them yourself privately to your application. Remember, any application you deploy using TLS will require a private key deployed with it. When distributing web apps that are supposed to run in intranets which you have no access this is hard to do; you’d ideally need to generate a different key for every host, even though they may use the same private IP, you have no access to a local nameserver and other complications. There is a <a href="https://blog.heckel.io/2018/08/05/issuing-lets-encrypt-certificates-for-65000-internal-servers/">nice proposal of how this can be done</a> if you need this level of security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=306af30f74c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/secure-context-for-webservers-on-lans-a-hack-306af30f74c2">Secure context for webservers on LANs: a hack</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</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 build a bullet-time rig with Camera360]]></title>
            <link>https://medium.com/corollarium/how-to-build-a-bullet-time-rig-with-camera360-e521ceadc9b5?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/e521ceadc9b5</guid>
            <category><![CDATA[bullet-time]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[photography]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 14:11:19 GMT</pubDate>
            <atom:updated>2019-03-18T14:11:19.648Z</atom:updated>
            <content:encoded><![CDATA[<p>We’re often asked about how to build a rig to take bullet-time pictures. Our <a href="https://camera360.com.br/">Camera360 software</a> makes it very easy to take pictures, but you still have to get the cameras and the physical setup. Here is a guideline to help you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*99AZNA_ZH--T1Q7avNq_3A.jpeg" /><figcaption>Our basic Camera360 setup: an aluminum structure, light and easy to build and setup.</figcaption></figure><h3>Choosing the cameras</h3><p>Camera360 supports two types of cameras, Android devices (any modern phone will work!) and Raspberry Pi.</p><p>The <a href="https://www.raspberrypi.org/">RaspberryPi</a> is a credit card–sized computer, which with its camera module works as a very inexpensive solution for Camera360. It also features Ethernet support, which is more stable and faster than Wi-fi, so the time synchrony will be better and the photos will be downloaded faster.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FuXUjwk2-qx4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DuXUjwk2-qx4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FuXUjwk2-qx4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a442fcb5146a8e257e9cd2308a608fd/href">https://medium.com/media/6a442fcb5146a8e257e9cd2308a608fd/href</a></iframe><p>Android phones have more camera options, and high-end models have excellent optics and camera quality. They are a better option if you are looking for very high-quality and cost is not an issue.</p><h3>Mechanical structure</h3><p>Once you have the cameras, you need to place them on a physical structure. Anything will work, as long as:</p><ul><li>it’s stable.</li><li>the cameras can be aligned. We suggest 3D printed holder for the cameras, but you can use phone holders for cars as well.</li><li>if you are building a 180 or 360 degree setup, it should be round. Even smaller angles work better with round structures. You can bend a metal tube for that or buy a structure that is ready.</li><li>you have electrical power to keep the phones or Pis on.</li><li>remember to think about lighting as well.</li></ul><h3>Networking</h3><p>We suggest the following network topology:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mLObnNS5jqronb7c2vhbXQ.png" /></figure><p>This way devices are connected in a private LAN, without internet access (so your android devices won’t try to download updates in the middle of your shooting), but you can send pictures to our cloud server right away.</p><h3>Software</h3><p>Camera360 does everything for you: with just one click you take the pictures, which are processed by the computer and you get a GIF/MP4/list of JPEGs. You can also:</p><ul><li>control camera settings, like ISO or exposure</li><li>add overlays and watermarks</li><li>check camera status</li><li>get images online to our Camera360 Cloud Server immediately, sending emails to your customers or integrating with social media, all using your own domain. We do everything for you, no technical expertise required at all.</li></ul><p>You can <a href="https://corollarium.com/product/4333">download a free trial and test a basic two-phone bullet-time rig</a>. Start now!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e521ceadc9b5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/how-to-build-a-bullet-time-rig-with-camera360-e521ceadc9b5">How to build a bullet-time rig with Camera360</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How we stress tested an app thousands pictures taken at the exact same time]]></title>
            <link>https://medium.com/corollarium/how-we-stress-tested-an-app-thousands-pictures-taken-at-the-exact-same-time-d452597201b4?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/d452597201b4</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 16:59:33 GMT</pubDate>
            <atom:updated>2019-01-08T17:08:22.349Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we stress tested thousands of pictures taken with our app at the exact same time</h3><p>Profiling is the final stage of a software development cycle, right before it goes back to the “let’s add new features and make it slow again” phase that starts everything all over again. It is also, even more than automatic testing, the thing developers are the least aware of how to do and more prone to skip. Profiler tools are very nice, and the ones in browsers these days are excellent.</p><p>This post is not about “how things are faster now with my micro optimizations.” It is about how we profiled and stress tested Multiselfie in real production conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yGs-wSTEx4vol880r4NRMw.png" /><figcaption>Multiselfie, the login page.</figcaption></figure><p><a href="https://multiselfie.com/">Multiselfie</a> is our new app to take a selfie not only with your phone, but your friends too, at the exact same time. It’s great fun.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGa1oRxY6SQc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGa1oRxY6SQc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGa1oRxY6SQc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f288bb9c8ac8c51060b7dbe6b02f21d6/href">https://medium.com/media/f288bb9c8ac8c51060b7dbe6b02f21d6/href</a></iframe><p>Of course we’re not only thinking about you and a couple of friends. We want events where thousands of users take a picture at the exact same time. We have a few challenges there to ensure synchronization of remote clients and crazy networks, and getting thousands of uploads at the same time right after the picture is taken. We want, at some point, over 1 million people taking a photo together.</p><p>When Multiselfie was first running we didn’t even know what load the server would handle.</p><p>Most people ignore profiling because software these days is fast enough, becoming only an issue in heavy processing or with tens of thousands of users. But when you’re up to our challenge of taking thousands of pictures at the exact same time, milliseconds are an eternity.</p><p>We had to test. Let’s add stress.</p><h3>How we wrote our stress test</h3><p>Yes, there are are several tools for stress testing, but all the ones we found essentially hit the server in uncoordinated fashion. This makes sense in a webserver for an ecommerce business, with tons of people buying at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*b8HWSEheDHD6smWjFuqvzg.jpeg" /><figcaption>Let’s reinvent the wheel.</figcaption></figure><p>But it was very different from our problem. We had this flow to follow:</p><ol><li>The first client had to create a multiselfie room. Each room has an id, and the other clients need this id to connect in the right room. This client has to login first, too.</li><li>Once the room is ready, we add a few hundred or thousand clients to that room, connecting to the server.</li><li>Once they connect, the clients join a room and wait for the shoot to happen.</li><li>The room owner shoots.</li><li>All clients shoot too, and start to upload their pictures in a stampede.</li><li>After they shoot, they start to download the images themselves to see what happened.</li></ol><p>That is not your trivial ‘ab’ command. We also wanted to run clients over many different nodes in different geographical regions, to test a global picture. Or run the clients locally over wifi and a real 3G connection. Or add artificial delays and kill certain clients mid-run.</p><p>Since no tool seemed to handle all that, it was time to write our own. As a bonus we could use our own client code, which meant less rewriting and more tests of real code. We quickly wrote a small test tool that performed the entire flow, but with no GUI. We have acceptance tests for the GUI running in real browsers. They are one of our dev’s favorite pet peeve.</p><p>If you are reading this post looking for ideas to stress test you own software, this proved up to be a good path. The server required no changes and the tests ensured that the client code was used. This proved helpful not only to benchmark, but also to find some bugs that would have been difficult to catch with simple unit tests. The complexity of implementing the tool was rather small, too. We needed to write a CLI utility that received parameters such as the number of clients to open, the server URL etc, and that had a main function implementing the entire flow without human interaction, calling the different parts of our code and timing each one.</p><p>Our stress tool could open several processes to better simulation parallel operations, each one with a number of connections. More than that, it can be run it in several different nodes at the same time, to test different networks and even more parallelism.</p><h3>What our tests had to do</h3><p>We drew a simple plan for the tests, in increasing order of complexity and load.</p><ol><li><strong>The 10 picture local test</strong>. Yes, 10. Well, things have to work before we can add stress. When we had 10 clients running we were ready to really start testing. This became a staple in our development process, since it was easier to run a single command to take pictures than any test (other than the CI tests, of course). Everytime we made changes to the flow we were running the stress script along.</li><li><strong>The 100 local test</strong>. Things should scale reasonably well and be fast. Most complex bugs should show up at this point, particularly crazy racing conditions. This caught the major performance problems.</li><li><strong>The 100 remote test</strong>. Add a real network on top of the test, and see if things still work and still are fast. We ran the server process in our real server machine, and ran things from our connections, including 4G. Working remote made this even better, since we were using different ISPs and completely different routes. We often ran 50 to 100 clients in each of the dev machines, connecting to the same room at the same time, to see how they’d behave. This is where we started to run into N² download problems: 100 clients meant 10.000 downloads.</li><li><strong>The 1k picture local test</strong>. We had to make sure our server could handle 1k clients and not be flooded, not caring about our network. A few things were obvious, like realizing that running a server with full debug printing connections on the console was not smart at this point.</li><li><strong>The 1k picture, remote</strong>. Let’s add a real network to the previous test and check if timeouts and delays and lost packets don’t wreck havoc. Run a server on the web and all those clients locally.</li></ol><h3>What we’re measuring</h3><p>We wanted to measure the total time for each operation in our flow and how it behaves according to the number of users. We have four basic steps to check:</p><ol><li><strong>Connection time</strong>: how long N clients take to connect to the server. This is simply the network connection. We expected this to be fast and not really problematic.</li><li><strong>Join photo time</strong>: how long N clients take to join a room. Joining a room is a complex operation that performs several checks (such as whether the room exists), updates shared data and notifies users of new people in the room. This, with the connection time, is essentially the “loading time” for the app. It’s the time between you clicking on “join a room” and seeing the camera open and ready to shoot (since opening the camera preview is much faster than the network connection).</li><li><strong>Upload time</strong>: how long N clients take to upload their photos. This is also a complex operation due to checks and notifying users of new photos as they arrive.</li><li><strong>Download time:</strong> not only all N clients upload their pictures, but they download the N pictures too. That’s a O(N²) operation. Let’s measure that, as it’s bound to be a major problem. Nothing N² is ever good. I’ll come back to this.</li></ol><h3>Profiling</h3><p>Perhaps due to computers being “fast enough”, I know very few programmers who can profile code. It’s not a hard task and there are wonderful tools. Node has a nice integration with Chrome that ‘just works’ and generates a great timeline chart for server code, similar to the one it generates for browser code. We used it to catch the major bottlenecks we had. The Chrome inspector is particularly easy to use. Profiling in C++ can be a pain, with special compilation flags, your code running way slower to the point that its behavior changes significantly in parallel tasks and the view tools sometimes getting in your way more than helping. The thing I miss the most about about profiling is the ability to filter code. I sometime want to know what is slowest just in certain points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*WGVUhP47KJdBnToN" /><figcaption>A small slice of time of our software, checking what is taking so long.</figcaption></figure><p>In this project profiling was particularly useful to locate our bottlenecks in the network communication code flow. With a ton of parallel requests and node co-routine system we wanted to find out what was locking the thread and what was interleaving in wrong places (profiling was useful to understand races, too!). It was a quick and painless procedure, with almost no setup other than a flag when starting the server. Thumbs up.</p><h3>Stress tests not only were good benchmarks, but caught new bugs and problems</h3><p>Everything was running well with a handful of clients and manual tests, or even our integration tests. Then we started to run tests with a lot of clients, and we caught tons of problems.</p><h3>Races</h3><p>We were too optimistic at first and node’s way to intercalate coroutines bit our ass pretty quickly. Hello mutex! Of course, nodejs does not have a native mutex. There are a few implementations which work for single core, but when it comes to using cluster you need a Redis lock <a href="https://redis.io/topics/distlock">https://redis.io/topics/distlock</a>.</p><p>We also had races in the clients. This was bad, and it was caused by subtle problems. The main one was that we lost data when we were updating a page, because data was arriving before we setup our events. It was detected early by our acceptance tests but it was difficult to reproduce manually or debug. Only when it happened in a real test (of course, with real people) I was so pissed that I had to find out what was going on.</p><h3>Everything works, but it’s too slow</h3><p>Our mutexes were generating long contention times, which again were not perceptible with 5 clients, but were really slow with 1000. Mutexes stayed, but we reduced the contention points to a minimum, so we can still keep the I/O bound operations parallel and other co-routines eating all the processing time we had..</p><p>Another problem we had was that the composite image generation was too slow, taking several seconds. That was fixed throwing away ImageMagick (which while excellent is so slow that I’m always replacing it with my own code) and writing our own C++ image composer, which was about 100 times faster.</p><h3>Things crash</h3><p>We had a bunch of crashes of all kinds as we increased the number of clients. From the not-worrying-at-all, like the hot-reload proxy exploding because it didn’t like to be hit with thousands of parallel requests while we were testing the stress test code; to the very worrying, like the server itself not handling something and going bonkers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TS8w0tj8sEBYSpV2" /><figcaption>Things breaking and getting fixed.</figcaption></figure><p>Our typical “fix this and see what else breaks later” worked well, thanks to a good amount of tests and our CI server running full time. We complemented the unit and acceptance tests with the stress test script. It ended up being a great tool not only to profile but to help us test things quickly. Taking a picture with 10 clients and seeing all that was going on both visually and with a small and simple report was invaluable. I expected the stress test script to lie unused most of the time and ended up having a console window dedicated to it. When the app was ready we were running stress tests all day long as part of our routine.</p><h3>Things are not always as expected and life is strange</h3><p>Here are two actual measurements.</p><blockquote>LOCAL:</blockquote><blockquote>100 nodes connected, took: 0.337s<br>100 joined room and waiting for shoot, took: 0.889s</blockquote><blockquote>REMOTE OVER 4G:</blockquote><blockquote>100 nodes connected, took: 3.652s<br>100 joined room and waiting for shoot, took: 1.371s</blockquote><p>In real life the initial connection sometimes take longer than the join; the connection does nothing, but the join is a complex operation which updates a lot of things and has locks. The timing difference, by the ways, seems to be caused by TCP and it’s delightful thousand-steps connection, plus the 4G network. Things are not always like you expect.</p><h3>What have we learned from this?</h3><p>The obvious conclusion is the reason for this post: stress testing finds bugs that we could not get in simple tests, and measures performance in real life conditions.</p><p>Multiselfie comes from <a href="https://camera360.com.br/">Camera360</a>. Both do more or less the same: take pictures at the same time with multiple cameras. Camera360 is our B2B version and is used for bullet-time pictures, and we were always talking about converting it to work in the phones of several people. We did it. They share the same basic code, but are wildly different in their synchronization algorithms and output. We had a good idea of what is possible and a good amount of code to start from, but a lot of different problems. Moving from LAN to the Internet is a wild party.</p><p>As usual, bottlenecks were sometimes exactly where we expected them to be, and sometimes in places we did not expect. Our initial development varied from “wow this is fast” to “what happened, it’s taking ages” and then back to “hey it’s faster than before”. Many times being fast meant “something is now broken”.</p><p>Despite a good architecture, things varied wildly. We never had to change our initial flow design, and the critical problem of synchronizing shoots worked well from day 1 — implemented after a lot of thinking. But as we faced real problems and the conjunction of Node, SQL, Redis, the network, bugs with conditions that were not properly checked at first, we had several waves of “it’s almost ready!” to “damn, that will take another couple of weeks”.</p><p>We started with a simple in-memory implementation, which worked well but meant that the application lost its entire state on restarts. For people who are used to several deploys a day this was unacceptable. There was very little written online about restarting node applications that had internal state — a surprise to me. PHP applications are in general “stateless” (well, saving anything in databases, but code is ran from scratch on each request), but with something like Node I see a lot of uses that require recreating states on deploys. We ended up writing it all in Redis and for a while keeping both versions, until it became a pain to support them.</p><p>Was it useful? Yes, the initial memory only version was much simpler and allowed us to focus on the actual algorithm and the problems. Moving to Redis had its challenges, especially to reduce queries. Optimizations are not always fitting to external APIs, and it took us some time to get it all right. Also, the memory implementation was synchronous, while Redis is asynchronous. This was bad at first, because we suddenly had a bunch of places that were synchronous and now were a rats nest of races. This was rather unpleasant and led to discussions on how to handle these problems. One of us wanted to follow a more JS-like approach and take coroutines as part of life and work around them or leave hard consistency off the picture. The other one, coming from a C++ background, wanted to handle things in a more traditional parallel computing pthreads-like way. We both survived, improved our UFC skills and ended up with a great compromise, with locks in a few key places and wild coroutine concurrency in other places.</p><p>We had very few problems with the client. Since our dataflow never changed, the initial implementation was kept and we had to tweak minor things and bugs. Most of the time was spent on the server, with a few optimizations that reduced traffic on the client, or handling timeouts and weird situations.</p><p>We were very worried with the uploads, but they turned out to be fine. The server could handle 1000 uploads in the time it took for clients to send them.</p><p>Testing these weird situations is hard. After a while we wrote a spreadsheet with a full analysis of all the cases, tracing situations that could go wrong combinatorially. We had 24 different scenarios, some of which had specific timings that was very difficult to reproduce manually and even more to write automated tests (how do you make one of the clients have a network disconnection in the middle of a test? Or how do you make it send a specific message at an exact moment that the server is in?). We ended up managing to reproduce a number of cases in integration tests, but a few required, ahn, creative solutions, like just yanking the computer from the network to see what actually happened.</p><p>As we mentioned before, having N clients downloading N images leads to the webserver having to distribute N² images. And N² does not scale. It’s works fine with around 50 clients, starts to get slow with 100 images and from then on it’s a hell.</p><p>We expected to get a lot of help from using a CDN for our images distribution, but… CDNs are not instantaneous. They need a few seconds to cache data. It’s not on the first request, and obviously not everybody will connect to the same CDN location. So after a lot of stressing this was the only issue we still had: we could upload 1 thousand images within a few seconds at most and not get close to overloading the server, but there was no way we could server 1 million images in a few seconds with a single server. And it would not be cheap using a cloud solution either.</p><p>How will we handle this problem? It’s a subject for the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d452597201b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/how-we-stress-tested-an-app-thousands-pictures-taken-at-the-exact-same-time-d452597201b4">How we stress tested an app thousands pictures taken at the exact same time</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multiselfie, or how we decided to do the impossible, fought Murphy and built it]]></title>
            <link>https://medium.com/corollarium/multiselfie-or-how-we-decided-to-do-the-impossible-fought-murphy-and-built-it-60d42fc4f6e3?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/60d42fc4f6e3</guid>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[photography]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Thu, 29 Nov 2018 13:38:24 GMT</pubDate>
            <atom:updated>2018-11-29T22:24:05.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZo10wE2LEgN2S1b6CbE2A.jpeg" /></figure><p><a href="https://multiselfie.com/">Multiselfie</a> is a mobile and web app to <strong>take photos with multiple devices at the exact same time</strong>. Only one person clicks and all the phones take photos together. Selfies are not so selfish now.</p><h3>How does Multiselfie work?</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGa1oRxY6SQc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGa1oRxY6SQc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGa1oRxY6SQc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d0023d7f270cc77c6e5abe5202cb2ab7/href">https://medium.com/media/d0023d7f270cc77c6e5abe5202cb2ab7/href</a></iframe><p><strong>Taking a Multiselfie is simple!</strong></p><ol><li>A <strong>single person creates</strong> a “room”, just like creating a chat room.</li><li>This person<strong> shares a link </strong>with everybody else. They only need to open the link. No downloads required!</li><li><strong>Everyone opens the link</strong> and get ready.</li><li>Only the person that created the room<strong> clicks a button to shoot</strong> the photos.</li><li>You all <strong>get the photos and share!</strong></li></ol><p>It’s a selfie with many phones. You have <strong>multiple photos of a single moment</strong>, and instead of a logistic problem you have fun taking the picture.</p><h3>Why it’s good for your event too</h3><p>In larger events we can integrate Multiselfie into other apps or sites, and give a more fine grained control to the responsible person, as well as information about the pictures and analytics. Think about a major event like a sport match or a music concert, with everyone taking pictures at the same time. That’s where we want to get.</p><h3>The origins</h3><p>The origins! Multiselfie comes as a sort of <strong>spin-off of </strong><a href="https://camera360.com.br/"><strong>Camera360</strong></a>, a product we made to take those nice bullet-time photos (you know the ones, when the camera seems to freeze like the Matrix movies).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fdi15O0y2aLA%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Ddi15O0y2aLA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fdi15O0y2aLA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/995dd4e6e1915920d2f7429d7990f791/href">https://medium.com/media/995dd4e6e1915920d2f7429d7990f791/href</a></iframe><p>We talked about how nice it would be to let people use their own phones for that. There were several technological problems to achieve it, but one day we set to do it. We had a good starting point, but we had a lot of work cut out to do.</p><p>We needed a nice new interface, a completely different user flow, we needed it to run in any sort of device, we needed it to scale. People were amazed that Camera360 could work with 80 cameras. Now we wanted 80, 800, 8000.</p><p>We had our first prototype quite quickly! It proved that it could be done. Then we had a few months of hard work, making sure it not only worked, but worked well. When you’re testing with 100 cameras at the same time, Murphy gets really creative.</p><p>Maybe we could have launched earlier, but it would have made our first users disappointed with the early problems. We have been in closed beta for the last month or two. There are few feelings as bad as showing it to your friend and… failing. Now things work well. We are ready to face the world.</p><h3>How to grow</h3><p>Although we still have a few extra features to add later, our focus now is to ensure people enjoy it and to grow.</p><p>How we are going to grow? We like this project because every time new users wants to take a picture they need to tell their friends about it! New users have to spread the word to try it.</p><p>We also made it<strong> very easy to share and take a picture</strong>. You send a link to your friends and they open it. No forced login, no multi-step procedure, no installation. If you open the link you’re using it. Only after taking the picture you’re asked to login, and it’s not required.</p><p>What do you think? And have you taken your <a href="https://multiselfie.com/">Multiselfie</a> already?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60d42fc4f6e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/multiselfie-or-how-we-decided-to-do-the-impossible-fought-murphy-and-built-it-60d42fc4f6e3">Multiselfie, or how we decided to do the impossible, fought Murphy and built it</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sharing your 360° bullet time photos easily]]></title>
            <link>https://medium.com/corollarium/sharing-your-360-bullet-time-photos-easily-12ef8cc80cec?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/12ef8cc80cec</guid>
            <category><![CDATA[photography]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[photobooth]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[360-video]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Mon, 22 Oct 2018 18:20:59 GMT</pubDate>
            <atom:updated>2018-10-22T18:20:59.488Z</atom:updated>
            <content:encoded><![CDATA[<p>Many of our customer requests for the <a href="https://camera360.com.br/">Camera360 bullet time software</a> is not actually taking pictures, but the post-shoot flow. After you take the pictures, people want to see them and share them. From our own experience and the feedback from our customers we built a nice flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbElXrP5Yr3QtBQ6GWP13A.jpeg" /><figcaption>360 degrees of good images</figcaption></figure><h3>View images right after shooting</h3><p>Once the picture is taken it’s immediately sent to the control computer, which applies image treatment (such as color correction). Usually the images are ready within 3 to 5 seconds. We immediately show them on the screen. Could not be easier.</p><h3>Operator and showcase</h3><p>Do you want to let people take their own pictures? Camera360 does not require a technical operator. Once it’s setup we provide a very simple operator interface that can run on a mobile:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9V6xHhdNcwdhlMB80efBg.png" /><figcaption>A simple interface to shoot images. You don’t even need an operator, customers can handle it themselves. Perfect for bullet-time photo booths.</figcaption></figure><p>There your users can add their name and email, and with a single click the interface starts a countdown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*H6M5i1eOFL2T_Qr0tYqr6Q.gif" /><figcaption>Countdown for our bullet-time shooting application.</figcaption></figure><p>Finally, we have a showcase mode to show images on a big screen. You can even run it on a SmartTV far away from the control computer. The images are replaced automatically as soon as a new picture is taken. You can show the last image or a pre-selected list of images. Just open it an forget it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dImJ2ABxUoVGCGI5EaVlsw.png" /><figcaption>See the 360 degree bullet time photos in real time. There’s even a QRCode to access them easilty.</figcaption></figure><p>In summary, it’s very easy to have an unattended Camera360 installation. It’s your own <a href="https://camera360.com.br/">360 degrees photobooth</a>!</p><h3>Paid pictures</h3><p>Is your business model selling pictures? Camera360 has built in support for payment integration. After the picture is taken you can use your preferred payment system and then send a simple request to Camera360 to release the picture. More than that, a status page shows you how many pictures were taken and how many were actually paid for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtRJVPP8znkSyydVshPq8w.png" /><figcaption>Reports page, with real time information on photos taken. You can control your payments too, if you are selling photos individually.</figcaption></figure><h3>Web publishing and social networks</h3><p>But what about your customers taking the pictures with them? We thought about that too. Camera360 automatically synchronizes with a website. We do it all for you, no setup, no server, no technical knowledge required. Everything is transparent and the pictures are online as soon as it’s taken (and your network connection allows, but we know about bad internet and Camera360 has a robust synchronization algorithm!).</p><p>Once the photos are on a public website your customer will get an email with the link. There are sharing buttons for all major social networks.</p><p>And if you wish to post pictures straight into your social network, we can handle that, too.</p><p>By the way, did you know you can <a href="https://corollarium.com/product/4333#kinesis-download-container"><strong>try Camera360 for free?</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12ef8cc80cec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/sharing-your-360-bullet-time-photos-easily-12ef8cc80cec">Sharing your 360° bullet time photos easily</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving our bullet time software: what’s new in Camera360 5.6]]></title>
            <link>https://medium.com/corollarium/improving-our-bullet-time-software-whats-new-in-camera360-5-6-f65be066454d?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/f65be066454d</guid>
            <category><![CDATA[marketing-technology]]></category>
            <category><![CDATA[photography]]></category>
            <category><![CDATA[360-video]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 16 Oct 2018 13:43:29 GMT</pubDate>
            <atom:updated>2018-10-16T13:43:29.131Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zQ2dJ6JRArZ-3I5L1GPmw.png" /><figcaption>Camera 360º 5.6 Version</figcaption></figure><p>We worked very hard over the last few months on a new major release of <a href="https://camera360.com.br/">Camera360</a>, and I’m proud to let you know that it’s online and available to our customers. And it’s a free update for our customers, too!</p><p>The list of changes is big, but here are the highlights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5Lv3JFjk8XN6BB-lJTgCg.jpeg" /><figcaption>Camera360 New Interface</figcaption></figure><p>We completely reviewed the interface, making it cleaner and more pleasant to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*0oXmbN0xTBdXMm0rghiijw.gif" /><figcaption>360º images with gif overlay</figcaption></figure><p>Animated overlays: you can now use GIFs as overlays.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFL89gy1IziKbnVsiZqa7Q.jpeg" /></figure><p>We improved the control settings for your camera and the video generated. We added a very simple remote interface for public control: let your customers take pictures by themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*vdubForrtAWCdclMqM9mqw.png" /><figcaption>Post processing options</figcaption></figure><p>Our post processing options are even more powerful now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQGi3MGxRHwVDF6E1Qlu4g.jpeg" /><figcaption>Raspberry Pi — Low Cost Cameras to use with Camera360</figcaption></figure><p>We improved support for Raspberry Pi, a small and inexpensive computer. This includes streaming the image in real time to the control interface, so it’s much simpler to align cameras. A Raspberry Pi with a high resolution camera should cost about US$60, making our system the most inexpensive multi-camera capture system we know of. We still support Android devices, of course! But we are very happy with the results with Raspberry Pis.</p><p>We made several internal improvements leading to better performance and quality. We updated our image processing algorithms, which are now faster and have better quality. A new color correction algorithm was added that performs really well under low lighting conditions.</p><p>Video capture. Yes, now we can capture videos from the cameras, and not only photos! It’s currently an experimental feature, only supported by Raspberry Pi, and available in the Platinum license. We are working hard on this and very pleased with the results. More to come soon!</p><p>Version 5.6 is a completely free upgrade for existing users. <a href="https://camera360.com.br/">Download Camera360 and start your bullet-time system now</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f65be066454d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/improving-our-bullet-time-software-whats-new-in-camera360-5-6-f65be066454d">Improving our bullet time software: what’s new in Camera360 5.6</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bullet time 360° Photography with Raspberry PI]]></title>
            <link>https://medium.com/corollarium/bullet-time-360-photography-with-raspberry-pi-e9021de4a2f4?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/e9021de4a2f4</guid>
            <category><![CDATA[360-photo]]></category>
            <category><![CDATA[photography]]></category>
            <category><![CDATA[cameras]]></category>
            <category><![CDATA[360-video]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <dc:creator><![CDATA[Vinícius Piva - Corollarium Technologies]]></dc:creator>
            <pubDate>Mon, 21 May 2018 20:24:12 GMT</pubDate>
            <atom:updated>2018-05-21T20:24:11.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Shooting 360º images with raspberry PI cameras.</p><p>The 360 degrees photography technique, better known as Bullet Time, became quite popular with The Matrix (1999). It consists in positioning dozens of cameras around the subject to capture pictures from various angles at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*HXCb6W5UmIfUWx-K." /><figcaption>Bullet Time effect — Movie: Matrix — Warner Bros. Pictures</figcaption></figure><p>To do this type of capture not only you need dozens of DSLR cameras, but extra equipment to synchronize them all. Unless you want to deal with dozens of SD cards you also need more equipment to transfer the images. As you can imagine, it’s not something that tends to have a low cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eqzhiG5htD4Yd5EU." /><figcaption>Photography Bullet Time with Canon cameras: <a href="https://www.youtube.com/attribution_link?a=Fh_1kfRdFLU&amp;u=/watch%3Fv%3DWDdxMBq2GW8%26feature%3Dshare">https://www.youtube.com/attribution_link?a=Fh_1kfRdFLU&amp;u=/watch%3Fv%3DWDdxMBq2GW8%26feature%3Dshare</a></figcaption></figure><p>Thinking about it, Corollarium Technologies has developed a practical and cost effective solution to capture images in 360 degrees. Initially developed for point-and-shoot cameras, the system has been improved. The current version supports Android smartphones and now also makes it possible to capture images in 360 degrees using Raspberry Pi. That makes the whole setup a fraction of the price, and with a much easier to use interface.</p><p>This increased availability of a 360 system allows its use in events, tourist sites, fashion, museums, shopping and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*_q2y-aNkTrueI-RY." /><figcaption>360º bullet time made with camera360 setup</figcaption></figure><h3>Challenges in 360º Photography</h3><p>Composing an image in 360 is not a simple task. There are also some technical challenges: even if you have a perfect mechanical rig, a perfect alignment between the images is not easy to achieve. There is also variations in color, lighting levels and more, and it demands patience and hours of painstaking corrections to achieve similar images between the camera settings.</p><p>Camera360 was designed to use from two to dozens of cameras, all without dedicated electronics. Setup is quick and simple, and the system can be controlled to shoot photos and see them afterwards from a tablet or mobile phone, making it easier to control.</p><p>The Corollarium Camera360 also corrects color and line images, and support for chroma keying, effects and instantaneous composition of the images already in the most popular formats (GIF MP4 // // JPG), all without manual intervention. The final videos are generated in seconds and available in the cloud immediately. Corollarium also can customize its product for promotional activities and events.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*WrAg_SV9wCv68k5a." /><figcaption>360º camera array with Android Smartphones</figcaption></figure><p>You can purchase licenses for the software and even buy kits ready with Raspberry Pi with Cameras + Case with delivery to anywhere in the world, through a partnership with <a href="http://getyourpi.com/products/camera-360-raspberry-pi">GetYourPi.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*woS_LVIFSjGZoAm3FvYC2A.jpeg" /><figcaption>GetYourPi Camera360 Rapsberry PI setup example</figcaption></figure><p>More information about the Camera360 available at: <a href="https://camera360.com.br./">https://camera360.com.br.</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FlV_HjmK9ylk%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DlV_HjmK9ylk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FlV_HjmK9ylk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e80f9481f6c03a11a5d412d131b6019/href">https://medium.com/media/1e80f9481f6c03a11a5d412d131b6019/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*EzSXdxY6_6wvCA8Y." /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9021de4a2f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/bullet-time-360-photography-with-raspberry-pi-e9021de4a2f4">Bullet time 360° Photography with Raspberry PI</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Programming & Music]]></title>
            <link>https://medium.com/corollarium/programming-music-bd2175580aa5?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/bd2175580aa5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 13:06:01 GMT</pubDate>
            <atom:updated>2018-02-27T13:06:01.308Z</atom:updated>
            <content:encoded><![CDATA[<p>Whenever a classical musician talks about his career, he mentions his teachers. They usually had one to three experienced musicians who taught them in such a way that it changed their playing and careers. Real mentors (in fact, to enhance my point: I started to write this a while ago, but I recently met a pianist and he told me about his mentors). Even rock stars and other non classical musicians do something similar; you often hear them saying “and when I was 12 I bought a record by SomeFamousMusician, and I played along with it until I was as good as the record.” These are two things that are really helpful, and that are rare in computer programming.</p><p>It’s interesting that other professions also have the concept of mentors. Physics is one; there’s a whole essay by <a href="https://en.wikipedia.org/wiki/Alan_Lightman"><strong>Alan Lightman</strong></a> (“Students and Teachers”, in “Dance for Two”) about it. Visual arts also have them (although not as much as before, I gather). But we don’t have that culture in computer programming; I think I only met one programmer in all my life who told me he had a mentor. All the others had learned mostly by themselves. I can’t explain why this happens: is it difficult to find those mentors? Are programmers naturally good at self-teaching? I really don’t know. And it’s a pity that it rarely happens.</p><p>It’s also rare to find someone who has taken time to <strong>read good code</strong> written by others — but not that rare. This is a trait that I almost always find in good developers, and I highly recommend doing it.</p><p>For instance, one of the best lessons in OO that I ever had was reading the code for GTK: they do OO in C, so there is no syntactic sugar to help. A lot of things that are given in C++ or Java had to be recreated in C, and understanding why and how they did it was enormously instructive to me. One of the beauties of open source is that: you can understand how they did it. It is also an important trait for good programmers, understanding other people’s code and dealing well with large projects.</p><p>So pick one of your favorite open source projects and learn a bit more about it. And find a mentor — or become one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd2175580aa5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/programming-music-bd2175580aa5">Programming &amp; Music</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</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 teach art (or at least software design)]]></title>
            <link>https://medium.com/corollarium/how-to-teach-art-or-at-least-software-design-97739b432846?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/97739b432846</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-design]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 20 Feb 2018 13:51:01 GMT</pubDate>
            <atom:updated>2018-02-20T13:51:00.919Z</atom:updated>
            <content:encoded><![CDATA[<p>There are many things that are straightforward to teach. Even some stuff that people consider “a talent”. Drawing technique, for example. You can learn how to draw: buy a couple books or go to classes to learn some theory, then fill 200 pages of drawings. Teaching art, on the other hand, is very difficult: you can draw wonderfully well, but having an idea for a good drawing and executing it well are whole different problems.</p><p>In writing this post I had to ask myself: how to teach software design? What have I learned in all these years that could be distilled into a more or less concrete form? At first I was at a loss. It’s not easy to translate it to words!</p><p>Then I started to think about what all my projects have in common. And they do have a lot in common, it turns out.</p><p>I start my designs with a simple, clean and clear spec. You can’t write software well if you don’t have a clear idea of the what it has to do, at least in its first version! Your spec is good if you can show it to somebody else and they can write the program for you just the way you imagined it. In big projects with a lot of people, detail is never too much in a spec.</p><p>Scenarios: while TDD can be tricky to do sometimes, always think about tests and scenarios before you start building. This is actually part of the first item, because if you see a problem in a certain scenario you may have to change everything. But think about the edge cases, about what happens if things go wrong. See below on tests.</p><p>At this point you can design your classes and database, if you have one. My class designs follow a very definite pattern:</p><ul><li>There are usually one or two classes to manage the software. They are responsible for initialization and for calling other classes (the main loop).</li><li>There are a few (abstract, usually) base classes; as few as possible, because it makes it much easier to understand the structure of the program. Our web applications have 4 base classes that probably encompass 90% of the code. Our sophisticated 3D engine has only 4 abstract base classes, but they give it great flexibility — the design was never modified since its inception, even though the number of features have been growing constantly and we are doing things that were not imagined at first. Even a large change made when the code was already mature (supporting multiple render backends) did not change the design of the code at all. A good design may suffer modifications over time, but the API will be constant. All (or at least most) changes will be internal.</li><li>Databases should be simple and think about future changes (because they will change!). Think a lot about the primary keys and about relationships (1:n for ever? or perhaps it can become n:m someday?). We ended up abstracting the database in our web applications. The framework does everything we need. There are no manual SELECTs or INSERTs.</li></ul><p>Have a powerful Log class. This is something I’ve written about before, in my post about the art of debugging<strong>.</strong> This is of great help: it makes me think about debugging from the start of the project. If it’s a graphic software, ways to dump screenshots and images at any point are fundamental.</p><p>Tests tests tests. If you are writing a function, write the test first or at the same time. Make sure inputs are tested for valid and invalid values. Get 100% coverage and if possible make someone else do the test, because they will see things you are too close to see now.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97739b432846" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/how-to-teach-art-or-at-least-software-design-97739b432846">How to teach art (or at least software design)</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The art of debugging]]></title>
            <link>https://medium.com/corollarium/the-art-of-debugging-5761a3eea606?source=rss----9e560158121---4</link>
            <guid isPermaLink="false">https://medium.com/p/5761a3eea606</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Bruno Barberi Gnecco]]></dc:creator>
            <pubDate>Tue, 13 Feb 2018 12:41:01 GMT</pubDate>
            <atom:updated>2018-02-13T12:41:00.996Z</atom:updated>
            <content:encoded><![CDATA[<p>Pesky bugs and how I smack them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Cme5OLPArjKctUgxCTfMLg.jpeg" /><figcaption><a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging">Rubber duck debugging</a> (source: Wikipedia)</figcaption></figure><ol><li>Code review. After writing anything I check it myself (don’t waste someone else’s eyes before you reviewed the code yourself). This catches most typos (things like = for ==, variables with typos in interpreted languages, etc). I also simulate code in my head, which makes sure simple logic errors that may have been made are caught early, before even running anything.</li><li>Static code analysis. Our code runs through all sort of code analysis, linters, etc, automatically on every commit.</li><li>Plenty of logs. I start any project by having a good Log class, with multiple log levels with filtering, information about the line and file that called the log, sometimes even automatic backtracing in cause of errors (in Python I automatically fall into the console debugging). I usually can get a pretty good idea of what went wrong just by checking these logs. Many times adding a few extra log() calls with detailed information about variables is quicker and simpler than using a debugger. And in some cases (websites, for example) setting up a debugger is not trivial, so this has to solve the problem. Also, it helps if you need to know what went wrong in production.</li><li>Tests. This is 2a), in fact, because you can only test properly if you have a test suite. I’ll write someday about how I write test suites, but the basic needs are universal: tests should be as simple as possible; should be written before or during development; should cover as much as possible of the code; should be completely automatic when viable; and should test for both the “good cases” and the “bad cases”.</li><li>Talk about it. <a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging">Rubber duck debugging</a> works. Try to explain what is going on to peers and you often will find the problem before you end your explanation.</li><li>If things are looking complicated and logs did not help enough, call that faithful debugger. These days my use of debuggers is quite simple: I often set breakpoints in the code itself (<em>debugger</em> for javascript,<em> raise(SIGINT)</em> for C/C++ and gdb), since it’s usually faster than navigating through the code in the debugger if I know where I want to stop. When the breakpoint is hit, I print all variables to check if their values are correct, and if necessary I step through a few calls.</li><li>Stack traces are your friends. In C/C++ I let the program run until it crashes, run a backtrace (<em>bt</em>) and start to move up in the call stack until I get to the culprit — usually it is pretty obvious. Python, PHP, JS, all of them have easy ways to get traces.</li><li>In JavaScript and Python you can fall into an interactive terminal when the debugger stops that is just as good as the real program: so you can pretty much type any code there, which is run instantly. Then you see immediately if it fixes the code. I’ve come to love this: interactive programming can be extremely useful (great for testing complicated selectors in javascript, for example!). gdb can do some of that, but has several limitations due to C++ being compiled. But use <a href="https://t.umblr.com/redirect?z=http%3A%2F%2Fsourceware.org%2Fgdb%2Fwiki%2FSTLSupport&amp;t=MDNmZTRjNDIyYTJhNzA4MDI1ZmIxZjdjMzhlMWIyMDJjY2MxMGE5NCw0Q2lhT3FVcw%3D%3D&amp;b=t%3ABtmxn4t1B40X8W2eJAjyuQ&amp;p=http%3A%2F%2Fblog.corollarium.com%2Fpost%2F19952779569%2Fthe-art-of-debugging&amp;m=1"><strong>STL support</strong></a> at least for decent printing of STL structures.</li><li>After the bug is fixed, make sure it becomes a test in your suite to avoid regressions.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5761a3eea606" width="1" height="1" alt=""><hr><p><a href="https://medium.com/corollarium/the-art-of-debugging-5761a3eea606">The art of debugging</a> was originally published in <a href="https://medium.com/corollarium">Corollarium</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>