Posted on

Sorting A Comma-Separated List On Linux

Here is a quick shortcut I used to combine a series of comma separated values into a single list of unique entries.  In my case I was trying to get a unique list of tags that came from several different lists of tags.   If list A had “apples, oranges, bananas” and list b had “apples,grapes,watermelons” I wanted to get “apples, bananas,grapes,oranges,watermelons” back.

There is the shortcut I used:

Paste each comma-separated list into a file named “x”, separate lines are OK.

Run this Linux command on the file to create a file named “Y” that has my sorted unique list of tags:

# tr ‘,’ ‘\n’ < x | sort -u | tr ‘\n’ ‘,’ > y

This is a quick and efficient way to sort comma-separated lists on Linux, which likely includes OS/X as well.

Posted on

OSX Mapping Control F To Find

After using Windows for more than 20 years I have found the switch to OS/X to have been a move that should have happened years ago. I cannot count the thousands of hours of lost productivity. To be fair, it is likely a few hundred hours as OS/X was not a true alternative to the power of Windows until the latest OS/X iterations over the past 5 years. After spending more than EIGHT HOURS trying to get Minecraft working on a 3-year-old PC (windows updates, driver updates, incompatible graphics drivers for Java… the usual Windows debacle) I decided I will rarely-if-ever recommend ANYONE every buy a Windows PC from this point forward.

However the move to OS/X has not been completely pain free. I am heavily trained on Windows and Linux keyboard shortcuts. One of the BIGGEST FAILINGS of OS/X was their decision to create a proprietary keyboard system for OS/X. They introduced things like the command key and the “apple key” along the way when the rest of the OS world standardized on keyboard mappings using the more-than-adequate 100+ keys including control, alt, shift, and the thousands of combinations therein.

After 6 months of using OS/X I still find myself pressing things like control-SOMETHING to perform an action. Control (^) C for copy. ^f for find. ^x for cut. ^v for paste. To perpetuate the keyboard training, I use a Linux virtual machine in GUI mode for my daily WordPress development. Linux adopted the defacto standards of the industry in the early 80s and uses the same key presses defined by , not Microsoft, but IBM.

Today I find the control-key training to slow me down significantly when using native OS/X apps. I found a “fix” for mapping the edit operations fairly quickly. You can do so without using Karabiner (which causes some odd side effects). You can edit the DefaultKeyBinding.dict file in your Users directory on OS/X. Create or edit the file:
~/Library/KeyBindings/DefaultKeyBinding.dict

You can assign keys like this:

{
/* Remap Home / End to PC Edition */
"\UF729"  = "moveToBeginningOfLine:";                   /* Home         */
"\UF72B"  = "moveToEndOfLine:";                         /* End          */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:";       /* Shift + End  */

    "^x" = cut:;
    "^c" = copy:;
    "^v" = paste:;
}

That remaps the oft-used ^c, ^x, and ^v commands to their OS/X equivalents of Command (@) X, @-c, and @-v respectively.

But mapping ^f is a whole other kettle of fish. Mapping the action for find is NOT quite as simple. I tried mapping ^f to @f, which executes a “find action” in most OS/X apps. I tried using the action code “find:”, to no avail.

However there is an easy way to map ^f to find in most apps. MOST apps. Not OS/X Firefox, which appears to not like changing the default keyboard mapping utility. More on that later.

For most apps, let’s take Google Chrome as an example, you can change the ^f to be the find key by using OS/X System Preferences.

OSX Keyboard Shortcuts
OSX Keyboard Shortcuts interface.
  • Go to System Preferences
  • Select Keyboard
  • Select Shortcuts
  • Select App Shortcuts
  • Then click the + to add a new app shortcut.
  • Pick your app, Google Chrome in this case.
  • Now you need to find the EXACT menu text for the find command.  On Google Chrome it is “Find…”.  The … is important.
  • Press the Control-F key combination to set that as the new find command.
  • Exit the app, i.e. Google Chrome, if you had it running (which you did because you had to look at  the Find menu entry text).
  • Restart the app.
  • Your menu should now show the Find shortcut code is ^f
