<?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 MathieuNls on Medium]]></title>
        <description><![CDATA[Stories by MathieuNls on Medium]]></description>
        <link>https://medium.com/@mathieuNls?source=rss-16e1a2e3f13e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lgF-GlQ47V7gXfAKZHDTmA.jpeg</url>
            <title>Stories by MathieuNls on Medium</title>
            <link>https://medium.com/@mathieuNls?source=rss-16e1a2e3f13e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:32:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mathieuNls/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[Typescript pitfalls-Part I: Type casting and JSON]]></title>
            <link>https://medium.com/@mathieuNls/typescript-pitfalls-type-casting-and-json-part-i-667308e2f13f?source=rss-16e1a2e3f13e------2</link>
            <guid isPermaLink="false">https://medium.com/p/667308e2f13f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[MathieuNls]]></dc:creator>
            <pubDate>Wed, 10 Aug 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-08-11T13:40:06.039Z</atom:updated>
            <content:encoded><![CDATA[<p>I am currently writing two books on Angular2 for Packt Publishing (<a href="https://www.packtpub.com/web-development/angular-2-design-patterns-and-best-practices">Angular 2 Design Patterns and Best Practices</a> and Mastering Angular2). So, I do A LOT of typescript and, in this post series, I go on and on about what&#39;s bother me...</p><p>I&#39;ve always h-a-t-e-d JavaScript. I was using it, sure, but only when it was necessary. I distinctly remember my first internship interview, back when I was a freshman at eXia.Cesi - a French computer engineering school. I only knew C and some Java, and I was asked to help on an intranet that mostly worked with homemade AJAX libraries. It was pure madness and kind of steer me away from the web aspect of computer engineering for a while. I find nothing likable in the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e85f0dc8ac215f6d34355fcd41bec67d/href">https://medium.com/media/e85f0dc8ac215f6d34355fcd41bec67d/href</a></iframe><p>How ugly is that? Of course, with jQuery modules and some separation of concerns it can be usable, but still not as comfortable as I would like. Fortunately, Typescript came to save me...or is it ?</p><h3>Ultra quick overview of typescript.</h3><p>TypeScript is a typed superset of Javascript; which means that, with TypeScript, you can do everything you used to do in JavaScript and more! To name a few advantages: user-defined types, inheritance, interfaces, visibility, ... And the best part is that TypeScript is transpiled into JavaScript so that any modern browser can run it. In fact, with the use of <a href="https://www.wikiwand.com/en/Polyfill">polyfill</a>, even our good old IE6 can almost execute the final output. We&#39;ll get back on that in the next chapter. The <a href="https://www.wikiwand.com/en/Source-to-source_compiler">transpilation</a> is different from compilation (e.g., from C to executable or .java to .class) as it only translates TypeScript into JavaScript.</p><p>While TypeScript is typed it only proposes four base type for you to use out of the box. The four types are string, number, boolean and any. These types can, using the “:” operator, type variables var name:String or function arguments and return type function add(a:number, b:number):number. Also, void can be used for functions to specify that they don&#39;t return anything. On the object-oriented side, string, number and, boolean specialize any. Any can be used for anything. It&#39;s the TypeScript equivalent of the Java Object for instance. If you need more than these types, well, you have to create them yourself ! Thankfully, this is pretty straightforward. Here&#39;s the declaration of the user class containing one property.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2228b2533120a1a795943ff27d944da7/href">https://medium.com/media/2228b2533120a1a795943ff27d944da7/href</a></iframe><p>Here, I create a variable p that statically (e.g. left-hand side) and dynamically (e.g. right-hand side) a Person. Then, I affect “Mathieu” to the name property. Properties are, by default, public, but you can use the public, private and, protected keywords to refine their visibility. They&#39;ll behave as expected of any object-oriented programming language. Typescript supports interface, inheritance and polymorphism in a very simple fashion. Here is a simple hierarchy composed of two classes and one interface. The interface—People—define the string that will be inherited by any People implementation. Then, Employee implements People and adds two properties: manager and title. Finally, the Manager class defines an Employee array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89dcb0208f4598f36a932d14295e7e0a/href">https://medium.com/media/89dcb0208f4598f36a932d14295e7e0a/href</a></iframe><p>Functions can be overridden by functions that have the same signature, and the super keyword can be used to refer to the parent implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19b2689241f612a9f9d9c04da72aa984/href">https://medium.com/media/19b2689241f612a9f9d9c04da72aa984/href</a></iframe><p>The last thing you need to know about Typescript before we move on to the best practices is the difference between let and var. In typescript, you can use both to declare a variable. Now, the particularity of variables in typescript is that it let you decide between function and block scope for variables using the var and let keyword. Var will give your variable a function scope while let will produce a block scoped variable. A function scope means that variables are visible and accessible from and to the whole function. Most programming languages have block scope for variables (i.e. c#, java, c++, …). Some languages also offer the same possibility as typescript such as Swift 2. More concretely, the output of the following snippet will be 456:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9cd5d414880e49549a4337452f80630b/href">https://medium.com/media/9cd5d414880e49549a4337452f80630b/href</a></iframe><p>Now that we powered through the language, let&#39;s see what&#39;s broken !</p><h3>Type casting and JSON</h3><p>Let&#39;s assume that we have an User class with two private variables: lastName:string and firstName:string. In addition, this simple class proposes the method hello that prints &quot;Hi I am&quot;, this.firstName, this.lastName.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17cfdb33c719280bebebe2d35113da5a/href">https://medium.com/media/17cfdb33c719280bebebe2d35113da5a/href</a></iframe><p>Now, consider that we receive users through a JSON API. Most likely, it&#39;ll look something like that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f31ccfbb1c62b9fd633463b04c7fd29e/href">https://medium.com/media/f31ccfbb1c62b9fd633463b04c7fd29e/href</a></iframe><p>Until now; the typescript compiler doesn&#39;t complain, and it executes smoothly. It works because the parse method returns any (e.g., the TypeScript equivalent of the Java Object). Surely enough, we can convert the any into User. However, userFromJSONAPI.hello(); will yield:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/674a7beb66993780763184160595679c/href">https://medium.com/media/674a7beb66993780763184160595679c/href</a></iframe><p>Why? Well, the left side of assignation is defined as User, sure, but it&#39;ll be erased when we transpile it to JavaScript.</p><p>The type safe TypeScript way to do it will be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/158a319bb6f86d56c81b5b46ab50133d/href">https://medium.com/media/158a319bb6f86d56c81b5b46ab50133d/href</a></iframe><p>Interestingly enough, the typeof function won&#39;t help you either. In both cases it&#39;ll display “Object” instead of “User” as the very concept of “User” doesn&#39;t exists in JavaScript.</p><p><em>Originally published at </em><a href="http://math.co.de/blog/Typescript-Pitfalls-1/"><em>math.co.de</em></a><em> on August 10, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=667308e2f13f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Report your client-side errors to Slack.]]></title>
            <link>https://medium.com/@mathieuNls/report-your-client-side-errors-to-slack-7d09ada567db?source=rss-16e1a2e3f13e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d09ada567db</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[MathieuNls]]></dc:creator>
            <pubDate>Wed, 23 Mar 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-08-05T14:01:51.071Z</atom:updated>
            <content:encoded><![CDATA[<p>Errors are inevitable in web-development or development at large. The first step to fix them is, well, to know about them. By looking through your server logs or using server monitoring, you’ll be able to see server side errors. But then, what about client side errors, a.k.a, javascript errors?</p><p>At toolwatch, our visitors use a wide-range of browser. Here’s a browser list as reported by Google analytics.</p><pre>Chrome 44,73 % <br>Safari 32,66 % <br>Firefox 8,18 % <br>Safari (in-app) 8,15 % <br>Internet Explorer 2,96 % <br>Edge 0,96 % <br>Android Browser 0,63 % <br>Mozilla Compatible Agent 0,63 % <br>Opera 0,56 % <br>UC Browser 0,16 % <br>BlackBerry 0,10 % <br>Coc Coc 0,07 % <br>Maxthon 0,05 % <br>Nichrome 0,02 % <br>Amazon Silk 0,01 %</pre><p>Sure, the top four/five are well-known and we do test that everything is awesome on these. However, testing everything on each and every browser isn’t only impractical, it’s near impossible. You could use some third party services such as <a href="http://browsershots.org/">Browser shot</a> and <a href="https://www.browserstack.com/">BrowserStack</a> or… use a quick <em>and dirty?</em> approach where client side errors get reported to wherever you want. Here’s what we use for reporting js errors in Slack with a php backend.</p><p>A simple js script, to include on every page, that posts an error variable composed of the file, line, user agent and platform that triggered the error:</p><pre>&lt;script type=&quot;text/javascript&quot;&gt;<br>  window.onerror = function(message, file, line) {<br>    $.post( &quot;https://&quot;+window.location.hostname+ &quot;/someBackendUrl&quot;, { error:  file + &quot;(&quot; + line + &quot;): &quot;<br>      + message + &quot; [&quot;+navigator.userAgent+&quot;,&quot;+navigator.platform+&quot;]&quot; })<br>    .done(function( data ) {<br>      console.log(&quot;logged&quot;);<br>    });<br>  }<br>&lt;/script&gt;</pre><p>Then, on the backend side, a php script the received error to slack:</p><pre>//Concat the error with the HTTP_HOST, so we know if the error was triggered in stage or prod env. $data = json_encode([“text”=&gt;$_SERVER[‘HTTP_HOST’].”\r\n”.$error]);</pre><pre>//Get environment variable for the slack API key $ch = curl_init(getenv(“SLACK_EXCEPTION”)); //curl magick curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( ‘Content-Type: application/json’, ‘Content-Length: ‘.strlen($data)) ); $result = curl_exec($ch); </pre><p>Which produces the following in Slack:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_nzylMKOeWUDXTYf.png" /></figure><p>And, that’s it, ~25 lines of code and you won’t be able to say you didn’t know anymore!</p><p><em>Originally published at </em><a href="http://math.co.de/blog/report-js-error-to-slack/"><em>math.co.de</em></a><em> on March 23, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d09ada567db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Citations.js: A JQuery plugin to ease citations in html documents]]></title>
            <link>https://medium.com/@mathieuNls/citations-js-a-jquery-plugin-to-ease-citations-in-html-documents-460dee98213b?source=rss-16e1a2e3f13e------2</link>
            <guid isPermaLink="false">https://medium.com/p/460dee98213b</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[MathieuNls]]></dc:creator>
            <pubDate>Wed, 02 Mar 2016 00:00:00 GMT</pubDate>
            <atom:updated>2016-08-05T13:57:28.585Z</atom:updated>
            <content:encoded><![CDATA[<p>I always liked LaTeX for how easy it is to manage references. Indeed a simple \cite{citation-key} coupled with a \thebibliography{your-bibtex} will automatically generate a citation and a reference table in your paper. However, when you write html/mardown content, managing references could be obnoxious. I trust that there is some Wordpress plugins or node module to achieve just that through elegant drag and drop, but I wanted a solution that I can use here, on my Jekyll Github-page powered blog.</p><p>That’s why I’ve created <a href="https://github.com/MathieuNls/citations.jquery.js">citations.js</a>, A simple JQuery plugin to ease citations in html documents. You can see a live example <a href="https://math.co.de/resume.html">here</a>.</p><p>For now, citations. is only supports the \citeAll command of LaTeX that includes references for all the entries of a given JSON file. In other words, it’ll <em>only</em> generate the reference table. However, you can already do some fancy manipulations on your reference table such as grouping, filtering, ordering, dynamic search and more.</p><p>Why JSON instead of the <em>regular</em> bibtex format you might ask. Well, did you ever write bibtex entry by hand ? I mean :</p><pre>@inproceedings{Giger2011, address = {New York, New York, USA}, author = {Giger, Emanuel and Pinzger, Martin and Gall, Harald C.}, booktitle = {Proceeding of the 8th working conference on Mining software repositories — MSR ‘11}, doi = {10.1145/1985441.1985456}, isbn = {9781450305747}, keywords = {code churn,nonlinear regression,prediction models,software bugs,source code changes}, month = {may}, pages = {83}, publisher = {ACM Press}, title = {{Comparing fine-grained source code changes and code churn for bug prediction}}, url = {<a href="http://dl.acm.org/citation.cfm?id=1985441.1985456">http://dl.acm.org/citation.cfm?id=1985441.1985456</a>}, year = {2011} }</pre><p>Seriously?! Personally, I use <a href="https://www.mendeley.com/">mendeley</a> and the export and its export bibliography feature for LaTeX-based content.</p><p>JSON is easy to read/write and it’s supported by jquery and bare javascript both which speed up the development of this plugin.</p><p>In the near future, I’d like to add the following to citations.js:</p><ul><li>Tests</li><li>Highlight search results</li><li>The current cite function is more like a LateX \citeAll, I would like to have both \cite and \citeAll behaviour.</li><li>Support bibtex/build a bib to json converter</li><li>Display a list of co-author with numbers of papers associated and allow searching by co-author</li><li>Same for years</li><li>Same for students (In case a Pr wants to highlights students of his)</li><li>Support official citation style (APA, Harvard,…)</li></ul><p>Let’s get to it and see how to use citations.js.</p><h3>How to install</h3><p>Download the <a href="https://github.com/MathieuNls/citations.jquery.js/releases/latest">latest version of the plugin</a>.</p><pre>&lt;script type=&quot;text/javascript&quot; src=&quot;//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js&quot;&gt;&lt;/script&gt;<br>&lt;script type=&quot;text/javascript&quot; src=&quot;//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js&quot;&gt;<br>&lt;/script&gt;<br>&lt;script type=&quot;text/javascript&quot; src=&quot;path/to/citations.jquery.js&quot;&gt;&lt;/script&gt;</pre><h3>How to use</h3><p>Given a publications.json file looking like:</p><pre>[ {“authors”: [ {“lastname”: “Nayrolles”, “firstname”: “Mathieu”}, {“lastname”: “Palma”, “firstname”: “Francis”}, {“lastname”: “Moha”, “firstname”: “Naouel”} ], “title”:”SOA Antipatterns : An Approach for their Specification and Detection”, “venue”: “International Journal of Cooperative Information Systems”, “volume”:22, “issue”:4, “year”:2013, “type”: “journal”, “pages”: “1–40” },… …, ]</pre><p>The following will populate the #papers element with a &lt;ul&gt;&lt;li&gt; structure.</p><pre> $(“#papers”).cite({ file : “/json/publications.json” }); </pre><p>In this example, it’ll generate</p><ul><li>Nayrolles, M. , Palma, F. &amp; Moha, N. (2013). SOA Antipatterns : An Approach for their Specification and Detection. International Journal of Cooperative Information Systems. (pp. 1–40).</li><li>…</li><li>…</li></ul><p>A more advanced example with sorting, grouping, and more:</p><pre> $(“#papers”).cite({ file : “json/publications.json”, sortBy : “year”, orderType : “desc”, groupBy: “type”, myLastName : “Nayrolles”, myFirstName : “Mathieu”, classul: “resume-item-list”, preGroup: “‘, groupTitle : { journal: “Peer Reviewed Journals” }, searchBar: “#filter” }); will generate :</pre><p>will generate</p><pre>&lt;div id=&quot;papers&quot;&gt;<br>  &lt;div class=&#39;resume-item&#39;&gt;&lt;h3 class=&#39;resume-item-title&#39;&gt;Peer Reviewed Journals&lt;/h3&gt;<br>  &lt;ul class=&quot;resume-item-list&quot;&gt;<br>    &lt;li&gt;&lt;u&gt;Nayrolles, M.&lt;/u&gt; , Palma, F. &amp;amp; Moha, N. (2013). SOA Antipatterns : An Approach for their Specification and Detection. International Journal of Cooperative Information Systems. (pp. 1-40).&lt;/li&gt;<br>    &lt;li&gt;...&lt;/li&gt;<br>    &lt;li&gt;...&lt;/li&gt;<br>  &lt;/ul&gt;<br>&lt;/div&gt;</pre><ul><li>Nayrolles, M. , Palma, F. &amp; Moha, N. (2013). SOA Antipatterns : An Approach for their Specification and Detection. International Journal of Cooperative Information Systems. (pp. 1–40).</li><li>…</li><li>…</li></ul><h4>Options</h4><ul><li>file: url to your publication json file</li><li>classul: optional class to add for ul</li><li>classli: optional class to add for each li</li><li>sortBy: optional field on which publications shall be sorted</li><li>orderType: optional, default = “asc”.</li><li>filterBy: optional, field on which remove publication</li><li>filterValue: optional, field value on which remove publication</li><li>myLastName: optional, your last name to underline it</li><li>myFirstName: optional, your first name to underline it</li><li>debug: optional, default false.</li><li>groupBy:optional, a field on which group your publications</li><li>preGroup:optional, if you group your citation, you might want to add something before each group. You can use the {title} key in preGroup to replace it with the group key value</li><li>postGroup: optional, see preGroup</li><li>groupTitle: optional, the group key value might not be the title you want for your group. You can provide an associative array groupKey value : Title</li><li>searchBar:optional, provide a selector to an input field. Only publications matching the input value will be shown.</li></ul><p><em>Originally published at </em><a href="http://math.co.de/blog/citations-js-makes-reference-easy/"><em>math.co.de</em></a><em> on March 2, 2016.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=460dee98213b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Toolwatch Deployment Process Github, Travis and Heroku]]></title>
            <link>https://medium.com/toolwatch/toolwatch-deployment-process-github-travis-and-heroku-c9337727d8a2?source=rss-16e1a2e3f13e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9337727d8a2</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[MathieuNls]]></dc:creator>
            <pubDate>Wed, 12 Aug 2015 00:00:00 GMT</pubDate>
            <atom:updated>2016-08-05T13:49:21.389Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="https://toolwatch.io/">Toolwatch</a> we use a full fledged development environment based on different tools and technologies. Let’s see how to integrate Github, Travis and Heroku for a fully automatized deployment process.</p><h3>Github : Build software better, together.</h3><p>In case you don’t know, Github is the absolute web repository hosting service. It provides (for free !) a git-based distributed source code management, access control, bug tracking, feature requests, milestone management, pull request and even the possibility to host a <a href="http://jekyllrb.com/">jekyll</a> based website (<em>This blog takes advantage of that. Here’s the </em><a href="https://github.com/MathieuNls/mathieunls.github.io"><em>https://github.com/MathieuNls/mathieunls.github.io</em></a>) and a wiki for each of your project.</p><h4>Why we love it so much</h4><p>Well… GIT ! With git comes <a href="http://git-scm.com/docs/gittutorial#_managing_branches">branching</a>, <a href="http://git-scm.com/docs/git-rebase">rebasing</a>, <a href="http://git-scm.com/docs/git-rebase">merging</a>, <a href="http://git-scm.com/docs/git-cherry-pick">cherry-picking</a> and much more. All these features will come handy in almost every programming session.</p><p>Also, the bug tracking, feature requests and milestone management makes Github the perfect spot for technical and non-technical folks to exchange about the project and see where you at and what’s going on.</p><p><a href="https://twitter.com/MarcAime">@Marc</a>, the founder of toolwatch, will also tell you that the mobile website is so well-designed that he don’t mind spending his daily four hours of commute on it.</p><h4>How to do it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*rZM8c8OIU6ZR3nDl.png" /></figure><ul><li>Give your repository a name and off you go !</li></ul><h4>I start from scratch</h4><p>If you start from scratch, the following will create a readme, add the readme modification for commit, commit the readme with the message “first commit” and push the whole thing on github.</p><p>{% highlight bash %} cd MyAwesomeRepoFolder echo “# myAwesomeRepo” &gt;&gt; README.md git init git add README.md git commit -m “first commit” git remote add origin <a href="/service/mailto:git@github.com">git@github.com</a>:MathieuNls/myAwesomeRepo.git git push -u origin master {% endhighlight %}</p><h4>I already have some code but it’s not versionned with git</h4><pre>cd MyAwesomeRepoFolder <br>git init git add . <br>git commit -m “first commit” <br>git remote add origin <a href="/service/mailto:git@github.com">git@github.com</a>:MathieuNls/myAwesomeRepo.git git push -u origin master</pre><h4>I already have some code and it’s versionned with git</h4><pre>cd MyAwesomeRepoFolder <br>git remote add origin <a href="/service/mailto:git@github.com">git@github.com</a>:MathieuNls/myAwesomeRepo.git git push -u origin master </pre><h4>What Should I Be Careful About ?</h4><p>In short: passwords, salt and API keys.</p><p>If you stay with the free plan (unlimited public repository) your code will be public, meaning every one can see it. I personally open-source as much as I can (see <a href="https://github.com/MathieuNls/mathieunls.github.io/blob/master/projects/bumper">Bumper</a> for an example) but I make sure that passwords and API key are not versionned in Github. Why ? Because, as <a href="http://www.devfactor.net/2014/12/30/2375-amazon-mistake/">Andrew Hoffman</a>, you could’ve your repository scanned by a script looking for API key and end up with a $2375 bill in your inbox !</p><p>Passwords and salt for you database, for example, will be major security breach. If you do need an explanation about this <a href="http://security.stackexchange.com/users/27048/u2702">u2702</a> and <a href="http://security.stackexchange.com/users/3339/lucas-kauffman">Lucas Kauffman</a> are here for you on <a href="http://security.stackexchange.com/a/38480">stackexange</a></p><h4>What’s missing ?</h4><p>Hear me here, the project management capabilities of Github are good, very good : issues, features, tags, developer assignation, comments on code and request both. The only thing that I would like to see in Github is a time tracking engine very much like <a href="http://www.redmine.org/">redmine</a>. I am using a combination of tools, mainly zappier and toggle, to track the time I spent on things in order to improve myself. Consequently, I wish I could have these data directly in Github, associated with the issues.</p><h3>Heroku : Focus on the app.</h3><p><a href="https://heroku.com/">Heroku</a> is one of the first cloud platform as a service that has been created in ’07 by James Lindenbaum, Adam Wiggins and Orion Henry. To keep it simple, Heroku gives access to virtual machines based (called Dynos) on Debian that you can use to serve your code.</p><p>Currently (august 2015), Heroku supports Ruby, Java, Scala, Clojure, Python, PHP and Perl.</p><h4>Why we love it so much</h4><p>In one word : Simplicity.</p><p>With Heroku, we can deploy, in matter of seconds our github repository and make it accessible for our users. Moreover, Heroku is a cloud platform, so we can, on the fly, throw more virtual machines to increase our processing capacity. Last but not least, heroku proposes hundreds of third party add-ons. Some handy examples includes <a href="https://elements.heroku.com/addons/cleardb">databases as a service</a>, <a href="https://elements.heroku.com/addons/algoliasearch">search engines</a> or <a href="https://elements.heroku.com/addons/fastly">caching mechanisms</a>.</p><h4>How to do it</h4><ul><li>Go on <a href="https://www.heroku.com/">heroku</a> and create an account.</li><li>Then login. You’ll be redirected to your dashboard. The dashboard is where you can manage your different projects and virtual machines.</li><li>Click on the big plus on the top right or go to <a href="https://dashboard.heroku.com/new">https://dashboard.heroku.com/new</a> to create your first heroku app.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2jX740V5ZRKchUSE.png" /></figure><ul><li>Choose where you want your app to be host.</li><li>Go in the deploy tab, then Github and connect to your Github repository.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P6SWKMf6Z2mIADl7.png" /></figure><p>Wait, what ?! Heroku provides a git repository and you didn’t use it ? We could use it, and we did for a while, but then, we do not leverage what’s makes Github awesome: the project management.</p><ul><li>You can also enable automatic deploy in order to have each commit pushed in github pull by heroku and delivered to your users automatically.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/0*MxYol3qel41EvGs2.png" /></figure><ul><li>Then, we have to tell heroku what’s our app is all about. Create a file named composer.json at the root of your project containing the following for a php project.</li></ul><pre>{ “require” : { “php”: “~5.6.5”, “ext-mysql”: “<em>”, “monolog/monolog”: “~1.7” }, “require-dev”: { “heroku/heroku-buildpack-php”: “</em>”, “mikey179/vfsStream”: “1.1.*” } }</pre><p>Go <a href="https://devcenter.heroku.com/articles/php-support">here</a> for a full-blown tutorial about that.</p><ul><li>Earlier, I told you it was dangerous to put your passwords and API keys in Github. Either you store them in a file that won’t ever be versionned and you upload that file through the heroku <a href="https://toolbelt.heroku.com/">toolbet</a> OR your use heroku capacity to create environment variables. To do so, go to the setting tab and click on reveal variables environment, then the green +. Finally, add your key name and value.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y4EGcZkADRJ_K8pf.png" /></figure><ul><li>Finally, you can retrieve them in your code. As example, here what you can do for database connection in php.</li></ul><pre>//With an environment variable named DB_URL <br>//which have mysql://user:password@host/db-name as value <br>$url = parse_url(https://medium.com/getenv(%E2%80%9CDB_URL%E2%80%9D)); <br>$db[‘default’][‘hostname’] = $url[“host”]; <br>$db[‘default’][‘username’] = $url[“user”]; <br>$db[‘default’][‘password’] = $url[“pass”]; <br>$db[‘default’][‘database’] = substr($url[“path”], 1);</pre><h4>What Should I Be Careful About ?</h4><p>Automatic deploys are a beautiful yet dangerous thing. Indeed, each one of your commit will be <em>live</em> automatically seconds after you push them. Sure, you should only push bug-free and complete commit, but what if ? What if you do introduce a new bug ? Well, that’s the subject of the next tool we use at toolwatch: Travis.</p><h3>Travis, Test and Deploy with Confidence</h3><p>Travis is an online continuous integration tool. Simply put, it will automatically run your unit tests (that you already wrote, right ?!) and provide you a report. If your tests are all green, your code will be deployed on heroku. Otherwise, you’ll be notified that something went wrong and you can check which test failed and fix what you broke.</p><h4>Why we love it so much</h4><p>Once again, simplicity. With the Github login, all your repositories are instantly accessible and testable. Moreover, the fact that heroku can wait for test to pass in order to deploy is a really awesome fail safe in our deployment process.</p><h4>How to do it</h4><ul><li>Go to <a href="https://travis-ci.org/">https://travis-ci.org/</a> and click on <em>Sign in with Github</em>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8fu3umyjRA3whruU.png" /></figure><ul><li>Open your profile and activate your repository.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/0*A2PPGG85F8-iPyo7.png" /></figure><ul><li>Click on the wheel right besides your repository’s name to access the setting.</li><li>Activate the <em>Build only if .travis.yml is present</em> option.</li><li>You can also add environment variables for your tests.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fpMlVGDMbNXTCEfX.png" /></figure><ul><li>Add a file named <em>.travis.yml</em> and create your test configuration. For testing a php application with php 5.6 and 5.5 and be notified by email, you could write the following:</li></ul><pre>language: php</pre><pre>notifications: email: true</pre><pre>script: cd application/tests/ &amp;&amp; phpunit — coverage-text</pre><p>The <em>script</em> attribute tells travis where and what to execute in order to run your tests. You can find all the possible options for the <em>.travis.yml</em> file <a href="http://docs.travis-ci.com/user/customizing-the-build/">here</a>.</p><ul><li>In heroku, activate the <em>Wait for CI to pass before deploy</em> option.</li></ul><h4>What Should I Be Careful About ?</h4><p>As Edsger W. Dijkstra wrote in <em>Software Engineering Techniques, April 1970, p. 16. Report on a conference sponsored by the NATO Science Committee, Rome, Italy, 27–31 October 1969.</em> : <strong>Testing shows the presence, not the absence of bugs</strong>. What does it means ? Well, the efficiency of your tests depends of your efficiency to write good tests. If you only write trivial tests, they’ll never fail and they won’t show the presence of any bugs. Consequently, you have to challenge yourself when writing test in order to imagine all probable possibilities. Even then, it’s impossible to test each on every possibility by hand, you’ll have to turn on formal methods to do that.</p><h3>Summary</h3><p>In this entry, I described the deployment process we adopted at toolwatch. First, the source code is versioned on Github and Travis runs the unit test we wrote automatically for each and every commit. If all goes well, Heroku kicks in and pull your commit from Github in order to deploy your modification to your users.</p><p><em>Originally published at </em><a href="http://math.co.de/blog/toolwatch-deployment-process-github-travis-heroku/"><em>math.co.de</em></a><em> on August 12, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9337727d8a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/toolwatch/toolwatch-deployment-process-github-travis-and-heroku-c9337727d8a2">Toolwatch Deployment Process Github, Travis and Heroku</a> was originally published in <a href="https://medium.com/toolwatch">Toolwatch</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>