<?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 Alejandro Vidal Rodriguez on Medium]]></title>
        <description><![CDATA[Stories by Alejandro Vidal Rodriguez on Medium]]></description>
        <link>https://medium.com/@goofyahead?source=rss-b6ad7ae6e9c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*H9nms8TkNrckgpr5OeLRIw.jpeg</url>
            <title>Stories by Alejandro Vidal Rodriguez on Medium</title>
            <link>https://medium.com/@goofyahead?source=rss-b6ad7ae6e9c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:19:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@goofyahead/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[The world biggest hackathon!]]></title>
            <link>https://medium.com/@goofyahead/the-world-biggest-hackathon-2f9f632ac222?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f9f632ac222</guid>
            <category><![CDATA[mentoring]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hackathons]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 07:49:03 GMT</pubDate>
            <atom:updated>2018-08-09T07:49:03.741Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week I was invited as a mentor/judge to the biggest hackathon in the world in Jeddah (Saudi) and it was EPIC!</p><p>The hackathon theme was the <strong>Hajj</strong>, its a time in the year based on the lunar calendar where muslims from all around the world come to perform a pilgrimage on Saudi to a few sacred places, such as Mecca, which is the city where the Holy Kaaba.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*oJbQPqm932fTV6rAp2kbRA.jpeg" /><figcaption>This is also where all the muslims pray towards to, so every Mosque is facing this specific city.</figcaption></figure><p>To understand the size of the challenge you have to know that more that 2 M people come at the same time to perform this once in a lifetime experience and its expected that for 2030 this number will grow to 30 M.</p><p>The Rio olympic games hosted around 1.2 M people and the Russia world cup had around 1M visitors, so its like hosting a great logistic challenge every year and everyone want to move to the same place, so you can start to guess all the interesting problems to solve and its going to get harder and harder, so how technology can help to make this experience better for everyone?</p><p>This was my first time visiting Saudi Arabia and I had no idea on how to even apply for a visa, but after getting an invitation letter, recording my fingerprints and quite a lot paperwork I got mine just in time to fly from Dubai to Jeddah.</p><p>Jeddah is the city that is closer to Mecca and its an important entry point for all the pilgrims, a new airport is being finished in preparation for next year Hajj to be able to manage all the flights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qgPXBEBeYJWQGUn48vDcHA.png" /></figure><p>After a welcoming drink in the hotel and meeting some old friends from different GDG groups from the MENA region they drove us to the venue and it was HUGE!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-GEhr4x_sbKtC3kgJwiIA.jpeg" /></figure><p>Around 3000 developers from all around the world came to try to solve some pretty complex problems and get a chance to win the 2M SAR 1st prize.</p><p>There were 3 types of mentors:</p><ul><li>Hajj mentors that would share their experience in the pilgrimage, problems, data and experience.</li><li>Business mentors that would help the teams figure out the way their solutions could be either sustainable or even profitable.</li><li>Tech mentors that would help the teams to pick and use the best possible technical solution to fix a problem</li></ul><p>As a tech mentor, my work involved going to different teams to help with any technical questions. I also guided them on how to pitch their ideas and of course, challenged some assumptions. For example, it is quite likely that most of the pilgrims will either have really bad data connection or no roaming data because of how crowded the place will be.</p><p>It was amazing to meet some of the teams, the vibe was energizing with all these young participants eager to learn and fix things. Developers, designers, business people from all the globe in teams building solutions in 36 hours and ready to pitch them in 2 minutes.</p><p>The ideas kind of clustered in a few main tracks:</p><ul><li>Crowd management: when that many people move to the same place there is a huge need of organization and real time data could help in many ways.</li><li>Waste management: The cities get flooded with waste that can be difficult to clean in time.</li><li>Medical assistance: How to get to people in need in this super crowded events, get a fast triage and make the best use of the medical resources available.</li><li>Financial solutions: Most of the people have to change their currency on their country and then carry a lot of cash with all the risks and issues associated with it.</li><li>Communication solutions: Such a diverse crowd speaks a lot of languages and dialects and can get tricky to find a common way to speak or get directions.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IwkfhF71AtMswlHJNri95Q.jpeg" /></figure><p>Like this team from Algeria that where trying to solve the cash issue, they where trying to create a closed loop paying system. I asked them if they knew they could build a nice solution using blockchain to keep track of all the money and make a more resilient solution.</p><p>They had no idea how to do it, but instead of continuing with whatever they where going to develop, they asked me if I could teach them how it worked and explain it.</p><p>Around an hour later after sharing a few resources they decided that made a lot of sense for their project and combined it with their original idea. I was impressed with the spirit and energy that they had, that feeling of eating the world, eager to learn and grow it was just amazing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-uJAlNIBMBbymMRLLcTew.jpeg" /></figure><p>This other team wanted to help with crowd control. They decided to use a hardware bracelet that could create a mesh network to send signals to specific towers to collect data using a frequency band that would less saturated than wifi band.</p><p>All the amazing ideas, teams and insane passion, mixed with all the cultures and languages was the highlight for me. It was an amazing experience interacting with so many different people and sharing our love for solving problems using technology.</p><p>The panels including Steve Wozniak and Jimmy Wales were also really interesting and covered topics like entrepreneurship, tech and how it continuously changes the world and how we live in it.</p><p>An then the final day arrived and as a judge I was part of a panel that had to score each team after a 2 minutes pitch and pick only 5 out of 60. From this only 10 would be selected to pitch on the main stage, which mimicked a runway with its long stage and bright lights..</p><p>And the first finalist team jumps on the stage and I was amazed about how this young women from this Algerian team pitched, she delivered an idea to the audience, the judges in 3 minutes with such a confidence, body language and presence in the stage!</p><p>She even replied to the question of the judges with no doubts in a very polite and professional way, questions from Steve Wozniak, Jimmy Wales or the head for the Saudi federation of cybersecurity and programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*2LTW35J3rMr-MRhJ89pucw.jpeg" /><figcaption>They build a snapchat for Hajj with tailored security so pilgrims could share their experience with their family in an easy and secure way</figcaption></figure><p>And the winner of the hackathon was an all women team from Saudi that made an app that allowed the pilgrims to get directions and read important information translated without internet connection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*ZlIe3DIxovGQZENkwSZhAg.jpeg" /></figure><p>And my own output? Lots of friends made, learned about other cultures and religions and confirmed that there is a universal language that is all about the passion to build great things and fix great problems.</p><p>See you on the next one!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f9f632ac222" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get Beautiful Coverage Reports in your Android Projects!]]></title>
            <link>https://medium.com/android-news/get-beautiful-coverage-reports-in-your-android-projects-ce9ba281507f?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce9ba281507f</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[thought-leadership]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Tue, 26 Jun 2018 12:32:14 GMT</pubDate>
            <atom:updated>2018-07-23T08:47:44.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*bZcuMBJFdveXY5vbMfFJkg.png" /></figure><p>By <a href="https://medium.com/@goofyahead?source=post_header_lockup">Alejandro Vidal Rodriguez</a></p><p>There are several steps you can take to improve the quality of your code:</p><ul><li>Linter check highlights on IDE</li><li>Enforce a correct and clean architecture</li><li>Write unit tests for your business logic</li><li>Write the test before implementation</li></ul><p>But how can you track your code coverage in an easy and beautiful way?</p><p>We can now get coverage (on Android Studio) by: right clicking in our project → Run Tests with Coverage. This will output our code coverage metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*nL5uv_eKaWSBvi-E5rdTVg.png" /><figcaption>Right click → Run Tests with Coverage</figcaption></figure><p>This will then output a report with our current coverage. After a few clicks you’ll find your package:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qO4l_OPpRtb_3Ue_2Njk3w.png" /></figure><p>To avoid clicking around you can define a run/debug configuration under Android JUnit to specify your package and select a few include/exclude options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NaU0uFdEnCflYRgSNVvFFQ.png" /><figcaption>Selecting Options</figcaption></figure><p>But how we can exclude our data-binding classes, our activities, and things that our unit test coverage should not track? We want to have a metric that we care about, is something to keep an eye on, and that will keep our code with at least 60% of coverage.</p><p>Our old friend <a href="https://www.eclemma.org/jacoco/">JACOCO</a> (java code coverage) can help us get something easy to run, configured, and that can even send reports to our <a href="https://www.sonarqube.org/">SonarQube</a> to keep track of our code quality.</p><p>So, let’s add our dependencies:</p><pre>apply plugin: &#39;org.sonarqube&#39;<br>apply plugin: &#39;jacoco&#39;</pre><p>When we add the JACOCO plugin our unit tests will be inspected, and JACOCO will output a .exec file with all the information regarding our coverage.</p><p>We also want specific reports that are readable and can give us feedback really fast, so let’s make a report task for our code with our exclusion rules for Android:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e952ec2be60ab11f5906b1cc0ea43ea8/href">https://medium.com/media/e952ec2be60ab11f5906b1cc0ea43ea8/href</a></iframe><p>We will not unit test anything regarding the OS or UI, which means that we <strong>do not</strong> have any business logic in our activities, fragments, etc.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e27ab91105c734f8d2345eca995220fd/href">https://medium.com/media/e27ab91105c734f8d2345eca995220fd/href</a></iframe><p>Our coverage task depends on our tests, which will change their names depending on the flavors we defined for our project.</p><p>When the test runs, the .exec will be generated. Then, it will be used as <strong>input </strong>for our report task, will output xml files that we can use on our CIs, and an html website for human readable results.</p><p>The last task is just a shortcut, execute <strong>./gradlew getCoverage</strong> and then the test will run, a report will be generated, and the website will open with your results! 😎</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrCw5_RfraYcu1RISchpBw.png" /><figcaption>I really need to improve the coverage of my sample :D</figcaption></figure><p>Cool! What if we want to use those same rules so that our SonarQube reports use the same configuration that we used to get our nice coverage report website? We probably want to exclude the files that we are not focusing on from our SonarQube report in the coverage section, but we still want SonarQube to run the linter, bug checks, etc.</p><p>That’s what the sonar.coverage.exclusions property is for and that’s why we defined our exclusion array with a wildcard in the extension. This way we can iterate on it for this property and can match both .java and .class files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eae0f6a4be88d18d9e72ef267cb67985/href">https://medium.com/media/eae0f6a4be88d18d9e72ef267cb67985/href</a></iframe><p>Bam! A task that can be run by our CI (after the .exec is generated) which will give us a nice history of our code coverage in our SonarQube report.</p><p>You can even enforce minimum coverage in your JACOCO task in your gradle tasks!</p><p>How do you enforce your code coverage? Are there any rules you follow to keep your business logics tested and secure outside of the UI components? Let me know in the comments! Happy coding!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*HvU-9iUjzcQHaxl0pmBW9Q.png" /></figure><p><em>Alejandro (Alex) Rodriguez is the Engineering Director at the TribalScale Dubai office. For 8+ years, Alex has been delivering mobile apps and backend solutions for companies all around the world. He’s worked in Telefonica R&amp;D’s mobile department in Spain, a search engine company in San Francisco, NFC payment solutions in the Netherlands, and is now helping TribalScale’s engineering team build clean efficient software in Dubai. Alex is passionate about architecture, clean code, process, and people.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e491f%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href">https://medium.com/media/fedb9f91e907af2468a937c944ed32ab/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce9ba281507f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/get-beautiful-coverage-reports-in-your-android-projects-ce9ba281507f">Get Beautiful Coverage Reports in your Android Projects!</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing your app with dagger 2 and AndroidInjectionModule]]></title>
            <link>https://medium.com/android-news/testing-your-app-with-dagger-2-c91cdc0860fb?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c91cdc0860fb</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ci]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Tue, 04 Apr 2017 07:47:22 GMT</pubDate>
            <atom:updated>2017-04-05T09:02:51.365Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*LXsuZ1jyGFxKYfVBMTBkNg.jpeg" /></figure><p>We want to build our apps as decoupled as possible and injecting those dependencies help, but if that dependency injection is hurting the testing then we need to find a fix for it!</p><p>The latest <a href="https://github.com/google/dagger/releases">release</a> of dagger 2 (2.10) brings some new classes to fix some issues on android development.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91fd13f4934dbf9d282e2bca73b0dfc4/href">https://medium.com/media/91fd13f4934dbf9d282e2bca73b0dfc4/href</a></iframe><p>The AndroidInjectionModule helps handling the android framework classes like Activity, Fragment, Service and Broadcasts.</p><p>We will still follow the same concepts from dagger, we will still have modules to @provide stuff.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4bc74de6cc9980249eb06fb7799e8547/href">https://medium.com/media/4bc74de6cc9980249eb06fb7799e8547/href</a></iframe><p>This would be our Rest modules, Db modules, Navigation modules… I like to think of them as concepts, something that provides what is need to handle the cart, something that gives you what you need to share app content, the network layer communication, etc.</p><p>But there was one problem with the activity injection and testing, if the activity had @injects for the flumbolator TM it would also need to know the component that it was injecting too!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/855fccc5c711b05f0a10bfbeaf68fb2d/href">https://medium.com/media/855fccc5c711b05f0a10bfbeaf68fb2d/href</a></iframe><p>So if we wanted to test this activity with a mock or an specific implementation of the dependency we would have to test against an activity that extends our activity and override the injection.</p><p>Thanks to the new structure this is all the activity knows about its injector.</p><pre>@Override<br>protected void onCreate(Bundle savedInstanceState) {<br>    AndroidInjection.<em>inject</em>(this);<br>    super.onCreate(savedInstanceState);<br>}</pre><p>To achieve this we need to start creating subcomponents for each Activity:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf853f0a715c92423904b999a5161242/href">https://medium.com/media/bf853f0a715c92423904b999a5161242/href</a></iframe><p>This subcomponent can have its own module for things that only attach to this activity, like the presenter.</p><p>The important part is to extend from <strong><em>AndroidInjector&lt;YourActivity&gt; </em></strong>and provide a builder annotated with<strong><em> @Subcomponent.Builder</em></strong></p><p>In the modules definition you can define all the modules that this activity is going to require, for us this is the super fantastic frumbolator module (yes I know that I call it different every time :)</p><p>How does it know dagger where to get the injection for MainActivity if the activity is just calling AndroidInjection.inject(this)?</p><p>With a map that relates the class with the builder, we will call this module the <strong><em>BindingModule</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6e97fee8b4e2bc08804cdb3024e99e7/href">https://medium.com/media/c6e97fee8b4e2bc08804cdb3024e99e7/href</a></iframe><p>with this approach we need to define the subcomponents and use the @binds and @IntoMap annotations, this is just like saying in an old java map put(Activity.class, Binder method) so for each class we know which builder needs to be called.</p><p>And where is this map being added? in the AppComponent</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c044af38ac42931708d6adef883556a2/href">https://medium.com/media/c044af38ac42931708d6adef883556a2/href</a></iframe><p>And last but not least we need our Application class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45b0b37f8c30a336b37da20293b3b723/href">https://medium.com/media/45b0b37f8c30a336b37da20293b3b723/href</a></iframe><p>we have the HasDispatchingActivityInjector interface and we need to return it and we inject ourselves in the DaggerMyApplicationcomponent (remember this is a generated class so you need to rebuild)</p><p>Ok but why all these changes, its true that I don’t need to write some boilerplate on the activity code but now I have to remember to add it to the map binding the activity submodule, etc (luckily the errors are quite informative and helps a lot in these cases)</p><p>Well the reason is that now we can do proper testing now!</p><p>We are going to use Mockito, Roboelectric and Junit.</p><p>The goal is to test a public method in the activity without testing the Injected flumbolator, so we want to have a mock that returns something that we control and do fast testing (some see the light on TDD again)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d9eb8631a7e3fff871777c7074d27fc/href">https://medium.com/media/8d9eb8631a7e3fff871777c7074d27fc/href</a></iframe><p>As you may have notice with roboelectric we can set the application class that we are going to use, yes that is our entry point!</p><p>There is one issue that test project does not find the generated classes by dagger so you need to add this to your gradle file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/092b967e7a1e634f1fe46c8fb1b2b94a/href">https://medium.com/media/092b967e7a1e634f1fe46c8fb1b2b94a/href</a></iframe><p>With that fix now your test files will be able to find generated classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e54571df85869383e309f1496659a29/href">https://medium.com/media/9e54571df85869383e309f1496659a29/href</a></iframe><p>Those ugly print lines are to see them in test runner and realize that you can change between the real application and the test with mocks or between mocks :)</p><p>Ok so on this testComponent we define our TestBindingModule to provide TestSubComponents that will use TestModules, yes I know, sounds a little bit too much but its worth it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/13d9dbef941a8bea16c1aec315cb0d42/href">https://medium.com/media/13d9dbef941a8bea16c1aec315cb0d42/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/85b65d3ca79d6d12b40472eae8af8976/href">https://medium.com/media/85b65d3ca79d6d12b40472eae8af8976/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6f6194c0564eb03589e75fac731bae3/href">https://medium.com/media/b6f6194c0564eb03589e75fac731bae3/href</a></iframe><p>and the testModule that provides the mock flumbulator TM.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/841c8f57c335779657c4d871ddbce3ee/href">https://medium.com/media/841c8f57c335779657c4d871ddbce3ee/href</a></iframe><p>Now if we run our TestMainActivity it will work with the mock Flumbolator and life will be wonderful, go and make those test that can be run in your CI without an emulator and hey the next time you fix a bug create a test for it!</p><p>Clone, fork and make PR on the sample project <a href="https://github.com/goofyahead/dagger2structureSample">here</a> :)</p><p>Share your thoughts in the comments! And if you like this story and think it would be helpful for others click on like and follow me for future dev stories.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e491f%3Fas_embed%3Dtrue&amp;url=https%3A%2F%2Fupscri.be%2F3e491f%2F&amp;image=https%3A%2F%2Fupscri.be%2Fmedia%2Fform.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ae57c1b4448392f65f474b01a127fbf/href">https://medium.com/media/2ae57c1b4448392f65f474b01a127fbf/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c91cdc0860fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-news/testing-your-app-with-dagger-2-c91cdc0860fb">Testing your app with dagger 2 and AndroidInjectionModule</a> was originally published in <a href="https://medium.com/android-news">AndroidPub</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debouncing EditText with RxAndroid]]></title>
            <link>https://medium.com/@goofyahead/debouncing-edittext-with-rxandroid-894e15da1012?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/894e15da1012</guid>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[rxandroid]]></category>
            <category><![CDATA[lambda]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Thu, 15 Sep 2016 09:45:52 GMT</pubDate>
            <atom:updated>2016-09-15T09:45:52.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rdI5LbKvLOi9pvv0_Wn9LA.png" /></figure><p>Typical case, several clics on a button, typing fast on a search box… Those are problems that we have to take care on front end for a better smooth UX.</p><p>So lets implement it on android, its also a perfect time to start with Rx and observable patterns.</p><p>First dependencies needed:</p><p>project gradle</p><pre>...</pre><pre>dependencies {<br>    classpath <strong>&#39;com.android.tools.build:gradle:2.2.0-rc1&#39;<br>    </strong>classpath <strong>&#39;me.tatarka:gradle-retrolambda:3.2.5&#39;</strong></pre><pre>...</pre><p>App gradle</p><pre>//on top of app graddle<br>apply <strong>plugin</strong>: <strong>&#39;me.tatarka.retrolambda&#39;</strong></pre><pre>...</pre><pre>compile <strong>&#39;io.reactivex:rxandroid:1.2.1&#39;<br></strong>compile <strong>&#39;io.reactivex:rxjava:1.1.6&#39;<br></strong>compile <strong>&#39;com.jakewharton.rxbinding:rxbinding:0.4.0&#39;<br></strong>compile <strong>&#39;com.jakewharton.rxbinding:rxbinding-design:0.4.0&#39;</strong></pre><pre>// these are for retrolambda and streams api<br>compile <strong>&#39;com.annimon:stream:1.1.2&#39;</strong></pre><p>These are retrolambda and stream api for android, Rx java dependencies, Rx for android and UI bindings from jakewharton :)</p><p>Thats nice but show me the code!</p><pre>Observable&lt;String&gt; obs = RxTextView.<em>textChanges</em>(<strong>searchBox</strong>).filter(charSequence -&gt; charSequence.length() &gt; 3).debounce(300, TimeUnit.<strong><em>MILLISECONDS</em></strong>).map(charSequence -&gt;  charSequence.toString());<br><br>obs.subscribe(string -&gt; {<br>    Log.<em>d</em>(<strong>TAG</strong>, <strong>&quot;debounced &quot; </strong>+ string);<br>    startIntentService(<strong>prefs</strong>.getLastLocation().getCountry() + <strong>&quot;, &quot; </strong>+ string);<br>});</pre><p>Yay! with just a few lines we got our debounced EditText that will save us some calls to our service and network calls :)</p><p>If you have any questions just comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=894e15da1012" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streams, lambdas and compatibility in android!]]></title>
            <link>https://medium.com/@goofyahead/streams-lambdas-and-compatibility-in-android-4750a8626d78?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4750a8626d78</guid>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Mon, 05 Sep 2016 09:17:56 GMT</pubDate>
            <atom:updated>2016-09-05T09:17:56.166Z</atom:updated>
            <content:encoded><![CDATA[<p>Well since the last GOOGLE I/O where support of some java 8 api features where announced.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FB08iLAtS3AQ%3Fstart%3D1694%26feature%3Doembed%26start%3D1694&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DB08iLAtS3AQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FB08iLAtS3AQ%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c83e7a387645a4130a8030460bdd8250/href">https://medium.com/media/c83e7a387645a4130a8030460bdd8250/href</a></iframe><p>I’ve been looking to introduce in my projects lambdas and specifically the stream API, with the new JACK compiler and java 8 support this features where enabled for our projects and with back portability till 2.3!!! :D :D</p><p>BUT you cannot use some apt plugins and there are issues with java annotations, so not so pretty, should we give up stuff like retrofit? while the plugin gets fixed or the JACK team allows this to work out of the box.</p><ul><li><a href="https://code.google.com/p/android/issues/detail?id=203850">https://code.google.com/p/android/issues/detail?id=203850</a></li></ul><p>With some bug reporting and work from the guy that made the apt plugin and the google guys the 2.2 version of gradle seems to support it.</p><p><a href="http://android-developers.blogspot.com.es/2016/05/android-studio-22-preview-new-ui.html">Android Studio 2.2 Preview - New UI Designer &amp; Constraint Layout | Android Developers Blog</a></p><p>With these you can use some of the java 8 functionality but with a minimum SDK 21</p><p>UPDATE: gradle build tool is on RC classpath <strong>‘com.android.tools.build:gradle:2.2.0-rc1’</strong></p><p>With this update you can get rid of the pre procesing plugins like the ones you needed for butterknife or dagger.</p><p>But what do we want? We want this</p><pre>Stream.<em>of</em>(<strong>mAdapter</strong>.getLikes()).forEach(category -&gt; {<br>    <strong>analytics</strong>.setUserProperty(Utils.<strong><em>ANALYTICS_USER_LIKES</em></strong>,     category.getName());<br>});</pre><p>Its really useful to get lambdas with the stream API, to get these on 14+ we need 2 libraries.</p><p>on build.gradle:</p><pre>classpath <strong>&#39;me.tatarka:gradle-retrolambda:3.2.5&#39;</strong></pre><p>on your app gradle:</p><pre>apply <strong>plugin</strong>: <strong>&#39;me.tatarka.retrolambda&#39;</strong></pre><pre>...</pre><pre>compile <strong>&#39;com.annimon:stream:1.1.2&#39;</strong></pre><p>with this two libs, retro lambda and the stream lib we can now filter, map, iterate with anonymous lambda functions.</p><p>:D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4750a8626d78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shared element transitions on Android 21+]]></title>
            <link>https://medium.com/@goofyahead/shared-element-transitions-on-android-21-7d694658e112?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d694658e112</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Tue, 02 Aug 2016 14:40:03 GMT</pubDate>
            <atom:updated>2016-08-02T14:40:03.615Z</atom:updated>
            <content:encoded><![CDATA[<p>Aren’t those beautiful transitions from material awesome?</p><p><a href="https://developer.android.com/training/material/animations.html">Defining Custom Animations | Android Developers</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ebM0uZk7ocT8WasgeUSPRQ.gif" /></figure><p>So how we do achieve such a smooth transition, that clearly shows the user that is watching that content expanded?</p><p>Well there are several issues, the first one is that all these transitions with shared content are 21+ so right now around a 40% of the user base can’t see them… There is no back compatibility port from the official android libs, there are some projects that allow it with code and performance.</p><p>Links to pre L libs:</p><ul><li><a href="https://github.com/takahirom/PreLollipopTransition">https://github.com/takahirom/PreLollipopTransition</a></li><li><a href="https://github.com/andkulikov/transitions-everywhere">https://github.com/andkulikov/transitions-everywhere</a></li><li><a href="https://github.com/lgvalle/Material-Animations">https://github.com/lgvalle/Material-Animations</a></li></ul><p>But for now lets focus on that 60% and growing user base that have 5.0+ android phones.</p><p>The key is the shared element, so activity or fragment A share a resource with fragment or activity B and from there is a basic transition from x,y to x1,y1 with size taken into account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5EWmdf5Dyq0MQNGhfoXoyw.png" /></figure><p>We are going to make 2 fragments share a picture to show a detail view of an item that will let us know that we are just taking a peek of the info but we are still on the same flow.</p><p>we will need a transition that will be used to defined origin and ending positions that we will create under transitions in res folder.</p><p><em>&lt;?</em><strong>xml version=”1.0&quot; encoding=”utf-8&quot;</strong><em>?&gt;<br></em>&lt;<strong>transitionSet xmlns:android=”http://schemas.android.com/apk/res/android&quot;</strong>&gt;<br> &lt;<strong>changeTransform </strong>/&gt;<br> &lt;<strong>changeBounds </strong>/&gt;<br>&lt;/<strong>transitionSet</strong>&gt;</p><p>For this example we are going to link a dynamic content item from a list to a detailed view.</p><p>In the adapter for each item we need to set the transition name of whatever we want to share and animate, so on the view in this case an image we set it, in your view instantiation item:</p><pre><strong>if </strong>(Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= Build.VERSION_CODES.<strong><em>LOLLIPOP</em></strong>) {<br>    image.setTransitionName(<strong>&quot;transition&quot; </strong>+ position);<br>}</pre><p>In my case I do handle the click event in the Activity that holds the fragment with a listener that will add the extra params to the fragment transaction.</p><pre><strong>if </strong>(Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= Build.VERSION_CODES.<strong><em>LOLLIPOP</em></strong>) {<br>    <strong>inviteSelectPlanFragment</strong>.setSharedElementReturnTransition(TransitionInflater.<em>from</em>(<br>            <strong>this</strong>).inflateTransition(R.transition.<strong><em>change_image_trans</em></strong>));<br>    <strong>inviteSelectPlanFragment</strong>.setExitTransition(TransitionInflater.<em>from</em>(<br>            <strong>this</strong>).inflateTransition(android.R.transition.<strong><em>fade</em></strong>));<br><br>    fragment.setSharedElementEnterTransition(TransitionInflater.<em>from</em>(<br>            <strong>this</strong>).inflateTransition(R.transition.<strong><em>change_image_trans</em></strong>));<br>    fragment.setEnterTransition(TransitionInflater.<em>from</em>(<br>            <strong>this</strong>).inflateTransition(android.R.transition.<strong><em>fade</em></strong>));<br>}</pre><p>And we also need to add in the bundle the transition name and the shared resource too:</p><pre>Bundle bundle = <strong>new </strong>Bundle();<br><strong>if </strong>(Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= Build.VERSION_CODES.<strong><em>LOLLIPOP</em></strong>) {<br>    bundle.putString(<strong>&quot;TRANS_NAME&quot;</strong>, picture.getTransitionName());<br>}<br>bundle.putParcelable(<strong>&quot;IMAGE&quot;</strong>, ((BitmapDrawable) picture.getDrawable()).getBitmap());<br>fragment.setArguments(bundle);<br><br><strong>if </strong>(Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= Build.VERSION_CODES.<strong><em>LOLLIPOP</em></strong>) {<br>    <strong>fm</strong>.beginTransaction()<br>            .replace(R.id.<strong><em>invite_activity_fragment_holder</em></strong>, fragment)<br>            .addToBackStack(<strong>&quot;detailed&quot;</strong>)<br>            .addSharedElement(picture, picture.getTransitionName())<br>            .commit();<br>} <strong>else </strong>{<br>    <strong>fm</strong>.beginTransaction()<br>            .replace(R.id.<strong><em>invite_activity_fragment_holder</em></strong>, fragment)<br>            .addToBackStack(<strong>&quot;detailed&quot;</strong>)<br>            .commit();<br>}</pre><p>And on the receiving fragment just handle the info and set it:</p><pre>@Override<br><strong>public </strong>View onCreateView(LayoutInflater inflater, ViewGroup container,<br>                         Bundle savedInstanceState) {<br>    <em>// Inflate the layout for this fragment<br>    </em>((TribooAplication) getActivity().getApplication()).getApiComponent().inject(<strong>this</strong>);<br>    View view = inflater.inflate(R.layout.<strong><em>fragment_featured_plan_detail</em></strong>, container, <strong>false</strong>);<br>    ButterKnife.<em>bind</em>(<strong>this</strong>, view);<br><br>    <strong>if </strong>(Build.VERSION.<strong><em>SDK_INT </em></strong>&gt;= Build.VERSION_CODES.<strong><em>LOLLIPOP</em></strong>) {<br>        Log.<em>d</em>(<strong><em>TAG</em></strong>, <strong>&quot;transition name &quot; </strong>+ getArguments().getString(<strong>&quot;TRANS_NAME&quot;</strong>));<br>        view.findViewById(R.id.<strong><em>featured_datail_plan_image</em></strong>).setTransitionName(getArguments().getString(<strong>&quot;TRANS_NAME&quot;</strong>));<br>    }<br>    ((ImageView)view.findViewById(R.id.<strong><em>featured_datail_plan_image</em></strong>)).setImageBitmap((Bitmap) getArguments().getParcelable(<strong>&quot;IMAGE&quot;</strong>));<br>    <strong>return </strong>view;<br>}</pre><p>And you obtain a beautiful animation that works on 5.0+ devices, note that to get the back animation to its tile you need to handle the state of the fragment with saveState.</p><p>In my humble opinion it generates way too much code to handle the SDK version and should be included in appCompat library to handle these things or using a wrapper.</p><p>I will try out the libs out there that probably do this just to avoid the SDK check.</p><p>Useful resources and links:</p><ul><li><a href="http://www.androidauthority.com/using-shared-element-transitions-activities-fragments-631996/">http://www.androidauthority.com/using-shared-element-transitions-activities-fragments-631996/</a></li><li><a href="https://guides.codepath.com/android/Shared-Element-Activity-Transition">https://guides.codepath.com/android/Shared-Element-Activity-Transition</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d694658e112" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dependency injection in Android]]></title>
            <link>https://medium.com/@goofyahead/dependency-injection-in-android-2321f0256756?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2321f0256756</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Thu, 21 Jul 2016 09:42:51 GMT</pubDate>
            <atom:updated>2016-07-21T09:42:51.561Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been some time since RoboGuice was the dependency injection library to use, based on Guice it made it possible through reflection with its drawbacks.</p><p>Now is all up to two sharp friends! Dagger 2&amp; Butterknife</p><ul><li><a href="http://google.github.io/dagger/">Dagger ‡ A fast dependency injector for Android and Java.</a></li><li><a href="http://jakewharton.github.io/butterknife/">Butter Knife</a></li></ul><p>Check the latest releases on MVN.</p><ul><li><a href="http://mvnrepository.com/artifact/com.google.dagger/dagger">http://mvnrepository.com/artifact/com.google.dagger/dagger</a></li><li><a href="http://mvnrepository.com/artifact/com.google.dagger/dagger-compiler">http://mvnrepository.com/artifact/com.google.dagger/dagger-compiler</a></li></ul><p>Both libraries are a must in android dev and they are really easy to use and come with a lot of handy stuff.</p><p>Project.graddle</p><pre>dependencies {<br>        classpath <strong>&#39;com.android.tools.build:gradle:2.2.0-alpha5&#39;<br>} //maybe when you read this are stable versions :)</strong></pre><p>The 2.2 builder allows now annotation procesor keyword so the apt plugin is no longer needed, no downsides in the testing so far and allows Jack building in the future with Java8 when its more stable :)</p><p>App.graddle</p><pre>annotationProcessor <strong>&#39;com.google.dagger:dagger-compiler:2.5&#39;<br></strong>compile <strong>&#39;com.google.dagger:dagger:2.5&#39;<br></strong>provided <strong>&#39;javax.annotation:jsr250-api:1.0&#39;<br></strong>annotationProcessor <strong>&#39;com.jakewharton:butterknife-compiler:8.1.0&#39;</strong></pre><p>Dagger now uses modules to define different scopes for injectable instances, lets build an API module to start.</p><p>We first define a class that will be the provider of some type, lets create the one that lets us mess with our API.</p><p>ApiModule</p><pre>@Module<br><strong>public class </strong>ApiModule {<br>    <strong>private final </strong>Context <strong>mContext</strong>;<br><br>    <strong>public </strong>ApiModule(Context context) {<br>        <strong>this</strong>.<strong>mContext </strong>= context;<br>    }<br><br>    @Provides<br>    @Singleton<br>    RequestQueue provideQueue() {<br>        <strong>return </strong>Volley.<em>newRequestQueue</em>(<strong>mContext</strong>);<br>    }<br><br>    @Provides<br>    @Singleton<br>    ImageLoader provideImageLoader(RequestQueue mRequestQueue) {<br>        <strong>return new </strong>ImageLoader(mRequestQueue, <strong>new </strong>ImageLoader.ImageCache() {<br>            <strong>private final </strong>LruCache&lt;String, Bitmap&gt; <strong>cache </strong>= <strong>new </strong>LruCache&lt;&gt;(20);<br><br>            @Override<br>            <strong>public </strong>Bitmap getBitmap(String url) {<br>                <strong>return cache</strong>.get(url);<br>            }<br><br>            @Override<br>            <strong>public void </strong>putBitmap(String url, Bitmap bitmap) {<br>                <strong>cache</strong>.put(url, bitmap);<br>            }<br>        });<br>    }<br><br>    @Provides<br>    @Singleton<br>    YourApiInterface provideApi() {<br>        <strong>return new </strong>Retrofit.Builder().baseUrl(<strong>mContext</strong>.getString(R.string.<strong><em>apiEndPoint</em></strong>)).build().create(YourApiInterface.<strong>class</strong>);<br>    }<br>}</pre><p>This module will provide the retrofit endpoint and the imageLoaderQueue in our app.</p><p>The new thing in Dagger 2 is that now we need to define a component, which is similar to de inject { someactivity.class } that we used to set in the module.</p><p>Our ApiComponent interface:</p><pre>@Singleton<br>@Component( modules = {ApiModule.<strong>class</strong>})<br><strong>public interface </strong>ApiComponent {<br>    <strong>void </strong>inject(MainActivity activity);<br>}</pre><p>In this case we are just aggregating one Module, but now makes sense to aggregate in components the api and the network modules for example in one NetworkModule.</p><p>And now our Application file:</p><pre><strong>public class </strong>YourApplication <strong>extends </strong>Application {<br>    <strong>private </strong>ApiComponent <strong>apiComponent</strong>;<br><br>    @Override<br>    <strong>public void </strong>onCreate() {<br>        <strong>super</strong>.onCreate();<br><br>        <em>// Dagger%COMPONENT_NAME%<br>        </em><strong>apiComponent </strong>= DaggerApiComponent.<em>builder</em>()<br>                .apiModule(<strong>new </strong>ApiModule(<strong>this</strong>))<br>                .build();<br>    }<br><br>    <strong>public </strong>ApiComponent getApiComponent() {<br>        <strong>return apiComponent</strong>;<br>    }<br>}</pre><p>Use it everywhere! MainActivity.java</p><pre>@Inject<br>YourApiInterface <strong>api</strong>;<br><br>@BindView(R.id.<strong><em>view_pager_holder</em></strong>)<br>ViewPager <strong>pager</strong>;<br>@BindView(R.id.<strong><em>tab_holder</em></strong>)<br>TabLayout <strong>tabHolder</strong>;<br><br>@Override<br><strong>protected void </strong>onCreate(Bundle savedInstanceState) {<br>    <strong>super</strong>.onCreate(savedInstanceState);<br>    setContentView(R.layout.<strong><em>activity_main</em></strong>);<br><br>    ButterKnife.<em>bind</em>(<strong>this</strong>);<br>    ((YourAplication) getApplication()).getApiComponent().inject(<strong>this</strong>);</pre><p>And with this we have up and running our graddle 2 with code generation in our android project.</p><p>Refs:</p><ul><li><a href="https://guides.codepath.com/android/Dependency-Injection-with-Dagger-2">https://guides.codepath.com/android/Dependency-Injection-with-Dagger-2</a></li><li><a href="https://blog.gouline.net/dagger-2-even-sharper-less-square-b52101863542#.l28slvicw">https://blog.gouline.net/dagger-2-even-sharper-less-square-b52101863542#.l28slvicw</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2321f0256756" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keep your Package.json updated!]]></title>
            <link>https://medium.com/@goofyahead/keep-your-package-json-updated-fefdcc893a41?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/fefdcc893a41</guid>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Tue, 19 Jul 2016 11:12:20 GMT</pubDate>
            <atom:updated>2016-07-19T11:12:20.584Z</atom:updated>
            <content:encoded><![CDATA[<p>This global package can check and update your package.json and keep it up to date in a second!</p><p><a href="https://www.npmjs.com/package/npm-check-updates">npm-check-updates</a></p><p>Its now another great tool to keep on your node.js projects :) so give it a try!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fefdcc893a41" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Today, logging :)]]></title>
            <link>https://medium.com/@goofyahead/today-logging-a5ccb75c0fc2?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5ccb75c0fc2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[sailsjs]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Mon, 11 Jul 2016 16:12:54 GMT</pubDate>
            <atom:updated>2016-07-11T16:12:54.848Z</atom:updated>
            <content:encoded><![CDATA[<p>Server is up &amp; running and logs are useful for debugging and do post mortem checks, but now I can have more than one instance managing requests and all the logs are at the same level, some of them I don’t care about in production.</p><p>Pick a new logger instead of building one, <strong>bunyan vs winston vs log4js</strong></p><p>I decided to go with bunyan to organize the logs for now but could not make a simple integration with sails, due to an error given on log configuration, the checks on the initialization look for a .log() method that bunyan does not expose, so winston it is!</p><pre>/**<br> * Built-in Log Configuration<br> * (sails.config.log)<br> *<br> * Configure the log level for your app, as well as the transport<br> * (Underneath the covers, Sails uses Winston for logging, which<br> * allows for some pretty neat custom transports/adapters for log messages)<br> *<br> * For more information on the Sails logger, check out:<br> * <a href="http://sailsjs.org/#/documentation/concepts/Logging">http://sailsjs.org/#/documentation/concepts/Logging</a><br> */<br>var winston = require(&#39;winston&#39;);<br>var customLogger = new winston.Logger();</pre><pre>customLogger.add(winston.transports.Console, {<br>  level: &#39;debug&#39;,<br>  colorize: true<br>});</pre><pre>customLogger.add(winston.transports.File, {<br>  level: &#39;error&#39;,<br>  filename: &#39;filename.log&#39;,<br>  json: false<br>});</pre><pre>module.exports.log = {</pre><pre>custom: customLogger,<br>  level: &#39;silly&#39;,<br>  inspect: false</pre><pre>};</pre><p>It turns out is not that simple to have winston take care off all the logging from sails you can check out some ongoing issues.</p><ul><li><a href="https://github.com/balderdashy/captains-log/issues/16#issuecomment-169890710">https://github.com/balderdashy/captains-log/issues/16#issuecomment-169890710</a></li><li><a href="https://github.com/balderdashy/sails/issues/2695">https://github.com/balderdashy/sails/issues/2695</a></li></ul><p>So now I can start changing all the console.log(‘something’) to different levels like debug, warn or error and set the level of verbosity on the development or production configuration files that will override the initial configuration (On startup till the config is set you will see initial log set level, IE logs on services)</p><pre>// config/env/development</pre><pre>log : {<br>    level : &#39;debug&#39; // for development, set to warn on prod<br>}</pre><p>And now what can we use for logs aggregation, reporting and search? There are several options:</p><ul><li>ELK: Elastic Logstash Kibana</li><li>Loggly (Service)</li></ul><p>With the new logs now seems more likely to follow errors and set levels in logging :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5ccb75c0fc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CI?]]></title>
            <link>https://medium.com/@goofyahead/so-ci-441a32225c44?source=rss-b6ad7ae6e9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/441a32225c44</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[sailsjs]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Alejandro Vidal Rodriguez]]></dc:creator>
            <pubDate>Tue, 28 Jun 2016 15:04:33 GMT</pubDate>
            <atom:updated>2016-07-12T09:16:45.757Z</atom:updated>
            <content:encoded><![CDATA[<p>Well it’s been a week checking out the code and the different repositories in the company, seems like if you let us developers work alone on a project we tend to push to master without hesitation and start running production code on heroku without any kind of development test environment…</p><p>So it’s time to put again those github repos into git flow!</p><p><a href="http://nvie.com/posts/a-successful-git-branching-model/">A successful Git branching model</a></p><p>But what should I do to avoid my future self from committing to master without tests? Jenkins needs to be up &amp; watching.</p><p>After some thought using Travis-CI did not want to spend the monthly fee, so I used this bitnami ready jenkins instance that can be deployed on AWS:</p><p><a href="https://bitnami.com/stack/jenkins">Jenkins</a></p><p>After installation you can log in with the username “user” and the generated password that is visible in the logs of the instance.</p><p>In our case we needed the nodejs plugin that you must follow carefully the installation steps :)</p><p><a href="https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin">NodeJS Plugin</a></p><p>But the run node script was not working for me and I manually installed globally the mocha bin, also setting it on the package.json to check on the node_modules folder could help.</p><p>So one of the issues was that I installed node &amp; npm using</p><pre>sudo apt-get install nodejs npm</pre><p>which lead that npm install had no access to the workspace folder and the build failed… same issue with mocha install, so install node the right way</p><p><a href="https://github.com/creationix/nvm">nvm-sh/nvm</a></p><pre>nvm install 4.4.6 //use current version :)</pre><p>After a few tries I decided to go with the LTS node version 4.4.6 and everything started to work, now we have to export the test results in an XML format that jenkins can understand.</p><p>Found this mocha wrapper that generates the XUNIT format and the coverage results.</p><p><a href="https://github.com/stjohnjohnson/jenkins-mocha">stjohnjohnson/jenkins-mocha</a></p><p>Everything works and test are passed and failed :) a very good place to start.</p><p>So now I want to add the github webhooks for each merge on the development branch, add the github plugin and configure the webhook on the repo and each change will generate a build and test, now lets just build when a change in development is made (merge from a feature branch) and generate a tag if build was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*DwNK4Tam7ZDwAAt4_wtDtg.png" /></figure><p>Additional link and resources:</p><ul><li><a href="https://strongloop.com/strongblog/roll-your-own-node-js-ci-server-with-jenkins-part-1/">https://strongloop.com/strongblog/roll-your-own-node-js-ci-server-with-jenkins-part-1/</a></li><li><a href="https://blog.dylants.com/2013/06/21/jenkins-and-node/">https://blog.dylants.com/2013/06/21/jenkins-and-node/</a></li><li><a href="http://www.nailedtothex.org/roller/kyle/entry/configuring-automatic-push-by-successfully">http://www.nailedtothex.org/roller/kyle/entry/configuring-automatic-push-by-successfully</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=441a32225c44" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>