<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://ggarrettgrossman.ddns.net/feed.xml" rel="self" type="application/atom+xml" /><link href="https://ggarrettgrossman.ddns.net/" rel="alternate" type="text/html" /><updated>2021-08-19T23:48:39+00:00</updated><id>https://ggarrettgrossman.ddns.net/feed.xml</id><title type="html">Gcubed</title><subtitle>My personal website.</subtitle><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><entry><title type="html">Conspiracy Detector Web App</title><link href="https://ggarrettgrossman.ddns.net/machine%20learning/coding/webdev/conspiracy-detector-webapp/" rel="alternate" type="text/html" title="Conspiracy Detector Web App" /><published>2017-08-13T00:00:00+00:00</published><updated>2017-08-13T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/machine%20learning/coding/webdev/conspiracy-detector-webapp</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/machine%20learning/coding/webdev/conspiracy-detector-webapp/">&lt;aside class=&quot;sidebar__right&quot;&gt;
&lt;nav class=&quot;toc&quot;&gt;
    &lt;header&gt;&lt;h4 class=&quot;nav__title&quot;&gt;&lt;i class=&quot;fa fa-file-text&quot;&gt;&lt;/i&gt; On This Page&lt;/h4&gt;&lt;/header&gt;
&lt;ul class=&quot;toc__menu&quot; id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#guess-what&quot; id=&quot;markdown-toc-guess-what&quot;&gt;Guess what!&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#wait-didnt-it-already-exist&quot; id=&quot;markdown-toc-wait-didnt-it-already-exist&quot;&gt;Wait, didn’t it already exist?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#so-what-pressing-need-does-it-solve&quot; id=&quot;markdown-toc-so-what-pressing-need-does-it-solve&quot;&gt;So what pressing need does it solve?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#is-it-a-sexy-sexy-website&quot; id=&quot;markdown-toc-is-it-a-sexy-sexy-website&quot;&gt;Is it a sexy, sexy website?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#so-how-does-it-work&quot; id=&quot;markdown-toc-so-how-does-it-work&quot;&gt;So how does it work?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#hasta-la-vista-baby&quot; id=&quot;markdown-toc-hasta-la-vista-baby&quot;&gt;Hasta la vista, baby!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

  &lt;/nav&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;guess-what&quot;&gt;Guess what!&lt;/h2&gt;
&lt;p&gt;I have finally created the definitive killer app, &lt;a href=&quot;https://conspiracydetector-web.herokuapp.com/&quot;&gt;Conspiracy Detector&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;wait-didnt-it-already-exist&quot;&gt;Wait, didn’t it already exist?&lt;/h2&gt;
&lt;p&gt;Fair enough, I am plagiarizing myself a little bit. If you have poked around  this site before, you might be aware of my previous &lt;a href=&quot;/machine%20learning/coding/conspiracy-detector/&quot;&gt;write up&lt;/a&gt; and portfolio item &lt;a href=&quot;/portfolio/conspiracy_detector/&quot;&gt;Conspiracy Detector&lt;/a&gt;. In fact, they are both based off of the same code, with this new version being a responsive web app.&lt;/p&gt;
&lt;h2 id=&quot;so-what-pressing-need-does-it-solve&quot;&gt;So what pressing need does it solve?&lt;/h2&gt;
&lt;p&gt;Why the need to be able to paste a blob of text into some stranger’s website and have it spit back out a heavily opinionated verdict on whether or not the text was written by someone off of their lithium of course!&lt;/p&gt;
&lt;h2 id=&quot;is-it-a-sexy-sexy-website&quot;&gt;Is it a sexy, sexy website?&lt;/h2&gt;
&lt;p&gt;Well, you are welcome to check for yourself, but in my opinion its rather spartan look  is  actually a statement against the oppression and commodification of the worker by the great neoliberal machine, a verbalization of the angst of the common man as the Ideological State Apparatus slowly imprisons us all within the confines of our own minds, all the while eating the orange and throwing away the peel in the words of Arthur Miller.&lt;/p&gt;

&lt;p&gt;In all seriousness though, the site is not the most beautiful to ever grace the interwebs. I designed it to be as minimalist as possible. It gets the job done and does not waste your time loading nor does it waste the rather limited resources of my mid 2000’s former thinclient server serving.&lt;/p&gt;

&lt;h2 id=&quot;so-how-does-it-work&quot;&gt;So how does it work?&lt;/h2&gt;
&lt;p&gt;The website is powered by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;flask&lt;/code&gt;, a microframework for python websites. Simply put, it takes the input of a text box, puts that string through the exact same code that gives predictions on the terminal (well, minus the tokenizer which slowed my server down too much and also caused some issues with loading my pretrained model), and serves a new page with the verdict.&lt;/p&gt;

&lt;h2 id=&quot;hasta-la-vista-baby&quot;&gt;Hasta la vista, baby!&lt;/h2&gt;
&lt;p&gt;And on that note, I hope you enjoyed my write up on Conspiracy Detector. If this interests you, go ahead and check out the web app  &lt;a href=&quot;https://conspiracydetector-web.herokuapp.com/&quot;&gt;here&lt;/a&gt;, the source code to the original &lt;a href=&quot;https://github.com/FakeNameSE/ConspiracyDetector&quot;&gt;here&lt;/a&gt;, or even my portfolio section on the project &lt;a href=&quot;/portfolio/conspiracy_detector/&quot;&gt;here&lt;/a&gt;, not to mention my original and more detailed write up  &lt;a href=&quot;/machine%20learning/coding/conspiracy-detector/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;
I have now just gotten around to posting the source code for the web app on GithHub &lt;a href=&quot;https://github.com/FakeNameSE/conspiracydetector-web&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I can’t shake the feeling that all these conspiracy theorists are in on it.
&lt;cite&gt;Wynne McLaughlin&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="machine learning" /><category term="coding" /><category term="webdev" /><category term="Support Vector Machine" /><category term="classification" /><category term="webapp" /><category term="Conspiracy Detector" /><category term="Flask" /><category term="linux" /><category term="server" /><summary type="html">On This Page Guess what! Wait, didn’t it already exist? So what pressing need does it solve? Is it a sexy, sexy website? Guess what! I have finally created the definitive killer app, Conspiracy Detector. Wait, didn’t it already exist? Fair enough, I am plagiarizing myself a little bit. If you have poked around this site before, you might be aware of my previous write up and portfolio item Conspiracy Detector. In fact, they are both based off of the same code, with this new version being a responsive web app. So what pressing need does it solve? Why the need to be able to paste a blob of text into some stranger’s website and have it spit back out a heavily opinionated verdict on whether or not the text was written by someone off of their lithium of course! Is it a sexy, sexy website? Well, you are welcome to check for yourself, but in my opinion its rather spartan look is actually a statement against the oppression and commodification of the worker by the great neoliberal machine, a verbalization of the angst of the common man as the Ideological State Apparatus slowly imprisons us all within the confines of our own minds, all the while eating the orange and throwing away the peel in the words of Arthur Miller.</summary></entry><entry><title type="html">Conspiracy Detector</title><link href="https://ggarrettgrossman.ddns.net/machine%20learning/coding/conspiracy-detector/" rel="alternate" type="text/html" title="Conspiracy Detector" /><published>2017-06-25T00:00:00+00:00</published><updated>2017-06-25T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/machine%20learning/coding/conspiracy-detector</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/machine%20learning/coding/conspiracy-detector/">&lt;aside class=&quot;sidebar__right&quot;&gt;
&lt;nav class=&quot;toc&quot;&gt;
    &lt;header&gt;&lt;h4 class=&quot;nav__title&quot;&gt;&lt;i class=&quot;fa fa-file-text&quot;&gt;&lt;/i&gt; On This Page&lt;/h4&gt;&lt;/header&gt;
&lt;ul class=&quot;toc__menu&quot; id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#what-are-you-babbling-about-now&quot; id=&quot;markdown-toc-what-are-you-babbling-about-now&quot;&gt;What are you babbling about now?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-exactly-did-this-happen&quot; id=&quot;markdown-toc-how-exactly-did-this-happen&quot;&gt;How exactly did this happen?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#so-what-does-it-actually-do&quot; id=&quot;markdown-toc-so-what-does-it-actually-do&quot;&gt;So what does it actually do?&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#what-conspiracy-detector-does&quot; id=&quot;markdown-toc-what-conspiracy-detector-does&quot;&gt;What Conspiracy Detector does&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#what-conspiracy-detector-does-not-do&quot; id=&quot;markdown-toc-what-conspiracy-detector-does-not-do&quot;&gt;What Conspiracy Detector does not do&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#how-does-the-magic-happen&quot; id=&quot;markdown-toc-how-does-the-magic-happen&quot;&gt;How does the magic happen?&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#give-me-some-technical-details&quot; id=&quot;markdown-toc-give-me-some-technical-details&quot;&gt;Give me some technical details!&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#and-what-about-training&quot; id=&quot;markdown-toc-and-what-about-training&quot;&gt;And what about training?&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#a-slight-problem&quot; id=&quot;markdown-toc-a-slight-problem&quot;&gt;A slight problem&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#so-how-did-you-fix-it&quot; id=&quot;markdown-toc-so-how-did-you-fix-it&quot;&gt;So, how did you fix it?&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#does-it-work&quot; id=&quot;markdown-toc-does-it-work&quot;&gt;Does it work?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#and-now-some-charts-and-tables&quot; id=&quot;markdown-toc-and-now-some-charts-and-tables&quot;&gt;And now some charts and tables&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#farewell&quot; id=&quot;markdown-toc-farewell&quot;&gt;Farewell&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

  &lt;/nav&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;what-are-you-babbling-about-now&quot;&gt;What are you babbling about now?&lt;/h2&gt;
