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.

Friday, July 14, 2017

Source code revision control with Git


Version control system is used to manage versions of files and is used widely with programming source codes. Common examples are SVN and Git.

Here is an example of the using GIT with Heroku (Working with GIT2). It demonstrates the git command for;
  • clone
  • branch
  • checkout
  • commit
  • status

Basic commands to manage a local version control repository

Typical process to prepare a folder where files are to be tracked/staged uses the commands init, status and add. It would be good to have created a folder with 4 or 5 files and try out the following commands.
 # Initialise Git repository   
  $ git init   
     
  # Identify status and which files are being track or untracked.   
  $ git status   
     
  # Add all files to the repository   
  $ git add .  
   
 # Identify files are being track as staged  
  $ git status   

At this time, a folder to manage the repository is created with the name ".git". Have a look at content of the files in this folder.

Filename: .git/HEAD
ref: refs/heads/master

Filename: .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly

Filename: .git/description
Unnamed repository; edit this file 'description' to name the repository.


To remove a file from being tracked.
 # Remove a file from list of staged files  
 $ git rm --cached somefile.txt.  

Process to place files into the repository.
 # Commit files to repository  
 $ git commit -m "Place comments here"  
   
 $ git status  

Retrieve tracked file from the repository. The latest thats found in the repository, that is.
 # Checkout a file from the repository  
 $ git checkout programming.txt  
   
 $ git status  

Cache and other files that should not be kept in the repository or tracked, can be listed in a file ".gitignore" within that folder. Example to ignore the folder "temp" and file "nofile.txt".

Filename: .gitignore
/temp
nofile.txt

end

Wednesday, June 21, 2017

Open Source Software Leads Growth of Deep Learning Community

Faster CPU and GPU computers have arrived and AI computing is becoming available to more people. Amazon and Google are already rolling out services that allow anyone access to the computational resources required for AI, in particular deep learning. I am looking forward at how this will be incorporated into the next gen of personal devices.


There are too many areas to discuss on this, but here I would like to mention that deep learning is catching up fast on the open source software (OSS) environment.

GPU deep learning with NVIDIA provides a good start. They even have a whole section devoted to deep learning;

https://www.nvidia.com/en-us/deep-learning-ai/education/

A quick guide on deep learning is available at Deep Learning Introduction.

Thursday, June 1, 2017

The Day British Airways System Crashed in 2017

Waiting to hear the cause of it. How difficult is it to start up the back up process?

Source https://www.thesun.co.uk/news/3669536/british-airway-it-failure-outsourced-staff/


Pentaho 7 Community Edition

Summary of their licenses.

With big data and increase interest in business intelligence, there seems to be many software out there to suit all your needs. As for OSS licensed, the name Pentaho have been around for a long time. Here is a little note on their licensing.

Pentaho Business Analytics Platform 2, Pentaho Reporting Engine and Pentaho Report Designer are licensed as GPL v2.

Pentaho Data Integration or Kettle is license as Apache version 2.0. Details are found at  their wiki.

There is an interesting and comforting public post on Kettle license at Pentaho Forum with regards to Pentaho licensing.

Community Edition

Pentaho 7.1 is currently available but there is still the community edition, and my notes on Howto install is available only for the Linux server.



The additional known components that enterprise have and community edition doesn't is the self service designer dashboard and interactive reporting. Still searching for comparison of the community edition and other BI tools in the market.

Thursday, April 20, 2017

Mouse Cursor Disappear in Chrome Web Browser

Google Chrome is among the web browsers that I use frequently on MS Windows 10. Chrome provide many standard web browser features, security and option to extend its capability via plugin extensions. Work productivity goes up a notch when many application windows are launched to run concurrently. The monitor screen is big enough to allow re-positioning of the windows, overlapping windows and minimizing of windows.

On 20th April (today), the mouse cursor disappears when its moved over the Chrome window. It appears back when the cursor is moved outside of the Chrome window area. Moving the cursor again on Chrome window area, its noticeable that an invisible cursor is moving as hyperlinks light up, menu and buttons get active and the standard windows minimise and maximise buttons can be accessed.

A quick search on the internet shows that this problem have occurred way back in June 2014. Its almost the same thing, and issue only started after a MS Windows update that had occurred the day before. Yes, there was a Windows 10 updated yesterday.

Solution is to disable the Hardware Acceleration in Chrome. Here is how to get that cute cursor back on Chrome.


