Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Tuesday, January 05, 2016

Dynamic Keypad / User Interface Elements (Quadro, Keypad)

BRIEF

When I started I expected this to be a review of several user interface packages, beginning with Keypad.   But I fell in love with the second package I tried, Quadro, so it has turned into a set of notes, mainly about problems, with Quadro.

Let me be clear:

Quadro (and Keypad, and several other apps) are "dynamic UI touchpads".  Software apps running on your touchpad cellphone or tablet, where you can define macros to interact with apps, typically on another device like your Apple Mac or Windows PC.

Quadro runs on an iPhone or iPad, and controls a Mac or PC.  Closed source, questionable security.

But... I love Quadro.   I want Quadro, or tools like it, to be popular, available everywhere, and successful - because I believe that tools like Quadro will help make me more successful in my work.

I like Quadro enough that I very quickly paid 50$ to support its development. Quadro is freemium, free to most users - but I believe in supporting stuff that I like.

I like Quadro enough that I am considering buying a used iPad so that I can get more surface area for buttons.

Quadro has problems, some noted here.   Some of these problems are severe enough that at the time I am writing (Jan 8, 2016), I would not recommend Quadro to most users.  But if these problems are fixed, if Quadro works reliably, I would recommend it to almost anyone who uses the computer for more than a few hours a day.



DETAIL

ISO of better User Interfaces

Not just "apps written by the original author that have better user intefaces" - although that is good.  Here I am specifically talking about tools to give myself a better user interface for an existing app written by someone else.

I have long been an advocate of "single command key big button email reading" (se notes at bottom). I have mashed up macros and menus and buttons to do this in many systems: AutoHotKey, various web tools.  Custom keyboard shortcuts. Etc.  Emacs, of course.

Recently, over Xmas, sharpening this particular saw: started off by starting to use Karabiner on MacOS (which allowed me to create keyboard shortcuts bound to spacebar, the only "big button" that is commonly available).  Frustrated because I need more than one big button, I started googling for physical buttons that I might be able to bind actions to, which led me to https://flic.io/.  Looks neat; if I had seen this during the funding phase, I would have signed up; but the current flick button looks too thick for my application: I would like to have a few such buttons stuck to my laptop, next to the trackpad.  Thin enough so that the laptop would close. Besides, I really wish that it had electric paper display surface so that I could display its current binding.

This line of thought led me to thin about an app or apps that would run on my iPhone (or one of my old Android devices), touchscreen key shapes, that would send commands, shortcuts, to my laptop, or to other apps on the iPhone.   User definable, so that I could always have a custom pad of the 4 or so commands that I am using most often.

Searching for things like "Android remote keyboard for laptop" and "iPad touch control of PC" led to first the Keypad app for iPhone http://keypad.iosproapps.com/, and then to Quadro  http://quadro.me/

Actually, to many, many, remote keyboard, mouse, keypad, joystick and other apps.  Keypad and Quadro are just the first two that I have started to look at.

Briefly: (more detail in separate sections)

Keypad easy to use.  VNC based.   Does not work with encrypted VNC - 8 character passwords. Gah!!!!  But easy to use.   Got something working in a few hours.  And then ran into problems like lack of version control, GUI only, no text file representation.

Looking for something better: of the many alternatives, Quadro seemed to have the biggest aspirations.   Security unknown.  Handshakes, interacts, with apps, not just macros sent blindly across. Version control?  Text files?  Harder to set up than Keypad.  Nevertheless, has aspirations, expressed in incoherent Italian inspired English: putting my money where my mouth is, I am about to pay 50$ to support further development.

This blog entry to record notes about Keypad, Quadro, and the overall field of such apps.   Notes about Quadro to collect and hopefully suggest to developer; notes overall because I want such better user interfaces.   I'm a CPU designer, but it's all about the user interface, baby!!!


(Gosh, I wish that blogger had a TOC.  Need to stop using this.)

Keypad App

http://keypad.iosproapps.com

Very easy to set up a custom keypad.  Nice collection of buttons, widets.  Swipe pad. For that matter, allows full touch control.

The usual problem of macro shortcut bindings: lack of interaction.  What happens if a binding is pressed, but not appropriate for the current app? Etc.

VNC based.  Recommends non-encrypted VNC, only 8 characters of password.  Gah!

Security offputting.  My last straw was realizing that there was no easy way to diff configurations.  No text file.   They do allow you to save and email config fules to yourself, but the format is binary.

So I kept looking.

Quadro

http://quadro.me/

Googling kept turning up Quadro.

Eventually realized that I had written enough about Quadro to warrant aa page of its own: http://blog.andy.glew.ca/2016/01/quadro-i-love-it-when-it-works-but-it.html

Currently, Jam 10, 2016, after a week of using Quadro, 
  • I am still hopeful that Quadro will be a good tool
  • I am frustrated, driven to exasperation, by how unreliable and flakey Quadro is.
    • Almost par for the course with this sort of application, although I suspect that Quadro, because of its command rather than keyboard orientation, hangs more than most more "Raw I/O" based tools in this class.
    • I was about to give up using Quadro today, but I am figuring out that it is more reliable in some environments than others.
  • I can't say that I regret contributing 50$ to support Quadro development, the maximum freemium they provide.  But I sure wish that it was more reliable.
  • I remain concerned about security, lack of.