&lt;p&gt;The scientific detection of clinical paranoia of course! This post is intended to complement my portfolio entry &lt;a href=&quot;/portfolio/conspiracy_detector/&quot;&gt;here&lt;/a&gt; on my conspiracy detector project, which I posted the code for on Github &lt;a href=&quot;https://github.com/FakeNameSE/ConspiracyDetector&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;
 I have also put together a web app that you can access &lt;a href=&quot;https://conspiracydetector-web.herokuapp.com/&quot;&gt;here&lt;/a&gt;. Unfortunately, because I am &lt;del&gt;self hosting (on the same box as this site)&lt;/del&gt; now hosting this site on Heroku (because setting it up for their free tier was a whole lot simpler than trying to run a server accessible to the wider world on a university network from my dorm room, that model has a simplified tokenizer to save processing power and is thus less accurate.&lt;/p&gt;

&lt;h2 id=&quot;how-exactly-did-this-happen&quot;&gt;How exactly did this happen?&lt;/h2&gt;
&lt;p&gt;Over the natural course of reducing false positives with my email spam filter, clearly! In truth, I kid you not, important emails were being filtered as spam and during my quest to fix this deep disturbance in the force, I was completely sidelined by my curiosity in the actual mechanics of spam filters. A few quick searches later and all was revealed to me… The secret sauce is math! Conditional probabilities and a naive Bayesian filter to be exact.I leave the actual specifics of the workings of this model to Wikipedia, but it suffices to say that it is a machine learning model which when given examples of inputs belonging to different categories is trained to draw inferences between certain characteristic of an input and its label, thereby allowing the trained model to make predictions and classify previously unseen inputs such as emails into spam and ham (legitimate).&lt;/p&gt;

&lt;p&gt;I then followed the obvious train of thought of using this type of system to determine whether or not Trump was the progenitor of a tweet. This jump was ultimately unsatisfactory, mainly because I was having a hard time finding a corpus of tweets that were not from Trump and training binary classifiers with only examples from one category leads to pretty disappointing results.&lt;/p&gt;

&lt;p&gt;Fortunately for my tinkering, I stumbled across this hilarious blog post entitled &lt;a href=&quot;https://www.stilldrinking.org/the-quantum-hitler-scale&quot;&gt;The Quantum Hitler Scale&lt;/a&gt; shortly thereafter, and decided that what the world was missing is a heavily opinionated bot capable of discerning text containing some semblance of rational and coherent thought from the literary works of the brave resistance fighters who refuse to be brought down by the Man and His Lithium pills, and who instead tell it like it is, staring death by shape-shifting, alien lizard monsters from the center of the Earth right in the eyes.&lt;/p&gt;

&lt;p&gt;And so, the conspiracy detector was born, a state of the art system powered by pure math (well really, applied math) with a twist of computer science.&lt;/p&gt;
&lt;h2 id=&quot;so-what-does-it-actually-do&quot;&gt;So what does it actually do?&lt;/h2&gt;
&lt;h3 id=&quot;what-conspiracy-detector-does&quot;&gt;What Conspiracy Detector does&lt;/h3&gt;
&lt;p&gt;Just as its name says, this weekend project (actually developed over summer break over the course of two weekdays) is a system that uses machine learning to detect conspiracy theories. In other words, I applied the miracles of modern mathematics and computer science to the prickly problem of detecting people who are totally off their rocker, or in the words of the verdict that my machine gives, “bonkers!”.&lt;/p&gt;
&lt;h3 id=&quot;what-conspiracy-detector-does-not-do&quot;&gt;What Conspiracy Detector does not do&lt;/h3&gt;
&lt;p&gt;An important caveat is that this system does not detect bias or even fake news (a much tougher problem because it can look pretty similar to reputable news sources). Instead it focuses on the previously (at least to the best of my knowledge) untackled problem of statistically determining if a given piece of text is absolutely nuts (shape-shifting, Jewish, alien lizard nuts).&lt;/p&gt;

&lt;p&gt;Another important factor is that this system is entirely constructed from my biases. It believes that the New World Order of Dick Cheney and the Communist, gay, Jews is a conspiracy theory (although I would not put it past Cheney), precisely because I think that this is a completely off its rocker conspiracy theory constructed by a lonely and chemically imbalanced talk show host, terrorist, or pseudo-intellectual who forgot to take his or her pills. If you do not agree with my assessment of what constitutes a crazy conspiracy theory, then you will not agree with this systems verdicts which reflect pretty strongly exactly what I think of the likes of Alex Jones, David Duke, Lyndon LaRouche, William Jennings Bryan, and company. In other words, if you believe &lt;a href=&quot;http://www.conservapedia.com/Main_Page&quot;&gt;Conservapedia&lt;/a&gt;, then this bot is probably not for you.&lt;/p&gt;

&lt;h2 id=&quot;how-does-the-magic-happen&quot;&gt;How does the magic happen?&lt;/h2&gt;
&lt;p&gt;Yep, almost indistinguishable from dark magic, this system is actually powered by math (also, python)! It uses a support vector machine (SVM), a machine learning model that can be used as a binary classifier, meaning a much fancier spam filter which is capable of assigning new inputs (after training) to one of two categories (so bonkers and not bonkers in this case).&lt;/p&gt;
&lt;h3 id=&quot;give-me-some-technical-details&quot;&gt;Give me some technical details!&lt;/h3&gt;
&lt;p&gt;The code is written in python3 and uses &lt;a href=&quot;http://scikit-learn.org/stable/&quot;&gt;sklearn&lt;/a&gt;, an awesome python library for all types of machine learning that I highly encourage you to check out, for the majority of the machine learning heavy lifting. It also uses nltk (a  python library for natural language processing) as part of the pipeline in the tokenizer for word stemming.&lt;/p&gt;
&lt;h3 id=&quot;and-what-about-training&quot;&gt;And what about training?&lt;/h3&gt;
&lt;p&gt;A large amount of this project, like many machine learning systems, was training data collection. In order to obtain these thousand of plain text samples necessary to train the system, I first quickly put together a web scraper in python to download articles from news sources such as CNN and BBC, as well as from my daily dose of dismay and despair for humanity (Infowars articles). To complement this, I then dove into the bowels of the &lt;a href=&quot;https://www.gutenberg.org/&quot;&gt;Gutenberg Project&lt;/a&gt;  and &lt;a href=&quot;https://archive.org/&quot;&gt;Archive.org&lt;/a&gt;, using old Infowars magazines, as well as “papers” from esteemed intellectuals like “Dr.” David Duke, Lyndon Larouche, William Jennings Bryan, Paul Joseph Watson, and so many more to obtain the irrefutable textual manifestation of clinical paranoia. On the more rational side, I populated the training set with the plain text English translations of several works by Dostoevsky, Tolstoy, Balzac, Flaubert, Hawthorne, and so many more, as well as through several bland scientific papers. I then split these documents into files of 100 lines each and removed all of the bizarre special characters which had infected some of these texts, eventually leaving me with a grand total of over 2000 training files.&lt;/p&gt;
&lt;h2 id=&quot;a-slight-problem&quot;&gt;A slight problem&lt;/h2&gt;
&lt;p&gt;When I initially built this system, it was pretty heavily based off of sklearn’s documentation examples. Unfortunately, due to David Duke and his love for Jews and communists, I had to tinker around quit a bit with tokenization, the process by which the words of the input text are split up and prepossessed, in order to prevent my baby from coughing up a lug nut every single time a text had the word “communist” or any variant of the word “Jew” or “Jewish” in it.&lt;/p&gt;
&lt;h3 id=&quot;so-how-did-you-fix-it&quot;&gt;So, how did you fix it?&lt;/h3&gt;
&lt;p&gt;After quite a bit of tinkering, I ended up adding among several minor things like stripping out white spaces and punctuation. This reduced the number of bizarre two letter features that would dominate the model’s conception of a conspiracy theory, but did not solve the underlying problem of the repeated use of certain  similar words. To solve that problem, I added word stemming to the tokenizer of the model. This strips all words to their roots, thereby reducing words like “jews” to “jew’ and preventing silly things such as plurals and derivations from causing too many problems. This solved my problem and improved overall accuracy quite a bit, but also slowed down the training process because of the added complexity to tokenization (although it is still very fast, taking only two minutes on my laptop from 2007).&lt;/p&gt;
&lt;h2 id=&quot;does-it-work&quot;&gt;Does it work?&lt;/h2&gt;
&lt;p&gt;Short answer: Yes!&lt;/p&gt;

