Posts

Showing posts from January, 2020

Google Earth on mobile

Google Earth on mobile can now display space and the stars around the planet

Google Safe Browsing API

Google Safe Browsing API lets your client applications download hashed versions of the Safe Browsing lists for storage in a local database. URLs can then be checked locally. Only if a match is found in the local database does the client need to send a request to the Safe Browsing servers to verify whether the URL is included on the Safe Browsing lists.

Google App Engine PHP Runtime

It is no longer necessary to whitelist your application for deployment.

Developers interested in the PHP runtime now can create an account and deploy PHP applications immediately.

How to Find and kill a process in Linux

For example, to show all the process IDs of mysql-workbench:

 $ ps -A | grep [m]ysql-workbench | awk '{print $1}'

The sample outpout:

12974
12982

The awk gives you the first field of each line, which is the PID.

The grep filters that based on your search string. [m]ysql-workbench is a trick that applies regex. It will then catch all other mysql-workbench processes but excluding grep itself.  If you use "grep mysql-workbench" directly, the process of grep itself will be caught too. Since [m]ysql-workbench != mysql-workbench, the process of grep will be excluded.

To kill them in one line:

$ kill $(ps -A | grep [m]ysql-workbench | awk '{print $1}')  (more reliable)

The $(x) is to execute x then put its output on the command line. So you end up with a command like "kill 12974 12982".

Or even simpler:

$ kill $(ps -A | awk '/[m]ysql-workbench/ {print $1}')

How to install New Relic Java agent to Glassfish

For Glassfish, you need to unpack newrelic.zip into your domain's directory, such as

/opt/glassfish3/glassfish/domains/domain1/

Difference between include directive and include action in JSP Servlet

Both include directive and include action is used to include output of a static page e.g. html or a dynamic page e.g. jsp inside another jsp file.
Include action vs Include directive in JSPWhat is include directive in JSP


Include directive in JSP is used to import a static file or dynamic file e.g. JSP inside another JSP. Most commonexample of include directive is including header and footer in JSP. Include directive is also called file includebecause resource to be included is specified using file attribute as shown in below example of include directive:
<%@ include file="detail.jsp" %>
The code written in detail.jsp will be included as it is in the jsp file which included it during JSP translation time and then merged code is get compiled to generate Servlet which is later used for server request. Include directive is also refereed as static import and it acts like #include from C or C++. file attribute is used tospecify resource to be included and can be specified in e…

Child themes for wordpress

Child themes are the recommended way of making modifications to a Wordpress theme.
To Make your WordPress child theme compatible with BuddyPress, you need to download and activate the BuddyPress Template Pack plugin. Then head over to admin dashboard > Appearance > BP Compatibility panel, and follow the steps.

Operator Difference: "MEMBER OF" vs "IN" in JPA

JPA distinguishes between the MEMBER OF operator, which should be used for checking a collectionfield, and the IN operator, which should be used for checking other collections, such as a collection that is passed to the query as a parameter.

For example:

'fido' MEMBER OF person.dogs

'fido' IN :dogs

The 20 most expensive keywords in Internet Ad

