<?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 Nahuel A. Verón on Medium]]></title>
        <description><![CDATA[Stories by Nahuel A. Verón on Medium]]></description>
        <link>https://medium.com/@Negan1911?source=rss-9dbc9cd203ca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*zN9WQuogv-4pKg1ta8NhTA.jpeg</url>
            <title>Stories by Nahuel A. Verón on Medium</title>
            <link>https://medium.com/@Negan1911?source=rss-9dbc9cd203ca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:22:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Negan1911/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[Three.js: WebGL for Humans]]></title>
            <link>https://medium.com/@Negan1911/three-js-webgl-for-humans-21753044bb2f?source=rss-9dbc9cd203ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/21753044bb2f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[webgl]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Nahuel A. Verón]]></dc:creator>
            <pubDate>Wed, 05 Jul 2017 12:06:09 GMT</pubDate>
            <atom:updated>2017-07-05T12:06:09.895Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O7ttrU2PqHXwPYni8RSA4w.png" /></figure><p>As Web developers, we are always adapting to changes. Our primary language, Javascript, has evolved from being a limited language to handling DOM modifications and form validations to a language that allows us to perform outstanding tasks, such as reading the sensors of a battery, accelerometer or gyroscope to rendering 3D graphics and interacting with them.</p><h3>So, what is WebGL?</h3><p>WebGL is an API available on browsers that allows us to render graphics just like most games and 3D software do with OpenGL or DirectX. In detail, WebGL is based on OpenGL ES 2.0. The “ES” means that it’s the version for mobile phones, which has differences with the desktop version for performance’s sake.</p><p>As you might already know, when someone starts creating a game or 3D animation, they don’t write it directly for OpenGL. Some people use an Engine and some people use a Graphic Software that can handle it, because writing Directly for OpenGL implies having low level considerations of the hardware, really well acknowledge of math and most important is a overkill for what we&#39;re trying to build. All of this applies for WebGL too.</p><pre>uniform mat4 u_worldViewProjection;<br>uniform vec3 u_lightWorldPos;<br>uniform mat4 u_world;<br>uniform mat4 u_viewInverse;<br>uniform mat4 u_worldInverseTranspose;<br><br>attribute vec4 a_position;<br>attribute vec3 a_normal;<br>attribute vec2 a_texcoord;<br><br>varying vec4 v_position;<br>varying vec2 v_texCoord;<br>varying vec3 v_normal;<br>varying vec3 v_surfaceToLight;<br>varying vec3 v_surfaceToView;<br><br>void main() {<br>  v_texCoord = a_texcoord;<br>  v_position = (u_worldViewProjection * a_position);<br>  v_normal = (u_worldInverseTranspose * vec4(a_normal, 0)).xyz;<br>  v_surfaceToLight = u_lightWorldPos - (u_world * a_position).xyz;<br>  v_surfaceToView = (u_viewInverse[3] - (u_world * a_position)).xyz;<br>  gl_Position = v_position;<br>}</pre><p>Above you can see an example of the code needed to run a small sample, this subset is called &quot;Vertex Shader&quot; and you&#39;ll need the &quot;Fragment Shader&quot; and Javascript &amp; Html to wire it up. I am not going to aim to do this right now, even if what you have in mind is to draw figures (which is basically the idea behind Webgl), you shouldn’t do it. But if you want to create your own Engine/Library, or you already know something about OpenGL, you can check out <a href="https://webglfundamentals.org/webgl/lessons/webgl-less-code-more-fun.html">this link</a> for more information:</p><p>Ok, having in mind that writing for WebGL directly is unreliable for most of our practical uses, we had to find an alternative, and this is where Three.js kicks in.</p><h3>What is Three.js and what does it offer us?</h3><p>Three.js is a Javascript 3D library, which provides us with canvas, svg, CSS3D and <strong>WebGL</strong> Renderers to render whatever we want to put in the screen.</p><p>This library is built in a way that it&#39;s familiar for the people that have worked with 3D software, like blender. Basically using a Renderer, a Scene, a Camera and Mesh Objects we can describe what the user will see.</p><p>The basic &quot;Hello World&quot; here is a spinning cube, so let&#39;s do it:</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fcodepen.io%2Fnegan1911%2Fpen%2FLyyQNz%2F&amp;src=https%3A%2F%2Fcodepen.io%2Fnegan1911%2Fembed%2Fpreview%2FLyyQNz%3Fheight%3D600%26slug-hash%3DLyyQNz%26default-tabs%3Djs%2Cresult%26host%3Dhttp%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;type=text%2Fhtml&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8d87e5bfeadd2204b798a83dd1a7558/href">https://medium.com/media/d8d87e5bfeadd2204b798a83dd1a7558/href</a></iframe><h3>Renderers, Cameras and Scene</h3><p>I&#39;m going to show a description about what I did above, with some small information about how to start with this.</p><h4>Renderers:</h4><p>Basically, we have an engine that will make the content appear on the screen allowing us to take one of the existent ones (WebGL on this case) set up the size and give us a DOMElement, which we&#39;ll use to tie the render onto the HTML.</p><pre>// Create and Set our Renderer<br>const renderer = new THREE.WebGLRenderer();<br>renderer.setSize(window.innerWidth, window.innerHeight);<br>document.body.appendChild(renderer.domElement);</pre><p>Later, when our scene and camera are ready, we&#39;ll trigger a render. This could happen once (just an only call) or inside a function called by requestAnimationFrame (which will render on each frame available, more likely to be used).</p><pre>// Finally, we render in the screen<br>// A key point here, is to see how the render connects <br>//the scene &amp; camera<br>renderer.render(scene, camera);</pre><h4>Cameras:</h4><p>The camera aims to give information to the renderer about what should render from the scene and how. We have a few cameras available but we&#39;ll focus on Two currently <a href="https://threejs.org/docs/index.html#api/cameras/PerspectiveCamera">PerspectiveCamera</a> and <a href="https://threejs.org/docs/index.html#api/cameras/OrthographicCamera">OrthographicCamera</a>.</p><p>While the first one aims to mimic how the human eyes see a 3D Object, the second one makes the objects size invariant regardless of its distance from the camera, so we can use it if we aim to render 2D.</p><pre>// Create a New Camera, set up his z position<br>const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);<br>camera.position.z = 1000;</pre><p>The first Parameter is the <strong>field of view</strong> or <strong>field of vision</strong> (abbreviated <strong>FOV</strong>) to the extent of the observable image that is seen on the display at any given moment. A natural FOV stands between 60 ~ 75.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*8vERSls9zXrUKBwa3RMqgA.png" /><figcaption>A example of what FOV is</figcaption></figure><p>The second one is the aspect ratio, used as width / height . There is no much science about this one, but if we want to use a fixed size instead of relying on the window size, we should define it fixed.</p><p>The 3rd and 4th parameters define what will get rendered on the screen. Something nearer than the first parameter will not be shown on the screen, and the same thing happens if it is farther than the 4th parameter. We could use this to tweak and get some performance improvements of our animation if it comes to clunky or certain elements are not showing up.</p><h4>Scene</h4><p>Imagine the scene as some sort of container where we&#39;ll be putting our elements (Meshes) and Lights. It will be used by the renderer to get information about what to show.</p><h3>Meshes: A compound of Materials and Geometries</h3><p>So far so good, until now we had been able to choose a renderer, setup our camera and define a scene, but all of that is useless if we don&#39;t have anything to show right? Well, all objects that we will show are called Meshes, and they are constructed by a Material and a Geometry, if we&#39;re going to create an application using Three.js I recommend using the Factory Pattern to create these meshes to avoid writing unmaintainable code on the long-term.</p><h4>Geometries</h4><p>A Geometry is the shape that the object will have, we have a lot of Geometries that you could check under the Three.js documentation, and ever more, using a Loader and <a href="https://threejs.org/docs/index.html#api/geometries/ShapeGeometry">ShapeGeometry</a><strong> </strong>you can be able to import your own shapes from 3D Modeling Softwares.</p><pre>const cubeGeometry = new THREE.BoxGeometry(width, height, depth);</pre><p>On our case, we created a <a href="https://threejs.org/docs/index.html#api/geometries/BoxGeometry">BoxGeometry</a><strong> </strong>to define our Mesh, if you follow the Link of the Geometries, you could see an example of how they should look.</p><h4>Materials</h4><p>The material defines the appearance and how the light will affect of our objects. Their configurations go simply from picking a color, to set up its roughness, metalness and reflectivity. Even some of its properties will allow us to upload a Texture, so we can use images to define how our component should look.</p><pre>const cubeMaterial = new THREE.MeshBasicMaterial({<br>  color: color,<br>  wireframe: showWireframe<br>})</pre><p>Here we&#39;re creating a <a href="https://threejs.org/docs/index.html#api/materials/MeshBasicMaterial">MeshBasicMaterial</a> with a defined color, and wireframe option, the first one will accept a hex value, like 0xff0000 and the second one marks if the object should be solid or we should only show his wireframes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NjJ3GgcWlbfLBkp3qN2jg.png" /><figcaption>Different kind of materials applied onto the same object</figcaption></figure><p><em>A Simple explanation of the image above:</em></p><p><a href="https://threejs.org/docs/index.html#api/materials/MeshBasicMaterial">MeshBasicMaterial</a> is a material that is not affected by Lights, so even if the source of light was there (it was), you&#39;ll not be able to see it.</p><p><a href="https://threejs.org/docs/index.html#api/materials/MeshNormalMaterial">MeshNormalMaterial</a><em> </em>map has vectors in RGB colors, which is the reason for the distortion you see.</p><p><a href="https://threejs.org/docs/index.html#api/materials/MeshLambertMaterial">MeshLambertMaterial</a> doesn’t use specular lights, it uses a non-physically based <a href="https://en.wikipedia.org/wiki/Lambertian_reflectance">Lambertian</a> model for calculating reflectance and it’s good for simulating untreated wood or stone.</p><p><a href="https://threejs.org/docs/index.html#api/materials/MeshStandardMaterial">MeshStandardMaterial</a> uses Physically based rendering (PBR) which means that to get the type of material you can tweak its metalness/roughness, it is the standard of Unity, Unreal and 3D studio among others.</p><p>After this introduction post, you should be able to have an idea about what is behind WebGL and Three.js, and use them to render your own 3D Graphics, There are many keypoints that you should check once you understand this like <strong>Lights, Animations, Controls</strong>. Try creating your own examples, it is pretty fun and doesnt’ take you much time to do it.</p><h4>If you want to know more about technology and innovation, check us out at <a href="https://lateralview.co/">Lateral View</a> or subscribe to our <a href="http://lateralview.us1.list-manage2.com/subscribe?u=1bb89edb08b35c2b3aae6f015&amp;id=31ad94f616">newsletter</a>!</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21753044bb2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Jest: The next generation testing]]></title>
            <link>https://codeburst.io/jest-the-next-generation-testing-8a6ee7c14656?source=rss-9dbc9cd203ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6ee7c14656</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Nahuel A. Verón]]></dc:creator>
            <pubDate>Mon, 19 Jun 2017 01:49:18 GMT</pubDate>
            <atom:updated>2017-06-19T16:40:39.369Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*adYdrfOLy0T5oW02kTvsqg.png" /></figure><p>I was one of those who pushed hard to do Unit test on the frontend too for my current company, but in fact, <em>write frontend unit test was not nice and smooth as backend does, </em>and requires a lot more of configurations, i faced this from a long time and finally found out that Jest was the answer for me, why? let&#39;s see...</p><h4>It&#39;s just Node</h4><p>If you are here from an angular context, like i was (i spent two years working with angular, and some time ago moved to react), you&#39;ll found that the best option available was <a href="https://karma-runner.github.io/1.0/index.html">Karma</a>, that it is good but has some flaws, like you had to actually run a browser, that takes time, and if you was using something like <a href="http://travis-ci.org/">travis-ci</a> you had to do some tricks to fake an screen because some browsers won&#39;t start without it.</p><h4>Don&#39;t have to deal with webpack</h4><p>Another option to not use Karma was <a href="https://mochajs.org/">Mocha</a>&amp;<a href="https://github.com/tmpvar/jsdom">jsdom</a>, but you should do changes into your webpack file, add mocha-webpack and start fighting with all kind of strange issues like i had, having 100 test working and suddenly when i moved the 40% stopped working made me not consider this option.</p><p>But anyway, if you were going to use <a href="https://karma-runner.github.io/1.0/index.html">Karma</a>, still requires to touch your webpack file, and adding karma-webpack as a Karma plugin.</p><p>Obviously both options above adds more time, as you&#39;ll need to wait for the webpack build. On Jest, there is no need to deal with webpack, why? because you can ignore the requires that are not part of your tests (images, non-code files, styles, or other). Even more, if you&#39;re using CSS-Modules there is a package that you could add that will help you with snapshot testing, that we&#39;ll talk about later. There is <a href="https://facebook.github.io/jest/docs/en/webpack.html#content">a page about it</a> that you could check.</p><h4>Timing</h4><p>Let&#39;s just compare how my project was when my tests ran with Karma, and now how they are when i ran them with Jest.</p><p>They had no differences on the tests, only the change of the runner:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7W-QtqYhQMk9gR8FAWdKcQ.png" /><figcaption>Karma</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vdgMUKuWZceLg3MEWf6J7g.png" /><figcaption>Jest</figcaption></figure><p>The proof talks by itself, there are 37.224 seconds of difference between both runners.</p><h4>Configuration</h4><p>That is another interesting point, while Karma has a strong configuration and plugins, you&#39;ll need (and be able) to setup according each project, Jest has some good defaults and you can create your own config file to match your needs, but almost everything already comes integrated, coverage, module transforms, and anothers… But if that is not enough, you can extend it with his config and external packages, i&#39;ll show the configuration and packages used on my project for each Jest/Karma:</p><p><strong>Karma:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f83054f0fa39a864793ceed2039d83bf/href">https://medium.com/media/f83054f0fa39a864793ceed2039d83bf/href</a></iframe><p>Packages: karma , karma-chrome-launcher , karma-coverage , karma-mocha , karma-mocha-reporter , karma-sourcemaps-loader , karma-webpack .</p><p><strong>Jest:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eea903ce2a53ab42911b33112467aab5/href">https://medium.com/media/eea903ce2a53ab42911b33112467aab5/href</a></iframe><p>Packages: jest , babel-jest , enzyme-to-json , identity-obj-proxy .</p><p>Last two packages are put to support features that are not available on Karma or Mocha, so we can count in or not, the unit tests will work fine only with jest and babel-jest .</p><p>I think that this point is ambiguous, since i like the pluggable style of Karma but i don&#39;t like to spent a day just for setting up my test environment.</p><h4>Killer points of Jest:</h4><p>Some of the things that could make you pick this over the other test runners available are:</p><ul><li>The ability to run only the tests that are significant based on the changes that you did: this is really useful to put into a precommit hook and don&#39;t die waiting for run all the tests.</li><li>Almost all the required features are already built in: I don&#39;t need to download another executable like mocha-webpack to do things that should been already there, or at least be configurable, mainly because if i depends on two plugins, and both comes in executables, i&#39;m not going to be able to chain them.</li><li>Snapshot testing: This is a really useful feature to make sure that the changes in your components are already done by you and avoid having regressions, you can read more about it <a href="https://facebook.github.io/jest/docs/snapshot-testing.html">here</a>.</li><li>Strong configurations: It not only includes the basic things that are required in a test runner, it also has a <a href="https://facebook.github.io/jest/docs/en/configuration.html#content">lot more nice to have things</a>, like being able to setup coverage thresholds, automock modules, module mappers (useful to not import .css or any other things managed by webpack), Multiple project support in the same runner, custom resolvers and transforms (exactly like webpack and babel does), into others.</li><li>Migrate without pain: If you&#39;re willing to use the Jest syntax and you&#39;d like to switch a current project, use the <a href="https://github.com/skovhus/jest-codemods">codemods</a> that programatically will migrate a current project without any mayor issue, and normally without any interaction with the code.</li><li>It&#39;s fast, really: Not only running all the test suite is fast, but also the watch mode is fast too.</li></ul><p>The only point that was a mayor drawback for me, but surprised me at the end was that i didn&#39;t liked the Jazmine assertion library, I already was using Chai and Sinon, and the whole set of developers that i knew was using it too. But even if there is a assertion library already included, you could use the one that you liked more, like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51e4e6eb52e2d5205e973be5a6036dee/href">https://medium.com/media/51e4e6eb52e2d5205e973be5a6036dee/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6ee7c14656" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/jest-the-next-generation-testing-8a6ee7c14656">Jest: The next generation testing</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating React Native into an Existing App (Android)]]></title>
            <link>https://codeburst.io/integrating-react-native-into-an-existing-app-android-c27bb1b81574?source=rss-9dbc9cd203ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/c27bb1b81574</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[gradle]]></category>
            <dc:creator><![CDATA[Nahuel A. Verón]]></dc:creator>
            <pubDate>Wed, 07 Jun 2017 04:04:13 GMT</pubDate>
            <atom:updated>2018-01-11T19:19:47.427Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sl2aoJPIm1yIH6JiiR_hJA.png" /></figure><p>In my <a href="https://medium.com/@Negan1911/integrate-react-native-into-an-existing-app-ios-87c947a16044">previous story</a> i talked about integrating react native on iOS applications, now we&#39;re going to rush the missing piece of this post so we can finish this topic.</p><p>Same as the previous story, we&#39;ll need to have the following:</p><ul><li>Node, NPM and react-native-cli installed.</li><li>A (new) React Native project.</li></ul><p>This steps are already explained on my previous story.</p><p>If you run you react-native project, you&#39;ll see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*EXg9JeJ_9kWQYJ9cZ6K2RQ.png" /></figure><p>That means that you have a react native application, that you&#39;ll treat as base to port your existing application, on your native application, you should move the project into an android folder, that means, if you project is called MyAwesomeNativeApp you should move your source code into MyAwesomeNativeApp/android</p><p>Later on, move all the react-native folders and file into your project, <strong>except for the android folder (and ios, if you had a native ios app), be careful of moving the hidden files too, those ones that starts with a dot.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*dbYCivmOJMv2xGXGnA06_w.png" /><figcaption>Those are my files, but may vary between projects</figcaption></figure><p>After that, we had the environment ready, our app can receive the non-android assets.</p><p>From now, we&#39;re going to work on your native project, starting to port react-native into it.</p><h4>Know the project name</h4><p>In the future steps we’ll be refer to the “project name” on steps of the code, this is the name that the main component is registering, it could be found on the file index.android.js find a line that is calling the method registerComponent of AppRegistry like this:</p><pre>AppRegistry.registerComponent(‘myAwesomeApplication’, <br>() <em>=&gt;</em> myAwesomeApplication);</pre><p>On this case, the first string is what we care about, since it told us that our project is called myAwesomeApplication</p><h4>Setting Up Gradle</h4><p>Same as the iOS guide, we&#39;ll start linking our libraries, but instead of adding .xcodeproj files, on android we do it using <a href="https://gradle.org/">Gradle</a>.</p><p>First, make sure that your sidebar view is on <strong>Project </strong>mode, because i&#39;ll be using it to show the routes of the files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*jCdGg_TSnXphTDzcG1WAGg.png" /><figcaption>This is the dropdown that allow you to change the sidebar mode</figcaption></figure><p>The first file that we&#39;ll touch is android/build.gradle , you&#39;ll be seeing something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7z3G6zRH9-HPdn9cU3mVg.png" /></figure><p>We&#39;re going to focus on the <em>allprojects </em>block, you&#39;ll need to replace it with this:</p><pre>allprojects {<br>    repositories {<br>        mavenLocal()<br>        jcenter()<br>        maven {<br>            url &quot;$rootDir/../node_modules/react-native/android&quot;<br>        }<br>    }<br>}</pre><p>This will include the react native android on the native app.</p><p>Now, on android/settings.gradle we&#39;ll add at the top of the file this sentence:</p><pre>rootProject.name = &#39;myAwesomeApplication&#39;</pre><p>And be sure of replace myAwesomeApplication with your real project name.</p><p>Head into android/app/build.gradle inside this file, we&#39;re going to look for the android block, it should have as children a defaultConfig block, inside of it, we&#39;ll put this lines:</p><pre>ndk {<br>    abiFilters &quot;armeabi-v7a&quot;, &quot;x86&quot;<br>}</pre><p>Now, we&#39;re going to look for dependencies block, it should be a sibling of the android block, and we&#39;ll add this line:</p><pre>compile &quot;com.facebook.react:react-native:+&quot;</pre><p>And remove the line that starts with androidTestCompile</p><p>You should end up having something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pg5-_hgj4M4Tegxl3XNJNg.png" /></figure><p>Finally, add the Buck task at the end of the file, copying this will work:</p><pre>task copyDownloadableDepsToLibs(type: Copy) {<br>    from configurations.compile<br>    into &#39;libs&#39;<br>}</pre><p>Now, sync the project and everything should be fine without any kind of gradle error.</p><h4>Adding MainApplication and the React Native Activity</h4><p>Our next steps will be to create our required classes, starting with MainApplication.java , this should be created under android/app/src/main/java/&lt;your.package.name&gt; .</p><p>On this folder, we&#39;re going to create a new Java Class, simply by right-clicking on the folder with the name of your package, selecting new &gt; Java Class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JU1zaqNAo8UODqktF_oEWQ.png" /></figure><p>There should be a popup asking for more information about this new class, that we should complete it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgD9rw4-BbtKTiFKLBRHuA.png" /><figcaption>We&#39;re going to inherit from Application and implement ReactApplication</figcaption></figure><p>Now, add this lines into our new file (don&#39;t replace the package statement, use your package name):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cbb4d39158f89de712a77b7a887f3aeb/href">https://medium.com/media/cbb4d39158f89de712a77b7a887f3aeb/href</a></iframe><p>If any import popup opens just give it ok, make sure that there are no syntax errors and you&#39;ll be fine, this is the starting point of the react application, later we&#39;ll be referencing it into our manifest, so it&#39;s fine if for now it shows up as an unused class.</p><p>Again, we&#39;re going to create a new class, but this time we can give it the name that we want, on my case, i&#39;ll call it ReactMainActivity , again we follow the same procedure as above but we&#39;ll fill the popup with this information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cqVcWcHAdRMsgpco4F8rA.png" /><figcaption>On this case, we inherit from ReactActivity</figcaption></figure><p>On this case, we&#39;re just going to implement this method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/176faa0ea5dc1f3644424c070f1c8288/href">https://medium.com/media/176faa0ea5dc1f3644424c070f1c8288/href</a></iframe><p>This is the starting point of our application, the activity that will start our react-native app.</p><h4>Configuring the Android Manifest</h4><p>We already set up the build phase and created the required classes, now is time to integrate those classes on the application.</p><p>Go to android/app/src/main/AndroidManifest.xml :</p><p>Inside the manifest tag put this permissions:</p><pre>&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;<br>&lt;uses-permission android:name=&quot;android.permission.SYSTEM_ALERT_WINDOW&quot;/&gt;</pre><p>This will do two things:</p><ul><li>Allow us to have internet Access, required for the debugger</li><li>Allow us to overlay windows, also used by our lovely debugger</li></ul><p>Now, inside the application tag put a new attribute called android:name of value .MainApplication</p><p>On the bottom of the application tag we&#39;re going to add the React Native Debugger Activity, simply pasting this tag:</p><pre>&lt;activity android:name=&quot;com.facebook.react.devsupport.DevSettingsActivity&quot; /&gt;</pre><p>Now, we&#39;re going to add our new activity, this will be enough on this case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4687dbf83847987c2e9d96ef9dfd5460/href">https://medium.com/media/4687dbf83847987c2e9d96ef9dfd5460/href</a></iframe><p>You&#39;ll probably want to do some adjustments so <a href="https://developer.android.com/guide/topics/manifest/manifest-intro.html">here is a good place to look about the Manifest Configuration.</a></p><p>You&#39;ll end up having something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fa3b2c7f57bc90a360a61a7728a9661/href">https://medium.com/media/5fa3b2c7f57bc90a360a61a7728a9661/href</a></iframe><h4>Launch Activity</h4><p>On the point where we want to start our application (could be a touch press on a button, for example), we&#39;ll launch a new Activity (Based on a Intent, as usual on Android)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39f660a99472456546221586aab7ca90/href">https://medium.com/media/39f660a99472456546221586aab7ca90/href</a></iframe><p>On My Case, inside my activity i have this onClick method called when i click a button, so it will open a new activity with react native on in.</p><h4>Launch Time!</h4><p>Finally, start your packager with npm start or react-native start and, on android studio, hit the green play button to open a emulator, you&#39;ll see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*pGwRm0WbMRukk0qUnJLiNw.gif" /></figure><p>On <a href="https://medium.com/@Negan1911/integrate-react-native-into-an-existing-app-ios-87c947a16044">my previous story</a> i didn&#39;t put what i thought about react-native, but i think that along with react, react-native is one of those pieces that changed the way to made apps, is currently happening and allow the same range of people to do more powerful things and not try to &quot;Mimic&quot; applications using a WebView, but it also allow us to dig inside of the low level of those platforms, so we can write on native what is really crucial and let react-native handle the rest. All that i had to say to the React Native engineering team is a big THANK YOU!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c27bb1b81574" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/integrating-react-native-into-an-existing-app-android-c27bb1b81574">Integrating React Native into an Existing App (Android)</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating React Native into an Existing App (iOS)]]></title>
            <link>https://codeburst.io/integrate-react-native-into-an-existing-app-ios-87c947a16044?source=rss-9dbc9cd203ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/87c947a16044</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Nahuel A. Verón]]></dc:creator>
            <pubDate>Sun, 28 May 2017 21:43:57 GMT</pubDate>
            <atom:updated>2018-01-17T14:10:02.160Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sl2aoJPIm1yIH6JiiR_hJA.png" /></figure><p>You’ve probably heard about <a href="https://facebook.github.io/react-native/">React Native</a>, but if you haven’t, it’s basically a framework that allows you to use React inside of it, as if it were the web (with some differences, obviously). The key here is that you write Javascript, using some modules that react native provide you, and you got an native app, with components from the OS (or created by yourself) and is really fast and it works with almost the same code for android too.</p><p>What i found, is that is difficult but not impossible to implement react native in an existing application, the fact is that you have to had at least a little bit of knowledge on iOS development, on this case, but don&#39;t worry, i&#39;ll follow a step by step guide about how to do it, for simplicity sake, i&#39;ll start two empty projects: One being an simple iOS empty app on xcode, and the other an hello world example on react native.</p><h4>Know the project name</h4><p>In the future steps we&#39;ll be refer to the &quot;project name&quot; on steps of the code, this is the name that the main component is registering, it could be found on the file index.ios.js find a line that is calling the method registerComponent of AppRegistry like this:</p><pre>AppRegistry.registerComponent(‘myAwesomeProject’, <br>() <em>=&gt;</em> myAwesomeProject);</pre><p>On this case, the first string is what we care about, since it told us that our project is called myAwesomeProject</p><h4>Install the required tooling and set up your project</h4><p>I&#39;ll not go into details on this one, so you can use whatever stack you like, but remember to install node &amp; react-native-cli, because we&#39;re going to create a new project with that.</p><p>A npm i -g react-native-cli will work.</p><p>After that, we&#39;re going to create a new React Native Project (if you already have one skip this step) with react-native init myAwesomeProject where myAwesomeProject put your project name</p><p>It will start downloading bunch of packages via <a href="http://npmjs.com/">npm</a>, starting the android/ios projects and finally you&#39;ll got this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*-U6sMKizjTpXkpTT5EZzlg.png" /><figcaption>Self Explanatory, right?</figcaption></figure><p>If like it says, we move into the directory project and ran react-native run-ios we&#39;ll got an emulator with our own example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*F5ia4IszvZQh6E9HnqSofQ.png" /></figure><p>Heading back to your existing application, the first step is convert the project into the format that react native has, that means, if your project is under myAwesomeNativeApp should be now myAwesomeNativeApp/ios</p><p>Later on, move all the react-native folders and file into your project, <strong>except for the ios folder (and android, if you had a native android app), be careful of moving the hidden files too, those ones that starts with a dot.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*SE-rFyWBNag7QdkK06pWcA.png" /><figcaption>Those are my files, but may vary between projects</figcaption></figure><p>After that, we had the environment ready, our app can receive the non-ios assets.</p><h4>Setting up the required libraries</h4><p>If we look both projects, we&#39;ll see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sRZy8oL1W60joQ19YVE6SA.png" /><figcaption>React Native on the left, my project on the right</figcaption></figure><p>We had a lot of libraries missing, if you don&#39;t use it, you can remove the tvOS targets and the tests, we&#39;ll not care about that one here.</p><p>On your new project, create a new group called Libraries , head to finder and inside your project, look for this path node_modules/react-native .</p><p>The react-native project will tell you what libraries you should include, if you select a project library, you&#39;ll see on the right their relative and absolute path</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HDznALRcTg2tIxwSDpNRbQ.png" /><figcaption>Those are the paths for React</figcaption></figure><p>We should replicate the same on our project, beware that should be relative to your project and inside node_modules , this will allow us later be able to update react native.</p><p>When we found the .xcodeproj that we want to include, simply drag it into the Libraries group, that for everyone.</p><p>After that, on both project go to the project description and build phases.</p><p>You&#39;ll need to move those who are under <em>Link Binary With Libraries, </em>simply press the &quot;+&quot; and look for the same filename.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lUc9vl6vUm8hZtOTZ6KH3g.png" /><figcaption>Here is an example of what i have, those should be replicated on your destination project</figcaption></figure><p>After that, add a new script phase, using the plus sign on the top.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*gXMJNf4FbvdMbuRCAwNexg.png" /></figure><p>Call it &quot;Bundle React Native code and images&quot;, open it and below the &quot;Shell&quot; input put this:</p><pre>export NODE_BINARY=node<br>../node_modules/react-native/packager/react-native-xcode.sh</pre><p>Now, head to &quot;Build Settings&quot;, look for &quot;Other Linker Flags&quot; and add those:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rYDIQbB_lsMV0KJfTffS6Q.png" /></figure><p>Basically $(inherited) , -ObjC and -lc++</p><h4>Setting up the Scheme</h4><p>On your native project, look for the schema configuration, press &quot;Edit Scheme&quot; and go into the &quot;Build&quot; tab, first, turn off the Parallelize Build checkbox, press the plus sign and look for the &quot;React&quot; Project, add it. <strong>And make sure that is the first on the list.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wXSYpS0bHHwk8gMDeZW0BA.png" /><figcaption>You should finish having something like this</figcaption></figure><h4>Integrate Your Code into a new View Controller (Swift)</h4><p>First, because of the libraries are made with Objective-C but we&#39;re using swift, we&#39;ll need to create a Bridging Header, its easy, create a fake Objective-C file (those who end on .m) and Xcode will ask you to create a bridging header, simply put yes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iptW0qAbAFmCwHCT-a1Cag.png" /><figcaption>Im creating an useless .m file so Xcode generate my bridging header</figcaption></figure><p>After that, we can delete our .m file, and inside our bridging header, we should put:</p><pre>#import &lt;React/RCTBundleURLProvider.h&gt;<br>#import &lt;React/RCTRootView.h&gt;</pre><p>Now, head back to Info.plist file, and add those properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPYrEXUtc-m-Gl2W5DP4sA.png" /></figure><p>Since we&#39;re going to work with the local packager, we should disable the App Transport policy, at least for now.</p><p>On the top of our AppDelegate.swift we&#39;ll add a new property that will have the view, it will be like this:</p><pre>var rootView : RCTRootView?</pre><p>And, to load it, inside our didFinishLaunchingWithOptions we&#39;ll put this statements:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8061cfa9d9e81f05eefc25255d29566f/href">https://medium.com/media/8061cfa9d9e81f05eefc25255d29566f/href</a></iframe><p>Now, on the point where we want to start our application (could be a touch press on a button, for example), put this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8685a13e5893297fd5c2f508e1f74367/href">https://medium.com/media/8685a13e5893297fd5c2f508e1f74367/href</a></iframe><h4>Integrate Your Code into a new View Controller (Objective-C)</h4><p>In this case is more straightforward because is the same language that react-native is made, on this case, under AppDelegate.h add:</p><pre>#import &lt;React/RCTBundleURLProvider.h&gt;<br>#import &lt;React/RCTRootView.h&gt;</pre><p>Inside the same, we&#39;re going to define a property that will hold the RootView, so, between the @interface and the @end tags put this line:</p><pre>@property RCTRootView * rootView;</pre><p>Head back into AppDelegate.m and add those lines inside the didFinishLaunchingWithOptions method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61031c95f9a4aa6891edd2532fce8676/href">https://medium.com/media/61031c95f9a4aa6891edd2532fce8676/href</a></iframe><p>Now, on the point where we want to start our application (could be a touch press on a button, for example), put this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1333dab654d8c6d199ded9871911535/href">https://medium.com/media/b1333dab654d8c6d199ded9871911535/href</a></iframe><p>On the top of the file, add:</p><pre>#import “AppDelegate.h”</pre><p>Finally, run your application and you should see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*yEG-CM8Obxad2ScrBGhtsw.gif" /><figcaption>All done, we started react-native from our ViewController</figcaption></figure><p>Check out <a href="https://medium.com/@Negan1911/integrating-react-native-into-an-existing-app-android-c27bb1b81574">the second part, that allow to do the same on android</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87c947a16044" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/integrate-react-native-into-an-existing-app-ios-87c947a16044">Integrating React Native into an Existing App (iOS)</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My experience with Microservices Communication]]></title>
            <link>https://medium.com/@Negan1911/microservices-communication-what-i-didnt-heard-fcd66a713e46?source=rss-9dbc9cd203ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcd66a713e46</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nahuel A. Verón]]></dc:creator>
            <pubDate>Mon, 22 May 2017 02:51:21 GMT</pubDate>
            <atom:updated>2017-05-22T13:28:04.127Z</atom:updated>
            <content:encoded><![CDATA[<p>I&#39;ll tell you the story about how i got into this point of view. But first, i&#39;ll start with a short and healthy disclaimer:</p><p>This is <strong>absolutely my point of view</strong>, and remember that the technology that i choose might not be the ideal for you, don&#39;t take this as the absolute truth, because it was not meant to be anyway.</p><p>I&#39;ll follow with a little bit of context, about how i am and what i&#39;m trying to do:</p><p>With some friends we had the crazy idea to start a product, we&#39;re all Javascript developers, we worked with Node.js for backend, but i though that if we&#39;re going to take this seriously from start, we should try the microservice approach, and nobody of us worked with them before. So, we started investigating about, we were shoked about the different types of interpretation of microservices that some guides has, some of them treated like pretty simple api&#39;s communicated, and some of them just go with a lot of technology: Message Brokers, Service Discovery, Key Storage, and more, much more…</p><p>So, we try to go to the easy path, knowing that if we did it fine, we can escalate some things later when we need. I had an structure in mind that was something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfUamacSxEO4EszE4ciVlg.png" /><figcaption>Of course that we wanna use Nginx as Load Balancer for the API but i thought that didn&#39;t make sense to show it right here.</figcaption></figure><p>Coming up from backend, we know pretty good how to make an API, but we didn&#39;t knew anything about message brokers, someone just recommended me to try RabbitMQ, i try to make it working, and fine, we had been able to make a simple server.js and client.js that shows us the connection, and also having multiples server.js running and balancing the connection, but instantly we found that was pretty complex for that server.js return a value into the client.js . Indeed, what we need was an RPC, and we dig some more weeks but we found that was going to be a pain for some guys that was just starting into this, but this basically was not for RabbitMQ only, for AMQP.</p><p>One of my friend want to give a shot to some Redis queue, what concerned me because the point of redis was not to be a Message Broker, we found 2 problems with two different libraries, we tried RSMQ and Kue, and both were slow compared with the AMPQ solutions, but a worst thing that was there are no open protocol or libraries of the implementation for other languages, so if i wanted to implement a service with Python (because maybe i wanted to use tensorflow), i&#39;ll not be able to do it with those protocols, and i really don&#39;t want to lose the time trying to implement a solution for it digging on the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dtweEAS2vZXvfa2_5nN1AQ.png" /><figcaption>The name of my solution</figcaption></figure><p>And then, when i was losing the faith of found a right solution, i found <a href="https://nats.io/">NATS</a>.</p><p>It has a really pretty simple way of setting up a RPC, it distribute the messages pretty good and is outstanding lightweight and fast.</p><p>And the best, it has implementations for Go, Java, C, C#, Ruby, Node, Python and Elixir. So, with that i&#39;ll be sure that i&#39;m not going to have issues with the common languages to make services at all.</p><p>Im going to let some examples of the simple test that i did to show you how simple it is to make a RPC:</p><p>This is a Service example (<em>written in javascript</em>), responsible of getting the messages, process them and reply:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b525908a3c4c6fa1ae26f90185aa7f0/href">https://medium.com/media/5b525908a3c4c6fa1ae26f90185aa7f0/href</a></iframe><p>Another Service Example (<em>but this time, written in Python</em>), same as above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6caf2281099eab7fcf32f01f0e955805/href">https://medium.com/media/6caf2281099eab7fcf32f01f0e955805/href</a></iframe><p>And now the client:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd961823f375b0ae6e7cf83a444c135b/href">https://medium.com/media/cd961823f375b0ae6e7cf83a444c135b/href</a></iframe><p>Here is an example of my terminal when i run both servers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*4MxKXekwvck-cJMseI2O9w.png" /><figcaption>Running Backed by 2 Node servers and 1 Python Server.</figcaption></figure><p>Just what i was looking for, i hope that this got useful for you as it is for me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcd66a713e46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>