Step 1: Open Chrome web browser (if its not already open).

Step 2: Click "Customise and control Google Chrome" or the "3 vertical dots" button. Its usually at same row as the URL bar. Choose "Settings", scroll down and click "Show advanced settings...".

In the section "System" uncheck Use hardware acceleration when available. Close Chrome and launch Chrome or restart Chrome.

I have not found out if its due to MS Windows change in its settings or Chrome settings changed. Maybe someone out there have an answer.

Tuesday, February 21, 2017

Cloud storage for Linux PCs

Having your resume, project files, assignments and other documents stored on the internet cloud is now a much more acceptable norm. Previously there were fears on privacy of the files from the providers and governments, possibility of the account being hacked or just plain poor software and hardware to protect integrity of the documents.

As cloud storage gain acceptance, there are more options available. Among the popular storage are Dropbox, gDrive and ownCloud as listed here.


Compare Dropbox gDrive OwnCloud
Storage (FREE) 2GB. Offers available up to 16GB 15GB. Include Google accounts like Gmail. Unlimited, provide your own
Availability Integration with MS O365, OneLogin, 1Password, MS Azure, Xero.
available Offline
Pretty much everything works with Google and Google Realtime API.
Available offline
Unlimited.
Not available offline
Features (General)
  • Accessible by main stream devices
  • Automatic updates
  • File sharing
  • Offline access
  • 256-bit AES encryption keys. 128-bit AES SSL/TLS encryption for files in transfer

  • Accessible by main stream devices
  • Automatic updates
  • File sharing
  • Offline access
  • File versioning
  • 128-bit AES encryption keys. 256-bit SSL/TLS encryption for files in transfer
Web based. 3rd party apps are available for wide variety of devices.

  • Open source licensed AGPLv3
  • File sharing
  • Comments and tagging
  • Versioning and undelete
  • Flexible external storage handling
  • Integration of anti-virus scanning

Its a matter of balancing your resources, needs and funding when deciding which services to take up.


Dropbox provide one of the most fancy looking and good security.

Google gDrive comes with a host of applications like Google Sheets, Docs, Presentation to open your documents on a PC and mobile devices. Truly any time, any where documents are available.

OwnCloud allows any individual and corporation to customise, design a security of their choosing and include branding with use of their own storage. With more controls, security exploits such as man-in-the-cloud attack can be avoided. Did I mention, you install the whole thing for FREE on your own (your ownCloud....get it)?

Wednesday, February 8, 2017

Howto start Programming with Laravel

With the announcement Laravel 5.4 is released on 24.1.2017, a better PHP programming framework is now available. Here is how you can start programming with Laravel 5.

What is Laravel 5?

Its a PHP programming framework. Yes, you still need to know PHP programming. This framework allow quick creation of a CRUD application and connection to a database to store data. Lots of work have been done for you to complete standard task BUT it requires you to adhere certain styles and syntax. These you MUST learn in order to appreciate the power of Laravel framework and the learning curve is NOT steep.

From laravel.com get more information on what is Laravel, browse examples and then install Laravel framework. Once installed, open a command line terminal to create a new project framework.

Laravel have a tool called artisan to do all the wonderful stuff of the framework. Here is an example to display Laravel version.


Getting help

The installed framework comes with its own description of its command tools. To access this, open a command line interface and type;

 $ php artisan --help  

or to display for a specific command

 $ php artisan help serve  
 $ php artisan help migrate  

List to find further help can be found at Laravel and Getting Help.




Monday, January 23, 2017

Copyright photography laws impeding civilization growth?

Did you know that you need permission and probably make a payment to take a picture of the light display at Eiffel Tower in France? As social media continue to grow, more people will post photos of their trip to the Eiffel Tower.

How can you LEGALLY share your photo of the Eiffel Tower at night? Its simple, you must gain permission from Societe d'Exploitation de la Tour Eiffel.

Tourist: Whoaa....you mean I can't even share my holiday trip photos to my friends?

Tour guide: Sure you can. Take photos of Eiffel Tower in the daytime. You can publish a photo of Paris city scene where the Eiffel Tower appears. Those, you can share. Please be reminded, the same goes for Louvre's pyramid in Paris.

Tourist: I guess everyone's got to earn a living. Hope the artist gets some of the earnings from the copyright.

If its a private place like a home or a club, I can understand photography restrictions due to copyright issues. Soon tourist and business trip to these places would require you to wear special glasses to restrict vision of these copyrighted places. Kind of peculiar for people to soon think of no reproduction by camera, smart phone, drawing or even thinking about it copyright laws.

