This feed does not validate.
<br />
<b>Warning</b>: Undefined variable $out in <b>/home/bakers/html/perturb.cla ...
In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.
help]
[<br />
<b>Warning</b>: Undefined variable $out in <b>/home/bakers/html/perturb.class.php</b> on line <b>1267</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<br />
<b>Warning</b>: Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1306</b><br />
<?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-06-15T15:04:33-07:00</modified> <link rel="alternate" type="text/html" href="http://www.perturb.org" /> <tagline>Geek blog</tagline>
<id>tag:www.perturb.org,2025://06</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/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>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1424/" />
<title mode="escaped">Vim: Insert a line of characters</title>
<modified>2025-04-01T00:00:00-07:00</modified>
<issued>2025-04-01T00:00:00-07:00</issued>
<created>2025-04-01T00:00:00-07:00</created>
<id>http://www.perturb.org/display/entry/1424/</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 an 80 character divider of text in Vim. I can never remember the sequence so I'm writing it down: <br />
<br />
``` <br />
80i/<ESC> <br />
``` <br />
<br />
Will generate: <br />
<br />
```text <br />
//////////////////////////////////////////////////////////////////////////////// <br />
```
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1423/" />
<title mode="escaped">Comparing 32bit and 64bit performance on low end micro-controllers</title>
<modified>2025-03-05T13:47:09-08:00</modified>
<issued>2025-03-05T13:47:09-08:00</issued>
<created>2025-03-05T13:47:09-08:00</created>
<id>http://www.perturb.org/display/entry/1423/</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">
<: <br />
<br />
| PRNG | Iterations per second | Output Bits | Bytes per second | <br />
| ------------- | --------------------- | ----------- | ---------------- | <br />
| pcg32 | 487802 | 32 | **1951266.7 b/s**| <br />
| xoroshiro64** | **516023** | 32 | 2050966.7 b/s | <br />
| xoshiro256+ | 487808 | 64 | **3878726.7 b/s**| <br />
| xoshiro512++ | 441735 | 64 | 3514373.3 b/s | <br />
| splitmix64 | 462290 | 64 | 3677033.3 b/s | <br />
| pcg64 | **416297** | 64 | 3313060.0 b/s | <br />
<br />
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.
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1422/" />
<title mode="escaped">Vim: Convert your syntax highlighted text into HTML</title>
<modified>2025-02-26T00:00:00-08:00</modified>
<issued>2025-02-26T00:00:00-08:00</issued>
<created>2025-02-26T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1422/</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">
<.
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1421/" />
<title mode="escaped">What kind of number makes a good seed for a PRNG?</title>
<modified>2025-02-20T00:00:00-08:00</modified>
<issued>2025-02-20T00:00:00-08:00</issued>
<created>2025-02-20T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1421/</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">
< use complex math to generate random numbers on your computer. These random numbers are used for all sorts of things: simulations, fractals, games, art, and even math experiments. Computers can **only** do math, which makes generating a random number difficult. <br />
<br />
PRNGs need a "seed" number to kick off the math that generates sequences of random numbers. Some PRNGs require a 32bit seed, and some require a 64bit seed. Some PRNGs require one seed, and some require four (or more). It is important to know what type of seed your PRNG needs. <br />
<br />
A 32bit number is between 0 and 4.2 billion and a 64bit number is between 0 and 18.4 quintillion. The larger a number is, the more bits are required to store it, and the better a seed it will make. The closer your seed is to the upper end of the number range the better. As a general rule a good seed will be a decimal number with 18 or 19 digits. <br />
<br />
`12` is a small number and **not** a good seed, `4611686018427387906` is a big number but still not a great seed. Seeds should **not** have large sections of zero/one bits. This is why small numbers do not make good seeds. Bits can be visualized by printing the number in binary: <br />
<br />
```bash <br />
# Horrible <br />
$ perl -E 'printf("%064b\n", 4611686018427387906)' <br />
0100000000000000000000000000000000000000000000000000000000000010 <br />
<br />
# Bad <br />
$ perl -E 'printf("%064b\n", 17770)' <br />
0000000000000000000000000000000000000000000000000100010101101010 <br />
<br />
# Poor <br />
$ perl -E 'printf("%064b\n", 2850756010)' <br />
0000000000000000000000000000000010101001111010110001010110101010 <br />
<br />
# Good <br />
$ perl -E 'printf("%064b\n", 11337502976607798025)' <br />
1001110101010110111001101110001101111000101001000100001100001001 <br />
``` <br />
<br />
Good seeds should have a _roughly_ even mix of zero and one bits. `9223372036854775808` is a large number and looks promising but it has 63 zeros, and only a single one bit. You can visualize the quality of your seed with [seed_quality.pl](https://www.perturb.org/code/seed_quality.pl). Quality above 75% should make for good seed numbers. <br />
<br />
Seeds should **not** be predictable. Do not use dates, times, or phone numbers as they are potentially guessable. Combinations of numbers can be good sources. Process PID, UID, unixtime are good potential sources _if_ they are combined together in a non-predictable way. PID multiplied by UID multiplied by Unixtime is an example of combining values. Memory locations of variables, especially if [ASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization) is in use is a potentially good source as well. <br />
<br />
Hashing numbers, strings, or combinations of numbers can be a good way to generate seeds. Hashing a value with [Komihash](https://github.com/scottchiefbaker/perl-Crypt-Komihash) or [xxHash](https://metacpan.org/pod/Digest::xxHash) will generate a suitable 64bit number. Hashing a value with [SHA256](https://metacpan.org/pod/Digest::SHA) will generate a 256bit value which can be [split](https://www.perturb.org/display/1415_Perl_Using_sha256_to_hash_strings_into_integers.html) into four 64bit values. Hashing functions also do a good job of ensuring the bits are mixed well and do not include large repeating sections. <br />
<br />
The best source of seed numbers is directly from your OS. On Linux this is `/dev/urandom` and on Windows you can interface with the `RtlGenRandom` API. These are carefully curated sources of _true_ randomness, but they can be slow-ish. Using them as a source for a fast PRNG is best practice. <br />
<br />
```perl <br />
sub get_64bit_seed { <br />
open my $urandom, '<:raw', '/dev/urandom' or croak("Couldn't open /dev/urandom: $!"); <br />
sysread($urandom, my $buf, 8) or croak("Couldn't read from csprng: $!"); <br />
<br />
return unpack("Q*", $buf); <br />
} <br />
```
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1420/" />
<title mode="escaped">Perl: Multiply-Shift Hash</title>
<modified>2025-01-27T00:00:00-08:00</modified>
<issued>2025-01-27T00:00:00-08:00</issued>
<created>2025-01-27T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1420/</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've been using the multiply-shift hash lately and have had good results. It's simple, fast, and well tested. <br />
<br />
```c <br />
// Multiply-Shift Hash <br />
static uint64_t hash_msh(uint64_t x) { <br />
uint64_t prime = 0x9e3779b97f4a7c15; // A large prime constant <br />
x ^= (x >> 30); <br />
x *= prime; <br />
x ^= (x >> 27); <br />
x *= prime; <br />
x ^= (x >> 31); <br />
return x; <br />
} <br />
``` <br />
<br />
Whenever I find interesting code like this I like to try and implement it in Perl: <br />
<br />
```perl <br />
sub hash_msh { <br />
my $x = $_[0]; <br />
my $prime = 11400714819323198485; <br />
<br />
$x ^= ($x >> 30); <br />
$x = multiply_uv($x, $prime); <br />
$x ^= ($x >> 27); <br />
$x = multiply_uv($x, $prime); <br />
$x ^= ($x >> 31); <br />
<br />
return $x; <br />
} <br />
<br />
# Perl converts numbers larger than 2^64 - 1 to floating point so <br />
# we 'use integer' to force integer math which retains any overflow. <br />
sub multiply_uv { <br />
my ($one, $two) = @_; <br />
<br />
use integer; <br />
my $ret = $one * $two; <br />
no integer; <br />
<br />
# Convert signed IV to unsinged UV <br />
if ($ret < 0) { <br />
$ret += 18446744073709551615; <br />
$ret += 1; <br />
} <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/1419/" />
<title mode="escaped">Perl: Calculate number of bits needed to store a number</title>
<modified>2025-01-27T00:00:00-08:00</modified>
<issued>2025-01-27T00:00:00-08:00</issued>
<created>2025-01-27T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1419/</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" />
Quick Perl function to calculate the number of bits required to store a given number. <br />
<br />
```perl <br />
sub bits_required { <br />
my ($n) = @_; <br />
<br />
# Handle special case for 0 <br />
return 0 if $n == 0; <br />
<br />
# Use logarithm to calculate the number of bits <br />
my $bits = int(log($n) / log(2)) + 1; <br />
return $bits; <br />
} <br />
```
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1418/" />
<title mode="escaped">Implmenting PRNGs in Perl</title>
<modified>2025-01-25T00:00:00-08:00</modified>
<issued>2025-01-25T00:00:00-08:00</issued>
<created>2025-01-25T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1418/</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">
<. It's simple, fast, and well documented. As is usually the case when I find interesting code I try and find a way to implement it in Perl. PCG32 poses an interesting problem when one tries to implement it in Perl because all the math is performed using **unsigned** integers and overflow. Most PRNGs use large numbers and overflow to work, that's their secret sauce. <br />
<br />
Perl does not have a native unsigned type so I had to learn the guts of how Perl does math so I could emulate it. I ended up coming up with two different implementations, a native Perl implementation, and a version that uses `Math::Int64`. Surprisingly the native version was *significantly* faster. <br />
<br />
Both implementations with detailed comments are available in [pcg32.pl](https://www.perturb.org/code/syntax_highlight.php?file=pcg32.pl) if you're interested in learning more about how to do integer style math in Perl. <br />
<br />
As a bonus I also ported the [xoshiro256 family](https://www.perturb.org/code/syntax_highlight.php?file=xoshiro256.pl) into Perl. [Splitmix64](https://www.perturb.org/code/syntax_highlight.php?file=splitmix64.pl) ended up being a little more complicated to port, but I got it as well.
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1417/" />
<title mode="escaped">C/C++: List all #define macros</title>
<modified>2025-01-22T00:00:00-08:00</modified>
<issued>2025-01-22T00:00:00-08:00</issued>
<created>2025-01-22T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1417/</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 target a specific platform with some code I'm writing. You can list **all** of the `#define` macros on a given platform with these commands: <br />
<br />
``` <br />
gcc -dM -E - < /dev/null <br />
``` <br />
<br />
``` <br />
clang -dM -E - < /dev/null <br />
``` <br />
<br />
In this big list of macros you should find something to help you target a given platform.
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1416/" />
<title mode="escaped">FFMPEG: Limit the output to only the encoding stats for quieter scripting</title>
<modified>2025-01-21T00:00:00-08:00</modified>
<issued>2025-01-21T00:00:00-08:00</issued>
<created>2025-01-21T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1416/</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" />
FFMPEG is a great tool, but it is very chatty. If you want to encode a file you'll get about 40 lines of headers and track information, most of which you probably will not read. For scripting purposes you probably **only** want to see the statistics. If you start FFMPEG, hide the banner, and set the loglevel low you can output only the stats you need <br />
<br />
```bash <br />
ffmpeg -y -hide_banner -loglevel quiet -stats ... <br />
```
]]>
</content>
</entry>
<entry xmlns="http://purl.org/atom/ns#">
<link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1415/" />
<title mode="escaped">Perl: Using sha256 to hash strings into integers</title>
<modified>2025-01-20T00:00:00-08:00</modified>
<issued>2025-01-20T00:00:00-08:00</issued>
<created>2025-01-20T00:00:00-08:00</created>
<id>http://www.perturb.org/display/entry/1415/</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 64bit integers to seed some PRNG work I'm doing. I found out that you can easily create four 64bit numbers from any string by using SHA256. <br />
<br />
``` <br />
use Digest::SHA; <br />
<br />
my $input = $ARGV[0] || int(rand() * 1000000); <br />
<br />
# Get raw bytes and convert to an array of uint64_t <br />
my $hash = Digest::SHA::sha256($input); <br />
my @nums = unpack("Q*", $hash); <br />
<br />
print "SHA256 Hashing '$input' to: " . join(", ", @nums) . "\n"; <br />
``` <br />
<br />
**Note:** We are using `sha256` here, not `sha256_hex` because we need raw bytes to convert to integers with `unpack`.
]]>
</content>
</entry>
</feed>