&lt;p&gt;Longer answer, quite well. On the test cases during training, the model attains 99% accuracy. Moreover, it has passed my ultimate litmus test of distinguishing between a Washington Post article and an article from &lt;a href=&quot;http://www.conservapedia.com/Main_Page&quot;&gt;Conservapedia&lt;/a&gt;  (a Christian fundamentalist version of Wikipedia that among other things believes that Obama is an Islamist Terrorist, that Liberals are pretty much genocidal maniacs, and that conversion therapy works).&lt;/p&gt;

&lt;p&gt;In case you were curious,, it has also determined that my  &lt;a href=&quot;/about/&quot;&gt;about&lt;/a&gt; page is for the most part not crazy, and neither is the &lt;em&gt;Communist Manifesto&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;and-now-some-charts-and-tables&quot;&gt;And now some charts and tables&lt;/h2&gt;
&lt;p&gt;After each training session, the system extracts the top ten features that you can see here:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Top 10 most important features:&lt;/code&gt;&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;&lt;th style=&quot;text-align: right;&quot;&gt;  Rank&lt;/th&gt;&lt;th style=&quot;text-align: right;&quot;&gt;   Weight&lt;/th&gt;&lt;th&gt;Bonkers   &lt;/th&gt;&lt;th style=&quot;text-align: right;&quot;&gt;  Weight&lt;/th&gt;&lt;th&gt;Fine     &lt;/th&gt;&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     1&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.91936 &lt;/td&gt;&lt;td&gt;o         &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.964309&lt;/td&gt;&lt;td&gt;change   &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     2&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.21264 &lt;/td&gt;&lt;td&gt;jew       &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.87151 &lt;/td&gt;&lt;td&gt;wildlife &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     3&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.09732 &lt;/td&gt;&lt;td&gt;government&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.82531 &lt;/td&gt;&lt;td&gt;reynard  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     4&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.09311 &lt;/td&gt;&lt;td&gt;ei        &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.805876&lt;/td&gt;&lt;td&gt;trump    &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     5&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.08023 &lt;/td&gt;&lt;td&gt;louse     &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.805513&lt;/td&gt;&lt;td&gt;senator  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     6&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.06831 &lt;/td&gt;&lt;td&gt;n         &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.773819&lt;/td&gt;&lt;td&gt;specie   &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     7&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.062   &lt;/td&gt;&lt;td&gt;txt       &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.753482&lt;/td&gt;&lt;td&gt;â        &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     8&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-1.01539 &lt;/td&gt;&lt;td&gt;ee        &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.749294&lt;/td&gt;&lt;td&gt;prince   &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;     9&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.999346&lt;/td&gt;&lt;td&gt;obama     &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.719461&lt;/td&gt;&lt;td&gt;sea      &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    10&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.930854&lt;/td&gt;&lt;td&gt;written   &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.703385&lt;/td&gt;&lt;td&gt;energy   &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    11&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.91092 &lt;/td&gt;&lt;td&gt;jewish    &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.678142&lt;/td&gt;&lt;td&gt;place    &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    12&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.901538&lt;/td&gt;&lt;td&gt;magazine  &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.672481&lt;/td&gt;&lt;td&gt;climate  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    13&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.886269&lt;/td&gt;&lt;td&gt;medium    &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.670092&lt;/td&gt;&lt;td&gt;important&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    14&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.885437&lt;/td&gt;&lt;td&gt;american  &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.655379&lt;/td&gt;&lt;td&gt;point    &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    15&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.829171&lt;/td&gt;&lt;td&gt;right     &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.651944&lt;/td&gt;&lt;td&gt;section  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    16&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.807909&lt;/td&gt;&lt;td&gt;st        &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.648213&lt;/td&gt;&lt;td&gt;photon   &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    17&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.7689  &lt;/td&gt;&lt;td&gt;d         &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.641958&lt;/td&gt;&lt;td&gt;orofino  &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    18&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.761795&lt;/td&gt;&lt;td&gt;litical   &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.641508&lt;/td&gt;&lt;td&gt;king     &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    19&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.744603&lt;/td&gt;&lt;td&gt;generator &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.619919&lt;/td&gt;&lt;td&gt;conflict &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: right;&quot;&gt;    20&lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;-0.742536&lt;/td&gt;&lt;td&gt;freedom   &lt;/td&gt;&lt;td style=&quot;text-align: right;&quot;&gt;0.60663 &lt;/td&gt;&lt;td&gt;himself  &lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Or, if bar charts are more your speed, you can see the top 20 features for each category here:
&lt;img src=&quot;/assets/images/conspiracydetector_features.svg&quot; alt=&quot;Bar chart&quot; title=&quot;Top 20 features&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, some weird things come up, mainly on the crazy side, because the input text is still a little dirty despite several attempts to clean it up. However, the system actually works quite well as you can see from its confusion matrix and classification report (from the test set):&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Classification Report:
             precision    recall  f1-score   support

    bonkers       0.99      0.99      0.99       298
       fine       0.99      0.99      0.99       303

avg / total       0.99      0.99      0.99       601


Confusion Matrix:
[[294   4]
 [  4 299]]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Overall, the top 10 features seem to indicate that a lot of conspiracy theories tend to focus on Jews, Obama, and the Government, as well as on our freedom being taken away, as the words “American” and “freedom” seem to indicate.&lt;/p&gt;

&lt;h2 id=&quot;farewell&quot;&gt;Farewell&lt;/h2&gt;
&lt;p&gt;And on that note, I hope you enjoyed my write up Conspiracy Detector. If this interests you, go ahead and check out the source code &lt;a href=&quot;https://github.com/FakeNameSE/ConspiracyDetector&quot;&gt;here&lt;/a&gt;, or even my portfolio section on the project &lt;a href=&quot;/portfolio/conspiracy_detector/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I stand by these selections and QHP, but a principle is not enough. No, after reading thousands of articles of alluring bullshit promising me oneness with Earth, good health, eternal life, and infinite persecution by secret kabbalahs bent on world domination and keeping me from knowing the truth about vitamin C, I thought, “Why can’t my computer sort this out for me?” I wanted a program that I could plug in that would tell me if the author of an article was bulldozing bullshit, and I wanted to know how much and how fast. I wanted a Quantum Hitler Scale.
&lt;cite&gt;&lt;a href=&quot;https://www.stilldrinking.org&quot;&gt;Peter Welch&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="machine learning" /><category term="coding" /><category term="Support Vector Machine" /><category term="classification" /><category term="Quantum Hitler Scale" /><category term="Conspiracy Detector" /><summary type="html">On This Page What are you babbling about now? What are you babbling about now? The scientific detection of clinical paranoia of course! This post is intended to complement my portfolio entry here on my conspiracy detector project, which I posted the code for on Github here .</summary></entry><entry><title type="html">An intro to Prisoner’s Dilemma</title><link href="https://ggarrettgrossman.ddns.net/game%20theory/coding/prisoner-dilemma/" rel="alternate" type="text/html" title="An intro to Prisoner’s Dilemma" /><published>2017-03-05T00:00:00+00:00</published><updated>2017-03-05T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/game%20theory/coding/prisoner-dilemma</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/game%20theory/coding/prisoner-dilemma/">&lt;aside class=&quot;sidebar__right&quot;&gt;
&lt;nav class=&quot;toc&quot;&gt;
    &lt;header&gt;&lt;h4 class=&quot;nav__title&quot;&gt;&lt;i class=&quot;fa fa-file-text&quot;&gt;&lt;/i&gt; On This Page&lt;/h4&gt;&lt;/header&gt;
&lt;ul class=&quot;toc__menu&quot; id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#the-first-musings&quot; id=&quot;markdown-toc-the-first-musings&quot;&gt;The first musings&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#what-is-prisoners-dilemma&quot; id=&quot;markdown-toc-what-is-prisoners-dilemma&quot;&gt;What is Prisoner’s Dilemma?&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#normal-prisoners-dilemma&quot; id=&quot;markdown-toc-normal-prisoners-dilemma&quot;&gt;Normal Prisoner’s Dilemma&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#iterated-prisoners-dilemma&quot; id=&quot;markdown-toc-iterated-prisoners-dilemma&quot;&gt;Iterated Prisoner’s Dilemma&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#through-the-lens-of-game-theory&quot; id=&quot;markdown-toc-through-the-lens-of-game-theory&quot;&gt;Through the Lens of Game Theory&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#some-history&quot; id=&quot;markdown-toc-some-history&quot;&gt;Some History…&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#would-you-like-to-play-a-game&quot; id=&quot;markdown-toc-would-you-like-to-play-a-game&quot;&gt;Would you like to play a game?&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#axelrods-tournament&quot; id=&quot;markdown-toc-axelrods-tournament&quot;&gt;Axelrod’s Tournament&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#the-tournament&quot; id=&quot;markdown-toc-the-tournament&quot;&gt;The Tournament&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#so-which-strategy-won&quot; id=&quot;markdown-toc-so-which-strategy-won&quot;&gt;So, which strategy won?&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#tit-for-tat&quot; id=&quot;markdown-toc-tit-for-tat&quot;&gt;Tit for Tat&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#variants-of-tit-for-tat&quot; id=&quot;markdown-toc-variants-of-tit-for-tat&quot;&gt;Variants of Tit for Tat&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#my-own-strategy&quot; id=&quot;markdown-toc-my-own-strategy&quot;&gt;My own strategy!&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-only-way-to-win-is-not-to-play&quot; id=&quot;markdown-toc-the-only-way-to-win-is-not-to-play&quot;&gt;The Only Way to Win is Not to Play…&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

  &lt;/nav&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;the-first-musings&quot;&gt;The first musings&lt;/h2&gt;
