This is a valid RSS feed.
This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="/css/rss-browser.css" ?>
<rss version="2.0">
<channel>
<title>Perturb.org - Scott's Geek Stuff</title>
<link>http://www.perturb.org/</link>
<description>Just Geek Stuff</description>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1436/</guid>
<title>PHP: Return a random element from an array</title>
<link>http://www.perturb.org/display/entry/1436/</link>
<description><p>Getting a random element from a PHP array is a multi-step process and I often forget the syntax. Here is a simple function that will return a random element from the provided array.</p>
<pre><code class="language-php">function random_elem(array $arr) {
$key = array_rand($arr);
$ret = $arr[$key];
return $ret;
}</code></pre></description>
<pubDate>Mon, 08 Sep 2025 15:33:27 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1435/</guid>
<title>Mustache is a very simple and powerful templating language</title>
<link>http://www.perturb.org/display/entry/1435/</link>
<description><p>I am late to the game learning about the <a href="https://mustache.github.io/">Mustache</a> templating language. It is very mature, and has support for all of the languages I care about: <a href="https://metacpan.org/pod/Template::Mustache">Perl</a>, <a href="https://github.com/bobthecow/mustache.php">PHP</a>, and <a href="https://github.com/janl/mustache.js">Javascript</a>. I am mainly focused on using it in Javascript as it is a great way to format raw data you get via JSON into something more human consumable like HTML.</p>
<p>It's <em>incredibly</em> easy to implement and get started with. A single include loads the entire zero-dependency library. As of v4.2.0 the library is tiny, clocking in at only 25k. Once loaded <code>Mustache.render(template_str, data_obj)</code> gets you a formatted string. A big selling point is the ease of installation and use. You can be up and running with Mustache.js in less than 5 minutes.</p>
<pre><code class="language-html">&lt;script src="/js/mustache.min.js"&gt;&lt;/script&gt;</code></pre>
<pre><code class="language-javascript">var data = { name: "Jason", animal: "Kitten" };
var str = Mustache.render("&lt;p&gt;Hello {{name}}, I hear you like {{animal}}s&lt;/p&gt;", data);</code></pre>
<p>I liked it so much I wrote up a <a href="https://www.perturb.org/code/mustache/">Mustache sandbox</a> to allow me to play around with the templating system live. The template syntax is a <a href="https://mustache.github.io/mustache.5.html">little archaic</a>, but it is workable.</p>
<p><strong>Note:</strong> They even have Arduino support, which I need to test.</p></description>
<pubDate>Fri, 05 Sep 2025 11:17:35 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1434/</guid>
<title>PHP: Simplify sending a JSON object to browsers</title>
<link>http://www.perturb.org/display/entry/1434/</link>
<description><p>I can never remember the correct MIME type for JSON so I wrote this wrapper function to simplify sending JSON to a browser.</p>
<pre><code class="language-PHP">// Convert a PHP data structure to JSON and send it to the browser
function json_output($obj) {
$output = json_encode($obj, JSON_INVALID_UTF8_SUBSTITUTE);
// http://tools.ietf.org/html/rfc4627
header('Content-type: application/json');
print $output;
exit;
}</code></pre></description>
<pubDate>Fri, 29 Aug 2025 11:19:44 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1433/</guid>
<title>Perl: Search and replace a string across your entire code base</title>
<link>http://www.perturb.org/display/entry/1433/</link>
<description><p>I need to rename a function anywhere it is found in my code base. This requires going through every file and directory recursively, and checking each file. Using the Linux <code>find</code> command we can find <em>all</em> the files and then hand the search and replace off to Perl. Easy peasy.</p>
<pre><code class="language-bash">find codebase/ -type f -exec perl -pi -E 's/foo/bar/g' {} +</code></pre>
<p>or using <code>fd</code> instead:</p>
<pre><code class="language-bash">fd . codebase/ --type f --exec-batch -pi -E 's/foo/bar/g' {}</code></pre></description>
<pubDate>Wed, 20 Aug 2025 08:15:57 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1432/</guid>
<title>Linux: Testing for x86_64-v3</title>
<link>http://www.perturb.org/display/entry/1432/</link>
<description><p>Modern Linux distributions are starting to require <a href="https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels">x86_64-v3</a> capable CPUs to run. If you do not have a CPU modern enough you may not be able to install certain versions of Linux. To test if your hardware is capable you can run the following command:</p>
<pre><code>/usr/lib64/ld-linux-x86-64.so.2 --help</code></pre>
<p>Basically any CPU made after 2015 will be fine.</p></description>
<pubDate>Tue, 29 Jul 2025 16:29:18 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1431/</guid>
<title>PHP: Only start a session when it's needed</title>
<link>http://www.perturb.org/display/entry/1431/</link>
<description><p>I use sessions on my sites for user authentication. Calling <code>session_start()</code> initiates a session and allows me to check if the user is logged in or not. However, calling <code>session_start()</code> creates a new session for <strong>every</strong> hit on your site: bots, unauthenticated users, etc. This can lead to an <em>excess</em> of session files on your filesystem.</p>
<p>A better way is to explicitly call <code>start_session()</code> when your user logs in. On your other pages you can check if the user has the appropriate session cookie and start a session <strong>only</strong> when it's needed.</p>
<pre><code class="language-PHP">function start_session_if_exists() {
if (isset($_COOKIE[session_name()]) &amp;&amp; session_status() !== PHP_SESSION_ACTIVE) {
session_start();
}
}</code></pre>
<p>This will avoid creating a session for every hit on your site.</p></description>
<pubDate>Sat, 21 Jun 2025 11:29:02 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1430/</guid>
<title>CSS: Selecting text made easy</title>
<link>http://www.perturb.org/display/entry/1430/</link>
<description><p>You can apply the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/user-select">user-select</a> CSS property to an element to control how it handles selecting text for copy and paste. This allows you to limit selecting text, or make it automatic. If you use the <code>all</code> property, anytime a user clicks on that element the text is automatically selected. This can be useful for keys or codes where the user is <strong>expected</strong> to copy and paste the text.</p>
<pre><code class="language-css">.click_select { user-select: all; }</code></pre>
<p>Example:</p>
<style>
.click_select {
user-select: all;
}
.test_button {
border: 1px solid black;
padding: 12px;
border-radius: 4px;
background: darkblue;
}
</style>
<p><span class="click_select test_button">Click me!</span></p></description>
<pubDate>Tue, 17 Jun 2025 09:58:19 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1429/</guid>
<title>Linux: Find all the text files in a directory</title>
<link>http://www.perturb.org/display/entry/1429/</link>
<description><p>I need to find all the <em>text</em> files in a given directory for potential clean up. There is not a super easy way to find only text files, but I came up with a hacky solution:</p>
<pre><code class="language-bash"># Using `fd` (new hotness)
fd . /tmp/ --exec file {} + | grep -P ":.*text" | cut -d: -f1
# Using old school `find` (old and busted)
find /tmp/ -exec file {} + | grep -P ":.*text" | cut -d: -f1</code></pre>
<p>These rely on the <code>file</code> command to determine what the filetype is.</p></description>
<pubDate>Fri, 06 Jun 2025 18:30:02 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1428/</guid>
<title>Javascript: Copy string to clipboard</title>
<link>http://www.perturb.org/display/entry/1428/</link>
<description><p>I needed a modern way to copy a string to the clipboard in JavaScript. <a href="https://claude.ai">Claude.ai</a> helped me come up with this:</p>
<pre><code class="language-javascript">// With async/await
async function copyToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
console.log('Copied to clipboard');
} catch (err) {
console.error('Failed to copy: ', err);
}
}</code></pre>
<p>Then you simply call it with a string</p>
<pre><code class="language-javascript">copyToClipboard("Hello world");</code></pre></description>
<pubDate>Tue, 03 Jun 2025 15:25:29 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1427/</guid>
<title>Rocky 10 package versions</title>
<link>http://www.perturb.org/display/entry/1427/</link>
<description><p>RedHat Enterprise Linux/Rocky 10 has these versions of packages:</p>
<table>
<thead>
<tr>
<th>Package</th>
<th>Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>Apache</td>
<td>2.4.63</td>
</tr>
<tr>
<td>GCC</td>
<td>14.2.1</td>
</tr>
<tr>
<td>Git</td>
<td>2.47.1</td>
</tr>
<tr>
<td>Kernel</td>
<td>6.12</td>
</tr>
<tr>
<td>MariaDB</td>
<td>10.11.11</td>
</tr>
<tr>
<td>OpenSSH</td>
<td>9.9p1</td>
</tr>
<tr>
<td>Perl</td>
<td>5.40.2</td>
</tr>
<tr>
<td>PHP</td>
<td>8.3.19</td>
</tr>
<tr>
<td>Vim</td>
<td>9.1.83</td>
</tr>
</tbody>
</table></description>
<pubDate>Mon, 02 Jun 2025 15:10:07 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1426/</guid>
<title>Javascript: Returning data from an AJAX call</title>
<link>http://www.perturb.org/display/entry/1426/</link>
<description><p>Javascript is by it's nature asynchronous, which makes returning data from an AJAX call complicated. Modern Javascript uses the concept of a "<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">promise</a>" to allow you to run code after an asynchronous call competes. This is similar to using a callback function, but it reads cleaner. JQuery implements this type of call with the <a href="https://api.jquery.com/deferred.then/"><code>then()</code></a> function. A simple example is as follows:</p>
<pre><code class="language-javascript">function getData() {
return $.ajax({
url: '/api/data'
});
}
// Usage
getData().then(function(data) {
console.log(data);
});</code></pre></description>
<pubDate>Wed, 28 May 2025 19:59:48 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1425/</guid>
<title>PHP: Generate secure password hashes from the CLI</title>
<link>http://www.perturb.org/display/entry/1425/</link>
<description><p>The <code>password_hash()</code> function in PHP is excellent for storing passwords securely. In order to generate password to store in a database or config file I like to generate passwords from the CLI. This has the risk of storing the password in your bash history. This command prompts you for the password on the fly and protects your history.</p>
<pre><code class="language-bash">php -r 'echo "Password: "; $pwd = trim(fgets(STDIN)); echo password_hash($pwd, PASSWORD_DEFAULT) . "\n";'</code></pre></description>
<pubDate>Sat, 24 May 2025 20:13:35 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1424/</guid>
<title>Vim: Insert a line of characters</title>
<link>http://www.perturb.org/display/entry/1424/</link>
<description><p>I need an 80 character divider of text in Vim. I can never remember the sequence so I'm writing it down:</p>
<pre><code>80i/&lt;ESC&gt;</code></pre>
<p>Will generate:</p>
<pre><code class="language-text">////////////////////////////////////////////////////////////////////////////////</code></pre></description>
<pubDate>Tue, 01 Apr 2025 00:00:00 -0700</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1423/</guid>
<title>Comparing 32bit and 64bit performance on low end micro-controllers</title>
<link>http://www.perturb.org/display/entry/1423/</link>
<description><p>Testing 32bit vs 64bit PRNGs on a 32bit ESP32-C3 <a href="https://gist.github.com/scottchiefbaker/e4c87de8d6c1ad4a33b1ffe5a3ce707f">I'm seeing</a>:</p>
<table>
<thead>
<tr>
<th>PRNG</th>
<th>Iterations per second</th>
<th>Output Bits</th>
<th>Bytes per second</th>
</tr>
</thead>
<tbody>
<tr>
<td>pcg32</td>
<td>487802</td>
<td>32</td>
<td><strong>1951266.7 b/s</strong></td>
</tr>
<tr>
<td>xoroshiro64**</td>
<td><strong>516023</strong></td>
<td>32</td>
<td>2050966.7 b/s</td>
</tr>
<tr>
<td>xoshiro256+</td>
<td>487808</td>
<td>64</td>
<td><strong>3878726.7 b/s</strong></td>
</tr>
<tr>
<td>xoshiro512++</td>
<td>441735</td>
<td>64</td>
<td>3514373.3 b/s</td>
</tr>
<tr>
<td>splitmix64</td>
<td>462290</td>
<td>64</td>
<td>3677033.3 b/s</td>
</tr>
<tr>
<td>pcg64</td>
<td><strong>416297</strong></td>
<td>64</td>
<td>3313060.0 b/s</td>
</tr>
</tbody>
</table>
<p>Very little difference on PRNGs that use 64bit operations vs 32bit operations. Even on limited hardware like this it makes sense to use a 64bit PRNG because you get more bytes per cycle.</p></description>
<pubDate>Wed, 05 Mar 2025 13:47:09 -0800</pubDate>
</item>
<item>
<guid isPermaLink="true">http://www.perturb.org/display/entry/1422/</guid>
<title>Vim: Convert your syntax highlighted text into HTML</title>
<link>http://www.perturb.org/display/entry/1422/</link>
<description><p>Vim is my code editor of choice as it has great features, excellent syntax highlighting, and a robust plug-in infrastructure. I'm very used to look and feel of Vim. If you want to share some of your code online, converting things to HTML can be problematic. Luckily Vim has a built in code to HTML converter:</p>
<pre><code>:TOhtml</code></pre>
<p>Simply run the <code>:TOhtml</code> command in an open text file and your buffer will be redrawn in HTML which you can then save. Here is a quick sample of my pcg32.pl script <a href="https://www.perturb.org/code/pcg32.pl.html">converted to HTML</a>.</p></description>
<pubDate>Wed, 26 Feb 2025 00:00:00 -0800</pubDate>
</item>
</channel>
</rss>
If you would like to create a banner that links to this page (i.e. this validation result), do the following:
Download the "valid RSS" banner.
Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)
Add this HTML to your page (change the image src
attribute if necessary):
If you would like to create a text link instead, here is the URL you can use:
http://www.feedvalidator.org/check.cgi?url=http%3A//www.perturb.org/rss.php