A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label bug. Show all posts
Showing posts with label bug. Show all posts

Disable Mac Spotlight (mds_stores) because it uses too much CPU and disk space

# Disable spotlight
sudo mdutil -a -i off
# Restart the Mac

# I reclaimed 3.5Gb of disk space

# Delete database (was only 12K for me)
sudo rm -rf /.Spotlight-V100/

(source)

How to defeat Sub::Quote and Sub::Defer

Do you use the Perl debugger?

Are you frustrated when you hit a maze of Sub::Quote twisty passages, all alike?

Then this guide is for you!

Walkthrough solution for Sub::Quote:

  • n (north)
  • n (north)
  • s (south)
  • # Boom! You should now be on the other side of the maze.
Walkthrough solution for Sub::Defer:
  • to do
(source: Text adventures of the eighties and nineties, and Perl coding adventures of the naughties)

How OG fixed his Mac AGAIN

`for i in ../opt/openssl/lib/lib*; do ln -vs $i .; done`

and also installing *pkg-config*

and also deleting a local directory from `~/`

How to disable Mojo debug logging

When setting MOJO_LOG_LEVEL does not work... Make the following hacks:

removing debug output

~ ============================================================================ Tuesday 12th February 2019

~~~ FIXES FOR OLD VERSION OF MOJO (Supervillain 8.03)

