<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Gaurav Koley</title>
 <link href="//gaurav.koley.in/atom.xml" rel="self"/>
 <link href="//gaurav.koley.in/"/>
 <updated>2022-02-13T03:15:21-05:00</updated>
 <id>//gaurav.koley.in</id>
 <author>
   <name>Gaurav Koley</name>
   <email>gaurav__at__koley__dot__in</email>
 </author>

 
 <entry>
   <title>Setup Development Environment on Windows with WSL 2</title>
   <link href="//gaurav.koley.in/2020/setup-development-env-on-windows"/>
   <updated>2020-07-04T10:35:00-04:00</updated>
   <id>//gaurav.koley.in/2020/setup-development-env-on-windows</id>
   <content type="html">&lt;p&gt;I had been living the “Windows free” life for almost 10 years even since I switched over to first &lt;a href=&quot;https://www.linuxmint.com/&quot;&gt;Linux Mint&lt;/a&gt;, then &lt;a href=&quot;https://ubuntu.com/&quot;&gt;Ubuntu&lt;/a&gt; and lately &lt;a href=&quot;https://pop.system76.com/&quot;&gt;Pop!_OS&lt;/a&gt;. Over these years, I went to university, learnt programming and earned 2 degrees in Computer Science, all the while programming on Ubuntu/the CLI.&lt;/p&gt;

&lt;p&gt;This changed in 2019 when I joined Microsoft as a Software Engineer and I had to familiarize myself with coding on Windows. Since then, I have worked on Windows for .NET, C# and several Nodejs projects but never did any heavy lifting like Python or Ruby on Rails. (If you are familiar with my blog, my personal projects revolve mostly around Ruby on Rails and VueJS.)&lt;/p&gt;

&lt;p&gt;So when Microsoft announced WSL 2, I had to try it out! I’ve always wanted to play games on Windows as well code, but switching my entire workflow to Windows from Pop!_OS wasn’t quite seamless as I wanted — so I was ready for an upgrade.&lt;/p&gt;

&lt;h3 id=&quot;install-wsl-2&quot;&gt;Install WSL 2&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Jump on the Windows Insider Program by joining in the Settings. You’ll need to be on build 18917 or above, which means you can choose either the Dev or Beta channel — the latter of which is more stable.&lt;/li&gt;
  &lt;li&gt;Once you’re up and running, &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/wsl/install-win10&quot;&gt;Install WSL 2 with the Linux flavor of your choice&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Download and install the &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel&quot;&gt;Linux kernel update package&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;And done! To make the environment seamless, try out &lt;a href=&quot;https://www.microsoft.com/en-us/p/windows-terminal-preview/9n0dx20hk701&quot;&gt;Microsoft’s new Terminal&lt;/a&gt; to switch between your Linux installs on demand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;install-docker&quot;&gt;Install Docker&lt;/h3&gt;

&lt;p&gt;Download and install &lt;a href=&quot;https://hub.docker.com/editions/community/docker-ce-desktop-windows/&quot;&gt;Docker Desktop Stable 2.3.0.2&lt;/a&gt; or a later release.&lt;/p&gt;

&lt;p&gt;After installation, on the Docker Deskop app, do the following steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;From the menu, select Settings &amp;gt; General.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Select the Use WSL 2 based engine check box. If you are using Windows 10 Home, this will be checked by default.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/public/images/wsl_enable.png&quot; alt=&quot;WSL Enable&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;Optionally, select any additional distributions you would like to access docker from, by going to Resources &amp;gt; WSL Integration.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/public/images/wsl_select.png&quot; alt=&quot;WSL Select&quot; /&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Click Apply &amp;amp; Restart.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you will be able to access docker and docker-compose within your WSL 2 installations too (and these work like native Ubuntu, so most of your existing docker and docker-compose scripts should work just fine).&lt;/p&gt;

&lt;p&gt;Fire up Windows Terminal and from the dropdown at the top, you should be able to get a bash shell to your WSL distro.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/terminal.png&quot; alt=&quot;Terminal&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Profit!&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;install-vs-code-with-remote-wsl-extension&quot;&gt;Install VS Code with Remote WSL Extension&lt;/h3&gt;

&lt;p&gt;If you don’t use VS Code, now is the perfect time to give it a try. Pair it with the &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl&quot;&gt;Remote WSL Extension&lt;/a&gt; and from your terminal, launch into Visual Studio Code using &lt;code&gt;code .&lt;/code&gt; from your WSL bash. You can even use &lt;code&gt;wsl code .&lt;/code&gt; to switch to Linux inline from Command Prompt or Powershell, launch into VS Code, then return to your Windows shell. :D&lt;/p&gt;

&lt;p&gt;Personally, I’m using WSL 2 for 100% of my development on Windows – all dev tools such as Git and Node.js are installed in my Linux environment.&lt;/p&gt;

&lt;p&gt;Here’s a look at me writing this post on WSL:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/vscode.png&quot; alt=&quot;VS Code Setup&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the screenshot, it is visible that I’m connected to my WSL 2 instance (see ‘WSL:Ubuntu’ in the bottom-left as the remote source). Also notice that my line endings are defaulted to LF (shown in the Status bar) without having to set any additional Git configuration options - if you’re on Windows working in open source, you understand why this is a big deal. Also all my favorite extensions work and are targeting the correct environment.&lt;/p&gt;