Are there other countries with similar copyright laws on photography of public places?

Its almost like being in a tyrannical state, right? but wait, because its widely implemented in Europe, groups have people have been working on changing these limiting laws. Currently, an exception to these copyright laws are being published on Wikipedia by Freedom of Panorama (FOP).

Learning through photo sharing experiences is so easy. To some, going to Paris might only be a reality through the Internet.


Friday, January 20, 2017

Raspberry Pi Programming - typical electric components

Raspberry Pi provides a great platform to learn programming and gain knowledge of basic electric components.

At this moment I am considering that the most basic projects for a newbie with no educational background in electrical or electronic engineering would cover;

  1. Basic of electric circuits and personal safety
  2. Use of battery, LED and resistors
  3. Buzzer and sensors
The Raspberry Pi would then be connected to turn on/off and detect state of the component. Basics of Python programming would be needed, see my previous post. This is going to be fun, but expect some parts to get fried along the way even with only 3volts.

Next couple of days will be used to sort out which components for upcoming basic projects.

Which components should I use?


Wednesday, January 18, 2017

Python for kids

Every used Raspberry Pi and wanted to learn programming? It comes with a programming language called Python. You and any primary of secondary school going child can learn Python if they have access to the internet.

One such site is Learn Python
https://www.learnpython.org

An online compiler is provider with the tutorials and is a great start. Put aside all those daunting and distracting stuff, like it being Python version 2 or 3 and just dive into the lesson.

You will emerge a very much better person after completing the lessons. Once you are done, pick up a Raspberry Pi project that uses Python and you are on the way to being in the Matrix. Examples of projects can be found at (link, link ) and www.raspberrypi.org.

Friday, January 13, 2017

Howto reinstall Samsung Galaxy S5

The Samsung Galaxy S5 is a powerful phone and have lasted me over 2 years. Regular updates and the many different applications installed and removed does cause the storage to be bloated and its good option to clear everything and reinstall only the required apps after such a long time.

I will be doing a factory reset (wipe out all data on phone) then allowing the Galaxy S5 to restore last saved settings and finally restore application settings from Samsung Smart Switch (the PC software provided by Samsung). A USB cable is required to connect Galaxy S5 with the PC running the Smart Switch. Make sure the phone is detected when using the USB cable, else you may need to get another USB cable.

IMPORTANT
Backup all your data before proceeding. Copy your login information for Google, Samsung and other apps on a paper, if you need to.

Before we begin, there are 2 steps to be carried out;

BACKUP PHONE INFORMATION
Use the Backup and Restore.
From the phone, select the Settings (This usually looks like a gear when you pull down to display the menu from top of the screen) and choose Backup and Restore. Choose your backup and restore settings, including storing it on Google drive.

Backup other settings and apps to a PC or external storage as needed.

SAMSUNG SMART SWITCH
We will be using Samsung Switch, so go ahead and install this on a PC.  Start Smart Switch, plugin the Galaxy S5 phone to the PC via USB cable, then do backup of applications and other media that you require.

Here are steps taken to reinstall the smart phone from Samsung. Make sure the phone is fully charged BEFORE you start.

Step 1. FACTORY RESET (optional)
From the phone, select the Settings (This usually looks like a gear when you pull down to display the menu from top of the screen) and choose Backup and Restore. Then choose Factory Reset.

This may take a while as it will also reinstall default applications found on the phone.

Step 2. INITIALISE THE PHONE
Start the phone and follow the instructions to setup. I choose not restore all Apps from google but only the settings. Finish the setup with last steps that include confirmation of the phone name.

Step 3. UPDATE AND RESTORE DATA
On the PC, start Smart Switch then plugin via USB the Galaxy S5 phone. If prompted to upgrade, accept and follow instructions provided. Strongly suggest that the CAUTION message displayed is followed to avoid wasted time on failed software update.

Smart Switch update software for Galaxy S5

Smart Switch CAUTION messages

You will need to disconnect the cable once its done. This will cause the phone to restart, wait a little bit as it flashes the text "SAMSUNG", then it will show "Android is upgrading" before the phone can resume as normal. For me, on the phone it mentioned optimizing app total of 284, and this restart process took just over 15minutes before I could get the login screen.

RESTORE DATA
Start Smart Switch on the PC. Login to the phone and plug it to the PC using the USB cable.

