You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
54 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><generator uri="https://jekyllrb.com/" version="4.1.1">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml"/><link href="/" rel="alternate" type="text/html"/><updated>2020-12-14T11:19:49-07:00</updated><id>/feed.xml</id><entry><title type="html">Getting Pacaur Working on a Raspberry Pi 4 with Manjaro ARM or Arch Linux</title><link href="/2020/12/01/pacaur-rpi/" rel="alternate" type="text/html" title="Getting Pacaur Working on a Raspberry Pi 4 with Manjaro ARM or Arch Linux"/><published>2020-12-01T00:00:00-07:00</published><updated>2020-12-01T00:00:00-07:00</updated><id>/2020/12/01/pacaur-rpi</id><content type="html" xml:base="/2020/12/01/pacaur-rpi/">&lt;p&gt;I recently installed Manjaro ARM (based on Arch Linux ARM) on a Raspberry Pi 4. I used some standard commands to start to add the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pacaur&lt;/code&gt; package so I can easily retrieve &lt;a href=&quot;https://wiki.archlinux.org/index.php/Arch_User_Repository&quot;&gt;AUR packages&lt;/a&gt; without needing to do it manually. Unfortunately, there is a small problem with compiling this on ARM.&lt;/p&gt; &lt;h2 id=&quot;always_inline&quot;&gt;always_inline&lt;/h2&gt; &lt;p&gt;To setup the install for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pacaur&lt;/code&gt;, I first needed to download &lt;a href=&quot;https://aur.archlinux.org/packages/auracle-git&quot;&gt;auracle-git&lt;/a&gt; AUR package manually. I ran into an error when compiling this package.&lt;/p&gt; &lt;p&gt;But first, my setup:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; $ git clone https://aur.archlinux.org/auracle-git $ cd auracle-git $ makepkg -sri &lt;/pre&gt; &lt;p&gt;Around half way through compiling this project, I got this cryptic message telling me there was a “target specific option mismatch”…Whatever that means. The full error is below, hopefully that helps my chances on the search engines.&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; In file included from ../subprojects/abseil-cpp-20200225.2/absl/random/internal/randen_hwaes.cc:225: /usr/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/include/arm_neon.h: In function 'Vector128 {anonymous}::AesRound(const Vector128&amp;amp;, const Vector128&amp;amp;)': /usr/lib/gcc/aarch64-unknown-linux-gnu/9.3.0/include/arm_neon.h:12452:1: error: inlining failed in call to always_inline 'uint8x16_t vaesmcq_u8(uint8x16_t)': target specific option mismatch 12452 | vaesmcq_u8 (uint8x16_t data) &lt;/pre&gt; &lt;p&gt;Luckily, there is a very easy fix for this. The user redfish &lt;a href=&quot;https://aur.archlinux.org/packages/auracle-git#comment-762117&quot;&gt;helpfully pointed out&lt;/a&gt; on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;auracle-git&lt;/code&gt; package page that you need to add a special make option to your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/make.conf&lt;/code&gt; file to make this work.&lt;/p&gt; &lt;p&gt;His solution, as commented is like so:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;If you get this error when building for ARM aarch64:&lt;/p&gt; &lt;p&gt;(insert error message from before)&lt;/p&gt; &lt;p&gt;Then check that in /etc/makepkg.conf CFLAGS and CXXFLAGS have the +crypto suffix in -march flag, like -march=armv8-a+crypto (the base identifier may very depending on your hardware)&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;Basically, there is a file on Linux: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/makepkg.conf&lt;/code&gt; which tells your computer how to compile &lt;em&gt;all&lt;/em&gt; programs on the system. By default the Manjaro ARM (RPi4) edition has the following relevant lines in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;makepkg.conf&lt;/code&gt;.&lt;/p&gt; &lt;pre class=&quot;file&quot;&gt; CFLAGS=&quot;-march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt&quot; CXXFLAGS=&quot;-march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt&quot; &lt;/pre&gt; &lt;p&gt;What Mr. redfish is telling us is that we must add +crypto to the end of the -march compiler flag so that our compiler will know how to inline that pesky vaesmcq_u8 function.&lt;/p&gt; &lt;p&gt;So in the end, your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;makepkg.conf&lt;/code&gt;s relevant lines will look like so:&lt;/p&gt; &lt;pre class=&quot;file&quot;&gt; CFLAGS=&quot;-march=armv8-a+crypto -O2 -pipe -fstack-protector-strong -fno-plt&quot; CXXFLAGS=&quot;-march=armv8-a+crypto -O2 -pipe -fstack-protector-strong -fno-plt&quot; &lt;/pre&gt; &lt;h2 id=&quot;why&quot;&gt;Why?&lt;/h2&gt; &lt;p&gt;Redfish continues:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Build of abseil-cpp package works because it uses CMake which adds the correct -march flag regardless of makepkg.conf, whereas when abseil-cpp is build as a subproject within this package, it uses meson, which does not add the flag and thus fails with the above error.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;In other words, one of the dependencies pulled in with auracle is not compiling without this special compiler flag enabled.&lt;/p&gt; &lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt; &lt;p&gt;Thanks to redfish for posting this solution to the forums! Wouldve been quite the rabbit hole for me to figure out how to do that. In fact, it is very likely I would have never figured that one out.&lt;/p&gt; &lt;p&gt;After this issue is resolved, the installation of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pacaur&lt;/code&gt; goes as expected. Nice and easy! Pacuar will compile on any architecture so its smooth sailing from here.&lt;/p&gt; &lt;p&gt;Happy hacking!&lt;/p&gt;</content><author><name></name></author><summary type="html">I recently installed Manjaro ARM (based on Arch Linux ARM) on a Raspberry Pi 4. I used some standard commands to start to add the pacaur package so I can easily retrieve AUR packages without needing to do it manually. Unfortunately, there is a small problem with compiling this on ARM.</summary></entry><entry><title type="html">ZFS NAS Box, Part 2</title><link href="/2020/11/15/nas2/" rel="alternate" type="text/html" title="ZFS NAS Box, Part 2"/><published>2020-11-15T00:00:00-07:00</published><updated>2020-11-15T00:00:00-07:00</updated><id>/2020/11/15/nas2</id><content type="html" xml:base="/2020/11/15/nas2/">&lt;p&gt;Back in &lt;a href=&quot;/2020/04/12/nas1/&quot;&gt;part one of my NAS project&lt;/a&gt; I discussed how I wanted to set up my hardware. Today, I set up the NAS (almost).&lt;/p&gt; &lt;p&gt;There were some hiccup along the way, like learning that M.2 slots can disable some of your SATA ports or waiting a month for a host bus adapter to come in from China.&lt;/p&gt; &lt;h2 id=&quot;why-did-it-take-so-long&quot;&gt;Why Did It Take So Long&lt;/h2&gt; &lt;p&gt;So it turns out I was going to spend a lot more on this project than I originally anticipated. I ended up getting a server machine instead of a sleek NAS box. Here are some of the quick specs:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Standard ATX case by Thermaltake.&lt;/li&gt; &lt;li&gt;LSI 9211-8i.&lt;/li&gt; &lt;li&gt;The cheapest HDMI graphics card I could find on Kijiji.&lt;/li&gt; &lt;li&gt;6x 3TB Segate HDDs.&lt;/li&gt; &lt;li&gt;1x 250G Kingston SSD.&lt;/li&gt; &lt;li&gt;AMD Ryzen 5 3600.&lt;/li&gt; &lt;li&gt;MSI B450 Gaming Plus Max.&lt;/li&gt; &lt;li&gt;2x 8GB FlareX 3200Mhz RAM.&lt;/li&gt; &lt;li&gt;1x 16GB Kingston 3200Mhz RAM.&lt;/li&gt; &lt;/ul&gt; &lt;h2 id=&quot;zfs&quot;&gt;ZFS&lt;/h2&gt; &lt;p&gt;This is how I decided to configure my storage pools. In hindsight, this was not the best choice for upgrading. I may change it in the future to a 0+1 setup, but it works for now.&lt;/p&gt; &lt;p&gt;I have 5x 3TB in a RAIDZ2 with one drive not attached for redundancys sake. How does one setup a ZFS pool. Check this out:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; # zpool create poolname raidz2 \ /dev/by-id/blahblahblah1 \ /dev/by-id/blahblahblah2 \ /dev/by-id/blahblahblah3 \ /dev/by-id/blahblahblah4 \ /dev/by-id/blahblahblah5 &lt;/pre&gt; &lt;p&gt;And zippidy-doo! Weve got a ZFS pool! We can check its status with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;zpool status&lt;/code&gt;.&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; $ zfs status pool: raid state: ONLINE scan: scrub in progress since Wed Nov 18 18:41:41 2020 1.84T scanned at 8.51G/s, 121G issued at 562M/s, 1.84T total 0B repaired, 6.45% done, 0 days 00:53:25 to go config: NAME STATE READ WRITE CKSUM raid ONLINE 0 0 0 raidz2-0 ONLINE 0 0 0 ata-HGST_HUS724030ALA640_PN2234P8JTNMYY ONLINE 0 0 0 ata-HGST_HUS724030ALA640_PN2234P8JVSXTY ONLINE 0 0 0 ata-HGST_HUS724030ALA640_PN2234P8JXAS8Y ONLINE 0 0 0 ata-HGST_HUS724030ALA640_PN2234P8JXBARY ONLINE 0 0 0 ata-HGST_HUS724030ALA640_PN2234P8JXP77Y ONLINE 0 0 0 errors: No known data errors &lt;/pre&gt; &lt;p&gt;I had run a scrub right before this, so theres some extra detail in that. This is really fun! I will be doing more home storage projects soon. Perhaps Raspberry Pi NAS using all 4 USB ports to load SATA drives on it. Now that would be fun!&lt;/p&gt; &lt;h2 id=&quot;so-i-kinda-have-a-nas-now&quot;&gt;So I Kinda Have A NAS Now…?&lt;/h2&gt; &lt;p&gt;So right now I can only copy files with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rsync&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scp&lt;/code&gt; and moving data via a physical drive. The one major disadvantage this has is speed.&lt;/p&gt; &lt;p&gt;Due to this machine being connected directly outside my network and pulling DHCP like a normal router would, I need to send my data through the WAN connection to get my files to it. This is rather unfortunate as my upload speed is capped at 20 megabits per second, despite my upload being in the 300+ range.&lt;/p&gt; &lt;p&gt;Part 3 will involve a LAN card so I can connect both to the DHCP server of my ISP and my local router. This way my transfer speeds should be in the range of 1 gigabit per second. This will make my life much easier, at least on the local network.&lt;/p&gt; &lt;h2 id=&quot;fun-fact&quot;&gt;Fun Fact!&lt;/h2&gt; &lt;p&gt;Do not try to use the M.2 slot on a consumer motherboard where you are also using all the SATA ports. On my consumer gaming motherboard, the SATA ports next to the M.2 slot became &lt;em&gt;disabled&lt;/em&gt; when I attached the M.2 SSD. I found this out form my motherboard documentation, which I read only after a week of thinking my motherboard itself was defective, and sending it in for repairs that did absolutely nothing.&lt;/p&gt; &lt;h2 id=&quot;thoughts&quot;&gt;Thoughts&lt;/h2&gt; &lt;p&gt;I like having all this space. I plan on using it up pretty fast, so Im already looking at how to expand. Hopefully that gives a decent overview of how I set up my drives.&lt;/p&gt; &lt;p&gt;Happy hacking!&lt;/p&gt;</content><author><name></name></author><summary type="html">Back in part one of my NAS project I discussed how I wanted to set up my hardware. Today, I set up the NAS (almost).</summary></entry><entry><title type="html">Curiosity</title><link href="/2020/10/26/curiosity/" rel="alternate" type="text/html" title="Curiosity"/><published>2020-10-26T00:00:00-06:00</published><updated>2020-10-26T00:00:00-06:00</updated><id>/2020/10/26/curiosity</id><content type="html" xml:base="/2020/10/26/curiosity/">&lt;p&gt;Curiosity is fundamental to a deep understanding of any subject. Masters, Ph.Ds, and other fancy name suffixes will never help you if you dont have the spirit of curiosity burning inside of you.&lt;/p&gt; &lt;p&gt;I was speaking to someone from a journalism major at my school when the subject of hacking arose. I expected her to know nothing about it, being a journalism student and all, but surprisingly she had something to say about it:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;“The best hackers are the ones who are curious.”&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;That struck a cord with me. It seems to me she has nailed down the difference between the students who care about grades, and those who want to learn. These are not necessarily mutually exclusive, but in my experience they often are due to the way education is structured.&lt;/p&gt; &lt;h2 id=&quot;my-anecdote&quot;&gt;My Anecdote&lt;/h2&gt; &lt;p&gt;In my second semester at SAIT Polytechnic, I took a class entitled &lt;em&gt;Emerging Trends In Technology&lt;/em&gt;. This class was probably the best class I have ever taken. We had to combine two things:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Hard skills&lt;/strong&gt;: learning a new hard skill like Angular, Django, or GPG encryption.&lt;/li&gt; &lt;li&gt;&lt;strong&gt;Soft skills&lt;/strong&gt;: public speaking and presentation of our ideas.&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;Soft skills are not usually my area, but I can do public speaking. I grew up quite religious, so public speaking was drilled into me young. I liked to go off script and talk about interesting things I found along the way to the actual point. My creativity was not usually encouraged. That said, going off script is useful when teaching and presenting ideas; it gives a natural air to your breath and an unquestionable confidence in your speech.&lt;/p&gt; &lt;p&gt;This is how we learn: in relationships. Try explaining ancient Japanese history to a computer science major, or UNIX sockets to an English major and youll see what I mean. If there is nothing for us to connect the knowledge to, it dissipates.&lt;/p&gt; &lt;p&gt;So why did I do so well in this class?&lt;/p&gt; &lt;p&gt;Our task for the semester was as follows:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Learn a new subject (any &lt;em&gt;emerging trend in technology&lt;/em&gt;) which you find fascinating.&lt;/li&gt; &lt;li&gt;Give a one minute introduction by week three.&lt;/li&gt; &lt;li&gt;Give a 10 minute non-technical overview by week 8.&lt;/li&gt; &lt;li&gt;Give a 20 minute technical explaination and demo by week 13.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;This is the only course I have ever taken which lets students imagination run wild. Their presentation, their rules. They treated the students like adults who know what they are doing. What happened? Everyone stopped coming because “Oh no! Presentations!”?&lt;/p&gt; &lt;p&gt;No, exactly the opposite. There was never more than one student missing. Every single presentation was at least moderately interesting, and most students were excited to come to that class. You could see it in their faces, the way they carried themselves. Every student picked something unique to their tastes, leaving every student more educated than before.&lt;/p&gt; &lt;p&gt;This class, unlike many others, encouraged the curiosity of the students. It rewarded those who had unique interests and an ability to sell others on their ideas.&lt;/p&gt; &lt;p&gt;The curiosity and the grades were one.&lt;/p&gt; &lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt; &lt;p&gt;Although its nice to have a course where these goals align here and there, anyone who has been to collage or university can tell you that is far from the norm.&lt;/p&gt; &lt;p&gt;On the other hand, I never would have started this site if it wasnt for that class alone. So I thank you, Kitty Wong, for getting me started running my own “research blog” (?)&lt;/p&gt;</content><author><name></name></author><summary type="html">Curiosity is fundamental to a deep understanding of any subject. Masters, Ph.Ds, and other fancy name suffixes will never help you if you dont have the spirit of curiosity burning inside of you.</summary></entry><entry><title type="html">Minesweeper Bomb Generation And Tile Revealing</title><link href="/2020/09/12/minesweeper/" rel="alternate" type="text/html" title="Minesweeper Bomb Generation And Tile Revealing"/><published>2020-09-12T00:00:00-06:00</published><updated>2020-09-12T00:00:00-06:00</updated><id>/2020/09/12/minesweeper</id><content type="html" xml:base="/2020/09/12/minesweeper/">&lt;p&gt;When I was creating a little Minesweeper game, I got confused at some points. My bomb generation didnt look quite right, and I for sure didnt quite get the whole cascading tile reveal thing. With a bit of internet research, I found what I was looking for. Ill explain it all in one place for my own research purposes.&lt;/p&gt; &lt;h2 id=&quot;bomb-generation&quot;&gt;Bomb Generation&lt;/h2&gt; &lt;p&gt;When I started this project I attempted to use a random bomb generator. By this I mean on each square, before it gets generated, give it a one in 15 change of being a bomb. Personally, Im not sure why this never looked right. Something about the layout of the bombs did not mimic the classic Minesweeper game.&lt;/p&gt; &lt;p&gt;After looking at some open source Minesweeper examples, I started to get the idea. I wrote some mathematical statements describing the generation of bombs and how to get their x,y position from an appropriate number. For those non-mathy people, dont leave just yet; there will be code equivalents to the math.&lt;/p&gt; &lt;p&gt;W and H are the width and height of the board respectively.&lt;/p&gt; &lt;p&gt;&lt;span class=&quot;katex-display&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mn mathvariant=&quot;italic&quot;&gt;0&lt;/mn&gt;&lt;mo&gt;&lt;/mo&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mo&gt;&lt;/mo&gt;&lt;mtext&gt;W&lt;/mtext&gt;&lt;mo&gt;×&lt;/mo&gt;&lt;mtext&gt;H&lt;/mtext&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt; \it 0 \leq r \leq \text W \times \text H &lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.8193em;vertical-align:-0.13597em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathit&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathit&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord text&quot;&gt;&lt;span class=&quot;mord&quot;&gt;W&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222222222222222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;×&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222222222222222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord text&quot;&gt;&lt;span class=&quot;mord&quot;&gt;H&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;katex-display&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;x&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mtext&gt;&lt;/mtext&gt;&lt;mo lspace=&quot;0.22em&quot; rspace=&quot;0.22em&quot;&gt;&lt;mrow&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;m&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;o&lt;/mi&gt;&lt;mi mathvariant=&quot;normal&quot;&gt;d&lt;/mi&gt;&lt;/mrow&gt;&lt;/mo&gt;&lt;mtext&gt;&lt;/mtext&gt;&lt;mtext&gt;W&lt;/mtext&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt; \it x = r \bmod \text W &lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:0.69444em;vertical-align:0em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathit&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord mathit&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222222222222222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.05555555555555555em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mbin&quot;&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathrm&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;mord mathrm&quot;&gt;o&lt;/span&gt;&lt;span class=&quot;mord mathrm&quot;&gt;d&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2222222222222222em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.05555555555555555em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord text&quot;&gt;&lt;span class=&quot;mord&quot;&gt;W&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;katex-display&quot;&gt;&lt;span class=&quot;katex&quot;&gt;&lt;span class=&quot;katex-mathml&quot;&gt;&lt;math xmlns=&quot;http://www.w3.org/1998/Math/MathML&quot;&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi&gt;y&lt;/mi&gt;&lt;mo&gt;=&lt;/mo&gt;&lt;mrow&gt;&lt;mo fence=&quot;true&quot;&gt;&lt;/mo&gt;&lt;mfrac&gt;&lt;mi&gt;r&lt;/mi&gt;&lt;mtext&gt;H&lt;/mtext&gt;&lt;/mfrac&gt;&lt;mo fence=&quot;true&quot;&gt;&lt;/mo&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding=&quot;application/x-tex&quot;&gt; \it y = \left\lfloor\frac{r}{\text H}\right\rfloor &lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;span class=&quot;katex-html&quot; aria-hidden=&quot;true&quot;&gt;&lt;span class=&quot;base&quot;&gt;&lt;span class=&quot;strut&quot; style=&quot;height:1.8359999999999999em;vertical-align:-0.686em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathit&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mrel&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mspace&quot; style=&quot;margin-right:0.2777777777777778em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;minner&quot;&gt;&lt;span class=&quot;mopen delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size2&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mopen nulldelimiter&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mfrac&quot;&gt;&lt;span class=&quot;vlist-t vlist-t2&quot;&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:1.10756em;&quot;&gt;&lt;span style=&quot;top:-2.314em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord text&quot;&gt;&lt;span class=&quot;mord&quot;&gt;H&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.23em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;frac-line&quot; style=&quot;border-bottom-width:0.04em;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;top:-3.677em;&quot;&gt;&lt;span class=&quot;pstrut&quot; style=&quot;height:3em;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;mord&quot;&gt;&lt;span class=&quot;mord mathit&quot;&gt;r&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-s&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;vlist-r&quot;&gt;&lt;span class=&quot;vlist&quot; style=&quot;height:0.686em;&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose nulldelimiter&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;mclose delimcenter&quot; style=&quot;top:0em;&quot;&gt;&lt;span class=&quot;delimsizing size2&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;The code equivalent to this in Python is below:&lt;/p&gt; &lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;random&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# r &amp;lt;= 0 &amp;lt;= W*H &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;randint&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;W&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;H&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# x = r mod W &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;W&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# y = floor(r/H); note the special syntax python has for this operation &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;r&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;//&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;H&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;So thats that, we can put this in a big ol for loop and generate an arbitrary &lt;em&gt;n&lt;/em&gt; number of bombs given a width and height of a Minesweeper board.&lt;/p&gt; &lt;h2 id=&quot;cascading-tile-revealing&quot;&gt;Cascading Tile Revealing&lt;/h2&gt; &lt;p&gt;This one is hard to describe; I am adapting this from &lt;a href=&quot;https://leetcode.com/problems/minesweeper/&quot;&gt;leetcode.com&lt;/a&gt;. Whenever a player clicks a tile, the following logic should be used:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;If a mine is revealed, the game is over. (obviously)&lt;/li&gt; &lt;li&gt;If a tile with &lt;em&gt;no&lt;/em&gt; adjacent mines is revealed, recursively reveal all eight adjacent tiles.&lt;/li&gt; &lt;li&gt;If a tile with one or more adjacent mines is revealed, display the number of mines next to it.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;Here is the code in Python for this algorithm.&lt;/p&gt; &lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;reveal_square&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;alread_revealed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# if already checked &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;already_revealed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# if it's a bomb &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'B'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;you_lose&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# if the bomb number is more than 0 &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;already_revealed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;nx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ny&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# from -1 to 1 &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;xd&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;yd&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# skip if it is this the center tile &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;and&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# recursively check the adjacent square &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reveal&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;board&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;already_revealed&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;already_revealed&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt; &lt;p&gt;This has no checks for valid squares, but its the general idea. This function returns an array of tile coordinates which should be revealed.&lt;/p&gt; &lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt; &lt;p&gt;I wrote this because in the first place because I was writing my own Minesweeper game. I hope that this helps you with getting the general idea of a Minesweeper game. The completed version of this game is available on my &lt;a href=&quot;https://lamegames.tait.tech/&quot;&gt;lamegames&lt;/a&gt; site. Let me know what you think!&lt;/p&gt; &lt;p&gt;Happy hacking!&lt;/p&gt;</content><author><name></name></author><summary type="html">When I was creating a little Minesweeper game, I got confused at some points. My bomb generation didnt look quite right, and I for sure didnt quite get the whole cascading tile reveal thing. With a bit of internet research, I found what I was looking for. Ill explain it all in one place for my own research purposes.</summary></entry><entry><title type="html">lamegames.tait.tech</title><link href="/2020/09/09/lamegames/" rel="alternate" type="text/html" title="lamegames.tait.tech"/><published>2020-09-09T00:00:00-06:00</published><updated>2020-09-09T00:00:00-06:00</updated><id>/2020/09/09/lamegames</id><content type="html" xml:base="/2020/09/09/lamegames/">&lt;p&gt;This is an announcement for a new project of mine: &lt;a href=&quot;https://lamegames.tait.tech&quot;&gt;lamegames.tait.tech&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;This is something Im really excited to work on!&lt;/p&gt; &lt;p&gt;Right now, Ive just got a rock-paper-scissors game. A chat function, and a few simple card games to come.&lt;/p&gt; &lt;p&gt;Check out the repository on my &lt;a href=&quot;https://github.com/TTWNO/lamegames.io&quot;&gt;Github&lt;/a&gt;.&lt;/p&gt;</content><author><name></name></author><summary type="html">This is an announcement for a new project of mine: lamegames.tait.tech.</summary></entry><entry><title type="html">How to Solve The Django Deployment Puzzle</title><link href="/2020/08/18/django-deployment/" rel="alternate" type="text/html" title="How to Solve The Django Deployment Puzzle"/><published>2020-08-18T00:00:00-06:00</published><updated>2020-08-18T00:00:00-06:00</updated><id>/2020/08/18/django-deployment</id><content type="html" xml:base="/2020/08/18/django-deployment/">&lt;p&gt;A few days ago I had a Django project I wanted to put on a real server. This project is still in its infancy, but I thought it would be nice to put it on my resume and show my friends. Little did I know the headache coming my way. Here are some tips to help you not make the same mistakes as me.&lt;/p&gt; &lt;h3 id=&quot;asgi-servers&quot;&gt;ASGI Servers&lt;/h3&gt; &lt;p&gt;Because my project used the ASGI (Asynchronous webServer Gateway Interface), I needed to find a good production ASGI server to handle all the incoming requests. The best thing I found was &lt;a href=&quot;http://www.uvicorn.org/&quot;&gt;uvicorn&lt;/a&gt;. It focuses on speed, which is a priority, especially when using the ASGI protocol.&lt;/p&gt; &lt;p&gt;To run uvicorn on the command line for testing purposes, use something like the following:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; $ uvicorn --reload myapp.asgi:application &lt;/pre&gt; &lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--reload&lt;/code&gt; option says to reload the server if any of the files get updated. This is not recommended in production. Sadly, I thought this meant I would need to do a hard shutdown of the server process every time I wanted to update. This turned out to not be the case.&lt;/p&gt; &lt;h3 id=&quot;workload-managers&quot;&gt;Workload Managers&lt;/h3&gt; &lt;p&gt;There is another equine-named program called &lt;a href=&quot;https://gunicorn.org/&quot;&gt;gunicorn&lt;/a&gt; which can hold a number of processes under its control. An interesting feature of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gunicorn&lt;/code&gt; is that it will gracefully switch from an old to a new deployment, replacing the subprocesses one-by-one and eventually having only the new deployment active on all subprocesses. The greatest part? Zero down time. The server keeps any old processes open if there is communication with them, then shift and new connections to the new deployment. This was a very cool feature I wanted to take advantage of.&lt;/p&gt; &lt;p&gt;“Now hold on!” you might protest. “gunicorn is a WSGI server!” … oh you got me there! Yes, thats right, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gunicorn&lt;/code&gt; is paired with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;uvicorn&lt;/code&gt; to serve my files.&lt;/p&gt; &lt;h3 id=&quot;systemd&quot;&gt;systemd&lt;/h3&gt; &lt;p&gt;Love it or hate it, the majority of Linux distributions use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;systemd&lt;/code&gt; init system. I decided it would be very convenient to have a .service file for my Django application to run automatically at boot. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Systemd&lt;/code&gt; allows me to do this with a file like the following one I stored in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/lib/systemd/system/lamegames.service&lt;/code&gt;.&lt;/p&gt; &lt;pre class=&quot;file&quot;&gt; [Unit] Description=Gunicorn/Uvicorn (lamegames.io) [Service] WorkingDirectory=/home/lame/lamegames.io Type=simple RemainAfterExit=yes ExecStart=/home/lame/lamegames.io/env/bin/gunicorn lamegames.asgi:application -w 2 -k uvicorn.workers.UvicornWorker ExecStop=/bin/kill -HUP $MAINPID Restart=always [Install] WantedBy=multi-user.target &lt;/pre&gt; &lt;h3 id=&quot;nginx&quot;&gt;nginx&lt;/h3&gt; &lt;p&gt;NGINX (pronounced engine-X) is a performance web server designed for speed and simplicity. For the front facing side of the site, I do need a production web server like nginx. Gunicorn simply doesnt need all the features that nginx provides, but I do. To configure my nginx installation, I used the following few directives to:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Redirect most traffic towards the gunicorn server.&lt;/li&gt; &lt;li&gt;Redirect statically served files (CSS, JS, images) to the directory specified in the STATIC_ROOT variable of my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;settings.py&lt;/code&gt; file.&lt;/li&gt; &lt;li&gt;Use TLS to enable https://&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;Serving the static files from nginx as opposed to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gunicorn&lt;/code&gt; server is necessary. Gunicorn and other production A/WSGI web server will not set the proper MIME type over TLS. This will cause your browser to not load the Javascript/CSS.&lt;/p&gt; &lt;p&gt;This is the important part of my nginx config.&lt;/p&gt; &lt;pre class=&quot;file&quot;&gt; server { location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # these two lines ensure that WebSocket, and HTTP2 connection are forwarded correctly proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection &quot;Upgrade&quot;; proxy_redirect off; proxy_buffering off; # this forwards all traffic to the local server on port 8000 proxy_pass http://localhost:8000; } # This forwards all static requests to Django's STATIC_ROOT set in settings.py; it is generated using the collectstatic command. location /static { autoindex on; alias /home/lame/lamegames.io/static_generated; } } &lt;/pre&gt; &lt;h3 id=&quot;setup&quot;&gt;Setup&lt;/h3&gt; &lt;p&gt;After all that, I was able to do the following:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; # systemctl enable lamegames &lt;/pre&gt; &lt;p&gt;This enabled my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gunicorn&lt;/code&gt; server to run once the server started. NGINX is that way be default.&lt;/p&gt; &lt;p&gt;And tada! You now have a working Django project on a production server!&lt;/p&gt; &lt;h4 id=&quot;notes&quot;&gt;Notes&lt;/h4&gt; &lt;ul&gt; &lt;li&gt;If using ws:// websockets, change them to wss:// for secure web sockets.&lt;/li&gt; &lt;li&gt;Make sure to use channels.routing.get_default_application() instead of django.get_asgi_application() if yourre wanting to use channels/redis WebSockets.&lt;/li&gt; &lt;/ul&gt;</content><author><name></name></author><summary type="html">A few days ago I had a Django project I wanted to put on a real server. This project is still in its infancy, but I thought it would be nice to put it on my resume and show my friends. Little did I know the headache coming my way. Here are some tips to help you not make the same mistakes as me.</summary></entry><entry><title type="html">BSD Journey, Part 1</title><link href="/2020/08/15/openbsd1/" rel="alternate" type="text/html" title="BSD Journey, Part 1"/><published>2020-08-15T00:00:00-06:00</published><updated>2020-08-15T00:00:00-06:00</updated><id>/2020/08/15/openbsd1</id><content type="html" xml:base="/2020/08/15/openbsd1/">&lt;p&gt;As Linux becomes controlled by corporate sponsors and becomes more full of proprietary blobs, drivers, and even closed-source software like Steam, One may wonder if there are other options out there. For me, somebody that is intensely interested in security, there is one option: OpenBSD.&lt;/p&gt; &lt;p&gt;Now, my interest in OpenBSD has been going on for a long time. I started poking around for Linux alternatives way back a few years ago when Linus Torvalds decided to leave after he got in trouble for some &lt;a href=&quot;https://arstechnica.com/information-technology/2013/07/linus-torvalds-defends-his-right-to-shame-linux-kernel-developers/&quot;&gt;unprofessional behaviour&lt;/a&gt;. That said, Linus did come back to Linux development, but I knew that his abrasive style is what brought good code to the Linux kernel. I also knew that his ability to be critical would be hurt by the new &lt;a href=&quot;https://itsfoss.com/linux-code-of-conduct/&quot;&gt;code of conduct&lt;/a&gt;. It would become a tool for the SJW types to hammer on Linus for being a “white male, et al.”; It would become a tool for the easily offended to use to get their dumb code into Linux; It would become a tool for the corporatization, the HR-ification of Linux. Frankly, this does not interest me.&lt;/p&gt; &lt;p&gt;Now Im sure that OpenBSD has its own internal policies that I disagree with. That said, Theo De Raadt is still at least known for calling Firefox an “amorphous peace of garbage” due to its lack of privilege separation. And, in their &lt;a href=&quot;https://openbsd.org/goals.html&quot;&gt;project goals&lt;/a&gt; page, they specifically mention:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Be as politics-free as possible; solutions should be decided on the basis of technical merit.&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;Now thats something I can get behind! Bet you thats not in the Linux COC?&lt;/p&gt; &lt;p&gt;He also went to university in my hometown, so thats pretty cool! I can support a local madman who thinks he can make a better operating system than all those corporations. Maybe he was right, maybe not. What I know is I am excited to find out!&lt;/p&gt; &lt;p&gt;Wish my luck on my OpenBSD journey. I will post updates here along the way.&lt;/p&gt; &lt;p&gt;Happy hacking!&lt;/p&gt;</content><author><name></name></author><summary type="html">As Linux becomes controlled by corporate sponsors and becomes more full of proprietary blobs, drivers, and even closed-source software like Steam, One may wonder if there are other options out there. For me, somebody that is intensely interested in security, there is one option: OpenBSD.</summary></entry><entry><title type="html">Know How Your Representative Votes In Parliament</title><link href="/2020/07/30/canadian-parliament/" rel="alternate" type="text/html" title="Know How Your Representative Votes In Parliament"/><published>2020-07-30T00:00:00-06:00</published><updated>2020-07-30T00:00:00-06:00</updated><id>/2020/07/30/canadian-parliament</id><content type="html" xml:base="/2020/07/30/canadian-parliament/">&lt;p&gt;As an advocate for openness, I had an idea to make a project out of the government of Canadas &lt;a href=&quot;https://open.canada.ca/en/open-data&quot;&gt;Open Data&lt;/a&gt; initiative to take a look at how my local MP voted on various pieces of legislation. It turns out though that this was not necessary due to how easy it was to find this information on the governments own website. In this article, I will explain how you can do the same.&lt;/p&gt; &lt;h3 id=&quot;1-find-your-representative&quot;&gt;1. Find Your Representative&lt;/h3&gt; &lt;p&gt;The first step in this process is to find who your representative is. To do so, go to the governments own website &lt;a href=&quot;https://www.ourcommons.ca/Members/en&quot;&gt;ourcommons.cas search tool&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Simply type in your postal code in the search box to find out who your MP is.&lt;/p&gt; &lt;h3 id=&quot;2-their-voting-record&quot;&gt;2. Their Voting Record&lt;/h3&gt; &lt;p&gt;Every MPs voting record is public knowledge, and it is available nice and simple in a table on that MPs page. For example, this is a link to &lt;a href=&quot;https://www.ourcommons.ca/Members/en/pierre-poilievre(25524)/votes&quot;&gt;Pierre Poilievres voting record&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;To find your MPs voting record, do step one, then: After the &lt;strong&gt;Overview&lt;/strong&gt;, and &lt;strong&gt;Seat in The House&lt;/strong&gt; sections, there are three tabs, &lt;strong&gt;Roles&lt;/strong&gt;, &lt;strong&gt;Work&lt;/strong&gt;, and &lt;strong&gt;Contact&lt;/strong&gt;. Click on work. At the bottom of that tab is a link which says &lt;strong&gt;Chamber Votes&lt;/strong&gt;. This will open a small window with some recent votes by this politician. If you want to see all their votes, there is a button at the bottom named &lt;strong&gt;All Votes by This Member&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;Tada! You can now keep your local MP accountable for anything you do or do not support.&lt;/p&gt; &lt;h3 id=&quot;3-bill-details&quot;&gt;3. Bill Details&lt;/h3&gt; &lt;p&gt;If you want to get into the nitty gritty, once you open a specific bill, you can actually find out the status of said bill, or read the actual text by clicking the &lt;strong&gt;View this Bill on LEGISinfo&lt;/strong&gt; button.&lt;/p&gt; &lt;p&gt;Both the status of the bill, and a link to a PDF document containing the bilingual text of the bill are visible in the main body of the page.&lt;/p&gt; &lt;h4 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h4&gt; &lt;p&gt;I thought this was pretty cool! It was &lt;em&gt;way&lt;/em&gt; simpler than I thought it would be.&lt;/p&gt; &lt;p&gt;Thanks, Canada!&lt;/p&gt;</content><author><name></name></author><summary type="html">As an advocate for openness, I had an idea to make a project out of the government of Canadas Open Data initiative to take a look at how my local MP voted on various pieces of legislation. It turns out though that this was not necessary due to how easy it was to find this information on the governments own website. In this article, I will explain how you can do the same.</summary></entry><entry><title type="html">Installing MultiCraft on Gentoo Linux</title><link href="/2020/07/19/multicraft-php-gentoo/" rel="alternate" type="text/html" title="Installing MultiCraft on Gentoo Linux"/><published>2020-07-19T00:00:00-06:00</published><updated>2020-07-19T00:00:00-06:00</updated><id>/2020/07/19/multicraft-php-gentoo</id><content type="html" xml:base="/2020/07/19/multicraft-php-gentoo/">&lt;p&gt;In a very odd combination of requirements, I needed to install &lt;a href=&quot;https://multicraft.org&quot;&gt;MultiCraft&lt;/a&gt; on a Gentoo Linux system. The PHP &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USE&lt;/code&gt; flags are important so you dont have to recompile it three times like I did.&lt;/p&gt; &lt;p&gt;Here are some useful tips I came across:&lt;/p&gt; &lt;h3 id=&quot;php-use-flags&quot;&gt;PHP &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USE&lt;/code&gt; flags&lt;/h3&gt; &lt;p&gt;In &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/portage/package.use/php&lt;/code&gt; I placed the following line:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; dev-lang/php cgi mysql mysqli fpm pdo gd truetype &lt;/pre&gt; &lt;p&gt;This should give you enough for a mysql backended MultiCraft installation. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cgi&lt;/code&gt; option may not be required as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fpm&lt;/code&gt; stands for &lt;em&gt;FastCGI Process Managment&lt;/em&gt;. I dont know for sure though.&lt;/p&gt; &lt;h3 id=&quot;paper&quot;&gt;Paper&lt;/h3&gt; &lt;p&gt;This will grab the latest version of the Paper jar file using &lt;a href=&quot;https://yivesmirror.com&quot;&gt;YivesMirror&lt;/a&gt;. Im not sure how reputable it is, but my buddy who works with this stuff more often than me seemed to recognize it.&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; ## See the default craftbukkit.jar.conf for a detailed documentation of the ## format of this file. [config] name = Paper 1.16.1 Latest source = https://yivesmirror.com/files/paper/Paper-1.16.1-latest.jar category = Mods [encoding] #encode = system #decode = system #fileEncoding = latin-1 [start] command = &quot;{JAVA}&quot; -Xmx{MAX_MEMORY}M -Xms{START_MEMORY}M -XX:MaxPermSize=128M -Djline.terminal=jline.UnsupportedTerminal -jar &quot;{JAR}&quot; nogui &lt;/pre&gt; &lt;h3 id=&quot;other-tips&quot;&gt;Other Tips&lt;/h3&gt; &lt;p&gt;Do not use the option to setup a separate user for each server. This completely stalled any work getting done with a ton of permission denied errors.&lt;/p&gt; &lt;h4 id=&quot;security&quot;&gt;Security&lt;/h4&gt; &lt;p&gt;If the panel is in the root directory of your NGINX web server, use the following in your server block to deny access to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/protected&lt;/code&gt; directory.&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; location /protected { deny all; return 404; } &lt;/pre&gt; &lt;h5 id=&quot;mysql&quot;&gt;MySQL&lt;/h5&gt; &lt;p&gt;It is always good practice to separate privileges. The MultiCraft daemon should have one SQL login, with one database allocated to it. The MultiCraft panel should have a separate SQL login, with a separate database allocated to it.&lt;/p&gt; &lt;p&gt;You can do this with the following commands in your MySQL prompt:&lt;/p&gt; &lt;pre class=&quot;terminal&quot;&gt; sql&amp;gt; CREATE DATABASE multicraft_daemon_database; Query OK, 0 rows affected (0.01 sec) sql&amp;gt; CREATE DATABASE multicraft_panel_database; Query OK, 0 rows affected (0.01 sec) sql&amp;gt; CREATE USER 'muilticraft_daemon'@'localhost' IDENTIFIED BY 'strong password here'; Query OK, 0 rows affected (0.01 sec) sql&amp;gt; CREATE USER 'multicraft_panel'@'localhost' IDENTIFIED BY 'different strong password here'; Query OK, 0 rows affected (0.01 sec) sql&amp;gt; GRANT ALL PRIVILEGES ON multicraft_daemon_database . * TO 'multicraft_daemon'@'localhost'; Query OK, 0 rows affected (0.01 sec) sql&amp;gt; GRANT ALL PRIVILEGES ON multicraft_panel_database . * TO 'mutlicraft_panel'@'localhost'; Query OK, 0 rows affected (0.01 sec) &lt;/pre&gt; &lt;p&gt;During setup, make sure the proper credentials are used for each step. Database 1 is the panel database. Database 2 is the daemon database.&lt;/p&gt; &lt;p&gt;Happy hacking :)&lt;/p&gt;</content><author><name></name></author><summary type="html">In a very odd combination of requirements, I needed to install MultiCraft on a Gentoo Linux system. The PHP USE flags are important so you dont have to recompile it three times like I did.</summary></entry><entry><title type="html">Independence</title><link href="/2020/07/12/independence/" rel="alternate" type="text/html" title="Independence"/><published>2020-07-12T00:00:00-06:00</published><updated>2020-07-12T00:00:00-06:00</updated><id>/2020/07/12/independence</id><content type="html" xml:base="/2020/07/12/independence/">&lt;blockquote&gt; &lt;p&gt;“When given a choice between independence and dependence, always choose independence; you will never regret that choice!”—Luke Smith&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;Whatever you may believe about the YouTube personality Luke Smith, the quote above summarizes a core principle of mine. Much like many people have religious principles, I have &lt;em&gt;Independence&lt;/em&gt;.&lt;/p&gt; &lt;p&gt;My choice to use Linux as my primary operating system, host my own website, own my own domain name—all of these are directly related to this core principle of independence.&lt;/p&gt; &lt;p&gt;I never want a man, or a company to have too much power over my life. Just like I would not trust just any person to be able to read my emails, know where I live, where I am going, who are my friends, what do I believe; in the same way, I do not trust a company with that same information.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;“If you want to find out what a man is to the bottom, give him power. Any man can stand adversity — only a great man can stand prosperity.”—Robert Ingersoll&lt;/p&gt; &lt;/blockquote&gt; &lt;p&gt;Take control of your own digital life:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Own your own domain.&lt;/li&gt; &lt;li&gt;Hookup an email and a website to that.&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;Thats it!&lt;/p&gt; &lt;p&gt;Without this, any of your internet privileges can be revoked at any time by Google, Facebook, YouTube, Twitter, or even an angry Twitter Mob. Maybe because they hate your skin colour, maybe they hate your religious/political views, or maybe you got caught on a technicality.&lt;/p&gt; &lt;p&gt;If you own your own domain, however:&lt;/p&gt; &lt;p&gt;Your email provider goes down/bans you: change your provider; keep the email.&lt;/p&gt; &lt;p&gt;Your website is pulled for controversial views: switch hosts.&lt;/p&gt; &lt;p&gt;Protect yourself; give yourself choices. Why give others that power when you could have it for yourself?&lt;/p&gt;</content><author><name></name></author><summary type="html">“When given a choice between independence and dependence, always choose independence; you will never regret that choice!”—Luke Smith</summary></entry></feed>