“The application XXX can’t be opened” on Mac OS X

If you are trying to launch an app on OS X and simply get the error “The application XXX can’t be opened”, the problem could be the actual executable file in the app bundle does not have corresponding permissions.

To fix the issue:

  1. Open a Terminal and enter into your app bundle. You can just type “cd
    and then drag the app into the Terminal and then hit the enter.
  2. cd Contents/MacOS
  3. chmod +x * or chmod +x <FILENAME> if you know which one is the actual executable.
  4. sudo !! may be needed if you don’t have permissions to execute step 3.

Now try to launch the app again, and the problem should be solved.

Where is curl in Ubuntu core?

Sorry if you are trying to get the answer, I don’t have yet. Please close it.

Recently I’m trying the new Ubuntu core which is using fancy snaps as the package management tool. I’m not understanding it well, but when I did my first attempt on this OS, command curl was needed and I could not figure out a way to install it.

I did a simple search and noticed that there are several alternatives, but I just simply want a real curl command. Am I asking too much?

Have to give it up and fall back to my love Ubuntu server for now. Hopefully I could be smarter soon.

Secret Angular (2+) Key event filtering

According to the official document (here) You’ll be able to bind

 to your

 control to just handle keyboard

 event like this:

What else can you do with this cool filter then? 

According to the source code of Angular (Github) , you could use a lot more like:

  • two events: keydown, keyup
  • modifiers: e.g. keyup.control.shift.enter
  • special key names: e.g. dot, space, escape, enter
  • short forms: e.g. esc (short for escape)

Install Apps from 3rd party in macOS Sierra

When installed apps from 3rd party or Internet download, macOS always prompt “Downloaded .app is damaged and can’t be opened”.

The solution is really simple:

Run the following command before launching the app:

sudo spctl --master-disable

Launching the app and finish installing it, and then run the following command to re-enable the restriction:

sudo spctl --master-enable

That’s it.

Create an ISO Image from a source CD or DVD under Linux

(source: https://www.thomas-krenn.com/en/wiki/Create_an_ISO_Image_from_a_source_CD_or_DVD_under_Linux)

This brief article will describe the creation of a proper ISO image from a CD or DVD.

If an ISO image has been created with the help of the dd (diskdump) command from a CD or DVD then the ISO file created thereby may have an MD5 checksum, which is different than the original ISO file that was used for burning the source CD or DVD. A pair of zero data blocks at the end of the CD or DVD are responsible for this. Such an ISO image can be used without any problems, however testing the MD checksum against the source disk cannot be done (the download servers that provide ISO image for Linux, for example, typically also provide MD5 checksums for testing).

Using the following procedure, exactly the same ISO image that was used for burning the CD or DVD can be read from a CD or DVD:

1. Reading the block size and the volume size:

[root@testserver ~]# isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size' 
Logical block size is: 2048
Volume size is: 327867

2. Running dd with the parameters for block size and volume size:

[root@testserver ~]# dd if=/dev/cdrom of=test.iso bs=<block size from above> count=<volume size from above>

Note: When reading the ISO image, the following command can be used in a second console for viewing the current progress status (requires root rights):

killall -USR1 dd

With the of watch, this call can also be executed each second:

watch -n 1 killall -USR1 dd

Thereby, dd will display the progress status as follows:

admin@adminpc:~/Downloads/isos$ dd if=/dev/sr0 of=cdimage.iso bs=10M
1+0 records in
0+0 records out
0 bytes (0 B) copied, 10.2447 s, 0.0 kB/s
2+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 16.3769 s, 640 kB/s
3+0 records in
2+0 records out
20971520 bytes (21 MB) copied, 22.3123 s, 940 kB/s
5+0 records in
4+0 records out
41943040 bytes (42 MB) copied, 33.6603 s, 1.2 MB/s

Restart SSH/sshd in Mac OS X

To restart ssh/sshd service in Mac OS X, you can simply run the following two commands together:

sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd

Your sshd will get restarted and your new ssh config file can be loaded as well.

p.s. Friendly reminding: DO NOT try to execute

sudo launchctl reboot com.openssh.sshd

instead since your computer will immediately get rebooted 🙂

SSH does not work after upgraded macOS sierra?

If you ever met the following errors when trying to git or ssh after upgraded your OS to sierra:

Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss

Just relax, it’s not your fault but your server’s fault. Upgrading your OS to sierra will also bump your OpenSSH from version 6.9 to 7.2. According to the document of OpenSSH 7 (http://www.openssh.com/legacy.html):

OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public key algorithm. It too is weak and we recommend against its use. It can be re-enabled using the HostKeyAlgorithms configuration option:

ssh -oHostKeyAlgorithms=+ssh-dss user@legacyhost

or in the ~/.ssh/config file:

Host somehost.example.org
    HostKeyAlgorithms +ssh-dss

However, it is probably not enough. You may be prompted for password all the time but no password is correct. In that case, you can simply append another line in your ~/.ssh/config file:

    PubkeyAcceptedKeyTypes +ssh-dss

That’s it! Don’t forget to restart your sshd service before retrying.