Thursday, 3 November 2022

How to generate a random password quickly in BASH?

To generate a 32-chars random password with letters and digits:

openssl rand -base64 128 | tr -dc [:alnum:] | cut -c -32

Monday, 14 February 2022

How to share a folder with your minimal CentOS guest in VirtualBox?

 

  1. yum install bzip2 kernel-devel gcc make perl
  2. click 'insert Guest Additions CD Image ...' from VirtualBox Manager's Devices menu;
  3. mount /dev/cdrom /mnt
  4. cd /mnt
  5. ./VBoxLinuxAdditions.run
  6. reboot
  7. add a shared folder, say 'temp', to the guest from VirtualBox Manager's Devices menu;
  8. mount -t vboxsf temp /mnt

Wednesday, 3 April 2019

winword is freezing after pasting from followed by closing powerpoint on Windows 10

With 'Analyse wait chain' from task manager, you can see that winword is still waiting for powerpoint. Even the powerpoint has been closed (by clicking the x on top right of its window), there is still a powerpoint process running (not seen in 'processes' list, but in 'details' list). This looks like a 'bug' of powerpoint 2016. If you close powerpoint file by Ctrl+F4, then close the powerpoint app, everything is fine. If you close powerpoint app by Alt+F4, you have the same problem.

Saturday, 16 February 2019

How to make a disk dump using dd command?

To virtualize a physical PC in VirtualBox (see here), I need a copy of its disk image. The PC is quite old 386 (32bit) and its spec is quite low. So, I choose the less resource demanding Linux distro, Tiny Core (CorePlus version) to boot it up. To hold the big image file, I have a USB external drive in NTFS format. Here is what I did:

1. boot the PC with CorePlus

2. install ntfs-3g extension

3. connect the USB drive to the PC

4. find the device ID of the USB drive (in my case, sdd) with: fdisk -l

5. sudo -s

6. mount /mnt/sdd1

7. cd /mnt/sdd1/

8. dd if=/dev/sda of=sda_image.dd


Sunday, 19 August 2018

How to install RTL8811AU WiFi adapter?

Ubuntu
---------------------------------------------------------------------------------------------------------------------------
# Download Ubuntu desktop 18.04 ISO from here

# write the ISO image to a USB stick using w32 disk imager

# install minimal installation on a laptop using the USB stick

# boot the laptop by holding shift key after BIOS loading screen to get into GRUB)
select option:
Advanced options for Ubuntu
Ubuntu, with Linux 4.15.0-29-generic (recovery mode)
root (Drop to root shell prompt)
:~# mount -o rw,remount /
:~# vi /etc/gdm3/custom.conf
uncomment following line
#WaylandEnable=false in /etc/gdm3/custom.comf
^D

# resume the reboot

sudo apt-get update
sudo apt install dkms
sudo apt install git

# following instruction here to build the driver from source
git clone https://github.com/gnab/rtl8812au.git
sudo cp -r rtl8812au  /usr/src/rtl8812au-4.2.2
sudo dkms add -m rtl8812au -v 4.2.2
sudo dkms build -m rtl8812au -v 4.2.2
sudo dkms install -m rtl8812au -v 4.2.2
reboot

Update on 11/02/2019
---------------------------------------------------------------------------------------------------------------------------
I have tried following from here on lubuntu and Mint, Both work well:

sudo apt install git dkms build-essential
git clone https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git
cd rtl8812AU_8821AU_linux
sudo make -f Makefile.dkms install

Note: you may need install the headers first
apt-get install linux-headers-$(uname -r)

Update on 13/02/2019
---------------------------------------------------------------------------------------------------------------------------
Another try on my old Dimension8400 with Debian9, and it seems working as well. Occasionally, the connection is dropped.
BTW, the out-of-box Debian9 has problem with my wifi and it dropped the connection immediately after authenticated with error: DEAUTH_LEAVING
The fix is simple as described here   


Sunday, 20 November 2016

如何转换MP3的ID3标签?

mp3文件ID3标签包括歌曲的名字、歌手名字等等。如果这些在播放器里显示为乱码,可按下述步骤修改:

在CentOS6.8系统下:

安装工具包:yum install python-mutagen

显示mp3文件标签:mid3v2 a.mp3

核实mp3文件标签是否为GB18030 编码:mid3iconv -p -e GB18030 -d a.mp3  (若显示为汉字则是)

将当前目录下全部mp3文件标签转换为Unicode编码:find . -name "*mp3" -print0 | xargs -0 mid3iconv -e GB18030 -d

参见:http://ask.xmodulo.com/convert-mp3-id3-tag-encodings-linux.html

Monday, 14 March 2016

How to work with Apache Ignite?

First of all, don't try to build from the source unless you know how to. I have tried following the instruction (BUILDING FROM SOURCE), it simply does not work!

Here is the way working for me:

1. Create a MAVEN project with following files


