Category Archives: How to Fix

Ubuntu 16.04 install Chinese input method


http://www.programering.com/a/MTOyMDMwATc.html

Ubuntu 16.04 Chinese input method to install Input method on Ubuntu are mainly small input platform (support Pinyin/two pen/five pen), Fcitx, Ibus, Scim etc.. Where Scim and Ibus are input method framework.

In Chinese Ubuntu system comes with Chinese input method, through the Ctrl+ Space English input method switch. Here we mainly said Ubuntu English system, Chinese input method to install.

The first step to install the input method, is installing a language pack. We choose the System Settings–> Language Support–> Install/Remove Languages, the following window will popup: www.2cto.com

After inputting password, the system will install simplified Chinese language pack.

The second step, install the IBus framework, input the following commands in a terminal:
sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4 Start the IBus framework, in terminal input:

im-switch -s ibus

After you install the IBus framework after the write off system, guaranteed that the changes take effect immediately.

The third step: install the Pinyin engine

There are several common choices:

IBus Pinyin: sudo apt-get install ibus-pinyin

IBUS five pen: sudo apt-get install ibus-table-wubi

Google Pinyin input method: sudo apt-get install ibus-googlepinyin

Sun Pinyin input method: sudo apt-get install ibus-sunpinyin

The fourth step: setting the IBus framework www.2cto.com

ibus-setup

At this point, IBus Preference is set to be opened. We are in the Input Method tab, select the input method you like, and configure shortcuts can be like. As shown below:

The fifth step: normally, the IBus icon (a small keyboard) will appear in the top right corner of the taskbar. Sometimes this icon will disappear, you can use the following command, retrieve the disappearance of the IBus Icon:

ibus-daemon -drx

The sixth step: Click the Keyboard icon, choose  configure current input method,
                           Click the add(+) icon, choose the Chinese input method
The seventh step: configure the shortcut key
                                system sitting-> Test Entry 
Then you can set the shortcut key of input method exchange.

Empty Matrices, Scalars, and Vectors

Overview
Although matrices are two dimensional, they do not always appear to have a rectangular shape. A 1-by-8 matrix, for example, has two dimensions yet is linear. These matrices are described in the following sections:
The Empty Matrix An empty matrix has one or more dimensions that are equal to zero. A two-dimensional matrix with both dimensions equal to zero appears in the MATLAB® application as []. The expression A = [] assigns a 0-by-0 empty matrix to A. Scalars A scalar is 1-by-1 and appears in MATLAB as a single real or complex number (e.g., 7, 583.62, -3.51, 5.46097e-14, 83+4i). Vectors A vector is 1-by-n or n-by-1, and appears in MATLAB as a row or column of real or complex numbers:

     Column Vector                 Row Vector

         53.2                  53.2 87.39 4-12i 43.9
         87.39
         4-12i
         43.9

The Empty Matrix
A matrix having at least one dimension equal to zero is called an empty matrix. The simplest empty matrix is 0-by-0 in size. Examples of more complex matrices are those of dimension 0-by-5 or 10-by-0.
To create a 0-by-0 matrix, use the square bracket operators with no value specified:

A = [];

whos A
  Name      Size            Bytes  Class     Attributes

  A         0x0                 0  double 

You can create empty matrices (and arrays) of other sizes using the zeros, ones, rand, or eye functions. To create a 0-by-5 matrix, for example, use

A = zeros(0,5)
A =

  0×5 empty double matrix
Operating on an Empty Matrix

The basic model for empty matrices is that any operation that is defined for m-by-n matrices, and that produces a result whose dimension is some function of m and n, should still be allowed when m or n is zero. The size of the result of this operation is consistent with the size of the result generated when working with nonempty values, but instead is evaluated at zero.
For example, horizontal concatenation

C = [A B]

requires that A and B have the same number of rows. So if A is m-by-n and B is m-by-p, then C is m-by-(n+p). This is still true if m, n, or p is zero.
As with all matrices in MATLAB, you must follow the rules concerning compatible dimensions. In the following example, an attempt to add a 1-by-3 matrix to a 0-by-3 empty matrix results in an error:

[1 2 3] + ones(0,3)
Error using +
Matrix dimensions must agree.

Common Operations.   The following operations return zero on an empty array:

A = [];
size(A), length(A), numel(A), any(A), sum(A)

These operations return a nonzero value on an empty array :

A = [];
ndims(A), isnumeric(A), isreal(A), isfloat(A), isempty(A), ...
   all(A), prod(A)
Using Empty Matrices in Relational Operations

You can use empty matrices in relational operations such as “equal to” (==) or “greater than” (>) as long as both operands have the same dimensions, or the nonempty operand is scalar. The result of any relational operation involving an empty matrix is the empty matrix. Even comparing an empty matrix for equality to itself does not return true, but instead yields an empty matrix:

x = ones(0,3);
y = x;