&lt;p&gt;I have recently been reworking a computer science and mathematics workshop that I have been running with the &lt;a href=&quot;/portfolio/united-innovators/&quot;&gt;United Innovators&lt;/a&gt; , and I thought that I might as well share my thoughts on just how interesting I think it is.&lt;/p&gt;

&lt;h2 id=&quot;what-is-prisoners-dilemma&quot;&gt;What is Prisoner’s Dilemma?&lt;/h2&gt;
&lt;h3 id=&quot;normal-prisoners-dilemma&quot;&gt;Normal Prisoner’s Dilemma&lt;/h3&gt;
&lt;p&gt;Prisoner’s Dilemma is a classical game theory problem in which two prisoners are given the option to defect (betray the other) or cooperate (stay tight lipped). These actions carry different incentives depending on the actions of the opponent that can be represented like so:
&lt;img src=&quot;/assets/images/pd-teaser.png&quot; alt=&quot;Different consequences for actions&quot; title=&quot;Different consequences for actions&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Thus, when playing a single game the best option is always to defect because it minimizes the potential cost while maximizing the potential reward, especially since the opponent cannot retaliate later.&lt;/p&gt;

&lt;h3 id=&quot;iterated-prisoners-dilemma&quot;&gt;Iterated Prisoner’s Dilemma&lt;/h3&gt;
&lt;p&gt;However, things get more interesting when we spice them up with a twist on the game, iterated prisoner’s dilemma. In this case, the players play multiple successive games, both aware of the other’s past moves. This means that there is a possibility for retaliation, creating a need for more nuanced strategies.&lt;/p&gt;

&lt;h3 id=&quot;through-the-lens-of-game-theory&quot;&gt;Through the Lens of Game Theory&lt;/h3&gt;
&lt;p&gt;Game theory is as Wikipedia puts,&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The study of mathematical models of conflict and cooperation between intelligent rational decision-makers.”
&lt;cite&gt;Wikipedia&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In other words, it deals with how to  maximize rewards and minimize negative outcomes when competing and cooperating with other selfish parties.&lt;/p&gt;

&lt;p&gt;If we translate iterative prisoner’s dilemma into the terms of game theory, this means that we get a game that is:&lt;/p&gt;

&lt;dl&gt;
  &lt;dt&gt;&lt;strong&gt;Symmetrical&lt;/strong&gt;&lt;/dt&gt;
  &lt;dd&gt;Both parties have equal power&lt;/dd&gt;
  &lt;dt&gt;&lt;strong&gt;Non-Zero Sum&lt;/strong&gt;&lt;/dt&gt;
  &lt;dd&gt;Net result is not necessarily 0, so both players can win or lose&lt;/dd&gt;
  &lt;dt&gt;&lt;strong&gt;Simultaneous&lt;/strong&gt;&lt;/dt&gt;
  &lt;dd&gt;Players make their moves simultaneously&lt;/dd&gt;
  &lt;dt&gt;&lt;strong&gt;Imperfect Information&lt;/strong&gt;&lt;/dt&gt;
  &lt;dd&gt;Each player does not know what the other one is doing&lt;/dd&gt;
  &lt;dt&gt;&lt;strong&gt;Discrete Game&lt;/strong&gt;&lt;/dt&gt;
  &lt;dd&gt;Moves are discrete and binary&lt;/dd&gt;
&lt;/dl&gt;

&lt;h2 id=&quot;some-history&quot;&gt;Some History…&lt;/h2&gt;
&lt;p&gt;At this point I think that its interesting to inject some historical context into this problem.&lt;/p&gt;

&lt;h3 id=&quot;would-you-like-to-play-a-game&quot;&gt;Would you like to play a game?&lt;/h3&gt;
&lt;p&gt;Yes, I did just manage to tie this in with &lt;em&gt;Wargames&lt;/em&gt;. Prisoner’s Dilemma actually does originate from the Cold War when the United States was struggling to figure out how to keep the Arms Race under control without over-escalating to war. Around the time of the Cuban Missile Crisis they came to an organization called the &lt;em&gt;Rand Corporation&lt;/em&gt;, an American nonprofit global policy think tank made up of mathematicians, economists, and public policy experts. These academics subsequently modeled the scenario  using the mathematical model of Prisoner’s Dilemma and made pioneering working studying this problem, all to avoid nuclear war (or win one when they thought it was possible to).&lt;/p&gt;

&lt;h2 id=&quot;axelrods-tournament&quot;&gt;Axelrod’s Tournament&lt;/h2&gt;
&lt;h3 id=&quot;the-tournament&quot;&gt;The Tournament&lt;/h3&gt;
&lt;p&gt;In the 80’s a professor named Robert Axelrod decided to try a new approach to Prisoner’s Dilemma. He setup a round robin tournament in which he excepted code submissions from around the world to compete as bots. The interesting thing is that he discovered that it is the “greedy” strategies, those that are the most selfish, that in the long run did the worst whereas within that scope it was the more altruistic strategies that began to shine. This lead him to conclude that cooperation between organisms might actually be the result of natural selection, with the most strictly selfish (over the short term) behaviors that in the end lead to failure.&lt;/p&gt;

&lt;h3 id=&quot;so-which-strategy-won&quot;&gt;So, which strategy won?&lt;/h3&gt;
&lt;h4 id=&quot;tit-for-tat&quot;&gt;Tit for Tat&lt;/h4&gt;
&lt;p&gt;While it obviously depends on the competitors, the winner of the tournament was a remarkably short and simple strategy called &lt;em&gt;Tit for Tat&lt;/em&gt;. The rules for it were simple:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Always start by cooperating&lt;/li&gt;
  &lt;li&gt;Repeat the same move the opponent did the move before
In other words, this algorithm tries to quick start a virtuous cycle of cooperation, then rewards further cooperation from the opponent with cooperation and penalizes defections by retaliating with a defection. This avoids the costly situation of cooperating when the opponent defects, while still attempting to construct a virtuous cycle of mutual cooperation, the only move in the game that truly benefits both players.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;variants-of-tit-for-tat&quot;&gt;Variants of Tit for Tat&lt;/h4&gt;
&lt;p&gt;Over the years, a couple of variants of &lt;em&gt;Tit for Tat&lt;/em&gt; have emerged. Some like &lt;em&gt;Two Tits for Tat&lt;/em&gt; are a little stricter when it comes to retaliation by retaliating with a defection for two turns instead of one, while others have introduced the concept of forgiveness, that the bot has a certain probability of cooperating even if the opponent defects.&lt;/p&gt;

&lt;h4 id=&quot;my-own-strategy&quot;&gt;My own strategy!&lt;/h4&gt;
&lt;p&gt;The entire concept of Prisoner’s Dilemma, the mix between geopolitics, mathematics, and computer science, fascinated me enough that not only have I run a workshop on it (and  I’m planning on doing another one soon), but I actually came up with my own original strategy called &lt;em&gt;Dynamic Two Tits for Tat&lt;/em&gt; which  you can take a closer look at in my portfolio &lt;a href=&quot;/portfolio/Axelrod-strategy/&quot;&gt;here&lt;/a&gt; . In fact, if you want to take a closer look, it is now a strategy integrated into the Axelrod repository, an awesome open source project that you can take a look at &lt;a href=&quot;https://github.com/Axelrod-Python/Axelrod&quot;&gt;here&lt;/a&gt;, and which allows you to run full blown matches and tournaments between strategies (and so much more)!&lt;/p&gt;

&lt;p&gt;I digress. My own minor contribution to this field is another variant of &lt;em&gt;Tit for Tat&lt;/em&gt;. It  is actually based off of &lt;em&gt;Two Tits for Tat&lt;/em&gt;, but integrates a probability of forgiveness, meaning cooperating even when the opponent has defected within the last two turns, which is calculated as the ration of the opponents number of defections and total number of moves: 
&lt;img src=&quot;/assets/images/forgiveness.svg&quot; alt=&quot;number of defections over total number of moves&quot; title=&quot;Calculation of forgiveness&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This represents in a sense just how nice the opponent is, and thus allows my bot to determine how forgiving it should be of its opponent based off of this (which is also the odds that any move by the opponent will be a defection).&lt;/p&gt;

&lt;h2 id=&quot;the-only-way-to-win-is-not-to-play&quot;&gt;The Only Way to Win is Not to Play…&lt;/h2&gt;
&lt;p&gt;Or maybe just to outsmart them with a better strategy (just kidding, nuclear war is unwinnable).&lt;/p&gt;