The highest search volume (i.e. the most used keywords) and highest costs per click, thereby netting Google the most money, are:
Insurance (example keywords in this category include "buy car insurance online" and "auto insurance price quotes")Loans (example keywords include "consolidate graduate student loans" and "cheapest homeowner loans")Mortgage (example keywords include “refinanced second mortgages” and “remortgage with bad credit”)Attorney (example keywords include “personal injury attorney” and “dui defense attorney”)Credit (example keywords include “home equity line of credit” and “bad credit home buyer”)Lawyer ("personal  injury lawyer," "criminal defense lawyer)Donate ("car donation centers," "donating a used car")Degree ("criminal justice degrees online," "psychology bachelors degree online")Hosting ("hosting ms exchange," "managed web hosting solution")Claim (&…

How to fix: Error: schema com.canonical.notify-osd not installed

use Synaptics and search for notify-osd.
Install it.

How to drop database with # in name in MySQL

By default any folders inside the mysql data directories will be read as database and will be shown in "show databases".

You can escape database names using backtick quotes to drop it:

DROP DATABASE `#mysql50#lost+found`;

Reads from Amazon DocumentDB replicas are eventually consistent.

Reads from Amazon DocumentDB replicas return the data in the same order as it was written on the primary, and there is often less than a 50 ms replication lag. You can monitor the replica lag for your cluster using the Amazon CloudWatch metrics DBInstanceReplicaLag and DBClusterReplicaLagMaximum.

How to choose the location for your business

You can choose a location for your business that suits your needs, whether that means working from home, working close to home, or taking the opportunity to travel and see different places. 
You might choose a trendy downtown office, or a place outside the city to avoid traffic or a long commute. While you have a lot of flexibility in choosing a location, you should take into account access to customers, employees and suppliers.

How to fix MySQL workbench: statement may be truncated

Edit -> Preferences -> SQL Execution -> Max. Field Value Length to Display. Default 256 bytes

Simple example to access Gmail by Java

To show the folders and their message counts:
Propertiesprops=System.getProperties();props.setProperty("mail.pop3.port",prop.getProperty("995"));Sessionsession=Session.getInstance(props,null);Storestore=session.getStore("imaps");store.connect("pop.gmail.com","name","password");javax.mail.Folder[]dfolders=store.getDefaultFolder().list("*");for(Folderf:dfolders){System.out.println(f.getFullName());if((f.getType()&amp;javax.mail.Folder.HOLDS_MESSAGES)!=0){System.out.println(f.getMessageCount());}} On github

The output:
INBOX 25 [Gmail] [Gmail]/All Mail 69 [Gmail]/Drafts 0 [Gmail]/Important 1 [Gmail]/Sent Mail 6 [Gmail]/Spam 4761 [Gmail]/Starred 0 [Gmail]/Trash 121
Open folder and delete the messages
IMAPFolderfolder=null;String[]folders=newString[]{"INBOX","[Gmail]/Spam"};for(Stringfname:folders){folder=(IMAPFolder)store.getFolder(fname);folder.open(Folder.READ_WRITE);intc=folder.getMe…

How to solve: Form submit does not trigger action method on JSF commandlink or commandbutton

First, make sure those commandlink or commandbutton is inside the
<h:form> and </h:form>

If still not woking, check whether you have "rendered" or "disabled" attribute for that component and your bean is request scope. You should change it from request scope to view scope. This is because if your bean is request scope, your "rendered" or "disabled" attributes are evaluated in different condition during processing the form submit from during displaying the form. JSF won't invoke the command if "rendered" or "disabled" attribute evaluates as "false".



Database Lifecycle

The life-cycle of a database instance includes creating, modifying, maintaining and upgrading, performing backups and restores, rebooting, and deleting the instance.

Finds AWS database instance name and class

The following command finds AWS database instance name and class for up to 100 instances.

# aws docdb describe-db-instances     --query 'DBInstances[*].[DBInstanceIdentifier,DBInstanceClass]' | less

Amazon DocumentDB storage automatically scales with the data in your cluster volume.

As your data grows, your cluster volume storage grows in 10 GiB increments, up to 64 TiB.

The size of your cluster volume is checked on an hourly basis to determine your storage costs.

How to fix MySQL Warning: Using a password on the command line interface can be insecure

The mysql_config_editor utility (available as of MySQL 5.6.6) enables you to store authentication credentials in an encrypted login file named .mylogin.cnf. The file location is the %APPDATA%\MySQL directory on Windows and the current user's home directory on non-Windows systems. The file can be read later by MySQL client programs to obtain authentication credentials for connecting to MySQL Server.

mysql_config_editor set --login-path=local --host=localhost --user=username --password

Then you can use in your shell script:

mysql --login-path=local 

instead of:

mysql -u username -p pass 

You need to put --login-path as the first parameter, or else you will get something similar to
"unknown variable 'login-path=local'"


SET

shell> mysql_config_editor set --login-path=local
         \ --host=localhost --user=localuser --password
Enter password: enter password "localpass" here
shell> mysql_config_editor set --login-path=remote
        \ --host=remote.example.com …

SEO: The description is missing in the head section of the page

The description is missing in the head section of the pageSearch engines may use the description provided in the <description> tag in the search engine results page (SERP). A well-written description that pertains to the content of the page and that is relevant to the searcher's intent can help you increase traffic since it can help improve the click-through rate of your page in search.
Recommended Action:

Add a description to the <head> section of the page source: <meta name="description" content="Descriptive, keyword-rich text that talks about the page content goes here.">.

How to install Apple Mobile Device USB Driver in Windows

Sometimes Windows chooses the best driver for you and it doesn't choose Apple Mobile Device USB Driver for your iPhone or iPad. Then you need to install the driver manually. Or else you won't be able to sync your iPhone or iPad to your iTunes. App Screen and Options to Sync Apps Are Grayed Out in iTunes.

Inside "Device Manager"
Expand all the sections labeled below (not all sections might be listed):

Imaging DevicesOther DevicesPortable DevicesUniversal Serial Bus Controllers
Look for the entry that recognizes the device as a camera. This entry should be called Apple iPhone, Apple iPad, or Apple iPod.

Right-click the Apple iPhone, Apple iPad, or Apple iPod entry in Device Manager and choose Update Driver from the shortcut menu.Click "Browse my computer for driver software".Click "Let me pick from a list of device drivers on my computer".Click the Have Disk button. (If the Have Disk option is not present, choose a device category such as Mobile Phon…

How to fix Android Studio: Unable to run mksdcard SDK tool

To fix it on 64 bit Ubuntu:

sudo apt-get install lib32z1 lib32ncurses5  lib32stdc++6

How to change Google cloud SQL timezone

See also:
How to Configure a MySQL flag for a Google Cloud SQL instance
Change MySQL Flag default_time_zone to the value you want. For example, to change to Eastern Standard time:
change default_time_zone to -05:00

How to avoid corrupted binlogs on MySQL

To avoid corrupted binlogs on the MySQL, enabling sync_binlog=1 on MySQL helps in most cases. sync_binlog=1 will synchronize the binary log to disk after every commit. sync_binlog makes MySQL perform on fsync on the binary log in addition to the fsync by InnoDB. As a reminder, it has some cost impact as it will synchronize the write-to-binary log on disk after every commit. On the other hand, sync_binlog=1 overhead can be very minimal or negligible if the disk subsystem is SSD along with battery-backed cache (BBU). You can read more about this here in the manual.
sync_binlog is a dynamic option that you can enable on the fly. Here’s how:
Shell

Java Apache asynchronous HttpClient REST (RESTful) client example

Flurry - Analytics Measure, track and analyze app performance, user acquisition and activity with Flurry Analytics.

Unlock App Growth Flurry empowers product, development and growth experts to build better apps that users love. Use Flurry to supercharge app engagement, run a data-driven product iteration process and boost user acquisition efforts. Easily track installs, sessions, time spent, and moreUnderstand your audience and how they use your appRun on-demand analysis with Explorer for funnels, cohorts and more
Big insights Gain insight into your user’s age, gender, and behavior. Benchmark your app’s Session Length, Frequency of Use and Retention against all Flurry clients. Compare your app to those in any app store category. Flurry Analytics Explorer Perform even more complex queries with Explorer, an easy-to-use data exploration interface that returns insights in seconds. No need to write code, build queries or wait for calculations.  Free Flurry Analytics is free at any scale and available for iOS, Android, Blackberry, Windows Phone, and mobile web.

Simple OAuth Java lib Scribe Twitter Example

<dependency> <groupId>org.scribe</groupId> <artifactId>scribe</artifactId> <version>1.3.7</version> // please use always the latest version </dependency>

Simple OAuth Java lib Scribe Linkedin Example

<dependency> <groupId>org.scribe</groupId> <artifactId>scribe</artifactId> <version>1.3.7</version> <!--please use always the latest version--> </dependency>

SIGTERM vs. SIGKILL

The SIGTERM signal is a generic signal used to cause program termination. Unlike SIGKILL, this signal can be blocked, handled, and ignored. It is the normal way to politely ask a program to terminate. The shell command kill generates SIGTERM by default.
The SIGKILL signal is used to cause immediate program termination. It cannot be handled or ignored, and is therefore always fatal. It is also not possible to block this signal. This signal is usually generated only by explicit request. Since it cannot be handled, you should generate it only as a last resort, after first trying a less drastic method such as C-c or SIGTERM. If a process does not respond to any other termination signals, sending it a SIGKILL signal will almost always cause it to go away. In fact, if SIGKILL fails to terminate a process, that by itself constitutes an operating system bug which you should report. The system will generate SIGKILL for a process itself under some unusual conditions where the program cannot po…

How to Configure RAID vdisk using Dell Dell OpenManage Server Administrator (OMSA) CLI

Configuring RAID vdisk using Dell Dell OpenManage Server Administrator (OMSA) CLI1. Install the omsa on a dell system: >wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell Key already exists in RPM, skipping Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios Key already exists in RPM, skipping Write repository configuration Downloading repository RPM Installing repository rpm: http://linux.dell.com/repo/hardware/latest/platform_independent/rh50_64/prereq/dell -omsa-repository-2-5.noarch.rpm Installing yum plugins for system id Loaded plugins: dellsysid, security dell-omsa-indep | 1.9 kB 00:00 dell-omsa-specific …

Dell OpenManage Server Administrator

Dell OpenManage Server Administrator (OMSA) provides a comprehensive, one-to-one systems management solution in two ways: from an integrated, web browser-based graphical user interface (GUI) and from a command line interface (CLI) through the operating system. Server Administrator is designed for system administrators to manage systems locally and remotely on a network. It allows system administrators to focus on managing their entire network by providing comprehensive one-to-one systems management.

What type of tasks can be performed using OMSA?
View the server’s hardware configurationCheck for hardware errorsCheck for firmware updatesReplace or reconfigure storage See also: How to Access OMSA from web browser

How to enable NetBeans modules

Tools -> Plugins -> Installed -> Activate.

You have to install it first if it is not available inside "Installed".

Request body and Length limit to share on Linkedin by API

POSThttps://api.linkedin.com/v1/people/~/shares?format=json

Request body Field DescriptionMax Length (chars)contentA collection of fields describing the shared content.titleThe title of the content being shared.200descriptionThe description of the content being shared.256submitted-urlA fully qualified URL for the content being shared.n/asubmitted-image-urlA fully qualified URL to a thumbnail image to accompany the shared content.

The image should be at least 80 x 150px for best results.n/acomment A comment by the member to associated with the share. If none of the above content parameters are provided, the comment must contain a URL to the content you want to share.  If the comment contains multiple URLs, only the first one will be analyzed for content to share. 700visibilityA collection of visibility information about the share.code One of the following values: anyone:  Share will be visible to all members.connections-only:  Share will only be visible to connections of the member perfor…