y == x
ans =

  0×3 empty logical array
Using Empty Matrices in Logical Operations

MATLAB has two distinct types of logical operators:
Short-circuit (&&, ||) — Used in testing multiple logical conditions (e.g., x >= 50 && x < 100) where each condition evaluates to a scalar true or false. Element-wise (&, |) — Performs a logical AND, OR, or NOT on each element of a matrix or array.
Short-circuit Operations.   The rule for operands used in short-circuit operations is that each operand must be convertible to a logical scalar value. Because of this rule, empty matrices cannot be used in short-circuit logical operations. Such operations return an error.
The only exception is in the case where MATLAB can determine the result of a logical statement without having to evaluate the entire expression. This is true for the following two statements because the result of the entire statements are known by considering just the first term:

true || []
ans =

  logical

   1

false && []
ans =

  logical

   0

Element-wise Operations.   Unlike the short-circuit operators, all element-wise operations on empty matrices are considered valid as long as the dimensions of the operands agree, or the nonempty operand is scalar. Element-wise operations on empty matrices always return an empty matrix:

true | []
ans =

  0×0 empty logical array

Note   This behavior is consistent with the way MATLAB does scalar expansion with binary operators, wherein the nonscalar operand determines the size of the result.

Scalars
Any individual real or complex number is represented in MATLAB as a 1-by-1 matrix called a scalar value:

A = 5;

ndims(A)        % Check number of dimensions in A
ans =
     2

size(A)         % Check value of row and column dimensions
ans =
     1     1

Use the isscalar function to tell if a variable holds a scalar value:

isscalar(A)
ans =

  logical

   1

Vectors

Matrices with one dimension equal to one and the other greater than one are called vectors. Here is an example of a numeric vector:

A = [5.73 2-4i 9/7 25e3 .046 sqrt(32) 8j];

size(A)         % Check value of row and column dimensions
ans =
     1     7

You can construct a vector out of other vectors, as long as the critical dimensions agree. All components of a row vector must be scalars or other row vectors. Similarly, all components of a column vector must be scalars or other column vectors:

A = [29 43 77 9 21];
B = [0 46 11];

C = [A 5 ones(1,3) B]
C =
   29   43   77    9   21    5    1    1    1    0   46   11

Concatenating an empty matrix to a vector has no effect on the resulting vector. The empty matrix is ignored in this case:

A = [5.36; 7.01; []; 9.44]
A =
    5.3600
    7.0100
    9.4400

Use the isvector function to tell if a variable holds a vector:

isvector(A)
ans =

  logical

   1

How To Install Google Chrome on Linux Mint 19

Add Google Chrome Repository
First, download the Google signing key and install it.

wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -

Set up the Google Chrome repository.

echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list

Install Google Chrome
Update the repository index.

apt update

To Install Google Chrome Stable, use the below command.

apt install -y google-chrome-stable

Android avoids memory leak: reasonable use of getcontext() and getapplication ()

To conclude:
GetApplicationContext () can fetch the Application object, and getContext() is generally considered to return an Activity object (which, of course, is not actually limited to the Activity). 2. For Application, you can see from the Manifest file that an Application typically has only one Application node. Application is just an Application, that is, as long as the current Application is still running, it can get to the Application object. 3.Application is a long reference, and Activity is a short reference. Application is suitable for storing objects that need to be read repeatedly, such as the user’s username and password, the current Settings of the Application, and so on. When an Activity is applied to the current active form, such as displaying a Dialog, or creating a new View, the context object passed in should be the current Activity, not the Application.
    
Android applications limit heap memory to 16M (note: heap memory is also related to device performance; available heap memory for high performance devices may be 24M or more), with phone functions taking up a portion of the heap and developers having very limited access to it. If you’re not going to run out of memory, your application should use as little as possible so that other programs don’t get killed when they run. The more applications the Android system can hold in memory, the faster users can switch between applications. As part of my work, I researched memory leaks in Android applications and found that most of the time it was the same problem: holding a long reference to the Context.
In Android, Context is used for many operations, but mostly to load or access resources. This is why all Widget components receive a Context parameter in the constructor. For a typical Android Application, there are usually two contexts, namely Activity and Application. Developers often need the context to select an Activity when passing between classes or methods.

this indicates that Views have a reference to the entire Activity, so anything in your Activity will be held by Views, which are generally held by the view hierarchy and its corresponding resources. So, if you give away the Context, you’re giving away some memory. If you’re not careful, it’s very easy to reveal an Activity.
when the screen direction changes, the system will save its state by default, destroy the current Activity, and create a new one. To do this, Android reloads the application’s UI from resources. Now let’s say you’re developing an app that contains a lot of bitmaps, and you don’t want to load bitmaps every time you switch screens. So the easiest way to do this is to use the static static field.

Java – how to shuffle an ArrayList

In Java, you can use collections.shuffle to clean or rerun a ArrayList

