{"title":"Ashwin's Chronicles\ud83d\uddde\ufe0f - Blog","link":[{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/","rel":"alternate"}},{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/feeds\/blog.atom.xml","rel":"self"}}],"id":"https:\/\/ashwinschronicles.github.io\/","updated":"2020-06-20T00:00:00+05:30","entry":[{"title":"Producing Beamer slide shows from markdown using\u00a0Pandoc","link":{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/beamer-slides-using-markdown-and-pandoc","rel":"alternate"}},"published":"2020-06-06T00:00:00+05:30","updated":"2020-06-20T00:00:00+05:30","author":{"name":"Ashwin Kumar Karnad"},"id":"tag:ashwinschronicles.github.io,2020-06-06:\/beamer-slides-using-markdown-and-pandoc","summary":"<p>Short note on bueatiful Producing Beamer slide shows from markdown using&nbsp;Pandoc<\/p>","content":"<h1 id=\"producing-slide-shows-with-pandoc\">Producing slide shows with pandoc<a class=\"headerlink\" href=\"#producing-slide-shows-with-pandoc\" title=\"Permanent link\">&para;<\/a><\/h1>\n<p>Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses this&nbsp;library.<\/p>\n<p>You can use pandoc to produce an <span class=\"caps\">HTML<\/span> + JavaScript slide presentation that can be viewed via a web browser. There are five ways to do this, using <a href=\"https:\/\/meyerweb.com\/eric\/tools\/s5\/\">S5<\/a>, <a href=\"http:\/\/paulrouget.com\/dzslides\/\">DZSlides<\/a>, <a href=\"https:\/\/www.w3.org\/Talks\/Tools\/Slidy2\/\">Slidy<\/a>, <a href=\"https:\/\/goessner.net\/articles\/slideous\/\">Slideous<\/a>, or <a href=\"https:\/\/revealjs.com\/\">reveal.js<\/a>. You can also produce a <span class=\"caps\">PDF<\/span> slide show using LaTeX <a href=\"https:\/\/ctan.org\/pkg\/beamer\"><code>beamer<\/code><\/a>, or slides shows in Microsoft <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_PowerPoint\">PowerPoint<\/a>&nbsp;format.<\/p>\n<p>This article mainly covers generating slides in LaTeX <a href=\"https:\/\/ctan.org\/pkg\/beamer\"><code>beamer<\/code><\/a>  format, which is what is used extensively in&nbsp;academia. <\/p>\n<p>If you are not familiar with markdown, you can take a look at the following markdown source for a simple beamer slide show, <code>Demo.md<\/code>:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>---\ntitle:\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>AI Playground\nauthor:\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Ashwin Kumar Karnad\ntheme:\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Copenhagen\ndate:\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>March 22, 2020\n\n---\n\n\n\n<span class=\"gh\"># What&#39;s AI?<\/span>\n\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Artificial Intelligence- The ability of machine to think and behave like humans.\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>How does the machine learn on its own? - That is called Machine Learning. ML is the study of computer algorithms that improve automatically with experience.\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Just like humans learn with experience - Machines also learn with experience!\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Examples of common AI? Alexa, Siri, Google Home, Self Driving Cars, Robots etc.\n\n<span class=\"gh\"># What&#39;s out there?<\/span>\n\n![<span class=\"nt\">Verticles<\/span>](<span class=\"na\">img\/Untitled.png<\/span>)\n\n\n<span class=\"gh\"># How do computers make decisions?<\/span>\n\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Conditional statements are used to perform different actions based on different conditions.\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>In many programming languages, decisions (also called conditionals) take the form of an if-then construct. They start with a condition, which is then evaluated as either True or False.\n\n<span class=\"gh\"># How do computers make decisions?<\/span>\n\n![<span class=\"nt\">Flow chart<\/span>](<span class=\"na\">img\/Untitled 1.png<\/span>){ width=250px }\n\n<span class=\"gh\"># Let&#39;s Build that<\/span>\n\n\u200b```jsx\nBot.send(&quot;Are you going out to play?&quot;)\nasync function respond(inputText){\n    if (inputText == &quot;yes&quot;){\n        Bot.send(&quot;Wear a hat&quot;);\n    }\n    else {\n        Bot.send(&quot;ok&quot;);\n    }\n\n }\n\\```     &lt;REMOVE THE \\&gt;\n\nWhat we learned. - Bot.send() method - if else statements.\n\n<span class=\"gh\"># Build a basic greetings bot<\/span>\n\n![<span class=\"nt\">Flow chart<\/span>](<span class=\"na\">img\/Untitled 2.png<\/span>)\n\n\n\n<span class=\"gh\"># Benefits of AI Playground<\/span>\n\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Streamlines a lot of back end operations, so that the you can just learn what AI is \u2014 and can get immediate results!\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>User friendly!\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Designed to suit students needs.\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Students can see and publish new projects and thus learn from each other.\n\n<span class=\"gu\">## How does learning AI help?<\/span>\n\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Logical reasoning and Sequencing \n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Critical thinking\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Problem solving\n<span class=\"k\">-<\/span><span class=\"w\"> <\/span>Mental Mathematics\n<span class=\"w\">    <\/span><span class=\"k\">-<\/span><span class=\"w\"> <\/span>The above skills are implicit skills that students learn along with AI. And this helps them in academics, life, etc.\n\n<span class=\"gh\"># Extra <\/span>\n\nThe well known Pythagorean theorem $x^2 + y^2 = z^2$ was  proved to be invalid for other exponents. \nMeaning the next equation has no integer solutions:\n$$x^n + y^n = z^n$$\n\nCan AI, help find near misses for this equation?\n<\/code><\/pre><\/div>\n\n\n<p>The slides generated from this markdown can bee seen <a href=\"https:\/\/ashwinschronicles.github.io\/pdfs\/Demo.pdf\">here<\/a><\/p>\n<p>When you compare the source and the resulting pdf that it generates, you notice the general rules that a markdown document&nbsp;follows.<\/p>\n<p>For instance, you can create a slide show broken up into sections (slides) by using the # tag and you can use ##  tags for sub heading. You can also create a new slide without a header using a horizontal rule (&#8212;-). You can insert latex equations by going to math mode (Insert the equation in $ $&nbsp;)<\/p>\n<p>To produce an <span class=\"caps\">HTML<\/span>\/JavaScript slide show, simply run the following command in your favourite&nbsp;terminal:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pandoc<span class=\"w\"> <\/span>-t<span class=\"w\"> <\/span>FORMAT<span class=\"w\"> <\/span>-s<span class=\"w\"> <\/span>Demo.txt<span class=\"w\"> <\/span>-o<span class=\"w\"> <\/span>Demo.html\n<\/code><\/pre><\/div>\n\n\n<p>where <code>FORMAT<\/code> is either <code>s5<\/code>, <code>slidy<\/code>, <code>slideous<\/code>, <code>dzslides<\/code>, or <code>revealjs<\/code>.<\/p>\n<p>To produce a <span class=\"caps\">PDF<\/span> slide show using  LaTeX <a href=\"https:\/\/ctan.org\/pkg\/beamer\"><code>beamer<\/code><\/a>,&nbsp;type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pandoc<span class=\"w\"> <\/span>-t<span class=\"w\"> <\/span>beamer<span class=\"w\"> <\/span>Demo.txt<span class=\"w\"> <\/span>-o<span class=\"w\"> <\/span>Demo.pdf\n<\/code><\/pre><\/div>\n\n\n<p>Note that a reveal.js slide show can also be converted to a <span class=\"caps\">PDF<\/span> by printing it to a file from the&nbsp;browser.<\/p>\n<p>To produce a Powerpoint slide show,&nbsp;type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pandoc<span class=\"w\"> <\/span>Demo.txt<span class=\"w\"> <\/span>-o<span class=\"w\"> <\/span>Demo.pptx\n<\/code><\/pre><\/div>\n\n\n<p>You get the&nbsp;idea.<\/p>\n<h2 id=\"structuring-the-slide-show\">Structuring the slide show<a class=\"headerlink\" href=\"#structuring-the-slide-show\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>By default, the <em>slide level<\/em> is the highest heading level in the hierarchy that is followed immediately by content, and not another heading, somewhere in the document. In the example above, level-1 headings are always followed by level-2 headings, which are followed by content, so the slide level is 2. This default can be overridden using the <a href=\"https:\/\/pandoc.org\/MANUAL.html#option--slide-level\"><code>--slide-level<\/code><\/a>&nbsp;option.<\/p>\n<p>The document is carved up into slides according to the following&nbsp;rules:<\/p>\n<ul>\n<li>A horizontal rule always starts a new&nbsp;slide.<\/li>\n<li>A heading at the slide level always starts a new&nbsp;slide.<\/li>\n<li>Headings <em>below<\/em> the slide level in the hierarchy create headings <em>within<\/em> a&nbsp;slide.<\/li>\n<li>Headings <em>above<\/em> the slide level in the hierarchy create \u201ctitle slides,\u201d which just contain the section title and help to break the slide show into sections. Non-slide content under these headings will be included on the title slide (for <span class=\"caps\">HTML<\/span> slide shows) or in a subsequent slide with the same title (for&nbsp;beamer).<\/li>\n<li>A title page is constructed automatically from the document\u2019s title block, if present. (In the case of beamer, this can be disabled by commenting out some lines in the default&nbsp;template.)<\/li>\n<\/ul>\n<p>These rules are designed to support many different styles of slide show. If you don\u2019t care about structuring your slides into sections and subsections, you can just use level-1 headings for all each slide. (In that case, level-1 will be the slide level.) But you can also structure the slide show into sections, as in the example&nbsp;above.<\/p>\n<p>Note: in reveal.js slide shows, if slide level is 2, a two-dimensional layout will be produced, with level-1 headings building horizontally and level-2 headings building vertically. It is not recommended that you use deeper nesting of section levels with&nbsp;reveal.js.<\/p>\n<h2 id=\"incremental-lists\">Incremental lists<a class=\"headerlink\" href=\"#incremental-lists\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>By default, these writers produces lists that display &#8220;all at once&#8221;. If you want your lists to display incrementally (one item at a time), use the <code class=\"literal\">-i<\/code> option. If you want aparticular list to depart from the default (that is, to display incrementally without the <code class=\"literal\">-i<\/code> option and all at once with the <code class=\"literal\">-i<\/code> option), put it in a block&nbsp;quote:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>&gt; - Eat spaghetti\n&gt; - Drink wine\n<\/code><\/pre><\/div>\n\n\n<p>In this way incremental and non-incremental lists can be mixed in a\nsingle&nbsp;document.<\/p>\n<h2 id=\"styling-the-slides\">Styling the slides<a class=\"headerlink\" href=\"#styling-the-slides\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>To style beamer slides, you can specify a beamer \u201ctheme\u201d or \u201ccolortheme\u201d using the <code>-V<\/code> option:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pandoc<span class=\"w\"> <\/span>-t<span class=\"w\"> <\/span>beamer<span class=\"w\"> <\/span>Demo.txt<span class=\"w\"> <\/span>-V<span class=\"w\"> <\/span>theme:Warsaw<span class=\"w\"> <\/span>-o<span class=\"w\"> <\/span>Demo.pdf\n<\/code><\/pre><\/div>\n\n\n<p>for more settings visit  <a href=\"https:\/\/pandoc.org\/MANUAL.html\">Pandoc Manual<\/a> and <a href=\"https:\/\/bookdown.org\/yihui\/rmarkdown\/beamer-presentation.html\">bookdown.org<\/a> <\/p>","category":[{"@attributes":{"term":"Blog"}},{"@attributes":{"term":"Pandoc"}},{"@attributes":{"term":"slides"}},{"@attributes":{"term":"markdown"}}]},{"title":"Extending Desktop to another device over VNC","link":{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/extending-desktop-to-another-device-over-vnc","rel":"alternate"}},"published":"2020-02-05T00:00:00+05:30","updated":"2020-02-05T00:00:00+05:30","author":{"name":"Ashwin"},"id":"tag:ashwinschronicles.github.io,2020-02-05:\/extending-desktop-to-another-device-over-vnc","summary":"<p>This post details the procedure to Extending Desktop to another device over <span class=\"caps\">VNC<\/span> or other protocol in&nbsp;Linux<\/p>","content":"<hr \/>\n<div class=\"toc\">\n<ul><\/ul>\n<\/div>\n<p>If you have an old tablet or old laptop, you might want to put it to good use by using its display as a secondary screen to your primary laptop. If you are using windows on your primary laptop, you have a host of applications that does this for you (like Builtin windows Wireless display, Synergy) but if you are using linux you can follow the following&nbsp;instructions.<\/p>\n<p><strong>Assumptions<\/strong>\nI will list the steps on how to get it done wit the following&nbsp;configuration:<\/p>\n<ul>\n<li>The laptop screen is&nbsp;eDP-1<\/li>\n<li>We are using the <span class=\"caps\">VIRTUAL1<\/span> output for the <span class=\"caps\">VNC<\/span>&nbsp;server<\/li>\n<li>The resolution of the <span class=\"caps\">VNC<\/span> monitor will be&nbsp;1920x1080<\/li>\n<li>We are extending the desktop to the right of the laptop&#8217;s&nbsp;screen<\/li>\n<\/ul>\n<p><strong>Step 1:<\/strong> Generate modeline for the resolution of the vpn screen you are going to use with your <span class=\"caps\">VNC<\/span> display.\nIf xrandr already show the desired mode for any of the displays, generating a new one is not needed, we can use the existing one. If this is the case, you can jump directly to step 3.\nAny random number can be used for the frequency, as we are not using the mode with any real&nbsp;monitor.<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>gtf<span class=\"w\"> <\/span><span class=\"m\">1920<\/span><span class=\"w\"> <\/span><span class=\"m\">1080<\/span><span class=\"w\"> <\/span><span class=\"m\">60<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>This command generates the following&nbsp;modeline:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"w\"> <\/span><span class=\"c1\"># 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz<\/span>\n<span class=\"w\">  <\/span>Modeline<span class=\"w\"> <\/span><span class=\"s2\">&quot;1920x1080_60.00&quot;<\/span><span class=\"w\">  <\/span><span class=\"m\">172<\/span>.80<span class=\"w\">  <\/span><span class=\"m\">1920<\/span><span class=\"w\"> <\/span><span class=\"m\">2040<\/span><span class=\"w\"> <\/span><span class=\"m\">2248<\/span><span class=\"w\"> <\/span><span class=\"m\">2576<\/span><span class=\"w\">  <\/span><span class=\"m\">1080<\/span><span class=\"w\"> <\/span><span class=\"m\">1081<\/span><span class=\"w\"> <\/span><span class=\"m\">1084<\/span><span class=\"w\"> <\/span><span class=\"m\">1118<\/span><span class=\"w\">  <\/span>-HSync<span class=\"w\"> <\/span>+Vsync\n<\/code><\/pre><\/div>\n\n\n<p><strong>Step 2:<\/strong> Generate a new mode based on the modeline we got from step&nbsp;1.<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>xrandr<span class=\"w\"> <\/span>--newmode<span class=\"w\"> <\/span><span class=\"s2\">&quot;1920x1080_60.00&quot;<\/span><span class=\"w\">  <\/span><span class=\"m\">172<\/span>.80<span class=\"w\">  <\/span><span class=\"m\">1920<\/span><span class=\"w\"> <\/span><span class=\"m\">2040<\/span><span class=\"w\"> <\/span><span class=\"m\">2248<\/span><span class=\"w\"> <\/span><span class=\"m\">2576<\/span><span class=\"w\">  <\/span><span class=\"m\">1080<\/span><span class=\"w\"> <\/span><span class=\"m\">1081<\/span><span class=\"w\"> <\/span><span class=\"m\">1084<\/span><span class=\"w\"> <\/span><span class=\"m\">1118<\/span><span class=\"w\">  <\/span>-HSync<span class=\"w\"> <\/span>+Vsync\n<\/code><\/pre><\/div>\n\n\n<p><strong>Step 3:<\/strong> Add the desired mode to our disconnected&nbsp;output:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>xrandr<span class=\"w\"> <\/span>--addmode<span class=\"w\"> <\/span>VIRTUAL1<span class=\"w\"> <\/span>1920x1080_60.00\n<\/code><\/pre><\/div>\n\n\n<p><strong>Step 4:<\/strong> Enable the disconnected monitor using the newly added mode and use it to extend the desktop to the right of&nbsp;eDP1:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>xrandr<span class=\"w\"> <\/span>--output<span class=\"w\"> <\/span>VIRTUAL1<span class=\"w\"> <\/span>--mode<span class=\"w\"> <\/span>1920x1080_60.00<span class=\"w\"> <\/span>--right-of<span class=\"w\"> <\/span>eDP1\n<\/code><\/pre><\/div>\n\n\n<p>This extends your desktop to the invisible monitor on your left. At this point you can&#8217;t see it&#8217;s picture but you can move your mouse there and drag your windows there. if your hardware dosnet support <span class=\"caps\">VIRTUAL1<\/span>, you can also use <span class=\"caps\">VGA1<\/span>  instead of <span class=\"caps\">VIRTUAL1<\/span><\/p>\n<p><strong>Step 5:<\/strong> Run xrandr to check if the new setup is&nbsp;listed.<\/p>\n<p><strong>Step 6:<\/strong> Export the invisible part of your desktop using <span class=\"caps\">VNC<\/span><\/p>\n<div class=\"highlight\"><pre><span><\/span><code>x11vnc<span class=\"w\"> <\/span>-clip<span class=\"w\"> <\/span>1920x1080+1920+0<span class=\"w\"> <\/span>\n<\/code><\/pre><\/div>\n\n\n<p><strong>Step 7:<\/strong> <span class=\"caps\">VNC<\/span> viewer\nSome kind of <span class=\"caps\">VNC<\/span> viewer that supports showing the remote cursor is needed on your secondary laptop \/&nbsp;tablet.<\/p>\n<p>Both of them needs to be on the same network and they need to be discover-able. After that you are asked the ip address of the remote computer. If your not happy with the performance of the setup you can use <strong>NoMachine<\/strong> instead of <span class=\"caps\">VNC<\/span> viewer, it uses <span class=\"caps\">NX<\/span> protocoal and seems to be better optimised for low bandwidth and low performance device (the secondary laptop).\nThis trick works on the more or less recent Intel drivers on an Optimus\/Bumblebee system. It would be fun to know if this trick is also repeatable using other&nbsp;drivers. <\/p>\n<p>Once this is setup the parameters can be set in as a bash&nbsp;script<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"ch\">#!\/bin\/bash<\/span>\n<span class=\"c1\">#contents of virtual_display_to_right.sh<\/span>\nxrandr<span class=\"w\"> <\/span>--newmode<span class=\"w\"> <\/span><span class=\"s2\">&quot;1920x1080_60.00&quot;<\/span><span class=\"w\">  <\/span><span class=\"m\">172<\/span>.80<span class=\"w\">  <\/span><span class=\"m\">1920<\/span><span class=\"w\"> <\/span><span class=\"m\">2040<\/span><span class=\"w\"> <\/span><span class=\"m\">2248<\/span><span class=\"w\"> <\/span><span class=\"m\">2576<\/span><span class=\"w\">  <\/span><span class=\"m\">1080<\/span><span class=\"w\"> <\/span><span class=\"m\">1081<\/span><span class=\"w\"> <\/span><span class=\"m\">1084<\/span><span class=\"w\"> <\/span><span class=\"m\">1118<\/span><span class=\"w\">  <\/span>-HSync<span class=\"w\"> <\/span>+Vsync\nxrandr<span class=\"w\"> <\/span>--addmode<span class=\"w\"> <\/span>VIRTUAL1<span class=\"w\"> <\/span>1920x1080_60.00\nxrandr<span class=\"w\"> <\/span>--output<span class=\"w\"> <\/span>VIRTUAL1<span class=\"w\"> <\/span>--mode<span class=\"w\"> <\/span>1920x1080_60.00<span class=\"w\"> <\/span>--right-of<span class=\"w\"> <\/span>eDP1\nxrandr\nx11vnc<span class=\"w\"> <\/span>-clip<span class=\"w\"> <\/span>1920x1080+1920+0<span class=\"w\"> <\/span>\n<\/code><\/pre><\/div>","category":[{"@attributes":{"term":"Blog"}},{"@attributes":{"term":"VNC"}},{"@attributes":{"term":"Nomachine"}},{"@attributes":{"term":"Extend desktop"}},{"@attributes":{"term":"Linux"}}]},{"title":"git\u00a0cheat-sheet","link":{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/git-cheat-sheet","rel":"alternate"}},"published":"2019-04-17T00:00:00+05:30","updated":"2019-04-17T00:00:00+05:30","author":{"name":"Ashwin"},"id":"tag:ashwinschronicles.github.io,2019-04-17:\/git-cheat-sheet","summary":"<p>This post is about&nbsp;git<\/p>","content":"\n<h1 id=\"quick-refresher\">Quick Refresher<a class=\"headerlink\" href=\"#quick-refresher\" title=\"Permanent link\">\u00b6<\/a><\/h1>\n<h2 id=\"initial-setup\">Initial setup<a class=\"headerlink\" href=\"#initial-setup\" title=\"Permanent link\">\u00b6<\/a><\/h2>\n<ul>\n<li>Open a terminal\/shell and\u00a0type:<\/li>\n<\/ul>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>config<span class=\"w\"> <\/span>--global<span class=\"w\"> <\/span>user.name<span class=\"w\"> <\/span><span class=\"s2\">\"Your name here\"<\/span>\n$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>config<span class=\"w\"> <\/span>--global<span class=\"w\"> <\/span>user.email<span class=\"w\"> <\/span><span class=\"s2\">\"your_email@example.com\"<\/span>\n<\/code><\/pre><\/div>\n<p>(Don\u2019t type the <code>$<\/code>; that just indicates that you\u2019re doing this at the command\u00a0line.)<\/p>\n<p>optionally\u00a0do:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>config<span class=\"w\"> <\/span>--global<span class=\"w\"> <\/span>color.ui<span class=\"w\"> <\/span><span class=\"nb\">true<\/span>\n$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>config<span class=\"w\"> <\/span>--global<span class=\"w\"> <\/span>core.editor<span class=\"w\"> <\/span>nano\n<\/code><\/pre><\/div>\n<p>The first of these will enable coloured output in the terminal; the second tells git that you want to use nano (a user friendly text editor). You can change the highlighted section with your editor of\u00a0choice!<\/p>\n<p>Another way to do this is to edit the <code>.gitconfig<\/code> file in your <code>home<\/code> directory. The location of this file depends on the operating system you\u2019re\u00a0using.<\/p>\n<ul>\n<li>\n<p>Set up ssh on your\u00a0computer. <\/p>\n<\/li>\n<li>\n<p>Look to see if you have files <code>~\/.ssh\/id_rsa<\/code> and <code>~\/.ssh\/id_rsa.pub<\/code>.<\/p>\n<\/li>\n<li>\n<p>If not, create such public\/private keys: Open a terminal\/shell and\u00a0type:<\/p>\n<p><code>$ ssh-keygen -t rsa -C \"your_email@example.com\"<\/code><\/p>\n<\/li>\n<li>\n<p>Copy your public key (the contents of the newly-created <code>id_rsa.pub<\/code> file) into your\u00a0clipboard.<\/p>\n<\/li>\n<li>\n<p>Paste your ssh public key into your github account\u00a0settings.<\/p>\n<\/li>\n<li>\n<p>Go to your github <a href=\"https:\/\/github.com\/settings\/profile\">Account\u00a0Settings<\/a><\/p>\n<\/li>\n<li>\n<p>Click \u201c<a href=\"https:\/\/github.com\/settings\/ssh\"><span class=\"caps\">SSH<\/span> Keys<\/a>\u201d on the\u00a0left.<\/p>\n<\/li>\n<li>\n<p>Click \u201cAdd <span class=\"caps\">SSH<\/span> Key\u201d on the\u00a0right.<\/p>\n<\/li>\n<li>\n<p>Add a label (like \u201cMy laptop\u201d) and paste the public key into the big text\u00a0box.<\/p>\n<\/li>\n<li>\n<p>In a terminal\/shell, type the following to test\u00a0it:<\/p>\n<p><code>$ ssh -T git@github.com<\/code><\/p>\n<\/li>\n<li>\n<p>If it says something like the following, it\u00a0worked:<\/p>\n<p><code>Hi username! You've successfully authenticated, but Github does\nnot provide shell access.<\/code><\/p>\n<\/li>\n<\/ul>\n<h2 id=\"start-a-new-git-repository\">Start a new git repository<a class=\"headerlink\" href=\"#start-a-new-git-repository\" title=\"Permanent link\">\u00b6<\/a><\/h2>\n<p>Your first instinct, when you start to do something new, should be <code>git init<\/code>. You\u2019re starting to write a new paper, you\u2019re writing a bit of code to do a computer simulation, you\u2019re mucking around with some new data \u2026 <em>anything<\/em>: think <code>git init<\/code>.<\/p>\n<h3 id=\"a-new-repo-from-scratch\">A new repo from scratch<a class=\"headerlink\" href=\"#a-new-repo-from-scratch\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>Say you\u2019ve just got some data from a collaborator and are about to start exploring\u00a0it.<\/p>\n<ul>\n<li>Create a directory to contain the\u00a0project.<\/li>\n<li>Go into the new\u00a0directory.<\/li>\n<li>Type <code>git init<\/code>.<\/li>\n<li>Write some\u00a0code.<\/li>\n<li>Type <code>git add<\/code> to add the files (see the <a href=\"https:\/\/kbroman.org\/github_tutorial\/pages\/routine.html\">typical use page<\/a>).<\/li>\n<li>Type <code>git commit<\/code>.<\/li>\n<\/ul>\n<p>The first file to create (and add and commit) is probably a ReadMe file, either as plain text or with <a href=\"https:\/\/daringfireball.net\/projects\/markdown\/\">Markdown<\/a>, describing the\u00a0project.<\/p>\n<h3 id=\"a-new-repo-from-an-existing-project\">A new repo from an existing project<a class=\"headerlink\" href=\"#a-new-repo-from-an-existing-project\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>Say you\u2019ve got an existing project that you want to start tracking with\u00a0git.<\/p>\n<ul>\n<li>Go into the directory containing the\u00a0project.<\/li>\n<li>Type <code>git init<\/code>.<\/li>\n<li>Type <code>git add<\/code> to add all of the relevant\u00a0files.<\/li>\n<li>You\u2019ll probably want to create a <code>.gitignore<\/code> file right away, to indicate all of the files you don\u2019t want to track. Use <code>git add .gitignore<\/code>,\u00a0too.<\/li>\n<li>Type <code>git commit<\/code>.<\/li>\n<\/ul>\n<h3 id=\"connect-it-to-github\">Connect it to github<a class=\"headerlink\" href=\"#connect-it-to-github\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>You\u2019ve now got a local git repository. You can use git locally, like that, if you want. But if you want the thing to have a home on github, do the\u00a0following.<\/p>\n<ul>\n<li>Go to <a href=\"https:\/\/github.com\/\">github<\/a>.<\/li>\n<li>Log in to your\u00a0account.<\/li>\n<li>Click the <a href=\"https:\/\/github.com\/new\">new repository<\/a> button in the top-right. You\u2019ll have an option there to initialize the repository with a <span class=\"caps\">README<\/span> file, but I suggest you  don\u2019t do\u00a0it.<\/li>\n<li>Click the \u201cCreate repository\u201d\u00a0button.<\/li>\n<\/ul>\n<p>Now, follow the second set of instructions shown on the screen, \u201cPush an existing\u00a0repository\u2026\u201d<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>remote<span class=\"w\"> <\/span>add<span class=\"w\"> <\/span>origin<span class=\"w\"> <\/span>git@github.com:username\/new_repo\n$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>push<span class=\"w\"> <\/span>-u<span class=\"w\"> <\/span>origin<span class=\"w\"> <\/span>master\n<\/code><\/pre><\/div>\n<p>Actually, the first line of the instructions will usually\u00a0say<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>remote<span class=\"w\"> <\/span>add<span class=\"w\"> <\/span>origin<span class=\"w\"> <\/span>https:\/\/github.com\/username\/new_repo\n<\/code><\/pre><\/div>\n<p>But I use <code>git@github.com:username\/new_repo<\/code> rather than <code>https:\/\/github.com\/username\/new_repo<\/code>, as the former is for use with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\">ssh<\/a>, if you set up ssh  then you won\u2019t have to type your password every time you push things to github. If you use the latter construction, you\u2019ll have to type your github password every time you push to\u00a0github.<\/p>\n<h2 id=\"often-used-commands\">Often used commands<a class=\"headerlink\" href=\"#often-used-commands\" title=\"Permanent link\">\u00b6<\/a><\/h2>\n<h3 id=\"add-and-commit\">Add and commit<a class=\"headerlink\" href=\"#add-and-commit\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>After you\u2019ve made some small modifications to your project and checked that they work, use <code>git add<\/code> to indicate that they\u2019re\u00a0ready.<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>add<span class=\"w\"> <\/span>R\/modified.R<span class=\"w\"> <\/span>man\/modified.Rd\n<\/code><\/pre><\/div>\n<p>Then use <code>git commit<\/code> to add the modifications to the\u00a0repository.<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>commit\n<\/code><\/pre><\/div>\n<p>A text editor (nano if you followed this tutorial) will open; add a short message describing the\u00a0changes.<\/p>\n<p>To abandon your commit, exit the editor without adding text ( ctrl+x in case of nano\u00a0).<\/p>\n<p>For a one-line commit message, you can just\u00a0type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>commit<span class=\"w\"> <\/span>-m<span class=\"w\"> <\/span><span class=\"s2\">\"Fix such and such\"<\/span>\n<\/code><\/pre><\/div>\n<p>If you want to commit all of the modifications you\u2019ve made, without having to explicitly \u201cadd\u201d each file, you can skip the separate <code>add<\/code> and <code>commit<\/code> commands and just\u00a0type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>commit<span class=\"w\"> <\/span>-a\n<\/code><\/pre><\/div>\n<h3 id=\"push-to-github\">Push to <a href=\"https:\/\/github.com\/\">github<\/a><a class=\"headerlink\" href=\"#push-to-github\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>To push committed changes to github,\u00a0type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>push\n<\/code><\/pre><\/div>\n<p>You don\u2019t need to do this every time. Do it after you\u2019ve completed a batch of changes that you\u2019re thoroughly happy with and before you move on to something\u00a0else.<\/p>\n<p>Once you\u2019ve pushed a commit, it\u2019s hard to take it away. If you\u2019ve not pushed it yet, you <em>can<\/em> go back and scrap it and not have it be part of your project\u2019s\u00a0history.<\/p>\n<h3 id=\"status\">Status<a class=\"headerlink\" href=\"#status\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>You\u2019ve made some changes to a project, but you\u2019re not sure what.\u00a0Type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git status\n<\/code><\/pre><\/div>\n<p>It\u2019ll give you a list of files that have been changed, plus new files that haven\u2019t been formally\u00a0added.<\/p>\n<h3 id=\"diff\">Diff<a class=\"headerlink\" href=\"#diff\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>Exactly what changes have you made?\u00a0Type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git diff\n<\/code><\/pre><\/div>\n<p>Or to see your changes to a particular file,\u00a0type<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git diff R\/modified.R\n<\/code><\/pre><\/div>\n<p>It\u2019ll show you which lines have been added and which have been\u00a0deleted.<\/p>\n<h3 id=\"gitignore\">.gitignore<a class=\"headerlink\" href=\"#gitignore\" title=\"Permanent link\">\u00b6<\/a><\/h3>\n<p>The various files in your project directory that you\u2019re not tracking in git should be indicated in a <code>.gitignore<\/code> file.<\/p>\n<p>You don\u2019t <em>have<\/em> to have a <code>.gitignore<\/code> file, but if you don\u2019t, those files will show up every time you type <code>git status<\/code>.<\/p>\n<p>Each subdirectory can have its own <code>.gitignore<\/code> file,\u00a0too.<\/p>\n<p>Also, you can have a global such in your home directory; I use <code>~\/.gitignore_global<\/code>, which\u00a0contains:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"err\">*~<\/span>\n<span class=\"err\">.*~<\/span>\n<span class=\"na\">.DS_Store<\/span>\n<span class=\"na\">.Rhistory<\/span>\n<span class=\"na\">.RData<\/span>\n<\/code><\/pre><\/div>\n<p>You have to tell git about the global <code>.gitignore<\/code> file:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>config<span class=\"w\"> <\/span>--global<span class=\"w\"> <\/span>core.excludesfile<span class=\"w\"> <\/span>~\/.gitignore_global\n<\/code><\/pre><\/div>\n<p>Huge thanks to <a href=\"https:\/\/kbroman.org\/github_tutorial\/\">kbroman.org<\/a> for his tutorials from where I have collated articles for this cheat sheet. you can check out his page for more detailed\u00a0workflow. <\/p>","category":[{"@attributes":{"term":"Blog"}},{"@attributes":{"term":"git"}},{"@attributes":{"term":"github"}}]},{"title":"Make a Github Pages blog with\u00a0Pelican","link":{"@attributes":{"href":"https:\/\/ashwinschronicles.github.io\/gh-pages-with-pelican","rel":"alternate"}},"published":"2019-01-01T00:00:00+05:30","updated":"2019-01-01T00:00:00+05:30","author":{"name":"Ashwin"},"id":"tag:ashwinschronicles.github.io,2019-01-01:\/gh-pages-with-pelican","summary":"<p>Wake your own webbsite using Pelican static site generator  and host it on github&nbsp;pages<\/p>","content":"<p>Github, worlds leading  hosting service for Git repositories  offers a simple, elegant website solution. It allows its users to  store page content in a git repository along with their&nbsp;code.<\/p>\n<p>In this blog post ill walk you through the process of setting up a website by combining Pelican with Github Pages. Pelican is a simple python utility that lets you create beautiful weblogs using just text files. In other words its a static-site generator. I have chosen Pelican over other static-site generators as Pelican unlike its counter parts is based on python hence initial  setup takes literally no&nbsp;time.<\/p>\n<h2 id=\"setting-up-a-githubio-page\">Setting up a github.io page<a class=\"headerlink\" href=\"#setting-up-a-githubio-page\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>To create your Github user page, log in to Github and create a  new repositorie username.github.io, as explained on Github pages. (Use your Github username for these repositories.) The  username.github.io repository will contain the output <span class=\"caps\">HTML<\/span> files Pelican generates. To add the output directory as a submodule, initialize it with a <span class=\"caps\">README<\/span>&nbsp;file.<\/p>\n<h2 id=\"installing-pelican\">Installing Pelican<a class=\"headerlink\" href=\"#installing-pelican\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>We will first  create a virtual environment for Pelican via virtualenv before installing Pelican.\ncd into the directory where you want to install the Pelican website and then run the following&nbsp;command:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>python<span class=\"w\"> <\/span>-m<span class=\"w\"> <\/span>venv<span class=\"w\"> <\/span>.\n<span class=\"nb\">source<\/span><span class=\"w\"> <\/span>bin\/activate\n<\/code><\/pre><\/div>\n\n\n<p>This essentially creates a virtual python environment where Pelican can be installed and any python package installed here wont affect the global python\npackages.\nOnce the virtual environment has been created and activated, Pelican can be installed via  prefixing with sudo if permissions&nbsp;warrant:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pip<span class=\"w\"> <\/span>install<span class=\"w\"> <\/span>pelican<span class=\"w\"> <\/span>markdown<span class=\"w\"> <\/span>typogrify<span class=\"w\"> <\/span>ghp-import<span class=\"w\"> <\/span>shovel<span class=\"w\"> <\/span>cssmin<span class=\"w\"> <\/span>webassets\n<\/code><\/pre><\/div>\n\n\n<p>Now clone the source repository you&nbsp;created:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>clone<span class=\"w\"> <\/span>https:\/\/github.com\/YOUR_USERNAME\/YOUR_USERNAME.github.io.git<span class=\"w\"> <\/span>web-sources\n<\/code><\/pre><\/div>\n\n\n<p>Then change directory to the source&nbsp;folder:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"nb\">cd<\/span><span class=\"w\"> <\/span>web-sources\n<\/code><\/pre><\/div>\n\n\n<p>Because of how Github Pages prefers to work, serving the files from the master branch, you have to put your source code in a new branch, preserving the &#8220;master&#8221; for the output of the static files generated by Pelican. To do that, you must create a new branch called&nbsp;&#8220;source&#8221;:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git<span class=\"w\"> <\/span>checkout<span class=\"w\"> <\/span>-b<span class=\"w\"> <\/span><span class=\"nb\">source<\/span>\n<\/code><\/pre><\/div>\n\n\n<h2 id=\"pelican-quickstart\">Pelican quickstart<a class=\"headerlink\" href=\"#pelican-quickstart\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>Pelican provides an excellent quickstart command. Run&nbsp;it:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pelican-quickstart\n<\/code><\/pre><\/div>\n\n\n<p>The quickstart will ask you various questions, which you can answer in turn. Before answering them, take a look at my answers&nbsp;below:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>&gt;<span class=\"w\"> <\/span>Where<span class=\"w\"> <\/span><span class=\"k\">do<\/span><span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>create<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>new<span class=\"w\"> <\/span>web<span class=\"w\"> <\/span>site?<span class=\"w\"> <\/span><span class=\"o\">[<\/span>.<span class=\"o\">]<\/span><span class=\"w\"> <\/span>.\/\n&gt;<span class=\"w\"> <\/span>What<span class=\"w\"> <\/span>will<span class=\"w\"> <\/span>be<span class=\"w\"> <\/span>the<span class=\"w\"> <\/span>title<span class=\"w\"> <\/span>of<span class=\"w\"> <\/span>this<span class=\"w\"> <\/span>web<span class=\"w\"> <\/span>site?<span class=\"w\"> <\/span>Ashwin<span class=\"err\">&#39;<\/span>s<span class=\"w\"> <\/span>Chronicles\n&gt;<span class=\"w\"> <\/span>Who<span class=\"w\"> <\/span>will<span class=\"w\"> <\/span>be<span class=\"w\"> <\/span>the<span class=\"w\"> <\/span>author<span class=\"w\"> <\/span>of<span class=\"w\"> <\/span>this<span class=\"w\"> <\/span>web<span class=\"w\"> <\/span>site?<span class=\"w\"> <\/span>Ashwin<span class=\"w\"> <\/span>Kumar<span class=\"w\"> <\/span>Karnad\n&gt;<span class=\"w\"> <\/span>What<span class=\"w\"> <\/span>will<span class=\"w\"> <\/span>be<span class=\"w\"> <\/span>the<span class=\"w\"> <\/span>default<span class=\"w\"> <\/span>language<span class=\"w\"> <\/span>of<span class=\"w\"> <\/span>this<span class=\"w\"> <\/span>web<span class=\"w\"> <\/span>site?<span class=\"w\"> <\/span><span class=\"o\">[<\/span>pt<span class=\"o\">]<\/span><span class=\"w\"> <\/span>en\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>specify<span class=\"w\"> <\/span>a<span class=\"w\"> <\/span>URL<span class=\"w\"> <\/span>prefix?<span class=\"w\"> <\/span>e.g.,<span class=\"w\"> <\/span>http:\/\/example.com<span class=\"w\">   <\/span><span class=\"o\">(<\/span>Y\/n<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span><span class=\"nb\">enable<\/span><span class=\"w\"> <\/span>article<span class=\"w\"> <\/span>pagination?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>Y\/n<span class=\"o\">)<\/span><span class=\"w\"> <\/span>y\n&gt;<span class=\"w\"> <\/span>How<span class=\"w\"> <\/span>many<span class=\"w\"> <\/span>articles<span class=\"w\"> <\/span>per<span class=\"w\"> <\/span>page<span class=\"w\"> <\/span><span class=\"k\">do<\/span><span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want?<span class=\"w\"> <\/span><span class=\"o\">[<\/span><span class=\"m\">10<\/span><span class=\"o\">]<\/span><span class=\"w\"> <\/span><span class=\"m\">10<\/span>\n&gt;<span class=\"w\"> <\/span>What<span class=\"w\"> <\/span>is<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span><span class=\"nb\">time<\/span><span class=\"w\"> <\/span>zone?<span class=\"w\"> <\/span><span class=\"o\">[<\/span>Europe\/Paris<span class=\"o\">]<\/span><span class=\"w\"> <\/span>Asia\/Calcutta\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>generate<span class=\"w\"> <\/span>a<span class=\"w\"> <\/span>Fabfile\/Makefile<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>automate<span class=\"w\"> <\/span>generation<span class=\"w\"> <\/span>and<span class=\"w\"> <\/span>publishing?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>Y\/n<span class=\"o\">)<\/span><span class=\"w\"> <\/span>Y<span class=\"w\"> <\/span>**#<span class=\"w\"> <\/span>PAY<span class=\"w\"> <\/span>ATTENTION<span class=\"w\"> <\/span>TO<span class=\"w\"> <\/span>THIS!**\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>an<span class=\"w\"> <\/span>auto-reload<span class=\"w\"> <\/span><span class=\"p\">&amp;<\/span><span class=\"w\"> <\/span>simpleHTTP<span class=\"w\"> <\/span>script<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>assist<span class=\"w\"> <\/span>with<span class=\"w\"> <\/span>theme<span class=\"w\"> <\/span>and<span class=\"w\"> <\/span>site<span class=\"w\"> <\/span>development?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>Y\/n<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>FTP?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>SSH?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>Dropbox?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>S3?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>Rackspace<span class=\"w\"> <\/span>Cloud<span class=\"w\"> <\/span>Files?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>n\n&gt;<span class=\"w\"> <\/span>Do<span class=\"w\"> <\/span>you<span class=\"w\"> <\/span>want<span class=\"w\"> <\/span>to<span class=\"w\"> <\/span>upload<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>website<span class=\"w\"> <\/span>using<span class=\"w\"> <\/span>GitHub<span class=\"w\"> <\/span>Pages?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>y\n&gt;<span class=\"w\"> <\/span>Is<span class=\"w\"> <\/span>this<span class=\"w\"> <\/span>your<span class=\"w\"> <\/span>personal<span class=\"w\"> <\/span>page<span class=\"w\"> <\/span><span class=\"o\">(<\/span>username.github.io<span class=\"o\">)<\/span>?<span class=\"w\"> <\/span><span class=\"o\">(<\/span>y\/N<span class=\"o\">)<\/span><span class=\"w\"> <\/span>y\nDone.<span class=\"w\"> <\/span>Your<span class=\"w\"> <\/span>new<span class=\"w\"> <\/span>project<span class=\"w\"> <\/span>is<span class=\"w\"> <\/span>available<span class=\"w\"> <\/span>at<span class=\"w\"> <\/span>YOUR_USERNAME.github.io\n<\/code><\/pre><\/div>\n\n\n<p>Now, go ahead and create your first blog post! You might want to open the project folder on your favorite code editor and find the &#8220;content&#8221; folder inside it. Then, create a new file, which can be called my-first-post.md (Just for testing). The contents should begin with the metadata which identifies the Title, Date, Category and more from the post before you start with the content, like&nbsp;this:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>Title: My first post\nDate: 2018-1-2\nModified: 2018-1-3\nCategory: misc\nTags: first, misc\nSlug: My-first-post\nAuthors: Your name\nSummary: What does your post talk about? Write here.\n\nThis is the <span class=\"ge\">*first post*<\/span> from my Pelican blog. <span class=\"gs\">**YAY!**<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>Let&#8217;s see how it&nbsp;looks?<\/p>\n<p>Go to the terminal, generate the static files and start the server. To do that, use the following&nbsp;command:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"o\">(<\/span>venv<span class=\"o\">)<\/span>$<span class=\"w\"> <\/span>make<span class=\"w\"> <\/span>html<span class=\"w\"> <\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"w\"> <\/span>make<span class=\"w\"> <\/span>serve\n<\/code><\/pre><\/div>\n\n\n<p>While this command is running, you should be able to visit it on your favorite web browser by typing <code>localhost:8000<\/code> on the address&nbsp;bar.<\/p>\n<h2 id=\"a-little-touch-up\">A little touch up<a class=\"headerlink\" href=\"#a-little-touch-up\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>Now,  if you want to put an image in a post, a neat way is to first  create a &#8216;images&#8217; directory inside your content directory, where your posts are. Now, you have to tell Pelican to use it. Find the <code>pelicanconf.py<\/code>, the file where you configure the system, and add a variable that contains the directory with your&nbsp;images:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"n\">STATIC_PATHS<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span><span class=\"s1\">&#39;images&#39;<\/span><span class=\"p\">]<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>Save it. Go to your post and add the image this&nbsp;way:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>![<span class=\"nt\">Write here a good description for people who can&#39;t see the image<\/span>](<span class=\"na\">{filename}\/images\/IMAGE_NAME.webp<\/span>)\n<\/code><\/pre><\/div>\n\n\n<p>You can interrupt the server at anytime pressing <span class=\"caps\">CTRL<\/span>+C on the terminal. But you should start it again and check if the image is correct. Can you remember&nbsp;how?<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"o\">(<\/span>venv<span class=\"o\">)<\/span>$<span class=\"w\"> <\/span>make<span class=\"w\"> <\/span>html<span class=\"w\"> <\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"w\"> <\/span>make<span class=\"w\"> <\/span>serve\n<\/code><\/pre><\/div>\n\n\n<p>One last step before your coding is &#8220;done&#8221;: you should make sure anyone can read your posts using <span class=\"caps\">ATOM<\/span> or <span class=\"caps\">RSS<\/span> feeds. Find the pelicanconf.py, the file where you configure the system, and edit the part about feed&nbsp;generation:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"n\">FEED_ALL_ATOM<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;feeds\/all.atom.xml&#39;<\/span>\n<span class=\"n\">FEED_ALL_RSS<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;feeds\/all.rss.xml&#39;<\/span>\n<span class=\"n\">AUTHOR_FEED_RSS<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;feeds\/<\/span><span class=\"si\">%s<\/span><span class=\"s1\">.rss.xml&#39;<\/span>\n<span class=\"n\">RSS_FEED_SUMMARY_ONLY<\/span> <span class=\"o\">=<\/span> <span class=\"kc\">False<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>Save everything so you can send the code to Github. You can do that by adding all files, committing it with a message (&#8216;first commit&#8217;) and using git push. You will be asked for your Github login and&nbsp;password.<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git<span class=\"w\"> <\/span>add<span class=\"w\"> <\/span>-A<span class=\"w\"> <\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>commit<span class=\"w\"> <\/span>-a<span class=\"w\"> <\/span>-m<span class=\"w\"> <\/span><span class=\"s1\">&#39;first commit&#39;<\/span><span class=\"w\"> <\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>push<span class=\"w\"> <\/span>--all\n<\/code><\/pre><\/div>\n\n\n<p>As I had said before you would be preserving the master branch for the output of the static files generated by Pelican. Now it&#8217;s time  to generate the&nbsp;mater:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>$<span class=\"w\"> <\/span>make<span class=\"w\"> <\/span>github\n<\/code><\/pre><\/div>\n\n\n<p>You will be asked for your Github login and password again. And&#8230; voil\u00e0! Your new blog should be live on&nbsp;https:\/\/YOUR_USERNAME.github.io.<\/p>\n<h1 id=\"whats-next\">What&#8217;s next?<a class=\"headerlink\" href=\"#whats-next\" title=\"Permanent link\">&para;<\/a><\/h1>\n<p>You generated your first Pelican static website using Markdown and Jinja2. Additional modifications can be made to the Jinja2 templates and the content contained in the Markdown&nbsp;files.<\/p>\n<h3 id=\"adding-gitignore\">Adding .gitignore<a class=\"headerlink\" href=\"#adding-gitignore\" title=\"Permanent link\">&para;<\/a><\/h3>\n<p>.gitignore file contains a list of files and folder that git will ignore while syncing with the remote repository. Utilizing .gitignore wisely can reduce the amount of data you need to&nbsp;upload.<\/p>\n<p>make a file .gitignore in the web-sources file with the following&nbsp;contents<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"n\">#Custom<\/span>\n<span class=\"k\">output<\/span>\n<span class=\"n\">pelicanconf_local<\/span><span class=\"p\">.<\/span><span class=\"n\">py<\/span>\n\n<span class=\"n\">#Python<\/span>\n<span class=\"o\">*<\/span><span class=\"p\">.<\/span><span class=\"n\">py<\/span><span class=\"o\">[<\/span><span class=\"n\">cod<\/span><span class=\"o\">]<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">C<\/span><span class=\"w\"> <\/span><span class=\"n\">extensions<\/span>\n<span class=\"o\">*<\/span><span class=\"p\">.<\/span><span class=\"n\">so<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">Packages<\/span>\n<span class=\"o\">*<\/span><span class=\"p\">.<\/span><span class=\"n\">egg<\/span>\n<span class=\"o\">*<\/span><span class=\"p\">.<\/span><span class=\"n\">egg<\/span><span class=\"o\">-<\/span><span class=\"n\">info<\/span>\n<span class=\"n\">dist<\/span>\n<span class=\"n\">build<\/span>\n<span class=\"n\">eggs<\/span>\n<span class=\"n\">parts<\/span>\n<span class=\"n\">bin<\/span>\n<span class=\"nf\">var<\/span>\n<span class=\"n\">sdist<\/span>\n<span class=\"n\">develop<\/span><span class=\"o\">-<\/span><span class=\"n\">eggs<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">installed<\/span><span class=\"p\">.<\/span><span class=\"n\">cfg<\/span>\n<span class=\"n\">lib<\/span>\n<span class=\"n\">lib64<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">Installer<\/span><span class=\"w\"> <\/span><span class=\"n\">logs<\/span>\n<span class=\"n\">pip<\/span><span class=\"o\">-<\/span><span class=\"nf\">log<\/span><span class=\"p\">.<\/span><span class=\"n\">txt<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">Unit<\/span><span class=\"w\"> <\/span><span class=\"n\">test<\/span><span class=\"w\"> <\/span><span class=\"o\">\/<\/span><span class=\"w\"> <\/span><span class=\"n\">coverage<\/span><span class=\"w\"> <\/span><span class=\"n\">reports<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">coverage<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">tox<\/span>\n<span class=\"n\">nosetests<\/span><span class=\"p\">.<\/span><span class=\"nc\">xml<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">Translations<\/span>\n<span class=\"o\">*<\/span><span class=\"p\">.<\/span><span class=\"n\">mo<\/span>\n\n<span class=\"err\">#<\/span><span class=\"w\"> <\/span><span class=\"n\">Mr<\/span><span class=\"w\"> <\/span><span class=\"n\">Developer<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">mr<\/span><span class=\"p\">.<\/span><span class=\"n\">developer<\/span><span class=\"p\">.<\/span><span class=\"n\">cfg<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">project<\/span>\n<span class=\"p\">.<\/span><span class=\"n\">pydevproject<\/span>\n<\/code><\/pre><\/div>\n\n\n<h3 id=\"automate-github-upload-process\">Automate GitHub upload process<a class=\"headerlink\" href=\"#automate-github-upload-process\" title=\"Permanent link\">&para;<\/a><\/h3>\n<p>Create a file <code>up.sh<\/code> in the  <code>web-sources<\/code><\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git<span class=\"w\"> <\/span>add<span class=\"w\"> <\/span>-A<span class=\"w\"> <\/span><span class=\"o\">&amp;&amp;<\/span><span class=\"w\"> <\/span>git<span class=\"w\"> <\/span>commit<span class=\"w\"> <\/span>-a<span class=\"w\"> <\/span>-m<span class=\"w\"> <\/span><span class=\"s2\">&quot;&quot;<\/span><span class=\"nv\">$1<\/span><span class=\"s2\">&quot; &amp;&amp; git push --all<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>Now whenever you want to upload sync the repo just do <code>bash up.sh \"Comment\"<\/code> Note that the argument &#8220;Comment&#8221; should not contain&nbsp;spaces.<\/p>\n<h3 id=\"download-themes\">Download Themes<a class=\"headerlink\" href=\"#download-themes\" title=\"Permanent link\">&para;<\/a><\/h3>\n<p>Clone pelican-themes&nbsp;repository<\/p>\n<p><code>git clone --recursive https:\/\/github.com\/getpelican\/pelican-themes themes<\/code><\/p>\n<p>In <code>pelicanconf.py<\/code> add the following&nbsp;variables:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"n\">THEME<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;themes\/bootstrap2&#39;<\/span>\n<span class=\"n\">OUTPUT_PATH<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;output&#39;<\/span>\n<span class=\"n\">PATH<\/span> <span class=\"o\">=<\/span> <span class=\"s1\">&#39;content<\/span>\n<\/code><\/pre><\/div>\n\n\n<h3 id=\"custom-home-page\">Custom Home page<a class=\"headerlink\" href=\"#custom-home-page\" title=\"Permanent link\">&para;<\/a><\/h3>\n<p>Add this variables to&nbsp;pelicanconf.py<\/p>\n<div class=\"highlight\"><pre><span><\/span><code><span class=\"c1\"># Custom Home page<\/span>\n<span class=\"n\">DIRECT_TEMPLATES<\/span> <span class=\"o\">=<\/span> <span class=\"p\">((<\/span><span class=\"s1\">&#39;index&#39;<\/span><span class=\"p\">,<\/span> <span class=\"s1\">&#39;blog&#39;<\/span><span class=\"p\">,<\/span> <span class=\"s1\">&#39;tags&#39;<\/span><span class=\"p\">,<\/span> <span class=\"s1\">&#39;categories&#39;<\/span><span class=\"p\">,<\/span> <span class=\"s1\">&#39;archives&#39;<\/span><span class=\"p\">))<\/span>\n<span class=\"n\">PAGINATED_DIRECT_TEMPLATES<\/span> <span class=\"o\">=<\/span> <span class=\"p\">((<\/span><span class=\"s1\">&#39;blog&#39;<\/span><span class=\"p\">,))<\/span>\n<span class=\"n\">TEMPLATE_PAGES<\/span> <span class=\"o\">=<\/span> <span class=\"p\">{<\/span><span class=\"s1\">&#39;home.html&#39;<\/span><span class=\"p\">:<\/span> <span class=\"s1\">&#39;index.html&#39;<\/span><span class=\"p\">,}<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>Duplicated the index.html to blog.html in your template folder and add this&nbsp;lines:<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>{% set active_page = &quot;blog&quot; %}\n{% block title %}{{ SITENAME }} - Blog{% endblock %}\n<\/code><\/pre><\/div>\n\n\n<p>Create home.html or use page override feature to use a Markdown page as your home&nbsp;page.<\/p>\n<p><code>nano home.html<\/code><\/p>\n<div class=\"highlight\"><pre><span><\/span><code>{% extends &quot;base.html&quot; %}\n{% block content %}\n<span class=\"p\">&lt;<\/span><span class=\"nt\">div<\/span> <span class=\"na\">class<\/span><span class=\"o\">=<\/span><span class=\"s\">&#39;page&#39;<\/span><span class=\"p\">&gt;<\/span>\n  <span class=\"p\">&lt;<\/span><span class=\"nt\">div<\/span> <span class=\"na\">class<\/span><span class=\"o\">=<\/span><span class=\"s\">&quot;page-header&quot;<\/span><span class=\"p\">&gt;&lt;<\/span><span class=\"nt\">h1<\/span><span class=\"p\">&gt;<\/span>Home<span class=\"p\">&lt;\/<\/span><span class=\"nt\">h1<\/span><span class=\"p\">&gt;&lt;\/<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;<\/span>\n  <span class=\"p\">&lt;<\/span><span class=\"nt\">div<\/span> <span class=\"na\">class<\/span><span class=\"o\">=<\/span><span class=\"s\">&quot;page-content&quot;<\/span><span class=\"p\">&gt;<\/span>Content<span class=\"p\">&lt;\/<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;<\/span>\n<span class=\"p\">&lt;\/<\/span><span class=\"nt\">div<\/span><span class=\"p\">&gt;<\/span>\n{% endblock %}\n<\/code><\/pre><\/div>\n\n\n<h1 id=\"process-for-new-articles\">Process for new articles.<a class=\"headerlink\" href=\"#process-for-new-articles\" title=\"Permanent link\">&para;<\/a><\/h1>\n<p>Ones the setup is done, the contents of the folder <code>web-sources<\/code> need not be generated again using the above procedure. All one has to do is place the article in the content folder then (after testing the website locally using <code>make devserver<\/code>) then execute  <code>bash up.sh \"Comment\"<\/code>  to sync the source branch and then do <code>make github<\/code><\/p>\n<h2 id=\"process-for-moving-to-a-different-machine\">Process for moving to a different machine<a class=\"headerlink\" href=\"#process-for-moving-to-a-different-machine\" title=\"Permanent link\">&para;<\/a><\/h2>\n<p>If you are on a different machine or you have lost access to the <code>web-sources<\/code> folder, you just have to make the virtual environment and then do git clone again.&nbsp;i.e<\/p>\n<div class=\"highlight\"><pre><span><\/span><code>virtualenv<span class=\"w\"> <\/span>website<span class=\"w\">  <\/span>\n<span class=\"nb\">cd<\/span><span class=\"w\"> <\/span>website\n<span class=\"nb\">source<\/span><span class=\"w\"> <\/span>bin\/activate\npip<span class=\"w\"> <\/span>install<span class=\"w\"> <\/span>pelican<span class=\"w\"> <\/span>markdown<span class=\"w\"> <\/span>typogrify<span class=\"w\"> <\/span>ghp-import<span class=\"w\"> <\/span>shovel\ngit<span class=\"w\"> <\/span>clone<span class=\"w\"> <\/span>https:\/\/github.com\/YOUR_USERNAME\/YOUR_USERNAME.github.io.git<span class=\"w\"> <\/span>web-sources\n<span class=\"nb\">cd<\/span><span class=\"w\"> <\/span>web-sources\ngit<span class=\"w\"> <\/span>checkout<span class=\"w\"> <\/span>-b<span class=\"w\"> <\/span><span class=\"nb\">source<\/span>\n<\/code><\/pre><\/div>\n\n\n<p>This article just touches upon getting a basic website up and running. More features that Pelican offers (like custom plugins)can be explored <a href=\"http:\/\/docs.getpelican.com\/en\/3.6.3\/content.html\">here<\/a>.<\/p>\n<h1 id=\"upgrading-pelican\">Upgrading Pelican<a class=\"headerlink\" href=\"#upgrading-pelican\" title=\"Permanent link\">&para;<\/a><\/h1>\n<p>Pelican is under constant development so it might happen that after sometime you will need to upgrade to a newer version.\nFor instance when I wrote the tutorial initially pelican was on version 3.7 and the current version is 4.7 is it seemed like a good idea to&nbsp;upgrade.<\/p>\n<p>To upgrade and regenerate the content you need these twoo&nbsp;commands <\/p>\n<div class=\"highlight\"><pre><span><\/span><code>pip<span class=\"w\"> <\/span>install<span class=\"w\"> <\/span>--upgrade<span class=\"w\"> <\/span>pelican\npelican<span class=\"w\"> <\/span>content\n<\/code><\/pre><\/div>\n\n\n<p>Then we need to update the local copies of the plugins and themes. If you have just cloned from the original git repos the nall you need to do&nbsp;is <\/p>\n<div class=\"highlight\"><pre><span><\/span><code>git<span class=\"w\"> <\/span>pull<span class=\"w\"> <\/span>origin\n<\/code><\/pre><\/div>\n\n\n<h1 id=\"faqs-and-tips\">FAQs and Tips<a class=\"headerlink\" href=\"#faqs-and-tips\" title=\"Permanent link\">&para;<\/a><\/h1>\n<ul>\n<li><strong>Separate slug (<span class=\"caps\">URL<\/span>) words with a hyphen, or an underscore?<\/strong> you should use a <strong>hyphen<\/strong> for your <span class=\"caps\">SEO<\/span> <strong>URLs<\/strong>. Google treats a <strong>hyphen<\/strong> as a word separator, but does not treat an <strong>underscore<\/strong> that way. Google treats and <strong>underscore<\/strong> as a word joiner \u2014 so github_pages is the same as githubpages to&nbsp;Google.<\/li>\n<\/ul>","category":[{"@attributes":{"term":"Blog"}},{"@attributes":{"term":"Github"}},{"@attributes":{"term":"Pelican"}},{"@attributes":{"term":"gh-pages"}}]}]}