&lt;p&gt;With WSL 2, Windows has come a long way as a preferred programming platform and hopefully as the community matures, we would see more tightly integrated tools being ported from Linux to Windows.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>339 bytes of responsive CSS</title>
   <link href="//gaurav.koley.in/2019/339-bytes-of-responsive-css"/>
   <updated>2019-04-09T17:27:00-04:00</updated>
   <id>//gaurav.koley.in/2019/339-bytes-of-responsive-css</id>
   <content type="html">&lt;p&gt;7 CSS declarations and a/an (optional) font import is all it takes to change a drab basic website to a minimalistic easy to read piece of beauty.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-css&quot;&gt;@import url(&apos;https://fonts.googleapis.com/css?family=Fira+Sans:300&apos;);
body {
  font-family: &apos;Fira Sans&apos;, sans-serif;
  line-height: 1.6;
  color: #222;
  max-width: 40rem;
  padding: 2rem;
  margin: auto;
  background: #fafafa;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let’s go over this.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code&gt;font-family&lt;/code&gt; sets a font for your webpage. In this case, it sets ‘Fira Sans’. Incase, ‘Fira Sans’ is unavailable, the page would take the standard sans-serif font.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;line-height&lt;/code&gt; gives us some room between the lines, preventing it from looking like a wall of text and enhances readability.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;color&lt;/code&gt; and &lt;code&gt;background&lt;/code&gt; together reduce the text-to-background contrast making it easier on the eyes.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;max-width&lt;/code&gt; with &lt;code&gt;padding&lt;/code&gt; and &lt;code&gt;margin&lt;/code&gt; restrict the content to a maximum of 640px, aligns it in the middle and makes sure that the text never hits the edges of the screen. And its even responsive. Looks good on mobile too!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s add some flavor with some colors and making images fit in with the text.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-css&quot;&gt;img {
  max-width: 100%;
}
a {
  color: #2ECC40;
  text-decoration: none;
}
h1, h2, strong {
  color: #111;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These 4 CSS rule-sets together form a base for a simple, readable website. The best part about this code is that its completely class free and works well with default browser styles. 
It puts in perspective how much overengineering goes into building websites when people use Bootstrap for their blogs.&lt;/p&gt;

&lt;p&gt;Browsers and CSS engines in them have come a long way since 2011 when Bootstrap was introduced. CSS styles are standard and consistent across browsers today and require minimal tweaking to work flawlessly. Bootstrap, Foundation, Semantic-UI etc. are great CSS frameworks and they have their own use cases. However, people tend to overuse them and that has led to websites being laden with ton of unnecessary CSS.&lt;/p&gt;

&lt;p&gt;With just &lt;strong&gt;339 Bytes&lt;/strong&gt; and &lt;strong&gt;20 lines&lt;/strong&gt; of CSS, a reasonably good looking text heavy website can be designed. See it at work: &lt;a href=&quot;https://blog.koley.in/baserock/&quot;&gt;Baserock&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; This article got much more attention than I expected it to have and with that attention came a few suggestions on how this CSS can be improved.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Drop the use of Google Fonts as a dependency, use system fonts. Removed Fira since its thin font style would cause readability issues on non hi-res monitors.&lt;/li&gt;
  &lt;li&gt;Retain underlines for links&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With those changes in place:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-css&quot;&gt;body {
  font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #222;
  max-width: 40rem;
  padding: 2rem;
  margin: auto;
  background: #fafafa;
}
img {
  max-width: 100%;
}
a {
  color: #2ECC40;
}
h1, h2, strong {
  color: #111;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now, the amount of css you need is &lt;strong&gt;296 Bytes&lt;/strong&gt;. Ba Dum Tss.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;The discussion is on Hacker News at: &lt;a href=&quot;https://news.ycombinator.com/item?id=19622786&quot;&gt;https://news.ycombinator.com/item?id=19622786&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Backup and restore Postgresql database running on docker</title>
   <link href="//gaurav.koley.in/2019/backup-and-restore-postgresql-database-running-on-docker"/>
   <updated>2019-02-05T15:25:00-05:00</updated>
   <id>//gaurav.koley.in/2019/backup-and-restore-postgresql-database-running-on-docker</id>
   <content type="html">&lt;p&gt;I use docker a lot, so much so that I even run PostgreSQL and MySQL on
docker rather than having them installed locally. This makes much more
sense when you have a local and production setup like mine where both 
run around docker. And so, every once in a while, I encounter a 
situation where I have to backup my Postgres databases.&lt;/p&gt;

&lt;p&gt;I use the standard official postgres docker image from &lt;a href=&quot;https://hub.docker.com/_/postgres&quot;&gt;Docker Hub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This image comes with two handy tools (&lt;code&gt;pg_dump&lt;/code&gt; and &lt;code&gt;psql&lt;/code&gt;) which let 
us take easy backups and restore them with equal ease.&lt;/p&gt;

&lt;p&gt;To backup, we use the &lt;code&gt;pg_dump&lt;/code&gt; tool:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;docker exec &amp;lt;postgres_container_name&amp;gt; pg_dump -U postgres &amp;lt;database_name&amp;gt; &amp;gt; backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This would create a text file named &lt;code&gt;backup.sql&lt;/code&gt; containing all the 
data and schema of your database. You can then import this data back 
into postgres using the &lt;code&gt;psql&lt;/code&gt; tool:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;docker exec -i &amp;lt;postgres_container_name&amp;gt; psql -U postgres -d &amp;lt;database_name&amp;gt; &amp;lt; backup.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;-i&lt;/code&gt; flag is of particular importance here because the &lt;code&gt;psql&lt;/code&gt; tool
needs to be run interactively for it to be able to read from the 
&lt;code&gt;backup.sql&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: The above commands assume that you have &lt;code&gt;postgres&lt;/code&gt; as the 
default user for the database. This is indeed the case for the 
standard postgres docker image.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Vue components in Multi-Page Apps</title>
   <link href="//gaurav.koley.in/2018/vue-components-in-multi-page-apps"/>
   <updated>2018-12-17T15:14:00-05:00</updated>
   <id>//gaurav.koley.in/2018/vue-components-in-multi-page-apps</id>
   <content type="html">&lt;p&gt;Over the past year, I have been working on &lt;a href=&quot;https://goodwill.zense.co.in&quot;&gt;Gratiato&lt;/a&gt;, a social networking site for students,
teachers and researchers to share papers, find relevant research and collaborators.&lt;/p&gt;

&lt;p&gt;Gratiato is built on top of Ruby on Rails with sprinkles of Vue for a very dynamic and interactive UI. Thus, the website is
a multi-page Rails app interspersed with Vue components. These components are written in &lt;code&gt;.vue&lt;/code&gt; Single File Components and
compiled with Webpacker and the Rails Webpacker gem. &lt;a href=&quot;http://blog.koley.in/2017/webpacker-with-rails4.2&quot;&gt;I wrote a post about that here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This allows me to use Vue components within Rails &lt;code&gt;.html.erb&lt;/code&gt; layouts as well as pass Rails data to the components by
sprinkling some wrapper code which I would talk about subsequently.&lt;/p&gt;

&lt;p&gt;So a typical Rails layout file looks like:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;!-- app/resources/show.html.erb --&amp;gt;

&amp;lt;div class=&quot;ui divided items&quot;&amp;gt;
  &amp;lt;div class=&quot;item&quot;&amp;gt;
    &amp;lt;div class=&quot;content&quot;&amp;gt;
      &amp;lt;%= link_to @resource.title, @resource, class: &quot;header&quot; %&amp;gt;
      &amp;lt;div class=&quot;vue-container&quot;&amp;gt;
        &amp;lt;!-- Vue Component --&amp;gt;
        &amp;lt;gratia-count /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div class=&apos;vue-container&apos;&amp;gt;
        &amp;lt;!-- Vue Component --&amp;gt;
        &amp;lt;get :resource=&quot;&amp;lt;%= @resource.to_json %&amp;gt;&quot;&amp;gt;&amp;lt;/get&amp;gt; &amp;lt;!-- passing Rails data as JSON using to_json --&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class=&quot;vue-container&quot;&amp;gt;
    &amp;lt;!-- Vue Component --&amp;gt;
    &amp;lt;show-pdf :resource=&quot;&amp;lt;%= @resource.to_json %&amp;gt;&quot;&amp;gt;&amp;lt;/show-pdf&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So there may be multiple &lt;code&gt;.vue-container&lt;/code&gt; containers which wrap our Vue components. I then initialize a Vue app on these containers
and then do the same for all the pages that need Vue components.&lt;/p&gt;

&lt;p&gt;In the above file &lt;code&gt;gratia-count&lt;/code&gt;, &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;show-pdf&lt;/code&gt; are three Vue components which I use.&lt;/p&gt;

&lt;p&gt;Then, I have a JS file which is imported for all the pages within which I have the following code:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;// app/javascript/packs/app.js
import Vue from &apos;vue/dist/vue.esm&apos;
import TurbolinksAdapter from &apos;vue-turbolinks&apos;

import store from &apos;./store&apos;
import ShowPdf from &apos;./ShowPdf.vue&apos;
import Get from &apos;./Get.vue&apos;
import GratiaCount from &apos;./GratiaCount.vue&apos;

Vue.use(TurbolinksAdapter)

[&apos;turbolinks:load&apos;, &apos;DOMContentLoaded&apos;].map(e =&amp;gt;
  document.addEventListener(e, () =&amp;gt; {

    if(window.vueapp == null){
      window.vueapp = []
    }
    if(window.vueapp != null){
      for(var i=0, len=vueapp.length; i &amp;lt; len; i++){
        vueapp[i].$destroy();
      }
      window.vueapp = []
    }
    var myNodeList = document.querySelectorAll(&apos;.vue-container&apos;);
    forEach(myNodeList, function (index, element) {
      if (element != null) {
        var vueapp = new Vue({
          el: element,
          store,
          components: {
            ShowPdf, Get, GratiaCount  // my components
          }
        })
        window.vueapp.push(vueapp);
      }
    });
  })
)

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This creates and initializes a Vue instance on every &lt;code&gt;.vue-container&lt;/code&gt; DOM element with all the components registered and everything works!
An important thing to note is that all the components are being registered with all the Vue apps being created here.&lt;/p&gt;

&lt;p&gt;The code in &lt;code&gt;app.js&lt;/code&gt; also cleans any remnants of previous Vue instances created by itself and reinitializes everything on page load. This
is particularly useful when using this in conjuction with Turbolinks which is fairly common in Rails.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-js&quot;&gt;[&apos;turbolinks:load&apos;, &apos;DOMContentLoaded&apos;].map(e =&amp;gt;
  document.addEventListener(e, () =&amp;gt; {
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This piece of code ensures that the Vue instances are cleaned and initialized on page load for both turbolinks and regular page load. 
&lt;code&gt;Vue.use(TurbolinksAdapter)&lt;/code&gt; ensures that Vue works seamlessly with Turbolinks.&lt;/p&gt;

&lt;h3 id=&quot;sharing-data&quot;&gt;Sharing data&lt;/h3&gt;

&lt;p&gt;If you need to share data among the different components, across the different containers, any of the standard data sharing techniques
like an &lt;a href=&quot;https://vuejs.org/v2/guide/migration.html#dispatch-and-broadcast-replaced&quot;&gt;Event Bus&lt;/a&gt; or Vuex would work just fine. In my use,
I use a Vuex store as shown by &lt;code&gt;store&lt;/code&gt; in the code above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;
The Vue components may be defined in any manner which the developer sees fit. The mentioned approach works irrespective of component being
a SFC or a global component such as:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-html&quot;&gt;&amp;lt;div id=&quot;fruit-template&quot; class=&quot;vue-template&quot;&amp;gt;
  &amp;lt;div class=&quot;fruit&quot;&amp;gt;
    &amp;lt;h3&amp;gt;&amp;lt;/h3&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
  Vue.component(&apos;my-fruit&apos;, {
    template: &apos;#fruit-template&apos;,
    props: [&apos;fruit-name&apos;]
  });
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</content>
 </entry>
 
 <entry>
   <title>Why GitHub will still be at the top</title>
   <link href="//gaurav.koley.in/2018/why-github-will-still-be-at-the-top"/>
   <updated>2018-06-06T04:48:00-04:00</updated>
   <id>//gaurav.koley.in/2018/why-github-will-still-be-at-the-top</id>
   <content type="html">&lt;p&gt;&lt;em&gt;This post has been crossposted from the &lt;a href=&quot;http://zense.co.in/2018/06/06/github-will-still-be-at-the-top/&quot;&gt;Zense Blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Microsoft recently announced that it is buying GitHub for &lt;a href=&quot;https://arstechnica.com/gadgets/2018/06/microsoft-snaps-up-github-for-7-5-billion/&quot;&gt;$7.5 billion dollars&lt;/a&gt;, and predictably, &lt;a href=&quot;https://developers.slashdot.org/story/18/06/04/0935200/microsofts-interest-in-buying-github-draws-backlash-from-developers&quot;&gt;there’s a developer backlash&lt;/a&gt;. Microsoft’s history with acquisitions has not been good, notably Skype, Wunderlist and Nokia. However, in recent years that has not been the case.&lt;/p&gt;

&lt;p&gt;Satya Nadella has been an incredible game changer for Microsoft. Starting from joining hands with Linux foundation to launching Microsoft first ever laptops. Since Nadella joined Microsoft, stocks of the company have doubled.&lt;/p&gt;

&lt;p&gt;When Microsoft bought LinkedIn, the tech community agreed with Microsoft’s vision that this acquisition will help both LinkedIn and Microsoft with the access to all the professional profiles of the people around the globe. Then why the backlash with them acquiring GitHub?&lt;/p&gt;

&lt;p&gt;People in the Open Source community are saying “RIP GitHub” and talking of switching to GitLab. The main concerns raised are that:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Microsoft will kill/damage GitHub.&lt;/li&gt;
  &lt;li&gt;GitHub freebies like Student Developer Pack would no longer be available.&lt;/li&gt;
  &lt;li&gt;Microsoft will have access to our “private code”.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The so-called “benefits” of GitLab are stated that it is free, it has more features, you are able to easily import your GitHub Projects, and most importantly that you can self-host GitLab. Let us back up a little bit. &lt;strong&gt;Why did people not take a look at GitLab before the news of GitHub’s acquisition?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GitLab has been around since 2012 and has gained the attention of people who want to use services like private repositories for free. Most of the organizations who have their repositories on GitLab have them as Private. This means no one else can see their code. This has been the trend of GitLab users and because of this, it has been hard for GitLab to create a community like GitHub where everyone wants to share their code instead of just storing it privately. One of the primary reasons why GitHub managed to have a 27 Million strong community is because people started using GitHub as a place to show off their projects and not merely as an online git storage facility. The fact that one has to pay to have private repositories deterred people from making private repos and encouraged them to participate in the open source movement by open sourcing their own code.&lt;/p&gt;

&lt;p&gt;GitHub came into the market in 2008 and took almost 8-9 years to develop this vibrant community that we see around it. In fact, for most people, GitHub was the gateway to Git and Version Control Systems and not the other way round.&lt;/p&gt;

&lt;p&gt;Further, GitHub has pumped in a tremendous amount of money and effort in building open source tools, the most notable projects being - &lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt; (Static Site Generator), &lt;a href=&quot;https://atom.io/&quot;&gt;Atom&lt;/a&gt; (Text Editor), &lt;a href=&quot;https://electron.atom.io/&quot;&gt;Electron&lt;/a&gt; (JS library to build Desktop apps), the last of which was game changer in how desktop apps are built. GitHub has never been in profit since they came in the industry and have been burning cash ever since. Such a model was clearly not sustainable and either GitHub had to be acquired by some corporation or be shut down. The fact that they managed to be bought by Microsoft which vehemently opposed Open Source until a few years ago, for a whopping $7.5 Billion is something to reckon.&lt;/p&gt;

&lt;p&gt;Coming to the concerns raised regarding the acquisition, ever since Microsoft acquired LinkedIn around two years ago, nothing has changed for the worse. Rather LinkedIn’s user experience has improved and the website has become faster than before. Microsoft did not create any new paid services or make free services as paid. Nothing has changed with respect to the core essence of LinkedIn. So it just makes us wonder why are thinking that bad things will happen to GitHub post-acquisition.&lt;/p&gt;

&lt;p&gt;In the past few years, Microsoft has been one of the leaders in Open Source. In the past year, they have been the largest code contributor on GitHub. They open sourced Visual studio code which is now being used by millions of developers and has left other editors behind in terms of usability and features. Microsoft also recently moved all of their documentation to GitHub allowing developers to contribute to it. Other notable mentions include the Microsoft Edge JavaScript engine and PowerShell. Microsoft also struck a deal with Canonical to develop the Windows Subsystem for Linux on Windows 10. And Linux is now fully supported on Microsoft’s cloud platform Azure.&lt;/p&gt;

&lt;p&gt;Microsoft new, under Satya Nadella, is much different from Microsoft old and we at Zense believe this step of acquiring GitHub will be helpful for both GitHub and the Open Source developer community at large. Even while steadily losing money over the past decade, GitHub has managed to deliver outstanding products and now with the backing of the third most valuable company, we feel that GitHub will do even better. This $7.5B acquisition validates that open source is indeed turning the way we code and is signalling that this is the new era for open source.&lt;/p&gt;

&lt;p&gt;At &lt;a href=&quot;https://zense.co.in&quot;&gt;Zense&lt;/a&gt;, GitHub is integral to our entire development workflow and we will remain using GitHub for all of the foreseeable future. With that being said, it would be interesting to see what kinds of integration Microsoft has planned for GitHub. Personally, we would like to see deeper integration with Microsoft Teams and LinkedIn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/shreyakupadhyay/&quot;&gt;@shreyakupadhyay&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
Group Manager, &lt;a href=&quot;https://zense.co.in&quot;&gt;Zense&lt;/a&gt;&lt;br /&gt;
&lt;strong&gt;&lt;a href=&quot;https://gaurav.koley.in&quot;&gt;@arkokoley&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
Group Coordinator, &lt;a href=&quot;https://zense.co.in&quot;&gt;Zense&lt;/a&gt;&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Install and Setup Rundeck on Ubuntu</title>
   <link href="//gaurav.koley.in/2018/install-and-setup-rundeck-on-ubuntu"/>
   <updated>2018-04-20T18:17:00-04:00</updated>
   <id>//gaurav.koley.in/2018/install-and-setup-rundeck-on-ubuntu</id>
   <content type="html">&lt;p&gt;Requirements: Ubuntu, Java&lt;/p&gt;

&lt;p&gt;1. Install Java:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo apt install openjdk-8-jdk
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;2. Download the latest run deck debian packages from this link
&lt;a href=&quot;http://rundeck.org/download/deb/&quot;&gt;http://rundeck.org/download/deb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3. Install the package using the following command&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo dpkg -i {rundeck package name}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;4. You can now start the Rundeck server using:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;sudo service rundeckd start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;5. Now you can access the server at the url: &lt;a href=&quot;http://localhost:4440&quot;&gt;http://localhost:4440&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will see a login page. Login as:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Username: admin&lt;br /&gt;
Password: admin&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;6. Create a new project at the url:
&lt;a href=&quot;http://localhost:4440/resources/createProject&quot;&gt;http://localhost:4440/resources/createProject&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill in the Name and Description and let all other details be set in their
default values and click &lt;strong&gt;Create&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;7. Add Nodes/Clients to the Project&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/nodes.png&quot; alt=&quot;Add Nodes&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;strong&gt;Edit&lt;/strong&gt; for the Source file and mark the &lt;strong&gt;Writable&lt;/strong&gt; option as
checked and Save.&lt;/p&gt;

&lt;p&gt;You would now be able to edit the nodes file.&lt;/p&gt;

&lt;p&gt;Edit the nodes file and add the following line:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;  &amp;lt;node name=&quot;client&quot; description=&quot;Client Node&quot; tags=&quot;&quot;
  hostname=&quot;Put Client Node IP Here&quot; osArch=&quot;amd64&quot; osFamily=&quot;unix&quot; 
  osName=&quot;Linux&quot; osVersion=&quot;4.13.0-36-generic&quot; 
  username=&quot;Put Client Node User Here&quot; sudo-command-enabled=&quot;true&quot;
  sudo-password-option=&quot;option.sudoPassword&quot;/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Save the file and click &lt;strong&gt;Save&lt;/strong&gt; again.&lt;/p&gt;

&lt;p&gt;8. &lt;strong&gt;Authenticated access to the clients:&lt;/strong&gt; 
   Rundeck uses ssh with ssh keys to securely access the client nodes. We need
   to set up access keys for this to happen.&lt;/p&gt;

&lt;p&gt;Run the following steps on your &lt;strong&gt;rundeck server&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;cd /var/lib/rundeck
mkdir -p .ssh
cd .ssh
sudo ssh-keygen
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will prompt you for a file name. Enter &lt;code&gt;id_rsa&lt;/code&gt;. Just press enter for
the prompt “Enter passphrase”. You will get something
similar to the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): id_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
SHA256:brKX0tb8fVkqcuiupNeQVMkRGJl/xZwyfAAJ8lK17eU root@arkokoley-PC
The keys randomart image is:
+---[RSA 2048]----+
|      . +O=B.+ . |
|       ++ =o+ *  |
|      . .o. .=.  |
|       .. ...o   |
|       .S. .. E  |
|       .o       .|
|      ..+* .   .o|
|      .** * o....|
|      o=.+o+.... |
+----[SHA256]-----+
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can now view the &lt;code&gt;id_rsa.pub&lt;/code&gt; file via &lt;code&gt;cat id_rsa.pub&lt;/code&gt;. We need to copy
the contents of this file to the client node.&lt;/p&gt;

&lt;p&gt;Install and start ssh service on your &lt;strong&gt;client node&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;sudo apt install ssh
sudo service ssh start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Copy the contents of &lt;code&gt;id_rsa.pub&lt;/code&gt; file from the &lt;strong&gt;rundeck server&lt;/strong&gt; and then perform the following operations in the &lt;strong&gt;client node&lt;/strong&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;cd ~
mkdir -p .ssh
cat &amp;gt;&amp;gt; ~/.ssh/authorized_keys
&amp;lt;Paste the contents of id_rsa.pub file from the rundeck server&amp;gt;

^C

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Verify that the contents were copied properly by viewing the contents of
&lt;code&gt;~/.ssh/authorized_keys&lt;/code&gt; in the &lt;strong&gt;client node&lt;/strong&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-sh&quot;&gt;cat ~/.ssh/authorized_keys
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we can test that the Rundeck server is able to access the client node.
Go to (Assuming &lt;strong&gt;“Test”&lt;/strong&gt; is the name of your project): 
&lt;a href=&quot;http://localhost:4440/project/Test/command/run&quot;&gt;http://localhost:4440/project/Test/command/run&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;Nodes&lt;/code&gt; input box, put in your client node name and click &lt;code&gt;Search&lt;/code&gt;. Then
in the &lt;code&gt;Command&lt;/code&gt; input box, type in the command &lt;code&gt;echo test&lt;/code&gt; and then click &lt;code&gt;Run
on 1 Node&lt;/code&gt;. You will be able to see the output &lt;code&gt;test&lt;/code&gt; below.&lt;/p&gt;

&lt;p&gt;9. &lt;strong&gt;Create a Job&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;To create a Job, go to (Assuming your project name is &lt;strong&gt;“Test”&lt;/strong&gt;):
&lt;a href=&quot;http://localhost:4440/project/Test/job/create&quot;&gt;http://localhost:4440/project/Test/job/create&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Put in a Job Name, Description.&lt;/p&gt;

&lt;p&gt;Earlier, when declaring our client node, we had put this piece of code:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-xml&quot;&gt;sudo-command-enabled=&quot;true&quot; sudo-password-option=&quot;option.sudoPassword&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This allows us to input &lt;code&gt;sudo&lt;/code&gt; passwords for different client nodes
on the go through the web GUI without having to store them in any config file.&lt;/p&gt;

&lt;p&gt;To make use of this feature, we create an &lt;code&gt;Option&lt;/code&gt; in the Job form.&lt;/p&gt;

&lt;p&gt;Set the option Name as “sudoPassword”, the same as mentioned in the node file.
Set &lt;code&gt;Input Type&lt;/code&gt; as “Secure” and click &lt;code&gt;Save&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add any number of &lt;code&gt;Steps&lt;/code&gt; in the Job workflow. All these steps will be run
sequentially.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/job.png&quot; alt=&quot;Job Steps&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Set &lt;code&gt;Nodes&lt;/code&gt; to “Dispatch to Nodes” and Set the &lt;code&gt;Node Filter&lt;/code&gt; if you want to
filter which nodes to run this job on.&lt;/p&gt;

&lt;p&gt;Set the other options as required and click &lt;code&gt;Create&lt;/code&gt; to save this job.&lt;/p&gt;

&lt;p&gt;You can now open the Job and run it. Before you run, you can specify the sudo
password in the &lt;code&gt;sudoPassword&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/job_run.png&quot; alt=&quot;Run Job&quot; /&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Root user in Docker Container</title>
   <link href="//gaurav.koley.in/2018/root-user-in-docker-container"/>
   <updated>2018-02-15T16:33:00-05:00</updated>
   <id>//gaurav.koley.in/2018/root-user-in-docker-container</id>
   <content type="html">&lt;p&gt;I have been playing around with Docker for a while. I use Docker for all of my
Rails development and deployment tasks. So, every once in a while I encounter a
situation where I have to enter the root user mode in the Docker container.&lt;/p&gt;

&lt;p&gt;If you think that the solution to the above problem is simply:&lt;br /&gt;
&lt;code&gt;$ docker run -it &amp;lt;container_name&amp;gt; sudo bash&lt;/code&gt;, then you will find that &lt;code&gt;sudo&lt;/code&gt; is
not included by default in most docker base images.&lt;/p&gt;

&lt;h2 id=&quot;so-what-is-the-solution&quot;&gt;So what is the solution?&lt;/h2&gt;

&lt;p&gt;The current recommended solution, as of Docker 1.3 is to run the following
command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ docker exec -u 0 -it &amp;lt;container_name_or_id&amp;gt; /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here, the &lt;code&gt;-u 0&lt;/code&gt; flag specifies that the root user with id &lt;code&gt;0&lt;/code&gt; be used to run
&lt;code&gt;/bin/bash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To run this command, your container needs to be running already.&lt;/p&gt;

&lt;p&gt;If you wish to enter as root into an image, run the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ docker run -u 0 -it &amp;lt;image_name_or_id&amp;gt; /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above mentioned commands adhere to all the restrictions that your docker
container adheres to.&lt;/p&gt;

&lt;p&gt;There is also an alternative way which doesn’t enter the cgroups, and therefore 
evades resource limitations. The potential benefit of this would be debugging and 
external audit.&lt;/p&gt;

&lt;p&gt;To do this, first determine the PID of your container on the host:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
$ PID=`docker inspect --format {{.State.Pid}} &amp;lt;container_name_ID&amp;gt;`

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then use nsenter to enter the container as root&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ nsenter --target $PID --mount --uts --ipc --net --pid
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And you will have access to a root shell in your desired container. This method
works only for containers which are currently running.&lt;/p&gt;

&lt;p&gt;Single line command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ nsenter --target `docker inspect --format  &amp;lt;container_name_or_ID&amp;gt;` --mount --uts --ipc --net --pid
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;sources&quot;&gt;Sources:&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/jpetazzo/nsente://github.com/jpetazzo/nsenter&quot;&gt;Looking to start a shell inside a Docker container?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Searching in Rails with Solr, Sunspot and Docker</title>
   <link href="//gaurav.koley.in/2018/searching-in-rails-with-solr-sunspot-and-docker"/>
   <updated>2018-01-19T07:16:00-05:00</updated>
   <id>//gaurav.koley.in/2018/searching-in-rails-with-solr-sunspot-and-docker</id>
   <content type="html">&lt;p&gt;Over the past few months, I have been working on a project titled &lt;a href=&quot;http://goodwill.zense.co.in&quot;&gt;Goodwill
Currency&lt;/a&gt; for the &lt;a href=&quot;https://wsl.iiitb.ac.in&quot;&gt;Web Science Lab @
IIIT-B&lt;/a&gt;. It is a Ruby on Rails based portal with a
VueJS frontend.&lt;/p&gt;

&lt;p&gt;One of the interesting challenges that I came across was search. Since most of
the content on this portal will be hidden behind a login wall, we need a custom
search solution. Enter Solr and Sunspot.&lt;/p&gt;

&lt;p&gt;Solr is a OpenSource Search platform based on Apache Lucene and has an
excellent community around it. The documentation is excellent although running
it in production can be a bit challenging.&lt;/p&gt;

&lt;p&gt;Sunspot is a ruby integration for solr and has excellent support for Rails.
To integrate sunspot:&lt;/p&gt;

&lt;p&gt;Add to the Gemfile&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;gem &apos;sunspot_rails&apos;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Install using &lt;code&gt;bundle install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Generate configuration file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rails g sunspot_rails:install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For the app, let’s assume we’ve got a Resource model (as is the case in my
app), with title, description and tag_list fields. Also, we have an association
&lt;code&gt;creators&lt;/code&gt; which is a &lt;code&gt;has_many&lt;/code&gt; which in turn has a “name” field.&lt;/p&gt;

&lt;p&gt;To set it up for keyword search, we use the searchable method:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;class Resource &amp;lt; ApplicationRecord

  has_many :creators

  searchable do
    text :title, :default_boost =&amp;gt; 2
    text :description
    text :creators do     # for associations
      creators.map { |creator| creator.name }
    end
    text :tag_list, :default_boost =&amp;gt; 2
    time :created_at
  end

end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;text&lt;/code&gt; here means that we’re creating a field that’s fulltext-searchable.
It’ll be broken apart into individual keywords, and then those keywords will be
matched against the words in keyword search queries.&lt;/p&gt;

&lt;p&gt;There are quite a few other field types, but text is the only one that is
searched by keywords.&lt;/p&gt;

&lt;p&gt;That &lt;code&gt;default_boost&lt;/code&gt; parameter means that, unless otherwise specified, words
matching the &lt;code&gt;title&lt;/code&gt; field should be considered twice as relevant as words
matching the &lt;code&gt;description&lt;/code&gt; field.&lt;/p&gt;

&lt;p&gt;Now that Sunspot knows how to index the Post model, we need to get the existing
data into Solr.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake sunspot:reindex
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Apart from any change in the &lt;code&gt;searchable&lt;/code&gt; definition, any time a Post is
created, updated, or destroyed, Sunspot will automatically make the change to
the index.&lt;/p&gt;

&lt;p&gt;Now lets add a new action to the controller which will handle our search
queries.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;class ResourcesController &amp;lt; ApplicationController

  # GET /resources/search?q={query}
  # GET /resources/search.json?q={query}
  def search
    @search = Resource.search(:include =&amp;gt; [:creators]) do
      keywords(params[:q])
    end
    @title = &quot;Search results for &quot;+params[:q]
    @resources = @search.results
    respond_to do |format|
      format.html { render &apos;resources/index&apos; }
      format.json { render &apos;resources/search&apos; }
    end
    end

end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above code utilises search form where a user types in some
keywords, which submits a &lt;code&gt;:q&lt;/code&gt; param to the &lt;code&gt;ResourcesController#search&lt;/code&gt;
action which then renders the results using the view for the &lt;code&gt;index&lt;/code&gt; action.&lt;/p&gt;

&lt;p&gt;Thats it! We are done configuring Rails for Solr and Sunspot.&lt;/p&gt;

&lt;p&gt;Now, lets start our Solr server.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;sunspot_solr&lt;/code&gt; gem if you want to run Solr in development.&lt;/p&gt;

&lt;p&gt;Sunspot embeds Solr inside the gem so there’s no need to install it separately.
This means that everything works straight out of the box which makes it far more
convenient to use in development.&lt;/p&gt;

&lt;p&gt;Add to Gemfile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem &apos;sunspot_rails&apos;
gem &apos;sunspot_solr&apos;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Run Solr server:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;bundle exec rake sunspot:solr:start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can now access the solr server from browser:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;http://localhost:8983/solr/#/
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;deploying-solr-search-to-production&quot;&gt;Deploying Solr Search to production&lt;/h2&gt;

&lt;p&gt;I prefer to deploy all of my Rails apps on docker using &lt;code&gt;docker-compose&lt;/code&gt;. So we
will be using docker-compose to deploy Solr as well.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;# docker-compose.yml

version: &apos;3&apos;
services:
  web:
    build: .
    ports:
      - &quot;3000:3000&quot;
    dns: &quot;8.8.8.8&quot;
    volumes:
      - &quot;.:/app&quot;
    env_file: .env
    links:
      - db:db
      - solr:solr
      # In production instead add external_links for db
    command: bash -c &quot;bin/rake assets:precompile &amp;amp;&amp;amp; bin/rake db:create &amp;amp;&amp;amp; bin/rake db:migrate &amp;amp;&amp;amp; bin/rails s&quot; 

  # In production remove this and add an external link in web
  db:
    image: postgres:latest
    environment:
      - POSTGRES_PASSWORD=somePassword
    volumes:
      - ./database:/var/lib/postgresql
  solr:
    image: solr:7.0.1
    ports:
      - &quot;8983:8983&quot;
    volumes:
      - data:/opt/solr/server/solr/mycores
    entrypoint:
      - docker-entrypoint.sh
      - solr-precreate
      - mycore
    links:
      - db:db
volumes:
  data: {}

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Go edit your &lt;code&gt;config/sunspot.yml&lt;/code&gt; for the right settings for production mode.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-yaml&quot;&gt;production:
  solr:
    hostname: solr # since our solr instance is linked as solr
    port: 8983
    log_level: WARNING
    solr_home: solr
    path: /solr/mycore 
    # this path comes from the last command of our entrypoint as
    # specified in the last parameter for our solr container
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that is all.&lt;/p&gt;

&lt;h2 id=&quot;common-initial-troubleshooting&quot;&gt;Common Initial Troubleshooting.&lt;/h2&gt;

&lt;p&gt;If you see:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Errno::ECONNREFUSED (Connection refused - connect(2))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then perhaps:&lt;/p&gt;

&lt;p&gt;You have not started the solr server:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake sunspot:solr:start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you see&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Solr::Error::Http (RSolr::Error::Http - 404 Not Found
Error:     Not Found

URI: http://localhost:8983/solr/development/select?wt=json
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a new core using the admin interface at:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;http://localhost:8983/solr/#/~cores
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or by running the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;docker-compose exec solr solr create_core -c development
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Resources:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://gist.github.com/maxivak/e1211b67d33add72a4c4#run-solr-in-production&quot;&gt;Run Solr in Production with
Tomcat&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/sunspot/sunspot&quot;&gt;Sunspot docs&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>The Internet is creating Net-States</title>
   <link href="//gaurav.koley.in/2017/net-states"/>
   <updated>2017-12-08T00:00:00-05:00</updated>
   <id>//gaurav.koley.in/2017/net-states</id>
   <content type="html">&lt;h2 id=&quot;abstract&quot;&gt;Abstract&lt;/h2&gt;

&lt;p&gt;A nation-state is a geopolitical entity with the cultural entity of a
nation, from which it aims to derive its political legitimacy to rule. A
few key features of the nation-state are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A Sovereign Government&lt;/li&gt;
  &lt;li&gt;Exclusive/Semi-exclusive Citizenship&lt;/li&gt;
  &lt;li&gt;Territorial Integrity or Territorial Impermeability&lt;/li&gt;
  &lt;li&gt;Nationalism as the core Philosophy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Web and Internet are two of the most significant technologies that
are currently shaping our world. The increased Internet penetration and
cheap access has spawned a whole lot of very popular web based services:
search and advertising services like those offered by Google, social
networks like Facebook, Twitter, Instagram; video stores like YouTube
and others.&lt;/p&gt;

&lt;p&gt;An individual generates tremendous amount of data pertaining to his or
her activities throughout the day, using these services. This data acts
as a user’s identity or a “Data Double” on the Web with the service
provider often being considered as the guarantor of the authenticity of
the user. Our profiles at Facebook, Instagram, LinkedIn, Uber are such
identities. And they are trusted albeit only to a certain extent.&lt;/p&gt;

&lt;p&gt;Also each of these Web Giants have their own governance style,
characterised by their rules and regulations which are determined by
both policy and the algorithms that run these platforms. Adding to that,
the web is increasingly encouraging more cross-border exchanges of goods
and services, allowing users and firms to bypass national borders.&lt;/p&gt;

&lt;p&gt;These phenomena raises the question of: Are these Web Giants a different
kind of nation-state themselves? Is the Internet helping shape
Net-States? To answer these questions, we use the theory of
sociomateriality.&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;With the increased presence of Internet and the Web we see a rise of a
new class of digital communities which are closely knit, have a concept
of memberships or “Citizenship” which acts a means of authentication and
are governed by a governing body of moderators and algorithms. They have
no physically territorial presence but they do have a very significant
digital territory and go to great lengths to preserve that digital
territorial integrity. Facebook and Quora are excellent examples of such
communities. Like all things online, the interests, affiliations and
goals of these groups are knit tighter than what their nation states may
dictate.&lt;/p&gt;

&lt;p&gt;These communities might seem superfluous and virtual but they do have
significant traction in real life. Noteworthy is the fact that online
communities actually invoke a passion that nation states were intended
to do when they were formed hundreds of years before. Members or
“Citizens” of such communities feel deeply passionate about their
communities and are often eager to leverage their community identity in
other contexts.&lt;/p&gt;

&lt;p&gt;The clash between these affiliations has already started, in some way or
the other, in some or other parts of the world. The revolution in Egypt,
and to a lesser extent in other countries of the Middle East, was kept
alive by the active online communities. It proved crucial in the end. In
China, the Party and the people clash less in the streets and more
across the forums online. The party doesn’t have to send tanks anymore;
it sends viruses to take servers down.  (Omroutray 2017)&lt;/p&gt;

&lt;p&gt;Facebook in particular is one community to worry about because of its
historically unprecedented size. With nearly two billion active users
across much of the globe, the company wields a potential influence that
at least threatens to outstrip the power of some governments.  (Alang
2017)&lt;/p&gt;

&lt;p&gt;To define these new powerful, digital states, lets propose a new
lexicon, Net-State.&lt;/p&gt;

&lt;h2 id=&quot;net-states&quot;&gt;Net States&lt;/h2&gt;

&lt;p&gt;Net-states are techno-politicial entities which are similar to nation
states in structure and behaviour. Like nation-states, they’re a wildly
diverse. Some are the equivalent to global superpowers: Google,
Facebook, Twitter. Others are paramilitary operations, like GhostSec
which is an invite-only cyberarmy specifically created to target the
ISIS. There are also the hacktivist collectives like Anonymous and
Wikileaks.  (Wichowski 2017)&lt;/p&gt;

&lt;p&gt;Regardless of the differences, all Net-States share three key qualities:
They exist largely online, enjoy international devotees, and advance
belief-driven agendas that they pursue separate from, and at times,
above, the law. Formalising these qualities, a Net-State can be termed
as an entity which has the following characteristics:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A Sovereign “Government”&lt;/li&gt;
  &lt;li&gt;Citizenship&lt;/li&gt;
  &lt;li&gt;Digital Territorial Impermeability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To expand on each of these criterion, A Net-State has a governing body
that may be a group of individuals, a corporation, a set of algorithms
or a mixture of all of these. Corporate Social Media-esque Net-States
like Facebook and Twitter are run by a government equivalent comprising
of its corporate official, moderators and algorithms that define the
social media feed. Hacktivist Net-States like Anonymous are governed
loosely by a group of core members.&lt;/p&gt;

&lt;p&gt;These governing bodies largely determine the entirety of the functioning
of the Net-State and are mostly free from influence from outsiders (read
sovereign) as are nation states.&lt;/p&gt;

&lt;p&gt;These Net-States also have a equivalent system of Citizenship which
enables its members to access the state machinery and get benefits.
These benefits may be access to news, as in the case of Net-States like
Facebook and Twitter, access a variety of online services like email and
AI based personal assistants as in the case of Google, or job offerings,
in the case of LinkedIn.&lt;/p&gt;

&lt;p&gt;This citizenship also serves as an identity to other places. For
example, one can use their Google or Facebook credentials to login to
various websites. YouTube/Quora fame turns one into a celebrity in real
life as well. GitHub contributions gets one jobs in real life and the
list of examples can go on.&lt;/p&gt;

&lt;p&gt;Net-States, while being the champions of cutting across national
boundaries, having members across the globe, advocate strong digital
boundaries of their own. Net-States prefer to live in silos. While the
citizens may have citizenship of multiple Net-States, the data they
create and share with the state remains tightly controlled by that state
and in usually never allowed to be exported or deleted. Other Net-states
may have restricted access to citizens’ data but that too remains at the
mercy of the Net-State government.&lt;/p&gt;

&lt;h2 id=&quot;nation-state-vs-net-state&quot;&gt;Nation State vs Net-State&lt;/h2&gt;

&lt;p&gt;While Nation and net states seem to have a lot in common, they represent
very different concepts. The former is based on the idea of tribes, that
common ancestry, language and cultural heritage are enough to build the
foundation of a state. The latter is built on the idea of like
mindedness. People with similar goals come together to build and be part
of net states.&lt;/p&gt;

&lt;p&gt;Another key difference between Nation states and Net-States conceptually
is that it is assumed to be the case that a person will be part of
multiple Net-States and they are. However, a person will usually be
citizen of a single nation state.&lt;/p&gt;

&lt;p&gt;The level of democratization that Net-States have inherently within them
cannot be modelled by the nation states. This partly from the fact that
the populace of the net states helped define the state. Change in
governing structures and constitution equivalents are faster and much
more deliberated upon by the citizens in Net-states than in Nation
States. Net-states are infusing us with new values, ones that are not
always national in nature: a growing number of people see themselves as
‘global’ citizens.&lt;/p&gt;

&lt;p&gt;A country’s sovereignty will be increasingly difficult to maintain as
there will be a conflict between loyalties of virtual and real citizens.
Even today, the opinion polls are conducted globally on variety of
complex issues affecting the politico-economic scenarios.&lt;/p&gt;

&lt;p&gt;As the number of internet user keeps growing, from 3.4 billion to soon
reaching over 7 billion by 2020, the Nation-states are facing the
cross-border influences and grappling to unite their citizens.  (Dr.
Govind 2016)&lt;/p&gt;

&lt;p&gt;If we look at the global scenario, the internet is a major factor for
dynamically changing cross-cultural habits, entertainment, education,
economy and politics. The internet is encouraging more cross-border
exchanges of goods and services, thereby allowing consumers and firms to
bypass national borders.&lt;/p&gt;

&lt;p&gt;An example of cross-cultural habits that the Internet is infusing in us
is Memes. The creation of a meme is simply found in the number of times
Internet users share it and spread it around. Anyone can upload a
picture and caption it, but only when it reaches a certain scale and
others also start to use it does it become a meme.&lt;/p&gt;

&lt;p&gt;From a theoretical standpoint, this is quite the democratic process.
This underlines the fact that, at its heart, the culture of the Internet
Nation is a democratic one. On the Internet, everyone can take part in
the discussions and express themselves. The billions of people connected
through the Internet create a powerful and active network democratically
granting influence to other people, governments and
companies. (Rharbaoui 2017)&lt;/p&gt;

&lt;p&gt;So we can say that Net-State culture works in large numbers, with
unprecedented scale, and it is participatory. India is often deemed the
world’s biggest democracy. To think about it, Net-States like Facebook
are actually the largest democratically-operating structure on Earth.&lt;/p&gt;

&lt;p&gt;And the formidable vehicle that allows this phenomenon to happen is
English, the language of Net-State is the same as that of business and
technology, and every “citizen” of the state learns it as a 1st, 2nd,
3rd or 4th language. Having a common language across continents and
countries facilitates sharing the same piece of content over and over
again, just as Latin did in the Middle Ages and French during the
Enlightenment. It creates conditions in which information can appear
faster and spread faster.&lt;/p&gt;

&lt;p&gt;The immediate consequences are political. Some countries are leading the
way, with Denmark recently announcing its appointment of a digital
ambassador in Silicon Valley to do diplomatic work with the world’s
largest tech companies. If that’s a positive development, the widely
debated question of fake news and its potential contribution to the
election of Donald Trump may be on the other side of the spectrum.
 (Rharbaoui 2017)&lt;/p&gt;

&lt;p&gt;So what’s the next step for these online democracies? Send their own
representatives to countries. Google did it in 2006. Facebook is doing
it now. It is preparing a foreign service that will do what is generally
done by ambassadors. This is Facebook reaching out global heads of
states directly as a unique entity which is not tied down by national
boundaries. (Omroutray 2017)&lt;/p&gt;

&lt;h2 id=&quot;internet-the-driving-force&quot;&gt;Internet: The Driving Force&lt;/h2&gt;

&lt;p&gt;The idea that Net-State are becoming as powerful as Nation-states in the
global scenario is a reality and the Internet is the driving force
behind this change. Never before now, humanity had a technology as such,
that breaks down all barriers of distance and accessibility. For the
first time in Human history, we have access to a technological
construct, the Internet, which has revolutionized information and
communications. On the Internet and the Net-states that we rising, we
are participants. The Internet uses us as much as we use the Internet.&lt;/p&gt;

&lt;p&gt;So, in reality, the driving force behind the rising Net-States is not
Internet, the technology, but Internet, the collective, which consists
of both the technology, the people using it and the corporations which
created the everyday services that we use.&lt;/p&gt;

&lt;p&gt;While Facebook indeed brought the world closer with its social network,
it is the people that form that network. It is the fact that 2 billion
people use Facebook for keeping in touch with friends and colleagues,
read news or just to share memes, that makes Facebook as powerful as it
seemingly is.&lt;/p&gt;

&lt;p&gt;The systems have evolved over time, as mentioned previously, in a
participatory fashion. The people as well as the technology together
have made Net-States as they are.&lt;/p&gt;

&lt;p&gt;To look at it from the socio-materialistic perspective, it is the
intricate relationship between the Internet, the platforms (Facebook,
Twitter, LinkedIn, Google) and the user (or “citizens”) from which the
Net-states derive their power and legitimacy. Without the backing of the
billions of users, Net-States like Facebook and Google would not have
the soft power that they enjoy. And without the technological
advancements of the Internet and Social Media/ Search/ AI on these
platforms, people wouldn’t have the global access to information and
communication as they do. It is the Social Machine of the platform and
its users that creates the Net-State.&lt;/p&gt;

&lt;p&gt;To conclude, it was the confluence of a number of technologies — the
telegraph, the train, the printing press, and more - that enabled the
nation state to form in the first place, unifying far flung people
through physical and ideological links. And now, we are immersed in a
technological platform that we turn to for media, for socializing, for
finance, and community, the question arises regarding what role the
nation state plays when affiliations have become closely knit and
passion evoking than they are in the form of a “country.” Indeed, as
these Net-states, which exist in the digital realm, continue to grow, we
are coming in terms with change in the idea of a country itself.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;div id=&quot;refs&quot; class=&quot;references&quot;&gt;
&lt;div id=&quot;ref-Alang2017&quot;&gt;
&lt;p&gt;Alang, Navneet. 2017. “The nation of Facebook.” &lt;a href=&quot;http://theweek.com/articles/734883/nation-facebook&quot; class=&quot;uri&quot;&gt;http://theweek.com/articles/734883/nation-facebook&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Berners-Lee:1999:WWO:554813&quot;&gt;
&lt;p&gt;Berners-Lee, Tim, and Mark Fischetti. 1999. &lt;em&gt;Weaving the Web: The Original Design and Ultimate Destiny of the World Wide Web by Its Inventor&lt;/em&gt;. 1st ed. Harper San Francisco.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Bertlett2017&quot;&gt;
&lt;p&gt;Bertlett, Jamie, and Sam Haselby. 2017. “The end of a world of nation-states may be upon us.” &lt;a href=&quot;https://aeon.co/essays/the-end-of-a-world-of-nation-states-may-be-upon-us&quot; class=&quot;uri&quot;&gt;https://aeon.co/essays/the-end-of-a-world-of-nation-states-may-be-upon-us&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Casey2017&quot;&gt;
&lt;p&gt;Casey, Doug. 2017. “The End of the Nation-State.” &lt;a href=&quot;https://mises.org/blog/end-nation-state&quot; class=&quot;uri&quot;&gt;https://mises.org/blog/end-nation-state&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Dr.Govind2016&quot;&gt;
&lt;p&gt;Dr. Govind. 2016. “The internet is the new geography: Nation-states beware, netizens are the citizens of the future.” &lt;a href=&quot;http://www.firstpost.com/tech/news-analysis/the-internet-is-the-new-geography-nation-states-beware-netizens-are-the-citizens-of-the-future-3694889.html&quot; class=&quot;uri&quot;&gt;http://www.firstpost.com/tech/news-analysis/the-internet-is-the-new-geography-nation-states-beware-netizens-are-the-citizens-of-the-future-3694889.html&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Kotler&quot;&gt;
&lt;p&gt;Kotler, Steven. 2017. “What Is the Future of Nation States? – Better Ask Facebook.” &lt;a href=&quot;https://www.forbes.com/sites/stevenkotler/2014/05/09/what-are-the-future-of-nation-states-better-ask-facebook/{\#}7550ace4720b&quot; class=&quot;uri&quot;&gt;https://www.forbes.com/sites/stevenkotler/2014/05/09/what-are-the-future-of-nation-states-better-ask-facebook/{\#}7550ace4720b&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Muggah2017&quot;&gt;
&lt;p&gt;Muggah, Robert. 2017. “Countries are so last-century. Enter the ’net state’ | World Economic Forum.” &lt;a href=&quot;https://www.weforum.org/agenda/2017/11/countries-nations-net-states-globalization-populism/&quot; class=&quot;uri&quot;&gt;https://www.weforum.org/agenda/2017/11/countries-nations-net-states-globalization-populism/&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Omroutray&quot;&gt;
&lt;p&gt;Omroutray. 2017. “Can Facebook &amp;amp; Google claim to be the new nation states? | The Young Bigmouth.” Accessed December 5. &lt;a href=&quot;http://theyoungbigmouth.com/2011/06/01/can-facebook-google-claim-to-be-the-new-nation-states/&quot; class=&quot;uri&quot;&gt;http://theyoungbigmouth.com/2011/06/01/can-facebook-google-claim-to-be-the-new-nation-states/&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Rharbaoui2017&quot;&gt;
&lt;p&gt;Rharbaoui, Younès. 2017. “Culture of the Internet Nation.” &lt;a href=&quot;https://salon.thefamily.co/culture-of-the-internet-nation-756a1e9b6ee5&quot; class=&quot;uri&quot;&gt;https://salon.thefamily.co/culture-of-the-internet-nation-756a1e9b6ee5&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Stern2015&quot;&gt;
&lt;p&gt;Stern, Maximilian. 2015. “The Internet and the End of the Nation State,” February. The European. &lt;a href=&quot;http://www.theeuropean-magazine.com/maximilian-stern--2/9580-the-internet-and-the-end-of-the-nation-state&quot; class=&quot;uri&quot;&gt;http://www.theeuropean-magazine.com/maximilian-stern--2/9580-the-internet-and-the-end-of-the-nation-state&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;ref-Wichowski2017&quot;&gt;
&lt;p&gt;Wichowski, Alexis. 2017. “Facebook and Google Are Actually ’Net States.’ And They Rule the World | WIRED.” &lt;a href=&quot;https://www.wired.com/story/net-states-rule-the-world-we-need-to-recognize-their-power/&quot; class=&quot;uri&quot;&gt;https://www.wired.com/story/net-states-rule-the-world-we-need-to-recognize-their-power/&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;

</content>
 </entry>
 
 <entry>
   <title>Multiple Associations Between 2 models in Rails </title>
   <link href="//gaurav.koley.in/2017/multiple-associations-b-w-2-models-in-rails"/>
   <updated>2017-09-25T17:10:00-04:00</updated>
   <id>//gaurav.koley.in/2017/multiple-associations-b-w-2-models-in-rails</id>
   <content type="html">&lt;p&gt;I have been working on a project as a part of &lt;a href=&quot;http://wsl.iiitb.ac.in&quot;&gt;Web Science Lab @ IIIT-B&lt;/a&gt;
which is essentially an online marketplace of content. I am building this marketplace using Ruby on
Rails 5 for backend and VueJS for a rich frontend.&lt;/p&gt;

&lt;p&gt;The marketplace has Resources and Users. There are other models in the platform as well but for the sake
of this post, Resources and Users are the models of interest.&lt;/p&gt;

&lt;p&gt;Users can create some resources and consume some other resources. This entails that Users may be either
&lt;strong&gt;Creators&lt;/strong&gt; or &lt;strong&gt;Consumers&lt;/strong&gt; or both. Likewise, the &lt;strong&gt;Resource&lt;/strong&gt; can be termed as &lt;strong&gt;Creation&lt;/strong&gt; or
&lt;strong&gt;Consumable&lt;/strong&gt; respectively. This presents a somewhat rare situation. There, now exist, 2 associations
between the same 2 models.&lt;/p&gt;

&lt;p&gt;A Resource might have multiple creators and a Creator might create multiple resources. Also, it might
be obvious to notice that a Resource will have multiple Consumers and a Consumers will consumer multiple
resources. This can be depicted as in this image:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/user_resource.png&quot; alt=&quot;User Resource Association&quot; /&gt;&lt;/p&gt;

&lt;p&gt;To achieve this, what I did was have a join model &lt;strong&gt;Association&lt;/strong&gt; generated using:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-shell&quot;&gt;→ rails g scaffold association user:belongs_to resource:belongs_to association_type:string
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here &lt;strong&gt;association_type&lt;/strong&gt; helps us achieve the multiple associations. In the application, we restrict it to have
only one of the two specified values: &lt;strong&gt;consumer&lt;/strong&gt; or &lt;strong&gt;creator&lt;/strong&gt;. This is done by:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;# app/models/association.rb

class Association &amp;lt; ApplicationRecord
  belongs_to :user
  belongs_to :resource

  validates :association_type, presence: true, inclusion: { in: %w(consumer creator),
    message: &quot;Association %{value} is not one of the types available.&quot;
  }
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, we setup the User and Resource Models as following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;# app/models/user.rb

class User &amp;lt; ApplicationRecord

  has_many :associations
  has_many :creation_associations, -&amp;gt; {where &apos;association_type = &quot;creator&quot;&apos;}, class_name: &quot;Association&quot;
  has_many :consumable_associations, -&amp;gt; {where &apos;association_type = &quot;consumer&quot;&apos;}, class_name: &quot;Association&quot;

  has_many :creations, through: :creation_associations, source: :resource
  has_many :consumables, through: :consumable_associations, source: :resource
end
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;# app/models/resource.rb
class Resource &amp;lt; ApplicationRecord
  has_many :associations
  has_many :creators, -&amp;gt; {where &apos;association_type = &quot;creator&quot;&apos;}, class_name: &quot;User&quot;, through: :associations
  has_many :consumers, -&amp;gt; {where &apos;association_type = &quot;consumer&quot;&apos;}, class_name: &quot;User&quot;, through: :associations

end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, a Creator(User) can access their creations as: &lt;code&gt;user.creations&lt;/code&gt; and a Consumer can access their consumables
through &lt;code&gt;user.consumables&lt;/code&gt;. Likewise, resources have handles:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-ruby&quot;&gt;resource.creators # For list of creators of this resource

resource.consumers # For a list of Consumers
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With this setup, multiple types of associations between 2 models might be established. This setup is extendable to
include other kinds of associations (maybe, maintainer or licencer etc).&lt;/p&gt;

&lt;p&gt;Hope this helped. For any queries, ping me at my email: gaurav__at__koley__dot__in&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>VueJS with Webpack on Rails 4.2</title>
   <link href="//gaurav.koley.in/2017/webpacker-with-rails4.2"/>
   <updated>2017-05-12T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2017/webpacker-with-rails4.2</id>
   <content type="html">&lt;p&gt;VueJS is a snazzy new frontend Javascript Framework that helps build reactive User Interfaces. I have been following VueJS since its beta and have recently been &lt;a href=&quot;https://github.com/zense/goliath/tree/v2&quot;&gt;using it&lt;/a&gt; &lt;a href=&quot;http://vstock.guru&quot;&gt;extensively&lt;/a&gt; for my projects.&lt;/p&gt;

&lt;p&gt;I use VueJS with Ruby on Rails. So far this was done by writing the Vue components as individual &lt;code&gt;erb&lt;/code&gt; partials and then include them in the UI as shown below. VueJS would compile the components and inject them as necessary at the client side.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-erb&quot;&gt;&amp;lt;%= render &apos;shares/_shares_component&apos; %&amp;gt;
&amp;lt;div id=&quot;shares_row&quot;&amp;gt;
  &amp;lt;shares apiurl=&quot;&amp;lt;%= root_url%&amp;gt;shares/&amp;lt;%= @market_name %&amp;gt;.json&quot; market=&quot;&amp;lt;%= @market_name %&amp;gt;&quot;&amp;gt;&amp;lt;/shares&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
  var nasdaq = new Vue({
    el: &apos;#shares_row&apos;
  });
&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This approach works when you don’t have many components and don’t have components being composed of other components themselves. That is where things start to get messy.&lt;/p&gt;

&lt;p&gt;The VueJS community recommends use of &lt;a href=&quot;https://github.com/vuejs/vue-loader&quot;&gt;webpack&lt;/a&gt; to create and manage large scale Vue projects. This requires a nodejs runtime and the ability to inject transpiled and minified JS into the &lt;code&gt;layouts/application.html.erb&lt;/code&gt; view. So how do I connect webpack with Rails?&lt;/p&gt;

&lt;h3 id=&quot;enter-webpacker&quot;&gt;Enter, &lt;a href=&quot;https://github.com/rails/webpacker&quot;&gt;Webpacker&lt;/a&gt;.&lt;/h3&gt;

&lt;p&gt;Add the webpacker gem to your Gemfile as: &lt;code&gt;gem &apos;webpacker&apos;, github: &apos;rails/webpacker&apos;&lt;/code&gt;&lt;br /&gt;
and run &lt;code&gt;bundle install&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Then run&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;→ rake webpacker:install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you get an error like &lt;code&gt;/usr/bin/env: ‘ruby2.2’: No such file or directory&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Solve it by:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;→ sudo update-alternatives --install /usr/bin/ruby2.2 ruby2.2 &amp;lt;location of your ruby binary&amp;gt; 1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Here &lt;code&gt;&amp;lt;location of your ruby binary&amp;gt;&lt;/code&gt; is typically in &lt;code&gt;/home/&amp;lt;username&amp;gt;/.rvm/rubies/ruby-2.2.2/bin/ruby&lt;/code&gt; if you use rvm.&lt;/p&gt;

&lt;p&gt;Then, run&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;→ rake webpacker:install:vue
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to install a webpack compatible vuejs project in the &lt;code&gt;app/javascripts/packs/&lt;/code&gt; folder. This also creates a &lt;code&gt;package.json&lt;/code&gt; file in the rails root directory as well as a &lt;code&gt;config/webpack/&lt;/code&gt; folder containing the webpack configuration for the VueJS project. The configuration works out of the box and you don’t really need to make any changes here.&lt;/p&gt;

&lt;p&gt;Next, add &lt;code&gt;&amp;lt;%= javascript_pack_tag &apos;application&apos; %&amp;gt;&lt;/code&gt; in your &lt;code&gt;layouts/application.html.erb&lt;/code&gt; view to include the &lt;code&gt;application.js&lt;/code&gt; file from &lt;code&gt;app/javascripts/packs/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And we are done!&lt;/p&gt;

&lt;p&gt;Now while developing, run &lt;code&gt;./bin/webpack-dev-server&lt;/code&gt; alongside &lt;code&gt;rails serve&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To deploy, do nothing! Webpacker hooks up a new &lt;code&gt;webpacker:compile&lt;/code&gt; task to &lt;code&gt;assets:precompile&lt;/code&gt;, which gets run whenever you run &lt;code&gt;assets:precompile&lt;/code&gt;. The &lt;code&gt;javascript_pack_tag&lt;/code&gt; and &lt;code&gt;stylesheet_pack_tag&lt;/code&gt; helper method will automatically insert the correct HTML tag for compiled pack.&lt;/p&gt;

&lt;p&gt;For further reading,&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rails/webpacker&quot;&gt;Webpacker on Github&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://pixelatedworks.com/articles/replacing-the-rails-asset-pipeline-with-webpack-and-yarn/&quot;&gt;Replacing the Rails Asset Pipeline with Webpack and Yarn&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://clarkdave.net/2015/01/how-to-use-webpack-with-rails/&quot;&gt;How to use Webpack with Rails&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
</content>
 </entry>
 
 <entry>
   <title>January 27 2015</title>
   <link href="//gaurav.koley.in/2015/january-27"/>
   <updated>2015-01-27T00:00:00-05:00</updated>
   <id>//gaurav.koley.in/2015/january-27</id>
   <content type="html">&lt;p&gt;26th January.&lt;/p&gt;

&lt;p&gt;The Republic day of India. And the day which evokes the patriotism of a lot of people across the country.&lt;/p&gt;

&lt;p&gt;Different kinds of patriotism. There are those who shout out “Happy Republic Day” on all social networks and post pictures of themselves with a plastic national flag, one that will be on the ground at the day comes to an end. Then there are those who call out the former as “fake patriots” because their patriotism ignites only on the days of Public Holidays and subsides the next day. But then these are the people who indulge in armchair politics and candlelight marches and in the end proclaim that this country is done for. Ask them what they have done to make their nation worth living for and you will hear them say that their efforts never made a mark. I say if their efforts were futile, they didn’t try hard enough.&lt;/p&gt;

&lt;p&gt;The real patriot is the one who’s patriotism is reflected in what he does all round the year not just one day. A real patriot is the one who works tirelessly throughout his life with true belief in that all that his country, his nation signifies. His passion for the country is not in armchair politics or in candle light marches. His patriotism is in the day’s work that gives him the satisfaction that his work affects the nation at large and in a positive way. You don’t have the right to run along proclaiming that this country is done for if you have done nothing in your life to make a difference to this country, to make this independence count.&lt;/p&gt;

&lt;p&gt;The Constitution of India gave us a set of 5 Fundamental Rights, that we exercise with much gusto, but with it, also gave us a set of Fundamental Duties which each citizen of this country is expected to fulfill. Google “Fundamental Duties of an Indian Citizen” and you will receive a list of duties that you are supposed to perform. Ask yourself this, how many of these have you fulfilled partially, let alone completely.&lt;/p&gt;

&lt;p&gt;So as the day next to the Republic Day begins, bring about a small change in yourself.&lt;/p&gt;

&lt;p&gt;Throw that scrap of paper, lying on the road, into a proper dustbin.&lt;/p&gt;

&lt;p&gt;Think again before defacing any public monument with hearts and cupid arrows.&lt;/p&gt;

&lt;p&gt;Complain to the authorities if you see child labor around you. If possible, get that kid freed and make sure he gets proper education.&lt;/p&gt;

&lt;p&gt;Make in India what you would have otherwise brought from abroad.&lt;/p&gt;

&lt;p&gt;Instead of turning a blind eye, go help that girl who’s being harassed.&lt;/p&gt;

&lt;p&gt;Say no Bribes.&lt;/p&gt;

&lt;p&gt;Say yes to Sanitation and Cleanliness.&lt;/p&gt;

&lt;p&gt;This year, be the change you want in this country. Only then will this country change.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>May 16 2014</title>
   <link href="//gaurav.koley.in/2014/may-16"/>
   <updated>2014-05-16T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2014/may-16</id>
   <content type="html">&lt;p&gt;7 p.m.&lt;/p&gt;

&lt;p&gt;I was outside my home, on the patio, with a friend discussing the results on the Indian General Elections 2014.&lt;/p&gt;

&lt;p&gt;An Ice-Creamwala, with his cart - he sells his wares on the corner of the street - called me up and asked: “भईया इलेक्शन का क्या नतीजा आया?” What do the Election results say?&lt;/p&gt;

&lt;p&gt;I told him. BJP has itself secured a majority and with its allies, is 330+ strong. No more coalition Governments. Modi has won. Congress has performed the worst ever with its 50 and AAP has just 4.&lt;/p&gt;

&lt;p&gt;“तो बाकी सब?” The rest?&lt;/p&gt;

&lt;p&gt;Divided in regional parties, I told him.&lt;/p&gt;

&lt;p&gt;He smiled. There was a sparkle in his eyes. Hope, perhaps.&lt;/p&gt;

&lt;p&gt;He walked away with his cart and I could only smile as I felt around me the change in the atmosphere all around me. People smiling, infused with hope for a better regime.&lt;/p&gt;

&lt;p&gt;This change was palpable right from the beginning of the day. For the first time in my entire life had I switched on the Television to watch the news and that too right after waking up.&lt;/p&gt;

&lt;p&gt;This was probably the only time after India’s independence that the youth was more interested in May 16 than February 14. Gone are the days when youth and middle classes didn’t take interest in the Elections. India is changing. The youth is changing. हवा बदली है। अब देश बदलेगा।&lt;/p&gt;

&lt;p&gt;Maybe for real, Acche din aane wale hai.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Goliath: Alternative Wordpress Dashboard</title>
   <link href="//gaurav.koley.in/2014/goliath"/>
   <updated>2014-04-24T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2014/goliath</id>
   <content type="html">&lt;h2 id=&quot;i-love-wordpress-we-all-love-wordpress&quot;&gt;I love Wordpress. We all love WordPress.&lt;/h2&gt;

&lt;p&gt;With that being said I would like to declare that I love the idea of WordPress. I love its community. Its far reaching presence and the ease with which one can start working with it. However, I hate, better said, I despise, WordPress’s Administration interface. I absolutely hate it! The clutter, the tacky menus and the pain to work with it in mobile. Phew! The wordpress Admin Interface is such that by the time one reaches its editor to start writing, a large part of the desire to write will have vanished. And this is what gnaws at me.&lt;/p&gt;

&lt;p&gt;I also build websites with WordPress, many of which required users with absolutely no knowledge of computers, let alone of WordPress, it becomes a pain in the ass to show them every time where to go and how to get started with the writing and content contributing process. Many a times and many a solutions(plugins) I have tried to make sense of then problem but all existing solutions took me on a fair ride and brought me to the same place as before.&lt;/p&gt;

&lt;p&gt;Although WordPress and its team (awesome team!) did do a good job in revamping and beautifying the interface in its newer versions, but for me that just wasn’t enough. All I wanted was a simpler Admin Interface for WordPress, the likes of Svbtle, Medium and Roon.io, that will for just once let me focus on the writing, the content.&lt;/p&gt;

&lt;p&gt;Frustrated and charged with a mission, I set forth to build which I now introduce to you:&lt;/p&gt;

&lt;p&gt;#&lt;center&gt;Goliath&lt;/center&gt;&lt;/p&gt;
&lt;h3 id=&quot;alternative-wordpress-dashboard&quot;&gt;&lt;center&gt;Alternative WordPress Dashboard&lt;/center&gt;&lt;/h3&gt;
&lt;h6 id=&quot;ba-dum-tss&quot;&gt;&lt;center&gt;Ba Dum Tss&lt;/center&gt;&lt;/h6&gt;

&lt;p&gt;Goliath is an alternative Admin Interface for WordPress that focusses on design and aesthetics. Goliath was inspired by &lt;a href=&quot;http://svbtle.com&quot;&gt;Svbtle&lt;/a&gt; and &lt;a href=&quot;http://medium.com&quot;&gt;Medium&lt;/a&gt;, both of which have excellently designed editor and Administrative interfaces. Goliath was built with the objective to bring the &lt;strong&gt;Distraction Free&lt;/strong&gt; environment of the aforementioned blogging platforms to WordPress.&lt;/p&gt;

&lt;p&gt;Goliath is simple. Clear consise buttons and other indicators clearly describe what goes where. The aim is to let the writer focus on writing and hold the other items for another time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Have a look:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Dashboard: 
&lt;img src=&quot;https://raw.githubusercontent.com/arkokoley/goliath/master/Screenshot1.png&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Editor:
&lt;img src=&quot;https://raw.githubusercontent.com/arkokoley/goliath/master/Screenshot2.png&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Editor menu in action:
&lt;img src=&quot;https://raw.githubusercontent.com/arkokoley/goliath/master/Screenshot3.png&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;like-it-then-let-me-tell-you-how-to-set-it-up&quot;&gt;Like it? Then let me tell you how to set it up:&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Download the files from here: &lt;a href=&quot;https://github.com/arkokoley/goliath/archive/master.zip&quot;&gt;https://github.com/arkokoley/goliath/archive/master.zip&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Unzip the files to a folder. Name it “dash”.&lt;/li&gt;
  &lt;li&gt;Upload “dash” to your WordPress root.&lt;/li&gt;
  &lt;li&gt;Profit! :D&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;so-what-is-goliath&quot;&gt;So What is Goliath?&lt;/h3&gt;

&lt;p&gt;Goliath is nothing but a bunch of PHP, CSS and Javascript files slapped together with some magic glue.&lt;/p&gt;

&lt;p&gt;Goliath borrows heavlily from &lt;a href=&quot;http://svbtle.com&quot;&gt;Svbtle&lt;/a&gt;’s design. While the editor, based on &lt;a href=&quot;http://sofish.github.com/pen/&quot;&gt;Pen&lt;/a&gt; by &lt;a href=&quot;http://sofish.de/&quot;&gt;Sofish&lt;/a&gt;, is basically copied from &lt;a href=&quot;http://medium.com&quot;&gt;Medium&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;what-else&quot;&gt;What Else?&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Less Distractions. More Writing.&lt;/strong&gt; 
As you can see, Golaith is in bare minimums with no distractions. No SEO settings, no category selection, no Tag selections. Just writing. Goliath encourages you to write first and later optimize as required for SEO or whatnot.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Less Options.&lt;/strong&gt;
Unlike the default WordPress Admin Interface, Goliath has no metadata sections. It consists of just the Post title and its content. Any metadata additions have to be done in the WordPress default interface, &lt;strong&gt;When you are not writing&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Markdown Support.&lt;/strong&gt;
Yeah this is for those supergeeks (like me) who like to write in &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; (A text formatting syntax developed by John Gruber). Goliath support Markdown out of the box. However, he can only read Markdown, not write it. Meaning, posts can be written in Markdown and they will be parsed to HTML on the go, with the final result being stored as HTML. So you can write in Markdown and not have to install any plugin too. Capital!&lt;/p&gt;

&lt;h3 id=&quot;what-next&quot;&gt;What Next?&lt;/h3&gt;

&lt;p&gt;I plan to keep adding features to and extending Goliath. I look forward to working with plugin makers who would like to have Goliath support for their fruits of labour. Hopefully in near future, Goliath will surely be an actual alterntive to the default interface not just in terms of fashion but function too.&lt;/p&gt;

&lt;h3 id=&quot;faq&quot;&gt;FAQ&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Wait, Who the hell are you?&lt;/strong&gt; My name is Gaurav Koley. I’m a 17 year old student. I have been blogging since 2009 and creating websites since then using mostly WordPress and Jekyll/Docpad. I started an edu-site &lt;a href=&quot;http://nxtclass.in&quot;&gt;NXTClass&lt;/a&gt; and a Blog based on poetry: &lt;a href=&quot;http://www.poetsareus.com&quot;&gt;Poets Are Us&lt;/a&gt;, since I’m poet myself. I also built a Jekyll Blog Framwork called &lt;a href=&quot;http://arkokoley.github.io/posts/presenting-sani&quot;&gt;Sani&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wait, didn’t [someone] do it before? You stole the idea from them!&lt;/strong&gt; Well, the WP-Svbtle team did do something exactly like this but they have long stopped working on it. And I’m going to do it anyway because I built Goliath to suit my needs and it does that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sounds Cool. Where do I get it?&lt;/strong&gt; &lt;a href=&quot;http://github.com/arkokoley/goliath&quot;&gt;Its available on Github&lt;/a&gt;. &lt;a href=&quot;http://www.poetsareus.com&quot;&gt;Poets Are Us&lt;/a&gt; uses Goliath for its poets. Its still a rather unfinished product, but I’d love help from people who would like to see this work. If you are interested in getting involved, let’s chat. I’m at &lt;a href=&quot;http://twitter.com/arkokoley&quot;&gt;@arkokoley&lt;/a&gt; and &lt;a href=&quot;mailto:arkokoley@live.in&quot;&gt;arkokoley@live.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I hate it/ hate you/ hate everything.&lt;/strong&gt; Point duly noted. But then haters gonna hate.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>First Logo</title>
   <link href="//gaurav.koley.in/2013/first-logo"/>
   <updated>2013-09-14T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2013/first-logo</id>
   <content type="html">&lt;p&gt;Yesterday (13 September 2013), I got the oppertunity to be asked by 
Navdeep Singh Rana, the owner and admin of IndiaExam.in, to design a logo for 
IndiaExam.&lt;/p&gt;

&lt;p&gt;I have made a few logos here but almost all them were either for my personal 
projects or just for fun. This one was a serious one. For the first time, my 
work was to be used by a large entity and is to be viewed and appreciated by 
a lacs of people.&lt;/p&gt;

&lt;p&gt;The logo, as Navdeep puts it:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;“[The logo] symbolises that if one road is closed for you, take the other one. 
One road connects to the other. But whatever you do, never stop moving 
forward. Everything happens for a reason. You need to keep your mind 
and eyes open to see it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But I see it as simply an abstract entity, an extension of our infinite thought 
process that ultimately derives itself from somewhere else but morphs into 
a part of our soul.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://indiaexam.in&quot;&gt;&lt;img src=&quot;/public/images/indiaexam.png&quot; alt=&quot;logo&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Presenting Sani - Just A Blogging Framework</title>
   <link href="//gaurav.koley.in/2012/presenting-sani"/>
   <updated>2012-11-26T00:00:00-05:00</updated>
   <id>//gaurav.koley.in/2012/presenting-sani</id>
   <content type="html">&lt;h2 id=&quot;i-love-blogging&quot;&gt;I love blogging.&lt;/h2&gt;

&lt;p&gt;Having said that I would like to emphasise that I love blogging not blog handling. But as those two come in packages, I have to deal with it. I tried a lot of blogging solutions, Wordpress, Tumblr, Blogger, Octopress and Jekyll-Bootstrap. And frankly I hate them all now.&lt;/p&gt;

&lt;p&gt;WordPress is just too clunky to satisfy my needs of a simplistic blog. Tumblr far too minimalistic and its hosted.(I like Self hosting my blogs.)&lt;/p&gt;

&lt;p&gt;Coming to Static blogging frameworks, both Octopress and Jekyll Bootstrap, although awesome blogging frameworks, are far too complex. Even a small change in the theme requires changes in the original theme, then installing the theme and finally generating the site. I can list these complexities on and on but I would refrain from doing that for now.&lt;/p&gt;

&lt;p&gt;Another great thing that Jekyll Bootstrap and Octopress don’t support is Prose.io. &lt;a href=&quot;http://arkokoley.github.com/blog/2012/09/07/hello-prose/&quot;&gt;I wrote about it a few months ago.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Octopress and Jekyll Bootstrap the set out to simplify blogging with Jekyll but have rather added on to the problem.&lt;/p&gt;

&lt;p&gt;And with that I introduce:&lt;/p&gt;

&lt;p&gt;#&lt;center&gt;Sani&lt;/center&gt;&lt;/p&gt;
&lt;h3 id=&quot;just-a-blogging-framework&quot;&gt;&lt;center&gt;Just A Blogging Framework&lt;/center&gt;&lt;/h3&gt;

&lt;p&gt;Sani is a blogging framework designed for Jekyll, to be used on Github Pages with Prose.io.&lt;/p&gt;

&lt;p&gt;To start blogging with Jekyll, you need to write your own HTML templates, CSS, Javascripts and set up your configuration. But with Sani, all you need to do is clone or fork Sani, install dependencies, and you’re set. All else is taken care of.(This is when you are setting up from your own computer.)&lt;/p&gt;

&lt;p&gt;Setting up Sani is so easy, it can be done even if you don’t have access to the device your regularly use.&lt;/p&gt;

&lt;p&gt;Just the following steps are needed to setup a Sani powered blog on GH:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Fork &lt;a href=&quot;http://github.com/arkokoley/sani/&quot;&gt;Sani&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Rename the forked repo to ‘username.github.com’, where username is your username.&lt;/li&gt;
  &lt;li&gt;Log in to &lt;a href=&quot;http://prose.io&quot;&gt;Prose.io&lt;/a&gt;. It works with Github, don’t worry.&lt;/li&gt;
  &lt;li&gt;Navigate to the newly forked repo and edit the _config.yml.&lt;/li&gt;
  &lt;li&gt;Navigate to _posts/ in that repo, create a new file and start writing.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it! Only 5 steps and about 5 minutes to setup a blog from zero.&lt;/p&gt;

&lt;h3 id=&quot;so-what-is-sani-is-exactly&quot;&gt;So what is Sani is exactly?&lt;/h3&gt;

&lt;p&gt;Sani is a bunch of HTML, CSS and Javascript files along with a Rakefile. The HTML, CSS and JS form the theme while rake gives you automation regarding generating and publishing the blog. Sani is an implementation of what people, who don’t use Octopress and Jekyll Bootstrap, use to make do with GH pages.&lt;/p&gt;

&lt;p&gt;Sani uses Disqus for comments and a theme designed by &lt;a href=&quot;http://adrianartiles.com/&quot;&gt;Adrian Artiles&lt;/a&gt;. (Much obliged, sir) Also, the rakefile is mostly ripped off from Octopress with some modifications.&lt;/p&gt;

&lt;h3 id=&quot;what-else&quot;&gt;What Else?&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Less Terminal. More Writing.&lt;/strong&gt; 
The one thing I hate about Octopress and Jekyll-Bootstrap is the frequent jumps from my favourite text editor to the terminal. This is why Sani makes use of Prose.io which allows posts to be created and edited right from the browser and published directly, without the use of the terminal at all. Even so, Sani packs in the Rakefile for automation in post/page creation and publishing. A complete list of rake commands will be available soon.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Less Options.&lt;/strong&gt;
Unlike other Jekyll based frameworks, Sani is minimalistic and I intend to keep it that way. NO plugins of any kind or support for systems other than GH pages. Minor additions will be accepted and anything heavy and bloated will be let go.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No learning Curve.&lt;/strong&gt;
Sani has been created by a noob (Me! :D) so its code is pretty simple. All there is of the code is a Rakefile and HTML, CSS and JS files that make up the theme. Any theme compatible with Jekyll is compatible with Sani. Sani has been built for People and Jekyll, not the other way round.&lt;/p&gt;

&lt;h3 id=&quot;faq&quot;&gt;FAQ&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Wait, Who the hell are you?&lt;/strong&gt; My name is Gaurav Koley. I’m a 16 year old student. I have been blogging since 2009 and creating websites since then using mostly WordPress and Drupal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Wait, didn’t [someone] do it before? You stole the idea from them!&lt;/strong&gt; Well, they probably did do something like this. But I’m going to do it anyway because I created Sani to suit my need and it does that. Further, development and maintaining Sani will give me the experience of maintaing an Open Source project, which is what Sani is: an Open Source Project. As for stealing ideas, yes, I did steal a lot of things! The theme has been designed by &lt;a href=&quot;http://adrianartiles.com&quot;&gt;Adrian Artiles&lt;/a&gt;. The rakefile was stolen from Octopress. Even the idea of the layout of this post was stolen from &lt;a href=&quot;http://john.onolan.org/ghost/&quot;&gt;John O’Nolan’s Ghost&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sounds Cool. Where do I get it?&lt;/strong&gt; &lt;a href=&quot;http://github.com/arkokoley/sani&quot;&gt;Its available on Github&lt;/a&gt;. &lt;a href=&quot;http://arkokoley.github.com&quot;&gt;This Blog&lt;/a&gt; is built using Sani and uses the default theme. Its still a rather unfinished product, but I’d love help from people who would like to see Sani bigger, better and stronger. If you are interested in getting involved, let’s chat. I’m at &lt;a href=&quot;http://twitter.com/arkokoley&quot;&gt;@arkokoley&lt;/a&gt; and &lt;a href=&quot;mailto:arkokoley@live.in&quot;&gt;arkokoley@live.in&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I hate it/ hate you/ hate everything.&lt;/strong&gt; Point duly noted. But then haters gonna hate.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>New Logo</title>
   <link href="//gaurav.koley.in/2012/new-logo"/>
   <updated>2012-09-07T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2012/new-logo</id>
   <content type="html">&lt;p&gt;I’ve been working for years to create a logo for my company ArkoMan(nonexistent yet!). But I’ve finally come up with something. Here’s the result after an hour of Illustrating and years of conceptualizing.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/images/arkoman.jpg&quot; height=&quot;600&quot; width=&quot;600&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So hows it? Tell me in the comments.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>GoodBye Octopress and hello Prose.io</title>
   <link href="//gaurav.koley.in/2012/hello-prose"/>
   <updated>2012-09-07T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2012/hello-prose</id>
   <content type="html">&lt;p&gt;Me: I’ve finally decided to let go of Octopress.&lt;/p&gt;

&lt;p&gt;You: Why?&lt;/p&gt;

&lt;p&gt;Me: Because its too complex for my needs.&lt;/p&gt;

&lt;p&gt;You: Oh Come on! That can’t be the reason. If Octopress is so complex, why are others using it? And anyways, you have not written that much that you can decide whether Octopress is easy or complex.&lt;/p&gt;

&lt;p&gt;Me: Alright, that is not the reason. The reason is&lt;/p&gt;

&lt;h3 id=&quot;im-in-love-with-proseio&quot;&gt;I’m in love with Prose.io.&lt;/h3&gt;

&lt;p&gt;Yup, thats right. Prose.io is just super awesome. Never in my life have I seen anything better to use with a &lt;a href=&quot;http://www.aaronsw.com/weblog/000404&quot;&gt;Baked Blog&lt;/a&gt; (on Github, mind you.) It’s easy to use, works with &lt;a href=&quot;http://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt; and is, well what more can I say, just great. No longer do I have to rush home to hatch my evil schemes on this blog. I can document my plans whenever I get them, wherever I am.&lt;/p&gt;

&lt;p&gt;Another good thing about Prose.io, actually its the same thing in a different way, is that I can always edit my posts on the go.&lt;/p&gt;

&lt;p&gt;Prose understands what I need. Click “New file” and a &lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Markdown&lt;/a&gt; file, complete with the required naming techniques and metadata gets created. After that, just start writing. Even this post is being written in Prose.&lt;/p&gt;

&lt;p&gt;To do the same thing in Octopress, I would have had to run&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake new_post[&quot;Hello Prose&quot;]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;then a post would be created somewhere among the dark corners of Octopress’s folders, some of which Ubuntu doesn’t even show by default. Then I would have to open up a text-editor, a bad one (Nice one’s are hard to come by in Ubuntu), and then start writing. That adds, what, 2 more steps than what I actually need and that will amount to lot of wasted time in the long run. (Just joking here. I have lots and lots of free time. :D )&lt;/p&gt;

&lt;p&gt;Also, I can always edit my theme files on the move in Prose, whereas, its a big, really big, pain in the ass to do so in Octopress. This even reflects in the number of themes available for Octopress. What’s the figure? Hmm, 15, while there are more that hundreds of Octpress users listed. Unlisted the figure might go upto a thousand.&lt;/p&gt;

&lt;p&gt;So, to sum it all, Octopress is a mighty old crick in the neck for those who just want a simple baked blog, one that they can post to from anywhere. So, adios Octopress and hello Sani. (What’s Sani, you might ask. Stay Tuned to Know.)&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>My Introduction</title>
   <link href="//gaurav.koley.in/2012/my-introduction"/>
   <updated>2012-08-17T00:00:00-04:00</updated>
   <id>//gaurav.koley.in/2012/my-introduction</id>
   <content type="html">&lt;p&gt;Hi! My name is Gaurav Koley and I’m the writer of, well, all that you currently see on your screen (Provided this page is the only thing that is on your screen). So here I am about to tell you a brief and a not so brief story of my doings.&lt;/p&gt;

&lt;p&gt;As you already know that my name is Gaurav Koley, I might a well move on to other things. I was born in a small town Chinsurah, near Kolkata, India on 18 October 1996. I’m 15 year old and full of ideas of what I’m about to do for the next 60 years of my life, although I think less than half of those ideas will ever come into existence.&lt;/p&gt;

&lt;p&gt;My first such idea was to build up a tech blog: liveByte (Catchy name! Don’t you think?). That started about 2 years ago, it was a trend then and I was one the latecomers to the drift. Things went about smoothly, somewhat. I started the blog on &lt;a href=&quot;http://wordpress.com&quot; title=&quot;WordPress&quot;&gt;WordPress.com&lt;/a&gt; and was kicked out of there for Image Copyright violation. Turned out I had to attribute others for using their images but I didn’t. SO I turned to &lt;a href=&quot;http://posterous.com&quot; title=&quot;Posterous&quot;&gt;Posterous&lt;/a&gt;. Downright awesome platform, easy, simple and well great for me. So liveByte turned out to be success, for sometime, on Posterous, until I guess it lost momentum. I had thousands of viewers (thats a lot for someone who has just started out) and after a few months none.&lt;/p&gt;

&lt;p&gt;For me that didn’t go down well and I dropped blogging. Tried hands at other things and then my friend and I had a brainwave of a website where, um, students can get together, share notes, discuss, something like that. And so I got busy with my conquest of creating &lt;a href=&quot;http://nxtclass.tk&quot; title=&quot;NXT Class&quot;&gt;NXT Class&lt;/a&gt;, working with Wordpress, Drupal and all kinds of CMS, actually any kind of CMS, until I decided to stick with WordPress, add in a few touches of my own, break it a bit here and there and, viola, I had created my own CMS &lt;a href=&quot;http://opensource.nxtclass.tk&quot; title=&quot;NXTClass&quot;&gt;NXTClass&lt;/a&gt;. But as fate would have it (I don’t actually believe in fate but that doesn’t stop me from using it to glorify what I write) I soon got bored with it too. I still devote much of my time to NXTClass but something it doesn’t give that exhilaration. As a remedy to this, a friend of mine gave me the advice to start writing again and so here I am!&lt;/p&gt;

&lt;p&gt;Now the thing that comes to my mind is what this blog will be about; and the answer is nothing and everything. I tried enclosing myself in boundries about what I write about: didn’t work. So all those who are expecting me to again stick to a topic to write about; don’t because the probability of that would be less than that of finding aliens in your backyard. And thats all I have to say here.&lt;/p&gt;

&lt;p&gt;See you soon.&lt;/p&gt;

&lt;p&gt;Ciao.&lt;/p&gt;

&lt;p&gt;(What? Were you expecting anything else? Don’t)&lt;/p&gt;
</content>
 </entry>
 

</feed>
