NTP and the Delay

We were setting up a check to ensure our time servers were pointed correctly from the firewall, but the standard time query was taking six seconds for each check.  With four time servers that’s nearly thirty seconds to make a simple “are you there” sort of check.  We didn’t want to do a simple ping test since this would not ensure the machine queried was in fact an actual time server.

After some digging and testing we found that if we limited the packets to a single packet the test was instantaneous.  So we added the -p argument and called it good.  (In our case we were not concerned with checking the time status but rather only the status of the server as an available time server.)

This is the basics of the command:

##
time ntpdate -qp ip.or.host.name
##

And that’s about it.  Very much faster with the p in the mix.

Share

Get git on a Server of Your Own

The trouble with searching the Web for instructions relating to git and using your own git server is that mostly you will find articles for working with someone else’s repository server (like GitHub or so many others).  You can find quite good instructions for interacting with a remote server from your local development machine, but there are so many such instructions out there that locating useful information about using your own server to host git gets buried pretty deep.

Let’s go over some of the most basic pieces, and if you know how to use git with someone else’s repository server then you will be in good enough shape to sort out your specific situation.

First we need to differentiate between the served repository and any local copy of the files you might like to keep.  You don’t necessarily need to keep a local copy of the files on the server since the repo contains enough information to rebuild the files at any point, but I’m going to show you how because I wanted mine to include server-held local copies of the files.

On your server you’ll want to create a bucket for holding any and all of your git repositories (I broke mine into projects plus an archive folder).  So your paths may look like this:

##
/media/storage/git
/media/storage/git/project1
/media/storage/git/project2
/media/storage/git/zzArchive
/media/storage/git/.repos
/media/storage/git/.repos/project1
/media/storage/git/.repos/project2
/media/storage/git/.repos/zzArchive
##

In the above example, the folder I’ve called git is just the bucket which holds the local copies of the repository files, and should not be used itself as a repository.  (If you are only planning a single repository I would still recommend using this structure as a way of being ready for the future.)  The folder I’ve called .repos is the bucket which contains the git repositories; these sub-folders do not contain any of the actual files but rather just diffs which allow git to rebuild the files at various stages.  You will see that I have a one-to-one correspondence between the .repos sub-foldders and the local copy folders above.

Move into each directory under .repos in turn and perform these actions.  Here we will just pick project1 and go through the steps.

##
cd /media/storage/git/.repos/project1
git init --bare
##

This will create an empty repository which you can clone, add files, and make commits.  This is how to make your first copy (of the empty repo) and add files.

##
cd /media/storage/git
git clone yourusername@localhost://media/storage/.repos/project1
# now move into the newly cloned directory... 
cd project1
# here you will want to add any existing files to this folder or create a new file then...
git add .
git commit -m "initial commit of new repo"
##

Now you have a good master to begin.

From your laptop or workstation or any other computer you can perform these cloning steps above but substitute the name of your server machine for localhost in the clone command above.  (This uses ssh for reading and writing to git.  You can find instructions out there for http if you’d rather use that.  I prefer ssh.)

You won’t need to use git add until there is at least one file you want git to know about.  Commits just let git understand that anything git knows you have changed is to be regarded as canon.

Add some files and make some changes. Then move into the project directory to add, commit, and push.

##
# move into some folder, probably called git, where you want to store your git repos
git clone yourusername@yourserver://media/storage/.repos/project1
# now move into the newly cloned directory... 
cd project1
git add .
git commit -m "useful commit message so you remember what the fuck you did"
git push
##

If you set up a local copy on your server like I did above, you will want to regularly git pull into that copy so the files stored there are as up to date as possible (when you run your backups for example).

As near as I can tell this is the best way to manage that for oneself.  If there are better practices than those I’m using here, I’d like to see the detailed explanations for making them work and why they are a best practice.  Let me know.

Otherwise, have a great time with your newly minted git server.

Share

AI v GAN

Another idea for improvements in the autonomous automobile space is the use of Generative Adversarial Networks (GAN’s) in the training thereof.

Normally in a GAN you might have one network attempting to identify birds in photographs, while the other network is doctoring photographs to get the first network to misidentify photoseither false-positives (birds where there are no birds) or false-negatives (non-identified birds).

In training autonomous vehicles, it may be possible to create virtual test environments where one network is working to successfully drive through simulations, while the second network is attempting to thwart that driving—either by causing the first network to crash its vehicle or by forcing the first network to halt its progress for trivial reasons.

I don’t know that anyone is doing this today, but it does seem a potentially fruitful avenue of testing and training.

Share

Change Default Mail on Mac without Launching Mail

I clicked on a mailto link at work again.  Happens from time to time.  The Mac popped up Apple’s Mail as though that might help.  I kept meaning to change my default mail application; maybe today was the day?

