Showing posts from November, 2018

Start selling for just $9/month - Add Ecommerce to Any Website with the Shopify Buy Button

Shopify Buy buttons are great if you’re not ready to start a fully-featured online store, or you just want to sell a few products on your existing website.

For just $9/month you can now use the Shopify platform to sell your products using buy buttons. As part of this plan you also have access to features including Shopify POS, the app store, and 24/7 support. When you’re ready, you can quickly and easily upgrade to a full online store.

How to Manage applications across AWS and GCP on the cloud

Manage applications across AWS and GCP.Google Stackdriver provides a unified view of the health, performance, and availability of your cloud-powered applications. Stackdriver combines metrics, logs, error reporting, and diagnostics from GCP and AWS to enable you to find and fix issues faster. New integrations add security, event management, and compliance reporting.READ MORE

How to Enable Debugging for GlassFish / Payara Java EE server

Form command line:asadmin start-domain --debug [domain-name] From Admin GUITo: Set the Server to Automatically Start Up in Debug Mode Use the Administration Console. Select the GlassFish Server component and the JVM Settings tab.

Check the Debug Enabled box.

How to stop / remove all Docker containers

docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)

Public DNS for performance

Google Public DNS IP addresses
The Google Public DNS IP addresses (IPv4) are as follows: 
The Google Public DNS IPv6 addresses are as follows:

2001:4860:4860::8888 2001:4860:4860::8844 OpenDNS

How to Enable Password-based Login for Amazon EC2 / Google Compute Engine

Although ssh key-based login is preferred to password-based login, sometimes clients still need password-based login. Amazon EC2 / Google Compute Engine disable password-based login by default. To enable it,

# vi /etc/ssh/sshd_config
Find the line
PasswordAuthentication no and change it to
PasswordAuthentication yes
Save the file and restart sshd:
# /etc/init.d/sshd restartCaution: whenever making changes to your sshd.config file, be certain that you have an active shell session in case you've made a fatal syntax error. After restarting sshd, log in from another session to test it before terminating your active terminal session.

jcmd - a utility to send diagnostic command requests to a Java Virtual Machine supporting this feature.

Used without arguments or with the -l option, jcmd prints the list of running Java processes with their process ID, their main class and their command-line arguments. When a process ID is specified on the command line, jcmd sends the diagnostic command request to the process with this ID. When a main class is specified on the command line, jcmd sends the diagnostic command request to all Java processes for which the command-line argument is a substring of the Java process' main class. With the PerfCounter.print argument, jcmd prints the performance counters available on the targeted Java processes. With the -f option, jcmd sends to the targeted Java processes the diagnostic commands stored in the specified file.
Example usage: jcmd -l 4896 8102 -l 23610 com.sun.enterprise.glassfish.bootstrap.ASMain --domain domain1 --domaindir /d/glassfish-
-h Prints a help message. -helpPrints a help message. To find out what …

Java Flight Recorder and Java Mission Control for production environments

Please be advised that although you can download Java Flight Recorder and Java Mission Control freely, you may need to pay to use them.

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collection framework built into the Oracle JDK. It allows Java administrators and developers to gather detailed low level information about how the Java Virtual Machine (JVM) and the Java application are behaving. Java Mission Control is an advanced set of tools that enables efficient and detailed analysis of the extensive of data collected by Java Flight Recorder. The tool chain enables developers and administrators to collect and analyze data from Java applications running locally or deployed in production environments.

Starting with the release of Oracle JDK 7 Update 40 (7u40), Java Mission Control is bundled wit…

How to set up SSH port forwarding in Linux

What is "Port Forwarding" or "Tunneling"?

In addition to the direct access provided by the "ssh" and "scp" commands, the SSH protocol includes a feature called "Port Forwarding", or "Tunneling". This can be used to provide secure access to other services that do not normally encrypt data during transmission.

For example, to receive email, many email programs use the (unencrypted) POP3 protocol to connect to a mail server on port 110. If we can SSH to the mail server before downloading our mail, we can configure the SSH session to "forward" port 110 through the encrypted SSH link. Now, if we configure our email client to connect to port 110 on our local machine it will in fact be connecting to the remote mailserver, but all the data, (i.e. our incoming email), will be transferred over the encrypted SSH link.

If we also forward port 25, (which normally handles SMTP, the outgoing email protocol), then both incoming and…

How to fix: There is a process already using the admin port of GlassFish server