Chrome ^f as Find
Chrome ^f as Find

What about Firefox?   It turns out the mapping shows up but does not work.   The menu shows ^f is the new find key, but it does not activate.  I had to install the Customizable Shortcuts add-on for Firefox and set the find key to be ^f instead of modifier-F (the system-set default).     For some reason Firefox has hard-bound to the modifier key internally instead of using standard OS/X keyboard mapping system calls.   The menu rendering is apparently a separate piece of code.

 

Posted on

MacBook Pro Video Problems Solved

I’ve posted about this a few times on this site and now I feel like a fool for not discovering the problem sooner.     I’m not 100% certain if the issue is an HP monitor issue, a cable manufacturer issue, or and Apple hardware/OS/firmware issue.   All I know for certain is that a couple different brands of cell phones will cause my monitors to lose video signal and “flicker” on/off or show video artifacts.     Sometimes the video loss runs in cycles as fast as 1-second on/ 1-second off.  Sometimes the monitors power off for minutes-at-a-time.     Sometimes I just see horrible bands of pixelation run horizontally or vertically on the screen.    In many cases OS/X starts logging all kinds of video events in the system logs, but I am certain that is a side effect of a video data error that is not being handled as well as it could be.

At the end of the day the problem is easy to fix.   Move my cell phone away from my monitors.

Turns out that ALL THREE of my phones, an older HTC Incredible, a newer HTC Incredible 4G LTE, and a brand new Samsung Galaxy S5 all cause the problem.    It also turns out that the problem varies in intensity based on the lunar cycle and its alignment with the solar winds or some other cosmic crap like that.     What I do know is that when the problem starts my productivity goes to hell and as I can never guess when I can see my code or my browser.

For some reason the electro-magnetic fields (EMF) from the phone are causing all hell to break loose on the displayport video communications to/from the monitor.   That causes a cascade of problems which inevitably results in a monitor powering off or a black screen where video should be.     After multiple red herrings, running down innumerable rabbit holes, and even going so far as to not only swap video cables and monitors but also a brand new MacBook Pro,  the real issue is basic electro-magnetic interference and the solution is as simple as “move my cell phone”.

Here is the recap I sent to Apple Support today regarding the issue.   Hopefully someone will stumble across this online and save themselves some headaches as well.

 

Apple Support Communication

I finally figured out the monitor flicker, power cycle, and pixelation artifacts problem with my monitors after MONTHS of dealing with the issue.

This is really crazy, but it is without-a-doubt what is going on here:

PROXIMITY OF CELL PHONE TO VIDEO HARDWARE

I haven’t yet narrowed down the issue to exactly what the root cause is, but here is what I know for a fact:

1) This happens with my older HTC Inredible 4G LTE phone.
2) This happens with my new Samsung Galaxy S5 phone.
3) This happens ONLY on displayport but HDMI does not appear to be impacted.

4) The problem appears to only happen with the phone is within 5cm of the monitor end of the displayport cable.

5) The problem happens on the HP ZR2440w monitor and other HP monitors using DisplayPort as well as a Samsung monitor using DisplayPort  (I no longer have that monitor, wish I could re-test).

6) Portrait or landscape mode was a red herring.

7) I could not reproduce the issue by placing the phone near (even touching) the MacBook end of the displayport cables.
After 5 days of trying to capture the behavior with my camera-phone and the problem suddenly going away after picking up my phone it finally came to me.      Move the phone back and TOUCH the display cable… bam powers off the display like a wireless power switch.     Move it away, pixelation, then the monitor comes back on.

I then tested the FIRST displayport as I have only seen this happen on the 2nd displayport (furthest from power port on the MacBook) and like magic the first monitor turned off as soon as I touched the phone to the cable.