After trying Quadro

As mentioned above and elsewhere, I became quite exited about Quadro, hopeful that the Quadro developer had improved the state of the art in such applications, which often have problems wrt error handling.   However, Quadro drive me almost to tears, being *almost" good enough - good enough for much of my needs - but failing, hanging, crashing a slot.  So I have kept looking.

Android "Remote Macro Keys"

I have not yet installed to try.  Notes from the Google Play store and googling.

"Very light"

Java server on PC.

Sounds as if mainly macro based.

No mention of Mac.

No mention of non-I/O macro, OSA/AppleScript or VBAS or ...

Limited ads.

Sounds "sincere", but the usual worries.

Security: UNKNOWN.

Open Source: UNKNOWN.  Have not verified whether the Java server is bytecodes or source.

Config file: ??
Diffable: ??
Version controllable: ??
Text config file: ??

I am not sure of whether "Remote Macro Keys" has a versionable-diffable-text config file.  



I do know that just before I found Remote Macro Keys, I found a similar Android project, macro keys or the like, that describved itself as Open Source and having an XML config file - but I am not sure if it was local macros, or remote.

It is rather typical for Android products to be more open source, more likely to use text config files, in "the UNIX way".



Android "Mouse and Keyboard Remote"

More Android SW.  PC Server.  Speech?


DIY physical keypad 

http://www.instructables.com/id/Making-a-powerful-programmable-keypad-for-less-tha/

These guys reminded me about xkeys.



X Keys 

http://xkeys.com

This was the sort of physical device that I was originally looking for, when I decided to go search for programmable

Reputation: good: I have used XKeys products before, mainly the Y-mouse. Never bought the keypads before, but vaguely remembered them.

Keypad flavors

  • XK-24 keys, 4 horizontal x 6 vertical
  • XK-80, 10 horizontal by 8 verrtical
  • XK-128, 16 horizontal by 8 vertical
  • sticks: XK-4, 8, 16 - that many keys in a 1 high row, nice to put at top edge of keyboard.
All keys same size (I remember seeing similar products with keys of different sizes, possible addons)

Modern devices all USB.  Macros are programmable using PC/Mac software; once programmed, retains state, so that can use on other devices that accept USB input.

Keytops are NOT dynamically changeable, the way something like Quadro or "Remote Macro Keys" is.



LCD Keytops - E3-Keys

Finally Google coughed up a device that has physical keys with LCD, dynaimic, keytops:

http://www.e3-keys.com/english/index.htm

I knew it was out therre.   ICAWTK, googling "LCD keytops" found it (too many false hits for "LCD keypad", etc.)

Nice: they have history going back to 1978 in an IBM Technical Disclosure Bulletin. http://www.e3-keys.com/english/history.htm.  Apparent a German company LcBloc Computer Technologie GmbH  1984.

(Mouse Parker between these two.)

Doesn't look consumer ready.   Doesn't look cheap.   But may be able to find somebody else.

Of course, why would I want LCD keys, if I can get a touchpad like Quadro working?   Only if one does USB and works everywhere, and one does not.  Making an IOS or Android device into a HID doesn't seem to have been done.

Optimus Keyboards

Same query as found e3-keys also found

Optimus family - Art. Lebedev Studio

www.artlebedev.com/portfolio/optimus/

and

https://en.wikipedia.org/wiki/Optimus_Maximus_keyboard

I have seen this before, and lusted after it.   But it appeared at the time to be vaporware, indeed receiving a Wired Magazine Vaporware award, 2007.  However, if wikipedia is to be believed, it is shipping now - not just full keyboard, but also smaller keypads.  The ArtLebedev website shows some as "sold out", the Popularis as shipping now, and several concepts.

Reviews are mixed.

http://www.artlebedev.com/ shows several more, such as the Tactus, no physical keys, just touch everywhere, or the Upravlator.  But "Expected to be available for sale in the second half of 2008" several with no updates in 7 years do not inspire confidence.

Overall, http://www.artlebedev.com/ seems to be a design house, with many neat ideas.  But probably not so much a consumer computer products company.

The keyboards are not for sale on their web.store. Well, maybe the Optimus Popularis is, at
http://store.artlebedev.com/electronics/optimus-popularis/  - the website has twisty pasages that do not directly connect.  1500$US.  Ouch!

Sonder Keyboard

https://www.sonderdesign.com/

e-Paper keytops.

Bluetooth.

Website with a pre-order button in Jan 2016, 200$, Pilot 2016Q2.


Virtual Laser Keyboard

There are several "virtual laser keyboards that project a pattern onto a flat surface, and sense where the user types.

http://www.ctxtechnologies.com/products/vk-200-keyfob-virtual-keyboard/

All that I know of provide a standard keyboard or numeric keypad.

I wonder if any of them could be programmed dynamically?


Some Personal History

Single Command Key Big Button Processing

of Email, and other Repetitive Stuff


I have long been an advocate of "single command key big button email reading".

But I oversimplify:

