Mobilization

by Joel Limardo

Software Developer and IT Professional

Chicago, IL

joel@joellimardo.com

SIP Phone (researching...)

Workadventure Workadventure (researching...)


Downstream Project Status

BixChange

33%

LIMSExpert.com

28%

Upstream Projects

Joellimardo.com Project Cleanup




Wed, 17 Jan 2024

GUIs in Perl

Have to start with Perl/Tk simply because it was the first one I started working with. Also, interfaces in Perl/Tk are on the unsightly side **but** look about the same as an Emacs interface so why not put a few things in there?

Super-quick spec of things I want to do:

  • Simple windows using Perl/Tk
  1. Installation
  2. Hello World
  3. Planning

  Up

/technical/upstream/perl/gui Permanent Link Project Sitemap Top  

Form Planning

It is tempting to just start writing code. However, you wind up with a great big mess. Here is PlantUML's Salt that can make the form visualization process go a bit smoother.

  Up

/technical/upstream/perl/gui Permanent Link Project Sitemap Top  

Hello World

There is an online Perl::Tk tutorial I'm going to utilize as well as just the standard Perl::Tk perldocs for these.

#!/usr/bin/perl -w
use Tk;
my $mw = new MainWindow;
$mw->minsize(400,300);
my %formElements = ();
$formElements{'button1Text'} = 'Quit';
$formElements{'label1'} =
$mw -> Label(-text=>"Hello World") -> pack();
$formElements{'button1'} =
$mw -> Button(-textvariable => \$formElements{'button1Text'},
-command => sub { exit })
-> pack();

$formElements{'button2'} =
$mw -> Button(-text => "Change",
-command => sub { $formElements{'button1Text'} = 'Donkey'})
-> pack();
MainLoop;

So here I created a simple form based on one of the site examples but made it a) a better minimum size rather than a very small popup with only a button on it b) added an additional button c) made the second button change the text of the first when pressed.

The standard beginner examples often skip past the fact that you can use -textvariable rather than just text and point that to a variable.

  Up

/technical/upstream/perl/gui Permanent Link Project Sitemap Top  


Tue, 26 Dec 2023

GUI Install on Mint

I forgot what I needed to install to get Perl/Tk to work on my Mint machine:

  • sudo apt install tcl
  • sudo apt install tk
  • sudo apt install libx11-dev
  • sudo apt install libpng-dev
  • sudo cpan Tk

/technical/upstream/perl/gui Permanent Link Project Sitemap Top  


Sat, 03 Jun 2023

Setting Emacs Windows in Code

(defun draw-up-windows (datFile)
(interactive "sPlease enter the package .DAT name: ")
(progn
(split-window-right)
(other-window 1)
(split-window-below)
(other-window 2)
(find-file datFile)
))

Above I define a function that asks the user for a file name, splits up the windows, moves around between them, and finally loads the file. For a very long time I have been doing this manually every time I open Emacs. I know there is a way to store these layouts to a file and restore them but I would rather just use code.

/technical/upstream/emacs Permanent Link Project Sitemap Top  


Sat, 13 Aug 2022

Perl Synopsis++

The Perl modules I am attracted to for some reason work but then mess up in strange ways. I install them with the highest hopes that everything will work out fine only to have to modify the code in some way. The purpose of my writing here is then not to teach you Perl or to parade the Perl language as being inherently better than anything else but rather to demonstrate when/how this happens and steps that I take to either work around these problems or fix them.

If you are an author and find something on this site misrepresents your module (for example if I am being incredibly stupid about using it or setting it up improperly) you can find my contact information on this site. Your help is actually very welcome.

Currently working on:

/technical/upstream/perl Permanent Link Project Sitemap Top  

Perl REPL

I was looking for something online and ran into a piece that said Perl did not have a REPL. I was a bit surprised about this and almost immediately thought, 'but we have the debugger...'

But the debugger (perl -de0), even on Linux, is not an ideal REPL environment. I figured I would look around online and found some Perlmonks stuff about Term::Readline::Gnu but I got to thinking, 'geez...you have to install a module to do this?'

perl -e 'while(<>){exit if m/^quit$/; print eval($_) . qq~\n~}'

I really just want to do something like that. Read in a line, execute it, probably store the line so I can go back and look at it, and keep on going. The previous one liner is quirky.

/technical/upstream/perl Permanent Link Project Sitemap Top  


Fri, 12 Aug 2022

GraphViz::DBI

This is a bit more experimental. I want to just show the database graphically as a big PNG file just for comparison I guess. Looking at the pod however I realize that this module is fairly old and when I try to run it I get weirdness:

perl -MGraphViz::DBI -MDBI -e 'my $dbh = DBI->connect(qq~DBI:Pg:dbname=test;port=5432;host=localhost~,qq~me~,qq~afairlystandardpass~); GraphViz::DBI->new($dbh)->graph_tables->as_png;
DBD::Pg::st execute failed: ERROR: permission denied for relation _pg_foreign_tables at /usr/local/share/perl/5.26.1/GraphViz/DBI.pm line 73.
DBD::Pg::st execute failed: ERROR: permission denied for relation _pg_user_mappings at /usr/local/share/perl/5.26.1/GraphViz/DBI.pm line 73.
DBD::Pg::st execute failed: ERROR: permission denied for relation transforms at /usr/local/share/perl/5.26.1/GraphViz/DBI.pm line 73. ...

