This feed does not validate.
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.o ...
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendations.
[help]
line 3, column 0: (16 occurrences) [help]
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.o ...
<?xml version="1.0" encoding="iso-8859-1"?><?xml-stylesheet type="text/css" href="/css/atom-browser.css" ?><feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en"> <title>Perturb.org - Scott's Geek Blog</title> <modified>2025-10-28T09:59:10-07:00</modified> <link rel="alternate" type="text/html" href="http://www.perturb.org" /> <tagline>Geek blog</tagline> <id>tag:www.perturb.org,2025://10</id> <generator>Perturb ATOM v0.1</generator> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1439/" /> <title mode="escaped">I was mentioned in the Perl v5.42 release notes</title> <modified>2025-10-09T13:23:49-07:00</modified> <issued>2025-10-09T13:23:49-07:00</issued> <created>2025-10-09T13:23:49-07:00</created> <id>http://www.perturb.org/display/entry/1439/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <. People get mentioned if they contribute code to the language. To be fair my contributions were documentation updates, but it's still pretty cool to get referenced in the _official_ release announcement that goes out to the entire world.]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1438/" /> <title mode="escaped">Linux: View all the lines in a file after a starting delimiter</title> <modified>2025-10-07T14:50:31-07:00</modified> <issued>2025-10-07T14:50:31-07:00</issued> <created>2025-10-07T14:50:31-07:00</created> <id>http://www.perturb.org/display/entry/1438/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> I need to print all the lines in a text file after a certain time. You can do this pretty easily with a Perl one-liner: <br /> <br />```bash <br />perl -nE 'if (/13:00/) { $found = 1; next } print if $found' /var/log/messages <br />``` <br /> <br />The delimiter **needs** to be in the file to trigger. If there was no line that matches `13:00` *nothing* will print. <br /> <br />**Update:** This can also be accomplished with `awk`: <br /> <br />```bash <br />awk '/13:00/ {found=1; next} found' /var/log/messages <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1437/" /> <title mode="escaped">Perl: Fetch data from a URL</title> <modified>2025-10-03T16:32:55-07:00</modified> <issued>2025-10-03T16:32:55-07:00</issued> <created>2025-10-03T16:32:55-07:00</created> <id>http://www.perturb.org/display/entry/1437/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> I need a quick way to fetch JSON data from a URL. Using `HTTP::Tiny` is the easiest way. You can call the function different ways depending on whether you **only** want the body, or if you want the HTTP status code as well: <br /> <br />```perl <br />my $json = get_url("https://domain.com/stats.json"); <br /> <br />my ($html, $http_code) = get_url("https://domain.com/index.html"); <br />``` <br /> <br />```perl <br />sub get_url { <br /> my $url = shift(); <br /> <br /> my $http = HTTP::Tiny->new(verify_SSL => 1, timeout => 5); <br /> my $resp = $http->get($url); <br /> <br /> my $body = $resp->{content}; <br /> my $status = $resp->{status}; <br /> <br /> my @ret = ($body, $status, $resp); <br /> <br /> return @ret; <br />} <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1436/" /> <title mode="escaped">PHP: Return a random element from an array</title> <modified>2025-09-08T15:33:27-07:00</modified> <issued>2025-09-08T15:33:27-07:00</issued> <created>2025-09-08T15:33:27-07:00</created> <id>http://www.perturb.org/display/entry/1436/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> 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. <br /> <br />```php <br />function random_elem(array $arr) { <br /> $key = array_rand($arr); <br /> $ret = $arr[$key]; <br /> <br /> return $ret; <br />} <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1435/" /> <title mode="escaped">Mustache is a very simple and powerful templating language</title> <modified>2025-09-05T11:17:35-07:00</modified> <issued>2025-09-05T11:17:35-07:00</issued> <created>2025-09-05T11:17:35-07:00</created> <id>http://www.perturb.org/display/entry/1435/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> < templating language. It is very mature, and has support for all of the languages I care about: [Perl](https://metacpan.org/pod/Template::Mustache), [PHP](https://github.com/bobthecow/mustache.php), and [Javascript](https://github.com/janl/mustache.js). 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. <br /> <br />[Mustache.js](https://github.com/janl/mustache.js) is _incredibly_ 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. 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. <br /> <br />```html <br /><script src="/js/mustache.min.js"></script> <br />``` <br /> <br />```javascript <br />var data = { name: "Jason", animal: "Kitten" }; <br />var str = Mustache.render("<p>Hello {{name}}, I hear you like {{animal}}s</p>", data); <br />``` <br /> <br />I liked it so much I wrote up a [Mustache sandbox](https://www.perturb.org/code/mustache/) to allow me to play around with the templating system live. The template syntax is a [little archaic](https://mustache.github.io/mustache.5.html), but it is workable. <br /> <br />**Note:** They even have [Arduino](https://github.com/floatplane/ministache) support, which I need to investigate.]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1434/" /> <title mode="escaped">PHP: Simplify sending JSON to a browser</title> <modified>2025-08-29T11:19:44-07:00</modified> <issued>2025-08-29T11:19:44-07:00</issued> <created>2025-08-29T11:19:44-07:00</created> <id>http://www.perturb.org/display/entry/1434/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> I can never remember the correct MIME type for JSON so I wrote this wrapper function to simplify sending JSON to a browser. <br /> <br />```PHP <br />// Convert a PHP data structure to JSON and send it to the browser <br />function json_output($obj) { <br /> $output = json_encode($obj, JSON_INVALID_UTF8_SUBSTITUTE); <br /> <br /> // http://tools.ietf.org/html/rfc4627 <br /> header('Content-type: application/json'); <br /> print $output; <br /> exit; <br />} <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1433/" /> <title mode="escaped">Perl: Search and replace a string across your entire code base</title> <modified>2025-08-20T08:15:57-07:00</modified> <issued>2025-08-20T08:15:57-07:00</issued> <created>2025-08-20T08:15:57-07:00</created> <id>http://www.perturb.org/display/entry/1433/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> 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 `find` command we can find *all* the files and then hand the search and replace off to Perl. Easy peasy. <br /> <br />```bash <br />find codebase/ -type f -exec perl -pi -E 's/foo/bar/g' {} + <br />``` <br /> <br />or using `fd` instead: <br /> <br />```bash <br />fd . codebase/ --type f --exec-batch -pi -E 's/foo/bar/g' {} <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1432/" /> <title mode="escaped">Linux: Testing for x86_64-v3</title> <modified>2025-07-29T16:29:18-07:00</modified> <issued>2025-07-29T16:29:18-07:00</issued> <created>2025-07-29T16:29:18-07:00</created> <id>http://www.perturb.org/display/entry/1432/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> < 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: <br /> <br />``` <br />/usr/lib64/ld-linux-x86-64.so.2 --help <br />``` <br /> <br />Basically any CPU made after 2015 will be fine.]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1431/" /> <title mode="escaped">PHP: Only start a session when it's needed</title> <modified>2025-06-21T11:29:02-07:00</modified> <issued>2025-06-21T11:29:02-07:00</issued> <created>2025-06-21T11:29:02-07:00</created> <id>http://www.perturb.org/display/entry/1431/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> I use sessions on my sites for user authentication. Calling `session_start()` initiates a session and allows me to check if the user is logged in or not. However, calling `session_start()` creates a new session for **every** hit on your site: bots, unauthenticated users, etc. This can lead to an _excess_ of session files on your filesystem. <br /> <br />A better way is to explicitly call `start_session()` when your user logs in. On your other pages you can check if the user has the appropriate session cookie and start a session **only** when it's needed. <br /> <br />```PHP <br />function start_session_if_exists() { <br /> if (isset($_COOKIE[session_name()]) && session_status() !== PHP_SESSION_ACTIVE) { <br /> session_start(); <br /> } <br />} <br />``` <br /> <br />This will avoid creating a session for every hit on your site.]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1430/" /> <title mode="escaped">CSS: Selecting text made easy</title> <modified>2025-06-17T09:58:19-07:00</modified> <issued>2025-06-17T09:58:19-07:00</issued> <created>2025-06-17T09:58:19-07:00</created> <id>http://www.perturb.org/display/entry/1430/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> < 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 `all` 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 **expected** to copy and paste the text. <br /> <br />```css <br />.click_select { user-select: all; } <br />``` <br /> <br />Example: <br /> <br /><style> <br /> .click_select { <br /> user-select: all; <br /> } <br /> .test_button { <br /> border: 1px solid black; <br /> padding: 12px; <br /> border-radius: 4px; <br /> background: darkblue; <br /> } <br /></style> <br /> <br /><span class="click_select test_button">Click me!</span>]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1429/" /> <title mode="escaped">Linux: Find all the text files in a directory</title> <modified>2025-06-06T18:30:02-07:00</modified> <issued>2025-06-06T18:30:02-07:00</issued> <created>2025-06-06T18:30:02-07:00</created> <id>http://www.perturb.org/display/entry/1429/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> I need to find all the _text_ 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: <br /> <br />```bash <br /># Using `fd` (new hotness) <br />fd . /tmp/ --exec file {} + | grep -P ":.*text" | cut -d: -f1 <br /> <br /># Using old school `find` (old and busted) <br />find /tmp/ -exec file {} + | grep -P ":.*text" | cut -d: -f1 <br />``` <br /> <br />These rely on the `file` command to determine what the filetype is.]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1428/" /> <title mode="escaped">Javascript: Copy string to clipboard</title> <modified>2025-06-03T15:25:29-07:00</modified> <issued>2025-06-03T15:25:29-07:00</issued> <created>2025-06-03T15:25:29-07:00</created> <id>http://www.perturb.org/display/entry/1428/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> < helped me come up with this: <br /> <br />```javascript <br />// With async/await <br />async function copyToClipboard(text) { <br /> try { <br /> await navigator.clipboard.writeText(text); <br /> console.log('Copied to clipboard'); <br /> } catch (err) { <br /> console.error('Failed to copy: ', err); <br /> } <br />} <br />``` <br /> <br />Then you simply call it with a string <br /> <br />```javascript <br />copyToClipboard("Hello world"); <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1427/" /> <title mode="escaped">Rocky 10 package versions</title> <modified>2025-06-02T15:10:07-07:00</modified> <issued>2025-06-02T15:10:07-07:00</issued> <created>2025-06-02T15:10:07-07:00</created> <id>http://www.perturb.org/display/entry/1427/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> RedHat Enterprise Linux/Rocky 10 has these versions of packages: <br /> <br />| Package | Version | <br />| ------- | -------- | <br />| Apache | 2.4.63 | <br />| GCC | 14.2.1 | <br />| Git | 2.47.1 | <br />| Kernel | 6.12 | <br />| MariaDB | 10.11.11 | <br />| OpenSSH | 9.9p1 | <br />| Perl | 5.40.2 | <br />| PHP | 8.3.19 | <br />| Vim | 9.1.83 |]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1426/" /> <title mode="escaped">Javascript: Returning data from an AJAX call</title> <modified>2025-05-28T19:59:48-07:00</modified> <issued>2025-05-28T19:59:48-07:00</issued> <created>2025-05-28T19:59:48-07:00</created> <id>http://www.perturb.org/display/entry/1426/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <" 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 [`then()`](https://api.jquery.com/deferred.then/) function. A simple example is as follows: <br /> <br />```javascript <br />function getData() { <br /> return $.ajax({ <br /> url: '/api/data' <br /> }); <br />} <br /> <br />// Usage <br />getData().then(function(data) { <br /> console.log(data); <br />}); <br />```]]> </content> </entry> <entry xmlns="http://purl.org/atom/ns#"> <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1425/" /> <title mode="escaped">PHP: Generate secure password hashes from the CLI</title> <modified>2025-05-24T20:13:35-07:00</modified> <issued>2025-05-24T20:13:35-07:00</issued> <created>2025-05-24T20:13:35-07:00</created> <id>http://www.perturb.org/display/entry/1425/</id> <summary type="text/plain"></summary> <author> <name>Scott Baker</name> <url>http://www.perturb.org/</url> <email>scott@perturb.org</email> </author> <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org"> <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" /> The `password_hash()` 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. <br /> <br />```bash <br />php -r 'echo "Password: "; $pwd = trim(fgets(STDIN)); echo password_hash($pwd, PASSWORD_DEFAULT) . "\n";' <br />```]]> </content> </entry></feed>