Smart Switch should detect the phone, then clik on the Restore button and follow the instructions. Once restore is complete, disconnect he USB cable. On the phone, Check the Contact, calendar and other contents that is needed.

TIPS
Find Lock a lost Samsung phone using a web browser.
Open a web browser and type location as https://findmymobile.samsung.com and login with the Samsung account used with the phone. Here is a well documented site on ensuring that you enable basic actions that you can take when the phone is lost.

Wednesday, November 30, 2016

Howto Install Laravel Using Composer

Following are instructions to install Laravel Framework 5.3.16 on a Centos Linux 7. The PHP Composer 1.2.2 is used to install all the dependency packages. Detailed instructions on MS Windows environment were initially prepared in previous blog Howto Install Laravel Framework using Composer.

The system on a x86 64-bit computer consist of
CentOS Linux 7.2
HTTPD 2.4.6-40.el7.centos.4
PHP 7.0.13
MySQL 5.7.16-1.el7

Step 1. Install Laravel

Login to a command line terminal (CLI) as a normal user (with sudo rights) and type

 $ sudo yum install composer  
 $ composer -V  

This installs Composer 1.2.2. Minimum requirement is PHP 5.3.2 as mentioned as Composer website.

Install Laravel

 $ sudo yum install composer  
 $ composer -V  

Create your first application called hello.

 $> composer create-project --prefer-dist laravel/laravel hello   

This install Laravel 5.3.16 as shown in the image below. The folder tests and vendor is not shown.

Listing in hello folder.



Step 2. Run Artisan Serve

Start local artisan server

 $ cd hello  
 $ php artisan serve  

Open a web browser and point to the provided URL http://localhost:8000

To allow access to this instance with a domain name such as tboxmy.blogspot.com, start the server with following command

 $ php artisan serve --host= tboxmy.blogspot.com --port=8000  

Step 3. View the Results in HelloWorld

Test Laravel with a helloworld file

Open a terminal and go to the project folder ->hello ->resources ->views
Create a file helloworld.blade.php with following text

1:   <!DOCTYPE html>   
2:   <html>   
3:    <head>   
4:     <title>Laravel</title>   
5:    </head>   
6:    <body>   
7:   Hello World!   
8:    </body>   
9:   </html>   

Display this "VIEW" when the URL is /hello by editing the file web.php in the project folder ->hello ->routes

1:   Route::get('/hello', function () {    
2:     return view('helloworld');   
3:   });   

Save the file and start the artisan serve.

Open a web browser and type the URL mentioned above in Step 2. E.g.
http://localhost:8000/hello

This displays the Hello World! page with HTML formatting from the file resources/views/helloworld.blade.php

Done

Tuesday, November 22, 2016

Raspbian Command Line Basics 102

This is continuation from Raspbian Command Line Basics 101


Here are 18 commands on configurations of Raspbian Jessie or Release 8.0 on a Raspberry Pi 2. This might work for other versions of Raspbian, as they are common Linux commands in most cases.

At the Raspbian terminal, users can access a whole load of information. These can be useful for troubleshooting graphics, program conflicts and networking issues.

GENERAL

Display your device name and operating system information
$ uname -a

Change directory
$ cd directoryname

List files n a directory
$ ls
or
$ ls directoryname

Restart background services
$ sudo systemctl daemon-reload

Display disk usage or free space
$ free
$ free -h

Display disk usage by partitions
$ df -h

Display contents of a file
$ cat filename
e.g. to display CPU type
$ cat /proc/cpuinfo

Display the system date and time
$ date

Edit a file with Vim or Nano
$ vi filename
or
$ nano filename

Schedule shutdown at specific time
$ shutdown -h 21:00
or reboot
$ shutdown -r now

Configure Raspbian
$ sudo raspi-config

PACKAGE MANAGEMENT

List installed packages
$ dpkg-query -l

To clear up disk space before updating
$ sudo apt-get clean

Update Raspbian system packages
$ sudo apt-get update

Upgrade installed packages
$ sudo apt-get dist-upgrade

Install a package
$ sudo apt-get install mypackagename
or
$ sudo apt-get install mypackagename -y

Remove an installed package
$ sudo apt-get remove mypackagename
or complete removal with its configuration files
$ sudo apt-get purge mypackagename

Search for a package online
$ apt-cache search mypackagename

Display information of a package
$ apt-cache show mypackagename


NETWORKING