Looks like some kind of special permissions are needed to view lots of these PostgreSQL tables/views. I am confronted with the decision to delve deeper into the problem or simply dump this module for something else.

Updates

Note: this uses Javascript to open these sections. I will eventually update this with just a POD or something. In the meantime you can just view this stuff using the Lynx browser with the permanent link below if you have Javascript turned off.

I wrote this in an earlier post but lost it due to server problems:

perl -MGraphViz::DBI -MDBI -e 'my $dbh = DBI->connect(qq~DBI:Pg:dbname=test;port=5432;host=localhost~,qq~usr~,qq~pss~); my $gv = GraphViz::DBI->new($dbh); $gv->{'tables'} = [qw~db_version customers~]; print $gv->graph_tables->as_png; ' > out.png

  Return

/technical/upstream/perl/dbmanage Permanent Link Project Sitemap Top  

IO::DB

Normally you would Install via:

sudo cpan -i IO::DB

When I try to install this way on 5.26.1 I get all sorts of errors due to the module dependencies. Turns out that this module relies on another called Class::HPLOO::Base that will not install. Apparently that module has not been updated in a while since the compile operation says certain syntax was deprecated in earlier versions of Perl.

This does not really mean I should totally avoid using this module. I just need to manually install it (or use force) and disable the so-called 'nasty bits.'

Every once in a while I get a kick out of trying to install a module manually anyway to see its dependencies (the IO::DB archive is called SDP-0.1.tar.gz). I then scoop out the module after running Perl Makefile.PL from the /lib directory and copy it to where I want it.

Give the module a quick test,

perl -e 'use lib qq~./~; use IO::DB; print 1;'

Or if you use:

cpan get IO::DB
... (get this from your ~/.cpan directory)
tar -zxvf SDP-0.1.tar.gz
cd ./SDP*/
mkdir ./olib
perl Makefile.PL PREFIX=./olib
make
make install
mv ./t/pod-coverage.t ./pod-coverage.t.skip
prove -b t

This will pass the basic tests. The pod-coverage.t only checks to see if the module documentation is complete. If you can read Perl this should not stop you from using the module.

Updates

Note: this uses Javascript to open these sections. I will eventually update this with just a POD or something. In the meantime you can just view this stuff using the Lynx browser with the permanent link below if you have Javascript turned off.

In order to extend tests why not just actually extend the tests? I copy the 00.load.t to 01.me.t and add the following to it:

use Test::More qq~no_plan~;
BEGIN {
use_ok( 'IO::DB' );
}
ok ( ( 1 == 1 ) , 'Basic test' );
my $db = new IO::DB( { db_dsn => 'dbi:Pg:dbname=test',
db_user => 'dynuser',
db_pass => 'pppaaassss' } );

my $rows = $db->sql_rows ('select count(*) as cnt from foo' );
ok ( ( $rows > 0 ) , 'Basic select count ' );
#warn $rows->[0]->{'cnt'};
ok ( ( $rows->[0]->{'cnt'} > 0 ) , 'Actually returned SQL count is correct' );

Most of this stuff is copied from the basic POD in the module. I just want to make sure it works with PostgreSQL. I think the author shows it using Sybase.

TBD

TBD

  Return

/technical/upstream/perl/dbmanage Permanent Link Project Sitemap Top  

Database Management

Here I am talking about modeling a DB and DML statements to control its formation. There seem to be lots of different ways to access your data (which is important as well if you are to work with your database) but utilities for managing the database is what I am looking for here.

Super-quick spec of things I want to do:

  • Create a table, view, and stored procedure all from the interface
  • Build some kind of utility that will allow for whatever structures to be identifiable to the program in a kind-of database agnostic way (I see various methods for accessing system tables being used which is not portable)
  • Control with field-level granularity a user's access to CRUD according to some kind of access control list (ACL),
  1. Data Access/Manip: IO::DB, SQL::Load, SQL::Abstract
  2. Structure Visualization: GraphViz-DBI

  Up

/technical/upstream/perl/dbmanage Permanent Link Project Sitemap Top  


Wed, 27 Jul 2022

Emacs

I was talking to a younger person and then, out of the blue, he asks, "pico or nano?" I had no idea what he was talking about. Then it hit me -- those are the so-called 'newer' editors that come included with modern Linux distributions. I was pretty quick to say that my first activity with a distribution is to check if emacs is installed. If it is not, install it, and then subsequently change the EDITOR in the shell by updating ~/.bashrc or something similar.

So my posts here are typically going to be about me watching someone struggle writing code in some way with one of these newer editors and respond with 'how you could have done this in emacs.'

  1. Setting Emacs Windows in Code

/technical/upstream/emacs Permanent Link Project Sitemap Top  


Fri, 11 Feb 2022

Upstream

Upstream projects are mini-learning projects that one can follow to get familiar with a technology. They should be easy enough to follow by going to a folder, reading/following the exercise, and then clicking on the Project button on the lower right hand side of the post. This will bring you back to the project page so you can click on the next one.

/technical/upstream Permanent Link Project Sitemap Top