<?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 Muhammad Hezby on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Hezby on Medium]]></description>
        <link>https://medium.com/@hezbymuhammad?source=rss-3e314920f89f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*KFPZ190oKKiDOmVcpSwNfA.jpeg</url>
            <title>Stories by Muhammad Hezby on Medium</title>
            <link>https://medium.com/@hezbymuhammad?source=rss-3e314920f89f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:18:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hezbymuhammad/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[Rails and Postgres/Mysql JSON Column]]></title>
            <link>https://medium.com/@hezbymuhammad/rails-and-postgres-mysql-json-column-61c4408cb370?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/61c4408cb370</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Sun, 08 Aug 2021 13:32:29 GMT</pubDate>
            <atom:updated>2021-08-08T13:32:29.042Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWM8rZbsrZID5tmymj-5wA.png" /><figcaption>Rails Logo</figcaption></figure><p>I learned that we can use Rails with Postgres/Mysql JSON column.</p><p>So, basically it’s a way to store data like settings or preferences in our model. Usually, when we have a lot of settings and preferences, we will add more and more column. Adding new columns in a relational database means adding new migrations.</p><p>However, with the release of Postgres 9.2, Postgres add a native support for JSON column. We can now finally use NoSQL database in our Postgres! Bye database migration!</p><p>Let’s create one. Here’s the DDL. If you want to, you can also use Rails db migration.</p><pre>CREATE TABLE users (<br>  id integer NOT NULL,<br>  settings jsonb<br>);</pre><p>Now we can also create index on JSON column.</p><pre>CREATE INDEX idxuserscolor ON cards ((settings-&gt;&gt;&#39;color&#39;));<br>CREATE INDEX idxusersheadline ON cards ((settings-&gt;&gt;&#39;headline&#39;));</pre><p>Database is prepared. How’s ActiveRecord model for User look like? ActiveRecord provides really useful <a href="https://api.rubyonrails.org/classes/ActiveRecord/Store.html">ActiveRecord::Store</a> object to deal with JSON column.</p><pre>class User &lt; ActiveRecord::Base<br>  store :settings, accessors: [ :color, :headline ], coder: JSON<br>end<br><br>u = User.new(color: &#39;red&#39;, headline: &#39;Hello world&#39;)</pre><pre>u.color # =&gt; &quot;red&quot;</pre><p>That’s it. We’re able to utilize JSON column on our Rails app!</p><p>Wait, there is one more. Currently, Rails doesn’t have any API to query JSON column. You have to query it manually if you want to search.</p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61c4408cb370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Play with Ruby Variable]]></title>
            <link>https://medium.com/@hezbymuhammad/lets-play-with-ruby-variable-dc5a635c308b?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc5a635c308b</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Tue, 23 Apr 2019 09:47:49 GMT</pubDate>
            <atom:updated>2019-04-23T10:56:37.839Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*DJbMQfWtADvAdUo49DC9FA.jpeg" /><figcaption>Ancient Egyptian Papyrus Script</figcaption></figure><p>Ruby is straightforward language. It’s dynamic and the syntax is amongst the easiest to understand language. In fact, Ruby is associated with love and joy! Awesome, isn’t it?</p><p>Today, we’re going to play with Ruby variable. Ruby is dynamic language. Declaring variable doesn’t need much effort. Furthermore, every Ruby variable has a built in method called object_id. Everything in Ruby is object. And each object has unique identifier called object_id that represent pointer on low level machine code. You can dig it <a href="http://taraellicott.com/object_ids_in_ruby">here</a> and <a href="http://taraellicott.com/object_ids_in_ruby">here</a>.</p><p>Let’s play with this code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60906f4ec57c92dc5679da4f7738e0ce/href">https://medium.com/media/60906f4ec57c92dc5679da4f7738e0ce/href</a></iframe><p>Let’s explore it! We have 3 variables foo, bar, and baz. From the object_id we know that bar and baz are actually the same object with different name. It’s quite expected since we do assignment baz = bar. However, what you might not expect is that it’s shared reference to a single object! Since it’s a shared reference, we can do something like this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/304679250b325b4fc607444e698dbf9f/href">https://medium.com/media/304679250b325b4fc607444e698dbf9f/href</a></iframe><p>Notice that by changing baz, we also change bar. Vice versa. From this object_id, we know that Ruby variable is passed by reference. Ruby variable might like Javascript variable, it looks like pass by value. However, Ruby internal mechanism for passing variable is quite different since all variable in Ruby is object and every object own its reference object_id.</p><h4>Reassignment</h4><p>Since we know that Ruby is using pass by reference, let’s play with reassignment! Previously, we declare baz = bar. What happens if we change bar? What will reassignment do to object_id? Let’s do it!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db8594e8ce78eb48dcb1e79b5820a62e/href">https://medium.com/media/db8594e8ce78eb48dcb1e79b5820a62e/href</a></iframe><p>Reassignment didn’t change baz at all! bar got new object_id and baz object_id didn’t change. What happens is when we do reassignment, referenced object didn’t change, instead it creates a new object for reassigned variable.</p><h4>Fixnum</h4><p>Sometimes, we use increment, right? What’s the object passing strategy when we do increment? Let’s find out!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5046ba1d48260a7e86a27df2d92e8956/href">https://medium.com/media/5046ba1d48260a7e86a27df2d92e8956/href</a></iframe><p>In Ruby, numbers and boolean values are immutable. Once we create an immutable object, we cannot change it. Align with what we’ve learned about reassignment when we do increment in Ruby, we don’t actually change the object. Instead, we assign incremented variable to another object.</p><p>What’s more interested in Ruby is that immutable object always have same object id.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1244088248622a74f2f396914cf0da4a/href">https://medium.com/media/1244088248622a74f2f396914cf0da4a/href</a></iframe><h4>What about mutability in Ruby?</h4><p>As we discovered before, everything in Ruby is an object, including variable! For the object in Ruby itself, there is 2 kind of it: mutable object and immutable object. Mutable object is object that can be changed.</p><p>By default, all objects in Ruby are mutable. However, some objects are immutable. Those immutable objects are NilClass, Integer, Float, Symbol, Boolean and several other objects. Ruby also can make any object immutable by invoking .freeze to an object.</p><p>However, frozen object still has different object_id. It only strip out mutable method from available method on variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0346e6efdc25715abbbc65cc178bea6e/href">https://medium.com/media/0346e6efdc25715abbbc65cc178bea6e/href</a></iframe><h4>Mutable method</h4><p>Ruby object has built in method called mutable method. Basically, mutable methods are method that can be called to mutate the object. In this article, we learn that &lt;&lt; and upcase! are mutable method. There are several other mutable methods available like [], concat, etc.</p><h3>Conclusion</h3><p>We learnt that all object in Ruby has identifier, it contain reference to that object in low level machine code. Ruby use pass by reference. However, for immutable object, Ruby use pass by value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45ff9beb8f33b4e5192a97964115684b/href">https://medium.com/media/45ff9beb8f33b4e5192a97964115684b/href</a></iframe><p>Using the fundamental of pass by reference, we can do a trick on modifying variable, especially if the variable is a large hash.</p><p>Using fundamental of pass by reference and mutability, we also should be aware when we call mutable method on any objects, especially when those objects are unfrozen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc5a635c308b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Work at Quipper: A Review]]></title>
            <link>https://medium.com/@hezbymuhammad/work-at-quipper-a-review-f7fff9f5ae78?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7fff9f5ae78</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[quipper]]></category>
            <category><![CDATA[personal]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Mon, 24 Sep 2018 07:01:13 GMT</pubDate>
            <atom:updated>2018-09-24T07:01:13.166Z</atom:updated>
            <content:encoded><![CDATA[<p>Since a long time ago, I’ve always wanted to work on a multinational company where I can have many colleagues from different cultures. And here I am, for about 6 months now, been working at Quipper. I was very excited back then on my first day. Yet, today, I’m even more excited. I’m learning that running a multinational business is hard even we’re still at early stage company, that aligning people from different cultures can be hard even though we’re same Asians, that scaling our tech requires a lot of perseverance and persistent even our stacks are not so big, etc.</p><p>While working in Quipper is mostly fun, but it’s not always fun. There were times when all I can do is swearing myself. Indeed, it’s not a perfect company. I’ll share things I like, things that challenge me (and sometimes give me headache), and thing I wish could be improved.</p><h3>Things I Like</h3><h4>Powerhouse Laptop</h4><p>Lemme show you how my desk looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0i-GPficbCgW2GsGy5Akpw.jpeg" /></figure><p>Quipper provides us MacBook Pro Touch Bar 15&quot; as well as Dell 22&quot; monitor. While it’s arguably whether MacBook Pro is good for developer or not, until now I’m satisfied with my setup. For the mech keyboard, it’s my own.</p><h4>Flexibility to Tweak Working Hours</h4><p>This is something I like very much in Quipper. Quipper, especially my division in the product team, is trying to build a healthy work environment where everyone can decide when to be productive. For example, I used to go to work after 10 AM because I can go to the office faster as there is no traffic jam after that time. The travel time between my home and my office is almost 1 hour at rush hour (8–10 AM), while it’s only 30 minutes after 10 AM. We can decide when to start working. However, 8 hours per day is a must.</p><p>What I like the most is Quipper build this healthy environment based on trust. Trust is a sacred word in Quipper. Everyone has to preserve that value no matter what. We’re happy if we can have flexibility in work, and the flexibilities depend on company’s trust on us, so we should do our best to keep company’s trust, therefore keep things that make us happy. See? It’s a circular process of trusting each other!</p><h4>Skillful Colleague</h4><p>My colleagues in Quipper came from different backgrounds. Some guys came from big companies like Microsoft, Blackberry Messaging, Samsung, etc. However, our member not only came from big company. Some people came from unexpected background. We value more than one’s background or experience. But we share the exact same value!</p><p>The things that amaze me the most is Quipper don’t value people absolutely from the background they have. It’s only how much skill and passion one has to contribute more value. Several of my senior colleagues don’t have formal programming education. Moreover, one of my senior is previously a nurse who worked in Borneo!!! He used to proudly tell us how he was able to pass recruitment test despite his handicap of no formal programming background and lived in rural area who seldom has access to either internet or even electricity. And as fellow Quiperian, we admire him for his passion for delivering good tech.</p><h3>Things that Challenge Me</h3><h4>Multi-Culture</h4><p>Quipper is a company that operates in several countries: Japan, Mexico, Philippine, and Indonesia. As a member of the product team, intense communication between those countries is to be expected. We haven’t yet localized our product in each country, so changes in the product are tightly coupled to each country’s business.</p><p>And because every country has their own culture, we should try to understand and respect it. For example, my manager is a Japanese. He used to chat me with the exclamation mark.</p><blockquote>Me: (on my first day)<br>Me: Hi Mr. Manager. Let me introduce my self, my name is Hezby. This is my first day. Looking forward to work and learn 🙇<br>Mr. Manager: Hi Hezby!!!<br>Mr. Manager: I’m glad you joined! let’s develop quipper system better!! 🙏<br>Me: Thank you 🙇</blockquote><p>Another day…</p><blockquote>Me: Hi.. Can I work remotely today?<br>Mr. Manager: that’s fine!</blockquote><p><em>*this conversation did not really happen, it’s just an imaginary example.</em> 😄</p><p>Do you notice that exclamation mark? That is our cultural differences. Japanese used to use the exclamation mark to show their excitement. Furthermore, they’ll use exactly three exclamation mark if they are very excited!!!</p><p>On the other hand, Indonesian used to use the exclamation mark to show our anger to others. So, on my first day, I was confused and asking myself “did I do something wrong?”. But after a few days, I began to understand and get used to it.</p><p>The exclamation case is just one of much cultural difference I’ve learned. So far, I’m enjoying this process of understanding and respecting differences. And I’m looking forward to able to understand and learn more!!!</p><h4>Local Approach with Global in Mind</h4><p>Quipper is running it’s business in 4 different countries. Those 4 countries have the same platform and share the same vision. There are times when we shift our global vision, but we should do it in a local way, Indonesian way for example. There are also times when we found something in Indonesian education that’s applicable in the global scale.</p><p>Then, the biggest challenge really came when we want to develop our platform. We have to carefully plan our platform development to make sure that we can deliver our value with no adverse impact on a specific country’s business. At the same time, because we’re a startup, we should also move fast in the agile way to catch up education need, both globally and locally.</p><h4>Tech Development and Legacy System</h4><p>Quipper is expanding. We evolve from simple learning platform to complete education platform. In order to expand our value, we also need to evolve our system. As software engineers, this is what we’re continuously doing in Quipper.</p><p>Started from simple learning platform, of course, we have many legacy systems. However, things I like here in Quipper is that we’re not afraid of learning and implementing something new! We’re not afraid of dropping some old legacy tech for better one. Even if it costs us additional time to change, we’re still open to any changes. We’re avid learners!</p><h3>Thing that Could Improve</h3><h4>Fun Activity Far Away from Office</h4><p>Quipper has exciting regular activities like sports and team building where we can mingle with each other. Even so, we have yearly kickoff season where there are a lot of games and prizes. However, so far, we haven’t had any fun activity of going far away from Jakarta. I hope we could have an exciting activity outside the office. Company trip to some exciting place would be great!</p><h3>Conclusion</h3><p>I’m very grateful that I’m working on Quipper. I learned a lot in Quipper and the working environment is also quite good. However, same as any other company, Quipper is not perfect.</p><p>I hope I can learn more in the future. And also, I hope I can bring more value and contribution to make Quipper better both as a company where I work and as an education platform for fellow Indonesian.</p><p><em>We’re hiring for web developer! Know some ruby magic and react perks? Let us know!!!!</em></p><p><em>Drop me an email for more info: </em><a href="/service/mailto: hezby.muhammad@quipper.com"><em>hezby.muhammad@quipper.com</em></a><em><br>Or just visit our website: </em><a href="https://www.quipper.com/career/"><em>quipper.com/career</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7fff9f5ae78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrasi dari Gulp 3 ke Gulp 4]]></title>
            <link>https://medium.com/karir-com-engineering/migrasi-dari-gulp-3-ke-gulp-4-43c8b58041c9?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/43c8b58041c9</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[updates]]></category>
            <category><![CDATA[task-management]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 05:20:52 GMT</pubDate>
            <atom:updated>2018-02-15T05:27:56.298Z</atom:updated>
            <content:encoded><![CDATA[<p>Di <a href="https://medium.com/karir-com-engineering/rails-dan-progressive-web-app-6e2318471f2e">tulisan sebelum ini</a>, saya membahas pembuatan gulp task. Tulisan tersebut menggunakan gulp 4.0.0. Jika kamu pernah menggunakan gulp &lt; 4.0.0 mungkin akan sedikit merasa tidak familiar dengan syntax gulp.series dan done(). Nah, tulisan kali ini akan sedikit membahas apa saja perbedaan gulp task versi 3.9.1 dan versi 4.0.0.</p><h4>Gulp 3.9.1</h4><p>Sebelum melanjutkan, untuk mempermudah penjelasan, kita akan menggunakan repository rails-gulp yang sama dengan <a href="https://medium.com/karir-com-engineering/rails-dan-progressive-web-app-6e2318471f2e">tulisan sebelum ini</a> namun dengan branch berbeda. Kita akan merewrite gulp task dengan syntax 3.9.1. Kamu bisa cek branch gulp 3.9.1 <a href="https://github.com/hezbymuhammad/rails-gulp/tree/gulp-v3.9.1/gulp/tasks">disini</a>.</p><p>Kita akan fokus pada task clean:</p><pre>var gulp = require(‘gulp’);<br>var del = require(‘del’);<br>var config = require(‘../config’);</pre><pre>gulp.task(&#39;clean&#39;, function (callback) {<br>  sw_path = config.sw.targetDir + config.sw.target;<br>  del([sw_path], callback);<br>});</pre><p>dan task default:</p><pre>var gulp = require(&#39;gulp&#39;);<br>                          <br>gulp.task(&#39;default&#39;, [&#39;clean&#39;, &#39;build&#39;]);</pre><p>Task tersebut akan dapat dijalankan secara normal pada gulp 3.9.1.</p><h4>Gulp 4.0.0</h4><p>Di bagian ini akan dibahas bagaimana migrasi dari gulp 3.9.1 ke 4.0.0. Kita akan menggunakan metode <em>trial and error</em> ya.</p><p>Kita akan mencoba langsung menjalankan task tersebut pada gulp 4.0.0. Jika task dijalankan, akan muncul error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*2YxB6LSEMPFdRYvHbML9cA.png" /><figcaption>Gulp Error</figcaption></figure><p>Error tersebut dikarenakan gulp 4.0.0 mengubah parameternya, dari 3 parameter menjadi hanya 2.</p><pre>// gulp 3.9.1<br>gulp.task(&#39;default&#39;, [&#39;task1&#39;, &#39;task2&#39;], function () {<br>  ...<br>});</pre><pre>// gulp 4.0.0 parallel execution<br>gulp.task(&#39;default&#39;, gulp.parallel(&#39;task1&#39;, &#39;task2&#39;));</pre><pre>// gulp 4.0.0 sequence execution<br>gulp.task(&#39;default&#39;, gulp.series(&#39;task1&#39;, &#39;task2&#39;));</pre><ul><li>gulp.parallel digunakan untuk menjalankan task secara paralel</li><li>gulp.series digunakan untuk menjalankan task secara sekuensial</li><li>gulp.series dan gulp.parallel dapat digunakan bersamaan</li></ul><p>Dengan syntax baru tersebut, kita dapat mengubah task default menjadi seperti ini</p><pre>var gulp = require(&#39;gulp&#39;);<br>                          <br>gulp.task(&#39;default&#39;, gulp.series(&#39;clean&#39;, &#39;build&#39;));</pre><p>Setelah kita ubah, akhirnya task kita dapat berjalan dengan lancar. Hanya saja muncul peringatan di akhir eksekusi seperti dibawah ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*RIvEfpAsK7Xz9ZR3X2Ztzg.png" /><figcaption>Async Completion Alert</figcaption></figure><p>Error ini datang dari task clean. Spesifiknya lagi, error ini datang dari penggunaan package del.</p><p>Gulp 4 mengharuskan suatu proses untuk mengikuti konsep <a href="https://github.com/gulpjs/async-done/issues/36">async await</a>. Suatu proses harus memiliki kembalian untuk diteruskan ke fungsi selanjutnya. Solusinya cukup dengan menggunakan parameter callback pada task dan memanggil callback tersebut setelah task selesai.</p><pre>var gulp = require(‘gulp’);<br>var del = require(‘del’);<br>var config = require(‘../config’);</pre><pre>gulp.task(&#39;clean&#39;, function (done) {<br>  sw_path = config.sw.targetDir + config.sw.target;<br>  del([sw_path], done);</pre><pre>  done();<br>});</pre><p>Cara lain adalah dengan menggunakan kembalian dari fungsi del</p><pre>var gulp = require(‘gulp’);<br>var del = require(‘del’);<br>var config = require(‘../config’);</pre><pre>gulp.task(&#39;clean&#39;, function () {<br>  sw_path = config.sw.targetDir + config.sw.target;<br>  return del([sw_path]);<br>});</pre><h3>Jadi, Apa yang Berubah?</h3><p>Gulp 4 memperkenalkan sistem baru dalam sistem eksekusi task. Sebelumnya, gulp 3 menggunakan sistem eksekusi task yang memperhitungkan dependensi antar task.</p><h4>Sistem Eksekusi Gulp 3</h4><pre><em>// Per default, start scripts and styles</em><br>gulp.task(&#39;default&#39;, [&#39;scripts&#39;, &#39;styles&#39;], function() {...});<br><br><em>// Both scripts and styles call clean</em><br>gulp.task(&#39;styles&#39;, [&#39;clean&#39;], function() {...});<br>gulp.task(&#39;scripts&#39;, [&#39;clean&#39;], function() {...});<br><br><em>// Clean wipes out the build directory</em><br>gulp.task(&#39;clean&#39;, function() {...});</pre><p>Pada task diatas, task scripts dan styles memiliki dependensi pada task clean sehingga ketika semua task tersebut dieksekusi, akan ada 2 tahap yaitu pengecekan dependensi lalu kemudian baru gulp menjalankan eksekusi tersebut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqCCRDhZYioJqDoFGi6chQ.jpeg" /><figcaption>Source: <a href="https://fettblog.eu/gulp-4-parallel-and-series/">https://fettblog.eu/gulp-4-parallel-and-series/</a></figcaption></figure><h4>Sistem Eksekusi Gulp 4</h4><pre>gulp.task(&#39;styles&#39;, gulp.parallel(&#39;clean&#39;, function() {...}));<br>gulp.task(&#39;scripts&#39;, gulp.parallel(&#39;clean&#39;, function() {...}));<br><br>gulp.task(&#39;clean&#39;, function() {...});<br><br>gulp.task(&#39;default&#39;, gulp.parallel(&#39;scripts&#39;, &#39;styles&#39;));</pre><p>Pada gulp 4, tidak ada pengecekan dependensi sehingga eksekusi task murni merupakan urutan task. Kemudian gulp 4 juga memperkenalkan parallel task dan series task. Sistem eksekusi task diatas dapat dilihat pada gambar dibawah ini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*4ICZ0iNRW9Cv8irkbNM-1A.jpeg" /><figcaption>Source: <a href="https://fettblog.eu/gulp-4-parallel-and-series/">https://fettblog.eu/gulp-4-parallel-and-series/</a></figcaption></figure><h4>Kesimpulan</h4><p>Gulp 4 memberikan fleksibilitas dalam menjalankan task, tidak ada lagi pengecekan dependensi task.</p><p>Urutak eksekusi task <em>default</em> tetap sama dan dapat diatur mirip dengan versi sebelumnya, namun task individual dapat dijalankan tanpa ketergantungan pada task lain.</p><h3>Resource</h3><ul><li><a href="https://github.com/gulpjs/gulp/blob/master/docs/README.md">https://github.com/gulpjs/gulp/blob/master/docs/README.md</a></li><li><a href="https://fettblog.eu/gulp-4-parallel-and-series/">https://fettblog.eu/gulp-4-parallel-and-series/</a></li><li><a href="https://blog.wearewizards.io/migrating-to-gulp-4-by-example">https://blog.wearewizards.io/migrating-to-gulp-4-by-example</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43c8b58041c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/karir-com-engineering/migrasi-dari-gulp-3-ke-gulp-4-43c8b58041c9">Migrasi dari Gulp 3 ke Gulp 4</a> was originally published in <a href="https://medium.com/karir-com-engineering">karir.com-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails dan Progressive Web App]]></title>
            <link>https://medium.com/karir-com-engineering/rails-dan-progressive-web-app-6e2318471f2e?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e2318471f2e</guid>
            <category><![CDATA[pwa]]></category>
            <category><![CDATA[website-development]]></category>
            <category><![CDATA[gulp]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Wed, 14 Feb 2018 11:12:36 GMT</pubDate>
            <atom:updated>2018-02-14T11:12:36.918Z</atom:updated>
            <content:encoded><![CDATA[<p>Progressive Web App (PWA) adalah salah satu teknologi modern yang ditujukan terutama untuk pengguna mobile. Walaupun optimasi utamanya adalah pengguna mobile, fitur-fitur PWA juga bisa dinikmati di aplikasi desktop.</p><p>PWA memungkinkan kita dapat menikmati website selayaknya kita menikmati aplikasi. PWA termasuk teknologi yang masih berkembang, dan sedang disempurnakan oleh asosiasi internet. Walaupun begitu, saat ini, beberapa fitur PWA sudah dapat kita nikmati. Perlu diperhatikan bahwa PWA hanya dapat dijalankan di website yang <strong>telah memiliki https</strong>.</p><p>Berikut adalah beberapa hal yang dapat dilakukan website yang telah mengadopsi PWA:</p><ol><li>Akses offline</li><li>Notifikasi pop up</li><li>Fullscreen</li><li>dll, lebih lengkap bisa dilihat <a href="https://developers.google.com/web/progressive-web-apps/">disini</a></li></ol><p>Artikel ini hanya mencontohkan bootstrap dan pembuatan service worker sederhana menggunakan gulp.</p><h4>Service Worker</h4><p>Pada dasarnya, PWA adalah website yang telah mengimplementasi service worker. Service worker sendiri merupakan javascript yang dijalankan browser di latar belakang, terpisah dari website, yang membuka pintu ke berbagai fitur yang tidak memerlukan laman web atau interaksi pengguna.</p><p>Service worker ini merupakan fitur baru browser modern, jadi jika ingin dapat menggunakan service worker pastikan browser yang Anda pakai telah diupdate ke versi terbarunya (dan tentunya bukan Internet Explorer, ya).</p><p>Implementasi service worker mirip seperti javascript pada umumnya, cukup panggil script di halaman utama. Perlu diperhatikan, service-worker.js harus berada pada root domain.</p><pre>if (&#39;serviceWorker&#39; in navigator) {<br>  window.addEventListener(&#39;load&#39;, function() {<br>    navigator.serviceWorker.register(&#39;/service-worker.js&#39;).then(function(registration) {<br>    // Registration was successful<br>    console.log(&#39;ServiceWorker registration successful with scope: &#39;, registration.scope);<br>    }).catch(function(err) {<br>      // registration failed :(<br>      console.log(&#39;ServiceWorker registration failed: &#39;, err);<br>    });<br>  });<br>}</pre><p>Anda dapat membaca lebih lanjut tentang service worker <a href="https://developers.google.com/web/fundamentals/primers/service-workers/">disini</a>.</p><h4>Rails Asset Pipeline</h4><p>Bagaimana implementasi service worker pada rails?</p><p>Ternyata, implementasi service worker pada rails tidak sederhana dikarenakan rails menggunakan asset pipeline. Asset pipeline adalah framework untuk menggabungkan, memperkecil atau mengkompres asset JavaScript dan CSS.</p><p>Berikut conton asset pipeline di application.js</p><pre>//= require script<br>//= require another_script</pre><p>Pada contoh diatas, asset pipeline menggabungkan script.js dan another_script.js. Hasilnya adalah satu file .js yang ada di folder public.</p><p>Asset pipeline memberikan keuntungan berupa asset yang lebih compact. Namun disisi lain, jika kita ingin memiliki javascript yang berbeda, kita harus menggunakan tools lain. Dalam kasus ini, file service worker harus berdiri sendiri sebagai satu file dan tidak dapat digabungkan dengan asset lain (misal sw.js seperti pada contoh diatas).</p><p>Beberapa tools yang sering digunakan untuk mengintegrasikan custom script ke rails asset pipeline diantaranya: gulp, grunt, dan webpack.</p><h4>Integrasi Rails dan Gulp</h4><p>Pada kesempatan kali ini kita akan inisialisasi gulp di rails project.</p><p>Tak perlu repot copas, cukup clone repository <a href="https://github.com/hezbymuhammad/rails-gulp">ini</a>. History commitnya sesuai dengan step yang akan saya jelaskan.</p><p>Pertama-tama, pastikan Node.js dan npm telah terinstall. Setelah itu inisialisasi package.json dan gulp (gulp 4 ya) dengan perintah:</p><pre>npm init<br>npm install --save-dev gulp@next</pre><p>Butuh waktu beberapa saat untuk mendownload dan menginstall package yang dibutuhkan.</p><p>Setelah selesai buat folder gulp, dan gulp/task. Setelah itu buat konfigurasi file gulp/config.js seperti dibawah ini.</p><pre>var publicAssets = &quot;./public/assets&quot;;<br>var sourceFiles  = &quot;./gulp/assets&quot;;</pre><pre>module.exports = {<br>  publicAssets: publicAssets,</pre><pre>sw: {<br>    target: &quot;service-worker.js&quot;,<br>    targetDir: &quot;./public/&quot;<br>  }<br>};</pre><h4>sw-toolbox</h4><p>Google telah menyediakan tools untuk mempermudah pembuatan service worker, yaitu <a href="https://googlechromelabs.github.io/sw-toolbox/">sw-toolbox</a>. Dengan sw-toolbox developer tak perlu bersusah payah mengembangkan service worker dari scratch. Cukup gunakan framework tersebut untuk mengembangkan service worker milik Anda.</p><pre>npm install --save-dev sw-precache</pre><h4>Integrasi Gulp dan sw-toolbox</h4><p>Salah satu kelebihan menggunakan sw-toolbox adalah kemudahan untuk integrasi dengan gulp dan asset pipeline. Kita cukup membuat gulp task untuk membuatnya.</p><p>Buat file build.js di folder gulp/tasks.</p><pre>var gulp         = require(&#39;gulp&#39;);<br>var config_sw    = require(&#39;../config&#39;).sw;<br>var sw           = require(&#39;sw-precache&#39;);</pre><pre>gulp.task(&#39;build&#39;, function(done) {<br>  var target = config_sw.targetDir + config_sw.target;<br>  var rootDir = config_sw.targetDir;</pre><pre>  sw.write(target, {</pre><pre>    staticFileGlobs: [rootDir+ &#39;/**/*.<br>{js,html,css,png,jpg,gif,svg,eot,ttf,woff}&#39;],<br>    stripPrefix: rootDir</pre><pre>  });</pre><pre>  done();<br>});</pre><p>Script tersebut merupakan script sangat sederhana, jika ingin menggunakan sw-precache untuk kasus yang lebih kompleks kamu bisa cek dokumentasinya <a href="https://github.com/GoogleChromeLabs/sw-precache">disini</a>.</p><p>Untuk menjalankan task tersebut, cukup panggil gulp build dari root directory. File service worker akan berada di public/service-worker.js.</p><h4>Memanggil Service Worker</h4><p>Langkah terakhir adalah memanggil service-worker.js dari aplikasi rails kita. Buat file baru di app/assets/javascripts/sw_initializer.js.</p><pre>if (&#39;serviceWorker&#39; in navigator) {<br>  window.addEventListener(&#39;load&#39;, function() {<br>    navigator.serviceWorker.register(&#39;/service-worker.js&#39;).then(function(registration) {<br>    // Registration was successful<br>    console.log(&#39;ServiceWorker registration successful with scope: &#39;, registration.scope);<br>    }).catch(function(err) {<br>      // registration failed :(<br>      console.log(&#39;ServiceWorker registration failed: &#39;, err);<br>    });<br>  });<br>}</pre><h4>Berhasil Kah?</h4><p>Setelah membuat sw_initializer.js, jalankan aplikasi rails dengan perintah rails s. Jika service worker berhasil jalan, akan muncul keterangan seperti berikut di browser developer tools (disini dicontohkan chrome developer tools).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*y9W-GFxqZZFVyaj0xl9vEw.png" /></figure><h4>Resource Lebih Lanjut tentang PWA</h4><ul><li>Washington Post PWA — <a href="https://wapo.com/pwa">https://wapo.com/pwa</a></li><li>SSLMate — <a href="https://sslmate.com/">https://sslmate.com</a></li><li>Let’s Encrypt — <a href="https://letsencrypt.org/">https://letsencrypt.org/</a></li><li>Search Ranking Guidance — <a href="https://bit.ly/https-migration">https://bit.ly/https-migration</a></li><li>The offline cookbook — <a href="https://jakearchibald.com/2014/offline-cookbook/">https://jakearchibald.com/2014/offline-cookbook/</a></li><li>Code labs — <a href="https://codelabs.developers.google.com/pwa-roadshow">https://codelabs.developers.google.com/pwa-roadshow</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e2318471f2e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/karir-com-engineering/rails-dan-progressive-web-app-6e2318471f2e">Rails dan Progressive Web App</a> was originally published in <a href="https://medium.com/karir-com-engineering">karir.com-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Merefactor Data Clump]]></title>
            <link>https://medium.com/karir-com-engineering/merefactor-data-clump-92bf22572e39?source=rss-3e314920f89f------2</link>
            <guid isPermaLink="false">https://medium.com/p/92bf22572e39</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Muhammad Hezby]]></dc:creator>
            <pubDate>Wed, 06 Dec 2017 12:09:39 GMT</pubDate>
            <atom:updated>2017-12-06T12:09:39.643Z</atom:updated>
            <content:encoded><![CDATA[<p>Ada beberapa teknik yang dapat digunakan untuk melakukan <em>refactoring</em>. Pada tulisan kali ini saya akan sedikit menuliskan tentang <em>data clump </em>dan cara <em>refactoring</em>-nya.</p><blockquote>“It is not enough for code to work.” — <em>R. C. Martin</em></blockquote><p>Salah satu duplikasi kode yang cukup sering terjadi adalah grup variabel yang yang selalu muncul bersamaan. Martin Fowler menamakan kasus tersebut sebagai <em>data clump. </em>Contoh <em>data clump</em> adalah rentang waktu (start_date, end_date).</p><p>Berikut ilustrasi <em>data clump</em>:</p><pre>class UsersAgenda<br>  def initialize users, start_date, end_date<br>    @users = users<br>    @start_date = start_date<br>    @end_date = end_date<br>  end</pre><pre>  def get_users_within_birthday_range<br>    @users.select { |user| user.birth_date_within_range? @start_date, @end_date }<br>  end<br>end</pre><pre>class User &lt; OpenStruct<br>  def birth_date_within_range? start_date, end_date<br>    birth_date &gt;= @start_date &amp;&amp; birth_date &lt;= @end_date<br>  end<br>end</pre><p>Spec UsersAgenda:</p><pre>require &#39;spec_helper&#39;</pre><pre>describe UsersAgenda do<br>  describe &quot;#get_users_within_birthday_range&quot; do<br>    it &quot;get users within range birth_date&quot;<br>      jono = User.new name: &quot;Jono&quot;, birth_date: Date.new(1989,1,1)<br>      joni = User.new name: &quot;Jon&quot;, birth_date: Date.new(1989,2,1)</pre><pre>      users = [jono, joni]</pre><pre>      UsersAgenda.new(users, Date.new(1989, 1, 1), Date.new(1989, 1, 30))<br>                 .get_users_within_birthday_range<br>                 .should == 1<br>    end<br>  end<br>end</pre><p>Pada contoh diatas, start_date dan end_date selalu muncul bersamaan. Kedua variabel tersebut secara implisit saling memiliki ketergantungan, keduanya harus urut dan jika salah satu dari keduanya tidak dideklarasikan maka UserAgenda dan class lain yang mengimplementasikannya tidak akan dapat dijalankan. Bayangkan jika implementasi variabel tersebut diubah (misal urutannya diubah atau ditambah median_date), maka tentu akan ada tugas merepotkan untuk mengubah implementasi di UserAgenda dan class-class terkait.</p><p>Kode tersebut dapat dibuat lebih baik dengan memindahkan grup variabel ke class baru. Dengan memindahkan variabel start_date dan end_date ke kelas baru, UsersAgenda dan class lain tidak perlu mengkhawatirkan ketergantungan antar grup variabel tersebut.</p><pre>class UsersAgenda<br>  def initialize users, date_range<br>    @users = users<br>    @date_range = date_range<br>  end</pre><pre>  def get_users_within_birthday_range<br>    @users.select { |user| user.birth_date_within_range? @date_range }<br>  end<br>end</pre><pre>class User &lt; OpenStruct<br>  def birth_date_within_range? date_range<br>    birth_date &gt;= date_range.start_date &amp;&amp; birth_date &lt;= date_range.end_date<br>  end<br>end</pre><pre>class DateRange &lt; Struct.new(:start_date, :end_date)<br>end</pre><p>Spec baru</p><pre>require &#39;spec_helper&#39;</pre><pre>describe UsersAgenda do<br>  describe &quot;#get_users_within_birthday_range&quot; do<br>    it &quot;get users within range birth_date&quot;<br>      jono = User.new name: &quot;Jono&quot;, birth_date: Date.new(1989,1,1)<br>      joni = User.new name: &quot;Jon&quot;, birth_date: Date.new(1989,2,1)</pre><pre>      users = [jono, joni]<br>      date_range = DateRange.new(Date.new(1989, 1, 1),<br>                                 Date.new(1989, 1, 30))</pre><pre>      UsersAgenda.new(users, date_range)<br>                 .get_users_within_birthday_range<br>                 .should == 1<br>    end<br>  end<br>end</pre><p>Demikian. Kita telah sukses menambahkan abstraksi pada implementasi start_date dan end_date sehingga code yang dihasilkan tidak lagi memiliki ketergantungan pada variabel tersebut.</p><p><a href="https://www.youtube.com/watch?v=DC-pQPq0acs">Refactoring from Good to Great by Ben Orenstein<br></a><a href="https://sourcemaking.com/refactoring/smells">More about Code Smells</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92bf22572e39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/karir-com-engineering/merefactor-data-clump-92bf22572e39">Merefactor Data Clump</a> was originally published in <a href="https://medium.com/karir-com-engineering">karir.com-engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>