To fix There is a process already using the admin port of GlassFish server If you encounter:
There is a process already using the admin port 4848 -- it probably is another instance of a GlassFish server.

You need to add your host name into /etc/hosts to to the end of the string, even you can see correctly see your host name by running:


See also:

How to Set / Change Host Name in CentOS 7 / RHEL 7 / Oracle Linux 7

Java Thread Status

NEW: The thread is created but has not been processed yet.RUNNABLE: The thread is occupying the CPU and processing a task. (It may be in WAITING status due to the OS's resource distribution.)BLOCKED: The thread is waiting for a different thread to release its lock in order to get the monitor lock.WAITING: The thread is waiting by using a wait, join or park method.TIMED_WAITING: The thread is waiting by using a sleep, wait, join or park method. (The difference from WAITING is that the maximum waiting time is specified by the method parameter, andWAITING can be relieved by time as well as external changes.)

HOW TO ADD Multiple / Ranges OF IP ADDRESSES TO CentOS / RHEL / Oracle Linux NIC

Go to the /etc/sysconfig/network-scripts directory.

Verify which interface you will use to add IP addresses. Typically, this will be em1, em2 or eth0, eth1 for public IP addresses.

Make a copy of ifcfg-eth0 for each IP you wish to add and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.
# cp ifcfg-eth0 ifcfg-eth0:0 # cp ifcfg-eth0 ifcfg-eth0:1 # cp ifcfg-eth0 ifcfg-eth0:2 # cp ifcfg-eth0 ifcfg-eth0:3 # cp ifcfg-eth0 ifcfg-eth0:4 Open each of them and change the fields DEVICE, .IPADDR and NETMASK accordingly.
A sample entry would look like this:
NAME="eth0:0" BOOTPROTO="static" IPADDR0="" PREFIX0="23" ONBOOT=yes GATEWAY0="" Restart the network:
# systemctl restart network OR # service network restart
To add a lot of IP addresses ( range(s) ) at once:

First, you need to make sure to append the following text to the end of the NIC configuration file ( such as /etc/sysconfig/network-scripts/i…

How to fix: pxe-e51 no dhcp or proxydhcp offers were received

Solution: pxe-e51 no dhcp or proxydhcp offers were received This error is usually received when the client booting up via PXE is having difficulty communicating with the DHCP/PXE server. The common troubleshooting steps and/or causes of this problem are as follows: 1-The PXE client is connected to a managed switch that does not have portfast enabled and/or is running spanning-tree. Portfast will need to be enabled.  2-The DHCP/PXE servers reside on a different subnet than the PXE client. IP helpers need to be in place.  3-Check the DHCP server and verify that the DHCP scope has free IP addresses to lease out (make sure they are not all used up). 4-If the above steps do not correct the issue, place the DHCP Server, PXE server and a client computer on a hub. Test PXE to see if the same message is received. If the same error message is not received, this is a good indication that there is some factor on the network not permitting the DHCP/PXE protocols to be passed down to the client comp…

SSH Port Forwarding (tunnel) in Linux for Proxy etc.

Dynamic: Dynamic port forwarding turns your SSH client into a SOCKS proxy server. To use dynamic port forwarding with the default SOCKS port:

ssh-C-D1080yourRemoteServer:portssh-C-D1080 yourRemoteServer (whenyouusethedefaultport22) ssh-C-D1080-iyourKeyFile.pemec2-user@yourEC2The -D option specifies dynamic port forwarding. 1080 is the standard SOCKS port. Although you can use any port number, some programs will only work if you use 1080. The -C option enables compression, which speeds the tunnel up when proxying mainly text-based information (like web browsing), but can slow it down when proxying binary information (like downloading files). Now you have a SOCKS proxy server: localhost:1080
Static: For instance, to connect to through from your local port 3306

ssh -L Both: You could add:
 -N      Do not execute a remote command.  This is useful for just forwarding ports (protocol version 2 only).

See also:
How to …

Make better test scripts.

Inputs and the gathered information from scripted tests can be used to enhance the current tests and diversify testing.

Main difference between Java List and ArrayList is that List is an interface while ArrayList is a class.

ArrayList implements the List interface, which means that ArrayList is a subtype of List interface.

In Java or any object oriented language, super type of variable can store an object of subtype. This is known as Polymorphism because any virtual method will be executed from subclass only, even though they were called from super type.

Java merge sort example

If your Facebook data was improperly shared with Cambridge Analytica

If you were of the affected, you'll see a message box with a link that will take you to Facebook's Help Center, where you'll find a tool that will tell you how your data may have been misused and which categories of information were shared.

How to deploy maven java project to Google App Engine from command line

mvn appengine:deploy

Keyboard shortcut for screen program in linux

'screen' gives you the ability to multiplex a number of interactive shell sessions through a single terminal session. You reserve one keystroke ([Ctrl]+[A] by default) which is the meta key that provides access to all 'screen' functions.
Thus the key sequence [Ctrl]+[A], [D] will "detach" your currently running screen session from the current terminal connection. To re-attach later (from that terminal session or any other) you use the 'screen -r' command.

screen -d -r: to remotely force a session to be detached and attach it here (to cleanly reattach from another session)
[Ctrl]+[A], [D] will "detach" your currently running screen session from the current terminal connection.
To resume a detached session: screen -r
To see the list of sessions: screen -ls
To attach without first detaching an active session: screen -x

KeyActionNotesCtrl+a cnew windowCtrl+a nnext windowI bind F12 to thisCtrl+a pprevious windowI bind F11 to thisCtrl+a &q…

How to forcefully unmount a Linux disk partition

$ sudo -i umount /extraumount: /extra: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
$ sudo -i fuser -km /extra $ sudo -i umount /extra -- You can also try umount command with –l option: # umount -l /mnt

-l : Also known as Lazy unmount. Detach the filesystem from the filesystem hierarchy now, and cleanup all references to the filesystem as soon as it is not busy anymore. This option works with kernel version 2.4.11+ and above only.

Caution: Using these commands or option can cause data loss for open files; programs which access files after the file system has been unmounted will get an error.

How to fix Google App Engine Deployment: mvn appengine:update 403 Forbidden You do not have permission to modify this app

To fix
mvn appengine:update 403 Forbidden You do not have permission to modify this app
you have to rename or delete the .appcfg_oauth2_tokens_java file in your home directory, so that the next time you try to deploy it, it will ask again for authentication.


How to Create Google App Engine App using Maven

Generate guestbook maven project from the command line: Then select from the artifact list by supplying the number.

If you want to create the complete, ready-to-run guestbook sample app, supply the number corresponding to

If you want to create an empty project that contains the required directory structure and files, ready for your own classes, supply the number corresponding to

Select the most recent version from the displayed list of available archetype versions by accepting the default.

See also:
Maven Google App Engine archetypes
You can also do it from Eclipse: -> New a Maven Project -> Add the New Maven Archetype From Google.
$ mvn clean install Use maven goal
$ appengine:devserver to run the app.

Use maven goal
$ appengine:update to upload to Google…

Avoid using prependId="false" in JSF

Creating a form with prependId="false" will lead to client-IDs of child components of this form where the path to be passed to findComponent() being different from the client-ID.
This leads to confusion, especially with composite components and f:ajax where referencing components outside of the same naming container are being used very often.

Obtain an entity reference without initializing its data in JPA: getReference

The ability to obtain a reference to an entity without having to load its data is very important.  The most common case being the need to create an association between an entity and another, existing entity.  We achieve this  lazy loading by using EntityManager.getReference(id). With the method “getReference” you will query only for the object ID, you will save some database traffic. Use getReference method when you just to update some state by setter method without need to know the whole object's state from database. getReference returns a proxy object which uses a powerful feature called automatic dirty checking. For example:
publicclassDog { privateString name; privateInteger age; } publicclassDogServiceImplimplementsDogService { publicvoidupdateAge(Integerid, IntegernewAge) { Dog dog = em.getReference(Dog.class, id); // dog is a proxy dog.setAge(newAge); } } If you call find method, JPA provider, behind the scenes, will call

How to change / configure default JDK on Ubuntu


HtmlCleaner - an open-source HTML parser written in Java

HTML found on Web is usually dirty, ill-formed and unsuitable for further processing. For any serious consumption of such documents, it is necessary to first clean up the mess and bring the order to tags, attributes and ordinary text. For the given HTML document, HtmlCleaner reorders individual elements and produces well-formed XML. By default, it follows similar rules that the most of web browsers use in order to create Document Object Model. However, user may provide custom tag and rule set for tag filtering and balancing.

Features Summary
HtmlCleaner parses input HTML and generates tree-structure suitable for programmatic manipulation.Serializers are responsible for outputting the DOM structure to XML, HTML, DOM or JDom.Parsing phase relies on tag descriptions which can be customized by the user.HtmlClaner's behaviour can be configured through number of parameters.HtmlClaner is thread safe, meaning that single instance can clean multiple html sources at the same time.HtmlClaner…

How to fix: DatastoreNeedIndexException: The index for this query is not ready to serve in Google App Engine

In the log of the admin panel of your app, you can find the suggestion of the index, such as: The index for this query is not ready to serve. See the Datastore Indexes page in the Admin Console.
The suggested index for this query is:

<datastore-index kind="Greeting"ancestor="true"source="manual"> <property name="date"direction="desc" /> </datastore-index>
Put the suggest index to datastore-indexes.xml file located in your WEB-INF directory. The full xml file would look like:

<?xml version="1.0" encoding="utf-8"?><datastore-indexesautoGenerate="true"><datastore-indexkind="Greeting"ancestor="true"source="manual"><propertyname="date"direction="desc" /></datastore-index></datastore-indexes>

It’s human nature to be greedy when times are good

Market fluctuations are primarily driven by the emotions of the masses.
It's human nature to be greedy when times are good.

The iPhone is the most popular phone

It is time to say formal goodbye to  iPhone 6

The IOS system of the iPhone is very easy to use and the iPhone is expensive. 
The lowest end of the current market for your mobile phone is the iPhone 6.
iPhone 6 has been released for four or five years.The various configurations look very poor than the processors of the CellCon 660 and the Kirin 960, and the memory is even worse. When you upgrade to the latest IOS system, you'll get stuck, and the battery will need to be charged three or four times a day. Price hovering around 2000 yuan, and Xiaomi 6 and Huawei mate9 compared to the difference is too far away, so  iPhone 6, time to say formal goodbye!!!

World Backup Day

World Backup Day was March 31. It's a great reminder to back up all of your digital data and should be a part of your digital spring cleaning.

Google Mobile-First Indexing

Mobile-first indexing is finally here.

Google has announced that it's beginning migration of best practice-compliant sites into the mobile-first index.

Ubuntu 18.04 LTS is powered by the Linux 4.15 kernel.

Various utilities are now offered in the Snap format like System Monitor, Calculator, Characters, and Logs, and there is a new automatic suspend timeout of 20 minutes for laptops.
Ubuntu 18.04 LTSincludes patches for the Meltdown and Spectre security flaws.

Clear Linux is Intel’s uber light weight OS

Clear Linux is targeted at cloud use cases.

The Clear Linux* Project for Intel® Architecture is a distribution built for cloud and IoT use cases. We want to showcase the best of Intel architecture technology and performance, from low-level kernel features to complex applications that span across the entire OS stack. We're putting emphasis on Power and Performance optimizations throughout the operating system as a whole.

Comparison of CLI commands between GlassFish and WildFly

GlassFishWildFlyList all available commandsasadmin -c "help --commands"Display help infoasadmin --helpCheck versionasadmin versionStart server or domainasadmin, or domain.shStop server or domainasadmin -c :shutdownRestart server or domainasadmin -c ":shutdown(restart=true)"Start in debug modeasadmin start-domain -d
asadmin start-domain --debugDeploy an app with CLIasadmin deploy ~/ -c "deploy ~/test.war"Undeploy the test.war appasadmin undeploy -c "undeploy test.war"List deployed appsasadmin list-applications
asadmin list-components
asadmin list-applications -l
asadmin list-components -c deploy -c undeploy -c "deploy -l" -c "undeploy -l" -c "ls deploy&quo…

Observer Design Pattern in Java ( SE and EE )

SE and EE versions:

SE version

package;importjava.util.Observable;importjava.util.Observer;classMyObserverimplements Observer {publicvoidupdate(Observable o, Object arg){ System.out.println("update: "+ arg);}}

package;publicclassObserverTest{publicstaticvoidmain(String[] args){ Observered oed =new Observered(); MyObserver mo1 =new MyObserver(); MyObserver mo2 =new MyObserver(); oed.addObserver(mo1); oed.addObserver(mo2); oed.updateNoticeBoard("Event from occurs");}}

package;importjava.util.Observable;classObserveredextends Observable {private String event;public String getEvent(){return event;}publicvoidupdateNoticeBoard(String notice){this.event= notice; setChanged(); notifyObservers(notice);}}
Source in GitHub

Problems with java.util.Observable
Because Observable is a class, you have to s…