After multiple tests I’ve learned that I need to just be close to the cable (it is not a physical cable connection issue, verified that a few times).   Within 1-2cm the monitor powers off 60% of the time.   Within 2-5cm the monitor may power off (10% of the time) or display pixelation artifacts or the notorious “ants” problem (30% of the time).

It *may* be the minidisplayport-to-displayport cables I am using, however I have swapped out these cables and at least one set of cables is NOT from the same manufacturer.

To be determined:

a) Is this a cable shielding issue?
b) Is this a monitor build issue?

c) Why does the software react to EMF introduced at the hardware level?   (bad error checking/trapping in the video processing firmware/software?)

Just though I’d share so you can close this ticket and possibly disseminate this information to support channels.     I’m guessing my cell phone is not the only possible source of EMF that can cause external display issues.   Given the number of online posts about similar problems I would venture a guess that more than a few Apple support calls and hardware returns may be related to similar EMF-related issues.

I am very techy and know all about EMF but it never occurred to me that the EMF from my phone would affect a displayport signal to the point of being able to actually power down a monitor IMMEDIATELY.

Good to know what it is.  When I have more time I’ll do more homework and post my findings online.

In the meantime I’m relocating my phone charging cable to not be under my monitors.
Posted on

MacBook Honeymoon Over, Apple Still Shines

Welcome To Apple Support

Day 4 of being a new Mac user and so far it is going well, considering.

My Hidden Talent

For people that don’t know me very well my “hidden talent” is the ability to break ANYTHING related to technology  with astounding efficiency.   All of my seasoned developers at the software consulting business I ran a few years back knew it well.    Whenever someone felt their project was ready for the customer one of my lead tech guys would say “let Lance play with it, if he doesn’t break it in less than 3 minutes you are close”.     Suffice to say that I don’t recall a single project that passed “the Lance test” on the first go.  Or second for that matter.

My favorite anecdote and my crowning achievement to date was breaking a regular ATM machine, and I’m not talking a 30-year old one build on Windows ME but a modern nearly-new ATM, within 30 seconds.  Pull up to the drive-up ATM, put in card, withdraw…wait…no… check balance (while withdraw screen is rendering)… POOF… system crash.   A BSOD on an ATM machine.  Sweet!

Sad Technology
Windows 8 Frowney-Face. Yup, that about sums it up.

I give that background because it applies to my MacBook experience for a few reasons.  First, I have become VERY familiar with technical support lines with every type and size of technology company on the planet.    Second, I have  also learned that there is NO technology I cannot break, even without trying, no matter how solid the platform may be.    My high-end HP laptop, less than 24 hours.   My teched-out 2014 BMW?  Less than 6 hours.    If something lasts more than a day under my full-fledge “run this thing at full throttle abuse” that is impressive.

Macs Are Not Lance-Proof

My MacBook Pro?   Lasted just over 48 hours.   That is somewhat impressive given the fact that I want from vanilla MacBook Pro setup to upgrading the packages software, adding proprietary Logitech unity wireless drivers, proprietary Wacom table wireless drivers, 3 external monitors on 2 display port adapters and a HDMI connection, a 5-year old inkjet, added a pro backup service, 3 virtual box machines, a security dongle, an Android phone, and installed several developer-heavy software packages in that time.     The MacBook survived all of that, ALMOST.

It Worked Great, At First

The AMAZING part is all that stuff worked exactly as I expected with minimal fuss.    Getting 3 external monitors (2 display port and 1 HDMI) on an HP notebook with a docking station SPECIFICALLY DESIGNED to run “5 monitors (sales lie, it really can only do 3)” took over a month including a BIOS update, video driver update, and 3 days of level 2 technical support on how to configure and hook everything up.   MacBook?  Plugin in all 3 monitors and BOOM… they are all up and running including a FOURTH if you included the laptop display.  Sweet.

