Thursday, January 10, 2019

AI found Mysterious fast radio bursts from deep space, ‘could be aliens’

Canadian-led team of astronomers searching for FRBs have recently detected a repeating FRBs that could be alien signal. With the Breakthrough Listen program used AI (artificial intelligence), they have found more than 60 FRBs, two of the FRBs was detected repeating.

The origin of fast radio bursts (FRBs), millisecond-long pulses of radio waves, may be generated by black holes or super-dense neutron stars merging together. However, for such astrophysical phenomena events randomly repeated at the same location twice has a tiny chance.



search keywords: FRBs, alien Continue Reading »

First Commercial Quantum Computing System from IBM

IBM debuts the Q System One, an integrated quantum computing system made for commercial and research use, the first of its kind in the world.

The system can be used to predict events that are almost impossible for classical computing, but which quantum computing is uniquely adept at solving. For example, predict financial events, optimize logistic problems.

𝑖Ψ(𝑞,𝑡)𝑡=HΨ(𝑞,𝑡)
Quantum mechanics describe our world as entangled waves in time and space (or a set of vectors where time and space dimensions are just mathematical presentations), instead of collection of small particles moving in space. This means that, because of this property of measurement in quantum mechanics, our universe is inherently a non-local, and everything seems connected. In another word, any quantum mechanics interaction has the whole universe considered, that's why it is simpler to predict financial events for quantum mechanics -- complexity and considering the influence of outside world is not a problem at all in quantum mechanics!



search keyword: IBM CES 2019 First Integrated Quantum Computing System Continue Reading »

Thursday, January 3, 2019

slack short cuts and commands

Slack is a useful communication tool. You can have direct chat with a contact, host a group chat, open a channel for topic discussion. It can also be integrated with other tools/apps such as zoom, splunk, jira, ssh, bitbucket, etc, allowing you to host video conference, share screen, share files, run reports etc.

There are magic in slack realm, here are the spell syntax:

Command + / list all the keyboad shortcuts for Slack.


For example:

  • command + [    previous channel or direct message window visited.
  • command + ]    next channel or direct message window visited
  • shift + enter will create a new line in your message
  • command + U will upload a file
  • command + shift + enter will add a new code snippets
  • command + +    will zoom in
  • command + -     will zoom out


/ will list the slack apps you can invoke. 


For example:

  • /zoom                 will send a zoom meeting to your contacts
  • /giphy words      will send a cool image relevant to the word to the chat window
  • /poll "Poll question?" "Option1" "Option2"       will create a poll in your chat window
Continue Reading »

Thursday, December 6, 2018

command + shift + G

command + shift + G is a handy shortcut.
In eclipse IDE, it means search the reference of a method in workspace, which is similar to Control + Option + H.

In mac os x finder, it means go to directory.

A useful usage scenario is as follows:

You look up a java method's references in workspace by typing command + shift + G, then  find an interesting class. You want to share the file to your coworker. So you right click the file, select properties, find the path in location, copy the path.

You then click finder icon or type command + space to open spotlight then type finder to open the finder.

Next you type command + shift + G to invoke "go to directory" UI, then paste the path and type enter. The finder will land on the file you want to send.

You then hightlight the file then drag it into the slack window to share it.

Continue Reading »

Tuesday, November 6, 2018

7 useful mac os x command line tools

Mac OS X has Darwin Unix like os. There are command line tools you can use in the console.

1. brew is a command to install other command line tools for mac os x.
To install brew and add the brew binary into the PATH, run the following commands in the console.


mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew;

echo export PATH=`pwd`/homebrew/bin:'$PATH' >> ~/.bashrc;
source ~/.bashrc;
which brew;

The last command "which brew;" should give the full path to brew binary file.

Now you have brew command available, you can install other command line tools easily.

2. pigz is a tool that is gzip equivalent but runs faster by exploiting parallel computing. pigz is useful when you need to unzip contents with gzip or zlib format. For example, you rabbitmq messages might be zlib compressed, then base64 encoded. Your decoding commands might looks funny:
base64 -D input.txt | pigz -d -z -c

To install pigz, issue the following command:
brew install pigz

3. apache bench (ab) is a command line tool that allows you to bench mark web sites. The most useful flag is -c, which allows you to specify the number of concurrent http requests sent to the host each time.
For example:

ab -n 100000 -c 10 -t 30 http://xyzcode.blogspot.com/

the above commands send total 10000 requests to xyzcode.blogspot.com, each time, 10 concurrent requests are sent.

ab is installed by default on mac os x, type which ab to check out. In case it is missing, you can install it with command:
brew install ab

4. pybot is a command line tool that automate stuff like ssh, web browsing etc. It is equivalent to have a robot to type the keyboard and read the screen then act upon it for you.

To install pybot, issue the following command:
brew install robot-framework

