<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Programming on Adam Hacks</title><link>https://hackeradam.com/blog/programming/</link><description>Recent content in Programming on Adam Hacks</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 03 Feb 2025 00:00:00 +0000</lastBuildDate><atom:link href="https://hackeradam.com/blog/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Taking a Dive into Linux's /proc/kcore</title><link>https://hackeradam.com/blog/taking-a-dive-into-linux-proc-kcore/</link><pubDate>Mon, 03 Feb 2025 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/taking-a-dive-into-linux-proc-kcore/</guid><description>&lt;p&gt;The Proc filesystem (&lt;code&gt;procfs&lt;/code&gt;) on Linux is quite an interesting thing to take a deep dive into. This virtual filesystem is generated on-the-fly by the Linux Kernel and contains all kinds of juicy information about the system. Two very interesting files that I recently found myself exploring are &lt;code&gt;/proc/kcore&lt;/code&gt; and &lt;code&gt;/proc/iomem&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Whilst poking around on a Linux system recently, I came across the &lt;code&gt;kccore&lt;/code&gt; file for the first time. Up until this point, I remained blissfully unaware of what it was, but on this day I had reason to dig into it. Through my research I discovered that it&amp;rsquo;s possible to access the entire memory of a Linux system via this file. Being that this is an interesting proposition, I went ahead and developed a proof-of-concept tool to dump the memory to a file on disk.&lt;/p&gt;</description></item><item><title>How To Set Up a Private Maven Repository with GitHub Packages</title><link>https://hackeradam.com/blog/how-to-set-up-a-private-maven-repository-with-github-packages/</link><pubDate>Thu, 24 Aug 2023 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/how-to-set-up-a-private-maven-repository-with-github-packages/</guid><description>&lt;p&gt;This quick tutorial will teach you how to use GitHub Actions to automatically build a Java library, publish it to a private GitHub Packages Maven repository, and how to use your newly hosted library in another Maven project.&lt;/p&gt;</description></item><item><title>CS Review: Merge Sort</title><link>https://hackeradam.com/blog/cs-review-merge-sort/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/cs-review-merge-sort/</guid><description>&lt;p&gt;Merge sort is among the divide and conquer algorithms. That is to say, it divides the input array into half, calls itself on both halves. This process is done recursively over the entire array. When we’re done, all the individually sorted pieces are merged back together to form the fully sorted array.&lt;/p&gt;</description></item><item><title>CS Review: Quicksort</title><link>https://hackeradam.com/blog/cs-review-quicksort/</link><pubDate>Sun, 28 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/cs-review-quicksort/</guid><description>&lt;p&gt;Quicksort is another one of the divide and conquer sorting algorithms. It works by partitioning the array around some chosen pivot point, which there are a few different ways to choose.&lt;/p&gt;
&lt;p&gt;Quicksort is generally preferred over &lt;a href="https://hackeradam.com/blog/cs-review-merge-sort/"&gt;merge sort&lt;/a&gt; for sorting arrays due to the fact that the general form of the algorithm sorts in-place.&lt;/p&gt;</description></item><item><title>CS Review: Bubble Sort</title><link>https://hackeradam.com/blog/cs-review-bubble-sort/</link><pubDate>Sat, 27 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/cs-review-bubble-sort/</guid><description>&lt;p&gt;Bubble sort is the easiest possible sorting algorithm you could imagine. It works by simply iterating over an array of data and comparing adjacent items. If those items are in the wrong order, then they are swapped. In doing this, the largest items “bubble up” to the correct position in the array (assuming ascending order, anyway).&lt;/p&gt;
&lt;p&gt;While this is great from a simplicity standpoint, it’s a pretty awful solution in terms of efficiency. The worst-case performance of bubble sort is O(n2). The best-case turns out to be O(n).&lt;/p&gt;
&lt;p&gt;As you can see, this algorithm is not suitable for any sufficiently large datasets.&lt;/p&gt;</description></item><item><title>CS Review: Selection Sort</title><link>https://hackeradam.com/blog/cs-review-selection-sort/</link><pubDate>Sat, 27 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/cs-review-selection-sort/</guid><description>&lt;p&gt;The previous sorting algorithm we took a look at was &lt;a href="https://hackeradam.com/blog/cs-review-bubble-sort/"&gt;bubble sort&lt;/a&gt;. This time around we will be taking a look at selection sort, which is slightly more complex than bubble sort, but only by a tiny bit.&lt;/p&gt;
&lt;p&gt;The idea behind selection sort is that you keep iterating over your array of data, finding the minimum element each time and placing it at the start of the list. In this way, you can think of selection sort as managing two subarrays: the portion of the array that is sorted and the portion that still needs to be sorted.&lt;/p&gt;
&lt;p&gt;Like bubble sort, selection sort has a worst-case time complexity of O(n2), but it does have a tendency to outperform bubble sort. Selection sort also has a nice side-effect where it will never do more than O(n) swaps, which is nice if you’re operating in an environment in which memory writes are costly.&lt;/p&gt;</description></item><item><title>A Review of Binary Search Trees</title><link>https://hackeradam.com/blog/a-review-of-binary-search-trees/</link><pubDate>Fri, 26 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/a-review-of-binary-search-trees/</guid><description>&lt;p&gt;My previous computer science review post took a look at &lt;a href="https://hackeradam.com/blog/a-review-of-binary-trees/"&gt;the tree data structure&lt;/a&gt;. This time around we will be exploring a specific kind of binary tree: The Binary Search Tree.&lt;/p&gt;
&lt;p&gt;Let’s not waste any more time and just jump right in!&lt;/p&gt;</description></item><item><title>A Review of Graphs</title><link>https://hackeradam.com/blog/a-review-of-graphs/</link><pubDate>Fri, 26 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/a-review-of-graphs/</guid><description>&lt;p&gt;You may have noticed that I’ve been putting a lot more work into writing posts for my &lt;a href="https://hackeradam.com/computer-science-review/"&gt;Computer Science Review series&lt;/a&gt; lately. The last installment of this series took a look at &lt;a href="https://hackeradam.com/blog/a-review-of-binary-search-trees/"&gt;binary search trees&lt;/a&gt;. This time around we will be taking some time to review one of my favorite data structures: Graphs.&lt;/p&gt;</description></item><item><title>A Review of Binary Trees</title><link>https://hackeradam.com/blog/a-review-of-binary-trees/</link><pubDate>Thu, 25 Feb 2021 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/a-review-of-binary-trees/</guid><description>&lt;p&gt;In my previous review series, I wrote a &lt;a href="https://hackeradam.com/blog/a-brief-review-of-set-theory/"&gt;brief review of set theory&lt;/a&gt;. This time around we’ll take a look at the binary tree data structure. The tree structure is very common, incredibly useful data structure in the field of computer science and it’s essential that any engineer understand how they work.&lt;/p&gt;</description></item><item><title>The Dining Philosophers Problem</title><link>https://hackeradam.com/blog/the-dining-philosophers-problem/</link><pubDate>Fri, 21 Aug 2020 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/the-dining-philosophers-problem/</guid><description>&lt;p&gt;The dining philosophers problem is a classic problem in the realm of computer science. If you’ve had any formal CS education you’ve more than likely seen the problem when learning about concurrent programming.&lt;/p&gt;
&lt;p&gt;Today we will take a look at the problem and look at an example of how we can solve it.&lt;/p&gt;</description></item><item><title>Creating an OpenCV 4 Project in Visual Studio 2017 &amp; 2019</title><link>https://hackeradam.com/blog/creating-an-opencv-4-project-in-visual-studio-2017-2019/</link><pubDate>Mon, 24 Dec 2018 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/creating-an-opencv-4-project-in-visual-studio-2017-2019/</guid><description>&lt;p&gt;In my &lt;a href="https://hackeradam.com/blog/installing-opencv-4-on-windows-10/"&gt;previous tutorial&lt;/a&gt;, I outlined how to build the OpenCV 4 library on Microsoft Windows 10. In that tutorial, however, I did not mention how to use that library in an actual project. This time around I will be showing you how to create an OpenCV 4 project within Microsoft Visual Studio 2017.&lt;/p&gt;
&lt;p&gt;Please note that I am going to assume that your OpenCV install is set up in the way I outlined in my previous tutorial. That is to say that the necessary files are located within an OpenCV folder in your &lt;strong&gt;C:\&lt;/strong&gt; drive. If this is not the case you’ll have to make some minor modifications to the steps outlined here to suit your setup.&lt;/p&gt;
&lt;p&gt;Let’s get started!&lt;/p&gt;</description></item><item><title>Let's Write a Simple Intel 8080 Disassembler</title><link>https://hackeradam.com/blog/lets-write-a-simple-intel-8080-disassembler/</link><pubDate>Mon, 03 Dec 2018 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/lets-write-a-simple-intel-8080-disassembler/</guid><description>&lt;p&gt;Typically my weekends are spent &lt;a href="https://serialphotog.com/"&gt;hiking with my camera&lt;/a&gt;, but this past weekend I was knocked down by a pretty nasty cold. As a result, I found myself toying around with various programming projects I’ve had laying around. Here for a while, I’ve been curious how emulators work, so I took this opportunity to start venturing down that rabbit hole. During this excursion, I decided to start my foray into emulators by writing one for the game Space Invaders, which ran on an Intel 8080 microprocessor. It seemed only natural to get started by writing a disassembler for the 8080 to get things started.&lt;/p&gt;
&lt;p&gt;What I came up with is a pretty simple (albeit long) bit of C code to disassemble binary code compiled for the Intel 8080. So, without further ado, let’s jump on in and see how I did it!&lt;/p&gt;</description></item><item><title>Dumping Map Tiles from MBTiles with Python</title><link>https://hackeradam.com/blog/dumping-map-tiles-from-mbtiles-with-python/</link><pubDate>Mon, 12 Feb 2018 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/dumping-map-tiles-from-mbtiles-with-python/</guid><description>&lt;p&gt;MBTiles is a database format, developed by &lt;a href="https://www.mapbox.com/"&gt;Mapbox&lt;/a&gt;, for storing tiled data. It’s a relatively simple database format that allows for a convenient, portable way to store map tile data.&lt;/p&gt;
&lt;p&gt;Here recently, I’ve been developing code that works with tiled map data, including data contained within an MBTiles database. As part of this, I’ve needed an easy way to dump the map tiles from an MBTiles database to my local disk. It turns out that we can do this quite easily with a little bit of Python, so let’s dig in!&lt;/p&gt;</description></item><item><title>Python - How to Capture Video from a Webcam with OpenCV</title><link>https://hackeradam.com/blog/python-how-to-capture-video-from-a-webcam-with-opencv/</link><pubDate>Mon, 07 Aug 2017 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/python-how-to-capture-video-from-a-webcam-with-opencv/</guid><description>&lt;p&gt;Have you ever written code to interface with a webcam? Well, if you have then you know that it can be a royal pain in the ass. And God forbid you want it to be a cross-platform solution! The good news is that there is a ready-made solution that can help us out: OpenCV. Yes, you heard me right. Not only is OpenCV and amazing computer vision library, but it also provides a handy, cross-platform way of interfacing with webcams. Let’s take a look at how simple OpenCV makes this. I’ll be using Python for these examples, but the API is similar in other languages.&lt;/p&gt;</description></item><item><title>Quickly Generating Primes Below n with the Sieve of Eratosthenes</title><link>https://hackeradam.com/blog/quickly-generating-primes-below-n-with-the-sieve-of-eratosthenes/</link><pubDate>Wed, 17 May 2017 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/quickly-generating-primes-below-n-with-the-sieve-of-eratosthenes/</guid><description>&lt;p&gt;The uses for prime numbers in computer science are nearly endless. They are useful for everything from hashing, cryptology, factorization, and all sorts of applications in-between.&lt;/p&gt;
&lt;p&gt;There exists a great number of algorithms that allow us to quickly generate primes, but today we are going to take a look at a popular method known as a &lt;strong&gt;prime sieve&lt;/strong&gt;. There are a number of different implementations of prime sieves, but one of the simplest to implement is known as the &lt;a href="https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes"&gt;Sieve of Eratosthenes&lt;/a&gt;. This algorithm is great for quickly generating smaller prime numbers (but it may not be the best choice for generating very large primes).&lt;/p&gt;</description></item><item><title>How to Route URLLib2 Through TOR (Python)</title><link>https://hackeradam.com/blog/how-to-route-urllib2-through-tor-python/</link><pubDate>Wed, 06 Jan 2016 00:00:00 +0000</pubDate><guid>https://hackeradam.com/blog/how-to-route-urllib2-through-tor-python/</guid><description>&lt;p&gt;I’ve recently been experimenting on a new project to scrape data from webpages located on the Tor network. For simplicity’s sake, I decided to write this bit of code in Python and use the handy urllib2 library to handle the HTTP requests.&lt;/p&gt;
&lt;p&gt;For those that don’t know, Tor runs a SOCKS5 proxy, which, by default, runs on &lt;strong&gt;127.0.0.1:9050&lt;/strong&gt;. I thought things would be as simple as telling urllib2 to use a proxy located at IP &lt;em&gt;127.0.0.1&lt;/em&gt; and port &lt;em&gt;9050&lt;/em&gt;, but I quickly found that this doesn’t work.&lt;/p&gt;</description></item></channel></rss>