Anyway, all of the instructions you will find tend to be, well, the same instructions:  open Mail, open Preferences, do some other stuff.  The trouble is that unless you set up a mail account in Mail you cannot open the Preferences.

Outlook used to have a setting for taking default, but that has gone away because Security!

Anyway, I found a solution (here) involving a small amount of Python which worked perfectly.  Nothing to install.  Just copy and paste and you’re good to go.  If you are not using Outlook, you’ll have to look up whatever the bundle identifier would be for your application of choice.  Here’s the code.

##
/usr/bin/python2.7 <<EOF
import LaunchServices;
result = LaunchServices.LSSetDefaultHandlerForURLScheme(
    "mailto",
    "com.microsoft.Outlook")
print("Result: %d (%s)" % (
    result,
    "Success" if result == 0 else "Error"))
EOF
##

(The use of EOF should allow you to copy and paste the entire block into a terminal without having to separately paste each line.)

Have fun with that!

Share

Calculate Pi from Scratch

Having been inspired by a video by Matt from Stand-up Maths, I have written my first Python script.  You might be thinking “If this Matt guy is so smart, why is there an s on math?”.  I would of course feel obligated to attempt to explain how periodically English speakers attempt to re-Latinize words that may or may not have any connection with Latin, but that would really be taking us far afield.  Let’s concentrate on what really matters!

What really matters is that I have written my first Python script and I have put the first of my scripts on my GitHub repository for all to love.  Love it!

JamesIsIn / blech

Basically, the script (with some prompting from the user) rolls pairs of dice and seeks out whether those pairs are coprimes or not.  It that uses that data to calculate an estimate of pi.

You can watch Matt’s video here:

He studied in Australia how to be funny at math!  Success.

Share

VSCode, Ubuntu, and Pylint

If you are running VSCode on Ubuntu and working with Python files, you may notice it telling you that Pylint isn’t installed and that you should choose a linter.  I don’t know much about linting or why I should care, but I do know that I don’t need VSCode alerting me each time I touch a Python file that Pylint isn’t installed.

So I looked into it.

Turns out I do have Pylint installed.  Turns out it is installed right where it would be expected.  Turns out that is a location which is in my PATH, by default.  Turns out that VSCode already knows all of this.  At least I can which pylint in the VSCode terminal and get an answer.  In fact, I get the correct answer.

And yet VSCode thinks it’s not installed.

It’s an easy enough fix.

##
# Add this change to your personal user settings file in VSCode:

// 20190420 Because VSCode can't find it...
"python.linting.pylintPath": "/usr/local/bin/pylint",
##

(I always make a note including the date whenever I make a change in a configuration file. Can be important later.)

Make that change and restart VSCode.  You should stop seeing this error.  You can read more about this here.

Share

The Smart Toilet

I have been kicking this idea around for years and am only now finally publishing something about it.  The title really tells it all.  The next big thing?  Sure.  You poop in a toilet every day, so let’s make a toilet that crowd sources medical and related data to tell you how you are doing.

(I know we use toilets for urine as well, and everything I am saying here about poop should be thus extended to urine as well.)

I suppose it will need a sort of garbage disposal or blender component.  It would presumably work from assays of your excrement, and make whatever various tests or analyses it will be capable of doing (which ought to increase over time).

Currently there are a number of states we can assess from human excrement.  I don’t know them well enough to list them all here, but things that come quickly to mind are pregnancy, some kinds of cancer, kidney issues, bowel issues, &c.

Imagine how this smart toilet might make various important measures each time you use it.  It would know you are you based on your account.  It would catalog everyone in a poop database.  This data could be made available to the medical community.  This could be done both specifically (your doctor could be allowed to access your data) and generally (your data would be part of the big data that researchers could use to further our knowledge and advance our research projects).

It could alert and advise things such as “you should have your kidneys checked and refer to test xxxx when you do” or “you should do a pregnancy test” directly to your smart phone (or whatever method you might choose).

Now lest you think I’ve gone mad (or think this is just one more data point in a long line trending toward madness), here is a great video concerning human gut biology in which the speaker specifically mentions a smart toilet!  Yay, me!  (He mentions the toilet at about 50:30 but the whole talk is quite excellent.)

Have fun out there!  Keep pooping!

Share

AI v IR

To my knowledge no one is currently taking advantage of camera sensors’ (typically) inherent ability to capture inferred (IR) data. If someone is, good on them. Someone will tell me at some point.

