Categories
Mac

Move between Code tabs on Mac

I primarily use macOS but I also use Windows on a regular basis. Or maybe I should say I have to use Windows because of various workplace activities where it makes it easier to do what I have to do. But that is invariably because of corporate IT policies defined by people who, due to malice or just lack of knowledge, go out of their way to make life difficult for non-Windows people.

If I were to point out one thing that irks me it is the inconsistent use of various keyboard shortcuts on Windows. The use of the control key for a lot of things also leads to very awkward finger positions. As a comparison, the command key on Mac is right under the left thumb so it is super easy to achieve various key combinations without moving the hands.

Coming from macOS to Windows I couldn’t wrap my head around how people could actually stand the use of the control key for so many shortcuts and briefly tried to remap the keys to switch ctrl and alt around. But that led to other problems so I abandoned it and, reluctantly, succumbed to the Windows way of doing things – on Windows.

But on macOS I really expect things to work in a consistent manner with all other applications so I was mightily surprised to notice that the default way to switch tabs on Visual Studio Code on macOS uses the control key. Every other program that I know of on macOS that allows the user to jump between tabs uses the command button plus number keys. Even Microsoft’s own Edge browser does it. But not Visual Studio Code! Switching between open documents is something I use frequently so this was a real nuisance. I was frustrated and almost gave up on VS Code.

Luckily VS Code allows for simple keybindings but it is not super intuitive. This is what I did:

  1. In VS Code, open Keyboard Shortcuts (under Code > Settings…)
  2. Open Keyboard Shortcuts (JSON) in the top right, the small document icon with an arrow
  3. Add the mappings below, or use the attached file

This enables Cmd plus numbers to switch between open tabs. Like the standard Cmd+9 switches to the last tab. It is also possible to use Option+Cmd plus arrow keys to move right and left among the tabs.

My sanity is restored. I just don’t understand why this couldn’t be the default mapping for VS Code on macOS to begin with.

[
  {
    "key": "cmd+alt+[ArrowLeft]",
    "command": "workbench.action.previousEditor"
  },
  {
    "key": "cmd+alt+[ArrowRight]",
    "command": "workbench.action.nextEditor"
  },
  {
    "key": "cmd+1",
    "command": "workbench.action.openEditorAtIndex1"
  },
  {
    "key": "cmd+2",
    "command": "workbench.action.openEditorAtIndex2"
  },
  {
    "key": "cmd+3",
    "command": "workbench.action.openEditorAtIndex3"
  },
  {
    "key": "cmd+4",
    "command": "workbench.action.openEditorAtIndex4"
  },
  {
    "key": "cmd+5",
    "command": "workbench.action.openEditorAtIndex5"
  },
  {
    "key": "cmd+6",
    "command": "workbench.action.openEditorAtIndex6"
  },
  {
    "key": "cmd+7",
    "command": "workbench.action.openEditorAtIndex7"
  },
  {
    "key": "cmd+8",
    "command": "workbench.action.openEditorAtIndex8"
  },
  {
    "key": "cmd+9",
    "command": "workbench.action.openEditorAtIndex9"
  },
  {
    "key": "cmd+0",
    "command": "workbench.action.lastEditorInGroup"
  }
]
Categories
Blog Computers

Send mail from your domain using Gmail

Sometimes you want to give someone a forwarding email address to a domain but not have the burden or cost associated with a full blown inbox. This could be done for example for people who get involved in a community or an association and need to communicate as that role for a while before handing it over to the next person.

Just forwarding email is easily done by using just about any web hotel. But that doesn’t in itself solve the fact that email sent by those people will come from their personal address. A slightly better alternative is to add a reply-to address in the email client. However, that is not ideal either as the email will still come from their personal address, although in this case any replies will be from the forwarded domain.

What we want is to allow users to send email as if they had a proper inbox but still receive those email in their normal inbox. This is perfectly doable and I will give you a step by step process of how to set it up using Gmail.

