Posts

Showing posts from October, 2018

How to add Multiple Recipients in Java Mail

Multiple Recipients in Java Mail If you invoke addRecipient multiple times it will add the given recipient to the list of recipients of the given time (TO, CC, BCC)

For example:

message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("abc@example.com"));
message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("bcd@example.com"));
message.addRecipient(Message.RecipientType.CC, InternetAddress.parse("xyz@example.com"));
Will add the 3 addresses to CC

If you wish to add all addresses at once you should use setRecipients or addRecipients and provide it with an array of addresses

Address[] cc = new Address[] {InternetAddress.parse("abc@example.com"),
                               InternetAddress.parse("bcd@example.com"),
                               InternetAddress.parse("xyz@example.com")};
message.addRecipients(Message.RecipientType.CC, cc);

You can also use InternetAddress.parse to parse a list of …

How to add new disk to Centos

fdisk -l to list the disk
fdisk /dev/sdb (suppose /dev/sdb is what you want to add.) Command (m for help): p
Command (m for help): n
Command (m for help): w mkfs -t ext4 /dev/sdb1 Format the new partition, suppose you want to format sdb1 to ext4 mkdir /where-evermount the disk sudo mount /dev/sdb1 /where-ever
Or add the following line into fstab. /dev/sdb1 /where-ever ext4 defaults 0 1

Dynamic Web Programming with AngularJS, JavaScript, and jQuery

JavaScript and its amped-up companions, jQuery and AngularJS, have completely changed the game when it comes to creating rich interactive web pages and web-based applications. JavaScript has long been a critical component for creating dynamic web pages. Now, with the advancements in the jQuery and AngularJS libraries, web development has changed forever.

Simple example to call digitalocean api from python

''' Created on Mar 6, 2013 @author: i88.ca Simple example to call digitalocean api from python ''' import urllib2 import urllib data = {} data['client_id'] = '8888' data['api_key'] = '8888' url_values = urllib.urlencode(data) url = 'https://api.digitalocean.com/droplets/8888/reboot' full_url = url + '?' + url_values data=urllib2.urlopen(full_url) response=data.read() print response

Why AWS Aurora

Why AWS AuroraAmazon Aurora is compatible with MySQL 5.6. That means the applications, tools, and drivers you’re already using with MySQL can be used.You can launch a new Aurora database from an RDS MySQL DB snapshot.5x increase in performance when compared to MySQL.You can scale your database up to 32 virtual CPU’s (vCPU) and 244 GB memory. You can optionally add up to fifteen read replicas to increase read capacity.Aurora is designed to detect database crashes and restart without the need for manual crash recovery.Highly available: the db is replicated six ways across three Availability Zones.Automatic storage scaling up to 64 TB.AWS Aurora uses SSL (AES-256) encryption to secure data in transit.The Aurora database engine is able to provide 100,000 writes and 500,000 reads per second.

Amazon API Gateway - a cloud-based API management layer that enables developers to create, publish, and maintain APIs

Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. With a few clicks in the AWS Management Console, you can create an API that acts as a “front door” for applications to access data, business logic, or functionality from your back-end services, such as workloads running on Amazon Elastic Compute Cloud (Amazon EC2), code running on AWS Lambda, or any Web application. Amazon API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, authorization and access control, monitoring, and API version management.

Amazon API Gateway has no minimum fees or startup costs. You pay only for the API calls you receive and the amount of data transferred out. Amazon API Gateway supports multiple stages, enabling developers to isolate development, test, and production environments. Priced at $3.50 per million API c…

How to input NFS parameters in Dell Lifecycle controller

Image
NFS parameters in Dell Lifecycle controller Share Name (CIFS or NFS) — Path to the shared folder where the Update Packages or
repository is located. For example: \\192.168.20.26\sharename or \\servername\sharename.

Catalog Location or Update package path or File path. For example: myos.iso


Apache Cordova - a platform for building native mobile applications using HTML, CSS and JavaScript

Apache Cordova is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript.

When using the Cordova APIs, an app can be built without any native code (Java, Objective-C, etc) from the app developer. Instead, web technologies are used, and they are hosted in the app itself locally (generally not on a remote http server).

And because these JavaScript APIs are consistent across multiple device platforms and built on web standards, the app should be portable to other device platforms with minimal to no changes.

Apps using Cordova are still packaged as apps using the platform SDKs, and can be made available for installation from each device's app store.

Cordova provides a set of uniform JavaScript libraries that can be invoked, with device-spe…

Using Lifecycle Controller in Dell Server