Camera sensors often (always?) are able to collect data beyond the visible spectrum into the inferred (and presumably into the ultraviolet (UV). It seems clear to me that parsing this data can be useful to an autonomous vehicle in identifying human and other animal agents on and near the roadways. (There may be similar benefits available in parsing the UV wavelengths as well.)

There are situations (especially at night) where IR will allow human and other animal agents to stand out against the background in ways the visible spectrum cannot. IR (and UV) may be able to usefully augment the lasers currently being used as well to provide a more robust dataset and thus more complete picture of the world for autonomous vehicles.

This may also help to solve some of the problems associated with windows and similar either reflective or transparent surfaces (as they should typically produce different IR ranges than the surrounding surfaces (and again perhaps UV differences)).

Another related source for potentially useful information would be comparing polarized lens data with standard lens data.

Thoughts?

Share

Powershellish Mailbox Creation

Found these old notes for making a post.  Figured I may as well move the notes here even if they are less relevant.  Maybe it will be useful to someone.

Mailbox Creation

Sometimes those old Exchange gui’s just ain’t enough. Time to bust out the command line. Here is some very useful information about doing just that.
So, of course, there is a special command prompt you will want to use: the Exchange Management Shell.

Main Data

I pulled this directly from the MS helps pages in Exchange. I did, however, add the very important (and neglected) identifier for each of these five mailbox types (at least my best guess):

User Account:

##
New-Mailbox -Name -Database -OrganizationalUnit -Password -UserPrincipalName [-ActiveSyncMailboxPolicy ] [-Alias ] [-DisplayName ] [-DomainController ] [-FirstName ] [-Initials ] [-LastName ] [-ManagedFolderMailboxPolicy ] [-ManagedFolderMailboxPolicyAllowed ] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName ] [-TemplateInstance ]
##

Linked Account:

##
New-Mailbox -Name -Database -LinkedDomainController -LinkedMasterAccount -OrganizationalUnit -UserPrincipalName [-ActiveSyncMailboxPolicy ] [-Alias ] [-DisplayName ] [-DomainController ] [-FirstName ] [-Initials ] [-LastName ] [-LinkedCredential ] [-ManagedFolderMailboxPolicy ] [-ManagedFolderMailboxPolicyAllowed ] [-Password ] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName ] [-TemplateInstance ]
##

Room Account:

##
New-Mailbox -Name -Database -OrganizationalUnit -Room -UserPrincipalName [-ActiveSyncMailboxPolicy ] [-Alias ] [-DisplayName ] [-DomainController ] [-FirstName ] [-Initials ] [-LastName ] [-ManagedFolderMailboxPolicy ] [-ManagedFolderMailboxPolicyAllowed ] [-Password ] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName ] [-TemplateInstance ]
##

Equipment Account:

##
New-Mailbox -Name -Database -Equipment -OrganizationalUnit -UserPrincipalName [-ActiveSyncMailboxPolicy ] [-Alias ] [-DisplayName ] [-DomainController ] [-FirstName ] [-Initials ] [-LastName ] [-ManagedFolderMailboxPolicy ] [-ManagedFolderMailboxPolicyAllowed ] [-Password ] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName ] [-TemplateInstance ]
##

Shared Account:

##
New-Mailbox -Name -Database -OrganizationalUnit -Shared -UserPrincipalName [-ActiveSyncMailboxPolicy ] [-Alias ] [-DisplayName ] [-DomainController ] [-FirstName ] [-Initials ] [-LastName ] [-ManagedFolderMailboxPolicy ] [-ManagedFolderMailboxPolicyAllowed ] [-Password ] [-ResetPasswordOnNextLogon <$true | $false>] [-SamAccountName ] [-TemplateInstance ]
##

Examples in Action

Create a shared mailbox:

##
new-Mailbox -alias testsharedmbx -name TestSharedMailbox -database "Mailbox Database" -org Users -shared -UserPrincipalName testsharedmbx@example.com
##

Realworld example:

##
new-Mailbox -alias sanfrancisco -name SanFrancisco -database "Mailbox Database" -org "simplecompany.lan/simpleCOMPANY/Resource Accounts" -shared -UserPrincipalName sanfrancisco@simplecompany.lan
##

Notes:

  • alias is the whatever@
  • name relates to the display name

Adding Permissions

Main Data

##
Add-MailboxPermission
Add-MailboxPermission -Identity "Some User" -User DonaldK -Accessright Fullaccess -InheritanceType all
##

To this point everything is more or less clear but people find it hard to find more parameters for -Accessright, which is actually the most important part of the command. Here they are:

  • FullAccess
  • SendAs
  • ExternalAccount
  • DeleteItem
  • ReadPermission
  • ChangePermission
  • ChangeOwner

Examples in Action

Realworld example:

##
Add-MailboxPermission -Identity SanFrancisco -User "simpleCompany San Francisco ACL" -Accessright FullAccess -InheritanceType all
##
Share