<?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 Akram Helil on Medium]]></title>
        <description><![CDATA[Stories by Akram Helil on Medium]]></description>
        <link>https://medium.com/@akramhelil?source=rss-b43ab51bd695------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dx5mqhJ00Co4Aerf.jpg</url>
            <title>Stories by Akram Helil on Medium</title>
            <link>https://medium.com/@akramhelil?source=rss-b43ab51bd695------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 05:35:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akramhelil/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[How to get large book covers from Google API in Ruby?]]></title>
            <link>https://medium.com/@akramhelil/how-to-get-large-book-covers-from-google-api-in-ruby-5dd7d93331f0?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/5dd7d93331f0</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sat, 25 Jan 2020 13:07:03 GMT</pubDate>
            <atom:updated>2020-01-31T23:42:29.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*PQErwday5KPVZYZM3SDIPQ.jpeg" /></figure><p>Recently I have been working on small bookkeeping and noting projects. First thought it would be great to get something shows up on the page. Picked Google Books API due to time crunch.</p><p>After creating and enabling the API for the Google books, I sent few requests through Ruby HttpPart gem. One thing that I noticed is that the book cover is super small.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*VW63AjQUTxlfBWbz9s154g.png" /><figcaption>Controller-Search Action</figcaption></figure><p>After handling some of the edge cases that might go wrong during the response, I decided to do a small error handling.</p><p>Once again, I turned into the powerful google.</p><pre>&lt;%= image_tag book[&quot;volumeInfo&quot;][&quot;imageLinks&quot;][&quot;thumbnail&quot;].gsub(&quot;zoom=1&quot;, &quot;zoom=0&quot;), class:&quot;card-img-top&quot;%&gt;</pre><p>So here is the trick, when you request the Google API for the Book information, by default, the API will return a string of image_links, which is pointed to twp sized thumbnails. zoom is an attribute in the image URL that determines the size of the book cover. So I tried out all the numbers, the best one is replacing the “zoom=1”, to “zoom=0”. There you go, your amazing books cover now came up with really nice and clear photos.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5dd7d93331f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Books API with Rails or Ruby]]></title>
            <link>https://medium.com/@akramhelil/google-books-api-with-rails-or-ruby-a931cece427a?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/a931cece427a</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sun, 19 Jan 2020 15:53:47 GMT</pubDate>
            <atom:updated>2020-01-19T15:56:14.358Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*dyX_EntgUInGVap-t4VjdA.png" /></figure><p>Google’s APIs are very powerful. Besides YouTube and news, Books API also is my favorite for building up a small project when I learning a new framework or practice.</p><p>It’s been a while that I have not played around with Ruby on Rails. So I decided to build a small book searching engine.</p><p>For this article, I used some helper gems to parsed API. There are multiple ways of doing this, I will attach the resource on the below.</p><p>After you registered your API key from Google, and find your endpoint for searching since we are doing our books. it should be looks like this</p><pre>url = &quot;https://www.googleapis.com/books/v1/volumes?q=#{params[:search]}&amp;maxResults=15&amp;key=#{ENV[&quot;API_KEY&quot;]}&quot;</pre><p>Let’s break it down a little bit:</p><ul><li>/v1/volumes in here I was using volumes resource due to I wanted a bulk of the same search results.</li><li>q= #{params[: search]} this is the keyword that we sent through our request from the form.</li><li>&amp;maxResults=15 it will help you to retrieve 15 book volumes. It can be up to 40.</li><li>then this is the most important part, your Google API key=#{ENV[“API_KEY”]}. I hit my key using the dotenv and ignored the file via .gitignore.</li></ul><p>So Since we all set on our endpoint explanation, now we can start with the meaty part.</p><p>Install or require the httpparty in your rails app or on your ruby file.</p><pre>gem install httparty</pre><p>or add this gem in your Gemfile, make sure to Bundle it up :)</p><p>Once you all done that:</p><pre>require &#39;httparty&#39; #you don&#39;t add this if you are using bundler<br><br>url = &quot;https://www.googleapis.com/books/v1/volumes?q=#{params[:search]}&amp;maxResults=15&amp;key=#{ENV[&quot;API_KEY&quot;]}&quot;</pre><pre>response = HTTParty.get(url)<br>result = response.parsed_response</pre><p>There you go, all the pretty books results are here, through this now you can do some iterations. and display your books with covers and also more Infos if you needed. I find this way easier to implement than goodreads-api.</p><p>Happy Coding!</p><p><a href="https://www.twilio.com/blog/2015/10/4-ways-to-parse-a-json-api-with-ruby.html">4 Ways to Parse a JSON API with Ruby</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a931cece427a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Explanation — Bcrypt]]></title>
            <link>https://medium.com/@akramhelil/bycrpt-explained-d02e96f43f86?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/d02e96f43f86</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sun, 05 Jan 2020 00:27:27 GMT</pubDate>
            <atom:updated>2020-01-05T17:06:07.653Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*mZAXXuZ6ezcLgf-c2ksX6Q.png" /><figcaption>source: redeszone.net</figcaption></figure><p>Today I am gonna talk a little bit about the security algorithm Bcrypt.</p><p>One of my instructors been telling me, the Internet is a super scary place, which I agree with! More and more data shared through the web, more and more digital crimes are happening all over the world. So let’s talk about how to keep things secure especially using one of the most well-known practices is Bcrypt.</p><p><em>What is Bcrypt?</em></p><blockquote>bcrypt is a password hashing function designed by Niels Provos and David Mazières, based on the Blowfish cipher, and presented at USENIX in 1999.</blockquote><blockquote>— Wikipedia</blockquote><p>So, from my personal understanding, it’s written functions and algorithms that transform some of the confidential data to a complex hash. Those algorithms include <a href="https://en.wikipedia.org/wiki/MD5"><strong><em>md5</em></strong></a><strong> </strong>and <a href="https://en.wikipedia.org/wiki/SHA-1"><strong><em>Sha1</em></strong></a><strong><em> </em></strong>algorithms.</p><p>So how this algorithm works? Let’s see if I can get this right when we insert a string like “Hello World”. Bcrypt will output a bunch of random letters and numbers every time, and every time the random string is unique to one and other even input the same letters. So which means, every time when you enter a string to Bcrypt you will get different results. Once that string is transformed into a complex hash, it is nearly impossible to revert that hash back to the string. So the differences between Md5 and Sha1 is Bcrypt is designed to be super slow when processing the hashing data, md5 and sha1 speed is faster. Which makes the Bcrypt is the first choice, can win some time to figure out where is the security problem occurred and find a fix.</p><p>Bcrypt designed to create an unbreakable hash on our database. For utilizing Bcrypt we have to use password_digest as a column name instead of the password.</p><p>resources:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO6cmuiTBZVs%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO6cmuiTBZVs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FO6cmuiTBZVs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/84f6f854c4e8acd08e19eedd55b013bf/href">https://medium.com/media/84f6f854c4e8acd08e19eedd55b013bf/href</a></iframe><ul><li><a href="https://en.wikipedia.org/wiki/MD5"></a></li><li><a href="https://en.wikipedia.org/wiki/SHA-1">SHA-1 - Wikipedia</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d02e96f43f86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MongoDB Beginner — Connect with NodeJS]]></title>
            <link>https://medium.com/@akramhelil/mongodb-beginner-connect-with-nodejs-575883fe8079?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/575883fe8079</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Fri, 27 Dec 2019 23:47:40 GMT</pubDate>
            <atom:updated>2019-12-27T23:47:40.239Z</atom:updated>
            <content:encoded><![CDATA[<h3>MongoDB Beginner — Connect with NodeJS</h3><p>When it comes to JavaScript, all the developers love to try new things and learn new libraries or frameworks. There are stacks that keep us excited to become a JavaScript Full Stack Developer. Such as MEAN Stack(MongoDB, Express, Angular, Node), MERN Stack(MongoDB, Express, ReactJS, Node). All of them considered more flexible and easier to scale.</p><p>Here I will be doing a general introduction to MongoDB. First, let’s learn how to use MongoDB to connect with NodeJS.</p><p>Let’s install the MongoDB:</p><pre>npm install mongodb --save</pre><p>For that, we will be using express and mongoose.</p><pre>npm init</pre><p>we can bypass by accepting all the default setups. Then let’s install some of the modules that we need in this short introduction.</p><pre>npm i express mongoose</pre><p>Now, we will be creating a file name it server.js, and connect our server to the MongoDB database.</p><pre><strong>const</strong> mongoose = require(&#39;mongoose&#39;)</pre><pre>mongoose.connect(&#39;mongodb://localhost/test&#39;, {useNewUrlParser: true})</pre><pre><strong>const</strong> testSchema= <strong>new</strong> Schema({<br>    name:  String<br>})</pre><pre><strong>const</strong> Test = mongoose.model(&#39;Test&#39;, testSchema)</pre><p>Then we will be connecting MongoDB(currently using the localhost)</p><p>Before starting any of the servers, we need to run in terminal:</p><pre>mongod</pre><p>then keep that tab open. This means the MongoDB server is up and running.</p><p>Now we can test out our DB by running</p><pre>mongo</pre><p>The terminal will be stepping into DB mode, then we can use the MongoDB methods to lookup our test db created or not.</p><pre>show collection</pre><p>then we will run</p><pre>use test</pre><p>If you interested to more of the information about the Shell Commands on MongoDB query docs <a href="https://docs.mongodb.com/manual/tutorial/getting-started/"><strong><em>here</em></strong></a><strong><em>.</em></strong></p><ul><li><a href="https://docs.mongodb.com/manual/tutorial/getting-started/">Getting Started</a></li><li><a href="https://code.tutsplus.com/articles/an-introduction-to-mongoose-for-mongodb-and-nodejs--cms-29527">An Introduction to Mongoose for MongoDB and Node.js</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=575883fe8079" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mac OS Catalina After the update —Error Fix for Developers Xcode Part]]></title>
            <link>https://medium.com/@akramhelil/mac-os-catalina-after-the-update-error-fix-for-developers-xcode-part-24cf01b37cc2?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/24cf01b37cc2</guid>
            <category><![CDATA[xcode]]></category>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sat, 21 Dec 2019 16:41:47 GMT</pubDate>
            <atom:updated>2019-12-21T16:41:47.281Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-225FslK-boWPQy-ekuqjw.png" /></figure><p>As I love new technology, anything new comes up I love to take the risk of trying it out. If I stuck in any problem as my nature of being a fixer, I spend hours figuring out what is going on and try to fix it.</p><p>Here are a few problems I had with Catilina, thinking of sharing my troubleshooting steps. Maybe if you have the same issue, it might come handy.</p><p><strong>Xcode</strong></p><p>This was crucial for me, with the Catilina, Xcode was not updated automatically. So when I try to open the app, it has been asking me to upgrade the Xcode. Then went to the App store try to update, the progress bar is spinning, but still stuck, then got an error: “Unable to Download app Xcode …”</p><p>SO I dug deeper to figure it out what was the problem, then I find out it was actually the xcrun error(<em>allows you to find or run any tool inside Xcode from the command line</em>)</p><pre>xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun.</pre><p>Since I use the partial Xcode tools, I googled(as a good developer do lol). Find out others also having the same issue, after reading through the threads, found few commands to run might fix the issue</p><pre>xcode-select --install</pre><p>If after this still not fixing the issue, then run:</p><pre>xcode-select --reset</pre><p>For me, none of them fixed the issue, so I decided to reinstall the Xcode.</p><p>Go to the Apple Developer website, log in with your Apple ID, then download the most recent Xcode version.</p><p>I will keep it updated if I saw more errors. So far my Xcode error is gone, still testing other gems and homebrew.</p><p>Hope this article was helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24cf01b37cc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Back end with NodeJs/ExpressJs and Postgress]]></title>
            <link>https://medium.com/@akramhelil/setting-up-back-end-with-nodejs-expressjs-and-postgress-ccc40fed1780?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccc40fed1780</guid>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sat, 14 Dec 2019 23:58:10 GMT</pubDate>
            <atom:updated>2019-12-14T23:58:10.338Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*EuaLaYV0VCDnuqFiJNMcLg.jpeg" /><figcaption>resource: udemy.com</figcaption></figure><p>After learning NodeJs through documents and online tutorials, I decided to write down a simple walk through how I set up my simple CRUD backend</p><p>First of all, make sure that you install the Postgres in your operating system, and It’s running on the background. Here I am using Express to setup out NodeJS Backend. After setup our Express app, we start our journey on setting up our database with Postgress.</p><pre>npm install pg</pre><p>Now we start setting up our connection to the Postgress.</p><pre>const express = require(&#39;express&#39;)<br>const bodyParser = require(&#39;body-parser&#39;)<br>const app = express()<br>const port = 3000<br><br>app.use(bodyParser.json())<br>app.use(<br>  bodyParser.urlencoded({<br>    extended: true,<br>  })<br>)</pre><pre>app.listen(port, () =&gt; {<br>  console.log(`App running on port ${port}.`)<br>})</pre><p>Let’s start with a simple GET request.</p><pre>app.get(&#39;/&#39;, (request, response) =&gt; {<br>  response.json({ info: &#39;NodeJS Postgres API&#39; })<br>})</pre><p>now we can start our server on the index.js</p><pre>node index.js<br>//App Running on post 3000. </pre><p>Check the localhost:3000, you should be able to see the JSON that we created earlier.</p><pre>{ <br>    info: &#39;NodeJS Postgres API&#39; <br>}</pre><p>Now is the time we connect the Postgress to our NodeJS/Express. For a better code organization, and making our life a little easier, let’s create a file named queries.js</p><p>From the documents on the node-pg, let’s setup out PostgreSQL Connection:</p><pre>const Pool = require(&#39;pg&#39;).Pool<br>const pool = new Pool({<br>  user: &#39;hello&#39;,<br>  host: &#39;localhost&#39;,<br>  database: &#39;nodejs-pg-api&#39;,<br>  password: &#39;12345&#39;,<br>  port: 5432,<br>})</pre><p>On the production, for the security have to put your configuration details in the separate file, then make sure restricted from version control.</p><p>so now lets setup our RESTful routes for demo blog app.</p><p><em>GET — </em><em>/ | </em><em>displayBlog()</em></p><p><em>GET — </em><em>/blogs | </em><em>getBlogs()</em></p><p><em>GET — </em><em>/blogs/:id | </em><em>getBlogById()</em></p><p><em>POST — </em><em>blogs | </em><em>createBlog()</em></p><p><em>PUT — </em><em>/blogs/:id | </em><em>updateBlog()</em></p><p><em>DELETE — </em><em>/blogs/:id | </em><em>deleteBlog()</em></p><p>Here are the routes that we expect to have with directed functions to give us the data back from the database. Still, here is an important step that we have to add on, the NodeJs request endpoint in query.js</p><p>For setting up those endpoints, through document we can see that we have to write simple SQL to get our data from the database.</p><p>This is how our queries.js look like:</p><pre>const Pool = require(&#39;pg&#39;).Pool<br>const pool = new Pool({<br>  user: &#39;hello&#39;,<br>  host: &#39;localhost&#39;,<br>  database: &#39;nodejs-pg-api&#39;,<br>  password: &#39;12345&#39;,<br>  port: 5432,<br>})</pre><pre>const getBlogs = (request, response) =&gt; {<br>  pool.query(&#39;SELECT * FROM blogs ORDER BY id ASC&#39;, (error, results) =&gt; {<br>    if (error) {<br>      throw error<br>    }<br>    response.status(200).json(results.rows)<br>  })<br>}<br><br>const getBlogById = (request, response) =&gt; {<br>  const id = parseInt(request.params.id)<br><br>  pool.query(&#39;SELECT * FROM blogs WHERE id = $1&#39;, [id], (error, results) =&gt; {<br>    if (error) {<br>      throw error<br>    }<br>    response.status(200).json(results.rows)<br>  })<br>}<br><br>const createBlog = (request, response) =&gt; {<br>  const { title, content } = request.body<br><br>  pool.query(&#39;INSERT INTO users (title, content) VALUES ($1, $2)&#39;, [title, content], (error, results) =&gt; {<br>    if (error) {<br>      throw error<br>    }<br>    response.status(201).send(`Blog added with ID: ${result.insertId}`)<br>  })<br>}<br><br>const updateBlog = (request, response) =&gt; {<br>  const id = parseInt(request.params.id)<br>  const { title, content } = request.body<br><br>  pool.query(<br>    &#39;UPDATE blogs SET title = $1, content = $2 WHERE id = $3&#39;,<br>    [title, content, id],<br>    (error, results) =&gt; {<br>      if (error) {<br>        throw error<br>      }<br>      response.status(200).send(`Blog modified with ID: ${id}`)<br>    }<br>  )<br>}<br><br>const deleteBlog = (request, response) =&gt; {<br>  const id = parseInt(request.params.id)<br><br>  pool.query(&#39;DELETE FROM blogs WHERE id = $1&#39;, [id], (error, results) =&gt; {<br>    if (error) {<br>      throw error<br>    }<br>    response.status(200).send(`Blog deleted with ID: ${id}`)<br>  })<br>}<br><br>module.exports = {<br>  getBlogs,<br>  getBlogById,<br>  createBlog,<br>  updateBlog,<br>  deleteBlog,<br>}<br></pre><p>Here now we setting up the endpoints with our queries.</p><p>For code readability, let’s assign the exported module from queries.js to a variable db in our index.js when we require the file.</p><pre>const db = require(&#39;./queries&#39;)</pre><p>Then it’s the time to set up our all routes and functions we need for the routes on our NodeJS API in our index.js file</p><pre>const express = require(&#39;express&#39;)<br>const bodyParser = require(&#39;body-parser&#39;)<br>const app = express()<br>const db = require(&#39;./queries&#39;)<br>const port = 3000<br><br>app.use(bodyParser.json())<br>app.use(<br>  bodyParser.urlencoded({<br>    extended: true,<br>  })<br>)<br><br>app.get(&#39;/&#39;, (request, response) =&gt; {<br>  response.json({ info: &#39;NodeJS Postgres API&#39; })<br>})<br><br>app.get(&#39;/blogs&#39;, db.getBlogs)<br>app.get(&#39;/blogs/:id&#39;, db.getBlogById)<br>app.post(&#39;/blogs&#39;, db.createBlog)<br>app.put(&#39;/blogs/:id&#39;, db.updateBlog)<br>app.delete(&#39;/blogs/:id&#39;, db.deleteBlog)<br><br>app.listen(port, () =&gt; {<br>  console.log(`App running on port ${port}.`)<br>})</pre><p>Here you go!</p><p>run:</p><pre>node index.js<br>//App Running on post 3000.</pre><p>Here we can test out our routes. using terminal curl:</p><pre>curl --data &quot;title=HelloWorld&amp;content=first-post&quot; <br>http://localhost:3000/blogs</pre><p>when you set a GET request /blogs, you should see</p><pre>{    <br>    &quot;title&quot;: &quot;HelloWorld&quot;,<br>    &quot;content&quot;: &quot;first-post&quot;<br>}</pre><p>Now you can set up your basic API using Postgress and NodeJS.</p><p>I am sure there must be other ways to do this, I took this as a learning step for creating my API with lightweight frameworks like express.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccc40fed1780" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Machar, Most occurred character… type Of Algo Problems]]></title>
            <link>https://medium.com/@akramhelil/working-with-machar-most-occurred-character-type-of-algo-problems-deb6ecaac8b4?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/deb6ecaac8b4</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sat, 07 Dec 2019 21:56:59 GMT</pubDate>
            <atom:updated>2019-12-07T21:56:59.902Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D-blt48I2BUWn6VLJazFpg.jpeg" /><figcaption>source: mission.org</figcaption></figure><p>After going through multiple code challenges I decided to write something about some of the patterns I found and helped me to understand and get a better solution. Every Code challenges I got during my job search have some similarities, give you an algorithm problem and you need to present your solutions through whiteboarding or timed online environment, both are monitored in various ways. The pressure is real! besides getting nervous (I am really bad at tests), I found it practice and exposure to different algorithm problems can help a lot. I use LeetCode and HackerRank for my practice and Udemy Interview Coding Challenge From Stephen Grider (<a href="https://www.udemy.com/course/coding-interview-bootcamp-algorithms-and-data-structure/"><em>class link</em></a>).</p><p>Let’s get to the topic. Practice! Practice! Practice!</p><p>The example I used here is from is seen in many interview questions. It’s a bit tricky, but there’s always have that Trick we can learn. Question is: “Given a String, find the most occurred character in the string?”</p><p>My Approach: First I will ask for the edge cases, dose the space count in the string, how about the punctuation? that confirmed then I will start tackling the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gXTPjmoItUWgTdlpCDhbw.png" /><figcaption>Screen Shot From Stephen Grider Class</figcaption></figure><p>Once the edge cases are cleared out, we will start thinking of how to tackle the problem. Let’s say we don&#39;t wanna count space and punctuations, two approaches, one might think of use split() and Regex. Both I would say necessary in this case. Still, we need mapping the alphabets in an object that can increment the count of the occurrence while we iterate, which means we need some kind of loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5iMTQpfxKkP2wcq_SvnR8w.png" /><figcaption>Screen Shot From Stephen Grider Class</figcaption></figure><p>Our Goal right now how to get the string mapped out to an object like this, then we can iterate over the object to compare the occurrence.</p><p>Let’s say we already sanitized the string with Regex. Now we can map out the characters. (I used es6)</p><pre>function mapChar(str) {</pre><pre>    const charMap = {}</pre><pre>    for(let char of str) {<br>        if(charMap[char]){<br>            charMap[char] ++<br>        } else {<br>            charMap[char] = 1<br>        }<br>    }<br>    return charMap<br>}</pre><p>So here we declared an empty object for saving the mapping of the characters, then used <em>for…of</em> loop just because regular for loop has a higher chance make mistakes on syntax. But it will work the same. Here the condition of iteration comes in, if the char has existed in the charMap we will increment the value, else create the key-value pair. Step one Logic is done! Make sure to RETURN the charMap.</p><p>Nest Step is iterate over the charMap and finds the maxChar.</p><pre>function maxChar(str) {</pre><pre>    const mappedObj = mapChar(char)<br>    const result= &#39;&#39;<br>    const max = 0</pre><pre>    for(let char in mappedObj) {<br>        if(mappedObj[char] &gt; max) {<br>            max = mappedObj[char]<br>            result = char</pre><pre>        }<br>    }</pre><pre>    return result<br>}</pre><p>in maxChar() function we iterate over the mappedObj using <em>for…in</em> loop, before that we need to declare two variables for help result and max. In the loop, we will assign them with the condition that we desire.</p><p>I am sure there are many ways of doing this, here I wanted to emphasize the using helper function to make the code more readable and we still have that single responsibility concept, also, the reusability of our code will be higher.</p><p>I am always open to suggestions and advice. Let me know what is your solutions?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb6ecaac8b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding Local Fonts to React and React Native]]></title>
            <link>https://medium.com/@akramhelil/adding-local-fonts-to-react-and-react-native-9cf7d383198a?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cf7d383198a</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Sun, 01 Dec 2019 13:59:30 GMT</pubDate>
            <atom:updated>2020-01-03T21:21:27.468Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1N6UaiN98yU2EcEaI2vCw.png" /><figcaption>from Medium Post</figcaption></figure><p>Many of us like to implement some of our Local fonts to our react native app. For me, I wanted to implement my native language (Uyghur) .ttf (true type format) fonts to the projects that I was planning to build with Expo with React-Native.</p><p>So let’s get into our point.</p><p>After you create your React-Native project, let’s say it’s called test-fonts</p><pre>expo init test-fonts</pre><p>Once we got the project setup and have the simulator running, then we can start doing the edit on the app.js file, typically you will want to load your apps primary fonts before the app is displayed to avoid text flashing in after the font loads. The recommended approach is to move the Font.loadAsync call to your top-level component.</p><p>So here is how our Starting code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*2T6q6S5oJZkL8QrbRIqlAw.png" /><figcaption>source: docs.expo.io</figcaption></figure><p>Then put the custom font file in the test-fonts/assets/fonts directory.</p><p>For us to be able to load the font into our Native App, the first thing we have to connect to the font using Expo SDK, font loader.</p><p>so on top of our app.js file</p><pre>import * as Font from &#39;expo-font&#39;</pre><p>Then we will be using component lifecycle methods to load the fonts.</p><pre>componentDidMount() {<br>    Font.loadAsync({<br>      &#39;uyghur-bold&#39;: require(&#39;./assets/fonts/uyghur-bold.ttf&#39;),<br>    });<br>  }</pre><p>Still, we might have a small issue, due sometimes we have some delay on reading the font-file. There might be a “Flash” font change situation. due to that we can set up a local state on the application for verifying the font was loaded or not, then we can do conditional rendering with, once font loaded then start the component mounting on the view on our App.</p><p>For using the font, we can add in to our style tag, as normal using the other fronts.</p><p><a href="https://docs.expo.io/versions/v36.0.0/guides/using-custom-fonts/">Using Custom Fonts</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F22LEiBYBiTw%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D22LEiBYBiTw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F22LEiBYBiTw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a3da3ba1cba57cf966436fe3899e428/href">https://medium.com/media/0a3da3ba1cba57cf966436fe3899e428/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cf7d383198a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React native — Navigation Where to start]]></title>
            <link>https://medium.com/@akramhelil/react-native-navigation-and-more-ca8c2f97f85c?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca8c2f97f85c</guid>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 06:44:01 GMT</pubDate>
            <atom:updated>2020-01-12T01:44:56.974Z</atom:updated>
            <content:encoded><![CDATA[<p>After learning ReactJS, I decided to look into react native.</p><p>If you are comfortable writing a component with JSX, react-native should not be that challenging, but still, you will find some learning curves. As a lifetime learner, and passion for ReactJS I decided to look into one of the important parts of the React Native — Navigation.</p><blockquote>The community solution to navigation is a standalone library that allows developers to set up the screens of an app with a few lines of code.. — React Native Docs.</blockquote><p>Thanks to the developers who are behind this! I can’t wait to start telling you how amazing this is!</p><p>So we will start installing with the module by running:</p><pre>npm install --save react-navigation</pre><p>Then install the gesture handler, this will help you to create event handler when you swipe the screen left and right</p><pre>npm install --save react-native-gesture-handler</pre><p>Third, we will need a stack handler for our project, stack in React-Native, it’s like routes in ReactJS, this module will help us create screens, set up our routes with few lines of code. for installing run</p><pre>npm install --save react-navigation-stack</pre><p>Nice! Now let’s talk about how this three-module were connected. In our iOS or Android apps, when we press a button on the screen, or when we click some part of the app, we expect something to be happening.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*sNQuUaEE65-rKe64qO2HSg.jpeg" /><figcaption>Instagram</figcaption></figure><p>in our web apps, we need a navigation bar, in our Native apps, we need a small menu, on your Insta the menu/Navbar located on the bottom of the screen. UI people are AMAZING! so when we tap all the cute little icons on this app it will trigger an event, in ReactJS we call it routes, in React-Native we call it screens.</p><p>So let’s see some code.</p><pre>// App.js<br>import React from &#39;react&#39;;<br>import { StyleSheet, Text, View } from &#39;react-native&#39;;<br>import { createStackNavigator, createAppContainer } from &quot;react-navigation&quot;;<br><br>import HomeScreen from &#39;./components/HomeScreen&#39;;<br>import AboutScreen from &#39;./components/AboutScreen&#39;;<br><br><br>export default class App extends React.Component {<br>  render() {<br>    return &lt;AppContainer /&gt;;<br>  }<br>}<br><br>const AppNavigator = createStackNavigator({<br>  Home: {<br>    screen: HomeScreen<br>  },<br>  About: {<br>    screen: AboutScreen<br>  }<br>});<br><br>const AppContainer = createAppContainer(AppNavigator);<br><br>const styles = StyleSheet.create({<br>  container: {<br>    flex: 1,<br>    backgroundColor: &#39;#fff&#39;,<br>    alignItems: &#39;center&#39;,<br>    justifyContent: &#39;center&#39;,<br>  },<br>});</pre><p>Let’s walk through, on ReactJS, best practice is to wrap the App component in the React Router component. The app component is the entry point(root) or the highest level component in ReactJS. Similar idea, just a little different approach in React-Native. So in our code, first we imported our React, then imported some of the components(tags), then createStackNavigator, createAppContainer is the one dose the magic trick. Once we imported our screens. First, we will create a container that wraps up the App, called AppContainer using createAppContainer()</p><pre>const AppContainer = createAppContainer(Something);</pre><p>this method will take an argument, a stack that we created using createStackNavigator()</p><pre>const AppNavigator = createStackNavigator({<br>  Home: {<br>    screen: HomeScreen<br>  },<br>  About: {<br>    screen: AboutScreen<br>  }<br>});</pre><p>we can call it App Navigator or App Routes. it will take an object.</p><pre>{<br>  Home: {<br>    screen: HomeScreen<br>  },<br>  About: {<br>    screen: AboutScreen<br>  }<br>}</pre><p>Here, the navigator will look into the first level key-directed to another object:</p><pre>Home: {<br>    screen: HomeScreen<br>  }</pre><p>Inside of the pointed object, we will have a keyword screen, THIS is where we render and connect all the screens/routes that we imported!</p><p>There are many other modifying options for the navbar. For now, I will just keep this first step of setup this simple.</p><p>Let me know if you have anything to feedback.</p><p>Resources:</p><ul><li><a href="https://reactnavigation.org/docs/en/app-containers.html">App containers · React Navigation</a></li><li><a href="https://reactnavigation.org/">React Navigation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca8c2f97f85c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native — My Approach]]></title>
            <link>https://medium.com/@akramhelil/react-native-my-approach-219464f8f704?source=rss-b43ab51bd695------2</link>
            <guid isPermaLink="false">https://medium.com/p/219464f8f704</guid>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Akram Helil]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 17:29:07 GMT</pubDate>
            <atom:updated>2020-01-03T21:34:37.547Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native — My Approach Learning Step One</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*GBg6Nv-NUhEU-I7YarxxcA.png" /><figcaption>dev.to</figcaption></figure><p>ReactJS always was my favorite front-end library, then I discovered the react-native.</p><p>I started looking into resources, I found Harvard CS50 has the course that fits my learning style. (Here is the link <a href="https://www.youtube.com/watch?v=X52b-8y2Hf4&amp;list=PLhQjrBD2T382gdfveyad09Ierl_3Jh_wR"><em>Harvard — CS50</em></a>)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLhQjrBD2T382gdfveyad09Ierl_3Jh_wR&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DX52b-8y2Hf4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FX52b-8y2Hf4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7369264e7d31d7fb2fe07e806c3236ce/href">https://medium.com/media/7369264e7d31d7fb2fe07e806c3236ce/href</a></iframe><p>The lecture covers the ES6 most important features to all the way startup a project and finishes a project on the React-Native.</p><p>Besides digging the limitless tutorial, I decided to dig right in with these 12 videos. Since each video was almost 2 hours long, I planned to break it to morning and afternoon learning process, in between I started to build some small apps. The practice is the most important part.</p><p>The first started with a to-do app. Which is lame, but easy to tackle. Then started working on one of my ReactJS projects.</p><p>If you are interested to know more about what’s the power of React-Native. Check out <a href="https://github.com/ReactNativeNews/React-Native-Apps"><em>this link</em></a><em>, </em>those are the projects that used react native, mostly open-source.</p><p><a href="https://github.com/ReactNativeNews/React-Native-Apps">ReactNativeNews/React-Native-Apps</a></p><p>Then here is an article that I found on for how to set up your React Native Dev environment.</p><p><a href="https://dev.to/rob117/how-to-really-set-up-a-react-native-environment-on-mac-248h">How to REALLY set up a React Native environment on Mac</a></p><p>Next is to start watching the tutorials and PRACTICE PRACTICE!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=219464f8f704" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>