Adding the 4-port USB monitor hub on these HP monitors to the MacBook?  No problem?   Cascade them with monitor 1 USB into monitor 2 into monitor 3?   No problem.   It shouldn’t be.  USB buses, when powered like these HP monitors are, should be able to daisy chain up to 128 units on a single USB chain.      With the HP?   It rarely could find devices on the first 4-port monitor hub.   Daisy chain them?  NO WAY.  NOTHING would be found and the system would crash corrupting files along the way.   The MacBook handled it with aplomb and to put the icing on the cake it recognized a 5-year old inkjet printer, installed it with the right drivers, and was printing through the 3rd hub on the 3rd external monitor in less than 30 seconds after connection.    Under Windows it was a bitch just to get the thing to print in under 10 minutes and only with a direct printer-to-laptop USB connection. Anything else was futile.

Overall I am impressed.

Breaking A MacBook Pro

But I DID break the MacBook Pro.

Somewhere along the way one of the software updates or installs (I’m fairly certain it is software related) caused my external monitors connected to the display port connects on the MacBook started to “flicker”.   By flicker I mean go completely black for 1 or 2 seconds then turn back on.  Sometimes this would happen once every hour.   Sometimes it would happen once every 5 seconds for 5 minutes straight.       When that didn’t happen I got what the Apple community has coined as “video ants”.   “Ants” are horizontal or vertical bands of pixel artifacts that are similar to “snow” you would find on analog TV years ago (for the young kids that don’t know what analog TV or “snow” is, go look it up… I’m sure YouTube has a video).     Needless to say, these issues made it impossible to use my external monitors and get anything accomplished.

Apple’s Stellar Support

What I found was that Apple Support, thus far, outshines Microsoft and just about EVERY vendor in the Microsoft-centric hardware space that I have ever used.    I’ve purchased top-of-the-line equipment from Sony, Dell, Toshiba, HP, Asus, Acer, and Lenovo.   Few can compare to the general engineering finesse of Apple but NONE can come anywhere CLOSE to Apple in regards to customer service.   NOT EVEN THE SAME PLANET.

I did some homework and tried various online remedies.  Nothing worked.    I decided to take advantage of Apple Support that comes FREE for the first 90 days with any Apple computer purchase.     I got online and opened a chat session.     This is where Apple starts to blow away the rest of the market when it comes to support.    Just getting started with support was painless.      Because I took literally 30 seconds to sign up for an Apple ID when booting my laptop I only had to enter my email and password for that ID and Apple could start building my support case.

It only took a minute and involved 3 simple questions before I had someone on  live chat.   The questions start with “your Apple serial number”.   This is easily found from an on-screen menu in the OS.  No flipper over the laptop, or looking under a desk at the back of a tower, or rebooting to the BIOS.  Just go to the main menu and look at System Preference/More Info.   There it is plain as day.  Now THAT is an novel idea… ANYONE in the Windows world paying attention?   The other questions? Your name and a brief description of your problem.

Support Personnel Using English?

So I have someone on chat.  Guess what?   They actually READ AND WRITE PERFECT ENGLISH.  Holy cow, does Apple actually employ Americans for support?    Maybe.    If not they do a GREAT job training people how to communicate in perfect English for the American users like myself.    Not that I’m a xenophobe but I just cannot stand reading blatantly horrid streams of grammatical and syntactically incorrect English for an entire 20 minute chat session.     I cannot tell you how refreshing it is to not be reading or listening to “Yoda-speak”.   I had ENOUGH of that with Microsoft premium customer support for their cloud services last night.   “If you press now please button on computer” or “Hold now down the control button, you shall.”   Really?

And Can Use Their Brain?

Guess what else?  They are ALLOWED TO USE THEIR BRAIN!   They actually are REAL PEOPLE WITH A REAL BRAIN.   I just about had a God-damned heart attack when they literally said “Can you tell me what debugging you’ve already done?  I don’t want to ask you to do things you tried already.  Your time is too valuable to be wasted.”.     HOLY FRIGGING CRAP… YOU CANNOT BE SERIOUS!  That is NOT how customer support works in 2014.   APPLE…  do you realize you are completely screwing with the customer support paradigm?   This cannot possibly be good for business!!!     That one simple interaction, that has now happened not with ONE but with TWO Apple support people in a row is one HUGE reason why I don’t think I’ll ever stray from Apple from this point forward.  Not unless they decide to be just like everyone else on the planet and go to a 100% check-the-box-while-reading-the-script support model.

