Sorry

This feed does not validate.

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.

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

  1. <br />
  2. <b>Warning</b>:  Undefined variable $out in <b>/home/bakers/html/perturb.class.php</b> on line <b>1197</b><br />
  3. <br />
  4. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  5. <br />
  6. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  7. <br />
  8. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  9. <br />
  10. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  11. <br />
  12. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  13. <br />
  14. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  15. <br />
  16. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  17. <br />
  18. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  19. <br />
  20. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  21. <br />
  22. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  23. <br />
  24. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  25. <br />
  26. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  27. <br />
  28. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  29. <br />
  30. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  31. <br />
  32. <b>Warning</b>:  Undefined variable $summary in <b>/home/bakers/html/perturb.class.php</b> on line <b>1236</b><br />
  33. <?xml version="1.0" encoding="iso-8859-1"?>
  34. <?xml-stylesheet type="text/css" href="/css/atom-browser.css" ?>
  35. <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>
  36. <modified>2024-03-28T21:52:36-07:00</modified> <link rel="alternate" type="text/html" href="http://www.perturb.org" /> <tagline>Geek blog</tagline>
  37. <id>tag:www.perturb.org,2024://03</id>
  38. <generator>Perturb ATOM v0.1</generator>
  39. <entry xmlns="http://purl.org/atom/ns#">
  40. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1396/" />
  41. <title mode="escaped">Perl: Matching multiple patterns with a regex</title>
  42. <modified>2024-02-16T00:00:00-08:00</modified>
  43. <issued>2024-02-16T00:00:00-08:00</issued>
  44. <created>2024-02-16T00:00:00-08:00</created>
  45. <id>http://www.perturb.org/display/entry/1396/</id>
  46. <summary type="text/plain"></summary>
  47. <author>
  48. <name>Scott Baker</name>
  49. <url>http://www.perturb.org/</url>
  50. <email>scott@perturb.org</email>
  51. </author>
  52. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  53. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  54.  
  55. Perl has regular expressions built in to the core of the language and they are very powerful. It's easy enough to find a single match with a regexp: <br />
  56. <br />
  57. ``` <br />
  58. # Find the *first* three letter word in the string <br />
  59. my $str = "one two three four five six seven eight nine ten"; <br />
  60. my @x   = $str =~ m/\b(\w{3})\b/; # ("one") <br />
  61. ``` <br />
  62. <br />
  63. If you want to find _all_ of the three letter words you can add the `g` [modifier](https://perldoc.perl.org/perlre#Modifiers) to the end of your regex to tell it to match "globally". <br />
  64. <br />
  65. ``` <br />
  66. # Find *all* the three letter words <br />
  67. my $str = "one two three four five six seven eight nine ten"; <br />
  68. my @x   = $str =~ m/\b(\w{3})\b/g; # ("one", "two", "six", "ten") <br />
  69. ``` <br />
  70. <br />
  71. You can also iterate on your global regexp if you want to get the matches one at a time: <br />
  72. <br />
  73. ``` <br />
  74. my $str = "one two three four five six seven eight nine ten"; <br />
  75. my @x   = (); <br />
  76. while ($str =~ m/\b(\w{3})\b/g) { <br />
  77. push(@x, $1); <br />
  78. } <br />
  79. <br />
  80. print join(",", @x); # "one,two,six,ten" <br />
  81. ```
  82. ]]>
  83. </content>
  84. </entry>
  85. <entry xmlns="http://purl.org/atom/ns#">
  86. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1395/" />
  87. <title mode="escaped">PHP: Disable PrivateTmp</title>
  88. <modified>2024-01-31T00:00:00-08:00</modified>
  89. <issued>2024-01-31T00:00:00-08:00</issued>
  90. <created>2024-01-31T00:00:00-08:00</created>
  91. <id>http://www.perturb.org/display/entry/1395/</id>
  92. <summary type="text/plain"></summary>
  93. <author>
  94. <name>Scott Baker</name>
  95. <url>http://www.perturb.org/</url>
  96. <email>scott@perturb.org</email>
  97. </author>
  98. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  99. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  100.  
  101. Rocky Linux uses [**PrivateTmp**](https://systemd.io/TEMPORARY_DIRECTORIES/) to give each process it's own walled off section of `/tmp/`. This is good for security sometimes, but it can also lead to frustration because files written to `/tmp/` or `/var/tmp/` will not show up when you need to debug. To disable **PrivateTmp** for php-fpm you need to modify the systemd configuration for php-fpm. This is done by running `systemctl edit php-fpm` and adding a section that says: <br />
  102. <br />
  103. ``` <br />
  104. [Service] <br />
  105. PrivateTmp=false <br />
  106. ``` <br />
  107. <br />
  108. Once the change is in place you will need to `systemctl daemon-reload` and then restart `systemctl restart php-fpm`. <br />
  109. <br />
  110. **Note:** Borrowed from [Stack Overflow](https://stackoverflow.com/questions/68098031/how-to-set-privatetmp-false-permanently-in-ubuntu-18-04).
  111. ]]>
  112. </content>
  113. </entry>
  114. <entry xmlns="http://purl.org/atom/ns#">
  115. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1394/" />
  116. <title mode="escaped">Kea DHCP4 systemd file</title>
  117. <modified>2024-01-25T13:53:49-08:00</modified>
  118. <issued>2024-01-25T13:53:49-08:00</issued>
  119. <created>2024-01-25T13:53:49-08:00</created>
  120. <id>http://www.perturb.org/display/entry/1394/</id>
  121. <summary type="text/plain"></summary>
  122. <author>
  123. <name>Scott Baker</name>
  124. <url>http://www.perturb.org/</url>
  125. <email>scott@perturb.org</email>
  126. </author>
  127. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  128. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  129.  
  130. I'm using Kea as a DHCP server and I need the service to start on boot. I'm not sure why it doesn't ship with a systemd `.service` file. Here is the file I ended up using: <br />
  131. <br />
  132. ``` <br />
  133. # Put this in /etc/systemd/system/kea-dhcp4.service <br />
  134. # Reload systemd so it picks it up `systemctl daemon-reload` <br />
  135. # Enable it on boot: `systemctl enable kea-dhcp4` <br />
  136. <br />
  137. [Unit] <br />
  138. Description=ISC KEA IPv4 DHCP daemon <br />
  139. Documentation=man:kea-dhcp4(8) <br />
  140. Wants=network-online.target mariadb.service <br />
  141. Requires=kea-ctrl-agent.service <br />
  142. After=network-online.target mariadb.service mysql.service <br />
  143. <br />
  144. [Service] <br />
  145. ExecStart=/usr/sbin/kea-dhcp4 -c /etc/kea/kea-dhcp4.conf <br />
  146. <br />
  147. [Install] <br />
  148. WantedBy=multi-user.target <br />
  149. ``` <br />
  150. <br />
  151. This is borrowed from [Skywalker-11](https://gist.github.com/Skywalker-11/29ab856ed3c88f0eadc6e833f32fa78a).
  152. ]]>
  153. </content>
  154. </entry>
  155. <entry xmlns="http://purl.org/atom/ns#">
  156. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1393/" />
  157. <title mode="escaped">Basic snmpd.conf file to monitor ethernet ports of a Linux box</title>
  158. <modified>2024-01-12T00:00:00-08:00</modified>
  159. <issued>2024-01-12T00:00:00-08:00</issued>
  160. <created>2024-01-12T00:00:00-08:00</created>
  161. <id>http://www.perturb.org/display/entry/1393/</id>
  162. <summary type="text/plain"></summary>
  163. <author>
  164. <name>Scott Baker</name>
  165. <url>http://www.perturb.org/</url>
  166. <email>scott@perturb.org</email>
  167. </author>
  168. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  169. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  170.  
  171. I need to monitor the Ethernet interfaces of a Linux VM. This is the perfect job for `snmpd` which you can get by installing `net-snmp` and then applying a basic config. Here is a simplified config that will get you basic read-only access for a community and subnet. <br />
  172. <br />
  173. ``` <br />
  174. # /etc/snmp/snmpd.conf <br />
  175. rocommunity snmp-read 165.92.231.0/24 <br />
  176. rocommunity snmp-read 10.3.1.0/24 <br />
  177. rocommunity snmp-read localhost <br />
  178. syslocation "City, State" <br />
  179. syscontact  "Admin <user@domain.com>" <br />
  180. ``` <br />
  181. <br />
  182. You can test your new SNMP configuration with `snmpwalk` <br />
  183. <br />
  184. ``` <br />
  185. snmpwalk -v 2c -c snmp-read 127.0.0.1 <br />
  186. ```
  187. ]]>
  188. </content>
  189. </entry>
  190. <entry xmlns="http://purl.org/atom/ns#">
  191. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1392/" />
  192. <title mode="escaped">Books of 2024</title>
  193. <modified>2024-01-01T00:00:00-08:00</modified>
  194. <issued>2024-01-01T00:00:00-08:00</issued>
  195. <created>2024-01-01T00:00:00-08:00</created>
  196. <id>http://www.perturb.org/display/entry/1392/</id>
  197. <summary type="text/plain"></summary>
  198. <author>
  199. <name>Scott Baker</name>
  200. <url>http://www.perturb.org/</url>
  201. <email>scott@perturb.org</email>
  202. </author>
  203. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  204. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  205.  
  206. List of books I read in 2024. Also see the list of [2023](https://www.perturb.org/display/1371_Books_of_2023.html). The date indicated denotes the date I started reading the book.   <br />
  207. <br />
  208. ### [Drizzt novels](https://en.wikipedia.org/wiki/The_Legend_of_Drizzt) <br />
  209. 2024-01-08 - [Homeland - Drizzt #1](//www.google.com/search?tbo=p&q=isbn+9780786939534) by R. A. Salvatore - 343 pages   <br />
  210. 2024-02-06 - [Exile - Drizzt #2](//www.google.com/search?tbo=p&q=isbn+9780786939831) by R. A. Salvatore - 343 pages     <br />
  211. 2024-xx-xx - [Sojourn - Drizzt #3](//www.google.com/search?tbo=p&q=isbn+9780786940073) by R. A. Salvatore - 346 pages     <br />
  212. 2024-xx-xx - [The Crystal Shard - Drizzt #4](//www.google.com/search?tbo=p&q=isbn+9780786942466) by R. A. Salvatore - 344 pages     <br />
  213. 2024-xx-xx - [Streams Of Silver - Drizzt #5](//www.google.com/search?tbo=p&q=isbn+9780786942657) by R. A. Salvatore - 377 pages     <br />
  214. 2024-xx-xx - [The Halfling's Gem - Drizzt #6](//www.google.com/search?tbo=p&q=isbn+9780786942893) by R. A. Salvatore - 378 pages   <br />
  215. <br />
  216. ### [Dark Tower novels](https://en.wikipedia.org/wiki/The_Dark_Tower_(series)) (Paperback collection) <br />
  217.   <br />
  218. 2024-01-13 - [The Gunslinger: Revised - Dark Tower #1](//www.google.com/search?tbo=p&q=isbn+9781501143519) by King, Stephen - 253 pages   <br />
  219. 2024-01-28 - [The Gunslinger: Original - Dark Tower #1](//www.google.com/search?tbo=p&tbm=bks&q=isbn:093798650x) by King, Stephen - 224 pages   <br />
  220. 2024-02-12 - [The Drawing Of The Three - Dark Tower #2](//www.google.com/search?tbo=p&q=isbn+9781501143533) by Stephen King - 459 pages     <br />
  221. 2024-03-14 - [The Waste Lands - Dark Tower #3](//www.google.com/search?tbo=p&q=isbn+9781501143540) by Stephen King - 606 pages   <br />
  222. 2024-xx-xx - [Wizard and Glass - Dark Tower #4](//www.google.com/search?tbo=p&q=isbn+9781501143557) by Stephen King - 893 pages     <br />
  223. 2024-xx-xx - [The Wind Through The Keyhole - Dark Tower #4.5](//www.google.com/search?tbo=p&q=isbn+9781501166228) by Stephen King - 309 pages   <br />
  224. 2024-xx-xx - [Wolves Of The Calla - Dark Tower #5](//www.google.com/search?tbo=p&q=isbn+9780743251624) by Stephen King - 709 pages     <br />
  225. 2024-xx-xx - [Song Of Susannah - Dark Tower #6](//www.google.com/search?tbo=p&q=isbn+9780743254557) by Stephen King - 411 pages     <br />
  226. 2024-xx-xx - [The Dark Tower - Dark Tower #7](//www.google.com/search?tbo=p&q=isbn+9780743254564) by Stephen King - 845 pages   <br />
  227. <br />
  228. ### [Redwall novels](https://en.wikipedia.org/wiki/Redwall) <br />
  229. 2024-01-16 - [Redwall](//www.google.com/search?tbo=p&q=isbn+9780142302378) by Brian Jacques - 351 pages     <br />
  230. 2024-02-19 - [Mossflower](//www.google.com/search?tbo=p&q=isbn+9780142302385) by Brian Jacques - 432 pages     <br />
  231. 2024-03-08 - [Mattimeo](//www.google.com/search?tbo=p&q=isbn+9780142302408) by Brian Jacques - 446 pages     <br />
  232. 2024-xx-xx - [Mariel Of Redwall](//www.google.com/search?tbo=p&q=isbn+9780142302392) by Brian Jacques - 387 pages     <br />
  233. 2024-xx-xx - [Salamandastron](//www.google.com/search?tbo=p&q=isbn+9780142501528) by Brian Jacques - 391 pages     <br />
  234. 2024-xx-xx - [Martin The Warrior](//www.google.com/search?tbo=p&q=isbn+9780142400555) by Brian Jacques - 376 pages   <br />
  235. <br />
  236. ### Various novels <br />
  237. 2024-01-01 - [Revival](//www.google.com/search?tbo=p&q=isbn+9781501168901) by Stephen King - 466 pages   <br />
  238. 2024-01-21 - [White Death](//www.google.com/search?tbo=p&q=isbn+0399150412) by Clive Cussler - 419 pages   <br />
  239. 2024-01-31 - [Red Rising](//www.google.com/search?tbo=p&q=isbn+9780345539786) by Pierce Brown - 382 pages   <br />
  240. 2024-02-25 - [Star Wars: Exile](//www.google.com/search?tbo=p&q=isbn+9780345477538) by Aaron Allston - 337 pages   <br />
  241. 2024-03-23 - [Empire Of Pain](//www.google.com/search?tbo=p&q=isbn+9780385545686) by Patrick Radden Keefe - 452 pages
  242. ]]>
  243. </content>
  244. </entry>
  245. <entry xmlns="http://purl.org/atom/ns#">
  246. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1391/" />
  247. <title mode="escaped">Perl: How to profile Perl code to improve your code quality</title>
  248. <modified>2023-12-21T00:00:00-08:00</modified>
  249. <issued>2023-12-21T00:00:00-08:00</issued>
  250. <created>2023-12-21T00:00:00-08:00</created>
  251. <id>http://www.perturb.org/display/entry/1391/</id>
  252. <summary type="text/plain"></summary>
  253. <author>
  254. <name>Scott Baker</name>
  255. <url>http://www.perturb.org/</url>
  256. <email>scott@perturb.org</email>
  257. </author>
  258. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  259. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  260.  
  261. If you've written some Perl and you want to improve upon the execution speed you can use a profiler. There are several profilers available, but the best one I've found is [`Devel::NYTProf`](https://metacpan.org/pod/Devel::NYTProf). Once you have the module installed you run your Perl script as normal but invoke the profiler: <br />
  262. <br />
  263. ``` <br />
  264. perl -d:NYTProf term-colors.pl <br />
  265. ``` <br />
  266. <br />
  267. This will result in a `nytprof.out` file being created in the current directory. This file contains raw stats about function calls and code timings. You can turn this data into something human readable by converting it to HTML. <br />
  268. <br />
  269. ``` <br />
  270. nytprofhtml nytprof.out --out perl-profile/ <br />
  271. ``` <br />
  272. <br />
  273. This will create a nice HTML page with all kinds of [information](https://www.perturb.org/code/perl-profile/) about how the Perl interpreter ran your script. With this information hopefully you can find places in your code that could use improvement.
  274. ]]>
  275. </content>
  276. </entry>
  277. <entry xmlns="http://purl.org/atom/ns#">
  278. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1390/" />
  279. <title mode="escaped">Keeping Apache and PHP from leaking version information</title>
  280. <modified>2023-12-06T00:00:00-08:00</modified>
  281. <issued>2023-12-06T00:00:00-08:00</issued>
  282. <created>2023-12-06T00:00:00-08:00</created>
  283. <id>http://www.perturb.org/display/entry/1390/</id>
  284. <summary type="text/plain"></summary>
  285. <author>
  286. <name>Scott Baker</name>
  287. <url>http://www.perturb.org/</url>
  288. <email>scott@perturb.org</email>
  289. </author>
  290. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  291. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  292.  
  293. PHP and Apache like to advertise themselves in the HTTP headers of every connection. It's probably best *not* to advertise your versions. You can disable that with these configuration entries: <br />
  294. <br />
  295. ``` <br />
  296. # In /etc/php.ini <br />
  297. expose_php = Off <br />
  298. ``` <br />
  299. <br />
  300. ``` <br />
  301. # In your Apache config <br />
  302. ServerTokens Prod <br />
  303. ServerSignature Off <br />
  304. ```
  305. ]]>
  306. </content>
  307. </entry>
  308. <entry xmlns="http://purl.org/atom/ns#">
  309. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1389/" />
  310. <title mode="escaped">SuperGenPass is great</title>
  311. <modified>2023-12-01T00:00:00-08:00</modified>
  312. <issued>2023-12-01T00:00:00-08:00</issued>
  313. <created>2023-12-01T00:00:00-08:00</created>
  314. <id>http://www.perturb.org/display/entry/1389/</id>
  315. <summary type="text/plain"></summary>
  316. <author>
  317. <name>Scott Baker</name>
  318. <url>http://www.perturb.org/</url>
  319. <email>scott@perturb.org</email>
  320. </author>
  321. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  322. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  323.  
  324. I'm a big fan of [SuperGenPass](https://chriszarate.github.io/supergenpass/) so I decided to learn how it works. The algorithm is pretty simple so I decided to implement it in two of my favorite languages: [PHP](https://www.perturb.org/code/supergen_pass.php?domain=domain.com&master=12345678) and [Perl](https://www.perturb.org/code/supergen_pass.pl). <br />
  325. <br />
  326. Hopefully this will help someone else trying to understand the concepts. Special thanks to Iannz for the great [Bash implementation](https://github.com/lanzz/bash-supergenpass) I based my code on.
  327. ]]>
  328. </content>
  329. </entry>
  330. <entry xmlns="http://purl.org/atom/ns#">
  331. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1388/" />
  332. <title mode="escaped">Perl: Array of all regexp captures</title>
  333. <modified>2023-11-29T00:00:00-08:00</modified>
  334. <issued>2023-11-29T00:00:00-08:00</issued>
  335. <created>2023-11-29T00:00:00-08:00</created>
  336. <id>http://www.perturb.org/display/entry/1388/</id>
  337. <summary type="text/plain"></summary>
  338. <author>
  339. <name>Scott Baker</name>
  340. <url>http://www.perturb.org/</url>
  341. <email>scott@perturb.org</email>
  342. </author>
  343. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  344. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  345.  
  346. Perl v5.25.7 added support for the `@{^CAPTURE}` variable which wrapped all the regexp parenthesis captures up into an array. If you need this functionality in an older version of Perl you can use this function: <br />
  347. <br />
  348. ``` <br />
  349. my $str =  "Hello Jason Doolis"; <br />
  350. $str    =~ /Hello (\w+) (\w+)/; <br />
  351. <br />
  352. my @captures = get_captures(); # ("Jason", "Doolis") <br />
  353. ``` <br />
  354. <br />
  355. ``` <br />
  356. sub get_captures { <br />
  357.    no strict 'refs'; <br />
  358. <br />
  359.    my $last_idx = scalar(@-) - 1; <br />
  360.    my @arr      = 1 .. $last_idx; <br />
  361.    my @ret      = map { $$_; } @arr; <br />
  362. <br />
  363.    return @ret; <br />
  364. } <br />
  365. ```
  366. ]]>
  367. </content>
  368. </entry>
  369. <entry xmlns="http://purl.org/atom/ns#">
  370. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1387/" />
  371. <title mode="escaped">PHP: Creation of dynamic property Class::$Var is deprecated</title>
  372. <modified>2023-11-01T00:00:00-07:00</modified>
  373. <issued>2023-11-01T00:00:00-07:00</issued>
  374. <created>2023-11-01T00:00:00-07:00</created>
  375. <id>http://www.perturb.org/display/entry/1387/</id>
  376. <summary type="text/plain"></summary>
  377. <author>
  378. <name>Scott Baker</name>
  379. <url>http://www.perturb.org/</url>
  380. <email>scott@perturb.org</email>
  381. </author>
  382. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  383. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  384.  
  385. I upgraded to PHP 8.2 today and started getting a lot of `Creation of dynamic property Class::$Var is deprecated` errors. This is just PHP's way of telling you that you need to pre-declare your class variables before you use them. To me this just meant adding a lot of: <br />
  386. <br />
  387. ``` <br />
  388. class user { <br />
  389. var $name  = ""; <br />
  390. var $id    = 0; <br />
  391. var $perms = []; <br />
  392. ``` <br />
  393. <br />
  394. to the tops of my classes. This is the **right** way to fix things, and what I did in 99% of the cases where I was seeing this error. <br />
  395. <br />
  396. However I do have a couple of classes where it's necessary to be able to add dynamic properties on the fly, and PHP does offer a work around for this. If you use a special declaration immediately before your class statement PHP will allow dynamic properties to be added without throwing any errors. <br />
  397. <br />
  398. ``` <br />
  399. #[\AllowDynamicProperties] <br />
  400. class user { <br />
  401. ``` <br />
  402. <br />
  403. **Note:** The `\` in the brackets **is** required
  404. ]]>
  405. </content>
  406. </entry>
  407. <entry xmlns="http://purl.org/atom/ns#">
  408. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1386/" />
  409. <title mode="escaped">Arduino: Using an ATX power supply as a hobbyist power source</title>
  410. <modified>2023-10-18T00:00:00-07:00</modified>
  411. <issued>2023-10-18T00:00:00-07:00</issued>
  412. <created>2023-10-18T00:00:00-07:00</created>
  413. <id>http://www.perturb.org/display/entry/1386/</id>
  414. <summary type="text/plain"></summary>
  415. <author>
  416. <name>Scott Baker</name>
  417. <url>http://www.perturb.org/</url>
  418. <email>scott@perturb.org</email>
  419. </author>
  420. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  421. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  422.  
  423. Running some RGB LEDs had me thinking about alternate sources of power. Specifically I need a mix of +5v and +12v to power different types of LEDs. Old ATX computer power supplies are a good/cheap source of power because they are easy to harvest from old PCs. They're also usually rated for high wattage. <br />
  424. <br />
  425. After some [research](https://www.technewstoday.com/atx-power-supply-pinout/) I found that you need to do a little work to turn *on* a PC power supply that's not hooked up to a motherboard. Specifically you need to short the green `PS-ON` pin to ground. This simulates pressing the power button on your PC and triggers the supply to turn on. You can tell the power supply is on when the fan starts to spin. This can be accomplished by cutting the green and (any) black wire out of the ATX connector and connecting them together. <br />
  426. <br />
  427. Alternately the power supply will supply +5v of power even in off or standby mode if you use the purple `+5vSB` line. If all you need is a small amount (less than 2 amps) of 5v power using the `+5vSB` line is a great alternative and will be quieter because the fan will not be on. <br />
  428. <br />
  429. Once the power supply is on you can use the other wires as follows: <br />
  430. <br />
  431. | Color   | Type            | <br />
  432. | ------- | --------------- | <br />
  433. | Black   | Ground          | <br />
  434. | Orange  | +3.3v           | <br />
  435. | Red     | +5v             | <br />
  436. | Yellow  | +12v            | <br />
  437. <br />
  438. Other pins are less useful but available: <br />
  439. <br />
  440. | Color   | Type            | <br />
  441. | ------- | --------------- | <br />
  442. | Green   | Power Supply On | <br />
  443. | Blue    | -12v            | <br />
  444. | White   | -5v             | <br />
  445. | Purple  | +5v standby     | <br />
  446. <br />
  447. [<img src="/images/ec/atx_power_pinout.jpg" style="width: 100%; max-width: 550px">](/images/ec/atx_power_pinout.jpg) <br />
  448. <br />
  449. Be sure to check the amperage ratings for each voltage on the side of your power supply before use.
  450. ]]>
  451. </content>
  452. </entry>
  453. <entry xmlns="http://purl.org/atom/ns#">
  454. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1385/" />
  455. <title mode="escaped">PHP: Serializing data to save it for caching</title>
  456. <modified>2023-10-04T00:00:00-07:00</modified>
  457. <issued>2023-10-04T00:00:00-07:00</issued>
  458. <created>2023-10-04T00:00:00-07:00</created>
  459. <id>http://www.perturb.org/display/entry/1385/</id>
  460. <summary type="text/plain"></summary>
  461. <author>
  462. <name>Scott Baker</name>
  463. <url>http://www.perturb.org/</url>
  464. <email>scott@perturb.org</email>
  465. </author>
  466. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  467. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  468.  
  469. I need to cache some data to disk between PHP requests so I decided to [compare](https://www.perturb.org/code/serialize_compare.php) the various methods available. <br />
  470. <br />
  471. > Using 100000 element array as source data   <br />
  472. > <br />
  473. > Serialize save: 2.958 ms (1.5M)   <br />
  474. > Serialize read: 5.447 ms <br />
  475. > <br />
  476. > JSON save: 1.880 ms (574.96K)   <br />
  477. > JSON read: 6.876 ms <br />
  478. > <br />
  479. > PHP save: 8.684 ms (1.7M)   <br />
  480. > PHP read: 26.863 ms <br />
  481. > <br />
  482. > Memcache set: 5.651 ms   <br />
  483. > Memcache get: 2.465 ms <br />
  484. >  <br />
  485. > IGBinary save: 1.377 ms (720.08K)   <br />
  486. > IGBinary read: 2.245 ms <br />
  487. > <br />
  488. > MsgPack save: 1.389 ms (359.92K)   <br />
  489. > MsgPack read: 2.930 ms <br />
  490. <br />
  491. I was surprised to see IGBinary and MsgPack so much faster than native JSON. JSON is easy and super portable, but not the fastest.
  492. ]]>
  493. </content>
  494. </entry>
  495. <entry xmlns="http://purl.org/atom/ns#">
  496. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1384/" />
  497. <title mode="escaped">Linux: repeatedly run a command to monitor output</title>
  498. <modified>2023-10-03T00:00:00-07:00</modified>
  499. <issued>2023-10-03T00:00:00-07:00</issued>
  500. <created>2023-10-03T00:00:00-07:00</created>
  501. <id>http://www.perturb.org/display/entry/1384/</id>
  502. <summary type="text/plain"></summary>
  503. <author>
  504. <name>Scott Baker</name>
  505. <url>http://www.perturb.org/</url>
  506. <email>scott@perturb.org</email>
  507. </author>
  508. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  509. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  510.  
  511. If you need to repeatedly run a command and view the output changes over time then check out my [cli_watch.pl](/code/cli_watch.pl) script. I was watching a RAID array rebuild slowly and needed a way to see the progress over time. <br />
  512. <br />
  513. Usage: `cli_watch.pl [--delay 15] [--line 3] command` <br />
  514. <br />
  515. Run **my_command** every 15 seconds:   <br />
  516. <br />
  517. `cli_watch.pl --delay 15 'my_command | grep stuff'` <br />
  518. <br />
  519. Filter output to only line 2: <br />
  520.   <br />
  521. `cli_watch.pl --line 2 'ping -c 1 192.168.5.222'`
  522. ]]>
  523. </content>
  524. </entry>
  525. <entry xmlns="http://purl.org/atom/ns#">
  526. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1383/" />
  527. <title mode="escaped">Perl: Add an element to the middle of an array</title>
  528. <modified>2023-09-09T21:19:42-07:00</modified>
  529. <issued>2023-09-09T21:19:42-07:00</issued>
  530. <created>2023-09-09T21:19:42-07:00</created>
  531. <id>http://www.perturb.org/display/entry/1383/</id>
  532. <summary type="text/plain"></summary>
  533. <author>
  534. <name>Scott Baker</name>
  535. <url>http://www.perturb.org/</url>
  536. <email>scott@perturb.org</email>
  537. </author>
  538. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  539. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  540.  
  541. If you want to add an element to the middle of an existing array you can use the `splice()` function. Splice modifies arrays in place. Splice takes four arguments for this: the array to modify, the index of where you want to modify, the number of items you want to remove, and an array of the elements to add. <br />
  542. <br />
  543. ``` <br />
  544. my @x = qw(one three); <br />
  545. <br />
  546. # At the 2nd index, add (replace zero elements) a one element array <br />
  547. splice(@x, 1, 0, ('two')); <br />
  548. <br />
  549. print join(" ", @x); # "one two three" <br />
  550. ```
  551. ]]>
  552. </content>
  553. </entry>
  554. <entry xmlns="http://purl.org/atom/ns#">
  555. <link rel="alternate" type="text/html" href="http://www.perturb.org/display/entry/1382/" />
  556. <title mode="escaped">Perl: Get certain elements of an array the lazy way</title>
  557. <modified>2023-08-23T00:00:00-07:00</modified>
  558. <issued>2023-08-23T00:00:00-07:00</issued>
  559. <created>2023-08-23T00:00:00-07:00</created>
  560. <id>http://www.perturb.org/display/entry/1382/</id>
  561. <summary type="text/plain"></summary>
  562. <author>
  563. <name>Scott Baker</name>
  564. <url>http://www.perturb.org/</url>
  565. <email>scott@perturb.org</email>
  566. </author>
  567. <content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.perturb.org">
  568. <![CDATA[<link rel="stylesheet" type="text/css" media="screen" href="/css/rss-feed.css" title="Default" />
  569.  
  570. I [learned](http://modernperlbooks.com/books/modern_perl_2016/03-perl-language.html#QXJyYXlz) that you can extract various elements from a Perl array in a very creative/simple way. Using this syntax may simplify some of your code and save you a lot of time. <br />
  571. <br />
  572. ``` <br />
  573. my @colors = ("red", "blue", "green", "yellow", "orange", "purple"); <br />
  574. <br />
  575. my @w = @colors[(0, 3)];    # ("red", "yellow"); <br />
  576. my @x = @colors[(0, 2, 4)]; # ("red", "green", "orange"); <br />
  577. <br />
  578. # First and last element <br />
  579. my @y = @colors[(0, -1)];   # ("red", "purple"); <br />
  580. <br />
  581. # First ten items <br />
  582. my @z = @array[0 .. 10];    # Using the `..` range operator <br />
  583. ``` <br />
  584. <br />
  585. Basically any call to an array where the payload is an array of indexes will return a new array with those items extracted. <br />
  586. <br />
  587. ``` <br />
  588. my @colors = ("red", "blue", "green", "yellow", "orange", "purple"); <br />
  589. <br />
  590. # You can also use an array variable to specify the elements to extract <br />
  591. my @ids = (1,3,5); <br />
  592. my @x   = @colors[@ids]; # ("blue", "yellow", "purple") <br />
  593. ``` <br />
  594. <br />
  595. **Note:** Since you are referencing the **whole** array (not one element) you use the `@` sigil instead of `$`.
  596. ]]>
  597. </content>
  598. </entry>
  599. </feed>
  600.  
Copyright © 2002-9 Sam Ruby, Mark Pilgrim, Joseph Walton, and Phil Ringnalda