<1> pom.xml


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>my.ignite</groupId>
    <artifactId>ignite-test</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-core</artifactId>
            <version>1.5.0.final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-spring</artifactId>
            <version>1.5.0.final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-indexing</artifactId>
            <version>1.5.0.final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-log4j</artifactId>
            <version>1.5.0.final</version>
        </dependency>
    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>config</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>-Xms1G</argument>
                        <argument>-Xmx1G</argument>
                        <argument>-classpath</argument>
                        <classpath />
                        <argument>my.ignite.Test</argument>
                    </arguments>
                    <workingDirectory>${project.build.outputDirectory}</workingDirectory>        
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

<2> src\main\java\my\ignite\Test.java

package my.ignite;

import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;

public class Test {

    public static void main(String[] args) throws IgniteException {
        Ignition.start("ignite.xml");
    }
}

<3> config\ignite.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util.xsd">

    <!-- Datasource for sample in-memory H2 database. -->
    <bean id="h2-example-db" class="org.h2.jdbcx.JdbcDataSource">
        <property name="URL" value="jdbc:h2:tcp://localhost/mem:ExampleDb" />
        <property name="user" value="sa" />
    </bean>

    <bean abstract="false" id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <!-- Enable client mdoe. -->
        <property name="clientMode" value="false"/>
        <!-- Set to true to enable distributed class loading for examples, default is false. -->
        <property name="peerClassLoadingEnabled" value="true"/>

        <!-- Enable task execution events for examples. -->
        <property name="includeEventTypes">
            <list>
                <!--Task execution events-->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_STARTED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FINISHED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_FAILED"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_TIMEDOUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_SESSION_ATTR_SET"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_TASK_REDUCED"/>

                <!--Cache events-->
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ"/>
                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED"/>
            </list>
        </property>

        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <!--
                        Ignite provides several options for automatic discovery that can be used
                        instead os static IP based discovery. For information on all options refer
                        to our documentation: http://apacheignite.readme.io/docs/cluster-config
                    -->
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <!--bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"-->
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>

<4> config\java.util.logging.properties

handlers=java.util.logging.ConsoleHandler, org.apache.ignite.logger.java.JavaLoggerFileHandler
.level=INFO
java.util.logging.ConsoleHandler.formatter=org.apache.ignite.logger.java.JavaLoggerFormatter
java.util.logging.ConsoleHandler.level=INFO
org.apache.ignite.logger.java.JavaLoggerFileHandler.formatter=org.apache.ignite.logger.java.JavaLoggerFormatter
org.apache.ignite.logger.java.JavaLoggerFileHandler.pattern=ignite-%{id8}.%g.log
org.apache.ignite.logger.java.JavaLoggerFileHandler.level=INFO
org.apache.ignite.logger.java.JavaLoggerFileHandler.limit=10485760
org.apache.ignite.logger.java.JavaLoggerFileHandler.count=10

2. mvn compile

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ignite-test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ ignite-test ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ ignite-test ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.641s
[INFO] Finished at: Mon Mar 14 20:31:27 GMT 2016
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------

3. mvn exec:exec

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ignite-test 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:exec (default-cli) @ ignite-test ---
[20:31:34]    __________  ________________
[20:31:34]   /  _/ ___/ |/ /  _/_  __/ __/
[20:31:34]  _/ // (7 7    // /  / / / _/
[20:31:34] /___/\___/_/|_/___/ /_/ /___/
[20:31:34]
[20:31:34] ver. 1.5.0-final#20151229-sha1:f1f8cda2
[20:31:34] 2015 Copyright(C) Apache Software Foundation
[20:31:34]
[20:31:34] Ignite documentation: http://ignite.apache.org
[20:31:34]
[20:31:34] Quiet mode.
[20:31:34]   ^-- To see **FULL** console log here add -DIGNITE_QUIET=false or "-v" to ignite.{sh|bat}
[20:31:34]
[20:31:34] OS: Windows 7 6.1 x86
[20:31:34] VM information: Java(TM) SE Runtime Environment 1.7.0_80-b15 Oracle Corporation Java HotSpot(TM) Client VM 24.80-b11
[20:31:37] Configured plugins:
[20:31:37]   ^-- None
[20:31:37]
[20:31:38] Security status [authentication=off, tls/ssl=off]
[20:31:51] Performance suggestions for grid  (fix if possible)
[20:31:51] To disable, set -DIGNITE_PERFORMANCE_SUGGESTIONS_DISABLED=true
[20:31:51]   ^-- Disable peer class loading (set 'peerClassLoadingEnabled' to false)
[20:31:51]   ^-- Disable grid events (remove 'includeEventTypes' from configuration)
[20:31:51]
[20:31:51] To start Console Management & Monitoring run ignitevisorcmd.{sh|bat}
[20:31:51]
[20:31:51] Ignite node started OK (id=c9abb969)
[20:31:51] Topology snapshot [ver=1, servers=1, clients=0, CPUs=4, heap=1.0GB]