<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonáš Jančařík on Medium]]></title>
        <description><![CDATA[Stories by Jonáš Jančařík on Medium]]></description>
        <link>https://medium.com/@jonasjancarik?source=rss-d1743ea3a240------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9EbYuCQzFOaX9LvGhlWCYg.jpeg</url>
            <title>Stories by Jonáš Jančařík on Medium</title>
            <link>https://medium.com/@jonasjancarik?source=rss-d1743ea3a240------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:29:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonasjancarik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to convert CSV to XLSX from the right-click context menu in Windows]]></title>
            <link>https://jonasjancarik.medium.com/how-to-convert-csv-to-xlsx-from-the-right-click-context-menu-in-windows-3236986e4fa1?source=rss-d1743ea3a240------2</link>
            <guid isPermaLink="false">https://medium.com/p/3236986e4fa1</guid>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[csv]]></category>
            <category><![CDATA[excel]]></category>
            <dc:creator><![CDATA[Jonáš Jančařík]]></dc:creator>
            <pubDate>Tue, 14 Jan 2020 06:40:07 GMT</pubDate>
            <atom:updated>2021-06-23T08:13:56.736Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to convert CSV to Excel .xlsx from the right-click context menu in Windows</h3><p>This setup uses <a href="https://gitlab.com/DerLinkshaender/csv2xlsx">csv2xlsx</a>, a command-line tool by Armin Hanisch (<a href="https://twitter.com/DerLinkshaender">twitter.com/DerLinkshaender</a>).</p><ol><li>Download the executable from <a href="https://gitlab.com/DerLinkshaender/csv2xlsx/blob/master/csv2xlsx_amd64.exe">https://gitlab.com/DerLinkshaender/csv2xlsx/blob/master/csv2xlsx_amd64.exe</a></li><li>Rename the file to csv2xlsx.exe and place it in your user folder (i.e. C:\Users\&lt;yourusername&gt;)</li><li>Open PowerShell with admin priviledges (right-click the Start button, select Windows Powershell (Admin))</li><li>Run the following command:</li></ol><pre>reg add HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell\&quot;Convert to Excel (.xlsx)&quot;\command /ve /t REG_EXPAND_SZ /d &#39;%USERPROFILE%\csv2xlsx.exe -infile \&quot;%1\&quot; -colsep , -silent -fontname Calibri -sheet Sheet1&#39;</pre><p>You should now see a new context menu item when you right-click a CSV file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2uW1qg6z46QUYHe01uCkVQ.png" /><figcaption>The new context menu item</figcaption></figure><p>The converted file will have the same name as the original file and will appear in the same folder, just with the .xlsx extension.</p><p>Unfortunately, there is no automatic data type detection, so you will have to convert numbers from text to the number data type in Excel manually. If you have a large file to process, you may want to use the csv2xlsx tool directly and set the column types with the -columns parameter:</p><blockquote>Column ranges are a comma-separated list of numbers (e.g. 1,4,8,16), intervals (e.g. 0–4,18–32) or a combination. Each comma group can take a type specifiers for the column, one of “text”, “number”, “integer”, “currency”, date”, “standard” or “formula” separated from numbers with a colon (e.g. 0:text,3–16:number,17:date)</blockquote><h3>Note on column separators</h3><p>The csv2xlsx tool does not automatically recognise what column separator the CSV file uses. It defaults to |, but in the command above, I set the -colsep parameter to , as I believe commas are more commonly used.</p><p>If you want, you can create additional context-menu items for different column separators, for example like this for semicolons:</p><pre>reg add HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell\&quot;Convert to Excel (.xlsx) [;]&quot;\command /ve /t REG_EXPAND_SZ /d &#39;%USERPROFILE%\csv2xlsx.exe -infile \&quot;%1\&quot; -colsep ; -silent -fontname Calibri -sheet Sheet1&#39;</pre><h3>Changing or removing the context menu item</h3><p>Open the Registry Editor (run regedit or simply search for Registry Editor in the Start menu) and navigate to HKEY_CURRENT_USER\Software\Classes\Excel.CSV\shell. There is going to be an entry for each context menu item you added.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3236986e4fa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Windows 10 dev setup — the tools that make my life easier]]></title>
            <link>https://jonasjancarik.medium.com/my-windows-10-dev-setup-the-tools-that-make-my-life-easier-74217bdcd10b?source=rss-d1743ea3a240------2</link>
            <guid isPermaLink="false">https://medium.com/p/74217bdcd10b</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Jonáš Jančařík]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 16:38:26 GMT</pubDate>
            <atom:updated>2019-10-11T06:59:04.353Z</atom:updated>
            <content:encoded><![CDATA[<h4>Developing on Windows is not a bad idea anymore.</h4><p>Indeed, until recently, Windows did not make it easy for developers, mainly if you needed Linux-type tools. For web developers especially, the ability to have both Adobe apps and a ‘proper’ terminal with native tools like SSH was the reason to go with Apple.</p><p><strong>But things have changed.</strong> There are plenty great tools available for Windows, and above all, Microsoft itself has made a lot of effort. Linux (Ubuntu, but not only) is now pretty much a first-class citizen within Windows and SSH comes included. And Windows 10 itself is a well-designed OS, with a window management I actually prefer to that of OS X.</p><p>In terms of <strong>hardware</strong>, there is also a lot more to choose from: I would consider the <a href="https://www.microsoft.com/en-us/p/surface-laptop/90fc23dv6snz?activetab=pivot%3aoverviewtab">Microsoft Surface Laptop</a>, Surface Pro, Dell XPS 13 or the ‘classic’ ThinkPad X1 Carbon. Huawei’s Matebook X Pro is also a solid choice if you can get your hands on one — I’d just suggest reinstalling the OS from scratch. You can save some serious €€€ compared to Apple and still get a premium experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*8jXS7iFUK_2DuanW" /><figcaption>Just look at this thing!</figcaption></figure><p>This is not meant to be a comprehensive overview of the absolutely best tools; I did not do any special research for this write-up, I am merely listing the tools I am using. Still, I hope this might be useful for someone, especially if you have just recently switched to Windows.</p><p>One final word of caution before jumping to the list: my dev experience is mostly about JS/Node.js, PHP (although now only rarely) and web development.</p><p>If you want to read more on how things can be set up on Windows, there is a good guide by <a href="https://medium.com/u/9cca1cc5944f">Owen Williams</a>: <a href="https://char.gd/blog/2017/how-to-set-up-the-perfect-modern-dev-environment-on-windows">How to set up the perfect modern dev environment on Windows</a>.</p><h3>Code Editor</h3><h4>Visual Studio Code</h4><p><a href="https://code.visualstudio.com/">VS Code</a>, by Microsoft, is my preferred choice these days. <a href="https://www.sublimetext.com/">Sublime Text</a> was the first modern editor I used after Notepad++ (which, at least visually, is stuck deep in the 2000’s), but then I moved on to <a href="https://atom.io/">Atom</a> (by GitHub), which I liked better for its more open-source friendly nature. However, VS Code won me over by its speed and stability. Like Atom, it is built on Electron and is pretty much infinitely extensible.</p><p>I also rely a lot on the built-in terminal in VS Code; it’s just convenient.</p><p>For debugging, you can inspect your JavaScript code directly in VS Code, but I prefer using the Chrome dev tools for that. (Navigate to chrome://inspect, click Open dedicated DevTools for Node and launch your script with node --inspect-brk scriptName. Or use the <a href="https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj?hl=en">Node.js V8 — inspector Manager (NiM)</a> extension to open the dedicated DevTools automatically.)</p><p><strong>Tip: </strong>If you edit files on a remote server often, Nano or VIM can be a nightmare. You can use VS Code instead to edit remote files:</p><p><a href="https://medium.com/@prtdomingo/editing-files-in-your-linux-virtual-machine-made-a-lot-easier-with-remote-vscode-6bb98d0639a4">Editing files in your Linux Virtual Machine made a lot easier with Remote VSCode</a></p><h3>Terminal</h3><h4>PowerShell</h4><p>Since I don’t spend a lot of time in the terminal outside VS Code, I stick to PowerShell. Warning: the default blue look is not great. You can change that, plus there seems to be a way to get <a href="https://github.com/neilpa/cmd-colors-solarized">a properly designed colour scheme</a>. Or use alternative terminal apps, such as <a href="http://cmder.net/">CMDer</a> or <a href="https://hyper.is/">Hyper</a> (Electron-based).</p><p><strong>Tip: </strong>Open PowerShell in the current folder by either typing powershell in the address bar (and pressing enter…) or Shift+Right Click in the window to reveal the context menu shortcut.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/143/1*uw3XdCZ94l4VuFzUC-noTg.png" /><figcaption>Typing in the File Explorer address bar</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*p7zPidTVavU_cmkA2b472Q.png" /><figcaption>Shift+Right Click in the File Explorer</figcaption></figure><h4>Windows Subsystem for Linux</h4><p>This one is a big one. In case you haven’t heard: Windows 10 can ‘host’ Linux as a subsystem, which basically means you can use Linux tools without any hassle. You can install it directly from the Windows Store and besides <a href="https://www.microsoft.com/store/p/ubuntu/9nblggh4msv6">Ubuntu</a>, there is also <a href="https://www.microsoft.com/store/apps/9njvjts82tjx">OpenSUSE</a>, <a href="https://www.microsoft.com/store/apps/9p32mwbh6cns">SLES</a>, <a href="https://www.microsoft.com/store/apps/9PKR34TNCV07">Kali Linux</a> and <a href="https://www.microsoft.com/store/apps/9MSVKQC78PK6">Debian GNU/Linux</a>. Unless you need something with a GUI, it is a much more convenient alternative to setting up a virtual machine.</p><p><strong>Tip: </strong>Type bash in the File Explorer address bar again to open it in the current folder.</p><h3>Remote server management — SSH, (S)FTP etc.</h3><h4>MobaXterm</h4><p>Sure, you can do ssh from the terminal in Windows — you don’t need any third-party apps for that as an <a href="https://www.bleepingcomputer.com/news/microsoft/windows-10-openssh-client-installed-by-default-in-april-2018-update/">OpenSSH client is now enabled by default</a>.</p><p>But <a href="https://mobaxterm.mobatek.net/">MobaXterm</a> is like a <strong>Swiss knife for your VPS remote management</strong>. You get tabs. You even get a usable FTP/SFTP manager, so <strong>you don’t really need FileZilla anymore</strong>. It remembers passwords for you, has a GUI for setting up port forwards/tunneling, it even contains a few games for some reason. Sure, it may look like an overkill, but the user experience is mostly really good.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*uAXys0uQuQXl4JGbbb_BbQ.png" /><figcaption>All the different types of sessions MobaXterm allows you to set up.</figcaption></figure><h4>Database management: MySQL and MongoDB</h4><h4>MongoDB: Studio 3T</h4><p>I feel <a href="https://studio3t.com/"><strong>Studio 3T</strong></a> is more useful than <a href="https://www.mongodb.com/products/compass">MongoDB Compass</a>, although the latter has a nice GUI and some cool visual features Studio 3T lacks. One of the things I like about Studio 3T: it allows you to <a href="https://studio3t.com/knowledge-base/articles/sql-query/">write SQL code to query MongoDB</a>.</p><p>Studio 3T isn’t completely free, but the free non-commercial license let’s you keep three connections set up.</p><p><strong>Alternatives: </strong><a href="https://robomongo.org/">Robo 3T</a> — sort of like a lighter, free version of Studio 3T (it was only recently acquired by 3T), <a href="https://www.mongodb.com/products/compass">MongoDB Compass</a></p><h4>MySQL: HeidiSQL</h4><p>I still sometimes use phpMyAdmin, but it doesn’t offer the speed and convenience of a proper desktop app. <strong>HeidiSQL </strong>is free and does everything I need.</p><p>If you only manage your DB through the browser (e.g. the aforementioned phpMyAdmin), don’t forget you have to <a href="https://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql">allow remote connections</a> before switching to a desktop client.</p><p><strong>Alternatives: </strong>phpMyAdmin, <a href="https://www.mysql.com/products/workbench/">MySQL Workbench</a></p><h3>Other tools</h3><ul><li><strong>Traffic inspection:</strong> <a href="https://www.telerik.com/fiddler">Fiddler</a></li><li><strong>API Debugging:</strong> <a href="https://www.getpostman.com/">Postman</a>, <a href="https://insomnia.rest/">Insomnia</a> (for REST, got it?)</li><li><strong>OpenVPN client:</strong> <a href="https://pritunl.com/">Pritunl</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2EVBjpv_PkF45JBkC8HKaQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74217bdcd10b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling those unhandled promise rejections with JS async/await]]></title>
            <link>https://jonasjancarik.medium.com/handling-those-unhandled-promise-rejections-when-using-javascript-async-await-and-ifee-5bac52a0b29f?source=rss-d1743ea3a240------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bac52a0b29f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Jonáš Jančařík]]></dc:creator>
            <pubDate>Wed, 06 Jun 2018 12:29:57 GMT</pubDate>
            <atom:updated>2020-12-01T09:25:38.919Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>2020 update: </strong>I updated the guide to reflect how the message has changed in the more recent versions of Node.js and I also shortened the post. If you are looking for the old version, you can find it in the <a href="https://web.archive.org/web/20201201091748/https://medium.com/@JonasJancarik/handling-those-unhandled-promise-rejections-when-using-javascript-async-await-and-ifee-5bac52a0b29f">Internet Archive</a>.</p><h3>The Problem</h3><p>If you are seeing this error:</p><blockquote><em>[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason “…”.] { code: ERR_UNHANDLED_REJECTION’ }</em></blockquote><p>then what you are doing is likely this:</p><ul><li>You put your code inside an <strong>async </strong>function in order to use await calls</li><li>One of your awaited functions fails (i.e. rejects a promise)</li><li>You get the error</li></ul><p>Another possibility is that you know you need to catch the rejected promise. In this case, what might be happening is this:</p><ul><li>You put your code inside an <strong>async </strong>function in order to use await calls</li><li>You put an await call inside a try/catch block or you use .catch()</li><li>The awaited function fails (i.e. rejects a promise)</li><li><strong>You </strong><strong>throw an error</strong> in the catch block to terminate the script</li><li>You get the error</li></ul><p>In the first case, the key is this part of the error message:</p><blockquote><em>… by rejecting a promise which was not handled with .catch().</em></blockquote><p>The solution is simple, either use .catch() as suggested by the message:</p><pre>await returnsPromise().catch(e =&gt; { console.log(e) })</pre><p>Or use a try/catch block:</p><pre>try {<br>  await returnsPromise()<br>} catch (error) {<br>  console.log(&#39;That did not go well.&#39;)<br>}</pre><p>In the second case, the key part is this:</p><blockquote><em>throwing inside of an async function without a catch block</em></blockquote><p><strong>Don’t </strong><strong>throw inside of an </strong><strong>async function without catching!</strong></p><p>You may think that the warning is about the promise from the function you awaited and which failed, but actually <strong>it’s about the promise returned from the wrapper async function </strong>within which you are throwing an error. Async functions return promises implicitly.</p><p><strong>Your options in this case are:</strong></p><ul><li>adding .catch() to your wrapper function call (you don’t even really need the try/catch block inside the wrapper then)</li></ul><pre>(async function () {<br>  try {<br>      await returnsPromise()<br>  } catch (error) {<br>      console.log(&#39;That did not go well.&#39;)<br>      throw error<br>  }<br>})()<strong>.catch( e =&gt; { console.error(e) })</strong></pre><ul><li>using process.exit(1) instead of throw to terminate the script (lazy but efficient…)</li></ul><pre>(async function () {</pre><pre>try {<br>       await returnsPromise()<br>   } catch (error) {<br>       console.error(error)<br>       process.exit(1)<br>   }</pre><pre>console.log(&#39;This will not be printed.&#39;);</pre><pre>})()</pre><h4>Could it be cleaner?</h4><p>If all you want is to terminate the script and display the error, you can simply get rid of the try/catch block altogether. The catch at the end of the IIFE will take care of the rejected promise from returnsPromise.</p><p>Again, this is a rather lazy solution which may backfire in a more complex script.</p><pre>(async function () {</pre><pre>  await returnsPromise()<br>  console.log(&#39;This will not be printed.&#39;);</pre><pre>})().catch( e =&gt; { console.error(e) })</pre><h4>Do you always need to add the .catch() at the end of the IIFE?</h4><p>Not if you catch and handle everything within the function.</p><p>If you want to terminate the script, you could catch the error and exit the process with <a href="https://nodejs.org/api/process.html#process_process_exit_code">process.exit(1)</a> instead of using throw, like this with .catch() :</p><pre>(async function () {</pre><pre>await returnsPromise().catch((e) =&gt; { console.error(e); process.exit(1) })</pre><pre>console.log(&#39;This will not be printed.&#39;);</pre><pre>})()</pre><p>or like this with try/catch :</p><pre>(async function () {</pre><pre>   try {<br>       await returnsPromise()<br>   } catch (error) {<br>       console.error(error)<br>       process.exit(1)<br>   }</pre><pre>   console.log(&#39;This will not be printed.&#39;);</pre><pre>})()</pre><p>But this gets a little repetitive if you have multiple awaits in your script.</p><p>Finally, just to be clear, if you want the script to continue, a .catch() or try/catch <em>without a throw</em> will be just fine. You can execute later parts of the code conditionally. For example, result below will be undefined:</p><pre>(async function () {</pre><pre>var result = await returnsPromise().catch((e) =&gt; { console.error(e<strong>.message</strong>) })</pre><pre>console.log( result ? &#39;This was a success! &#39; + result : &#39;This was a failure.&#39; )</pre><pre>})()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bac52a0b29f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to namespace Bootstrap CSS]]></title>
            <link>https://jonasjancarik.medium.com/namespacing-bootstrap-css-419961f4d1f8?source=rss-d1743ea3a240------2</link>
            <guid isPermaLink="false">https://medium.com/p/419961f4d1f8</guid>
            <category><![CDATA[twitter-bootstrap]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jonáš Jančařík]]></dc:creator>
            <pubDate>Tue, 20 Dec 2016 16:34:15 GMT</pubDate>
            <atom:updated>2020-04-01T12:50:23.157Z</atom:updated>
            <content:encoded><![CDATA[<h4>Isolating Bootstrap CSS rules</h4><p>TL;DR? Get the files from GitHub: <a href="https://github.com/jonasjancarik/bootstrap-namespaced">https://github.com/jonasjancarik/bootstrap-namespaced</a>.</p><p>Please note that this guide has not been updated since <strong>Bootstrap 4.0.0 </strong>(March 2018) so it’s probably outdated. If you encounter any problems, please let me know in the comments or on Twitter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sAolvxpL3h0QqKlsTCJobw.jpeg" /></figure><p>There is arguably one problem with Bootstrap’s class names: if you want to use Bootstrap alongside other CSS, the simple names can conflict with the rest of your styles because they do not use a clear <a href="https://en.wikipedia.org/wiki/Namespace">namespace</a>.</p><p>I recently came across this issue while working on a website which is built on Bootstrap, but where the developers changed some of its core classes and cut out other rules altogether, which makes it rather difficult to use Bootstrap reliably for other content.</p><p>The only way around it I could think of (short of changing the main template, which would take too long for various reasons) was to inject a regular version of Bootstrap, prefixed with a special class name to avoid conflicts with the bungled up version already included.</p><p>Since it took me a while to figure out all the steps (a <a href="http://stackoverflow.com/questions/13966259/how-to-namespace-twitter-bootstrap-so-styles-dont-conflict">Stack Overflow thread</a> helped), I decided to write them down in case someone is facing a similar issue. Following this guide may also help you if you want to compile your own custom version of Bootstrap.</p><h3>Prerequisites</h3><h4>Ubuntu Linux (or similar)</h4><p>Now you should actually be able to do all of this in Windows or Mac OS — I don’t really see a reason why that should not be possible, but obviously not all the steps and commands below are going to be the same.</p><p>On Windows 10, Ubuntu is now included — after <a href="https://www.google.be/amp/www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/amp/?client=ms-android-google">enabling it</a>, you can type bash in the File Explorer address bar and follow along.</p><h4>Node.js</h4><p>You can check whether you have Node.js installed by checking the version number:</p><pre>node -v</pre><p>If it is missing, you can install v8 with</p><pre>curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -</pre><pre>sudo apt install -y nodejs</pre><p>You can find other install options on the <a href="https://nodejs.org/en/download/">Node.js website</a>.</p><h4>Ruby</h4><p>Check which version of Ruby is installed (if any):</p><pre>ruby -v</pre><p>You will need Ruby version 2.0 or higher. There are multiple ways to install it.</p><p>In Ubuntu, currently the version you install with sudo apt install ruby-full is 2.3, which is enough. (Make sure to install ruby-full rather than just ruby — you will need the <em>dev </em>packages which are part of <em>ruby-full</em>. You can always install ruby-full on top of ruby, though.) Additional install options are <a href="https://www.ruby-lang.org/en/documentation/installation/">listed on the Ruby website</a>.</p><p>If you intend to use Ruby more heavily, you may want to look into <a href="http://rvm.io/">RVM</a> (Ruby Version Manager). This is how to install the latest stable version of Ruby with RVM:</p><pre>gpg — keyserver hkp://keys.gnupg.net — recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3</pre><pre>\curl -sSL https://get.rvm.io | bash -s stable --ruby</pre><pre>source ~/.rvm/scripts/rvm</pre><h4>Bundler</h4><p><a href="https://bundler.io/">Bundler</a> is used for managing Ruby dependencies. Install it with:</p><pre>gem install bundler</pre><p>If you get a permissions error, try running the command with sudo (i.e. sudo gem install bundler). (If you are using RVM, try rvmsudo instead.)</p><h3>Setting up Bootstrap</h3><p>1) Create a working directory and enter it. I called mine bootstrap-ns (for namespace):</p><pre>mkdir bootstrap-ns &amp;&amp; cd bootstrap-ns</pre><p>2) Clone the current version of Bootstrap with git:</p><pre>git clone https://github.com/twbs/bootstrap.git</pre><p>This will download the Bootstrap project (the source files) to a folder named <em>bootstrap</em> within your working directory. (You can of course also just download <a href="https://v4-alpha.getbootstrap.com/getting-started/download/">Bootstrap source</a> and unpack it in this directory.)</p><p>We need to enter the folder:</p><pre>cd bootstrap</pre><p>3) Install local Bootstrap dependencies with <em>npm</em>:</p><pre>npm install</pre><p>4) Install all Ruby dependencies, such as Jekyll and plugins, with this command:</p><pre>bundle install</pre><p>Pay attention to any additional instructions displayed: you will likely be asked to enter your account password. If you get stuck with errors regarding the installation of additional gems, make sure you have those Ruby <em>dev</em> packages mentioned above installed.</p><p>If you get <em>‘An error occurred while installing nokogiri’</em>, try running sudo apt install zlib1g-dev.</p><h3>Editing Bootstrap source</h3><p>Now you have a Bootstrap project prepared for compiling from the source files, you can proceed to editing those source files. There will be two main steps:</p><ol><li>creating a new SASS source file which will wrap the usual core Bootstrap CSS within a new class,</li><li>editing a script in <em>package.json</em> to include this file when compiling.</li></ol><p>The first step can be done with a simple command. If you want to pick your own name for the wrapping class, simply change <em>.twbs</em> to <em>.something-else</em>. Just make sure you are still in the <em>bootstrap </em>directory.</p><pre>echo &#39;.twbs { @import &quot;bootstrap&quot;; }&#39; &gt;&gt; scss/bootstrap-ns.scss</pre><p>Now for the second step, you will need to edit the <em>package.json</em> file to change the CSS compilation scripts to include the <em>-ns</em> files.</p><p>This could be done manually using an editor, but we will stick to the command line, using Trent Mick’s <a href="http://trentm.com/json/">json</a> tool. Install it with:</p><pre>sudo npm install -g json</pre><p>Now execute the two following commands:</p><pre>json -I -f package.json -e &#39;this.scripts[&quot;css-compile&quot;]=&quot;node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap.scss dist/css/bootstrap.css &amp;&amp; node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap-ns.scss dist/css/bootstrap-ns.css &amp;&amp; node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap-grid.scss dist/css/bootstrap-grid.css &amp;&amp; node-sass --output-style expanded --source-map true --source-map-contents true --precision 6 scss/bootstrap-reboot.scss dist/css/bootstrap-reboot.css&quot;&#39;</pre><p>and</p><pre>json -I -f package.json -e &#39;this.scripts[&quot;css-minify&quot;]=&quot;cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/bootstrap.min.css dist/css/bootstrap.css &amp;&amp; cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/bootstrap-ns.min.css dist/css/bootstrap-ns.css &amp;&amp; cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/bootstrap-grid.min.css dist/css/bootstrap-grid.css &amp;&amp; cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/bootstrap-reboot.min.css dist/css/bootstrap-reboot.css&quot;&#39;</pre><h3>Compiling</h3><p>Now that everything is ready, run the Grunt script from the /bootstrap directory (which should still be your current directory):</p><pre>npm run dist</pre><p>If you get an error saying <em>‘npm-run-all: not found’</em>,<em> </em>run sudo npm install -g npm-run-all to install the missing package.</p><p>Now check the dist/css folder:</p><pre>ls -lh dist/css</pre><p>It should contain the compiled CSS files, including bootstrap-ns.css, which will be the final file to include in your project (or the minified .min.css version).</p><h4>Fix the CSS rules for HTML and @page and minify</h4><p>Since the SASS file we used simply prefixed every rule with .twbs, you will need to change it for the rules concerning the HTML element by moving the <em>twbs</em> class selector after the tag selector. (I.e. changing <em>.twbs html </em>to <em>html.twbs.</em>)</p><p>You can do this manually or with the following command:</p><pre>sed -i &quot;s/\.twbs html/html.twbs/g&quot; dist/css/bootstrap-ns.css dist/css/bootstrap-ns.min.css</pre><p>If you’re running this process on a BSD derivative (e.g., macOS), then the sed command works differently. Use this one (thanks <a href="https://medium.com/u/cf4a7a42b8c7">Alex Bauer</a> for the tip!):</p><pre>sed -i &quot;&quot; &quot;s/\.twbs html/html.twbs/g&quot; dist/css/bootstrap-ns.css dist/css/bootstrap-ns.min.css</pre><p>Sass doesn’t compile the @page directive correctly (see <a href="https://github.com/sass/sass/issues/2458">here</a>), so what we have right now in <em>bootstrap-ns.css</em> looks like this:</p><pre>@page {<br><strong>  .twbs {</strong><br>    size: a3;<br>  }<br>}</pre><p>You have to remove the .twbs wrapper to make the CSS file valid:</p><pre>@page {<br>  size: a3;<br>}</pre><p>Since the rule was invalid, it was dropped from the minified file. Generate the minified CSS files again with:</p><pre>npm run css-minify</pre><p>Keep in mind the corresponding .css.map files now don’t match anymore, so if you want to work with those, you will need to edit them, too.</p><h3>And it’s done!</h3><p>All rules in the resulting CSS files (<em>bootstrap-ns.css</em> as well as the minified <em>bootstrap-ns.min.css</em>) should now start with .twbs (except html.twbs of course).</p><p>You will later have to add the namespace class to the tags in your HTML (if you want to use Bootstrap for the whole page), e.g.:</p><pre>&lt;html class=&quot;twbs&quot;&gt;<br>   ...<br>   &lt;body&gt;<br>      ...<br>   &lt;/body&gt;<br>   ...<br>&lt;/html&gt;</pre><p>What you should keep in mind is that <strong>you may still encounter some conflicts when using Bootstrap JS </strong><a href="http://v4-alpha.getbootstrap.com/components/alerts/"><strong>components</strong></a>, because some of the selectors in bootstrap.js are (at least used to be in previous versions) hardcoded.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=419961f4d1f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>