Default networking file is configured at
/etc/dhcpcd.conf

And the dhcpcd controls the networking interfaces

Display existing network interface settings
$ ifconfig


Display network routing table
$ route 
or display all numericals
$ route -n

Changes to the static ip in configuration file requires restart of the dhcpcd
$ sudo dhcpcd -k
$ sudo dhcpcd

Display status of running network interfaces
$ sudo service networking status

Restart network interfaces. Required after changes to network configuration.
$ sudo service networking restart

When there is network but web browser display "Unable to resolve name". Edit the domain name server at /etc/resolv.conf

nameserver x.x.x.x


Saturday, November 19, 2016

Oppo F1s How To Change Looks - Part 1

Oppo F1s is a decent phone running Android 5.1. Very responsive to the touch and with a nice big screen.

It's got a few things that new users just must do to personalize to look cute. Since there are so many things for customisation,  I will list few must know things to default theme.

Add screens

Default it comes with 2 screen where you can swipe left or right to go to each screen. Screens are a great way to organise contents. As you can see below,  there are 3 circles above the camera icon which means there are 3 screen.

Select an icon on the screen for the new screen. In this example,  I choose Theme Store icon and as drag it, the screen editor appears at bottom of screen.


Drag the icon to a new screen and release. If the icons are still wobbly or jello like,  tab on an empty space of the screen and it should end the editing mode. 



Create folder on a screen

Folders allow you to group several icons together on one screen.  With option to name the folder,  everything get more organised. Folders are shown as an icon with a little downwards arrow by it's side.

In order to create a folder,  identify the 2 icons for a folder.  Press on one icon and drag it on the centre of the other icon.  The icons will then be displayed in editing mode with the name of the folder above.  Click on that name and change the folder name.  Click the check mark and tap an empty space on the screen.

Change theme

Themes provide a feel of icon shapes,  background and lock screen that consistent.
Press Theme store icon and select a theme or press the download theme button.




The download button is to choose installed icons themes on the system.  Next press on apply and watch your screen and icon change. Other changes may effect fonts and lock screen.



Done.



Friday, November 11, 2016

Yum error Cannot retrieve metalink for repository

Yum provides installation, upgrades and removal of packages on Linux such as Centos. It is used to install other package repositories too. Over time, some of the certificates for installation would have changed and thats where you get this error when running Yum.

In this example, the error indicate Epel repository cannot be retrieved.

"Cannot retrieve metalink for repository: epel"

Some sysadmins have decided not to use that repo totally as they do not use that repo. E.g. when updating a package, they use

# yum --disablerepo="epel" update httpd

Solution

  1. Clean yum cache
  2. update the ca-certificate packages while disabling that repository with error.

Clean yum cache
# yum clean all

Update ca-certificate packages



In my Centos 6.3, it required to updated these related packages.


Monday, November 7, 2016

Howto Start Lavarel and MySQL


Lavarel provide the tools to quickly create an MVC application. In this guide, lets generate the required database table of a class and retrieve data while keeping to MVC.

Background

Models are used to represent objects and Laravel associates it with a database table of the same name. E.g. a model called Customer (singular) will have a table called Customers (plural). Using the --migration option will also produce a file to manage the database.
Our Customer class will consist of the fields id, cname, phone, last_update and a timestamp.



Controllers provide the glue to Views and Models. Laravel helps to create controllers that are empty or CRUD ready in the directory app/Http/Controllers. CRUD ready meaning that the standard functions or also known as Actions are generated for each HTTP action;

GET - create, show, edit and index.
POST - store
PUT/PATCH - update
DELETE - destroy

Each Controller file needs to be told which namespaces or Models to use.

Routing determines the URL mapping to actions that Controllers are to provide. Route can also be directly to a View or to deliver specific HTML contents without any Controllers.

The Laravel config directory contains a file, database.php with default settings to SQLite, Mysql and Postgresql database. You just need to fill in the appropriate values for the database in use. This Howto will use MySQL database.

Pre-Requisites

Installed the following and are in working order

  • Apache2
  • PHP v7.0.12
  • Composer 1.2.2
  • Lavarel 5.3


To install Laravel, refer to previous posting http://tboxmy.blogspot.my/2016/11/howto-install-laravel-framework-using.html

Step 1. Configure Lavarel to use MySQL

Create a database in MySQL called hellocustomer and assign the user permissions. Create 2 to 3 rows of dummy data as this howto will need to retrieve these data.