&lt;p&gt;And on that bright note, I hope you enjoyed my write up on the Prisoner’s Dilemma. I can’t encourage you enough to check out the Axelrod repository &lt;a href=&quot;https://github.com/Axelrod-Python/Axelrod&quot;&gt;here&lt;/a&gt;, or even my portfolio section on my strategy  &lt;a href=&quot;/portfolio/Axelrod-strategy/&quot;&gt;here&lt;/a&gt; if this interests you.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Dr. Strangelove: The whole point of the doomsday machine is lost…if you keep it a secret! Why didn’t you tell the world, eh?!
Russian Ambassador: It was to be announced at the Party Congress on Monday. As you know, the Premier loves surprises.
&lt;cite&gt;Dr. Strangelove: Or How I Learned to Stop Worrying and Love the Bomb&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="game theory" /><category term="coding" /><category term="prisonner's dilemma" /><category term="intro" /><summary type="html">On This Page The first musings The first musings I have recently been reworking a computer science and mathematics workshop that I have been running with the United Innovators , and I thought that I might as well share my thoughts on just how interesting I think it is.</summary></entry><entry><title type="html">Sexy, sexy custom 404 pages with Apache</title><link href="https://ggarrettgrossman.ddns.net/webdev/tutorial/custom-404-message/" rel="alternate" type="text/html" title="Sexy, sexy custom 404 pages with Apache" /><published>2017-02-02T00:00:00+00:00</published><updated>2017-02-02T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/webdev/tutorial/custom-404-message</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/webdev/tutorial/custom-404-message/">&lt;h2 id=&quot;what-is-this-404-page-you-speak-of&quot;&gt;What is this 404 page you speak of?&lt;/h2&gt;
&lt;p&gt;So, you just put together a beautiful webpage when lo and behold, you mistype the url and get a terrifying looking message like this:
&lt;img src=&quot;/assets/images/default-404.png&quot; alt=&quot;Default Apache 404 Message&quot; title=&quot;Default Apache 404 Message&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It’s like the creators of this message were trying to destroy your carefully crafted aesthetic experience, and maybe give your visitor a cold shiver down their spine from this brutally ugly and utterly unhelpful message.&lt;/p&gt;

&lt;h2 id=&quot;save-me&quot;&gt;Save me!&lt;/h2&gt;
&lt;p&gt;Fear not though! This can be fixed with less effort than you might imagine. Unfortunately, most tutorials that I came across seem to be meant for Wordpress sites and/or tell you to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.htaccess&lt;/code&gt; file, something which the folks  who built Apache very explicitly tell you not to do on their site with:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.
&lt;cite&gt;&lt;a href=&quot;https://httpd.apache.org/docs/2.4/howto/htaccess.html&quot;&gt;The Apache Team&lt;/a&gt;&lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;so-how-did-you-manage-it&quot;&gt;So, how did you manage it?&lt;/h2&gt;
&lt;p&gt;The good thing is that this is pretty easy to do right using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhosts&lt;/code&gt; and just a little bit of tinkering (we are running this on Linux after all).&lt;/p&gt;

&lt;h3 id=&quot;create-your-404-page&quot;&gt;Create your 404 page&lt;/h3&gt;
&lt;p&gt;First of all, create a beautiful &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404&lt;/code&gt; page named  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404.html&lt;/code&gt; and make sure that it is in the root web directory of your site.&lt;/p&gt;

&lt;h3 id=&quot;some-inspiration&quot;&gt;Some inspiration&lt;/h3&gt;
&lt;p&gt;Now, if you are lacking inspiration for your page, the magical interwebs will most certainly come to your rescue if you just search for custom &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404&lt;/code&gt; pages. Alternatively, you can check out mine &lt;a href=&quot;/404.html&quot;&gt;here&lt;/a&gt; .&lt;/p&gt;

&lt;h3 id=&quot;and-onto-apache&quot;&gt;And onto Apache&lt;/h3&gt;
&lt;p&gt;This part is actually quite simple. Just open the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhost&lt;/code&gt; file of your site with: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/apache2/sites-available/example.com.conf&lt;/code&gt; (example.com being the name of your site’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhost&lt;/code&gt; file) and add the line:
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ErrorDocument 404 /404.html&lt;/code&gt; under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, if you used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;certbot&lt;/code&gt; to setup &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https&lt;/code&gt;, you will need to repeat the same process with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apache2/sites-available/example.com.conf-le-ssl.conf&lt;/code&gt; file it created.&lt;/p&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Tip&lt;/strong&gt;  If you followed my previous tutorial about setting up your server and building your site with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Jekyll&lt;/code&gt;, then just modify as needed your theme’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404&lt;/code&gt; file (probably names &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404.md&lt;/code&gt;) and then follow along with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhost&lt;/code&gt; configuration.&lt;/p&gt;

&lt;h2 id=&quot;and-voila&quot;&gt;And Voila!&lt;/h2&gt;
&lt;p&gt;Done! Your visitors will now be graced with a beautiful custom &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404&lt;/code&gt; page.&lt;/p&gt;

&lt;p&gt;Thank you for dropping by, and&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;
    So long, and thanks for all of the fish!
  &lt;/p&gt;
  &lt;footer&gt;&lt;cite title=&quot;Douglas Adams&quot;&gt;Douglas Adams&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="webdev" /><category term="tutorial" /><category term="webdev" /><category term="server" /><summary type="html">What is this 404 page you speak of? So, you just put together a beautiful webpage when lo and behold, you mistype the url and get a terrifying looking message like this:</summary></entry><entry><title type="html">How I built this site!</title><link href="https://ggarrettgrossman.ddns.net/website/webdev/tutorial/building-of-new-site/" rel="alternate" type="text/html" title="How I built this site!" /><published>2017-01-05T00:00:00+00:00</published><updated>2017-01-05T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/website/webdev/tutorial/building-of-new-site</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/website/webdev/tutorial/building-of-new-site/">&lt;aside class=&quot;sidebar__right&quot;&gt;
&lt;nav class=&quot;toc&quot;&gt;
    &lt;header&gt;&lt;h4 class=&quot;nav__title&quot;&gt;&lt;i class=&quot;fa fa-file-text&quot;&gt;&lt;/i&gt; On This Page&lt;/h4&gt;&lt;/header&gt;
&lt;ul class=&quot;toc__menu&quot; id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#remember-remember-the-5th-of-november&quot; id=&quot;markdown-toc-remember-remember-the-5th-of-november&quot;&gt;Remember, remember the 5th of November?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#step-one-the-hardware&quot; id=&quot;markdown-toc-step-one-the-hardware&quot;&gt;Step one, the hardware&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#and-now-onto-the-software-end-of-things&quot; id=&quot;markdown-toc-and-now-onto-the-software-end-of-things&quot;&gt;And now, onto the software end of things…&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#the-os&quot; id=&quot;markdown-toc-the-os&quot;&gt;The OS&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#the-install&quot; id=&quot;markdown-toc-the-install&quot;&gt;The Install&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#basic-os-setup&quot; id=&quot;markdown-toc-basic-os-setup&quot;&gt;Basic OS setup&lt;/a&gt;            &lt;ul&gt;
              &lt;li&gt;&lt;a href=&quot;#update-and-install&quot; id=&quot;markdown-toc-update-and-install&quot;&gt;Update and install&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#setup-your-user&quot; id=&quot;markdown-toc-setup-your-user&quot;&gt;Setup your user&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#setup-ssh&quot; id=&quot;markdown-toc-setup-ssh&quot;&gt;Setup ssh&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#setup-a-firewall&quot; id=&quot;markdown-toc-setup-a-firewall&quot;&gt;Setup a firewall&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#automatic-security-updates&quot; id=&quot;markdown-toc-automatic-security-updates&quot;&gt;Automatic security updates&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#the-software&quot; id=&quot;markdown-toc-the-software&quot;&gt;The software&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#port-forwarding&quot; id=&quot;markdown-toc-port-forwarding&quot;&gt;Port forwarding&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#getting-a-free-domain-name&quot; id=&quot;markdown-toc-getting-a-free-domain-name&quot;&gt;Getting a free domain name&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#the-web-server&quot; id=&quot;markdown-toc-the-web-server&quot;&gt;The web-server&lt;/a&gt;            &lt;ul&gt;
              &lt;li&gt;&lt;a href=&quot;#installing-apache&quot; id=&quot;markdown-toc-installing-apache&quot;&gt;Installing Apache&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#configuring-apache-virtualhosts&quot; id=&quot;markdown-toc-configuring-apache-virtualhosts&quot;&gt;Configuring Apache Virtualhosts&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#setting-up-https-for-free&quot; id=&quot;markdown-toc-setting-up-https-for-free&quot;&gt;Setting up https for free!&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#finally-the-actual-website&quot; id=&quot;markdown-toc-finally-the-actual-website&quot;&gt;Finally, the actual website&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#a-quick-intro-to-jekyll&quot; id=&quot;markdown-toc-a-quick-intro-to-jekyll&quot;&gt;A quick intro to Jekyll&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#what-is-jekyll&quot; id=&quot;markdown-toc-what-is-jekyll&quot;&gt;What is Jekyll?&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#how-does-it-work&quot; id=&quot;markdown-toc-how-does-it-work&quot;&gt;How does it work?&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#themes-did-you-say-themes&quot; id=&quot;markdown-toc-themes-did-you-say-themes&quot;&gt;Themes, did you say themes?&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#great-but-how-do-i-host-this&quot; id=&quot;markdown-toc-great-but-how-do-i-host-this&quot;&gt;Great, but how do I host this?&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#so-how-do-you-self-host&quot; id=&quot;markdown-toc-so-how-do-you-self-host&quot;&gt;So how do you self host?&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

  &lt;/nav&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;remember-remember-the-5th-of-november&quot;&gt;Remember, remember the 5th of November?&lt;/h2&gt;