+ Not just single command: I often use multiple commands, e.g. the command I use most often in email, Archive, as well as a few others: Defer to handle later, file into one of 2-4 top projects, etc. Just not the full set of commands that the application provides.

+ Not just single key: although I prefer to use a single big key, like spacebar or caps lock spacebar for archiving,

++ sometimes I multiple key chords or sequences, and more than one of those: e.g. control+spacebar, and sometimes multiple keys - command+1 fir project 1, command+2 for project 2

++ sometimes I will use menus - especially menus that I can navigate by keystrokes as well as mouse

++ sometimes I bind the commands to the many buttons on my trackball (4 buttons, with various click combinations and modifiers)

++ sometimes I mash up controller pages, like webpages, with hot touch areas

++ Not just big keys:  as above, although if I am at a keyboard in an editor where keystrokes are hardwired, I may use small keys

+ Not just email: although email is my current hot button task, I have done things like this for repetitive tasks such as evaluating patents.  Whereas many folks were only able to read 100 patents a day, because of the slowness of clicking around to various information sources, I mashed up an interface (in Excel, last time), that traversed a list, automatically opened the information sources I needed, and which allowed me to give a score plus certain keywords - and was thereby able to process tens of thousands of patents.  So many that I cannot remember details of most of them (so don't accuse me).

More Personal History - Devices

I have a collection of I/O devices that I have used for this sort of task: gamer joysticks, keypads, gamer gauntlets that I could bind commands to ever finger motion of.  Foot pedals, etc.

These separate from my collection of I/O devices for normal use.  I never expected to use these gamer button pads for day-to-day computer use.  But when I have 2-3 months of a repetitive task,  like reviewing patents or papers, I felt tat a bit of investment in custom hardware was warranted.

I have long wanted a keyboard that had LCD or e-Paper tops, where the current bindings could be indicated.  e-Paper for long lasting.  LCD or other quickly changeable, e.g. for Emacs multi key bindings.  Type in ESC, and see symbols on the keytops for next actions.   I vividly remember a McGill meeting, circa 1984, with some vendor showing us a then state-of-the-art workstation, and Der Mouse Mike Parker flummoxing him by asking for LCD keytops.  I re,ember there was a Russian company promising such a keyboard, more than two decades later, but nothing came of it.

Friday, January 01, 2016

Metronome for Walking Pace/Cadence while listening to Podcast or Audiobooks

Brief

Looking for a metronome app to provide cadence while walking and listening to podcasts and audiobooks. iPhone can't, but Android can.

FAIL: I felt all good about kuewlsoft's Metronome app - but on the first longish walk I learned that it turns off when the phone is locked.  Trying other Android apps. So I created the table at Metronome Comparison Spreadsheet.

I thought that I was narrowing down to Rhythmic Metronome, Zenom Metronome, and B'Metronome - but after a week I switched back to kuewlsoft's Metronome app.  kuewlsoft's good metronome features - a tolerable click that does not offend my ears, the ability to specify emphasis clicks, volume controllable separately from the overall volume of the podcast - make up fr the problem of turning ff when I lock the phone.

I cope with kuewlsoft's Metronome turning off if I lock the phone by not locking the phone - after all, it is not my real phone, just an old Android phone (because iPhone can't mix two sound sources). At first when I put it in my pocket I had problems with accidentally hitting screen buttons - but my low-tech solution to that is to have a stuff piece of cardboard that covers the screen.

I can live with kuewlsoft Metronome, but I would still like to find a better Metronome app.  Must-have wants: simultaneous, works when locked, sounds nice, emphasis, 3:4 time, rates 100-160 bpm.  Wanna haves: controllable volume and rate from my headset.  In my dreams: a "smart" metronome that adjusts to encourage me to be faster, even if I slow down climbing a hill.

Haven't looked at pay apps. Some of the free but $ upgrade app$ look interesting, but I don't have time to search all.  Looking for software sucks.

Walking