Edit the file hello/config/database.php and configure database

        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'hellocustomer'),
            'username' => env('DB_USERNAME', 'mysql'),
            'password' => env('DB_PASSWORD', 'somepassword'),
            'charset' => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

Edit hello/.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=hellocustomer
DB_USERNAME=mysql
DB_PASSWORD=somepassword

Step 2. Create the Customer Model

1. At the project workspace directory, open a terminal and type

php artisan make:model Customer --migration

This will create

  • hello/app/Customer.php
  • hello/database/migrations/YYYY_MMM_DD_###_create_customers_table.php


2. Edit the table file in migrations (above) with all the required fields for Customer model.
3. Activate the migration file to generate Customer table in the database. Just type;

php artisan migrate

If the schema needs to be changed and database deleted after the above was created, just refresh the database, with;

php artisan migrate:refresh


Step 3. Create the CustomerController class

In order for the CustomerController class to retrieve data from the database, Eloquent provides the all() function, such as;
 $customers = Customer::all();  

An array of data rows are extracted to the variable $customers. No additional SQL coding is required.

At the terminal, type the following to generate the controller class app/Http/Controllers/CustomerController.php

php artisan make:controller CustomerController --resource

Edit CustomerController to use the Customer model by adding the "use App\Customer;" above class declaration as below;


use App\Customer;
class CustomerController extends Controller
{
 public function index()  
 {  
       //              
       $customers = Customer::all();  
       return View('customers.index')->with('cust', $customers);  
 }  

 public function show($id)  
 {  
       //              
       $customer = Customer::find($id);  
       return view('customers.show', array('customer' => $customer));  
 }  


Step 4. Create View for the Implemented Actions in Controller

Create a directory customers in resources/views and create the following 2 files

 <!DOCTYPE html>  
 <?php  
 // index.blade.php   
 ?>  
 <html>  
 <head>  
   <title>Customer index page</title>  
   <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">  
 </head>  
 <body>  
 Customers  
 <br/>  
 @foreach($cust as $key => $value)  
 <table>  
     <tr>  
       <td>{{ $value->id }}</td>  
       <td>{{ $value->cname }}</td>  
       <td>{{ $value->phone }}</td>  
                   </tr>  
                   @endforeach  
 </table>  
 </body>  

 <!DOCTYPE html>  
 <?php  
 // show.blade.php   
 ?>  
 <html>  
  <head>  
   <title>Customer</title>  
  </head>  
  <body>  
  <?php  
       if ($customer == null)   
       {  
             print "No data";  
             return;  
       }  
       ?>  
   <h1>Customer {{ $customer->id }}</h1>  
   <ul>  
    <li>Name: {{ $customer->cname }}</li>  
    <li>Phone: {{ $customer->phone }}</li>  
    <li>Last update: {{ $customer->last_update }}</li>  
   </ul>  
  </body>  
 </html>  

Edit routes/web.php file to use this new controller.

Route::resource('customer', 'CustomerController');

Step 5. Try them out

The Actions from our Laravel framework implementation can be listed with the command

php artisan route:list







Since you now know the URL for each Action we know to do the following displays for all customers and for each customer.

To call  INDEX action use the URL
http://localhost:8000/customers/



To call  SHOW action use the URL followed by a valid customer id.
http://localhost:8000/customers/1


Exercise:

This should take less than 15 minutes to complete.

Demonstrate use of database with Laravel. Create following Customer class below and display formatted data (create your own dummy data in the database).










Friday, November 4, 2016

Howto Install Laravel Framework using Composer

Laravel framework provides rapid development of a model-view-controller (MVC) with PHP programming language. Currently is at version 5.3 and is open source using MIT license.

Composer is a tool to easily retrieve packages required for most PHP projects and frameworks. Laravel can be found available in Composer at packagist.org. Detailed documentation for Composer can be found at https://getcomposer.org

This is a quick guide on installing Laravel then creating a page to display hello world!.

Installation environment for this How-to;
MS Windows 10
Apache2
PHP v7.0.12
Composer 1.2.2
Laravel 5.3

By the end of this guide, the following directories should have been generated.


Step 1: Installing Composer

Ensure Apache2 and PHP7 is already installed and working before starting this guide.

Download and install Windows Composer installer https://getcomposer.org/Composer-Setup.exe

Open a terminal and change to the installed PHP folder. Type