&lt;p&gt;Or, my previous post. Well, if you don’t, in that post I announced the creation of this site, outlined its purpose, and promised to put together an article on how I put together this website, mainly because it was a bit of a pain to find all of the information I needed to setup and self host Jekyll, and I think it would be helpful to have it all in one place for the sake of my sanity and possibly yours.&lt;/p&gt;

&lt;h2 id=&quot;step-one-the-hardware&quot;&gt;Step one, the hardware&lt;/h2&gt;
&lt;p&gt;While I do have and Raspberry Pi Model B+ lying around (used for among other things a personal IRC server), I decided that because this new webserver would be hosting both this website and also an Owncloud installation (a personal cloud server and possibly the subject of another post), it would need to run on something a little beefier. That is where the &lt;a href=&quot;http://www.dell.com/us/dfb/p/optiplex-fx160/pd&quot;&gt;Dell OptiPlex FX160&lt;/a&gt; comes into the picture.&lt;/p&gt;

&lt;p&gt;The OptiPlex FX160 is an old thinclient server, meaning that it was used by companies to run Citrix installations  that their employees could remote into. The best part is that a  whole lot of them have flooded  places like Ebay for cheap because it is relatively old hardware that has just gone off lease.&lt;/p&gt;

&lt;p&gt;There are a couple of nice things about this box that  led to me picking one up:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;They are cheap (I got mine with 3 GB of RAM and a 240 GB hdd for $55, only marginally more than the cost of a Raspberry Pi)&lt;/li&gt;
  &lt;li&gt;They are fast:
    &lt;ul&gt;
      &lt;li&gt;Because I can hook up the hdd directly over SATA, the IO bottleneck that made my Pi painfully slow as a webserver is no longer an issue.&lt;/li&gt;
      &lt;li&gt;With 3GB of RAM in my case and a 1.2 Ghz Intel Atom, it is pretty snappy.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;They are really energy efficient (not much worse than a Pi).&lt;/li&gt;
  &lt;li&gt;They are dead silent (fanless).&lt;/li&gt;
  &lt;li&gt;They look pretty sexy in my completely subjective opinion.&lt;/li&gt;
  &lt;li&gt;And why not?&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class=&quot;half &quot;&gt;
  
    
      &lt;a href=&quot;https://ggarrettgrossman.ddns.net/assets/images/FX160-1.jpg&quot;&gt;
        &lt;img src=&quot;https://ggarrettgrossman.ddns.net/assets/images/FX160-1.jpg&quot; alt=&quot;Picture 1 of FX160&quot; /&gt;
      &lt;/a&gt;
    
  
    
      &lt;a href=&quot;https://ggarrettgrossman.ddns.net/assets/images/FX160-2.jpg&quot;&gt;
        &lt;img src=&quot;https://ggarrettgrossman.ddns.net/assets/images/FX160-2.jpg&quot; alt=&quot;Picture 2 of FX160&quot; /&gt;
      &lt;/a&gt;
    
  
  
    &lt;figcaption&gt;A couple of pictures of my sexy, sexy home server. And yes, I know I am a master photographer.
&lt;/figcaption&gt;
  
&lt;/figure&gt;

&lt;h2 id=&quot;and-now-onto-the-software-end-of-things&quot;&gt;And now, onto the software end of things…&lt;/h2&gt;
&lt;p&gt;If you were like me and thought that the hardware end seemed a little too easy, welcome to the fun part. First stop, Debian.&lt;/p&gt;

&lt;p&gt;I chose Debian because it is fast, lean, and very stable with a wide selection of software. Kind of like Ubuntu without all of the bloat they add to Debian. Anyways, Debian owes being lean to people who take the expression&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;My program is user friendly, it is just very selective about its users&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to heart.&lt;/p&gt;

&lt;p&gt;A good example of this is quite simply the fact that it is very likely that the last time the Debian webpage was modified was in the mid 90’s (and yes this is the webpage of the same project that runs much of the world’s banking institutions among other things). For instance, it is laughably difficult to actually find the download links for the Debian iso, so to save you a bit of time (to make up for the time you just spent reading my tangent), here is the &lt;a href=&quot;https://cdimage.debian.org/debian-cd/current/amd64/bt-cd/&quot;&gt;torrent&lt;/a&gt;  link and here is the regular over &lt;a href=&quot;https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/&quot;&gt;http&lt;/a&gt; download link.&lt;/p&gt;

&lt;p&gt;Anyways, it is now time to start setting up and configuring your shiny new Debian system:&lt;/p&gt;
&lt;h3 id=&quot;the-os&quot;&gt;The OS&lt;/h3&gt;
&lt;h4 id=&quot;the-install&quot;&gt;The Install&lt;/h4&gt;
&lt;p&gt;Installing Debian is actually pretty easy. Just&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Burn the iso to your USB (using dd or unetbootin)&lt;/li&gt;
  &lt;li&gt;Plug the USB into your soon to be server&lt;/li&gt;
  &lt;li&gt;Turn on the future server and hit the function key that lets you select the media to boot off of&lt;/li&gt;
  &lt;li&gt;Select your USB and hit enter&lt;/li&gt;
  &lt;li&gt;Select install Debian from the GRUB menu&lt;/li&gt;
  &lt;li&gt;Follow the instructions&lt;/li&gt;
  &lt;li&gt;Sit back, relax, and enjoy the ride&lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;basic-os-setup&quot;&gt;Basic OS setup&lt;/h4&gt;
&lt;h5 id=&quot;update-and-install&quot;&gt;Update and install&lt;/h5&gt;
&lt;p&gt;First of all, let’s make sure all of our software is up to date:
Log in with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;root&lt;/code&gt; credentials (we have not set up the normal user with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo&lt;/code&gt; privileges yet) and run:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt-get  update &amp;amp;&amp;amp; sudo apt-get upgrade &amp;amp;&amp;amp; sudo apt-get dist-upgrade&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reboot&lt;/code&gt; for good mesure.&lt;/p&gt;

&lt;p&gt;Now  what we are going to do is setup ssh so that we can run the server headless:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt-get install ssh  openssh-server&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make sure that your favorite text editor is installed:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt-get install nano vi&lt;/code&gt;&lt;/p&gt;

&lt;h5 id=&quot;setup-your-user&quot;&gt;Setup your user&lt;/h5&gt;
&lt;p&gt;Now, lets make things more convenient by granting your normal user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo&lt;/code&gt; privileges:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Install sudo:&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apt-get install sudo&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Grant privileges: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;usermod -aG sudo username&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Open your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/sudoers&lt;/code&gt; file with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visudo&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano  /etc/sudoers&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Make sure the line under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;# Allow members of group sudo to execute any command&lt;/code&gt; looks exacly like this: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;%sudo   ALL=(ALL:ALL) ALL&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Restart the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SSHD&lt;/code&gt; server with: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/init.d/sshd restart&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Logout and then back in with you new non root user (run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;logout&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Tip&lt;/strong&gt;  You  use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ctrl-w&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nano&lt;/code&gt; to search the file and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ctrl-x&lt;/code&gt; to close it (hit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;enter&lt;/code&gt; when it asks about the filename and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;y&lt;/code&gt; to confirm).&lt;/p&gt;