I told them all the steps I had taken from swapping cables, ordering new cables, swapping monitors, uninstalling software, reboots, swapping ports, and a myriad of other options.     They read it all, and actually came up with some things I DID NOT TRY.     They did so nearly instantaneously.  Like they actually knew what the hell they were talking about.       Yes, they did have me reset PRAM which did not help.      They also had me reset SMC and run the Apple Hardware Test (AHT) which did not show any errors.      MAYBE the SMC reset did help, though at first I was not convinced because the login screen immediately showed screen flicker, but I will tell you that as soon as I powered off all 3 monitors, turned them back on after trying one more cable swap trick THE MONITORS WORKED.

What is not most impressive is the fact that my monitors are now working again as expected but the fact that I was not asked a bunch of dumb-ass questions or told to “did you reboot”, “did you power off for 30 seconds”, or other obvious options.     They could tell I know a little something about computers and went STRAIGHT to the uber-technical stuff.    They came up with some new analysis and debugging steps nearly immediately.    I was truly impressed.

Just as impressive was the team communication.     After my first contact with Apple Support I was told “this is your support ID in case you need to call back so the next person can pick up where I left off”.   True enough, the next support person after my system reboot and PRAM reset did not work picked up EXACTLY where he first person left off.     That person never needed to ask for my case ID, they looked at the history and said “is this related to the monitor issue”.  Yes.   Moving on to the next item.       That is how support should be.

Hey World – Copy This!

In my book, Apple knocked it out-of-the-park when it comes to technical support.  Why?

  • 30 seconds with a FEW simple questions to get registered for online support.
  • No more than a 2 minute wait for a LIVE support person.
  • Support people are ALLOWED TO THINK, they are not script-driven.
  • Support had a CLUE even with a less-common problem.
  • Support ALWAYS made me feel like they WANTED me to use the service.
  • Every support person said “please let us know if this doesn’t fix it, we want you to be 100% happy with you Apple experience and won’t stop working on this until you are”.
  • They actually UNDERSTOOD the problem and came up with what appears to be the right solution.

Not This!

After a month of dealing with Asurion to get my HTC phone fixed and an entire evening with Microsoft Azure support  I am absolutely blown-away by the fact that Apple has real old-fashioned technical support.

Asurion?  100% script based to the point of absurdity. “I just did a factory reset an hour before calling you, it didn’t help.   them: That doesn’t matter sir, if you DO NOT do a factory reset now I cannot help you.   If we don’t see the phone re-register we will not proceed.  me: Can you see it re-registered 90 minutes ago?   them: sir that is irrelevant, if you don’t do it again now while I am on the phone I cannot help you.”

Microsoft? 4 techs, 3 time zones and at least one guy that my disk failure problem was related to an IP address change (WTF, really?) Don’t forget this guy too: “I am not an expert in that area, I will refer you to someone that is” from the guy that I was originally referred to as an expert in that area.

Apple Fan Boy?

A month ago I thought Apple users where just zealots that had buried their heads in the sand and ignored the myriad of problems that come up on their devices.      I used to think “well they are not overly technical and just don’t push the systems like I do”, but that notion was dispelled a few years back as some of the uber-geeks I know were also raging Apple fans.      Now I’m getting a taste of the Kool-Aid.    If this support experience is any indication of what it is like being an Apple Fan Boy, I’m all in.

And just as I finish writing this… the first monitor flicker on my display port devices in over 3 hours.  Maybe this is not 100% fixed so we’ll see just how deep the Apple Kool-Aid Punch Bowl is.    But wait, it looks like it was the VirtualBox guest going into and out of sleep state while in full screen on my other monitors.    Very like just a VirtualBox bug not an OS/X or MacBook hardware issue after all.