I don't know, as a ttrpg'er, I'm being someone else every two weeks for three hours are a time. ;)

2
fun with /dev/random (lemmy.sdf.org)
submitted 1 year ago* (last edited 1 year ago) by dark776174657273@lemmy.sdf.org to c/perl@programming.dev

I've never had a need to use /dev/random before, but then I saw this in some documentation I was reading:

$ head -c20 /dev/random | base64
ZZXB6yF9bZvp103CI3lcREcBVEA=

Which got me thinking about my password generator. This is trivial, but I thought it was fun.

better-password-gen.pl

#!/usr/bin/env perl
use strict; use warnings; use Data::Dumper;
use feature qw< say >;

my @CList = ('a'..'z', 'A'..'Z', 0..9, split(//, q<\<\>\\/()[]{}:;"'`~#!@$%^&*-_=+>));
my $pwdLen = shift @ARGV // 12;
my $BUFF = "\x0" x $pwdLen;
open( my $RND, '<', '/dev/random' ) or die $!;
for (0..9){
    read $RND, $BUFF, $pwdLen;
    say join('', map {$CList[ord($_) % @CList]} split(//, $BUFF));
}
close($RND);

output:

$ ./better-password-gen.pl 25
M6V/$U(CGQ\p!d\lg=9>GpO[x
hlAN*"XiXnShRy)DB6GOCv;7j
NRXqeqSCZ^I\Tt2Bore4t1hYX
~4dIXVo+opRJfu6'b}u'y=N$:
6he=<mYdH'{P>Z4nDlfe4fk1T
Ffv28dOEu1fZxr9<VMhl$nS"n
yt[ol0;me'Rd2'6#ZD7!7plf[
=LZ^68!EOtP6EYJNq^;3T48HJ
V<3fcA%\b@:+"wghSX^)\S/cH
*1q08-+Zo`PHibJA<b)oeM!nx
[-] dark776174657273@lemmy.sdf.org 16 points 1 year ago

My least favorite is

Just be yourself!

Even in grade school I knew this was hogwash. I didn't act the same in class as during recess, or in church as when at the dinner table. Exactly which me was I supposed to be? When someone asks, "What am I supposed to do?" They are really asking, "How should I behave?" And if you've never been on a date before, or this is your first job interview, then it's not obvious.

A: "So, how did the interview go?"

B: "Not so well, he threw my resume away, in front of me, and ordered me to leave."

A: "What? Why?"

B: "Well, I did just as your said, I was being myself. I walked in, gave him the ol' finger guns, then started with my best fart joke."

A: "Why the hell would you do that at an interview?"

B: "Because that routine always slays in the dorms and I was trying to be myself."

Agreed. This sounds good but immediately falls apart at the first scrutiny. It's the same with "Don't be a dick." Everyone nods their heads and thinks, "Oh, that's so obvious!" Of course, everyone agrees because they're imagining what they believe is 'evil' or 'being a dick' and just assume everyone else agrees. Imagine their surprised-Pikachu face when they learn that other humans use different criteria.

But, if you think you can sum up thousands of years of ethics and legal theories with one pithy sentence, then go for it.

[-] dark776174657273@lemmy.sdf.org 10 points 1 year ago* (last edited 1 year ago)

I wondered about this for years and years, never understanding, especially, since "having cake" and "eating cake" are used interchangeably. But, I finally figured it out! In this sense, the "having" is equivalent to "keeping" or "being in possession of."

Examples:

  • "What's it like having a Mercedes Benz?"
  • "The Smiths have a very nice home."

No eating implied!

Therefore, the saying is more inline with "You can't keep (to show off or admire) your cake, and eat it, too."

2
submitted 1 year ago* (last edited 1 year ago) by dark776174657273@lemmy.sdf.org to c/perl@programming.dev

Calendar::Simple takes a few parameters and returns an array of array refs representing the weeks and days of the month. That's it! You can use it to display text calendars, or find all of the dates for a particular day of the week for a year, or use with an HTML builder module to create a calendar web page, or whatever you want.

One caveat, which is in the documentation though I missed it, is that weeks start on Monday by default. You need that third param to specify Sunday if you want that.

I also used enum and Text::Reform

Do you have any modules you've found that really get the old brain juices flowing?

july-thru-december.pl

|               July               |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |    |  1 |  2 |
|  3 |  4 |  5 |  6 |  7 |  8 |  9 |
| 10 | 11 | 12 | 13 | 14 | 15 | 16 |
| 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 |
| 31 |    |    |    |    |    |    |
|              August              |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |  1 |  2 |  3 |  4 |  5 |  6 |
|  7 |  8 |  9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |    |    |    |
|            September             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |  1 |  2 |  3 |
|  4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 |    |
|             October              |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |    |    |  1 |
|  2 |  3 |  4 |  5 |  6 |  7 |  8 |
|  9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |    |    |    |    |    |
|             November             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |  1 |  2 |  3 |  4 |  5 |
|  6 |  7 |  8 |  9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 |    |    |    |
|             December             |
| Mo | Tu | We | Th | Fr | Sa | Su |
|    |    |    |    |  1 |  2 |  3 |
|  4 |  5 |  6 |  7 |  8 |  9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |

humpdays.pl

All Wednesday's in 2023
Jan: 4, 11, 18, 25
Feb: 1, 8, 15, 22
Mar: 1, 8, 15, 22, 29
Apr: 5, 12, 19, 26
May: 3, 10, 17, 24, 31
Jun: 7, 14, 21, 28
Jul: 5, 12, 19, 26
Aug: 2, 9, 16, 23, 30
Sep: 6, 13, 20, 27
Oct: 4, 11, 18, 25
Nov: 1, 8, 15, 22, 29
Dec: 6, 13, 20, 27
1

When I searched for a solution, the site that came up was long since defunct.

Ahh, to be only 30 again!

2

OK, why didn't anyone tell me about this module?

I do a lot of work with CSV and TSV files, usually pulling and transforming reports. My usual goto modules are Text::CSV::Slurp and when that's not enough, I use Text::CSV. Then, I do all of the data manipulation myself.

I'm finding that Data::CTable makes reading, modifying, and writing tabular data files almost trivially easy. I can act on the data row-by-row (of course) but also column-by-column. I can add, delete, re-arrange, and rename columns. I can select a subset of rows and then perform actions, like calculating the value of a new column, only on the selected rows. I can load two files and merge columns into a third, writing the result as a new CSV.

I wasn't even looking for this. I had been searching metacpan for "fixed width template" (which was satisfied with Text::Reform) when I stumbled on this module. The irony, is that it's exactly what I needed for a current work report due tomorrow!

1

Does anyone have experience using GNU Stow for managing dot files? I'm especially interested in using it to build a git repo to include my .vimrc file so I can sync it between hosts.

I know I've seen other methods, such as making your home directory a bare git repo, so you can check-in your config files without moving them. There is also the chezmoi golang project.

How do others sync .vimrc between hosts?

2
Chaining Substitutions (lemmy.sdf.org)
submitted 1 year ago* (last edited 1 year ago) by dark776174657273@lemmy.sdf.org to c/perl@programming.dev

I was recently reading through Perl Regular Expression Tutorial (perlretut) when I found the section on using the 'r' option. I'd seen this before but rarely had any reason to use it. Then it occurred to me that you could chain these together.

I've been programming Perl for 30+ years and don't think I've ever seen this before.

Here's an example that shows how I would usually do this, i.e. a series of var =~ s/// lines, and how to do the same thing in one line while initializing a variable.

#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';

my $T = "one two trash THREE random";
my $T2 = $T;
$T2 =~ s/trash|random//g;
$T2 =~ s/(THREE)/lc($1)/e;
$T2 =~ s/\s+/ /g;
$T2 =~ s/^/Count with me: /;

my $T3 = $T =~ s/trash|random//gr =~ s/(THREE)/lc($1)/er =~ s/\s+/ /gr =~ s/^/Count with me: /r;

say "T  := $T\nT2 := $T2\nT3 := $T3";

Output:

$ ./perl-subst-test.pl 
T  := one two trash THREE random
T2 := Count with me: one two three 
T3 := Count with me: one two three 

Anyways, I had to tell someone ...

dark776174657273

joined 1 year ago