<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tom Edgeworth on Medium]]></title>
        <description><![CDATA[Stories by Tom Edgeworth on Medium]]></description>
        <link>https://medium.com/@tom_edgeworth?source=rss-80249efb0536------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Dxrr5ltTjslMEnGcbFeFNQ.png</url>
            <title>Stories by Tom Edgeworth on Medium</title>
            <link>https://medium.com/@tom_edgeworth?source=rss-80249efb0536------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:43:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tom_edgeworth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[12 Extremely Useful Hacks for JavaScript]]></title>
            <link>https://medium.com/@tom_edgeworth/12-extremely-useful-hacks-for-javascript-26bb2c6af4a1?source=rss-80249efb0536------2</link>
            <guid isPermaLink="false">https://medium.com/p/26bb2c6af4a1</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Tom Edgeworth]]></dc:creator>
            <pubDate>Wed, 02 Aug 2017 11:36:53 GMT</pubDate>
            <atom:updated>2017-08-02T11:36:53.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2pH_7EidgsisX7j1.png" /></figure><p>In this post I will share <strong>12 extremely useful hacks for JavaScript</strong>. These hacks reduce the code and will help you to run optimized code.</p><p>By the way, if your Automated Testing relies on Selenium tests running on a single headless browser, it should come as no surprise that your tests are unstable, unreliable and you’re constantly releasing bugs.</p><p>Don’t listen to that stubborn developer who insists on coding and maintaining an entire in-house infrastructure for Automated Testing, this trend is outdated and dangerous.</p><p>The trend is to be in the cloud. Just like companies have replaced their old bare metal servers with AWS, they have also replaced their old in-house tests with next-generation all-in-one platforms, such as <a href="https://endtest.io/"><strong>Endtest</strong></a>.</p><p>With Endtest, you can create and run Automated Tests on a cross-browser clud infrastructure and mobile device lab. And you can do all of that without writing a single line of code, that means that even your Product Owner can quickly write some tests.</p><p>Ford, MasterCard, KLM, Qatar Airways, Dell, Under Armour are just some of the big names that are relying on <a href="https://endtest.io/"><strong>Endtest</strong></a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqlvmTrB7pWY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqlvmTrB7pWY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqlvmTrB7pWY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0018b8d5480e289cb529f09f1071d04e/href">https://medium.com/media/0018b8d5480e289cb529f09f1071d04e/href</a></iframe><h3>1) Converting to boolean using !! operator</h3><p>Sometimes we need to check if some variable exists or if it has a valid value, to consider them as <em>true value</em>. For do this kind of validation, you can use the !!<em>(Double negation operator)</em> a simple !!variable, which will automatically convert any kind of data to boolean and this variable will return false only if it has some of these values: 0, null, &quot;&quot;, undefined or NaN, otherwise it will return true. To understand it in practice, take a look this simple example:</p><pre>function Account(cash) {  <br>    this.cash = cash;<br>    this.hasMoney = !!cash;<br>}<br>var account = new Account(100.50);  <br>console.log(account.cash); // 100.50  <br>console.log(account.hasMoney); // true</pre><pre>var emptyAccount = new Account(0);  <br>console.log(emptyAccount.cash); // 0  <br>console.log(emptyAccount.hasMoney); // false</pre><p>In this case, if an account.cash value is greater than zero, the account.hasMoneywill be true.</p><h3>2) Converting to number using + operator</h3><p>This magic is awesome! And it’s very simple to be done, but it only works with string numbers, otherwise it will return NaN<em>(Not a Number)</em>. Have a look on this example:</p><pre>function toNumber(strNumber) {  <br>    return +strNumber;<br>}<br>console.log(toNumber(&quot;1234&quot;)); // 1234  <br>console.log(toNumber(&quot;ACB&quot;)); // NaN</pre><p>This magic will work with Date too and, in this case, it will return the timestamp number:</p><pre>console.log(+new Date()) // 1461288164385</pre><h3>3) Short-circuits conditionals</h3><p>If you see a similar code:</p><pre>if (connected) {  <br>    login();<br>}</pre><p>You can shorten it by using the combination of a variable (which will be verified) and a function using the &amp;&amp; (AND operator) between both. For example, the previous code can become smaller in one line:</p><pre>connected &amp;&amp; login();</pre><p>You can do the same to check if some attribute or function exists in the object. Similar to the below code:</p><pre>user &amp;&amp; user.login();</pre><h3>4) Default values using || operator</h3><p>Today in ES6 there is the default argument feature. In order to simulate this feature in old browsers you can use the || (OR operator) by including the default value as a second parameter to be used. If the first parameter returns false the second one will be used as a default value. See this example:</p><pre>function User(name, age) {  <br>    this.name = name || &quot;Oliver Queen&quot;;<br>    this.age = age || 27;<br>}<br>var user1 = new User();  <br>console.log(user1.name); // Oliver Queen  <br>console.log(user1.age); // 27</pre><pre>var user2 = new User(&quot;Barry Allen&quot;, 25);  <br>console.log(user2.name); // Barry Allen  <br>console.log(user2.age); // 25</pre><h3>5) Caching the array.length in the loop</h3><p>This tip is very simple and causes a huge impact on the performance when processing large arrays during a loop. Basically, almost everybody writes this synchronous forto iterate an array:</p><pre>for (var i = 0; i &lt; array.length; i++) {  <br>    console.log(array[i]);<br>}</pre><p>If you work with smaller arrays — it’s fine, but if you process large arrays, this code will recalculate the size of array in every iteration of this loop and this will cause a bit of delays. To avoid it, you can cache the array.length in a variable to use it instead of invoking the array.length every time during the loop:</p><pre>var length = array.length;  <br>for (var i = 0; i &lt; length; i++) {  <br>    console.log(array[i]);<br>}</pre><p>To make it smaller, just write this code:</p><pre>for (var i = 0, length = array.length; i &lt; length; i++) {  <br>    console.log(array[i]);<br>}</pre><h3>6) Detecting properties in an object</h3><p>This trick is very useful when you need to check if some attribute exists and it avoids running undefined functions or attributes. If you are planning to write cross-browser code, probably you will use this technique too. For example, let’s imagine that you need to write code that is compatible with the old Internet Explorer 6 and you want to use the document.querySelector(), to get some elements by their ids. However, in this browser this function doesn’t exist, so to check the existence of this function you can use the in operator, see this example:</p><pre>if (&#39;querySelector&#39; in document) {  <br>    document.querySelector(&quot;#id&quot;);<br>} else {<br>    document.getElementById(&quot;id&quot;);<br>}</pre><p>In this case, if there is no querySelector function in the document object, we can use the document.getElementById() as fallback.</p><h3>7) Getting the last item in the array</h3><p>The Array.prototype.slice(begin, end) has the power to cut arrays when you set the begin and end arguments. But if you don’t set the end argument, this function will automatically set the max value for the array. I think that few people know that this function can accept negative values, and if you set a negative number as beginargument you will get the last elements from the array:</p><pre>var array = [1, 2, 3, 4, 5, 6];  <br>console.log(array.slice(-1)); // [6]  <br>console.log(array.slice(-2)); // [5,6]  <br>console.log(array.slice(-3)); // [4,5,6]</pre><h3>8) Array truncation</h3><p>This technique can lock the array’s size, this is very useful to delete some elements of the array based on the number of elements you want to set. For example, if you have an array with 10 elements, but you want to get only the first five elements, you can truncate the array, making it smaller by setting the array.length = 5. See this example:</p><pre>var array = [1, 2, 3, 4, 5, 6];  <br>console.log(array.length); // 6  <br>array.length = 3;  <br>console.log(array.length); // 3  <br>console.log(array); // [1,2,3]</pre><h3>9) Replace all</h3><p>The String.replace() function allows using String and Regex to replace strings, natively this function only replaces the first occurrence. But you can simulate a replaceAll() function by using the /g at the end of a Regex:</p><pre>var string = &quot;john john&quot;;  <br>console.log(string.replace(/hn/, &quot;ana&quot;)); // &quot;joana john&quot;  <br>console.log(string.replace(/hn/g, &quot;ana&quot;)); // &quot;joana joana&quot;</pre><h3>10) Merging arrays</h3><p>If you need to merge two arrays you can use the Array.concat() function:</p><pre>var array1 = [1, 2, 3];  <br>var array2 = [4, 5, 6];  <br>console.log(array1.concat(array2)); // [1,2,3,4,5,6];</pre><p>However, this function is not the most suitable to merge large arrays because it will consume a lot of memory by creating a new array. In this case, you can use Array.push.apply(arr1, arr2) which instead creates a new array – it will merge the second array in the first one reducing the memory usage:</p><pre>var array1 = [1, 2, 3];  <br>var array2 = [4, 5, 6];  <br>console.log(array1.push.apply(array1, array2)); // [1,2,3,4,5,6];</pre><h3>11) Converting NodeList to Arrays</h3><p>If you run the document.querySelectorAll(&quot;p&quot;) function, it will probably return an array of DOM elements, the NodeList object. But this object doesn’t have all array’s functions, like: sort(), reduce(), map(), filter(). In order to enable these and many other native array’s functions you need to convert NodeList into Arrays. To run this technique just use this function: [].slice.call(elements):</p><pre>var elements = document.querySelectorAll(&quot;p&quot;); // NodeList  <br>var arrayElements = [].slice.call(elements); // Now the NodeList is an array  <br>var arrayElements = Array.from(elements); // This is another way of converting NodeList to Array</pre><h3>12) Shuffling array’s elements</h3><p>To shuffle the array’s elements without using any external library like <em>Lodash</em>, just run this magic trick:</p><pre>var list = [1, 2, 3];  <br>console.log(list.sort(function() {  <br>    return Math.random() - 0.5<br>})); // [2,1,3]</pre><h3>Conclusion</h3><p>Now you learned some useful JS hacks which are largely used to minify JavaScript code and some of these tricks are used in many popular JS frameworks like Lodash, Underscore.js, Strings.js, among others. If you want to go even deeper and learn more about how you can minify your code even more and even protect it from prying eyes talk to <a href="https://blog.jscrambler.com/12-extremely-useful-hacks-for-javascript/support@jscrambler.com">us</a>. I hope you enjoyed this post and if you know other JS hacks, please let us know!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26bb2c6af4a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 Reasons for CI Failure]]></title>
            <link>https://medium.com/@tom_edgeworth/top-5-reasons-for-ci-failure-4fa4067e5f23?source=rss-80249efb0536------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fa4067e5f23</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Tom Edgeworth]]></dc:creator>
            <pubDate>Tue, 01 Aug 2017 08:35:14 GMT</pubDate>
            <atom:updated>2017-08-01T08:35:14.500Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*ugpU7_OgQXXhVdS8KcubAw.jpeg" /></figure><p>Agile software development can’t be perfect without an effective <a href="https://www.thoughtworks.com/continuous-integration">Continuous Integration</a> process. CI is a process of continuously analyizing, building, testing, and deploying software. Continuous Integration checks the internal quality of the code and tests the business logic of the product before it’s released to Production.</p><p>Ideally, we shouldn’t allow <a href="https://www.thoughtworks.com/continuous-integration">software to deploy to Production</a> when the build is broken. However, Continuous Integration doesn’t always work for every Agile team. Some Agile teams take <a href="https://www.thoughtworks.com/continuous-integration">CI practices</a> very seriously, some teams do it for sake of doing Agile, some teams ignore it completely, and some doesn’t have a CI server set up yet.</p><p>There are various reasons that CI practices might be ignored within the team. Businesses have different priorities, Product Owners doesn’t always understand the importance of <a href="https://www.madetech.com/blog/internal-vs-external-quality-of-software">internal quality</a>, testing processes, and clean builds. The Technical Manager can’t buy time to implement the CI practices or fix a broken CI. Production and Technology Management fail to understand each other’s priorities and they end up deploying the broken build to end users. The Production people are happy — they delivered business value with broken CI.</p><p>This approach can give temporary satisfaction, but it’s very dangerous. It can later throw severe bugs into Production, which can heavily impact business. The severity of an impact is unpredictable, ranging from the loss of money to the loss of reputation or, in an extreme case, the loss of the business completely.</p><p>However, even if the Production and Technology teams agree to invest time and money to implement or fix CI issues, some teams never succeed. Let’s discuss top five reasons for CI failures and potential solutions to overcome the problems.</p><h3>1. Primitive Automated Testing</h3><p>If your Automated Testing relies on Selenium tests running on a single headless browser, it should come as no surprise that your tests are unstable, unreliable and you’re constantly releasing bugs.</p><p>Don’t listen to that stubborn developer who insists on coding and maintaining an entire in-house infrastructure for Automated Testing, this trend is outdated and dangerous.</p><p>The trend is to be in the cloud. Just like companies have replaced their old bare metal servers with AWS, they have also replaced their old in-house tests with next-generation all-in-one platforms, such as <a href="https://endtest.io/"><strong>Endtest</strong></a>.</p><p>With Endtest, you can create and run Automated Tests on a cross-browser clud infrastructure and mobile device lab. And you can do all of that without writing a single line of code, that means that even your Product Owner can quickly write some tests.</p><p>Ford, MasterCard, KLM, Qatar Airways, Dell, Under Armour are just some of the big names that are relying on <a href="https://endtest.io/"><strong>Endtest</strong></a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqlvmTrB7pWY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqlvmTrB7pWY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqlvmTrB7pWY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0018b8d5480e289cb529f09f1071d04e/href">https://medium.com/media/0018b8d5480e289cb529f09f1071d04e/href</a></iframe><p>There are also other alternatives, you can code your own tests and run them with <a href="https://www.browserstack.com/"><strong>BrowserStack</strong></a> or <a href="http://www.saucelabs.com/"><strong>SauceLabs</strong></a>, but it’s more expensive and you won’t get the same stability.</p><h3>2. Wrong Selection of CI Server</h3><p>There are various Continuous Integration tools available in the market. The CI server solution can be <a href="https://www.claromentis.com/blog/cloud-vs-self-hosted-which-solution-is-best-for-your-intranet/">self-hosted or on the cloud</a>. You can get a whole <a href="https://www.slant.co/topics/799/~continuous-integration-tools">list of CI servers here</a> with recommendations.</p><p><a href="https://jenkins.io/">Jenkins</a> is one of the popular CI servers, and people have tended to use it blindly. We’ve had to adjust our project to work with Jenkins and the team has to compromise with the services that Jenkins offers. Now, that situation has changed and there are various promising CI services in the market. Looking at the wide range of CI servers in the market, it’s challenging to select one that suits our project need.</p><p>The process of setting up a CI server takes time and money. If you choose CI server without doing any research and it doesn’t work well for the team, then all the efforts you put in to get CI server will be in vain. A common mistake that management makes is selecting a generic CI server or service for all platforms like that doesn’t work quite well. Imagine that your application has a website, iOS app, and Android app; finding a generic solution might not work well. We have to be very careful about selecting our CI server.</p><h3>Potential Solutions</h3><ul><li>Research the market very well and evaluate options on pilot projects. <em>Slant</em> has already evaluated <a href="https://www.slant.co/topics/799/~continuous-integration-tools">major CI servers</a> with pros and cons of each.</li><li>Look for the features like pipeline support, pipeline as code, Docker container support, platform support, ease of use, availability, etc. while evaluating CI servers.</li><li>Don’t try to find a generic solution for all of the platforms to reduce cost. Each platform has different technical requirements and challenges.</li><li>Discuss it with the team and ask for past experiences so that we don’t need to train engineers again.</li></ul><h3>3. CI Amateur Engineers</h3><p>An engineer working in the Agile team should have great coding skills, but delivering a working software is more than just writing and testing code. It also involves setting up the appropriate environment to make sure we can deliver it easily. This requires strong command line and scripting skills for <a href="https://en.wikipedia.org/wiki/Build_automation">build automation</a> as well as sound knowledge of <a href="https://en.wikipedia.org/wiki/List_of_build_automation_software">build automation tools</a> and <a href="https://en.wikipedia.org/wiki/Package_manager">dependency/package management</a> tools.</p><p>Recently, companies have been moving the infrastructure to cloud, so there is a need to learn DevOps skills, i.e., cloud services like AWS, Azure, and Heroku; provisioning tools like bash, Ansible, and Chef; and container services like Docker and Kubernetes. The most important thing is having knowledge of one of the scripting languages, i.e., Bash, Ruby, or Python.</p><p>This doesn’t mean that you should learn everything in the world, but you should learn everything for your platform. Let’s assume that an engineer is working on iOS application development. The engineer should know tools like Cocoapods, Carthage, and Swift Package Manager for dependency management.</p><p>Also, build automation tools like Fastlane, Rake, and Make have a strong command over Apple’s native <a href="https://developer.apple.com/library/content/technotes/tn2339/_index.html">command line tools</a>. An engineer should be aware of recent tools related to the relevant platform.</p><p>There are different types of engineers in the market; some of them are good at writing native language code (i.e., Java, Objective-C, and Swift) and have a strong knowledge of DevOps and build automation tools. Some engineers just write code in an IDE (i.e., Eclipse, IntelliJ, and Xcode) are not capable of running commands from the terminal. Some engineers are better at build automation tools but are not that good at writing native language code.</p><p>CI amateurs are those who cannot get out of IDE and are not capable of using command line (scripting) tools. They prefer GUI tools to everything than command line or scripting. However, the CI server doesn’t have a GUI interface to interact with, so everything has to be scripted.</p><p>If you have CI amateur engineers on your team, CI practices are never going to be successful. The CI amateur developers might end up writing poor quality build automation scripts that break all the time. The team ends up spending time on learning, improving build automation, and switching between the CI servers rather than building features that are useful for the business.</p><h3>Potential Solutions</h3><ul><li>Hire engineers who have basic knowledge of Continuous Integration and DevOps.</li><li>Train CI amateur engineers. A good idea is to send them to external training or train them with in-house CI experts.</li><li>Hire experts on short-term contracts to set up the CI process and share knowledge.</li></ul><h3>4. Pipeline Isn’t Coded</h3><p>Most CI servers allow users to change the build configuration from the web interface. This approach makes it easy for engineers to create and edit the CI builds. However, changing build configuration frequently can cause a lot of issues, such as disabling important build steps. Additionally, everyone has permission to access the build machines, which can cause confusion as to who did what and when they did it. It takes long to figure out build failures if engineers are not aware of build setting changes. Frequent changes in the CI server machine can cause problems and confusions within the team.</p><h3>Potential Solution</h3><ul><li>Take control of build configuration by putting the config file, bash script, or similar file inside the source code.</li><li>Avoid manual configurations on CI server.</li><li>Restrict access to the CI server machine to a few people and give them the responsibility to manage the server.</li><li>Do not allow users to modify particular build steps.</li></ul><h3>5. Poor Quality Build Server Machines</h3><p>Developers working on the team frequently check in code in the source control system, which triggers a build on the CI server. This means that the CI server machine is continuously running jobs that can involve heavy tasks such as downloading dependencies from remote servers, backing up databases, running Docker containers, etc. In order to perform those task effectively, the CI server must be fast, reliable, and connected to the network. Using a poor-quality server wastes everyone’s time because the build takes too long to finish, resulting in intermittent test results and frustrated engineers.</p><h3>Potential Solutions</h3><ul><li>Get a quick and reliable server for Continuous Integration; avoid cheap servers.</li><li>Never leave the CI server machine on WiFi.</li><li>Never install unnecessary software on the CI server machine.</li><li>Smartly share the CI server machine by assigning specific jobs.</li><li>Never install any software manually.</li><li>Avoid giving GUI access to machines. SSH access should be sufficient.</li><li>Set up CI practices with team and apply them strictly within team.</li><li>Train Project Managers on CI practices.</li></ul><h3>Conclusion</h3><p>It’s challenging to implement Continuous Integration practices within an Agile team, but following some strict rules and avoiding common mistakes can make the CI process much effective. What are your experiences with CI servers? Do you feel your CI practices are working well? Weigh in with a comment below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fa4067e5f23" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>