When booting, press F10 to run Lifecycle Controller.

In Lifecycle Controller, you can

OS DeploymentConfigure RAID and Deploy an Operation SystemConfigure RAIDFirmware UpdateHardware ConfigurationLifecycle LogPlatform RestoreHardware DiagnosticsSettingsSystem Setup

strace - a diagnostic, debugging and instructional user space utility for Linux

strace is used to monitor interactions between processes and the Linux kernel, which include system calls, signal deliveries, and changes of process state. The operation of strace is made possible by the kernel feature known as ptrace.

The most common usage is to start a program using strace, which prints a list of system calls made by the program. This is useful if the program continually crashes, or does not behave as expected; for example using strace may reveal that the program is attempting to access a file which does not exist or cannot be read.

An alternative application is to use the -p flag to attach to a running process. This is useful if a process has stopped responding, and might reveal, for example, that the process is blocking whilst attempting to make a network connection.
As strace only details system calls, it cannot be used to detect as many problems as a code debugger such as GNU Debugger (gdb). It is, however, easier to use than a code debugger, and is an extremely…

How to handle big result sets in MySQL command line

mysql> pager less
mysql> show innodb status\G

You can specify anything you want as a pager.  You can write your own script and push the output through it.

mysql> pager path-to-your-script.sh
mysql> show innodb status\G

Common Internet File System (CIFS)

The Common Internet File System (CIFS) is the standard way that computer users share files across corporate intranets and the Internet. An enhanced version of the Microsoft open, cross-platform Server Message Block (SMB) protocol, CIFS is a native file-sharing protocol in Windows 2000. CIFS defines a series of commands used to pass information between networked computers. The redirector packages requests meant for remote computers in a CIFS structure. CIFS can be sent over a network to remote devices. The redirector also uses CIFS to make requests to the protocol stack of the local computer. The CIFS messages can be broadly classified as follows: Connection establishment messages consist of commands that start and end a redirector connection to a shared resource at the server. Namespace and File Manipulation messages are used by the redirector to gain access to files at the server and to read and write them. Printer messages are used by the redirector to send data to a print queue at…

Unified Extensible Firmware Interface (UEFI)

The Unified Extensible Firmware Interface (UEFI) is a specification that defines a software interface between an operating system and platform firmware. UEFI replaces the Basic Input/Output System (BIOS) firmware interface originally present in all IBM PC-compatible personal computers, with most UEFI firmware implementations providing legacy support for BIOS services.

UEFI can support remote diagnostics and repair of computers, even with no operating system installed. Intel developed the original EFI (Extensible Firmware Interface) specification. Some of the EFI's practices and data formats mirror those from Microsoft Windows.

What is disk spanning

Disk spanning combines multiple drives and displays them in the operating system as one drive.
For example, four 20-GB hard drives that are spanned appear as one 80-GB drive in the operating
system. Disk spanning alone provides no data protection. It is a logical grouping to increase the capacity of the disk.

What is the best write cache policy to implement? write-back vs write-through

There are two types of write caching:

write-back write-through 
In write-back caching, the RAID controller signals that a data transfer is complete when the controller cache has received all data in the transaction. In write-through caching, the RAID controller signals that a data transfer is complete when the disk subsystem has received all of the data.

Write-back caching is typically faster for applications that perform mostly random IO, while write-through caching provides more assurance that the data made it to the disk and does not require a battery backup for the cache.

If your RAID controller has a battery backup unit, the controller’s cache retains data if there is a power loss, meaning that you can have the performance of write-back caching as well as data security.

It is recommended that you use a Battery Backup Unit (BBU) to avoid loss of data.

How do hot spares work?

A hot spare is a drive that is on standby in case another drive fails. Depending on how the virtual
disk is configured, the drive is either picked up automatically and the virtual disk is rebuilt, or you
manually select the drive (or insert a new drive in the same slot as the failed drive) and rebuild the
virtual disk.

How the hot spare works depends on how the virtual disk is configured. When a drive fails, the virtual disk rebuilds automatically using the hot spare if automatic rebuild is available and enabled.

If automatic rebuild is not available or disabled, you must manually start the rebuild process. During a rebuild you may notice degraded performance on the drives.

A dedicated hot spare is assigned to one or more virtual disks, whereas a global hot spare can be
used for any redundant virtual disk that is on the same controller as the hot spare.

Do all drives in a RAID virtual disk have to be the same size?