First things first, you do need to have a Gmail address. If you don’t already have one go ahead and register for one. It is free. Also, this process assumes that you are using the two factor authentication support in Gmail. To set up two-factor authentication if you haven’t already done so, follow the instructions here: https://www.google.com/landing/2step/

When you have a Gmail account configured for two-factor authentication you can proceed with the configuration:

  1. Go to https://myaccount.google.com/apppasswords
  2. Choose “Mail” in the the dropdown for “select app”
  3. Choose “Other” in the dropdown for “select device”)
  4. When prompted for a name, just write any name that will help you remember its use, for instance the domain for which you are setting up email
  5. Press “Create”, on the next page and copy the password that is shown (you will need it later)
  6. Go to your gmail account (https://gmail.com)
  7. Under the settings > “Accounts and import” > “Send e-mail as” select “Add another email address”
  8. In the window that is shown type your name and email address that you want to send email as (i.e. not your Gmail address). Make sure to leave the checkbox “Treat as an alias” unchecked. Then click “Next step”
  9. Enter smtp.gmail.com as SMTP server with the port set to 587.
  10. When asked for a username, use whatever you have before @gmail.com in your Gmail account address with the password being the password from step 5 above. Choose to secure the connection using TLS. Then click “Add account”
  11. Keep the web browser tab open and open your mail client and wait for a verification email. This will be sent to the email address you are setting up Gmail to be able to send email as.
  12. You will receive a verification code that you will need on the previous web page, this concludes the configuration.

You have now configured Gmail to be able to send email with the specified name and email address. When writing a new email you can choose which originating address to use. By default each new email will use your normal Gmail address as sender address but this can be changed in the Gmail settings.

Finally, while this works it may not allow your recipients to receive emails sent via Gmail if the domain you are using employs an anti-spam feature called SPF. SPF allows a domain owner to specify valid sources of emails from that domain. If the recipients’ email servers uses SPF it will check if the email comes from a valid server, and if not it will be flagged as spam. To solve this the domain information needs to have the following setting added (the exact format can differ based on the existing SPF information):


v=spf1 include:_spf.google.com ~all

Categories
Computers Web design

Authenticate using Office 365

This is a extension to a previous post about creating a Rails web site that uses external OAuth providers to authenticate users. Until now the Rails template supported Facebook, Twitter, LinkedIn and Google OAuth providers. Lately I have added Office 365 support to the template available on Github. This could be useful for e.g. companies that want to develop web sites for internal applications and allow their internal users to log on using their standard accounts.

Azure portal

  1. Go to portal.azure.com & log in
  2. Expand “more services” and select “active directory”
  3. Choose “applications” and click “add” at the bottom (or click on ”
    Add an application you’re developing” if you are viewing the domain overview)
  4. Give your web application a name
  5. Enter a Sign-On URL and an App ID URL (e.g. http://example.com/users/sign_in). It is not obvious what the App ID URI should be but it seems to work fine to use the same as the Sign-On URL
  6. Configure the app and modify the reply URL to be e.g. http://example.com/users/auth/office365/callback/
  7. Copy the Client ID and add it to the Rails template
  8. Select duration under “keys”, press save and then copy the generated key to the Rails template

Finally, deploy your web site and hopefully it should work.

Categories
Gadgets Mac

The time is 9:41

You may have noticed that the iPhone time on Apple presentations is always 9:41. How come? This goes back to when Steve Jobs launched the iPhone in 2007. At the time the time displayed was 9:42 and it was subsequently used for all promotional screenshots until the iPad was launched when the time was changed to 9:41.

Having a static time for all screenshots is good as it makes it easier to produce screenshots for presentations at different times and be able to combine them without the time jumping around. In addition it is also a nice historic reminder of the launch of the iPhone.

This is all very well, but how do you go about producing screenshots that mimic this behaviour. One option is to connect the iPhone to a Mac via USB and then run QuickTimePlayer on the Mac and start a recording. This will force the time displayed on the iPhone to 9:41, blank out any operator name and change the signal strength to maximum.

This works fine but requires a physical device. This can be tricky when submitting apps to the App Store and you have to provide screenshots for all various screen sizes. Another alternative is to download SimulatorStatusMagic, a free Xcode project on GitHub, compile it and install it in the various Xcode iPhone simulators.

Running the app in the simulator shows a GUI that allows the user to set the time, or use the default 9:41 time. Then switch to any other app in the simulator and take whatever screenshots are required.

Categories
Computers Mobility

Parking app for iPhone

Spotwise today announces the availability of “Pendla i Göteborg” (Swedish for “Commute in Göteborg”). The app makes it possible for commuters in the greater Gothenburg area to check the number of available parking spots at nearby commuter parkings.

The app is now available on the Swedish App Store. For more information, please see the product page.

Categories
Mac

Missing recipients when emailing group in OS X

Sometimes when emailing a group from the contacts application in OS X El Capitan one or more of the addresses will be missing from the recipient list in the mail application. The missing recipients can be added manually to the recipient list but they will be silently dropped when the mail application expands the group into its members.

It is very unclear why this happens but a workaround seems to be to delete the mail addresses from the failing recipient and add them again. After that, the group expands to the full list of members.

Categories
Blog Computers Mac

Still broken unison brew

I wrote in an earlier post about how the brew build of unison is broken due to it defaulting to ocaml 4.02. Back then it was possible to checkout an old version of ocaml but since then changes to brew seem to have closed that option. Instead of being able to use brew to install a particular version of unison I had to install it from source and include the correct version of ocaml. This is how I did it.

First uninstall any existing brew installations of unison and ocaml

brew unlink unison
brew unlink ocaml

Then download ocaml 4.01 and compile from source.

wget http://caml.inria.fr/pub/distrib/ocaml-4.01/ocaml-4.01.0.tar.gz
tar -xvzf ocaml-4.01.0.tar.gz
cd ocaml-4.01.0
./configure
make world.opt
sudo su
umask 022
make install
exit

Finally, download unison 2.40.102 and compile from source

wget http://www.seas.upenn.edu/~bcpierce/unison/download/releases/unison-2.40.102/unison-2.40.102.tar.gz
tar -xvzf unison-2.40.102.tar.gz
cd unison-2.40.102
make UISTYLE=text

The unison binary is in the current directory. Just copy it to a location within your path and you should be set to go.

Featured photo by Kuba Bożanowski (https://www.flickr.com/photos/jbozanowski/4132669334/).

Categories
Computers

Got a beeping disk? Don’t despair!

I had a power outage a couple of weeks ago and when the power came back up I noticed that one of my servers made a strange beeping sound that I had not heard before.

My first thought was that all the data was lost. I knew that there are professional services that may be able to recover data but that they are typically very expensive. This was a private server and most of the data had been backed up anyway so paying that sort of money to salvage the disk was not an option I considered.

As it turns out, this particular issue is actually quite simple to solve by almost anyone. The only thing you need is a T6 torx screwdriver, a clean surface, a toothpick, a steady hand and some luck. It also helped that the data was not extremely valuable for me. I would perhaps not recommend this procedure if you care very much about the data on the disk. In that case it may be better to pay up. You can definitely make things worse. Don’t say I didn’t warn you.

Note that these instructions only apply if the disk beeps like in this audio clip. If the disk makes a more mechanical noise then the error is caused by some other issue and you should not follow these instructions as they could worsen the situation.

When the disk is beeping with a steady period (typically around 1Hz) it typically means that the disk head is not in its parked position when the disk is about to spin up. Normally the head moves away from the disk before the disk is shut down and does not move in over the platters until they are spinning at full speed. The rotating disks create an air flow that acts as a cushion for the heads so that they do not touch the surface. If the heads are over the platters when the disk is off then the disk will just refuse to spin up.

To fix the issue one just needs to open the hard drive and gently move the head to its parking position while at the same time turning the platters counter-clockwise.

The lid covering the internals of the drive is usually held in place by seven screws. Six of those are along the edge and readily visible. The seventh is in the centre of the disk head arm and normally covered by a sticker.

You may be concerned about opening up the disk outside of a proper clean room. While it is true that the internals of the disk are delicate you should not be too concerned. The disk is constructed to be able to handle small amounts of dust that could be released from the internals of the disk during operation. The white item in the bottom right on the photo is a filter that is there to catch dust particles. The heads do not leave their parking position until the disk it at full speed and their speed creates an air flow that should remove any dust from the disk and deposit it on the filter.

When you move the head back it may feel like it is stuck at first due to static electricity. Just rotate the disk counter-clockwise while you gently move the arm back and you should be fine. I found that a toothpick is a good tool for this. The image below shows how the arm should be positioned when you are done. Then just put the lid back on and keep your fingers crossed.

If it worked then congratulations. But make sure to copy the data to a new disk and consider the old disk used, never to be trusted again.

HD OK

Categories
Blog Mobility Wearables

Watch out for Apple Watch

Almost exactly eight years ago the late Steve Jobs presented the iPhone at MacWorld 2007. “It’s a widescreen iPod with touch control, a revolutionary mobile phone and a breakthrough Internet communications device”. The audience was enthusiastic, yet very few fully realised the impact this would have on an entire industry. As a phone and compared with what we have today it was lacklustre. There was no app store, that was to come much later. And as far as connectivity goes it was inferior to other phones, having only 2G connectivity. You could not copy and paste text when texting or writing email, nor attach photos. Which was probably just as well, since the camera was only 2MP and produced rather ordinary photos and no video. And, like the T-Ford, you could have any display background you wanted as long as you wanted black.

We all know what happened. The iPhone improved by leaps and bounds. An app ecosystem virtually exploded around it. The connectivity has since vastly improved and the performance is now hugely better thanks to Moore’s law. In the process it completely obliterated a number of industries and companies. Nokia, the biggest phone manufacturer at the time the iPhone was introduced has since succumbed due to their inability to see and act on the shift in their industry. But the impact of the iPhone was not limited to the mobile phone industry. The iPhone is today the go-to-camera for most people and there is now very little need for a standalone GPS to find your way.

Apple Watch

This spring Apple will release the Apple Watch to the world. And even though it mostly likely is a magical device that will find its place on the arms of many people (mine included) it is probably wise to see the future evolution of Apple Watch in the light of the history of the iPhone. It may not take eight years for the Apple Watch to find its true form but we will no doubt look back on 2015 a few years from now and realise the shortcomings of this, the first generation of the Apple Watch.

The Apple Watch of 2020 will no doubt be very much thinner than the first generation, charge seamlessly and run for weeks on a charge, be connected with everything around you and have a colour display that is always on. The first generation will require a phone to run apps but it is not hard to imagine that this requirement will be dropped in later revisions. When this happens it will be the beginning of the end for other watch-like offerings for runners, golfers etc.

Make no mistake. The release of the Apple Watch this year is not just for a watch but of a new product segment that will profoundly change several industries just like the iPhone has done before it. Many companies that fail to transform their business will go under but many other companies will flourish based on applications that we have yet to imagine.

Now, I just hope that spring comes early this year.

Categories
Blog Computers Linux

Ubuntu wallpapers

For every version of Ubuntu there is a set of wallpaper images. Each version has its own set and doesn’t include the old ones. However, it is very simple to install all previous versions by running:

apt-cache search ubuntu-wallpapers- | awk '{ print $1; }' | xargs apt-get -y install

As of today (January 2015) this will install the wallpapers from:

  • Karmic (9.10)
  • Lucid (10.04)
  • Maverick (10.10 LTS)
  • Natty (11.04)
  • Oneiric (11.10)
  • Precise (12.04 LTS)
  • Quantal (12.10)
  • Raring (13.04)
  • Saucy (13.10)
  • Trusty (14.04 LTS)

If you want to use them for other purposes you will find the images in /usr/share/backgrounds/. I use them as wallpaper in OS X. In return I may just use the Yosemite wallpapers in Ubuntu to really confuse people.

css.php