Since brew also installed python's package management tool, you can also use pip to install pybot:
pip install robotframework

5. in case pybot is an overkill for you, you can use expect command to automate ssh chat with remote hosts like a robot. Expect commands expect input, then send the response without any user interaction.
expect script is installed by default, check the installation path with
which expect;

6. zgrep is a better tool than grep.
zgrep allows you to grep content in zip files and normal files. It will be useful to search something in current log and backup logs.
The flexible syntax really compliments your searching strategy. So if you know the log will looks like

2018-11-07 16:42:25-05 HostNameppp Sophos Installer[72881]: [SGCCDFSBroker.m:306] Feedback json file was successfully uploaded (status code: 201).

Your searching strategy could be:
zgrep -i 'Sophos.*json.*successful' /var/log/install.log

each .* separated string became a filter string, so that you can narrow down the search.

You can use or syntax like:
zgrep -i 'Sophos.*json.*successful' /var/log/install.log | grep --color '72881\|72889'

zgrep is installed by default
which zgrep; will give you the installation location.

7. mysql is a command line tool to query mysql database. It allows you scripting mysql queries. You can pipe the result into zgrep to search relevant information.

mysql --host mysql.local -uuser -ppass -e 'select * from ct_prov.Student\G'

to install mysql command line tool
brew install mysql




Continue Reading »

Wednesday, October 31, 2018

7 tips for text edit efficiency

1. Inside chrome, use option + command + left to move tab by tab from left to right, use option + command + right to move tab by tab from right to left.

2. Inside chrome, right click then click inspect, then click network. Refresh the page to view the page loading process.

3. install chrome tools to handle json, xml etc.
jsonEditer to tidy and modify json string
https://chrome.google.com/webstore/search/jsonEdit?hl=en

ooxml tool to edit and compare xml files
https://chrome.google.com/webstore/detail/ooxml-tools/bjmmjfdegplhkefakjkccocjanekbapn?hl=en

4. install diffmerger to compare files side by side
https://sourcegear.com/diffmerge/downloads.php

5. use --color option to highlight text (good for your eye), use --text option to avoid searching missing in zip files with special characters.
>zgrep KEY --color --text demoClient.key
-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----

6. In xterm2, if you get a huge file which can not be displayed on one screen, click Session -> Edit Session -> Terminal -> then modify scroll back lines to a bigger number.
7. In xterm2, if you want to view several terminals side by side, type command + D to split horizontally, click command + shift + D to split vertically, then type command + shift + i to type in all the terminals. Type command + shift + i again to negate the effect.

Continue Reading »

Wednesday, October 17, 2018

How to exit java ExecutorService without calling shutdown method

The java Executor framework encapsulated the thread lifecycle management under interface ExecutorService. By default, the ExecutorService implementation returned by Executors needs programmer to call shutdown() method to stop it. Forget to call shutdown for an ExecutorService will prevent the JVM to exit. The JVM won't exit if there are any non-daemon thread still running. The worker threads in the ExecutorService's thread pool won't exit unless you interrupt them, in another words, they will still be running after the main thread exits. These worker threads prevent JVM to exit.

For example, the following program will never finish.


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TheadTester {
public static void main(String... args) {
TheadTester ts = new TheadTester();
ts.test();
}

private void test() {
ExecutorService exec = Executors.newSingleThreadExecutor();
exec.execute(() -> System.out.println("ok"));
//exec.shutdown();
}
}

You can override the default ThreadFactory, so that the worker thread in the thread pool will be daemon thread. Since daemon thread won't prevent JVM to exit, you don't have to call ExecutorService's shutdown() method. This approach has drawbacks, though. Once the main thread exits, the only threads remain are the worker daemon threads in the threadpool. When JVM exits, these threads may still have work to do. Since they are daemons, JVM won't wait them to finish. You need to give enough time for these daemon threads to finish the work and run to the last line so that they can exit normally instead of abruptly.


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class TheadTester {
public static void main(String... args) throws InterruptedException {
TheadTester ts = new TheadTester();
ts.test();
//give enough time for deamon thread to finish
Thread.sleep(2000);
}

private void test() {
ExecutorService exec = Executors.newSingleThreadExecutor(r -> {
Thread t = new Thread(r);
t.setDaemon(true);
return t;
});
exec.execute(() -> System.out.println("ok"));
//exec.shutdown();
}
}

This trick may be trivial, but it could be handy in big java project. For example, you need to add an ad-hoc threadpool in a class in a big project. If you use default ThreadFactory for the ExecutorService, you have to shutdown the ExecutorService somewhere. This "somewhere" might be in a thread that shutdown project level services before main thread exits, which you would rather not touch. You just want to create an ad-hoc threapool to handle events for a shot period of time, finish it, then exit. Next time, when new events come, you create a new threadpool to handle it. So on and so forth. The deamon worker strategy might be a good choice in this situation.
Continue Reading »