Walking is my main form of exercise. (One hour+ per day, 3+ miles per day; because I have a dog; because my knees are shot from too much hill running and soccer stomping in my youth; because I live next to many miles of beautiful trails in Portland's Forest Park.  I also swim and climb, but I do not live next to a swimming pool or a climbing wall.)

I love walking in quiet wilderness - but in a city like Portland, the woods are often not so quiet.   Plus, 2 hours a day really impacts other things, like continuing education. So I often walk while listening to podcasts (NPR news, computer security), or audiobooks.

Plus: when I do exercise in a gym (elliptical, treadmill, rowing), I was bored out of my skull until I stated listening to podcasts.

Problem: listening to human conversational voices, in news, podcasts, audiobooks or lectures, leads to a moderate, sauntering, walking/jogging/running pace.  Too slow a rate of exercise.

Now, folks who listen to music while exercising often choose songs with a target beats per minute rate.   But, I prefer learning to listening to music.

I have tried podcast players that compress, speeding up.   Unsatisfactory.


ISO Metronome for Exercise Cadence

I decided to try having a metronome tick or ... at my target cadence and gait, while listening to my podcasts.  How hard can that be?

I tried running such a periodic metronome on my Pebble watch, buzzing 100-120 times per second.   Drains the battery much too fast.

So, instead let's put the metronome on my phone. iPhone - I wish.

There are many, many, metronome apps for iPhone or Android.  Most for music, some specialized for running or hiking.

Annoyingly, apparently iPhone iOS is incapable of having both a podcast app and a metronome app running at the same time, and combining (mixing) their audio output.   Start the metronome playing, then start the podcast, and the metronome app stops, and vice versa.

Annoying but not necessarily surprising, given what I know about iOS.  Android is more of a real, multitasking OS, so is much more likely to be able to play sound from two apps simultaneously.

Gives me a reason to revive one of my old Android phones, to use as a dedicated podcast player and metronome.   Especially since I have not found any iPhone podcast player that is as useful as BeyondPod on Android.  Lossage:  my iPhone won't be able to act as a phone on my walks - but most of my walks in Portland's hills have no or little cell phone contact.   Actually, the biggest lossage is not so much the cell phone functionality, as having another device to have to keep charged, and having to pair my bluetooth headsets between Android and iPhone.

Note: I do not want to do my own audio mixing.  I might if I were playing music, but I tend to listen to podcasts or audiobooks once and then never again.  Plus I want to be able to dynamically adjust.

Note: real audio mixing, combining output from two apps, might be most desirable.   Require separate volume control.  Might be nice to be able to overlay arbitrary music on my podcasts and audiobooks.  But, metronomes are a special case, and may not require full mixing.


What I have found and am using

Anyway: 6-12 hors of research, and evaluation of Android apps.  Here is what I have ended up using:

FAIL: can't find a way to play both a metronome and Podcast/Audiobook on iPhone

FAIL: metronome app on Pebble watch causes battery to drain too quickly. (If battery life were not a problem, I think that I would very much like the Pebble watch as a pacemaker.)

WIN: old Android phone, with the "Metronome" app by keuwlsoft, with BeyondPod and Audible audiobooks.

Metronome by Keuwlsoft:
  • no ads
  • no permissions
  • adjustable beats: major, minor, muting, subbeats
  • adjustable rate beats per minute
  • 3 sound effects
For my purpose, the visual effects are useless - the phone is in my pocket, the sound plays in my earphones.

This is what I homed in on for my current use.

FAIL: I felt all good about keuwlsoft's Metronome app - but on the first longish walk I learned that it turns off when the phone is locked.  Certain other Android apps do not. :-) See Metronome Comparison Spreadsheet. But after a month, I am still using keuwlsoft Metronome, with a kluge (a stiff piece of cardboard to cover the screen)  to cope with keuwlsoft turning off if I lock the screen.

Criteria for Exercise Metronome
  • Simultaneous metronome and other audio source
    • MUST HAVE
  • Ability to adjust metronome rate.  
    • NICE: dynamically.   
    • NICER: dynamically, hands free. 
      • I don't know any app that does this.
  • Separate volume control
    • not quite must have, but pretty darn close
  • Separate ticks in each ear, for left/right foot
    • NICE?  helps keeping pace
  • Metronome sound
    • Many metronome apps have a single, hardwired, beep/click/chirp.
      • This may work for practicing piano
      • But it is not good if this chirp makes it impossible to hear the podcast or audiobook
    • VERY NICE, almost ESSENTIAL: ability to select a more pleasant sound
      • Possibly nice if you have a wide selection, or can provide your own
      • However, the metronome app I chose, keuwlsoft, had only 3 hardwired choices - 2 of which were acceptable.
  • Beat patterns
    • at first I thought that only a fixed beat pattern would be sufficient.
      • Q: tick every foot, or only on left foot?
    • but I quickly learned that a pattern of major/minor beats is helpful
      • NOT 1/2 time - not major every left, minor every right - seems to cause asymmetric gait
      • BETTER 3/4 waltz time: TICK-tock-tock-TICK-tock-tock - so that major beat alternates feet.
        • 3/4 time is a bit of a misnomer - the 1/4 is irrelevant.   It is really just a cycle of 3 beats, with different ephasis.
        • After a few days I figured that TICK-TICK-tock works better that TICK-tock-tock.  Go figure.

Ads and permissions: 
  • many metronome apps (and apps in general) require excessive permissions and serve obnoxious ads
  • it may be reasonable to allow a metronome app permission to
    • write files (to save carefully crafted rhythms, e.g. if you are a drummer)
    • read files - in particular, sound clips that you want to be use for the ticking
    • automatically mute when the phone rings
  • but I chose the keuwlsoft Metronome app that required no such permissions
Advanced Features for an "Exercise Cadence Metronome"
  • Accelerando
    • if you are trying to speed up, as I am, it might be nice to start at a first rate, say 100bpm, and smoothly accelerate to 120bpm over the space of a half hour or so
    • some musician oriented metronomes, such as the keuwlsoft Metronome app I chose have such an accelerando feature, but the timescales are not so appropriate to exercise
    • I am doing "long term gradual accelerando", trying to add 1 step per minute to my pace - every so often.
  • Rate programming
    • ramp up/down
    • intervals
  • Dynamic Rate Feedback
    • Some running oriented metronomes can detect your running speed, and compare it to your desired goal.  
    • I can imagine real dynamic feedback
      • trying to gradually accelerate to desired goal
      • with warmup and cooldown
      • possibly with adjustment according to incline
    • Feedback with heart rate and/or landspeed
    • After use, my main hope for feedback is
      • Detect the rate I am stepping at, and time clicks to try to encourage me to be just a bit faster
      • It may not be appropriate to just click at 128 spm when I am walking at 127 spm
      • I think that it might be better to dynamicaly adjust by phase: e.g. to advance a tick by a small amount - 1ms? - perjaps non-uniformly through my step cycle.  Not increasing rate before it looks likely that I can match it.
    • I would live to have dynamic cadence adjustment that
      • adjusts automatically if I slow down to walk up a hill, or other
I have noticed that my cadence varies during my walks, according to conditions: hill, hard vs soft surface, fatigue. I can walk faster in the morning than just before bed.
     It is a bit of a pain to adjust this, since it is a pain to have to take my phone out of my pocket.  I wish that I could adjust it from the headset that I wear to listen to the podcast and metronome, or possibly from my smartwatch.  


Thoughts about Wearable Devices

UI devices: phone (rectangular slab of glass with touchscreen); watch (wrist mounted display, with vibes, buttons and/or touch); headset (sound output, sound input, buttons and/or touch in several places.  Voice control with audible feedback, but that's hard to get right.)

More and more I wish to avoid having to click on my phone.   It may be okay for the phone in my pocket to be my "personal server", connected to devices like headset and watch by wireless like BlueTooth.  The phone is big, can hold a big battery, and probably diffuse more heat.  The big screen is okay for interaction when I want to browse the web.  But I really wish that I could do more, control more, without the phone.

I can control overall volume using my headset.  But I cannot control the volume of the metronome separately from the podcast - I have to pull out my phone to do that. :-(

I can skip forward or back in podcast from my headset.   I can stop/start the podcast from my headset.   But I cannot styart/stop the metronome.

I wish I could adjust the metronome rate from my headset.

My headset is cheap.  It has essentially 5 controls: on/off, with long presses for extra control.  Volume up/down.  Select forward/back. All of these contyrols are on one ear.
     I would gladly be willing to pay a bit extra to get 5 more controls on the other ear.

Or perhaps I should try to get these controls from my SmartWatch.   I.e. use watch and headset in conjunction.   The watch display gives a more dunamic selection of controls.   More irritating that just touching a button on my headset, but more variety, and less irritating than having to pull my phone out of my pocket, unlock it, and then interact.

I have done limited amounts of Siri voice control handsfree from my headset, but Siri requires too much screen interaction.




How many Steps per Minute?

     Note: writers differ as to whether you would walk at 60 steps per minute or 120.  The factor of two difference is due to counting steps by both feet or not.

    http://www.ontherunevents.com/ns0060.htm

    Heart rate more important than speed or steps per minute. Mix it up. Interval training.


    LEVEL 1: VERY INACTIVE: 80-100 steps per minute = 2 mph (30 minute mile)

    Some widely referenced studies talk about 100spm as moderate exercise.


    LEVEL 2: LIGHTLY ACTIVE: 120 steps per minute = 3 mph (20 minute mile)

    Weight loss: slow, 3 mph, 60-70% MHR (Maximum Heart Rate). Not aerobic. 1-2 hours a day. 120 steps per minute. 


    LEVEL 3: MODERATELY ACTIVE: 130 steps per minute = 3.5 mph (17-18 minute mile)


    LEVEL 4: ACTIVE: 140 steps per minute = 4 mph (15 minute mile)

    Aerobic: 75% MHR. 20-30 3x/week. 140 steps per minute. 


    LEVEL 5: VERY ACTIVE: 150 steps per minute = 4.3 mph (14 minute mile)

    Jogging, or race walking.


    LEVEL 6: EXCEPTIONALLY ACTIVE: 160 steps per minute = 4.6 mph (13 minute mile)

    Endurance/Fitness/Speed: 80-90% MHR. 160 steps per minute,


    LEVEL 7: ATHLETE: 170 steps per minute = 5 mph (12 minute mile) 

    Most walkers need at least a year to develop paces of 170 spm (12 minute mile) or faster. 


    LEVEL 8: ATHLETE : 180 steps per minute = 5.5 mph (11 minute mile)


    LEVEL 9: ATHLETE: 190 steps per minute = 6.0 mph (9-10 minute mile)


    Using CUA ^C/^X/^V as well as command-C/X/V on Mac

    I have been using my MacBook as my primary computer for a year now - and I still have trouble typing command-C/X/V for copy/cut/paste, rather than the Windows like control-C/X/V.

    More precisely, perhaps, the CUA, Common User Access, key bindings, that date back to Xerox PARC (and earlier, I think). http://en.wikipedia.org/wiki/IBM_Common_User_Access

    Oddly enough, I had managed to make the transition in my first few weeks or so, perhaps a month, on the Mac - up until I got a proper emacs working on my Mac. Now, I do NOT use ^C/^X/^V key bindings on Emacs.  But for some reason using Emacs pushed any new key bindings out of my cache, and I found that I started experiencing control/command confusion on Mac apps more often. Perhaps this happened because emacs uses SO MANY control key bindings - and I decided not to use any of the several ways of having emacs treat Mac command key as equivalent of control in standard emacs key bindings. (TBD: notes on this: briefly, doesn't always work).   So control is in the front of my mind when using emacs, even on a Mac.   Or perhaps this confusion became more prominent because when I am using emacs I work faster - so the errors waste a greater fraction of my time.

    Sometime over Xmas this became really frustrating, so I set out to fix it.

    Now, I do not want to globally swap command and control.  I want to use standard Mac key bindings as much as possible.  Also, globally swapping command and control messes up other apps, such as Windows RDP.   No, instead all I want to do is to take the keys that are problematic - typing ^C instead of command+C, etc., in my web browser - and remap only those keys.  While leaving the standard command+C/X/V bindings unaffected.

    Ideally, do this in only the apps where I am constantly making these errors - mainly, cutting and pasting between my web browser and emacs.   Or do it globally, but ideally without affecting the existing emacs keybindings - i.e. have ^C behave like command+C in my web browser, and in most other places, but not in emacs or any place where the standard Mac bindings do not apply.

    Here's a post along these lines:

    http://apple.stackexchange.com/questions/66970/remap-ctrlc-ctrlv-and-ctrl-x-only

    Here's a great webpage about Apple Cocoa key bindings:

    http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html

    Surprisingly, Apple's Cocoa key binding mechanism is almost as powerful as EMACS'.  It permits nearly any key to be rebound, it allows emacs-style multiple key sequences to be bound, and it allows multiple bindings to the same command.

    Surprising or not, most Apple key binding tools do not provide anywhere near this control.  Why not?  I conjecture that this is a carry-over from NeXT, from the old days when Men were Men, and Power Users wanted real keyboard control.  But that it has fallen into disuse with the rise of mass market non-power-user computing, and "usability" gurus who deprecate functionality.

    Also, while the remapping facility is powerful, it only applies to Cocoa apps.  It is not ubiquitous.  Apple has a long history of "software model tunnel vision", reflected in security bugs such as the "We assume that everyone is using Objective C,and cannot forge message names".

    Anyway, here's what I ended up doing: placing the following in ~/Library/KeyBindings/DefaultKeyBinding.dict

    {
        "^a"        = "selectAll:";                     /* C-a  Select all */
        "^x"        = "cut:";                           /* C-x   Cut */
        "^c"        = "copy:";                          /* C-c          Copy */
        "^v"        = "paste:";                         /* C-v          Paste */
        "^z"        = "undo:";                          /* C-z          Undo */
        "^y"        = "redo:";                          /* C-y          Redo */ 
    }
    Now, this provides the mappings in all Cocoa apps. No ability to say "do this only in Chrome".  But it seems good enough for now.

    Tuesday, December 22, 2015

    Perl one-liner to run all tests in a directory tree

    This is a Perl one-liner to run all tests in a directory tree:
    perl -e 'use File::Find; finddepth(\&wanted,"."); sub wanted { if( $_ eq "Makefile" ) { system("echo $File::Find::name; make -k test"); }} '
    OK, I admit it is a rather bloated one liner.

    Quick and Dirty Test Suite

    I remain an advocate of a quick and dirty test suite structure that is assembled in a directory tree, with tests in directories marked by a Makefile (with a test target), or a shell script, or...

    This is an easy way of integrating tests that come from different test suites, with different assumptions.  It is easier than having to write an adapter from your-favorite-Perl-Test::Unit-test-suite to your favorite Javascript-test-suite, and vice versa, ad infinitum.   Actually, the directory structure, and the convention that there is a Makefile with a test target is an adapter - but a fairly low level, universal, adapter.

    I usually accompany something like this one-liner with a script that greps for common indications of test failure, such as the string 'TEST FAILED'.  I also like positive indications of success, such as 'TEST PASSED'.  I like being able to create a green bar widget.

    I am not a big fan of Makefiles as a scripting solution - but they are fairly ubiquitous.  A Makefile with "make test" is more standard than a shell script called something like 'run-test.sh'.

    The above one-liner does not make any provision for setup - environment variables, etc.  I assume that is either done before invocation, or is encapsulated by "make test".

    CON: stopping recursive traversal

    The above one-liner does not make allowance for Makefiles where 'make test' knows how to recurse into subdirectories.  Indeed, the above one-liner is how some of my quick and dirty test suites recurse over submodule tests.  Such recursive Makefiles used in conjunction with the above one-liner may result in tests being run more than once.

    The above one-liner lacks an important feature: stopping.  Or, rather, it has the bad feature that it walks the entire tree - it does not have the ability to stop when certain conditions are met, such as a directory named 'Foo.do-not-follow'.

    It is important to have the stopping feature, because it is quite likely that some foreign, imported, test suite also uses the same convention, of Makefiles with 'Make test' targets.  But may require some setup.   In such a case, it may be desirable to have:
    • .../ImportedTestSuite-adapter
      • Makefile - a makefile suitable for my quick and dirty test suite, with 'make test' target.  Sets up for the stuff below
      • ImportedTestSuite
        • the foreign, imported, test suite, which should NOT be run directly by my quick and dirty test driver; ideally, its subtree should NOT be walked
        • Makefile - a makefile for the foreign, imported, test suite, which should NOT be run by my quick and dirty test suite
    I sometimes implement stopping with a naming convention, like
    • .../ImportedTestSuite-ADAPTER
      • run 'make test' in this directory, but do not traverse further
    • .../ImportedTestSuite-adapter/Makefile.MY-TEST-SUITE
      • look for this specially named Makefile, but do not traverse further
    • .../ImportedTestSuite-adapter/ImportedTestSuite.SPECIAL-NAME
      • do not run 'make test', do not traverse further
      • CON: I like keep a test suites own naming scheme
    • .../ImportedTestSuite-adapter/IMPORT/test-suite's-own-name
      • PRO: allows using a foreign test suite's own name for itself
      • COM: the import directory is often almost empty, containing only a single subdirectory.  (Although this may change if it is one of a family of test suites, or if you keep multiple versions.)
    Naming conventions are easy, but applying them to a directory can produce very long and clumsy pathnames, and sparse subdirectories.  The pathname length can be a problem on OSes with relatively small pathname length limits, like Windows or POSIX.

    Using special files at places in the directory, like 
    • .../ImportedTestSuite-adapter/Makefile.MY-TEST-SUITE
    • .../ImportedTestSuite-adapter/MY-TEST-SUITE.CONF
      • with an embedded directive
    places less pressure on pathname length.   But it requires controlling the traversal.  Whereas aa naming convention inside a directory name is trivial to filter out.




    Friday, December 11, 2015

    I dislike Perl's lib/Module.pm AND lib/Module/SubModule.pm

    I dislike how Perl requires modules, and the submodules which are really "internal" to them, to live in two places in the filesystem - even if those places are right next to each other.

    E.g. the module's top level code in some lib/Module.pm

    And the code for any submodules that are really part of the module in the directory tree under lib/Module, e.g. lib/Module/SubModule.pm

    So you cannot simply operate on one filesusem object for the module: e.g.g you cannot do:

    mv lib/Module some-other-lib-path/Module

    Instead, you must do
    mv lib/Module.pm some-other-lib-path/Module.pm
    mv lib/Module.pm some-other-lib-path/Module.pm 
    A minor difference, two commands rather than one, something that can odten be patched over by regexps.

    But an important difference: I would go so far as to say that the representation of Perl modules (classes) in the filesystem is not object oriented.  I would say that one of the key characteristics of an object, in this class treating the code for a class as an object, is that it behaves like it is a single object, unless explicitly opened up to look inside.

    ---+ Bad Influence on Perl CPAN class structure

    I think this decision, to have lib/Module.pm and lib/Module/SubModule.pm, has had a bad, or at least confusing, influence on CPAN's module structure.

    Sometimes a CPAN module Foo::Bar (lib/Foo/Bar.pm) is actually a module completely unrelated[*] to module Foo (lib/Foo.pm). More confusing if module Foo actually has some internal modules Foo::Fu (lib/Foo/Fu.pm).

    (Note *: OK, not "completely unrelated".  How about "unrelated wrt code structure", or "related only by topic, but not actual code".)

    Then there is no localization of Foo in the filesystem.   Some parts of lib/Foo are part of module Foo, and some are not.   And not everthing in module Foo is under lib/Foo.

    I.e. the Perl CPAN filesystem structure sometimes reflects module structure, and sometimes it just reflects theme.

    ---+ Kluges

    For this reason, I often make my modules appear as Foo::Foo, i.e. lib/Foo/Foo.pm.

    But this can become tiresome.  Tiresome. Repetitious.  And it does not prevent somebody else from defining Foo::Bar, and wanting to live in the same directory tree (if not in separate PATH elements).

    So I might try Topic::Long_Module_Name_Unlikely_To_Conflict::Short_Module_Name

    i.e.
          lib
               /TopicLong_Module_Name_Unlikely_To_Conflict
                   /Short_Module_Name.pm
                   /Short_Module_Name/Sub_Modules...

    e.g.  lib/Foo/AG_Foobar/Foo.pm

    Not ideal.

    Similarly, I might use a level of indirection to group internal submodules

    Foo::internal::Submodules
    vs
    Foo::Unrelated_Submodules

    Again, not ideal.    

    ---+ What is really needed

    Modules should correspond to subtrees of the filesystem.

    e.g. lib/Foo.pm, if no furter structure.

    lib/Foo.pmdir/Foo.pm  if submodules such as lib/Foo.pmdir/Sub.pm

    with it being an error to have both lib/Foo.pm and lib/Foo.pmdir exist.

    Or, if you will, require the indirection even if no further structure: lib/Foo.pmdir/Foo.pm, and never lib/Foo.pm

    The main file might be called lib/Foo/main.pm.  But I rather like lib/Foo/Foo.pm, or lib/Foo.pmdir/Foo.pm





    ---+ References

    use - perldoc.perl.org: <>

    require - perldoc.perl.org: <The require function will actually look for the "Foo/Bar.pm" file in the directories specified in the @INC array.>>



    'via Blog this'

    Finally got emacs compilation-error-regexp working for perl CPAN Test::Unit::TestCase

    Summary: Finally got emacs compilation-error-regexp working for perl CPAN Test::Unit::TestCase



    Not only did I need to add a regexp,
    but I also needed to disable a compilation-mode-font-lock-keywords pattern
    - apparently there may be some phase ordering.

    This woukd be more reliably if there were the ability to return ALL possible substrings matching a regexp,
    as opposed to being maximally or minimally greedy.

        ;; adding patterns to compilation-error-regexp-alist and/or compilation-error-regexp-alist
        ;; to try to get a perl CPAN Test::Unit error message, like

        ;; There were 3 failures:
        ;; 1) TestCases_for_FrameMaker_MIF_AG.pm:875 - test_another_error(TestCases_for_AG_FrameMaker_MIF)
        ;; expected '', got 'deliberate mismatch'
        ;;
        ;; 2) TestCases_for_FrameMaker_MIF_AG.pm:879 - test_yet_another_error(TestCases_for_AG_FrameMaker_MIF)
        ;; expected '', got 'deliberate mismatch'
        ;;
        ;; 3) TestCases_for_FrameMaker_MIF_AG.pm:898 - test_special_stuff__format_tuple_to_MIF_string__Cell_context__WIP(TestCases_for_AG_FrameMaker_MIF)

        (require 'compile)

        (add-to-list 'compilation-error-regexp-alist
    '("\nThere were [0-9]+ failures:\n1) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_"
      1 2)
        (add-to-list 'compilation-error-regexp-alist
    '("\n[0-9]+) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_"
      1 2)
          )
        (if nil  ;; the regexp below causes compilation-error-regexp-alist to stop working completely - no matching
          (add-to-list 'compilation-error-regexp-alist
    '("\nThere were [0-9]+ failures:\n1) .*\\(\\w\\|\\W)*\n[0-9]+) .*\\(test_\\)"
      2)
    )
          )


    Diffs:


        === modified file '.emacs'
        *** .emacs 2015-12-12 00:18:53 +0000
        --- .emacs 2015-12-12 00:26:30 +0000
        ***************
        *** 4129,4139 ****
         ;; perl CPAN Test::Unit
         ;; 1) TestCases_for_FrameMaker_MIF_AG.pm:763 - test_special_stuff_to_insert_wip(TestCases_for_AG_FrameMaker_MIF)
         '(("\\([a-zA-Z0-9_.-.---]+:[0-9]+\\)"
        !      ;;(0 'compilation-line-face nil t)
        !      ;; (0 'ag-test-result-unexpected) ;; works (modulo filename matching)
        !      ;;(1 'ag-test-result-unexpected) ;; works (modulo filename regexp
        !      (1 compilation-line-face nil t)
        !      ))
         '(("expected\s+.*got\s+.*"
     (0 'ag-test-result-unexpected)
     ))
        --- 4129,4139 ----
         ;; perl CPAN Test::Unit
         ;; 1) TestCases_for_FrameMaker_MIF_AG.pm:763 - test_special_stuff_to_insert_wip(TestCases_for_AG_FrameMaker_MIF)
         '(("\\([a-zA-Z0-9_.-.---]+:[0-9]+\\)"
        ! ;;      ;;(0 'compilation-line-face nil t)
        ! ;;      ;; (0 'ag-test-result-unexpected) ;; works (modulo filename matching)
        ! ;;      ;;(1 'ag-test-result-unexpected) ;; works (modulo filename regexp
        ! ;;      (1 compilation-line-face nil t)
        ! ;;      ))
         '(("expected\s+.*got\s+.*"
     (0 'ag-test-result-unexpected)
     ))
        ***************
        *** 4628,4637 ****
          (add-to-list 'compilation-error-regexp-alist
     '("\nThere were [0-9]+ failures:\n1) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_"
        1 2)
    )
        ! (if nil
    (add-to-list 'compilation-error-regexp-alist
        !     '("\nThere were [0-9]+ failures:\n1) .*\\(\\w\\|\\W)*\n[0-9]+) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_) "
        !        2 3)
     )
    )
        --- 4628,4640 ----
          (add-to-list 'compilation-error-regexp-alist
     '("\nThere were [0-9]+ failures:\n1) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_"
        1 2)
        + (add-to-list 'compilation-error-regexp-alist
        +     '("\n[0-9]+) \\([a-zA-Z0-9_.-.---]+\\):\\([0-9]+\\) - test_"
        +        1 2)
    )
        ! (if nil  ;; the regexp below causes compilation-error-regexp-alist to stop working completely - no matching
    (add-to-list 'compilation-error-regexp-alist
        !     '("\nThere were [0-9]+ failures:\n1) .*\\(\\w\\|\\W)*\n[0-9]+) .*\\(test_\\)"
        !        2)
     )
    )



    Friday, December 04, 2015

    p4 status - misleading Perforce command name

    So, I want to run a command in a script that asks Perforce if a file exists in the depot.



    I wonder what such a command might be callewd. Let's try "p4 status".



    Strange... google "p4 status".



    !!!! "p4 status"  `Open files for add, delete, and/or edit in order to reconcile a workspace with changes made outside of Perforce.1





    This is stupid.  In English, in 99.99% of programming systems, "status" is a read-only query.