Congratulations!

[Valid RSS] This is a valid RSS feed.

Recommendations

This feed is valid, but interoperability with the widest range of feed readers could be improved by implementing the following recommendations.

Source: http://www.perturb.org/rss.php

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <?xml-stylesheet type="text/css" href="/css/rss-browser.css" ?>
  3. <rss version="2.0">
  4. <channel>
  5. <title>Perturb.org - Scott's Geek Stuff</title>
  6. <link>http://www.perturb.org/</link>
  7. <description>Just Geek Stuff</description>
  8.  
  9. <item>
  10. <guid isPermaLink="true">http://www.perturb.org/display/entry/1429/</guid>
  11. <title>Linux: Find all the text files in a directory</title>
  12. <link>http://www.perturb.org/display/entry/1429/</link>
  13. <description>&lt;p&gt;I need to find all the &lt;em&gt;text&lt;/em&gt; 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:&lt;/p&gt;
  14. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Using `fd` (new hotness)
  15. fd . /tmp/ --exec file {} + | grep -P &quot;:.*text&quot; | cut -d: -f1
  16. # Using old school `find` (old and busted)
  17. find /tmp/ -exec file {} + | grep -P &quot;:.*text&quot; | cut -d: -f1&lt;/code&gt;&lt;/pre&gt;
  18. &lt;p&gt;These rely on the &lt;code&gt;file&lt;/code&gt; command to determine what the filetype is.&lt;/p&gt;</description>
  19. <pubDate>Fri, 06 Jun 2025 18:30:02 -0700</pubDate>
  20. </item>
  21. <item>
  22. <guid isPermaLink="true">http://www.perturb.org/display/entry/1428/</guid>
  23. <title>Javascript: Copy string to clipboard</title>
  24. <link>http://www.perturb.org/display/entry/1428/</link>
  25. <description>&lt;p&gt;I needed a modern way to copy a string to the clipboard in JavaScript. &lt;a href=&quot;https://claude.ai&quot;&gt;Claude.ai&lt;/a&gt; helped me come up with this:&lt;/p&gt;
  26. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;// With async/await
  27. async function copyToClipboard(text) {
  28.    try {
  29.        await navigator.clipboard.writeText(text);
  30.        console.log(&#039;Copied to clipboard&#039;);
  31.    } catch (err) {
  32.        console.error(&#039;Failed to copy: &#039;, err);
  33.    }
  34. }&lt;/code&gt;&lt;/pre&gt;
  35. &lt;p&gt;Then you simply call it with a string&lt;/p&gt;
  36. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;copyToClipboard(&quot;Hello world&quot;);&lt;/code&gt;&lt;/pre&gt;</description>
  37. <pubDate>Tue, 03 Jun 2025 15:25:29 -0700</pubDate>
  38. </item>
  39. <item>
  40. <guid isPermaLink="true">http://www.perturb.org/display/entry/1427/</guid>
  41. <title>Rocky 10 package versions</title>
  42. <link>http://www.perturb.org/display/entry/1427/</link>
  43. <description>&lt;p&gt;RedHat Enterprise Linux/Rocky 10 has these versions of packages:&lt;/p&gt;
  44. &lt;table&gt;
  45. &lt;thead&gt;
  46. &lt;tr&gt;
  47. &lt;th&gt;Package&lt;/th&gt;
  48. &lt;th&gt;Version&lt;/th&gt;
  49. &lt;/tr&gt;
  50. &lt;/thead&gt;
  51. &lt;tbody&gt;
  52. &lt;tr&gt;
  53. &lt;td&gt;Apache&lt;/td&gt;
  54. &lt;td&gt;2.4.63&lt;/td&gt;
  55. &lt;/tr&gt;
  56. &lt;tr&gt;
  57. &lt;td&gt;GCC&lt;/td&gt;
  58. &lt;td&gt;14.2.1&lt;/td&gt;
  59. &lt;/tr&gt;
  60. &lt;tr&gt;
  61. &lt;td&gt;Git&lt;/td&gt;
  62. &lt;td&gt;2.47.1&lt;/td&gt;
  63. &lt;/tr&gt;
  64. &lt;tr&gt;
  65. &lt;td&gt;Kernel&lt;/td&gt;
  66. &lt;td&gt;6.12&lt;/td&gt;
  67. &lt;/tr&gt;
  68. &lt;tr&gt;
  69. &lt;td&gt;MariaDB&lt;/td&gt;
  70. &lt;td&gt;10.11.11&lt;/td&gt;
  71. &lt;/tr&gt;
  72. &lt;tr&gt;
  73. &lt;td&gt;OpenSSH&lt;/td&gt;
  74. &lt;td&gt;9.9p1&lt;/td&gt;
  75. &lt;/tr&gt;
  76. &lt;tr&gt;
  77. &lt;td&gt;Perl&lt;/td&gt;
  78. &lt;td&gt;5.40.2&lt;/td&gt;
  79. &lt;/tr&gt;
  80. &lt;tr&gt;
  81. &lt;td&gt;PHP&lt;/td&gt;
  82. &lt;td&gt;8.3.19&lt;/td&gt;
  83. &lt;/tr&gt;
  84. &lt;tr&gt;
  85. &lt;td&gt;Vim&lt;/td&gt;
  86. &lt;td&gt;9.1.83&lt;/td&gt;
  87. &lt;/tr&gt;
  88. &lt;/tbody&gt;
  89. &lt;/table&gt;</description>
  90. <pubDate>Mon, 02 Jun 2025 15:10:07 -0700</pubDate>
  91. </item>
  92. <item>
  93. <guid isPermaLink="true">http://www.perturb.org/display/entry/1426/</guid>
  94. <title>Javascript: Returning data from an AJAX call</title>
  95. <link>http://www.perturb.org/display/entry/1426/</link>
  96. <description>&lt;p&gt;Javascript is by it&#039;s nature asynchronous, which makes returning data from an AJAX call complicated. Modern Javascript uses the concept of a &quot;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise&quot;&gt;promise&lt;/a&gt;&quot; 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 &lt;a href=&quot;https://api.jquery.com/deferred.then/&quot;&gt;&lt;code&gt;then()&lt;/code&gt;&lt;/a&gt; function. A simple example is as follows:&lt;/p&gt;
  97. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function getData() {
  98.    return $.ajax({
  99.        url: &#039;/api/data&#039;
  100.    });
  101. }
  102. // Usage
  103. getData().then(function(data) {
  104.    console.log(data);
  105. });&lt;/code&gt;&lt;/pre&gt;</description>
  106. <pubDate>Wed, 28 May 2025 19:59:48 -0700</pubDate>
  107. </item>
  108. <item>
  109. <guid isPermaLink="true">http://www.perturb.org/display/entry/1425/</guid>
  110. <title>PHP: Generate secure password hashes from the CLI</title>
  111. <link>http://www.perturb.org/display/entry/1425/</link>
  112. <description>&lt;p&gt;The &lt;code&gt;password_hash()&lt;/code&gt; 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.&lt;/p&gt;
  113. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;php -r &#039;echo &quot;Password: &quot;; $pwd = trim(fgets(STDIN)); echo password_hash($pwd, PASSWORD_DEFAULT) . &quot;\n&quot;;&#039;&lt;/code&gt;&lt;/pre&gt;</description>
  114. <pubDate>Sat, 24 May 2025 20:13:35 -0700</pubDate>
  115. </item>
  116. <item>
  117. <guid isPermaLink="true">http://www.perturb.org/display/entry/1424/</guid>
  118. <title>Vim: Insert a line of characters</title>
  119. <link>http://www.perturb.org/display/entry/1424/</link>
  120. <description>&lt;p&gt;I need an 80 character divider of text in Vim. I can never remember the sequence so I&#039;m writing it down:&lt;/p&gt;
  121. &lt;pre&gt;&lt;code&gt;80i/&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  122. &lt;p&gt;Will generate:&lt;/p&gt;
  123. &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;////////////////////////////////////////////////////////////////////////////////&lt;/code&gt;&lt;/pre&gt;</description>
  124. <pubDate>Tue, 01 Apr 2025 00:00:00 -0700</pubDate>
  125. </item>
  126. <item>
  127. <guid isPermaLink="true">http://www.perturb.org/display/entry/1423/</guid>
  128. <title>Comparing 32bit and 64bit performance on low end micro-controllers</title>
  129. <link>http://www.perturb.org/display/entry/1423/</link>
  130. <description>&lt;p&gt;Testing 32bit vs 64bit PRNGs on a 32bit ESP32-C3 &lt;a href=&quot;https://gist.github.com/scottchiefbaker/e4c87de8d6c1ad4a33b1ffe5a3ce707f&quot;&gt;I&#039;m seeing&lt;/a&gt;:&lt;/p&gt;
  131. &lt;table&gt;
  132. &lt;thead&gt;
  133. &lt;tr&gt;
  134. &lt;th&gt;PRNG&lt;/th&gt;
  135. &lt;th&gt;Iterations per second&lt;/th&gt;
  136. &lt;th&gt;Output Bits&lt;/th&gt;
  137. &lt;th&gt;Bytes per second&lt;/th&gt;
  138. &lt;/tr&gt;
  139. &lt;/thead&gt;
  140. &lt;tbody&gt;
  141. &lt;tr&gt;
  142. &lt;td&gt;pcg32&lt;/td&gt;
  143. &lt;td&gt;487802&lt;/td&gt;
  144. &lt;td&gt;32&lt;/td&gt;
  145. &lt;td&gt;&lt;strong&gt;1951266.7 b/s&lt;/strong&gt;&lt;/td&gt;
  146. &lt;/tr&gt;
  147. &lt;tr&gt;
  148. &lt;td&gt;xoroshiro64**&lt;/td&gt;
  149. &lt;td&gt;&lt;strong&gt;516023&lt;/strong&gt;&lt;/td&gt;
  150. &lt;td&gt;32&lt;/td&gt;
  151. &lt;td&gt;2050966.7 b/s&lt;/td&gt;
  152. &lt;/tr&gt;
  153. &lt;tr&gt;
  154. &lt;td&gt;xoshiro256+&lt;/td&gt;
  155. &lt;td&gt;487808&lt;/td&gt;
  156. &lt;td&gt;64&lt;/td&gt;
  157. &lt;td&gt;&lt;strong&gt;3878726.7 b/s&lt;/strong&gt;&lt;/td&gt;
  158. &lt;/tr&gt;
  159. &lt;tr&gt;
  160. &lt;td&gt;xoshiro512++&lt;/td&gt;
  161. &lt;td&gt;441735&lt;/td&gt;
  162. &lt;td&gt;64&lt;/td&gt;
  163. &lt;td&gt;3514373.3 b/s&lt;/td&gt;
  164. &lt;/tr&gt;
  165. &lt;tr&gt;
  166. &lt;td&gt;splitmix64&lt;/td&gt;
  167. &lt;td&gt;462290&lt;/td&gt;
  168. &lt;td&gt;64&lt;/td&gt;
  169. &lt;td&gt;3677033.3 b/s&lt;/td&gt;
  170. &lt;/tr&gt;
  171. &lt;tr&gt;
  172. &lt;td&gt;pcg64&lt;/td&gt;
  173. &lt;td&gt;&lt;strong&gt;416297&lt;/strong&gt;&lt;/td&gt;
  174. &lt;td&gt;64&lt;/td&gt;
  175. &lt;td&gt;3313060.0 b/s&lt;/td&gt;
  176. &lt;/tr&gt;
  177. &lt;/tbody&gt;
  178. &lt;/table&gt;
  179. &lt;p&gt;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.&lt;/p&gt;</description>
  180. <pubDate>Wed, 05 Mar 2025 13:47:09 -0800</pubDate>
  181. </item>
  182. <item>
  183. <guid isPermaLink="true">http://www.perturb.org/display/entry/1422/</guid>
  184. <title>Vim: Convert your syntax highlighted text into HTML</title>
  185. <link>http://www.perturb.org/display/entry/1422/</link>
  186. <description>&lt;p&gt;Vim is my code editor of choice as it has great features, excellent syntax highlighting, and a robust plug-in infrastructure. I&#039;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:&lt;/p&gt;
  187. &lt;pre&gt;&lt;code&gt;:TOhtml&lt;/code&gt;&lt;/pre&gt;
  188. &lt;p&gt;Simply run the &lt;code&gt;:TOhtml&lt;/code&gt; 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 &lt;a href=&quot;https://www.perturb.org/code/pcg32.pl.html&quot;&gt;converted to HTML&lt;/a&gt;.&lt;/p&gt;</description>
  189. <pubDate>Wed, 26 Feb 2025 00:00:00 -0800</pubDate>
  190. </item>
  191. <item>
  192. <guid isPermaLink="true">http://www.perturb.org/display/entry/1421/</guid>
  193. <title>What kind of number makes a good seed for a PRNG?</title>
  194. <link>http://www.perturb.org/display/entry/1421/</link>
  195. <description>&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Pseudorandom_number_generator&quot;&gt;Pseudo-random number generators&lt;/a&gt; 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 &lt;strong&gt;only&lt;/strong&gt; do math, which makes generating a random number difficult. &lt;/p&gt;
  196. &lt;p&gt;PRNGs need a &quot;seed&quot; 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.&lt;/p&gt;
  197. &lt;p&gt;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.&lt;/p&gt;
  198. &lt;p&gt;&lt;code&gt;12&lt;/code&gt; is a small number and &lt;strong&gt;not&lt;/strong&gt; a good seed, &lt;code&gt;4611686018427387906&lt;/code&gt; is a big number but still not a great seed. Seeds should &lt;strong&gt;not&lt;/strong&gt; 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:&lt;/p&gt;
  199. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Horrible
  200. $ perl -E &#039;printf(&quot;%064b\n&quot;, 4611686018427387906)&#039;
  201. 0100000000000000000000000000000000000000000000000000000000000010
  202. # Bad
  203. $ perl -E &#039;printf(&quot;%064b\n&quot;, 17770)&#039;
  204. 0000000000000000000000000000000000000000000000000100010101101010
  205. # Poor
  206. $ perl -E &#039;printf(&quot;%064b\n&quot;, 2850756010)&#039;
  207. 0000000000000000000000000000000010101001111010110001010110101010
  208. # Good
  209. $ perl -E &#039;printf(&quot;%064b\n&quot;, 11337502976607798025)&#039;
  210. 1001110101010110111001101110001101111000101001000100001100001001&lt;/code&gt;&lt;/pre&gt;
  211. &lt;p&gt;Good seeds should have a &lt;em&gt;roughly&lt;/em&gt; even mix of zero and one bits. &lt;code&gt;9223372036854775808&lt;/code&gt; 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 &lt;a href=&quot;https://www.perturb.org/code/seed_quality.pl&quot;&gt;seed_quality.pl&lt;/a&gt;. Quality above 75% should make for good seed numbers.&lt;/p&gt;
  212. &lt;p&gt;Seeds should &lt;strong&gt;not&lt;/strong&gt; 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 &lt;em&gt;if&lt;/em&gt; 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 &lt;a href=&quot;https://en.wikipedia.org/wiki/Address_space_layout_randomization&quot;&gt;ASLR&lt;/a&gt; is in use is a potentially good source as well.&lt;/p&gt;
  213. &lt;p&gt;Hashing numbers, strings, or combinations of numbers can be a good way to generate seeds. Hashing a value with &lt;a href=&quot;https://github.com/scottchiefbaker/perl-Crypt-Komihash&quot;&gt;Komihash&lt;/a&gt; or &lt;a href=&quot;https://metacpan.org/pod/Digest::xxHash&quot;&gt;xxHash&lt;/a&gt; will generate a suitable 64bit number. Hashing a value with &lt;a href=&quot;https://metacpan.org/pod/Digest::SHA&quot;&gt;SHA256&lt;/a&gt; will generate a 256bit value which can be &lt;a href=&quot;https://www.perturb.org/display/1415_Perl_Using_sha256_to_hash_strings_into_integers.html&quot;&gt;split&lt;/a&gt; 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.&lt;/p&gt;
  214. &lt;p&gt;The best source of seed numbers is directly from your OS. On Linux this is &lt;code&gt;/dev/urandom&lt;/code&gt; and on Windows you can interface with the &lt;code&gt;RtlGenRandom&lt;/code&gt; API. These are carefully curated sources of &lt;em&gt;true&lt;/em&gt; randomness, but they can be slow-ish. Using them as a source for a fast PRNG is best practice.&lt;/p&gt;
  215. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub get_64bit_seed {
  216.    open my $urandom, &#039;&amp;lt;:raw&#039;, &#039;/dev/urandom&#039; or croak(&quot;Couldn&#039;t open /dev/urandom: $!&quot;);
  217.    sysread($urandom, my $buf, 8) or croak(&quot;Couldn&#039;t read from csprng: $!&quot;);
  218.    return unpack(&quot;Q*&quot;, $buf);
  219. }&lt;/code&gt;&lt;/pre&gt;</description>
  220. <pubDate>Thu, 20 Feb 2025 00:00:00 -0800</pubDate>
  221. </item>
  222. <item>
  223. <guid isPermaLink="true">http://www.perturb.org/display/entry/1420/</guid>
  224. <title>Perl: Multiply-Shift Hash</title>
  225. <link>http://www.perturb.org/display/entry/1420/</link>
  226. <description>&lt;p&gt;I&#039;ve been using the multiply-shift hash lately and have had good results. It&#039;s simple, fast, and well tested. &lt;/p&gt;
  227. &lt;pre&gt;&lt;code class=&quot;language-c&quot;&gt;// Multiply-Shift Hash
  228. static uint64_t hash_msh(uint64_t x) {
  229.    uint64_t prime = 0x9e3779b97f4a7c15; // A large prime constant
  230.    x ^= (x &amp;gt;&amp;gt; 30);
  231.    x *= prime;
  232.    x ^= (x &amp;gt;&amp;gt; 27);
  233.    x *= prime;
  234.    x ^= (x &amp;gt;&amp;gt; 31);
  235.    return x;
  236. }&lt;/code&gt;&lt;/pre&gt;
  237. &lt;p&gt;Whenever I find interesting code like this I like to try and implement it in Perl:&lt;/p&gt;
  238. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub hash_msh {
  239.    my $x     = $_[0];
  240.    my $prime = 11400714819323198485;
  241.    $x ^= ($x &amp;gt;&amp;gt; 30);
  242.    $x = multiply_uv($x, $prime);
  243.    $x ^= ($x &amp;gt;&amp;gt; 27);
  244.    $x = multiply_uv($x, $prime);
  245.    $x ^= ($x &amp;gt;&amp;gt; 31);
  246.    return $x;
  247. }
  248. # Perl converts numbers larger than 2^64 - 1 to floating point so
  249. # we &#039;use integer&#039; to force integer math which retains any overflow.
  250. sub multiply_uv {
  251.    my ($one, $two) = @_;
  252.    use integer;
  253.    my $ret = $one * $two;
  254.    no integer;
  255.    # Convert signed IV to unsinged UV
  256.    if ($ret &amp;lt; 0) {
  257.        $ret += 18446744073709551615;
  258.        $ret += 1;
  259.    }
  260.    return $ret;
  261. }&lt;/code&gt;&lt;/pre&gt;</description>
  262. <pubDate>Mon, 27 Jan 2025 00:00:00 -0800</pubDate>
  263. </item>
  264. <item>
  265. <guid isPermaLink="true">http://www.perturb.org/display/entry/1419/</guid>
  266. <title>Perl: Calculate number of bits needed to store a number</title>
  267. <link>http://www.perturb.org/display/entry/1419/</link>
  268. <description>&lt;p&gt;Quick Perl function to calculate the number of bits required to store a given number.&lt;/p&gt;
  269. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub bits_required {
  270.    my ($n) = @_;
  271.    # Handle special case for 0
  272.    return 0 if $n == 0;
  273.    # Use logarithm to calculate the number of bits
  274.    my $bits = int(log($n) / log(2)) + 1;
  275.    return $bits;
  276. }&lt;/code&gt;&lt;/pre&gt;</description>
  277. <pubDate>Mon, 27 Jan 2025 00:00:00 -0800</pubDate>
  278. </item>
  279. <item>
  280. <guid isPermaLink="true">http://www.perturb.org/display/entry/1418/</guid>
  281. <title>Implmenting PRNGs in Perl</title>
  282. <link>http://www.perturb.org/display/entry/1418/</link>
  283. <description>&lt;p&gt;I&#039;m a big fan of the &lt;a href=&quot;https://www.pcg-random.org/download.html&quot;&gt;PCG32 PRNG&lt;/a&gt;. It&#039;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 &lt;strong&gt;unsigned&lt;/strong&gt; integers and overflow. Most PRNGs use large numbers and overflow to work, that&#039;s their secret sauce.&lt;/p&gt;
  284. &lt;p&gt;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 &lt;code&gt;Math::Int64&lt;/code&gt;. Surprisingly the native version was &lt;em&gt;significantly&lt;/em&gt; faster. &lt;/p&gt;
  285. &lt;p&gt;Both implementations with detailed comments are available in &lt;a href=&quot;https://www.perturb.org/code/syntax_highlight.php?file=pcg32.pl&quot;&gt;pcg32.pl&lt;/a&gt; if you&#039;re interested in learning more about how to do integer style math in Perl. &lt;/p&gt;
  286. &lt;p&gt;As a bonus I also ported the &lt;a href=&quot;https://www.perturb.org/code/syntax_highlight.php?file=xoshiro256.pl&quot;&gt;xoshiro256 family&lt;/a&gt; into Perl. &lt;a href=&quot;https://www.perturb.org/code/syntax_highlight.php?file=splitmix64.pl&quot;&gt;Splitmix64&lt;/a&gt; ended up being a little more complicated to port, but I got it as well.&lt;/p&gt;</description>
  287. <pubDate>Sat, 25 Jan 2025 00:00:00 -0800</pubDate>
  288. </item>
  289. <item>
  290. <guid isPermaLink="true">http://www.perturb.org/display/entry/1417/</guid>
  291. <title>C/C++: List all #define macros</title>
  292. <link>http://www.perturb.org/display/entry/1417/</link>
  293. <description>&lt;p&gt;I need to target a specific platform with some code I&#039;m writing. You can list &lt;strong&gt;all&lt;/strong&gt; of the &lt;code&gt;#define&lt;/code&gt; macros on a given platform with these commands:&lt;/p&gt;
  294. &lt;pre&gt;&lt;code&gt;gcc -dM -E - &amp;lt; /dev/null&lt;/code&gt;&lt;/pre&gt;
  295. &lt;pre&gt;&lt;code&gt;clang -dM -E - &amp;lt; /dev/null&lt;/code&gt;&lt;/pre&gt;
  296. &lt;p&gt;In this big list of macros you should find something to help you target a given platform.&lt;/p&gt;</description>
  297. <pubDate>Wed, 22 Jan 2025 00:00:00 -0800</pubDate>
  298. </item>
  299. <item>
  300. <guid isPermaLink="true">http://www.perturb.org/display/entry/1416/</guid>
  301. <title>FFMPEG: Limit the output to only the encoding stats for quieter scripting</title>
  302. <link>http://www.perturb.org/display/entry/1416/</link>
  303. <description>&lt;p&gt;FFMPEG is a great tool, but it is very chatty. If you want to encode a file you&#039;ll get about 40 lines of headers and track information, most of which you probably will not read. For scripting purposes you probably &lt;strong&gt;only&lt;/strong&gt; 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&lt;/p&gt;
  304. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;ffmpeg -y -hide_banner -loglevel quiet -stats ...&lt;/code&gt;&lt;/pre&gt;</description>
  305. <pubDate>Tue, 21 Jan 2025 00:00:00 -0800</pubDate>
  306. </item>
  307. <item>
  308. <guid isPermaLink="true">http://www.perturb.org/display/entry/1415/</guid>
  309. <title>Perl: Using sha256 to hash strings into integers</title>
  310. <link>http://www.perturb.org/display/entry/1415/</link>
  311. <description>&lt;p&gt;I need 64bit integers to seed some PRNG work I&#039;m doing. I found out that you can easily create four 64bit numbers from any string by using SHA256.&lt;/p&gt;
  312. &lt;pre&gt;&lt;code&gt;use Digest::SHA;
  313. my $input = $ARGV[0] || int(rand() * 1000000);
  314. # Get raw bytes and convert to an array of uint64_t
  315. my $hash = Digest::SHA::sha256($input);
  316. my @nums = unpack(&quot;Q*&quot;, $hash);
  317. print &quot;SHA256 Hashing &#039;$input&#039; to: &quot; . join(&quot;, &quot;, @nums) . &quot;\n&quot;;&lt;/code&gt;&lt;/pre&gt;
  318. &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; We are using &lt;code&gt;sha256&lt;/code&gt; here, not &lt;code&gt;sha256_hex&lt;/code&gt; because we need raw bytes to convert to integers with &lt;code&gt;unpack&lt;/code&gt;.&lt;/p&gt;</description>
  319. <pubDate>Mon, 20 Jan 2025 00:00:00 -0800</pubDate>
  320. </item>
  321. </channel>
  322. </rss>
  323.  

If you would like to create a banner that links to this page (i.e. this validation result), do the following:

  1. Download the "valid RSS" banner.

  2. Upload the image to your own server. (This step is important. Please do not link directly to the image on this server.)

  3. 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

Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda