Friday, November 17, 2017

What's new in Firefox Quantum (screens)



Firefox 57, also known as Quantum is a major upgrade for Firefox web browser. Here are initial screens of this new web browser compared to previous version of Firefox 56.






Tools menu






Toolbar


Preferences
 

Speedtest



Speedtest Ranking



Friday, November 10, 2017

Laravel and using custom CSS file

Laravel 5 supports CSS and JavaScript preprocessors through Elixir and Gulp. Elixir is a node.js tool that helps gulp in the use of less, sass and coffee methods. Gulp assist programmers by automating repeated task like copying files, testing, minify codes.

If all that sounds confusing, dig deeper and you will find that Laravel framework assist developers to build and test application faster through tools like Elixir and Gulp.

There will be cases where an existing and proven CSS file should be used within a Laravel 5 project. In this example, there is a CSS file name beautiful.css that provides a box when used in the DIV CLASS code of the php application as shown below;

<DIV class="beautiful-tip">
 <P>Hello World</P>
</DIV>

We will use an existing working Laravel 5 application that is installed at the folder named <project>. In the gulpfile.js, the mix.sass contains 'app.scss' where instructions to use the CSS will be recorded.

Step 1: Copy the CSS file to Project's node_modules folder

Create the folder "example" in <project>/node_modules
Copy beautiful.css into the folder <project>/node_modules/example and make sure the folder and its contents are readable by the web server service.

Step 2: Include the CSS file when gulp compiles SASS files.

Edit <project>/resources/assets/sass/app.scss

At the last row, add the command (name of CSS file without its extension) and save.
@import "node_modules/example/beautiful";

Step 3: Run gulp.

At a command prompt in the project folder, type
# gulp

Done

Friday, November 3, 2017

Can anyone use OSS in their product?

Use of open source (OSS) licensed software have gained widespread acceptance. Its no longer just for hobbyist and academic studies. R&D takes place much rapidly with these open knowledge available to masses but its very different from just copying the software when corporations and industry adopts OSS in their product.

Ever wonder why anyone would allow their codes formed from sweat and sleepless nights to be made available to everyone? Broadcom for example, provide their source codes and its become such a powerful references. Something to ponder, but lots of articles are around to help one understand.

If you intend to use OSS as part of a product that is sold (not the services) or distributed freely, there is the GPL and LGPL type of licensing type of OSS. A brief if not too broad explanation on the differences.

Products bundled with GPL type licensed OSS components and codes must distribute with the source code made available to the product recipient. Lets say, you develop a smart desktop suite called P99SmartDS that incorporates modified Mozilla Thunderbird to handle smtp and pop messaging to the desktop. Thunderbird expects you to ship the P99SmartDS with working source code and be licensed not more restrictive than that GPL licensed.

Products bundled with LGPL type licensed OSS component and codes must distribute with the license and library of that specific OSS component. Lets say, you develop a wireless driver interface and application to simplify configuration and its using a LGPL licensed OSS library. This application does not have to be OSS licensed.

Selling a product base on OSS is not just about submitting bugs or chats in forums. It sharing of knowledge gain via successful products. The OSS licensed is the guardian to ensure continuity of the freedom of choices and knowledge. Play your part to safe guard this freedom.

Wednesday, November 1, 2017

Laravel 5 and OpenSSL

Notes on updating Apache 2.4, Laravel 5.5 with PHP 5, to PHP 7.1. 


Currently, the openssl key on my Apache server is serving encryption with AES 128. Information here is for development server environment only.

Default new Laravel applications are generated with use of encryption key type AES 256 as found in <Laravelproject>/config/app.php

The cipher key in app.php can be changed, or just generate the new required AES 256 keys.

Steps to generate the OpenSSL public and private keys;

$ openssl genrsa -aes256 -out mysitename.key 2048
$ openssl rsa -in mysitename.key -out mysitename-decrypted.key
$ openssl req -x509 -nodes -new -sha256 -key mysitename-decrypted.key -out mysitename.crt


When restarting Apache on MS Windows 10, this error appears.
"Init: SSLPassPhraseDialog builtin is not supported on Win32"

Solution is to remove the pass phrase in private key (See). In this example, the public and private ssl certs are both stored in <Apache directory>/conf/ssl/
Step 1:
Copy private key mysitename.key to secure.key

Step 2: Remove pass phrase from private key in use.
In CLI of the folder for ssl type

$ openssl rsa -in secure.key -out mysitename.key

Step 3: Open <Apache directory>/conf/extra/httpd-ssl.conf and comment out the line
# SSLPassPhraseDialog  builtin

Step 4: Restart Apache

In the event the following error appears, it means the openssl module is not loaded. Find another compatible Apache server to be installed that can load the openssl in directory extension.

PHP Startup: Unable to load dynamic library
or
Undefined method openssl_cipher_iv_length( )

Laravel non-existent script error

Recently updated to PHP 7.1 and all the existing PHP projects are working fine.

However, this error appeared when I am trying to create a new Laravel 5 project,

You made a reference to a non-existent script @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
. . .

You made a reference to a non-existent script @php artisan key:generate

Lets fix this in one step;

Step 1: Update the composer,

$ composer self-update

Updating to version 1.5.2 (stable channel).
    Downloading: 100%
Use composer self-update --rollback to return to version 1.2.2

Run the command used to create the new project,

$ composer create-project laravel/laravel myapps

Wednesday, October 4, 2017

Android AlertDialog

How to display a delete confirmation box?

A simple method is to use AlertDialog that quickly provides the "CANCEL" and "OK" along with your custom confirmation message.



An example within a Fragment class where a user click's the Delete button which calls the deleteConfirmation( ) function with the title or name of item to be delete.

1:  private void deleteConfirmation(String title){  
2:    AlertDialog.Builder alert = new AlertDialog.Builder(getContext());  
3:    alert.setTitle("Delete");  // Declare the title
4:    alert.setMessage("Are you sure you want to delete \n"+title+"?");  // Set message below title
5:    alert.setIcon(R.mipmap.ic_delete);  // Set the icon at top left
6:    alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {  
7:      public void onClick(DialogInterface dialog, int which) {  
8:        // continue with delete  
9:        MainActivity.confirmDelete=true;  
10:        delete();  
11:      }  
12:    });  
13:    alert.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {  
14:      public void onClick(DialogInterface dialog, int which) {  
15:        // close dialog  
16:      }  
17:    });  
18:    MainActivity.confirmDelete=false;  
19:    alert.show();  
20:  }  

Note 1:
The Dialog class is the base class to AlertDialog that makes the user take an action before returning back to the Fragment or Activity. This is known as a Modal Event. Other example of Dialog class are DatePickerDialog and TimePickerDialog.

If used for Android API 25 and onward, the import statement is

import android.app.AlertDialog;

for API 11 to below API 25 use

import android.support.v7.app.AlertDialog;

Note 2:
There are 3 type of buttons that can be added (in the example above, only 2 are added) to an AlertDialog. Only one of each type can be added using the following methods;

alert.setPositiveButton
alert.setNegativeButton
alert.setNeutralButton

List can be added to AlertDialog if required.

Note 3:
There are several ways to pass message or status to the Activity or Fragment that created/launched the AlertDialog. In the example above, a static variable is declared in the MainActivity and values are changed base on button clicked.

In MainActivity.java

public static boolean confirmDelete=false;

Note 4:
To further customise the AlertDialog look, a resource file (XML) can be created and assigned with the method

LayoutInflater inflater = getActivity().getLayoutInflater();
alert.setView( inflater.inflate(R.layout.customDialog, null) )


Done.

Tuesday, August 15, 2017

Raspberry Pi Workshop 2017 (Java)

Java is still very much alive today despite the many new programming languages sprouting. This portable language provides programming solution for a wide variety of computer systems including embedded devices.
As for the Raspberry Pi, the most common operating system being in use is Raspbian which comes default with Java installed. The Raspberry Pi provides a physical extension that connect to sensors and other electrical components. There are 2 most common Java libraries being used to accessed these extensions. Each having their own strengths.


In Malaysia, organisations can accelerate their learning path in this area through a 1 day fully hands-on comprehensive workshop. Details can be found the SHOP section of Harmony Shades or leave a message with details of your interest.

Wednesday, July 26, 2017

MySQL Console Pops Up Unexpectedly

MySQL database server provides an easy to implement and uses ANSI SQL syntax with wide implementation for many programming platforms. It is still open source licensed for the Community Edition as GPL (see details at mysql.com).

Current versions of MySQL Community Edition is available on Red Hat 6+, Centos 6+ and MS Window 10, for following versions;

  • MySQL 5.6 GA on 5.2.2013
  • MySQL 5.7 GA on 21.10.2015

Both versions are known to support current SQL standards, being SQL:2008.

Since using MySQL Community Edition version 5.6.21, something strange has been happening every midnight. A DOS like prompt pops up and very quickly does "something", which does NOT really allow me the time to read the messages and then it goes away (disappears). On one occasion I managed to capture that screen as the database it was trying to reach was not connected and here is how that screen looks like.


Apparently it was updating the MySQL catalogue, pretty harmless. The problem that I can see;
  • Takes up additional processing which is not good when I am running emulators or CPU intensive work
  • Distracts any on going work, such as when preparing documentation
  • Disrupts desktop on-going recordings
  • Disrupts benchmark operations

One could either disable the update process or assign it to another pre-defined time. On MS Windows 10, here are the steps to do either.

Step 1: Start MySQL Installer

Click the MS Windows Start and type; mysql installer
Click the Desktop App that appears. An upgrade my be required, proceed with the upgrade.


Step 2:  Edit Installer Options

In the installer option, click the Configure icon (Looks like a wrench).



  1. To disable the automatic catalog update; Uncheck "Should MySQL Installer update its catalog periodically?"
  2. To change the update time; Select a new time in "What time?" dropdown list.

Click Close.

Done.

Blog Archive