../local/lib/perl5/Mojolicious.pm
132:    $self->log->debug(qq{$method "$path" ($id)}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Controller.pm
209:      $app->log->debug("$code $msg (${elapsed}s, $rps/s)") if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Plugin/EPLRenderer.pm
18:    $c->app->log->debug("Rendering cached @{[$mt->name]}") if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
30:      $c->app->log->debug(qq{Rendering inline template "$name"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
40:        $c->app->log->debug(qq{Rendering template "$name"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
46:        $c->app->log->debug(qq{Rendering template "$name" from DATA section}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};

../local/lib/perl5/Mojolicious/Routes.pm
95:  $app->log->debug('Routing to a callback') if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
150:    $log->debug(qq{Routing to application "$class"}) if $ENV{BB_DEBUG} || $ENV{MOJO_DEBUG};
164:      $log->debug(qq{Routing to controller "$class" and action "$method"}) if $ENV{MOJO_DEBUG} || $ENV{BB_DEBUG};

~ ============================================================================ Thursday 7th March 2019

local/lib/perl5/Mojolicious.pm
123:          #return unless $ENV{MOJO_DEBUG}; # WS hack

local/lib/perl5/Mojolicious/Controller.pm
187:      return unless $ENV{MOJO_DEBUG};

local/lib/perl5/Mojolicious/Routes.pm
103:  $app->log->debug('Routing to a callback') if $ENV{MOJO_DEBUG};
170:      $log->debug(qq{Routing to controller "$class" and action "$method"}) if $ENV{MOJO_DEBUG};

x
491:>> /Users/will/dev/ats-broadcast-hub/local/lib/perl5/Mojolicious/Routes.pm:103:   $app->log->debug('Routing to a callback') if $ENV{MOJO_DEBUG};

~~~~ AND ~~~~

To fix CODE(0x7fde03335ca0) now:

vi local/lib/perl5/Mojolicious.pm +122

~~~ OLD VERSION OF MOJO

local/lib/perl5/Mojolicious.pm

  60 our $CODENAME = 'Supervillain';
  61 our $VERSION  = '8.03';

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121   unless ($stash->{'mojo.static'} || $stash->{'mojo.started'}) {
 122     my $req    = $c->req;
 123     my $method = $req->method;
 124     my $path   = $req->url->path->to_abs_string;
 125     my $id     = $req->request_id;
 126     $self->log->debug(qq{$method "$path" ($id)});
 127     $c->helpers->timing->begin('mojo.timer');
 128   }

~~~ NEW VERSION OF MOJO

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121   $self->log->debug(sub {
 122     my $req    = $c->req;
 123     my $method = $req->method;
 124     my $path   = $req->url->path->to_abs_string;
 125     my $id     = $req->request_id;
 126     $c->helpers->timing->begin('mojo.timer');
 127     return qq{$method "$path" ($id)};
 128   }) unless $stash->{'mojo.static'};
 129 

~~~ FIX FOR NEW VERSION (8.12)

vi local/lib/perl5/Mojolicious.pm

  61 our $CODENAME = 'Supervillain';
  62 our $VERSION  = '8.12';

 119   # Start timer (ignore static files)
 120   my $stash = $c->stash;
 121     my $req    = $c->req;
 122     my $method = $req->method;
 123     my $path   = $req->url->path->to_abs_string;
 124     my $id     = $req->request_id;
 125     $c->helpers->timing->begin('mojo.timer');
 126 if ($ENV{MOJO_DEBUG}) {
 127     $self->log->debug(qq{$method "$path" ($id)}) unless $stash->{'mojo.static'};
 128 }

vi local/lib/perl5/Mojolicious/Controller.pm

184     # Disable auto rendering and stop timer
185     my $app = $self->render_later->app;
186 #    $app->log->debug(sub {
187       my $timing  = $self->helpers->timing;
188       my $elapsed = $timing->elapsed('mojo.timer') // 0;
189       my $rps     = $timing->rps($elapsed) // '??';
190       my $code    = $res->code;
191       my $msg     = $res->message || $res->default_message($code);
192 #      return "$code $msg (${elapsed}s, $rps/s)";
193 #    }) unless $stash->{'mojo.static'};
194 if ($ENV{MOJO_DEBUG}) {
195       $app->log->debug("$code $msg (${elapsed}s, $rps/s)") unless $stash->{'mojo.static'}; # MOJO_DEBUG
196 }



Surprising behaviour of the perl debugger for wantarray()

When you are running a perl script in the debugger, do not expect wantarray() to return the same thing it would if not running in the debugger.

If you break execution at a breakpoint, wantarray() seems to return 1 when it wouldn't otherwise.

ssh debug3: Incorrect RSA1 identifier debug3: Could not load ".ssh/id_rsa" as a RSA1 public key

When testing ssh with -vvv, you see this in the log:

    debug3: Incorrect RSA1 identifier
    debug3: Could not load ".ssh/id_rsa" as a RSA1 public key

This is not an error.
This is not the problem you're looking for.
Your problem is something else.

(source)

See also another ssh non-error.

debug2: key_type_from_name: unknown key type '-----BEGIN'

SSH debug output can be quite misleading.
When you see the following output, it does NOT indicate a problem.

debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
...
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/foo/.ssh/id_rsa type 1

The final line tells you that the key was read successfully.

(source)

See also another ssh non-error.

Change quoting level in Outlook 2007

When replying to an HTML email, the original message has a blue bar to the left (which replaces the traditional > symbol). I've seen in previous versions of Outlook that pressing enter on this line takes you to a new line without the blue line ("paragraph unindent") and allows you to write a reply inline. That's fine and what I'd expect.

But currently that doesn't work and I can't easily get rid of the blue line, meaning all my inline replies look like they're part of the original message! Quite odd. Here's how to work around the problem:

  • Change the message format from HTML to Rich-text
  • Type Ctrl-Q where you want to add a reply
  • Type your reply
Voila


Cannot install Java JDK: semicolon found in selected path

There's no semi colon in the install path. But you still get the error:

        semicolon found in selected path

Solution is to move the install .exe to c:\ and run it again.

Possibly with command line switches: /v"/L c:\install.log"

(Search results show that this same issue has existed for 11 years!)

Windows: folder or file open in another program

When you try to move a folder:

    "The action can't be completed because the folder or a file in it is open in another program"

This stunningly unhelpful error message has persisted through many versions of Windows.

The way I work around it is:

  • Rename an unrelated file or folder nearby, then rename it back again.
  • The original folder or file should now be "unlocked"
You can always reboot to fix it, too.

Ctrl-C doesn't interrupt loop in Bash script

If you want Ctrl-C to be able to stop your loop in Bash, put this inside the loop:

trap "echo Exited!; exit;" SIGINT SIGTERM

(source)

SSH warning: authenticity of host can't be established

Problem

The authenticity of host 'example.com (1.2.3.4)' can't be established.
RSA key fingerprint is ab:cd:ef:12:34:56:78:90:ab:cd:ef:12:34:56:78:90
Are you sure you want to continue connecting (yes/no)?

Solution

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no

Make sure you understand the security implications of doing this (Hint: they're not good).

(source)

See all commit messages in svn log

After merging a branch to trunk, subversion does not include commit logs from branches in the trunk log. With a little work it can be persuaded to display the log in a more useful way, see "svnlogg" perl script below.

When viewing this log output you may want to see the diff of one of the changes and naively type:

    svn diff -c 69271

...this may produce no output. However, if you type this intead:

    svn diff -c 69271 https://www.example.com/repo/branches/feature_xyz

...then you will see the expected output.

How to determine the branch name from the commit message is left as an exercise for the reader.


"svnlogg" perl script:

#!/usr/bin/env perl

# First, get all the commits.
# -v shows the filenames of changed files,
# -g shows commits from all merged branches.

my $LOG_TEMP = "/tmp/log.txt";

system("svn log -v -g > $LOG_TEMP");

# Then split the list into individual commits, filter out ones we don't want to see, and sort by date:

open(my $fh,"<",$LOG_TEMP) or die "cannot open file $LOG_TEMP";
local $/="------------------------------------------------------------------------"; # define the record separator
my @a = <$fh>; # populate an array with the commit messages
foreach my $aa (
    sort {
        # sort the commits by date (descending)
        my ($c) = $a =~ /\s\|\s(\d\d\d\d\-\d\d\-\d\d)\s/; # extract date field
        my ($d) = $b =~ /\s\|\s(\d\d\d\d\-\d\d\-\d\d)\s/; #
        $d cmp $c
    } @a
) {
    # exclude unwanted messages, especially the hundreds of "remove svn:mergeinfo"
    # also exclude the commit messages we use by convention in our organisation
    # to refer to branches and merges
    if ($aa !~ /(remove svn:mergeinfo|branching|final pull)/i) {
        print "$aa\n";
    }
}

Depending on your hardware it may be unusably slow, so pipe it into a file for viewing later.

Outlook 2007 autocomplete doesn't work

It really doesn't.

I tried these things:
  • Adding the name to my contacts list
  • Composing and sending an email to the contact (source)
  • Tools | Address Book | Tools | Options | Check names using these address lists | Contacts
Some names are auto-completed, but some aren't.

:-(

Do you know how to make it work? Leave a comment

iPhone: No new pictures or videos were found on this device

(Windows) Sometimes photos get "stuck" on the iPhone, and the usual method of right-clicking on the iPhone in My Computer and importing doesn't work. It errors: "No new pictures or videos were found on this device".

The fix is to rename the file C:\Users\[username]\AppData\Local\Microsoft\Photo Acquisition\PreviouslyAcquired.db

NOTE: AppData will probably be hidden - you must make hidden files and folders visible in Windows Explorer options.

(source)

Prevent Windows from restarting after an update

Windows Vista/7: Start > search for gpedit.msc. Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Update and enable "No auto-restart for scheduled Automatic Updates installations".

All non-Home users can apply the same policy change by adding a new key to the registry. Go to Start > Run/Search for regedit. Navigate to HKEY_LOCAL_MACHINE SOFTWARE Policies Microsoft Windows WindowsUpdate AU. Create a new 32-bit DWORD value named NoAutoRebootWithLoggedOnUsers and give it a value of 1.

(source)

Outlook 2007: Don't remove line breaks

Microsoft :'-(

Outlook 2007:
Tools | Options | Preferences | E-mail Options
Untick "Remove extra line breaks in plain text messages"

(source)

How to transfer files between Windows 7 and Android 4

Settings | Storage | (three dots in top-right) | USB computer connection | Camera (PTP)

Then go to Developer Options (read elsewhere how to get this), and tick 'USB debugging'.

Voila - your device will appear in My Computer | Portable Devices.

Copy the files to a subdirectory of the Android Camera device in Windows, and move them into the right place from within Android. e.g. using ES File Explorer