 $> composer -V  

(Or with the file composer.phar in same directory, type)
 $> php composer.phar  
This should display the version number of composer.
Update composer and check the version.
 $> php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"  
 $> php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"  
 $> php composer-setup.php  
 $> php -r "unlink('composer-setup.php');"  
 $> composer -V  

Step 2: Create an empty composer project 

Create a project folder called myproject.
Open a terminal and enter folder for myproject
Type
 $> composer init  

Choose default values, except following;
Package type: project
dev dependencies: yes
Search for a package: laravel/laravel

Press "Enter" until exit the interactive menu.

This will create a default json file for the composer. This step is only an example of creating a json file. Feel free to ignore this step.

Step 3: Install Laravel Framework and dependencies

Create a project folder called myproject, if you haven't.
Open a terminal and enter folder for myproject, and type.

 $> composer create-project --prefer-dist laravel/laravel hello  


This will do pretty much that same as Step 2 above, except that it will create the workspace called hello and load all the required libraries and plugins.

Laravel is installed in the folder hello.

Step 4: Start local server

Open a terminal and enter folder for hello, and type.

 $> cd hello  
 $> php artisan serve  

Laravel development server started on http://localhost:8000/

Open a web browser and type the URL mentioned above.
http://localhost:8000/

It displays the default Laravel page.

Step 5: Display a Hello World page

Open a terminal and go to the project folder ->hello ->resources ->views
Create a file helloworld.blade.php with following text

 <!DOCTYPE html>  
 <html>  
   <head>  
     <title>Laravel</title>  
   </head>  
   <body>  
  Hello World!  
   </body>  
 </html>  

Tell Laravel that to display this "VIEW" when the URL is /hello.
Edit the file web.php in the project folder ->hello ->routes

 Route::get('/hello', function () {    
      return view('helloworld');  
 });  

Save the file.

Open a web browser and type the URL mentioned above.
http://localhost:8000/hello

This displays the Hello World! page with HTML formatting from the file resources/views/helloworld.blade.php

Step 6: Display a Hello World text (without Views)

Tell Laravel to display some HTML when the URL is /hello2
Edit the file web.php in the project folder ->hello ->routes

 Route::get('/hello2', function () {    
      return 'Hello World 2!';  
 });  

Save the file.

Open a web browser and type the URL mentioned above.
http://localhost:8000/hello2

This displays the Hello World 2! text.

Happy trying out Lavarel.



Tuesday, October 11, 2016

Open Source Hardware Today

The spirit of open source software means providing access to the source code, friendly licensing models and community support (documentations, forums and social gatherings). Computer and electronic hardware have always been proprietary as it involved large sum of money and required access to specialised machines and technology in order to design and build hardware.

In October 2016, it is announced by Open Source Hardware Association the rollout of Open Source Hardware Certification Program (read more). Hopefully it will help to address the long time conflict of patent law with OSS licenses in regards to hardware. That's right, OSS relates to copyright laws in almost all cases I know, but when it comes to hardware, most of it refer to patent law.

The most well known license for open source hardware is the European Organization for Nuclear Research (CERN). CERN list their licenses, hardware repository and projects that use their license at http://www.ohwr.org


More projects on hardware can be found at
Makezine
Olimex
Raspberry Pi
Adruino

With the certification coming out, a growing list of open source hardware vendors and project, looks like the stars are shinning for open source hardware enthusiast and business.



Thursday, October 6, 2016

Learning to code for kids

Here are 5 websites to start the young minds with coding. In no particular order;

Scratch 

Use of the famous programming blocks of different shape and colours to do coding. Adobe Flash is required for the web interface.

CodinGame

Use web interface to complete snippet of codes. This is not for the uninitiated. You have a choice of using the text editor Emacs, Vim or the standard IDE that supports several popular programming languages. This includes C, C++, Java, Go, Paskal, PHP, Python and Ruby. If you are looking to learn logics and algorithms, this is it.




Code Academy

Provides programming courses for free. Personal learning plan and quizzes with advisor are included in the paid subscription. Its starts off with learn to HTML and CSS.


Code.org

Place to learn coding with contribution from many difference sources. Some element of Scratch with specialised themes and gamification to learn coding. Lots of resources for lesson plans.
A sweet start would be Coding with Anna and Elsa.


Alice

Create 3D animations and learn programming for those familiar with the use of computers. This product of Carnegie Mellon University teaches C++, Java and C#.



Any of these made it to your your favourite sites?

Blog Archive