Monday, September 9, 2019

Windows batch file to map virtual drive letter with prompts and conditional branching

I created this batch file for NPS Maricopa Inc. to help colleagues map their local Dropbox root to a standard drive letter. This was necessary because AutoCAD Civil 3D data shortcuts do not use relative paths.

@echo off

set drive_letter=P

  echo Virtual Drive Mapper
  echo Mapping to %drive_letter%:\
  echo What do you want to do?
  echo [S] Session (Map the drive until you restart Windows)
  echo [A] Add permanent (Map the drive until removed)
  echo [R] Remove permanent (Remove the permanent mapping)
  echo [N] Nothing
  set /p answer=[S]ession, [A]dd permanent, [R]emove permanent, [N]othing: 
  if /i "%answer:~,1%" EQU "S" set action=session
  if /i "%answer:~,1%" EQU "A" set action=add
  if /i "%answer:~,1%" EQU "R" set action=remove
  if /i "%answer:~,1%" EQU "N" exit /b

  if /i "%answer:~,1%" EQU "S" goto get_folder
  if /i "%answer:~,1%" EQU "A" goto get_folder
  if /i "%answer:~,1%" EQU "R" goto remove_mapping

  echo Please choose one of the given actions.
  goto get_action

  set /p dropbox_path=Please paste your Dropbox folder path here (e.g., C:\Dropbox): 
  if {%dropbox_path%}=={} goto get_folder
  goto test_folder_exist
  if exist %dropbox_path% (
    goto create_command
  ) else (
    echo That path does not exist. Please try again.
    goto get_folder

  set map_command=subst %drive_letter%: "%dropbox_path%"
  goto map_drive_%action%

  goto end_file

@echo on
  REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v "NPS Maricopa Dropbox Drive" /t REG_SZ /d "subst %drive_letter%: \"%dropbox_path%\"" /f
@echo off
  goto end_file

  REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v /f
  goto end_file


Monday, July 1, 2019

DDMSW HEC-1 Quick Start

DDMSW is a program of Maricopa County to calculate and manage drainage projects. This blog post tells the simplest way to get started using the HEC-1 hydrology part of DDMSW.

Sunday, May 5, 2019

Arrested and stranded in Chihuahua, Chihuahua

Saturday 2 Mar 2019
It's dark, and it's getting late. My bags are both heavy and ill-prepared. I need to find a bus to downtown Chihuahua. I know downtown is to the right, but a passerby assures me the bus to downtown comes from the right. So I confirm with other passersby, then cross the street to wait at a bus stop on night three of a 3-week vacation now interrupted.

Two nights ago, after singing baritone backup for the Remember When Doo Wop show at Scottsdale Shadows, changing clothes, and saying good-bye to my grown sons in Mesa, I drove to a Walmart parking lot in Benson, AZ. I slept there until I couldn't stand the cold, continued to El Paso, TX for a USA Trusted Traveler Quick Entry (SENTRI) card interview, then crossed the Zaragoza bridge over the Rio Grande into Ciudad Juárez, Chihuahua, Mexico.

Once on the Mexico side, I pulled my car into a diagonal pull-through bay where I was looked over and asked where I was going.

"To San Luis Potosi to visit a friend."

"OK. You're good."

I found the toll road to Chihuahua, Chihuahua and continued to a checkpoint at the edge of the border zone, beyond which immigration and customs law applies. I was waved through, and I spent the night in my Chevy Metro "CaRV" in the parking lot of a gas station in Villa Ahumada.

On Saturday morning I continued through Chihuahua, Chih. to its south side, where I spent the day working at Cíber Monica and consulting on dialect with a communications graduate.

In the evening I continued south toward Parral for another night in my "caRV". A few miles outside Chihuahua, Chih., I stopped at another Highway Patrol checkpoint where I was waved through. No sooner had I left the checkpoint than I saw flashing lights in my rear view mirror. I hastily worked on getting Facebook Live started as I pulled over.

"You need a sticker in your windshield," the officer told me. I replied that when I had asked about driving in Mexico on getting my visa at Nogales customs office I wasn't given anything. He replied that he'd have to confiscate my license and my car.

"Well, then, let's go to the police station," I said. He told me to go to the next turnaround and from there he'd guide me back to the checkpoint. Once at the checkpoint, one of the police officers started sketching my situation and my future.

"I want to show you a permit somebody else has. To get this permit, you have to leave a deposit, more or less $400. They will ask for your passport, registration, license, and insurance."

"Can it be done here in Chihuahua, or I need to go back to Juárez?"

"You can't do it anymore. I'm trying to find a vehicle to show you the permit. When your vehicle returns to the USA, they return your deposit. They only charge you $55. The deposit's just so Mexican customs has a guarantee that your vehicle will return to the USA."


"In a bit I will show you the document. And the judge, the vehicle is going to be impounded, you can't get the vehicle back. The vehicle is lost. And as for you, the judge will decide how long you stay arrested. ... You aren't going to be able to get it back anymore. ... I am going to drive it in to the station. ... You are going to be handcuffed. You knew you needed the permit. Tell the people on the video. Yes, you knew. Yes, you knew."

They read me my rights, showed me handcuffs, took my keys and license, and asked me to sit in their truck. But eventually they returned everything and escorted me driving back to Chihuahua where they impounded my car at the Highway Patrol headquarters (28.6128733,-106.105889 WGS84)--with me under the impression I'd be spending the night at the station waiting to see a judge. They told me to take my belongings from my car.

I was under the impression I would be spending the night at the police station where they'd give me food and water. So I grabbed my valuables instead of my necessities. So I'm standing here without adequate travel gear needing to find a hotel.

Thursday, March 14, 2019

Driving in Mexico 2019

Mexico Customs (la Aduana) considers your vehicle contraband if you leave the border zone without first getting a Temporary Import Permit (Importación Temporal) from Banjercito (Make sure you understand how your security deposit will be returned to you) in addition to your personal visa and your Mexico insurance (I got mine from GNP).  Here's my sad story:

Sunday, February 10, 2019

Thursday, January 24, 2019

Positive proof that the earth is not a sphere

If the earth were roughly an ellipsoid (even more roughly a sphere) approximately 8000 miles in diameter, it would imply several things that are clearly false:

Tuesday, January 1, 2019

How to calculate dice and cards probabilities in the 21st Century

Dice probabilities are calculated using something called the Binomial Distribution. Wait! Wait! Don't go away. This is super easy. And I'm giving you a finished calculator. But it's good to remember the name of the formula. Card deck probabilities are calculated using the Hypergeometric Distribution. For dice, here's the BINOMDIST calculator. For cards, here's the HYPGEOMDIST calculator.

Snom 320 IP phone basic configuration quick start

This assumes you have a voip account set up at VOIP.MS with a DID number and server. This is how to configure your Snom 320 IP phone for basic use.

Sunday, September 16, 2018

Best practices for HEC-RAS 2D modeling with AutoCAD Civil 3D

I've had enough experience now using AutoCAD Civil 3D and HEC-RAS for 2D flow modeling in Maricopa County Arizona to share a list of best practices. It's only a small beginning, but it's something. Enjoy.

Wednesday, August 29, 2018

How to export a shapefile from AutoCAD or Civil 3D

Somebody wants a shapefile and you are an AutoCAD user or a Civil 3D user. How can you give them a shapefile? It's pretty easy. And it requires nothing but AutoCAD (assuming you have the ADESETCRDSYS and MAPEXPORT commands available) . But you need to learn a few new tricks and terms.

Saturday, August 18, 2018

EPA SWMM Notes and Tips

These notes and tips on modeling with EPA SWMM are mostly for me.

Monday, July 30, 2018

Fast with Sam Young for LDS Child Protection

This is a rigorous log of my participation with Sam Young in a fast for LDS Child Protection.

Saturday, June 30, 2018

Authority to use digital signature for a professional engineer seal in Arizona

According to the Arizona Revised Statutes R4-30-304.G, "An electronic signature, as an option to a permanently legible signature, in accordance with A.R.S. Title 41 and Title 44, is acceptable
for all professional documents. The registrant shall provide adequate security regarding the use of the seal and signature."

Tuesday, June 5, 2018

Documenting my Democracy Spring arrests

In 2016 I was arrested three times with Democracy Spring protesting for campaign finance reform (anti-corruption). Here I am documenting videos practicing love while protesting.


My second arrest televised:
15:55 folding banner
17:00 thanking and blessing police
17:30 giving ID
18:30, 18:50 awaiting processing

1:20:00 praise for police and marchers

0:22-0:25 On right behind black shirt man
0:59-1:05 Marching behind N in big Democracy Spring with Pam Borden right of G
1:22 and 1:23 Seconds before arrest with Pam Borden 

0:26-0:28 Marching

3:03-3:12 Center and lower left screen pre-arrest
3:16 Left with Pam below left
Boy! was it hot that day sweating it out in the crowd!

Bus where they detained the men for a long time after the Philadephia arrest. I am not shown, but I was seated handcuffed further behind Kai shown here singing.

1:10-1:16 I am holding blue and red umbrella. Pam Borden is wetting her clothes and fanning.

Wednesday, May 9, 2018

How I helped myself screen spam registrations at my PHPBB forum

I get a lot of spam registrations at my PHPBB forum. So I asked new users to tell a little about themselves like this:

In Administration Control Panel, Users and Groups, Custom profile fields, I added an "about" field asking new registrants to tell about themselves. It looks like this on the registration page.

In this file
I added a line for ABOUT here:
  'ABOUT'  => request_var('pf_about', ''),
  'USERNAME'   => htmlspecialchars_decode($data['username']),
  'U_USER_DETAILS' => "$server_url/memberlist.$phpEx?mode=viewprofile&u=$user_id",
  'U_ACTIVATE'  => "$server_url/ucp.$phpEx?mode=activate&u=$user_id&k=$user_actkey")

In this file
I added a message to myself using the ABOUT template variable like this:
Subject: Activate user account

is what {USERNAME} just said about themself upon registering at the CNM Forum
That's all. Now those spam registrations take me only a second to triage and delete. Robots aren't that smart yet!