Entries Categorized as 'Technology'
Author:
erics, April 16th, 2021
The key is to define a variable first, then use the BEGIN block to initialize the variable, then reference the variable in use lib $var; later on ;-} For example, enable a module contained in the same directory as a script called via the PATH:
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
|
#!/ussr/bin/env perl use strict; use warnings; our $scriptPath; BEGIN { eval { use File::Basename; use File::Spec; $scriptPath = dirname(File::Spec->rel2abs(__FILE__)); 1; } or do { die "$0 use CRASHED: $@"; }; } use lib $scriptPath; eval { use MyModule::ABC; 1; } or do { die "$0 use CRASHED: $@"; }; |
Categories: How-To's, Technology Tags: @INC, compile, Compile-time, Dir, directory, howto, include, lib, Library, module, Path, perl, require, Run-time, runtime, tips, Use, use lib
|
No comments
Author:
erics, March 22nd, 2021
Ah, the power of grep!
|
mysql --help | grep 'Default options' -A 1 |
Categories: How-To's, Technology Tags: howto, my.cnf, mysql, tips
|
No comments
Author:
erics, March 16th, 2021
Recent changes to git have made the push default choice a bit confusing – “matching” vs. “simple” I picked “matching” when prompted. This means that git push by itself will try to push ALL local branches, not just the one you are working on. Personally, I find that a bit mad, so I decided to […]
Categories: How-To's, Technology Tags: Config, Default, defaults, git, git config, git push, Matching, Push, Simple
|
No comments
Author:
erics, March 9th, 2021
The trick to using eval to catch shell execution is to return twice, once inside the eval and once outside:
|
sub isMaintenance { my $return = eval { my $err=system("check_policy.sh | grep 'Policy is MAINTENANCE' >/dev/null 2>/dev/null"); &debug("perl error code: $err"); $err=$err / 256; &debug("system error code: $err"); if ($err != 0) { # Not Maintenance if ($verbose) { warn "policy is NOT MAINTENANCE\n"; } return 0; } else { return 1; } }; return $return; } |
Neat!
Categories: How-To's, Technology Tags: Code, eval, Exit, Exit Code, howto, perl, Return, System
|
No comments
Author:
erics, February 26th, 2021
On MacOSX 10.10.5 Yosemite, I was having trouble with Spotlight preventing the clean eject of an attached hard drive. Using the fuser command allowed me to see that it what the Spotlight-specific mds process preventing the eject.
|
fuser -u /Volumes/Archive03 |
At first, I tried to disable the indexing via the mdutil command, but that just gave me […]
Categories: How-To's, Technology Tags: 10.10.5, apple, Disable, diskutil, eject, Halt, howto, Index, Indexing, Mac, MacOS, macosx, mdutil, metadata_never_index, Prevent, Spotlight, Stop, tips, Touch, umountDisk, Yosemite
|
No comments
Author:
erics, February 19th, 2021
Create two template files in the wp-content/themes/{themeName}/ subdirectory:
|
page_blog.php page_blog_plus_content.php |
page_blog.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?php /* WARNING: This file is part of the core Genesis framework. DO NOT edit this file under any circumstances. Please do all modifications in the form of a child theme. */ /** * Template Name: Blog * This file handles blog post listings within a page. * * This file is a core Genesis file and should not be edited. * * @category Genesis * @package Templates * @author StudioPress * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) * @link http://www.studiopress.com/themes/genesis */ genesis(); |
page_blog_plus_content.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<?php /* WARNING: This file is part of the core Genesis framework. DO NOT edit this file under any circumstances. Please do all modifications in the form of a child theme. */ /** * Template Name: Blog Plus Content * This file handles blog post listings within a page. * * This file is a core Genesis file and should not be edited. * * @category Genesis * @package Templates * @author StudioPress * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later) * @link http://www.studiopress.com/themes/genesis */ // to see the page title and page content, uncomment this: add_action('genesis_loop', 'genesis_standard_loop' ,5); genesis(); |
Categories: How-To's, Technology Tags: Blog, Blog Paage, Categories, Category, genesis, howto, page_blog, query_args, tips, WordPress
|
No comments
Author:
erics, February 19th, 2021
First, use lsblk to see the raw partitions:
|
# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/nvme0n1p1 xfs 20G 2.8G 18G 14% / # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 259:0 0 40G 0 disk ├─nvme0n1p1 259:1 0 20G 0 part / └─nvme0n1p128 259:2 0 1M 0 part |
Note how the partition at 259:1 is only 20GB, while the entire disk at 259:0 is 40GB. A partition resize is required in this case.
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
|
# sudo growpart /dev/nvme0n1 1 CHANGED: partition=1 start=4096 old: size=41938911 end=41943007 new: size=83881951 end=83886047 # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT nvme0n1 259:0 0 40G 0 disk ├─nvme0n1p1 259:1 0 40G 0 part / └─nvme0n1p128 259:2 0 1M 0 part # df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/nvme0n1p1 xfs 20G 2.8G 18G 14% / # sudo xfs_growfs -d / meta-data=/dev/nvme0n1p1 isize=512 agcount=11, agsize=524159 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1 spinodes=0 data = bsize=4096 blocks=5242363, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 5242363 to 10485243 # df -hT /dev/nvme0n1p1 xfs 40G 2.8G 38G 7% / If the XFS tools are not already installed, you can install them as follows: sudo yum install xfsprogs |
For an EXT4 filesystem, use the resize2fs command instead:
|
sudo resize2fs /dev/nvme0n1p1 |
For more information, please visit the AMW Docs: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html
Categories: How-To's, Technology Tags: Amazon, Amazon Linux 2, AWS, df, df -hT, Disk, EBS, Expand, Filesystem, Grow, howto, Linux, Linux2, lsblk, NVMe, partition, Resize, tips, volume, XFS
|
No comments
Author:
erics, February 15th, 2021
First, get the container ID using docker ps:
|
shell> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3bcc0baffd68 dashboard:1.0.10-88 "docker-php-entrypoi…" 29 minutes ago Up 29 minutes 0.0.0.0:8080->80/tcp dashboard |
Now run docker exec -it {ContainerID} /bin/bash:
|
shell> docker exec -it 3bcc0baffd68 /bin/bash root@3bcc0baffd68:/var/www/html# exit |
You can make a simple shell script to ease typing a bit:
|
shell> cat dshell #!/bin/sh # dshell # usage: dshell ContainerID docker exec -it $* /bin/bash |
Categories: How-To's, Technology Tags: Container, Docker, docker exec, docker ps, Exec, howto, login, ps, Shell, tips
|
No comments
Author:
erics, February 11th, 2021
## to add a single backslash in front of whatever char was matched
|
my $password = q#abc'A1r%Fgt&jh[-#; $password =~ s/(['])/\\$1/g; print qq#'$password'\n#; 'abc\'A1r%Fgt&jh[-' |
## to double whatever char was matched
|
my $password = q#abc'A1r%Fgt&jh[-#; $password =~ s/(['])/$1$1/g; print qq#'$password'\n#; 'abc''A1r%Fgt&jh[-' |
## to convert ‘ to ‘\” for shell execution
|
my $password = q#abc'A1r%Fgt&jh[-#; $passwordShell =~ s/(['])/$1\\$1$1/g; print qq#'$password'\n#; 'abc'\''A1r%Fgt&jh[-' |
Categories: How-To's, Technology Tags: Backslash, Characters, double, double quotes, Escape, howto, perl, quote, quotes, Replace, Single, single quotes, Speci, Special, Special character, Substitute, tips
|
No comments
Author:
erics, February 8th, 2021
Test Renewal of a Single Domain
|
certbot renew --cert-name yourdomain.com --dry-run |
Execute Renewal of a Single Domain
|
certbot renew --cert-name yourdomain.com |
Categories: How-To's, Technology Tags: cert-name, Certbot, certbot renew, dry-run, howto, LetsEncrypt, Renew, Renewal, tips
|
No comments