TestApp.java

package com.mkyong.utils;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class TestApp {

    public static void main(String[] args) {

        List<String> list = Arrays.asList("A", "B", "C", "D", "1", "2", "3");

        //before shuffle
        System.out.println(list);

        // again, same insert order
        System.out.println(list);

        // shuffle or randomize
        Collections.shuffle(list);
        System.out.println(list);
        System.out.println(list);

        // shuffle again, different result
        Collections.shuffle(list);
        System.out.println(list);

    }

}

Output

[A, B, C, D, 1, 2, 3]
[A, B, C, D, 1, 2, 3]

[2, B, 3, C, 1, A, D]
[2, B, 3, C, 1, A, D]

[C, B, D, 2, 3, A, 1]

References

    Collections.shuffle JavaDoc

There will be row spacing problems in algorithm use in latex. Please use the ‘setstretch {1.35}

The algorithm template in latex is:
Package added at the top of latex files:

\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{setspace}

Algorithm block code:

\begin{algorithm}[htb]
\setstretch{1.35} %Set the length of the rubber with the specified elasticity (1.35 times the original line width).
\caption{}
\label{alg:Framwork}
\begin{algorithmic}
\REQUIRE ~~\\
The set of positive samples for current batch, $P_n$;\\
The set of unlabelled samples for current batch, $U_n$;\\
Ensemble of classifiers on former batches, $E_{n-1}$;


\ENSURE ~~\\
Ensemble of classifiers on the current batch, $E_n$;
Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$;\\
\label{ code:fram:extract }

Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches;\\
\label{code:fram:trainbase}

$E_n=E_{n-1}\cup E$;\\
\label{code:fram:add}

Classifying samples in $U_n-T_n$ by $E_n$;\\
\label{code:fram:classify}

Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$;\\
\label{code:fram:select}

$E_n$;\\
\end{algorithmic}
\end{algorithm}


The actual algorithm results are shown as follows:

Second usage:
The processing is done using the Algorithm2e package

\documentclass{article}
\usepackage{algorithm2e,setspace}

\begin{document}

\begin{algorithm}
\setstretch{1.35}
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}

\bigskip

\begin{algorithm}
\SetAlgoLined
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}

\end{document}


The above codes correspond to two algorithms respectively, and the algorithm blocks obtained are:

Common blocks of algorithms in Latex are set after querying, as described above, with other tricks of the process.
The above notes are only used to summarize experience in latex usage.
Latex typesetting needs to be kept calm, otherwise it is easy to make silly mistakes. If you encounter a format or method that you don’t know, use search engines frequently to find the answer.

In fact, I was stuck for a long time by the line spacing problem. The problem I encountered was because the line spacing of the algorithm was too small:
The problem of line spacing can be solved by web search, and also by consulting Liu Haiyang’s latex Latex Primer.

Python bug: cannot install ‘Django’. It is a distutils installed project and thus we cannot

Cannot uninstall 'django'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Installed dependent packages have errors:
you can add – ignore-installed after the PIP command to ignore the installed libraries and install the latest ones

pip install django --ignore-installed

How to debug stored procedure/function in TOAD

I studied how to debug the Stored Procedure or function under Toad and saw the corresponding menu under Toad before, but I never knew how to use it. For details, please refer to the article:
Debugging PL/SQL, now available for everyone!

Here’s a case of how debugging in Toad works:


The test code for this Case:
CREATE OR REPLACE PROCEDURE APPS.swapn (num_one IN OUT NUMBER, num_two IN OUT NUMBER) IS
temp_num NUMBER;
BEGIN
temp_num := num_one;
num_one := num_two;
num_two := temp_num ;
END;


On the breakpoint


Be sure to compile your Procedure
first


Run in Debug (most of the buttons in the Debug menu are grayed out if you don’t compile the Stored Procedure)


Before is debugged, set the values of input parameters

will stop at the break point, you can see the Watches output window, variable value changes




What did project > clean do in eclipse

It felt like something, but I just forgot. Picture is truth, look at the answers on stack overflow.



So this step removes the class files that have been compiled in the project and recompiles them. That’s all. What’s the difference between
and build all, since eclipse builds on
The time stamp
Of the judgment mechanism. So when you press build all some classes that eclipse thinks the timestamp hasn’t changed won’t be recompiled.
I’m sure you know the difference between Clean and Build All.

Anaconda create environment, delete environment, activate environment, exit environment

 
Anaconda Create environment:
// Below is the environment for creating Python =3.6, called Py36
Conda create-n py36 Python =3.6
 
Delete the environment (don’t delete the environment)
conda remove -n py36 –all
 
Activate the environment
// The next py36 is an environment name
Conda activate Py36 (the previous version of Conda4 was: Source activate Py36)
 
Out of the environment
Conda Deactivate (the previous version of Conda4 was: Source Deactivate)