All drives in a virtual disk do not have to be the same size. However, all drives in the virtual disk
default to the smallest drive in the virtual disk. For example, if your virtual disk contains three 36-GB
drives and one 18-GB drive, the maximum capacity of any drive in the virtual disk is 18 GB. On some controllers that support spanned RAID levels, it is possible to use different drive sizes in different spans and still use all the available disk space.

For example in a RAID50 config you can have one span with 4x300 GB drives and a second span with 4x500 GB drives and all the disk space will be available to the end user without any loss of redundancy.

To reduce complexity and use drive space efficiently, use only unpartitioned drives of the same size
when creating an virtual disk.

How to ignore SSL certificate errors in Apache HttpClient 4.3+

Sometimes in development mode, you need to ignore SSL certificate errors for https connections:

CloseableHttpClient httpClient = HttpClients.custom().setHostnameVerifier(new AllowAllHostnameVerifier()).build();

Example of org.apache.http.client.utils.uribuilder

URIBuilder

Maven dependency:

<dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient-osgi</artifactId><version>4.3.6</version></dependency>
URIBuilder u=null; try { u =new URIBuilder("http://it.i88.ca/bounce"); for (String name : map.keySet()) { u.addParameter(name, map.get(name)); } } catch (URISyntaxException e) { e.printStackTrace(); } System.out.println(u.toString());

txt2html - convert plain text files to HTML

txt2html supports headings, tables, lists, simple character markup, and hyperlinking, and is highly customizable. It recognizes some of the apparent structure of the source
       document (mostly whitespace and typographic layout), and attempts to mark that structure explicitly using HTML. The purpose for this tool is to provide an easier way of
       converting existing text documents to HTML format.

       One can use txt2html as a filter, outputting the result to STDOUT, or to a given file.

       One can define options in a config file as well as on the command-line.


/usr/bin/txt2html version 2.51
Usage:
    txt2html --help | --manpage

    txt2html [ --append_file *filename* ] [ --append_head *filename* ] [
    --body_deco *string* ] [ --bold_delimiter *string* ] [ --bullets
    *string* ] [ --bullets_ordered *string* ] [ --caps_tag *tag* ] {
    --custom_heading_regexp *regexp* } [ --debug ] [ --demoronize ] [
    --default_link_dict *filename* ] [ --dict_debug *n* ] [ --…

Using visudo - editing configuration file for sudo

The configuration file for sudo is /etc/sudoers. It should always be edited with the visudo command. visudo locks the sudoers file, saves edits to a temporary file, and checks that file's grammar before copying it to /etc/sudoers. Warning:
It is imperative that sudoers be free of syntax errors! Any error makes sudo unusable. Always edit it with visudo to prevent errors.From man 8 visudo: Note that this can be a security hole since it allows the user to execute any program they wish simply by setting VISUAL or EDITOR. The default editor for visudo is vi. sudo from the core repository is compiled with --with-env-editor by default and honors the use of the VISUAL and EDITOR variables. EDITOR is not used when VISUAL is set. To establish nano as the visudo editor for the duration of the current shell session, set and export the EDITOR variable before calling visudo. # EDITOR=nano visudo To change the editor of choice permanently system-wide only for visudo, add the following to /etc/sud…

How to Set Up a USB Key to Install CentOS 7

Starting with CentOS 6.5, one can install from USB keys by simply transferring the desired ISO using dd. For example: dd if=CentOS-6.5-x86_64-bin-DVD1.iso of=/dev/sdb When asked for the media to install from, select "hard disk" and then the device corresponding to the USB key.
Make sure you select as destination the device corresponding to the USB key (/dev/sdb in the above example) and not a partition(such as /dev/sdb1)

Popular Software Reference

Supported SoftwareWild Card SSLRequirements: VPS or Dedicated server
Root Required: No
Cost: $25.00 install fee
Other: We do not sell Wild Card SSL; however, you can purchase one elsewhere and have it installed.Adobe Flash MediaserverRequirements: Dedicated
Root Required: No
Cost: $80.00 + License Cost
Other: Flash Media server (FMS) is from Adobe Systems. The License must be obtained prior to us installing the software from Adobe.BFD (Brute-Force Detection)Requirements: VPS or Dedicated server
Root Required: No
Cost: $25.00
Other: This software detects if an IP is trying to connect to port 22 too many times, then blocks the IP and emails the administrator of the server.PHP FoxRequirements: VPS or Dedicated server due to resource usage
Root Required: No
Cost: N/A
Other: phpfox.comClamAVRequirements: VPS or Dedicated server or Dedicated
Root Required: The customer does not need root access for basic functionality of this software, however, as with anything done outside a user's account, if the …