<?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[Code O’Clock - Medium]]></title>
        <description><![CDATA[DaWanda Developers Blog - Medium]]></description>
        <link>https://medium.com/dawandadev?source=rss----5d2a82b49ab7---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Code O’Clock - Medium</title>
            <link>https://medium.com/dawandadev?source=rss----5d2a82b49ab7---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 06:58:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dawandadev" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Docker for Selenium test automation?]]></title>
            <link>https://medium.com/dawandadev/docker-for-selenium-test-automation-c61f1a9163a2?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/c61f1a9163a2</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[qa]]></category>
            <dc:creator><![CDATA[Chris Stefani]]></dc:creator>
            <pubDate>Mon, 08 Jan 2018 08:05:23 GMT</pubDate>
            <atom:updated>2018-01-08T08:05:22.555Z</atom:updated>
            <content:encoded><![CDATA[<h4>YES, please! #AgileTD</h4><p>At first glance, we are mainly using Ruby for programming at DaWanda. And this is true! On the other hand, we are using great languages like Go, Java, Swift, JavaScript, and others. Our test automation for the desktop apps is developed in Java for different reasons. One is just the support of the community. The other is the easy support for parallel threading.</p><p>The DaWanda QA team visited the <a href="https://agiletestingdays.com/"><strong>Agile Testing Days</strong> <strong>2017</strong></a> in Potsdam Germany and held a workshop about using Docker for test automation. I will explain the basics of dockerized test automation below, and you can find the complete presentation <a href="https://docs.google.com/presentation/d/1p61ncmJSbLD1zkFjpwz8X7lhMrZ6OxQtn7N1v0WHcGs/edit?usp=sharing">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVGp20QCnhdupyWH_ZhjCQ.jpeg" /><figcaption><a href="https://twitter.com/CStefani91/status/930771062752673792">https://twitter.com/CStefani91/status/930771062752673792</a></figcaption></figure><p><strong>But first, why should you consider (yet) another testing environment?</strong></p><p>Let’s summarize the three current ways of automation environments and their respective issues:</p><ol><li>Local execution has the problem that you cannot scale the amount of executable browsers; furthermore, only browsers supported by your operating system are available.</li><li>The other possibility is to create an environment using your own grid. You can execute tests in parallel on multiple machines, but the maintenance of the drivers and browsers will take you a lot of time and effort.</li><li>Cloud services take care of this, but they are very costly (around 3000€ per month for 25 parallel sessions) and the location of the cloud provider’s servers impacts the execution speed of your tests.</li></ol><p>We, at DaWanda, decided to use Docker for test our automations. A new technology has not only benefits, so before we look at more details, let me first list some pros and cons of this setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*d-HKujYLR5Q2QED4ybEiPw.png" /><figcaption><a href="https://www.docker.com/brand-guidelines">https://www.docker.com/brand-guidelines</a></figcaption></figure><p><strong>Pros</strong>:</p><ul><li>Efficient, lightweight, self-contained Images and Containers</li><li>Very easy to scale the number of Nodes</li><li>Local and remote execution of tests</li><li>Executable on any system where Docker is installed (<a href="https://www.docker.com/get-docker">https://www.docker.com/get-docker</a>)</li><li>No setting up and configuring development environments, just develop (no download of drivers, browsers or any other dependencies are necessary)</li><li>Selenium Hub and Node images are provided by Selenium</li></ul><p><strong>Cons</strong>:</p><ul><li>Only Firefox and Chrome browsers are currently supported</li><li>Other browsers can be added through cloud (Browserstack, Saucelabs) or grid services; it will at least save money</li></ul><p><strong>Preparation</strong></p><p>Basically, we have <strong>four components</strong>: our created automation code, the Selenium Hub, and Firefox and Chrome images. The good aspect is: <strong>We can download the images for the Hub and the Firefox and Chrome browsers directly from Selenium!</strong> We only need to take care of our own code and we can scale the amount of running containers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T0oSwAsXkRDd-F88SC3WZw.png" /><figcaption><a href="https://github.com/skarlig/ATD_local/blob/master/README.md">https://github.com/skarlig/ATD_local/blob/master/README.md</a></figcaption></figure><p>We have to create <strong>three files</strong> to dockerize an automation project: a Dockerfile, a Docker-compose file, and a local cache for our code dependencies. If not used already, we need to change the local WebDriver to a RemoteWebDriver for grid usage.</p><p>A Dockerfile is a ‘text document that contains all the commands a user could call on the command line to assemble an image.’¹ It contains all the instructions needed to build an image automatically (used by Jenkins).</p><p>A Docker-compose YAML file is a ‘tool for defining and running multi-container Docker applications.’¹ Just ‘with a single command, you create and start all the services from your configuration.’¹</p><p><strong>Just do it!</strong><br>Create our cache file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15c29cb3de9acd97954d52b5014741f3/href">https://medium.com/media/15c29cb3de9acd97954d52b5014741f3/href</a></iframe><p>In this example we are using Java. Our project depends on the <em>openjdk</em> image (version 8). This contains everything that we need, including the operating system and Java. We are defining our working directory “/app” as the root directory. The next step is to copy the important folders - like <em>gradle</em> (my software project management tool) - into this path. We also have to copy some code into the image. We only want to save/cache it’s dependencies, so we remove the compiled code (rm -rf src/). We turn this file into an image using the command docker build -f Dockerfile-base . . After creating it you should give it a useful name like qa-test-base with the command docker tag &lt;container_id&gt; qa-test-base.</p><p>The second step is our Dockerfile, which is used by CI systems like Jenkins:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15d7ed87530a5a51641abbc81a426729/href">https://medium.com/media/15d7ed87530a5a51641abbc81a426729/href</a></iframe><p>We are using our newly created cache image qa-test-base. Now we want to copy our written code into the root path. In this example, we are also creating a few environment variables to be a bit more flexible in the execution. The command at the end will start our test. That’s it for the remote execution. The remaining problem is that we don’t have any Hub or Browser setup running for executing our test on a local machine.</p><p>The third step is to create a <em>docker-compose</em> file to have an easy way of executing our tests locally:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ac9035f0d591db92e46ff1019c0ad62/href">https://medium.com/media/4ac9035f0d591db92e46ff1019c0ad62/href</a></iframe><p>I know this looks quite complicated at first glance, but let me show you why it isn’t! 😉</p><p>We are using version 2 in this example, but you can already use version 3 if you like. We need four services: one for our code (test_local), one for the hub (hub), and one each for the Firefox and Chrome browsers. Our code service (test_local) depends on the other services (depends_on). Furthermore we are setting some environment variables and mounting our local code path to get some results locally (this step is not strictly necessary). The other services are very easy to setup. We have to define the images and the version that we want to use, as well as which IP and Port should be used. That’s it! You can execute the dockerized example with docker-compose run test_local.</p><p>For more information, have a look at the finished dockerized code example here:</p><p><a href="https://github.com/skarlig/ATD_dockerized">skarlig/ATD_dockerized</a></p><p>Have a look at the official docker and selenium documentation:</p><ul><li><a href="https://docs.docker.com/"><strong>Docker documentation</strong></a></li><li><a href="https://hub.docker.com/r/selenium/"><strong>Selenium Images</strong></a></li></ul><p>Docker makes my daily life easier at DaWanda and you should give it a try. Before, I was frustrated about the maintenance part of my local grid setup. Of course I made my own experience with cloud providers. The service is just expensive and it slowed down the test execution.</p><p>¹docs.docker.com (23 Oct. 2017)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c61f1a9163a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/docker-for-selenium-test-automation-c61f1a9163a2">Docker for Selenium test automation?</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DaWanda Devs Go to Budapest ✈️ ]]></title>
            <link>https://medium.com/dawandadev/dawanda-devs-go-to-budapest-%EF%B8%8F-b02c08e66ed5?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/b02c08e66ed5</guid>
            <category><![CDATA[dawanda]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[euruko]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 14:06:03 GMT</pubDate>
            <atom:updated>2017-11-21T14:04:00.041Z</atom:updated>
            <content:encoded><![CDATA[<h4>A short recap of <a href="https://euruko2017.org/">EuRuKo 2017</a>, by <a href="https://twitter.com/zfhui">Fei</a> &amp; <a href="https://twitter.com/shushugah">Yonatan</a></h4><p>Conference days can be magical! 🦄 🌈✨ If a conference is organised well, you float from talk to talk on a fluffy pink cloud , gather new knowledge, inspiration and friends along the way. Soon, your mind starts to wander and your fingers start to itch — you cannot wait to try out the new things you’ve just learnt. At the same time, your heart starts to swell. You realise that you are part of a fantastic community, and all you want to do is to give back as much as you can.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sgMdO8qxNm3SajUIrkdyWQ.png" /><figcaption><em>📷 </em><a href="https://twitter.com/amrAbdelwahab"><em>Amr Abdelwahab</em></a><em> (</em><a href="https://twitter.com/amrAbdelwahab/status/914181672781918208"><em>Source</em></a><em>)</em></figcaption></figure><p>This year’s European Ruby <em>K</em>onference took place in the historic city of Budapest, Hungary (the first one took place 14 years ago in Karlsruhe, Germany, hence the “Conference”.gsub!(‘C’, ‘K’)). Around 700 people attended this year’s single tracked conference, making it one of the largest EuRuKo’s thus far!</p><p>Several of us from DaWanda rented a beautiful old Budapesti flat, close to the conference venue, and spent three days attending talks by a very diverse speaker lineup, tasting Hungarian food and strolling (at some point, biking 🚲) through the historic district.</p><p>The Ruby community in general is a very inclusive community, with emphasis on diversity and developer happiness. This was reflected in the great mix of community centric talks (empathy, mental health, care for juniors) and more technical talks (algorithm <a href="https://speakerdeck.com/sebasoga/the-overnight-failure-2">disaster story</a> 💥, <a href="https://speakerdeck.com/nettofarah/rescuing-legacy-codebases-with-graphql-1">GraphQ</a>L, <a href="https://twitter.com/ghammadi/status/913695201100693504">Ruby 3.0</a>).</p><p>We each <strong>highlighted</strong> a couple of our favourite talks:</p><p><a href="https://medium.com/u/f0aabaa58855"><strong>Yonatan</strong></a><strong>: </strong><em>My favourite technical talk by </em><a href="https://euruko2017.org/speakers/#katarzyna"><em>Katarzyna Turbiasz-Bugała</em></a><em>, was about relevant search algorithms and internationalisation. Slides can be found </em><a href="https://euruko2017.org/downloads/slides/search_engine.pdf"><em>here</em></a><em>. </em><a href="https://euruko2017.org/speakers/#sasha"><em>Erik Sasha Romijn</em></a><em> talked about empathy for non technical users, as well as within developer community. Giving empathy alone is not enough, it also needs to be received for it be meaningful.</em></p><p><a href="https://medium.com/u/3a8d2d80ab57"><strong>Zhuo-Fei</strong></a><strong>: </strong><em>I enjoyed </em><a href="https://euruko2017.org/speakers/#headius"><em>Charles Nutter</em></a><em>’s JRuby talk a lot. I never tried JRuby myself and was initially not very excited about the topic. However, Nutter is a great storyteller. He started with a very light and fun introduction to JRuby’s history, and moved on to an in-depth technical update about the upcoming plans, which was very interesting. The talk by </em><a href="https://twitter.com/nettofarah"><em>Netto Farah</em></a><em> about </em><a href="https://speakerdeck.com/nettofarah/rescuing-legacy-codebases-with-graphql-1"><em>GraphQL</em></a><em> made my eyes shine. Mainly because one of my 1st project at DaWanda was about building a prototype with GraphQL. Farah’s talk was very beginner’s friendly, but he also talked about problems and insights of GraphQL on production.</em></p><p>Besides getting inspired by the great lineup of talks, we mostly enjoyed the time we were able to spent with each other — bonding, meeting former colleagues and making new friends.</p><p>DaWanda’s developers are very active in Berlin’s lovely Ruby and tech community — many of us teach at <a href="http://railsgirlsberlin.de/">Rails Girls Berlin workshops</a>, we host the <a href="http://www.rug-b.de/">RUG::B</a> regularly and DaWanda has been a sponsor of Rails Girls Berlin, <a href="https://railsgirlssummerofcode.org/">Rails Girls Summer of Code</a>, <a href="https://www.girls-day.de/">Girls Day</a> and <a href="https://alterconf.com/">AlterConf</a>. That is why when two of our devs- Alex and Yonatan decided to pitch Berlin for hosting the next EuRuKo, we thought that it’s a great idea and were definitely up for the challenge and opportunity.</p><p>But we are very happy for our friends in Vienna, who in the end won the pitch, and we are looking forward to see everyone again in a year! 💎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6HYDt40ZQN4Qfz90IxDWuQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cJGwaHKbgKix-5wQVj1Mig.jpeg" /><figcaption>DaWanda devs on tour. 📷 by <a href="https://twitter.com/zfhui">Fei</a> (left) and <a href="https://twitter.com/fanaugen">Alex</a> (right)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b02c08e66ed5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/dawanda-devs-go-to-budapest-%EF%B8%8F-b02c08e66ed5">DaWanda Devs Go to Budapest ✈️ 🇭🇺🚆</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Canvas-based blur detection with JavaScript]]></title>
            <link>https://medium.com/dawandadev/canvas-based-blur-detection-with-javascript-8d9dc25cb7d5?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/8d9dc25cb7d5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[archived]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 17:03:34 GMT</pubDate>
            <atom:updated>2017-10-26T17:04:21.700Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>By </strong><a href="https://github.com/timotgl"><strong>Timo</strong></a></h4><p><a href="https://github.com/timotgl/inspector-bokeh">Inspector Bokeh</a> is an experimental JavaScript library to measure blur in images, created during the DaWandathon 2014. This post illustrates the chosen algorithm, based on a paper by <a href="http://stefan.winklerbros.net/Publications/icip2002.pdf">Marziliano et al.</a>, and expands on some image processing basics.</p><h3>Motivation</h3><p>Shop owners on DaWanda’s marketplace upload around 40,000 product images of varying quality every day, ranging from snapshots taken with camera phones to professionally edited, studio-quality pictures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*hM1ckHEudtrlLAwK.jpg" /><figcaption>banker’s lamp by Palazzo Int</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*d9wfemcdDMpcoPfW.jpg" /></figure><p>Apart from requiring certain file formats and dimensions, we currently have no means of assuring the quality of these images. Some of our listed products are manually curated in certain sections of the website, but it wouldn’t be possible for us to classify every uploaded image this way.</p><p>The goal of this project was to experiment with <em>automated</em> quality checks in the browser. This could provide feedback to users and potentially prompt them to upload images of higher quality.</p><h3>‘Why is this image bad?’</h3><p>Initial research was conducted to answer this question by clustering images based on different types of degradations (I basically sat around for a day and bothered our backend with countless queries, looking for the worst images I could find).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*8E8xOIn9jxZ_idxU.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*MsHt9IkrTY2dI3uV.jpg" /></figure><p>Some quality problems are fairly easy to detect and solve (e.g. over- or underexposure, low contrast), while others would require complex analysis (e.g. cut off edges of objects, hard-to-read text on images). By far the most frequent cause was <strong>blur</strong>, so I focused on measuring this particular effect.</p><h3>Measuring blur</h3><p>There are several distinct types of blur, but for the sake of simplification I was looking for a general algorithm which only processes one given image. The orginal, unblurred version is assumed to not be available (no-reference blur detection). Researching the state of science on this topic, I compiled this chronologically sorted overview of papers:</p><p>Given the limited amount of time and working knowledge of statistical methods, I chose to implement the algorithm presented in the first paper from 2002 <a href="http://stefan.winklerbros.net/Publications/icip2002.pdf">Marziliano et al.</a>. It is relatively simple and based on measuring the width of vertical edges. Given a high enough contrast, it can be observed that edges get smoothened out and appear wider than in the original, if blur occurs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/0*VzdnMRPNZ4csNnQg.png" /></figure><h3>Detecting vertical edges</h3><p>As a preparation, the image is converted to greyscale. We only care about the overall contrast in light intensity, not about edges of a particular color. The main work is then done by a <a href="https://www.html5rocks.com/en/tutorials/canvas/imagefilters/#toc-convolution">convolution filter</a>. This algorithm examines the surrounding pixels of each individual pixel and calculates a new value with the weighted sum of its neighbors. Different <a href="https://en.wikipedia.org/wiki/Kernel_%28image_processing%29">kernels/matrices</a> produce different results such as sharpening, blurring, and edge detection. The following 3×3 kernel is also called <a href="https://en.wikipedia.org/wiki/Sobel_operator">sobel operator</a> and detects only vertical edges:</p><p>For each pixel C, we look at the surrounding pixels px1 to px8:</p><pre>px1 px2 px3 px4 C px5 px6 px7 px8</pre><p>The intensity values for all these pixels are multiplied with their respective weights and added up. This results in a new value for the center pixel C. To demonstrate this, assume the following actual values of a center pixel (87) and its eight neighbours in a greyscale image:</p><pre>13 120 111 46 87 104 9 114 5</pre><p>Now we plug the numbers into the sobel operator:</p><pre>(px1 * -1) + (px2 * 0) + (px3 * 1) + (px4 * -2) + (C * 0) + (px5 * 2) + (px6 * -1) + (px7 * 0) + (px8 * 1)</pre><p>After removing the zeros and filling in the actual pixel values, we get:</p><pre>-13 + 111 - 92 + 208 - 9 + 5 = 210</pre><p>The sobel operator turned the original center pixel with value 87 into 210.</p><p>The end result of edge detection, when it is done in <em>both horizontal and vertical</em> direction, combined with smoothing, is an image like the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*_fL3sX4VdEl_0dxO.jpg" /></figure><h3>Measuring the width of vertical edges</h3><p>The edges we detected are evident to a human seeing the greyscale image, but we still need to make them ‘machine visible’ — i.e. find out exactly where edges begin and end. <a href="http://stefan.winklerbros.net/Publications/icip2002.pdf">Marziliano et al.</a> used local minima and maxima to determine this, but didn’t fully reveal their process to get them, at least to my best knowledge and understanding. So I chose simpler criteria:</p><ol><li>an edge <strong>begins</strong> when the intensity value is anything greater than zero (a black pixel, no edge found in the original image).</li><li>Given that we’re processing the pixels in a row from left to right, the edge <strong>continues</strong> as long as the intensity values keep increasing.</li><li>The edge <strong>ends</strong> as soon as the subsequent value decreases.</li></ol><p>To not count edges caused by noise in the original image, we discard intensities below a certain threshold. Usually the clearly visible edges in an image have enough contrast around them to end up as 100% white pixels after edge detection.</p><h3>Core algorithm in JavaScript</h3><p>// For each row of pixels for (y = 0; y &lt; height; y += 1) { // Reset edge marker edgeStart = -1; // For each pixel in the current row of pixels for (x = 0; x &lt; width; x += 1) { // Intensity value of current center pixel value = pixels[y][x]; // Edge is still open if (edgeStart &gt;= 0 &amp;&amp; x &gt; edgeStart) { // Intensity value of previous pixel oldValue = pixels[y][x - 1]; // Intensity is not increasing anymore, the edge ended if (value &lt; oldValue) { // Only count edges above a certain intensity if (oldValue &gt;= edgeIntensThresh) { // Calculate edge width edgeWidth = x - edgeStart - 1; // Count total number of detected edges numEdges += 1; // Add to sum of all edge widths sumEdgeWidths += edgeWidth; } // Reset edge marker edgeStart = -1; } } // Beginning of a new edge detected if (value == 0) { // Remember where the edge started edgeStart = x; } } }</p><p>The final blur score is the average width of a vertical edge, in relation to the width of the image:</p><p>avgEdgeWidth = sumEdgeWidths / numEdges; blurScore = avgEdgeWidth / width * 100;</p><p><strong>A high blur score suggest a high amount of blur in the given image</strong>.</p><h3>Inspector Bokeh at work</h3><p>Running measure_blur.js as a Node.js module on an image and its blurred versions gives the following output:</p><ol><li>Original image (378 × 528 pixels)</li><li>Gaussian blur with radius of 2 pixels applied</li><li>Gaussian blur with radius of 8 pixels applied</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*B4u-AABW6KcBbF9-.jpg" /></figure><h3>Conclusion</h3><p>The algorithm still needs a lot of fine tuning and is far from anything production-ready. The major problem is that noise/grain is wrongly detected as edges. To ease this, the current implementation <a href="https://github.com/timotgl/inspector-bokeh/blob/master/measure_blur.js#L10">applies a low-radius gaussian blur on input images of lower resolution</a>. Despite these limitations, <a href="https://github.com/timotgl/inspector-bokeh">Inspector Bokeh</a> can be used to automatically detect extreme cases of blurred images when a threshold for the resulting blur score is carefully chosen.</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/06/05/blur-detection-javascript/"><em>https://www.codeoclock.com/2015/06/05/blur-detection-javascript/</em></a><em> on June 5, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9dc25cb7d5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/canvas-based-blur-detection-with-javascript-8d9dc25cb7d5">Canvas-based blur detection with JavaScript</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Responsive ratio keeping box]]></title>
            <link>https://medium.com/dawandadev/responsive-ratio-keeping-box-964341e71816?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/964341e71816</guid>
            <category><![CDATA[archived]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:56:46 GMT</pubDate>
            <atom:updated>2017-10-26T16:58:01.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*EVQ2WUmLhAIO1ln0.jpg" /></figure><h4><strong>By </strong><a href="https://github.com/Lelith"><strong>Kathrin</strong></a></h4><p>How to create CSS only responsive divs that keep their ratio?</p><p>Discussion Sometimes you would like to include a third party widget like a video into your page. Usually iframes are used for including such things, but iframes are a technique back from the old days and have a fixed width and height — thus not allowing them to react in a responsive way.</p><p>Most YouTube videos have a ratio of 16:9. If you change your device width you have to calculate a new height for the box. You can do that with JavaScript, but there is also a flexible CSS-only solution, which we will show you here.</p><h3>Groundwork</h3><p>First we need to know some mathematical basics: how you can calculate the percentage ratio height to width of a box. If the percentage height of the box is relative to its width, the box will keep its ratio on all devices.</p><p>The mathematical formula to calculate the percentage from ratio a:b is: &gt; (b ÷ a) * 100</p><p>For example, given the ratio 16:9, the calculation is &gt; (9 ÷ 16)* 100 = 56.25%</p><p>How does calculating this help us? Here comes the magic of CSS. If you have a div or any other box element with a given width and you use percentage value for the padding of this box, the padding will be relative to the width of the box. Therefore, if your box is 500px wide, 56.25% would be 281px ( or 282px — depends on the browser) high.</p><p>This still works when you have a percentage width value on your box, because this width will be relative to the surroundings. If, for example, your box has a width of 100%, the padding will be relative to whatever 100% width of the box means.</p><h3>Tying it together</h3><p>How does this knowledge fix our initial problem? When you add a large amount of padding-top to a box, the content will be simply pushed down. Therefore, we need to wrap things up a little bit..</p><p>Here’s the markup you’ll need for your responsive box:</p><p>&lt;div class=&quot;ratio-box ratio-16-9&quot;&gt; &lt;iframe class=&quot;ratio-content&quot; width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/5lH8X39iF8w&quot; frameborder=&quot;0&quot; allowfullscreen&gt; &lt;/iframe&gt; &lt;/div&gt;</p><p>Now you have a ratio-box wrapper around the ratio-box content</p><p>Now let’s add some CSS to it:</p><p>.ratio-box { position: relative; width: 100%; } .ratio-16-9:before { content: &quot; &quot;; display:block; padding-top: 56.25% } .ratio-box .ratio-content { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }</p><h3>Getting more advanced</h3><p>This is already working very well, but how about writing a SASS mixin which allows you to call this every time you need a new ratio?</p><p>@mixin ratio-box($a, $b) { &amp;:before { content: &quot; &quot;; display:block; padding-top: percentage($b / $a); } }</p><p>With this mixin you can now create all kind of ratio-classes!</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/05/05/ratio-boxes/"><em>https://www.codeoclock.com/2015/05/05/ratio-boxes/</em></a><em> on May 5, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=964341e71816" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/responsive-ratio-keeping-box-964341e71816">Responsive ratio keeping box</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RubyConfLT]]></title>
            <link>https://medium.com/dawandadev/rubyconflt-475ace8d8a75?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/475ace8d8a75</guid>
            <category><![CDATA[archived]]></category>
            <category><![CDATA[conference]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:55:15 GMT</pubDate>
            <atom:updated>2017-10-26T17:00:22.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*9baPKLd9Dk5buA5m.png" /></figure><h4><strong>By </strong><a href="https://github.com/tadassce"><strong>Tadas</strong></a></h4><p>This year we proudly sponsored <a href="http://rubyconf.lt/">RubyConfLT</a>. It took place in Vilnius and a bunch of us went there. We got to meet plenty of great local and visiting people, even some friends from Berlin. It was a one day conference, not super big, but great atmosphere and we’re very happy that we went there.</p><p>The conference was a nice mixture of non-technical, but inspirational, and quite technical talks. It started with motivational drinking-heavy open source talk and finished with a very technical presentation about the <a href="https://github.com/plexus/yaks">Yaks</a> library for building hypermedia APIs.</p><p>I loved the sweets and the snacks.</p><p>I really enjoyed this trip, it also was a new destination for almost all of us. Beautiful city and perfect venue. Inspiring talks from great speakers outreached my expectations from a rather small conference like RubyConf Lithuania.</p><p>The conference was very enjoyable, and I especially liked the good mixture between motivational talks, presentation of Ruby projects (<a href="https://github.com/shoes/shoes4">Shoes 4</a>, <a href="https://github.com/apotonick/trailblazer">Trailblazer</a>, <a href="https://github.com/plexus/yaks">Yaks</a>…) and more general programming talks. The atmosphere was very friendly and we got the opportunity to get to know a lot of nice people. Plus, Vilnius was a positive surprise, I should really go back with some more time!</p><p>RubyConfLT was a really interesting and also entertaining conference. The talks have been very inspiring, especially the talks that went beyond rails.</p><p>Some moments from there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*WCvVHOLpDYyGC14n.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*XCYhj_j5ihSgsN9W.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ysm-_CQZwLWGT3K1.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*r-FTQyMXrfwHkMa6.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Twnlj9DC2mgVmG8P.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ouxgA7kXUFDE9REV.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*ZrlshrELdgdBS5G5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*eQSJ2UlE3UiNtHbr.png" /></figure><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/04/02/rubyconflt/"><em>https://www.codeoclock.com/2015/04/02/rubyconflt/</em></a><em> on April 2, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=475ace8d8a75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/rubyconflt-475ace8d8a75">RubyConfLT</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting the Rails Girls Summer of Code Kick Off Party]]></title>
            <link>https://medium.com/dawandadev/hosting-the-rails-girls-summer-of-code-kick-off-party-7b6b8894e3d6?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/7b6b8894e3d6</guid>
            <category><![CDATA[women-in-tech]]></category>
            <category><![CDATA[archived]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:50:41 GMT</pubDate>
            <atom:updated>2017-10-27T21:42:35.554Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>By </strong><a href="https://github.com/lauralindal"><strong>Laura</strong></a></h4><p>The relationship between DaWanda and Rails Girls Berlin is a special one — we have been a longtime regular sponsor of the workshops in Berlin, many of us are involved in either organising or coaching at the events, and we’re supporting the international Rails Girls Summer of Code for the third time this year.</p><p>Don’t have any idea what <a href="http://www.railsgirlsberlin.de/">Rails Girls</a> is? Well, it’s a movement that started 2012 in Finland and offers free coding workshops for women. Within 1.5 days, they get an introduction to web development with Ruby on Rails, and especially in Berlin, many keep on learning afterwards. There are a bunch of self-organized learning groups that have already managed to set up amazing projects, such as <a href="http://www.speakerinnen.org/">Speakerinnen</a>.</p><p>The <a href="http://railsgirlssummerofcode.org/">Rails Girls Summer of Code</a> then aims to get more women involved in open source projects. It’s a three-month long scholarship program in which teams of two women contribute to an open source project with the help of coaches, mentors and companies. This year, 16 teams could be funded all over the world and DaWanda was happy to host the Kick off Party in Berlin on July 3rd.</p><p>We decided to offer, next to delicious food and drinks, some fun activities. So in case you ever host a tech-related party yourself, feel free to be inspired. Also, feel free to improve ;)</p><h3>Tech Trivia Pub Quiz</h3><p>Know any weird facts about technology, like what half a byte is called? Or who coined the term <em>bug</em>? We collected 13 questions, some of them from our own memory, some from the depths of the Internet. The party people got into teams and had 15 minutes to find solutions — again, either in their own mind or via their favorite search engine of choice. While a lot of fun for the teams, we also enjoyed evaluating the answers, as creativity was apparently key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*WGrSsHUv2WtK1dbm.png" /><figcaption>Picture Courtesy of Anika Lindtner</figcaption></figure><h3>Bug Fixing in Real Life</h3><p>The winning team was then invited to fix a major bug that had been hanging around in the DaWanda office for some time. Or rather: a piñata in the shape of a bug. Equipped with a computer keyboard, team <em>High Five</em> smashed the bug into a million candy pieces! Very metaphorical, and very yummy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*Dtvt9Ejzd4jFM0P1.jpg" /></figure><h3>Crafting Computer Science Unplugged</h3><p>For the crafty people, we set up a DIY table to combine some <a href="http://csunplugged.org/activities/">Computer Science Unplugged</a> with creative tinkering. The idea was to make cards with which one can understand as well as explain the binary number system better — as this is what computers work with, in the end. To be honest, there wasn’t really much time for crafting in between the socializing, trivia quizzing, barbecuing and bug hunting. But maybe we’ll find another opportunity for this activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/0*NSDGK-75kDvyq-FI.png" /></figure><h3>Wrap up</h3><p>We’d like to thank all party people for making this such a memorable event. But most important of all, we wish all the Summer of Code teams many new learnings, fun with code, successful bug hunting and a beautiful summer! ❤</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/07/15/rgsoc_party/"><em>https://www.codeoclock.com/2015/07/15/rgsoc_party/</em></a><em> on July 15, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b6b8894e3d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/hosting-the-rails-girls-summer-of-code-kick-off-party-7b6b8894e3d6">Hosting the Rails Girls Summer of Code Kick Off Party</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The power of prototyping]]></title>
            <link>https://medium.com/dawandadev/the-power-of-prototyping-796d0dcbff0?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/796d0dcbff0</guid>
            <category><![CDATA[archived]]></category>
            <category><![CDATA[ux]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:46:14 GMT</pubDate>
            <atom:updated>2017-10-26T16:51:13.535Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>By </strong><a href="https://github.com/frappacanu"><strong>Francesca</strong></a></h4><p>Before a feature goes into development, it is good practice to check if the overall concept and design really make sense for the user. It’s the time to build an interactive prototype and go into user testing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*t2gpeZM18RUJ67Is.jpg" /></figure><p>Prototypes can become the biggest ally of UX designers, and of the whole team. They can lead to the (re)shaping of a product or feature in few iterations and save us time and money. But if we invest too much time and effort to make them look and work like they were ready for production, they can actually turn into blockers.</p><p>Also, if we fall in love with our design, we risk trying to stick to it or even getting stuck. For example, we can loose the necessary flexibility one needs to adjust after user feedback. That’s why the prototype must be stripped down to the minimum, but it still has to contain all the necessary functionalities and needed design basics to be understandable for the user.</p><h3>Ideation and creation</h3><p>First of all it is possible to create a user story mapping, which helps to design the flow that the user will follow and to map the various phases of the interaction. This can be aided by sketching a storyboard, something close to a comic that illustrates the various parts of the flow. This is a very creative part of the process and it is awesome!</p><p>The second step might be the creation of a paper prototype, with sketches and several layers of paper to emulate the interface. It’s very crafty and definitely fun!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*ZjJv4diik9u2uzHM.jpg" /></figure><p>The final step is the creation of the digital prototype. This will either be reviewed internally for feedback or go into user testing, another really exciting phase cause we can foresee how the user will interact with our product and collect more information about his needs, goals and pain points. Probably the best part!</p><p>There are several pieces of software that help to create interactive prototypes, for instance <a href="http://www.axure.com/">Axure</a>, <a href="http://www.invisionapp.com/">Invision</a>, <a href="http://tumult.com/hype/">Hype</a>, <a href="https://www.uxpin.com/">UXPin</a>, but my personal favorites are good old HTML, CSS and Javascript. In this way you can include the prototype of your new feature in the environment of your website or web application and especially you can see how it works together with the other interactions already available on the site. Also if you have a styleguide or a pattern library, it is easy to copy and paste code snippets to the html to give it the look and feel of your website or app.</p><h3>Design and usability</h3><p>In my experience, even a little design tweak can improve the interface’s usability. For example, in a prototype we worked on in the past, we chose a medium grey for headlines. They were tapable, but during the user testing nobody noticed that. They were perceiving the grey as inactive! It was enough to modify the CSS right away, to see the next users <em>all</em> tap on them. The prototype should not be too detailed, but the usability should be taken into account.</p><h3>Conclusion</h3><p>Prototypes are shortcuts to user feedback. Definitely a necessary asset if you want to create a product that fulfils the user needs. Go build some!</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/10/05/power-of-prototyping/"><em>https://www.codeoclock.com/2015/10/05/power-of-prototyping/</em></a><em> on October 5, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=796d0dcbff0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/the-power-of-prototyping-796d0dcbff0">The power of prototyping</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails AutoLoading Magic Gone Wrong!]]></title>
            <link>https://medium.com/dawandadev/rails-autoloading-magic-gone-wrong-cf53e2aec097?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/cf53e2aec097</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Yonatan Miller]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:45:08 GMT</pubDate>
            <atom:updated>2017-10-26T17:04:41.617Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*MINb-ejYCab5RKkhqAplDA.gif" /><figcaption>Algorithms are Magical!</figcaption></figure><p>In short, use explicit module namespacing or avoid complex namespacing as often as possible when inheriting classes.</p><p>Class and Module constants depends on order of <a href="http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths">autoload-paths</a> lookup (a Ruby on Rails feature), more on that below. Because of this, class discoverability can vary depending on the name and location of an inheriting class. When multiple classes share the same name, as is the case in our Rails app, this subtlety can impact implicit class inheritance.</p><p>Ruby on Rails has <a href="http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#resolution-algorithm-for-relative-constants">two main algorithms</a> for constant look up in its autoload_paths (by default all subdirectories of app in the application and engines present at boot time, and app/*/concern).</p><p>The values of autoload_paths can be inspected with following command:</p><pre>$ bin/rails r &#39;puts ActiveSupport::Dependencies.autoload_paths&#39;<br>.../app/assets<br>.../app/controllers<br>.../app/helpers<br>.../app/mailers<br>.../app/models<br>.../app/resources # This is loaded before models/ <br>.../app/controllers/concerns<br>.../app/models/concerns<br>.../test/mailers/previews</pre><p>In my attempt to clean up some of our code, I unwittingly created a difficult bug to spot. Here is some example code to see the issue in action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85a8472ba207cb1009fe586f2040c8c2/href">https://medium.com/media/85a8472ba207cb1009fe586f2040c8c2/href</a></iframe><p>Hopefully Ruby on Rails autoloading is clearer now. You can always read more and improve Ruby on Rails documentation <a href="http://guides.rubyonrails.org/autoloading_and_reloading_constants.html">here</a>. If you have any questions or found errors, please comment here or contact me on t<a href="http://twitter.com/shushugah">witter</a>!</p><p>In Rails 5, autoloading is disabled by <a href="http://blog.bigbinary.com/2016/08/29/rails-5-disables-autoloading-after-booting-the-app-in-production.html">default</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf53e2aec097" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/rails-autoloading-magic-gone-wrong-cf53e2aec097">Rails AutoLoading Magic Gone Wrong!</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bundler Source Order (Yes, It’s Important)]]></title>
            <link>https://medium.com/dawandadev/bundler-source-order-yes-its-important-40498b5254d9?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/40498b5254d9</guid>
            <category><![CDATA[archived]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:41:16 GMT</pubDate>
            <atom:updated>2017-10-26T16:41:16.201Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>By </strong><a href="https://www.amazon.com/Paolo-Perrotta/e/B002Z2QZB4/ref=dp_byline_cont_book_1"><strong>Paolo</strong></a></h4><p>If you ever use gems from your own private repository, then there is something important that you should know about <a href="https://bundler.io/">Bundler</a>. To explain what that is, let me introduce Tadas. He’s the founder of a startup called Fishoo, that sells fish-shaped iPhone cases (a niche but lucrative market):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*yjtcRlG9c9T6TLYq.jpg" /></figure><p>Here is the Gemfile of the main Fishoo application:<br>source &quot;https://fishoo_gem_server&quot; <br> source &quot;https://rubygems.org&quot; <br> gem &#39;rails&#39;, &#39;4.2.0&#39; <br> gem &#39;redis&#39;, &#39;~&gt; 2.2.0&#39; <br> gem &#39;resque&#39;, &#39;1.16.1&#39; <br> gem &#39;fishoo-payments&#39;, &#39;~&gt; 2.10&#39; <br> # ...</p><p>The first two lines are telling Bundler to install gems from two different places. Some gems, such as rails and redis, are on the public <a href="https://rubygems.org/">RubyGems</a> repository. Others, such as fishoo-payments, are private gems on Fishoo’s internal repository. Bundler will check both sources when installing gems.</p><p>And here is the question: in which order does Bundler check the sources? The order is actually important, as we’ll find out when a new, shady character enters our story: <em>Sadat</em>, Tadas’s evil twin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*Sv1nsjQeFem5O-2v.jpg" /></figure><p>Sadat has been working on Fishoo in the past, and he still has a clone of the fishoo-payments source code on his computer. So he comes up with an evil plan: he modifies his copy of fishoo-payments to divert all payments from the site to his own Bitcoin account. Then he deploys fishoo-payments as a public gem on RubyGems.</p><p>That night, Tadas (the Good twin) sets up a new Fishoo server on Amazon EC2, and uses Bundler to install all the required gems — but Bundler finds a gem named fishoo-payments on the public RubyGems server, and installs that tampered gem instead of the gem from Fishoo’s server. Sadat (the Evil twin) can now sit back and sip his daiquiri as he watches money flow from Fishoo to his untraceable Bitcoin account!</p><p>If you also have a private gem server in your company, then the order of Bundler sources can be a real security threat. Here are three ways that you can solve the problem.</p><p><strong>Use the safer, block-based form of Bundler’s </strong><strong>source method</strong>. For example, you can write this:</p><p>source &quot;https://rubygems.org&quot; <br> gem &#39;rails&#39;, &#39;4.2.0&#39; <br> gem &#39;redis&#39;, &#39;~&gt; 2.2.0&#39; <br> gem &#39;resque&#39;, &#39;1.16.1&#39; <br> # (other public gems)</p><p>source &quot;https://fishoo_gem_server&quot; do <br> gem &#39;fishoo-payments&#39;, &#39;~&gt; 2.10&#39; # (other private gems) <br>end</p><p>The Gemfile above tells Bundler that RubyGems is the default source for gems, but a few gems are special, and they should be downloaded from a different source.</p><p>Whenever you can, it’s a good idea to use the technique above. Unfortunately, sometimes you can’t. One problem we had at DaWanda is that some of our projects are themselves gems, and their dependencies are listed in the gemspec file - which doesn’t support multiple sources at all (for reasons that depend on the way RubyGems works).</p><p>A second way to solve the problem is to <strong>sign your gems</strong>. This is <a href="http://guides.rubygems.org/security/">extra work</a>, but probably worth it if you have a serious project.</p><p>A third, cheap way to solve the problem is to <strong>know the order in which Bundler loads gems from sources</strong>. That order is, perhaps surprisingly, bottom-to-top (at least since <a href="https://bundler.io/v1.7/whats_new.html">Bundler 1.7</a>). Respect this order, and you will always know which source each gem is loaded from. For example, Tadas can force Bundler to check the Fishoo gem server before RubyGems by simply switching the first two lines in the Gemfile:</p><p>source &quot;https://rubygems.org&quot; # this is checked second <br> source &quot;https://fishoo_gem_server&quot; # this is checked first <br> gem &#39;rails&#39;, &#39;4.2.0&#39; <br> gem &#39;redis&#39;, &#39;~&gt; 2.2.0&#39; <br> gem &#39;resque&#39;, &#39;1.16.1&#39; <br> gem &#39;fishoo-payments&#39;, &#39;~&gt; 2.10&#39; # ...</p><p>If you have multiple sources in your Gemfile, you’re likely following this order already: first, you specify the public gem server - then, any private ones. If you’re doing this consistently, then you’re safe.</p><p>Today, my team spent some time to retrieve this information. In the end, we had to <a href="https://github.com/bundler/bundler/blob/master/spec/install/gems/sources_spec.rb#L30">dig into Bundler’s tests</a>. We hope that this blog post will make it easier for you to spoil Sadat’s despicable plots. Oh, and if you want to know more about the priority of gem sources, take a minute to read <a href="https://bundler.io/v1.9/man/gemfile.5.html#SOURCE-PRIORITY">this</a> as well.</p><p>Happy fish-phoning!</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2015/11/23/bundler-sources/"><em>https://www.codeoclock.com/2015/11/23/bundler-sources/</em></a><em> on November 23, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40498b5254d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/bundler-source-order-yes-its-important-40498b5254d9">Bundler Source Order (Yes, It’s Important)</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1 = 0]]></title>
            <link>https://medium.com/dawandadev/1-0-2bdfc25ab237?source=rss----5d2a82b49ab7---4</link>
            <guid isPermaLink="false">https://medium.com/p/2bdfc25ab237</guid>
            <category><![CDATA[archived]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[DaWanda Dev]]></dc:creator>
            <pubDate>Thu, 26 Oct 2017 16:28:51 GMT</pubDate>
            <atom:updated>2017-10-26T16:29:26.904Z</atom:updated>
            <content:encoded><![CDATA[<h4>By <a href="https://github.com/cmw">Chris Weis</a></h4><p>Recently, our CI system produced this cryptic message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/0*jNsCHIsXLiepJ6vH.png" /></figure><p>Couldn&#39;t find Deployment with &#39;id&#39;=1 [WHERE 1=0]</p><p>What was that supposed to mean? Especially frustrating as the system Worked On My Machine™.</p><p>I was puzzled. What could ever prompt ActiveRecord to add WHERE 1=0 to a query? I discussed the incident with my colleagues, and we theorized that something may be using that WHERE clause as a resource-efficient way to find whether a table exists. That wasn’t it at all and it wouldn’t have made sense at this particular place in the code anyway, but it put me on the right track: What does ActiveRecord do with my query anyway?</p><h3>ActiveRecord::QueryMagic</h3><p>You might already know these examples of how where() conditions get translated into SQL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/0*ZmXODjTvemwpXXX6.png" /></figure><p>The examples above are quite common to most Ruby on Rails users, but even then, they already hide a lot of magic. Depending on what you pass as a hash value to where, it picks ` = , IN () or IS` as an operation.</p><p>There is one more rare edge case: passing an array to where that turns out to be empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*_SMHaMIast5VbeNa.png" /></figure><p>Looking at the examples above, we might expect it to be turned into WHERE field IN (). This would be a reasonable assumption. However, empty sets are not legal SQL syntax, at least in MySQL. So ActiveRecord handles this case differently: it replaces IN () with WHERE 1=0, which has the intended result, but it did confuse us.</p><h3>Conclusion</h3><p>Magic is great, but with great magic comes great chance of confusion. Know your magic :)</p><p><em>Originally published at </em><a href="https://www.codeoclock.com/2016/01/05/WHERE-1=0/"><em>https://www.codeoclock.com/2016/01/05/WHERE-1=0/</em></a><em> on January 5, 2016</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bdfc25ab237" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dawandadev/1-0-2bdfc25ab237">1 = 0</a> was originally published in <a href="https://medium.com/dawandadev">Code O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>