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/1433/</guid>
  11. <title>Perl: Search and replace a string across your entire code base</title>
  12. <link>http://www.perturb.org/display/entry/1433/</link>
  13. <description>&lt;p&gt;I wanted to rename a function anywhere it was found in my code base. This requires going through every file and directory recursively, and checking each file. Using the Linux &lt;code&gt;find&lt;/code&gt; command we can find &lt;em&gt;all&lt;/em&gt; the files and then hand the search and replace off to Perl. Easy peasy.&lt;/p&gt;
  14. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;find codebase/ -type f -exec perl -pi -E &#039;s/foo/bar/g&#039; {} +&lt;/code&gt;&lt;/pre&gt;
  15. &lt;p&gt;or using &lt;code&gt;fd&lt;/code&gt; instead:&lt;/p&gt;
  16. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;fd . codebase/ --type f --exec-batch -pi -E &#039;s/foo/bar/g&#039; {}&lt;/code&gt;&lt;/pre&gt;</description>
  17. <pubDate>Wed, 20 Aug 2025 08:15:57 -0700</pubDate>
  18. </item>
  19. <item>
  20. <guid isPermaLink="true">http://www.perturb.org/display/entry/1432/</guid>
  21. <title>Linux: Testing for x86_64-v3</title>
  22. <link>http://www.perturb.org/display/entry/1432/</link>
  23. <description>&lt;p&gt;Modern Linux distributions are starting to require &lt;a href=&quot;https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels&quot;&gt;x86_64-v3&lt;/a&gt; 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:&lt;/p&gt;
  24. &lt;pre&gt;&lt;code&gt;/usr/lib64/ld-linux-x86-64.so.2 --help&lt;/code&gt;&lt;/pre&gt;
  25. &lt;p&gt;Basically any CPU made after 2015 will be fine.&lt;/p&gt;</description>
  26. <pubDate>Tue, 29 Jul 2025 16:29:18 -0700</pubDate>
  27. </item>
  28. <item>
  29. <guid isPermaLink="true">http://www.perturb.org/display/entry/1431/</guid>
  30. <title>PHP: Only start a session when it's needed</title>
  31. <link>http://www.perturb.org/display/entry/1431/</link>
  32. <description>&lt;p&gt;I use sessions on my sites for user authentication. Calling &lt;code&gt;session_start()&lt;/code&gt; initiates a session and allows me to check if the user is logged in or not. However, calling &lt;code&gt;session_start()&lt;/code&gt; creates a new session for &lt;strong&gt;every&lt;/strong&gt; hit on your site: bots, unauthenticated users, etc. This can lead to an &lt;em&gt;excess&lt;/em&gt; of session files on your filesystem.&lt;/p&gt;
  33. &lt;p&gt;A better way is to explicitly call &lt;code&gt;start_session()&lt;/code&gt; when your user logs in. On your other pages you can check if the user has the appropriate session cookie and start a session &lt;strong&gt;only&lt;/strong&gt; when it&#039;s needed.&lt;/p&gt;
  34. &lt;pre&gt;&lt;code class=&quot;language-PHP&quot;&gt;function start_session_if_exists() {
  35.    if (isset($_COOKIE[session_name()]) &amp;amp;&amp;amp; session_status() !== PHP_SESSION_ACTIVE) {
  36.        session_start();
  37.    }
  38. }&lt;/code&gt;&lt;/pre&gt;
  39. &lt;p&gt;This will avoid creating a session for every hit on your site.&lt;/p&gt;</description>
  40. <pubDate>Sat, 21 Jun 2025 11:29:02 -0700</pubDate>
  41. </item>
  42. <item>
  43. <guid isPermaLink="true">http://www.perturb.org/display/entry/1430/</guid>
  44. <title>CSS: Selecting text made easy</title>
  45. <link>http://www.perturb.org/display/entry/1430/</link>
  46. <description>&lt;p&gt;You can apply the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/user-select&quot;&gt;user-select&lt;/a&gt; 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 &lt;code&gt;all&lt;/code&gt; 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 &lt;strong&gt;expected&lt;/strong&gt; to copy and paste the text.&lt;/p&gt;
  47. &lt;pre&gt;&lt;code class=&quot;language-css&quot;&gt;.click_select { user-select: all; }&lt;/code&gt;&lt;/pre&gt;
  48. &lt;p&gt;Example:&lt;/p&gt;
  49. &lt;style&gt;
  50.    .click_select {
  51.        user-select: all;
  52.    }
  53.    .test_button {
  54.        border: 1px solid black;
  55.        padding: 12px;
  56.        border-radius: 4px;
  57.        background: darkblue;
  58.    }
  59. &lt;/style&gt;
  60. &lt;p&gt;&lt;span class=&quot;click_select test_button&quot;&gt;Click me!&lt;/span&gt;&lt;/p&gt;</description>
  61. <pubDate>Tue, 17 Jun 2025 09:58:19 -0700</pubDate>
  62. </item>
  63. <item>
  64. <guid isPermaLink="true">http://www.perturb.org/display/entry/1429/</guid>
  65. <title>Linux: Find all the text files in a directory</title>
  66. <link>http://www.perturb.org/display/entry/1429/</link>
  67. <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;
  68. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Using `fd` (new hotness)
  69. fd . /tmp/ --exec file {} + | grep -P &quot;:.*text&quot; | cut -d: -f1
  70. # Using old school `find` (old and busted)
  71. find /tmp/ -exec file {} + | grep -P &quot;:.*text&quot; | cut -d: -f1&lt;/code&gt;&lt;/pre&gt;
  72. &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>
  73. <pubDate>Fri, 06 Jun 2025 18:30:02 -0700</pubDate>
  74. </item>
  75. <item>
  76. <guid isPermaLink="true">http://www.perturb.org/display/entry/1428/</guid>
  77. <title>Javascript: Copy string to clipboard</title>
  78. <link>http://www.perturb.org/display/entry/1428/</link>
  79. <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;
  80. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;// With async/await
  81. async function copyToClipboard(text) {
  82.    try {
  83.        await navigator.clipboard.writeText(text);
  84.        console.log(&#039;Copied to clipboard&#039;);
  85.    } catch (err) {
  86.        console.error(&#039;Failed to copy: &#039;, err);
  87.    }
  88. }&lt;/code&gt;&lt;/pre&gt;
  89. &lt;p&gt;Then you simply call it with a string&lt;/p&gt;
  90. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;copyToClipboard(&quot;Hello world&quot;);&lt;/code&gt;&lt;/pre&gt;</description>
  91. <pubDate>Tue, 03 Jun 2025 15:25:29 -0700</pubDate>
  92. </item>
  93. <item>
  94. <guid isPermaLink="true">http://www.perturb.org/display/entry/1427/</guid>
  95. <title>Rocky 10 package versions</title>
  96. <link>http://www.perturb.org/display/entry/1427/</link>
  97. <description>&lt;p&gt;RedHat Enterprise Linux/Rocky 10 has these versions of packages:&lt;/p&gt;
  98. &lt;table&gt;
  99. &lt;thead&gt;
  100. &lt;tr&gt;
  101. &lt;th&gt;Package&lt;/th&gt;
  102. &lt;th&gt;Version&lt;/th&gt;
  103. &lt;/tr&gt;
  104. &lt;/thead&gt;
  105. &lt;tbody&gt;
  106. &lt;tr&gt;
  107. &lt;td&gt;Apache&lt;/td&gt;
  108. &lt;td&gt;2.4.63&lt;/td&gt;
  109. &lt;/tr&gt;
  110. &lt;tr&gt;
  111. &lt;td&gt;GCC&lt;/td&gt;
  112. &lt;td&gt;14.2.1&lt;/td&gt;
  113. &lt;/tr&gt;
  114. &lt;tr&gt;
  115. &lt;td&gt;Git&lt;/td&gt;
  116. &lt;td&gt;2.47.1&lt;/td&gt;
  117. &lt;/tr&gt;
  118. &lt;tr&gt;
  119. &lt;td&gt;Kernel&lt;/td&gt;
  120. &lt;td&gt;6.12&lt;/td&gt;
  121. &lt;/tr&gt;
  122. &lt;tr&gt;
  123. &lt;td&gt;MariaDB&lt;/td&gt;
  124. &lt;td&gt;10.11.11&lt;/td&gt;
  125. &lt;/tr&gt;
  126. &lt;tr&gt;
  127. &lt;td&gt;OpenSSH&lt;/td&gt;
  128. &lt;td&gt;9.9p1&lt;/td&gt;
  129. &lt;/tr&gt;
  130. &lt;tr&gt;
  131. &lt;td&gt;Perl&lt;/td&gt;
  132. &lt;td&gt;5.40.2&lt;/td&gt;
  133. &lt;/tr&gt;
  134. &lt;tr&gt;
  135. &lt;td&gt;PHP&lt;/td&gt;
  136. &lt;td&gt;8.3.19&lt;/td&gt;
  137. &lt;/tr&gt;
  138. &lt;tr&gt;
  139. &lt;td&gt;Vim&lt;/td&gt;
  140. &lt;td&gt;9.1.83&lt;/td&gt;
  141. &lt;/tr&gt;
  142. &lt;/tbody&gt;
  143. &lt;/table&gt;</description>
  144. <pubDate>Mon, 02 Jun 2025 15:10:07 -0700</pubDate>
  145. </item>
  146. <item>
  147. <guid isPermaLink="true">http://www.perturb.org/display/entry/1426/</guid>
  148. <title>Javascript: Returning data from an AJAX call</title>
  149. <link>http://www.perturb.org/display/entry/1426/</link>
  150. <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;
  151. &lt;pre&gt;&lt;code class=&quot;language-javascript&quot;&gt;function getData() {
  152.    return $.ajax({
  153.        url: &#039;/api/data&#039;
  154.    });
  155. }
  156. // Usage
  157. getData().then(function(data) {
  158.    console.log(data);
  159. });&lt;/code&gt;&lt;/pre&gt;</description>
  160. <pubDate>Wed, 28 May 2025 19:59:48 -0700</pubDate>
  161. </item>
  162. <item>
  163. <guid isPermaLink="true">http://www.perturb.org/display/entry/1425/</guid>
  164. <title>PHP: Generate secure password hashes from the CLI</title>
  165. <link>http://www.perturb.org/display/entry/1425/</link>
  166. <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;
  167. &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>
  168. <pubDate>Sat, 24 May 2025 20:13:35 -0700</pubDate>
  169. </item>
  170. <item>
  171. <guid isPermaLink="true">http://www.perturb.org/display/entry/1424/</guid>
  172. <title>Vim: Insert a line of characters</title>
  173. <link>http://www.perturb.org/display/entry/1424/</link>
  174. <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;
  175. &lt;pre&gt;&lt;code&gt;80i/&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/pre&gt;
  176. &lt;p&gt;Will generate:&lt;/p&gt;
  177. &lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;////////////////////////////////////////////////////////////////////////////////&lt;/code&gt;&lt;/pre&gt;</description>
  178. <pubDate>Tue, 01 Apr 2025 00:00:00 -0700</pubDate>
  179. </item>
  180. <item>
  181. <guid isPermaLink="true">http://www.perturb.org/display/entry/1423/</guid>
  182. <title>Comparing 32bit and 64bit performance on low end micro-controllers</title>
  183. <link>http://www.perturb.org/display/entry/1423/</link>
  184. <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;
  185. &lt;table&gt;
  186. &lt;thead&gt;
  187. &lt;tr&gt;
  188. &lt;th&gt;PRNG&lt;/th&gt;
  189. &lt;th&gt;Iterations per second&lt;/th&gt;
  190. &lt;th&gt;Output Bits&lt;/th&gt;
  191. &lt;th&gt;Bytes per second&lt;/th&gt;
  192. &lt;/tr&gt;
  193. &lt;/thead&gt;
  194. &lt;tbody&gt;
  195. &lt;tr&gt;
  196. &lt;td&gt;pcg32&lt;/td&gt;
  197. &lt;td&gt;487802&lt;/td&gt;
  198. &lt;td&gt;32&lt;/td&gt;
  199. &lt;td&gt;&lt;strong&gt;1951266.7 b/s&lt;/strong&gt;&lt;/td&gt;
  200. &lt;/tr&gt;
  201. &lt;tr&gt;
  202. &lt;td&gt;xoroshiro64**&lt;/td&gt;
  203. &lt;td&gt;&lt;strong&gt;516023&lt;/strong&gt;&lt;/td&gt;
  204. &lt;td&gt;32&lt;/td&gt;
  205. &lt;td&gt;2050966.7 b/s&lt;/td&gt;
  206. &lt;/tr&gt;
  207. &lt;tr&gt;
  208. &lt;td&gt;xoshiro256+&lt;/td&gt;
  209. &lt;td&gt;487808&lt;/td&gt;
  210. &lt;td&gt;64&lt;/td&gt;
  211. &lt;td&gt;&lt;strong&gt;3878726.7 b/s&lt;/strong&gt;&lt;/td&gt;
  212. &lt;/tr&gt;
  213. &lt;tr&gt;
  214. &lt;td&gt;xoshiro512++&lt;/td&gt;
  215. &lt;td&gt;441735&lt;/td&gt;
  216. &lt;td&gt;64&lt;/td&gt;
  217. &lt;td&gt;3514373.3 b/s&lt;/td&gt;
  218. &lt;/tr&gt;
  219. &lt;tr&gt;
  220. &lt;td&gt;splitmix64&lt;/td&gt;
  221. &lt;td&gt;462290&lt;/td&gt;
  222. &lt;td&gt;64&lt;/td&gt;
  223. &lt;td&gt;3677033.3 b/s&lt;/td&gt;
  224. &lt;/tr&gt;
  225. &lt;tr&gt;
  226. &lt;td&gt;pcg64&lt;/td&gt;
  227. &lt;td&gt;&lt;strong&gt;416297&lt;/strong&gt;&lt;/td&gt;
  228. &lt;td&gt;64&lt;/td&gt;
  229. &lt;td&gt;3313060.0 b/s&lt;/td&gt;
  230. &lt;/tr&gt;
  231. &lt;/tbody&gt;
  232. &lt;/table&gt;
  233. &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>
  234. <pubDate>Wed, 05 Mar 2025 13:47:09 -0800</pubDate>
  235. </item>
  236. <item>
  237. <guid isPermaLink="true">http://www.perturb.org/display/entry/1422/</guid>
  238. <title>Vim: Convert your syntax highlighted text into HTML</title>
  239. <link>http://www.perturb.org/display/entry/1422/</link>
  240. <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;
  241. &lt;pre&gt;&lt;code&gt;:TOhtml&lt;/code&gt;&lt;/pre&gt;
  242. &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>
  243. <pubDate>Wed, 26 Feb 2025 00:00:00 -0800</pubDate>
  244. </item>
  245. <item>
  246. <guid isPermaLink="true">http://www.perturb.org/display/entry/1421/</guid>
  247. <title>What kind of number makes a good seed for a PRNG?</title>
  248. <link>http://www.perturb.org/display/entry/1421/</link>
  249. <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;
  250. &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;
  251. &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;
  252. &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;
  253. &lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;# Horrible
  254. $ perl -E &#039;printf(&quot;%064b\n&quot;, 4611686018427387906)&#039;
  255. 0100000000000000000000000000000000000000000000000000000000000010
  256. # Bad
  257. $ perl -E &#039;printf(&quot;%064b\n&quot;, 17770)&#039;
  258. 0000000000000000000000000000000000000000000000000100010101101010
  259. # Poor
  260. $ perl -E &#039;printf(&quot;%064b\n&quot;, 2850756010)&#039;
  261. 0000000000000000000000000000000010101001111010110001010110101010
  262. # Good
  263. $ perl -E &#039;printf(&quot;%064b\n&quot;, 11337502976607798025)&#039;
  264. 1001110101010110111001101110001101111000101001000100001100001001&lt;/code&gt;&lt;/pre&gt;
  265. &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;
  266. &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;
  267. &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;
  268. &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;
  269. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub get_64bit_seed {
  270.    open my $urandom, &#039;&amp;lt;:raw&#039;, &#039;/dev/urandom&#039; or croak(&quot;Couldn&#039;t open /dev/urandom: $!&quot;);
  271.    sysread($urandom, my $buf, 8) or croak(&quot;Couldn&#039;t read from csprng: $!&quot;);
  272.    return unpack(&quot;Q*&quot;, $buf);
  273. }&lt;/code&gt;&lt;/pre&gt;</description>
  274. <pubDate>Thu, 20 Feb 2025 00:00:00 -0800</pubDate>
  275. </item>
  276. <item>
  277. <guid isPermaLink="true">http://www.perturb.org/display/entry/1420/</guid>
  278. <title>Perl: Multiply-Shift Hash</title>
  279. <link>http://www.perturb.org/display/entry/1420/</link>
  280. <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;
  281. &lt;pre&gt;&lt;code class=&quot;language-c&quot;&gt;// Multiply-Shift Hash
  282. static uint64_t hash_msh(uint64_t x) {
  283.    uint64_t prime = 0x9e3779b97f4a7c15; // A large prime constant
  284.    x ^= (x &amp;gt;&amp;gt; 30);
  285.    x *= prime;
  286.    x ^= (x &amp;gt;&amp;gt; 27);
  287.    x *= prime;
  288.    x ^= (x &amp;gt;&amp;gt; 31);
  289.    return x;
  290. }&lt;/code&gt;&lt;/pre&gt;
  291. &lt;p&gt;Whenever I find interesting code like this I like to try and implement it in Perl:&lt;/p&gt;
  292. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub hash_msh {
  293.    my $x     = $_[0];
  294.    my $prime = 11400714819323198485;
  295.    $x ^= ($x &amp;gt;&amp;gt; 30);
  296.    $x = multiply_uv($x, $prime);
  297.    $x ^= ($x &amp;gt;&amp;gt; 27);
  298.    $x = multiply_uv($x, $prime);
  299.    $x ^= ($x &amp;gt;&amp;gt; 31);
  300.    return $x;
  301. }
  302. # Perl converts numbers larger than 2^64 - 1 to floating point so
  303. # we &#039;use integer&#039; to force integer math which retains any overflow.
  304. sub multiply_uv {
  305.    my ($one, $two) = @_;
  306.    use integer;
  307.    my $ret = $one * $two;
  308.    no integer;
  309.    # Convert signed IV to unsinged UV
  310.    if ($ret &amp;lt; 0) {
  311.        $ret += 18446744073709551615;
  312.        $ret += 1;
  313.    }
  314.    return $ret;
  315. }&lt;/code&gt;&lt;/pre&gt;</description>
  316. <pubDate>Mon, 27 Jan 2025 00:00:00 -0800</pubDate>
  317. </item>
  318. <item>
  319. <guid isPermaLink="true">http://www.perturb.org/display/entry/1419/</guid>
  320. <title>Perl: Calculate number of bits needed to store a number</title>
  321. <link>http://www.perturb.org/display/entry/1419/</link>
  322. <description>&lt;p&gt;Quick Perl function to calculate the number of bits required to store a given number.&lt;/p&gt;
  323. &lt;pre&gt;&lt;code class=&quot;language-perl&quot;&gt;sub bits_required {
  324.    my ($n) = @_;
  325.    # Handle special case for 0
  326.    return 0 if $n == 0;
  327.    # Use logarithm to calculate the number of bits
  328.    my $bits = int(log($n) / log(2)) + 1;
  329.    return $bits;
  330. }&lt;/code&gt;&lt;/pre&gt;</description>
  331. <pubDate>Mon, 27 Jan 2025 00:00:00 -0800</pubDate>
  332. </item>
  333. </channel>
  334. </rss>
  335.  

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