Entries filed under Computer

Android Debug Bridge

Posted on Dec 19, 2020

  1. Download the Android SDK Platform-Tools package.
    https://developer.android.com/studio/releases/platform-tools
  2. Activate the developer mode.
    [Settings] – [System] – [About phone] – hit [Build number] 7 times
  3. Connect the phone with a USB cable.
  4. Type adb commands on the command line.
    adb devices
    adb shell am force-stop package
    adb shell am kill package
    adb shell pm clear package
    adb shell pm uninstall –user 0 package
    adb kill-server

Add the data exploration buttons back to the figure toolbar in MATLAB R2018b or larer

Posted on Sep 13, 2019

In R2018b and later, the data exploration buttons (zoom in, zoom out, etc.) were moved from the figure toolbar to the axes toolbar. I use those buttons all the time, so this change is really annoying. What is relieving is that you can use the addToolbarExplorationButtons and removeToolbarExplorationButtons functions to bring the buttons back to the figure toolbar.

fig = figure;
surf(peaks);

addToolbarExplorationButtons(fig);     % add zoom buttons to the figure toolbar
removeToolbarExplorationButtons(fig);  % Remove the buttons from the figure toolbar

The functions work for the specified figure only. If you want to open all figures with the data exploration buttons, put the following code in the startup.m

set(groot,'defaultFigureCreateFcn',@(fig,~)addToolbarExplorationButtons(fig));
set(groot,'defaultAxesCreateFcn',@(ax,~)set(ax.Toolbar,'Visible','off'));

Vectorizing Value Assignment to an Array of Structures

Posted on Nov 7, 2015

MATLAB code:
% create an array of 100 structures
chan = struct('Index', num2cell(1:100));

% assign new numbers (larger by 3) to the Index field without using a loop

% Method 1
chan = arrayfun(@(s) setfield(s,'Index', s.Index + 3), chan);

% Method 2: This is faster than Method 1, but requires a temporary variable.
new_index = num2cell([chan.Index] + 3);
[chan.Index] = new_index{:};

% Method 3: Surprisingly using a loop is the fastest!!!
for m=1:100, chan(m).Index = chan(m).Index + 3; end

% The fastest time out of 10 runs on my desktop with R2015b
% Method 1: Elapsed time is 0.002056 seconds.
% Method 2: Elapsed time is 0.000357 seconds.
% Method 3: Elapsed time is 0.000124 seconds.

Thunderbird Command Error 12

Posted on Jul 31, 2015

From http://forums.mozillazine.org/viewtopic.php?f=39&t=2530463

Symptom:
Thunderbird shows a popup that says, “The current operation on ‘Inbox(or one of your folders)’ did not succeed. The mail server for account (your account name) responded: Command Error. 12.”, when it tries to access an IMAP account.

Cause:
The error happens with some servers that does not support “ID command”.

Solution:
Go [Option] – [Advanced], click [Config Editor] and fnd the following pref.

mail.server.default.send_client_info

It is true by default. Toggle it to false by double-clicking on it. Close the editor and restart Thunderbird.