&lt;h5 id=&quot;setup-ssh&quot;&gt;Setup ssh&lt;/h5&gt;
&lt;p&gt;Now, lets make things a little more secure by forcing key based authentication for ssh and disabling direct root login:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;First disable root logins by opening &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ssh/sshd_config&lt;/code&gt; and changing the line &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PermitRootLogin&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PermitRootLogin no&lt;/code&gt; (you might need to get rid of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#&lt;/code&gt; prefixing it)&lt;/li&gt;
  &lt;li&gt;Create a key by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh-keygen -t rsa&lt;/code&gt; on the computer you will login in to the server with (make sure to back these  keys up)&lt;/li&gt;
  &lt;li&gt;Now run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scp ~/.ssh/id_rsa.pub username@ipofserver:.ssh/authorized_keys&lt;/code&gt; (I’m assuming you’re running Linux) on the same computer to copy the public key to your server&lt;/li&gt;
  &lt;li&gt;Test by restarting the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sshd&lt;/code&gt;server with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/init.d/sshd restart&lt;/code&gt; and then trying to login to your server again (on Linux by running on your local machine &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh username@ipofserver&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;If that worked,  you can now disable password logins by opening &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/ssh/sshd_config&lt;/code&gt; and changing the line &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PasswordAuthentication&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PasswordAuthentication no&lt;/code&gt; (you might need to get rid of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#&lt;/code&gt; prefixing it)&lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Warning!&lt;/strong&gt; If you are considering exposing this server through &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; to the outside world, you should  look into something like port knocking and authentication rate limiters like  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fail2ban&lt;/code&gt;.&lt;/p&gt;

&lt;h5 id=&quot;setup-a-firewall&quot;&gt;Setup a firewall&lt;/h5&gt;
&lt;p&gt;Another easy thing you should do to harden your server is setup a basic firewall.
I chose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ufw&lt;/code&gt; a wrapper for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iptables&lt;/code&gt;, because it is a lot easier to quickly setup and for something like this we don’t need that much configuration&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ufw&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt-get install ufw&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Make sure it is configured to handle IPv6 too with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/default/ufw&lt;/code&gt; and making sure that IPv6 is set to &lt;strong&gt;yes&lt;/strong&gt;  with&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt; IPV6=yes&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Lets put together some basic rules: run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw default deny incoming&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw default allow outgoing&lt;/code&gt; to block all incoming connections and allow all outgoing connections from the server&lt;/li&gt;
  &lt;li&gt;Now, lets make sure that we don’t lock ourselves out when the firewall is brought up by allowing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ssh&lt;/code&gt; (port 22) connections by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw allow ssh&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;For good measure, enable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http&lt;/code&gt; (port 80) connections and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https&lt;/code&gt; (port 443) connections with: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw allow http&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw allow https&lt;/code&gt;. That way, we won’t be blocking any web connections when the web server is up and running&lt;/li&gt;
  &lt;li&gt;We are now ready to start the firewall with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw enable&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Check that all of the rules are setup with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ufw status&lt;/code&gt;. The output should resemble this:&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
443                        ALLOW       Anywhere
80                         ALLOW       Anywhere
22                         ALLOW       Anywhere (v6)
443                        ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere (v6)

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

&lt;h5 id=&quot;automatic-security-updates&quot;&gt;Automatic security updates&lt;/h5&gt;
&lt;p&gt;Another good thing to do in order to harden our system, after-all we are going to be exposing it to the internet,  is to setup automatic security updates.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;First, we need to install: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt-get install unattended-upgrades apt-listchanges&lt;/code&gt;.
If you get an error about the package not existing, add  the following to the end of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/sources.list&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;# backports
deb http://ftp.debian.org/debian jessie-backports main
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;Next, open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/apt/apt.conf.d/50unattended-upgrades&lt;/code&gt; and add the line &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Unattended-Upgrade::Mail &quot;root&quot;;&lt;/code&gt; inside the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Unattended-Upgrade::Origins-Pattern&lt;/code&gt; block&lt;/li&gt;
  &lt;li&gt;Now, just run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dpkg-reconfigure -plow unattended-upgrades&lt;/code&gt; in order to configure &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unattended-upgrades&lt;/code&gt; (just hit yes when it asks if it should automatically install certain updates&lt;/li&gt;
  &lt;li&gt;And we are done!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So now the server is a little more hardened and we are ready to install the software for our web-server:&lt;/p&gt;

&lt;h3 id=&quot;the-software&quot;&gt;The software&lt;/h3&gt;
&lt;p&gt;In order to get this web-server up and running, there are a couple of pieces of software that we will need to install and confgure. These will be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; for the actual web-server, a client to update the IP for the server’s domain name, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;certbot&lt;/code&gt; for our free SSL certificate.&lt;/p&gt;

&lt;h4 id=&quot;port-forwarding&quot;&gt;Port forwarding&lt;/h4&gt;
&lt;p&gt;Firstly, we are going to need to setup port forwarding. This will allow you to expose your server on specified ports to the outside world (which is a little necessary for a web-server).&lt;/p&gt;

&lt;p&gt;Depending on your router, you will probably need to go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10.0.0.1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.1.1&lt;/code&gt;, or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.168.0.1&lt;/code&gt; with your browser. Enter your username and password (if you don’t know it, it is probably either written on your router or the default one which you can find online: &lt;em&gt;in which case change it!&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Now, find the menu for port forwarding (probably under advanced) and set it up to port forward ports &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;80&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;443&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https&lt;/code&gt;) to your server’s local IP address which you can get by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo ifconfig&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;getting-a-free-domain-name&quot;&gt;Getting a free domain name&lt;/h4&gt;
&lt;p&gt;Once that is out of the way, you should now get a domain name. This allows people to type in the domain (for instance &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;www.google.com&lt;/code&gt;) and have it redirect to your server’s public  IP address which can change and is harder to remember. While you can pay for a domain name, it is just as easy to get a free, albeit slightly uglier looking one.&lt;/p&gt;

&lt;p&gt;Several companies such as &lt;a href=&quot;https://www.noip.com/&quot;&gt;NoIp&lt;/a&gt;  provide free domain names, so you can just go over to one of their websites and follow their instructions to register one and set up a client on your server.&lt;/p&gt;

&lt;h4 id=&quot;the-web-server&quot;&gt;The web-server&lt;/h4&gt;
&lt;p&gt;We have finally reached the point where the humble computer gestates into a beautiful web-server. There are a couple of different ways to do this, with&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nginx&lt;/code&gt; being the two big solutions. While both work, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nginx&lt;/code&gt; might be a little faster in the context of serving static web pages, in my opinion &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; is &lt;em&gt;waaaaayyyyy&lt;/em&gt; easier and quicker to setup, especially if later on you want to setup something like &lt;a href=&quot;https://owncloud.org/&quot;&gt;Owncloud&lt;/a&gt;  (a personal cloud server) later on.&lt;/p&gt;
&lt;h5 id=&quot;installing-apache&quot;&gt;Installing Apache&lt;/h5&gt;
&lt;p&gt;First of all, we clearly need to install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt;, which is as easy as running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt-get install apache2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can test that this worked by going to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ipofyourserver&lt;/code&gt; with your web-browser.&lt;/p&gt;

&lt;h5 id=&quot;configuring-apache-virtualhosts&quot;&gt;Configuring Apache Virtualhosts&lt;/h5&gt;
&lt;p&gt;The next and last thing that we will need to directly configure with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtuahosts&lt;/code&gt;. These allow you to run multiple websites with different domain names from the same server.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;First, we need to create a root direcetoty for your new web-page. Run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mkdir -p /var/www/example.com/public_html&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example.com&lt;/code&gt; being the domain name that you picked up earlier.&lt;/li&gt;
  &lt;li&gt;Create a demo page for this site by copying the default demo page for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; wiith
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo cp /var/www/public_html/index.html /var/www/example.com/public_html/index.html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Next up, we need to changethe permissions of this new directotry structure so that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; will be able to serve our web-page.  Run
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo chgrp -R www-data /var/www/example.com &amp;amp;&amp;amp; sudo chown-R www-data /var/www/example.com &amp;amp;&amp;amp; sudo chmod -R 755 /var/www
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;At this point, we need to create the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhost&lt;/code&gt; file by first copying the default one with
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Customize this file by opening it with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo nano /etc/apache2/sites-available/example.com.conf&lt;/code&gt; and then
    &lt;ol&gt;
      &lt;li&gt;Setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ServerAdmin admin@example.com&lt;/code&gt; to your email&lt;/li&gt;
      &lt;li&gt;Setting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ServerName &lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example.com&lt;/code&gt; (your domain name)&lt;/li&gt;
      &lt;li&gt;Changing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot&lt;/code&gt; to your root directory which we set earlier to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DocumentRoot /var/www/example.com/public_html&lt;/code&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;Enable this new virtualhost and site with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo a2ensite example.com.conf&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Restart &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;apache&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo service apache2 restart&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Test this configuration by navigating to your domain name from outside your local network (for example using your phone connected with data)&lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Tip!&lt;/strong&gt;  You  can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhosts&lt;/code&gt; to setup and run multiple websites with different domain names from the same box. Just repeat the same steps for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;virtualhosts&lt;/code&gt; as above, but change the domain name and root directory. You will probably also need to reconfigure your dynamic ddns client to point your new domain name towards the same box, and also rerun the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;certbot&lt;/code&gt; step (up next) to have both sites use the same certificate.&lt;/p&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;A word of advice!&lt;/strong&gt; If you want access this site from its domain name from inside your network, you will need to modify your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/hosts&lt;/code&gt; file if you are running Linux so that that domain resolves to the local IP of your server.&lt;/p&gt;

&lt;h4 id=&quot;setting-up-https-for-free&quot;&gt;Setting up https for free!&lt;/h4&gt;
&lt;p&gt;At this point, the web-server is setup and serving a basic page when we connect to it. It even works with a domain name! However, we might want for the sake of security to enable &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;https&lt;/code&gt;, and thanks to the wonderful people from &lt;a href=&quot;https://letsencrypt.org/&quot;&gt;Let’s Encrypt&lt;/a&gt; , it is not only ridiculously easy, but also free.&lt;/p&gt;

&lt;p&gt;They even have a great guide &lt;a href=&quot;https://certbot.eff.org/#debianjessie-apache&quot;&gt;here&lt;/a&gt;  that shows you how to obtain that nice, shiny green lock.&lt;/p&gt;

&lt;h2 id=&quot;finally-the-actual-website&quot;&gt;Finally, the actual website&lt;/h2&gt;
&lt;p&gt;At last, you are nearing the end of the road. You are just spitting distance away from the random and wise quote, but alas, you have not yet achieved your goal of a beautiful website. You put your faith in me, and I abandon you at this junction with just a pitiful single &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;html&lt;/code&gt; page to show for it. But fear not! I have not forsaken you!&lt;/p&gt;

&lt;p&gt;In this part of the tutorial I am going to give you a quick overview of &lt;a href=&quot;https://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt; , the system I used to build this site. I will then show you how to self host, using the web-server we just setup, the content you create using Jekyll.&lt;/p&gt;

&lt;h3 id=&quot;a-quick-intro-to-jekyll&quot;&gt;A quick intro to Jekyll&lt;/h3&gt;

&lt;h4 id=&quot;what-is-jekyll&quot;&gt;What is Jekyll?&lt;/h4&gt;
&lt;p&gt;So, what is Jekyll? In the words of its creators, (or at least the creators of its website),&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Jekyll is a simple, blog-aware, static site generator perfect for personal, project, or organization sites.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;how-does-it-work&quot;&gt;How does it work?&lt;/h4&gt;
&lt;p&gt;Basically, the way it works is you take a preexisting theme (or make your own) that defines  a bunch of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;layouts&lt;/code&gt; (reformatted pages) and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;includes&lt;/code&gt; (snippets of code to include in pages). You then write your content mainly in markdown and specify which &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;layouts&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;included&lt;/code&gt; to use. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Jekyll&lt;/code&gt; then compiles your page into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;html&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;css&lt;/code&gt;that the server will serve.&lt;/p&gt;

&lt;h4 id=&quot;themes-did-you-say-themes&quot;&gt;Themes, did you say themes?&lt;/h4&gt;
&lt;p&gt;The great thing aout Jekyll is that it is pretty widely used, so there is no shortage of free, open source, and sexy themes. If you google &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll themes&lt;/code&gt;, you’ll get a bunch of pages of themes like &lt;a href=&quot;http://jekyllthemes.org/&quot;&gt;this one&lt;/a&gt;  and &lt;a href=&quot;http://themes.jekyllrc.org/&quot;&gt;this one&lt;/a&gt;  with  massive lists of themes. Check a few out, and then just follow the instructions on its webpage to use the theme of your dreams. Jekyll and most themes have pretty good documentation, so between the two of them, you should be pretty well set for building your site.&lt;/p&gt;

&lt;p&gt;For reference, the theme I used for this site is called &lt;a href=&quot;https://github.com/mmistakes/minimal-mistakes&quot;&gt;Minimal Mistakes&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Some words of wisdom!&lt;/strong&gt; In case the documentation does not make it clear, you do all of your development of your webpage on your computer and only push the final compiled result to the server.&lt;/p&gt;

&lt;h3 id=&quot;great-but-how-do-i-host-this&quot;&gt;Great, but how do I host this?&lt;/h3&gt;
&lt;p&gt;So, you just put together a sexy, sexy site, the most beautiful to ever grace the interwebs, but wait, how do you actually put this on the interwebs? You may have noticed that the bulk of the explanations for hosting your Jekyll page involve using Github Pages, but you’re here because you want to do this yourself.&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Github, we don’t need no stinkin Github! 
&lt;cite&gt; A famous movie or something &lt;/cite&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4 id=&quot;so-how-do-you-self-host&quot;&gt;So how do you self host?&lt;/h4&gt;
&lt;p&gt;It is actually pretty simple. You just have to push the contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_site&lt;/code&gt; to your root directory of your web server. The easiest way to do this is to do all of your development on your local machine, and then open your terminal inside the root directory of your Jekyll site (where you can see all of the files and directories starting with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_&lt;/code&gt;). Then, just run the following to copy the contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_site&lt;/code&gt; onto your server:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; jekyll build --destination _site &amp;amp;&amp;amp; scp -r ./_site/* username@ipofserver:site
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;If that gave you a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;directory does not exist&lt;/code&gt; error, run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkdir ~/site&lt;/code&gt; on your server first.&lt;/p&gt;

&lt;p&gt;After that, move these files to the root directory of your website (get rid of the demo file first) with:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo cp -rv site/* /var/www/example.com/public_html/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, fix the file permissions with:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo chgrp -R www-data /var/www/example.com/public_html
sudo chown -R www-data /var/www/example.com/public_html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And &lt;em&gt;presto&lt;/em&gt;, you are done!&lt;/p&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Some words of wisdom!&lt;/strong&gt; Whenever you want to do this again (say, when you update your site), make sure you delete the contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/site&lt;/code&gt; on your server before you rerun all of these steps starting with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scp&lt;/code&gt;.&lt;/p&gt;

&lt;p class=&quot;notice&quot;&gt;&lt;strong&gt;Some more advice to spare you the hair pulling!&lt;/strong&gt;  If after transferring your built site to the server you get weird looking pages and a bunch of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;404&lt;/code&gt; messages, make sure that you only copied the contents of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_site&lt;/code&gt; into your root web directory and not the directory itself.&lt;/p&gt;

&lt;p&gt;And so, it is  now time to part ways. Good luck on your journey to build your own website, and I hope this post helped you maintain a little but of sanity.&lt;/p&gt;

&lt;p&gt;I’m not quite sure what my next post will be right now, but I’m thinking some game theory is coming up…&lt;/p&gt;

&lt;p&gt;Until then, good luck and good day to you!&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;
    The more you find out about the world, the more opportunities there are to laugh at it.
  &lt;/p&gt;
  &lt;footer&gt;&lt;cite title=&quot;Bill Nye the Science Guy&quot;&gt;Bill Nye the Science Guy&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="website" /><category term="webdev" /><category term="tutorial" /><category term="this website" /><category term="jekyll" /><category term="linux" /><category term="server" /><summary type="html">On This Page Remember, remember the 5th of November? Remember, remember the 5th of November? Or, my previous post. Well, if you don’t, in that post I announced the creation of this site, outlined its purpose, and promised to put together an article on how I put together this website, mainly because it was a bit of a pain to find all of the information I needed to setup and self host Jekyll, and I think it would be helpful to have it all in one place for the sake of my sanity and possibly yours.</summary></entry><entry><title type="html">Guess what: A brand new website!</title><link href="https://ggarrettgrossman.ddns.net/website/new-site/" rel="alternate" type="text/html" title="Guess what: A brand new website!" /><published>2016-12-05T00:00:00+00:00</published><updated>2016-12-05T00:00:00+00:00</updated><id>https://ggarrettgrossman.ddns.net/website/new-site</id><content type="html" xml:base="https://ggarrettgrossman.ddns.net/website/new-site/">&lt;h2 id=&quot;guess-what&quot;&gt;Guess What?&lt;/h2&gt;
&lt;p&gt;I finally got around to building myself a website! Repeat, I finally got around to building myself a website.&lt;/p&gt;

&lt;h2 id=&quot;why-should-you-care&quot;&gt;Why Should You Care?&lt;/h2&gt;
&lt;p&gt;Honestly, you shouldn’t. It almost certainly will not have any life changing effect on your life (if it does, please let me know as that may qualify as a miracle and make me eligible for sainthood).&lt;/p&gt;

&lt;h2 id=&quot;the-true-meaning-of-it-all&quot;&gt;The True Meaning of it all…&lt;/h2&gt;
&lt;p&gt;42, no wait…
The true intention of the website is fourfold:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Actually put all of the eclectic devops and webdev skills I have acquired for various reasons  to use for me.&lt;/li&gt;
  &lt;li&gt;Provide a centralized place for me to put any random thoughts I may have, as well as any tips or tricks I have come across in my projects that I would rather not forget and that might be helpful for you, my dear reader.&lt;/li&gt;
  &lt;li&gt;Host a portfolio of the projects I have worked on.&lt;/li&gt;
  &lt;li&gt;Because it just seemed like fun to put together and self host a website.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;back-to-the-future&quot;&gt;Back to the Future!&lt;/h2&gt;
&lt;p&gt;Soon enough this website will have more then enough content to satiate the appetite of anyone, even those willing to read the musings of some random internet person, so please stick around and check back soon.&lt;/p&gt;

&lt;h2 id=&quot;spoilers&quot;&gt;Spoilers&lt;/h2&gt;
&lt;p&gt;Currently, I am planning on putting together my first article/tutorial on what else but the creation of this very website (hint: the day Debian works out of the box is the day that chickens will have teeth).&lt;/p&gt;

&lt;h2 id=&quot;bye&quot;&gt;Bye!&lt;/h2&gt;
&lt;p&gt;Until then, have a nice life, but first a random and wise quote from your favorite always smoking Frenchman.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;
    Man is the only creature that refuses to be what he is.
  &lt;/p&gt;
  &lt;footer&gt;&lt;cite title=&quot;Albert Camus&quot;&gt;Albert Camus&lt;/cite&gt;&lt;/footer&gt;
&lt;/blockquote&gt;</content><author><name>Grant Garrett-Grossman</name><email>grant.garrettgrossman@gmail.com</email></author><category term="website" /><category term="website" /><category term="webdev" /><category term="new stuff" /><summary type="html">Guess What? I finally got around to building myself a website! Repeat, I finally got around to building myself a website.</summary></entry></feed>