Friday

Linux Mint: Commands to restart and shutdown PC

On the Linux terminal, type the following command to restart your PC:

$ sudo restart

On the Linux terminal, type the following command to shutdown your PC:

$ sudo poweroff

Saturday

Python Web Programming with CherryPy

Python v2.7 64-bit Web Programming with CherryPy v3.2.3 64-bit

Download and install Python v2.7.8 64-bit (Python Interpreter) from
https://www.python.org/downloads/windows/

Download and install PyScripter v2.5.3 64-bit (Python IDE) from
https://code.google.com/p/pyscripter/downloads/list

Download and install pip-1.5.6.win-amd64-py2.7.exe from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pip

Download and install setuptools-5.8.win-amd64-py2.7.exe from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#setuptools

Download and install CherryPy-3.2.3.win-amd64.exe from
https://bitbucket.org/cherrypy/cherrypy/downloads/CherryPy-3.2.3.win-amd64.exe

Download and install pywin32‑219.win‑amd64‑py2.7.exe from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32

Download and install simplejson-3.6.4.win-amd64-py2.7.exe from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#simplejson

Add the below two paths to the Windows OS environment variables path:
C:\Python27\Scripts
C:\Python27

Open PyScripter Python IDE

Type the following in the PyScripter Python Interpreter console window to check if the correct cherrypy version has been installed:
>>> import cherrypy
>>> cherrypy.__version__
'3.2.3'
>>>

Type the following in the PyScripter File Editor window:
{
import cherrypy

class HelloWorld(object):
    def index(self):
        return "Hello, World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())
}
Click on the {Toolbar > Play button}

Open the browser and point at http://127.0.0.1:8080 to see the web page output.

Click on the {PyScripter IDE > Toolbar > Stop button}

Open the .py file at
C:\Python27\Lib\site-packages\cherrypy\tutorial\tut02_expose_methods.py
Click on the {Toolbar > Play button}

Sunday

Online Python Script Interpreter(s)

Read-Evaluate-Print Loop IT
url: http://repl.it/languages/Python
notes: file editor by clicking on the play icon, console interpreter by hitting the enter key
try:
Python 2.7.2 (default, Jul 20 2011, 02:32:18)
[GCC 4.2.1 (LLVM, Emscripten 1.5, Empythoned)] on linux2
   [n for n in range(0,10,1) if n%2==1] #odd numbers
=> [1, 3, 5, 7, 9]

Codecademy Labs
url: http://labs.codecademy.com/#
notes: file editor and console interpreter
try:
You're running Python version 2.7.2. To get started, type in the console below or the text editor to the left. Want to learn more about Python? Take Codecademy lessons!
>  print time.localtime()
time.struct_time(tm_year=2010, tm_mon=11, tm_mday=12, tm_hour=1, tm_min=22, tm_sec=33, tm_wday=4, tm_yday=333, tm_isdst=0)
# dst is the daylight savings time 
> import os
> os.getcwd()
=> '/sandbox'

Python Tutor, Line-by-line Code Visualization
url: http://pythontutor.com/visualize.html#mode=edit
notes: only file editor, you can change the drop down box value to "show only outputs" if there is any output, has Python versions 2 and 3
LEARN programming by visualizing code execution
Helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program in the Web browser and visualize what the computer is doing step-by-step as it executes the program.
try:
Write: Python 2.7 code here or load an example:
    name = raw_input('What is your name?\n')
    print 'Hi, %s.' % name
Program Output:
    What is your name?
    Name1
    Hi, Name1.

codepad is an online compiler/interpreter and a simple collaboration tool
url: http://codepad.org/
notes: file editor only, select radio button Python
try:
Paste your code below, and codepad will run it and give you a short URL you can use to share it in chat or email.
text area:
print """
What is duck typing?
  It is a term used in dynamic languages
that do not have strong typing.
  The idea is that you don't need a type
in order to invoke an existing method on an object -
if a method is defined on it, you can invoke it.
  The name comes from the phrase
"If it looks like a duck and
quacks like a duck,
it's a duck".
"""
Click on the Submit button
Output:
01
02  What is duck typing?
03    It is a term used in dynamic languages
04  that do not have strong typing.
05    The idea is that you don't need a type
06  in order to invoke an existing method on an object -
07  if a method is defined on it, you can invoke it.
08  The name comes from the phrase
09  "If it looks like a duck and
10  quacks like a duck,
11  it's a duck".
12

Wandbox, [Python] python 2.7.3
url: http://melpon.org/wandbox/
notes: file editor only, choose compiler: [Python] python 2.7.3
try:
input code:
import calendar
print calendar.month(2013, 2)
print "Display multiplication table of 13"
for i in range(1,11):
   print 13,'x',i,'=',13*i
click the button "Run (or Ctrl+Enter)"
#1
Start
   February 2013
Mo Tu We Th Fr Sa Su
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28


Display multiplication table of 13
13 x 1 = 13
13 x 2 = 26
13 x 3 = 39
13 x 4 = 52
13 x 5 = 65
13 x 6 = 78
13 x 7 = 91
13 x 8 = 104
13 x 9 = 117
13 x 10 = 130

0

Finish
input stdin: empty text area box
Tick two checkboxes: No Wrap, Expand

Ideone is an online compiler, IDE, and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.
url: http://ideone.com/
notes: only file editor, click run button to get the script output
Choose a programming language, enter the source code with optional input data... and you are ready to go!
try:
</> enter your source code or insert template or sample or your template:
# your code goes here
def factorial(n):
  if n == 0:
    return 1
  else:
    return n * factorial(n - 1)
print factorial(5)
Choose Python programming language from the drop-up list box
Click the "spectacles" icon for secret
Click on the link "few options" if there is any
Success
stdin:
Standard input is empty
stdout:
120

Execute Python Script Online (Python 2.7.4)
url: http://www.compileonline.com/execute_python_online.php
try:
notes: file editor only
try:
#!/usr/local/bin/python2.7
print 'a' "b" """c"""
Executing the program....
$python2.7 main.py
abc


References:
- http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html

Thursday

Thunderbird: How to search for email messages by certain category in your inbox?

Menu > Edit > Find > Search Messages (Ctrl + Shift + F)
Using this way, you may search for email messages by subject, from, date, or other category.

Wednesday

Java Database Programming Visually using NetBeans

Java DB (Derby) Database Tutorial using NetBeans IDE, Create Database Table Visually, Write Code to View Table Data

Download and install Java SE 7 from

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download and install NetBeans IDE 7 from
https://netbeans.org/downloads/7.4/

Open NetBeans IDE

Go to the Projects window. Tab on Services

Expand the Databases tree node

Right-click on Java DB and select Start Server

Right-click on Java DB and select Create Database. Key-in the following text:
Database Name: db1
User Name: db1username
Password: db1password
Confirm Password: db1password
Database Location: C:\Users\yourname\.netbeans-derby
Click OK button

Right-click on jdbc:derby://localhost:1527/db1 [db1username on DB1USERNAME]
and select Properties. You will see the following information:
Database URL: jdbc:derby://localhost:1527/db1
Driver: org.apache.derby.jdbc.ClientDriver
Schema: DB1USERNAME
User: db1username
Click Close button to close the database Properties window

Right-click on jdbc:derby://localhost:1527/db1 and select Connect

Expand the “jdbc:derby://localhost:1527/db1” tree node

Expand the DB1USERNAME tree node

Right-click on Tables and select Create Table. Key-in the following information using the Create Table Dialog:
Table name: customer
Add the following columns to the customer table:
customer_id, type: INTEGER, contraints: Primary key & Unique & Index
customer_name, type: VARCHAR, size: 1000, contraints: Null
customer_home_address, type: VARCHAR, size: 1000, contraints: Null
customer_mobile_phone_number, type: VARCHAR, size: 1000, contraints: Null
customer_email_address, type: VARCHAR, size: 1000, contraints: Null
Click OK button to close Create Table window

Expand the Tables tree node

Right-click on CUSTOMER tree node, select “View Data” to add table data using the SQL editor

Go to the CUSTOMER table middle window toolbar, click on “Insert Record(s) (Alt+I)” icon
Insert the following Customer table data:
customer_id, customer_name, customer_home_address, customer_mobile_phone_number, customer_email_address
1, name1, address1, mpnum1, email1
2, name2, address2, mpnum2, email2
3, name3, address3, mpnum3, email3
Click OK button to close Insert Record(s) window

Create a Java Application project. Name the project as prjJavaDBDerby1

Create a Java package. Name the package as test. Create a new Java Class under test package. Name the Java Class as ReadDbTableData.java

The code for the ReadDbTableData.java file content is as follows:
--
package test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ReadDbTableData {

    public static void main(String[] args) {
       
        try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        } catch (ClassNotFoundException e) {
            System.out.println(e);
        }

        try {
            Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/db1", "db1username", "db1password");
            Statement stmt = con.createStatement();

            ResultSet rs = stmt.executeQuery("SELECT * FROM db1username.customer");

            while (rs.next()) {
                int customer_id = rs.getInt("customer_id");
                String customer_name = rs.getString("customer_name");
                String customer_home_address = rs.getString("customer_home_address");
                String customer_mobile_phone_number = rs.getString("customer_mobile_phone_number");
                String customer_email_address = rs.getString("customer_email_address");
                System.out.println(customer_id + ", " +
                                  customer_name + ", " +
                                  customer_home_address + ", " +
                                  customer_mobile_phone_number + ", " +
                                  customer_email_address
                                  );
            }
        } catch (SQLException e) {
            System.err.println(e);
        }

    }
}
--

Right-click on the project, select Properties.
On the left window, select Libraries.
Click on “Add Library…” button.
Select “Java DB Driver” library. Click on Add Library button to add this JAR library.
Click OK to close Project Properties window

Right-click on the ReadDbTableData.java file window and select Run File

You should be getting the following output:
--
1, name1, address1, mpnum1, email1
2, name2, address2, mpnum2, email2
3, name3, address3, mpnum3, email3
BUILD SUCCESSFUL (total time: 0 seconds)
--

Sunday

Android Programming using NetBeans IDE

Download and install Java SE 7 from http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download and install NetBeans IDE 7 from https://netbeans.org/downloads/7.4/

Download and unzip stand-alone Android SDK Tools (android-sdk_r23.0.2-windows.zip) for an existing IDE from http://developer.android.com/sdk/index.html to the C drive. The extracted folder name should be "android-sdk-windows"

Open the "SDK Manager.exe" at C:\android-sdk-windows\SDK Manager.exe
Tick the box beside the package name "Android 4.1.2 (API 16)"
Tick also "Intel x86 Emulator Accelerator (HAXM) installer" package under Extras node
HAXM = Android Hardware Accelerated eXecution Manager for Intel processor
Click on the "Install anInteger packages..." button
Wait until all the ticked packages are finished installing

Restart PC. Press F10 or delete key to enter BIOS to enable Virtualization Technology which is normally under System Configuration section
Double-click on
"C:\android-sdk-windows\extras\intel\Hardware_Accelerated_Execution_Manager\intelhaxm.exe" file to install Intel HAXM
HAXM speeds up the slow Android emulator on Intel machine

On the Android SDK Manager window:
- click on SDK Manager Menu > Tool > Manage AVDs...
- create a new Android Virtual Device Manager (AVD)
--- AVD Name: avdAndroid_4_1_2
--- Device: Nexus 4 (4.7", 768 x 1280: xhdpi)
--- Target: Android 4.1.2 – API Level 16
--- CPU/ABI: ARM (armeabi-v7a)
--- By default, let the box beside the "Hardware keyboard present" ticked
--- Skin: Skin with dynamic hardware controls
--- Click the OK button
--- At top right corner, click 'x' icon to close "Manage AVDs..." window
- At top right corner, click 'x' icon to close the Android SDK Manager window

Open NetBeans IDE
Click on Menu > Tools > Plugins > Settings tab
Click Add button to add new url to the Update Center
Type: Provider Name: nbandroid
Type: URL: http://nbandroid.org/updates/updates.xml
Click OK button
Select "Available Plugins" tab
Tick the "Android" box
Click on Install button to install this nbandroid plugin
After "Android" plugin installed, click Close button

NetBeans IDE Menu > Tools > Options > Miscellaneous toolbar icon > Android tab
SDK Location: C:\android-sdk-windows (use Browse button)
Click OK button

NetBeans IDE Menu > File > New Project > Android > Android Project
Click "Next >" button
Project Name: AndroidApplication1
Package Name: com.mycompanyname
Activity Name: MainActivity
Target Platform: select: Target Name: Android 4.1.2
Click Finish button

Clean and build the Android project

Run the Android project
Wait for some minutes until you get the "MainActivity" app icon on the emulator menu screen

Note that, you do not need to close the avdAndroid_4_1_2 Android Emulator window once it is opened

Edit the Android source code to meet your requirements
If you don't have any clue, try to edit the file text in the "AndroidApplication1\Resources\layout\main.xml"

Right-click on the AndroidApplication1 project name, select Run again to execute this app

Thunderbird: Compact Folders Manually

Click on the Inbox folder at the left pane
Click on Menu > File > Compact Folders
Wait until you see the message "Done compacting" on the status bar
Done for now

Friday

Gmail: Undo Sent Email for a few seconds after hitting the send button

- Login into Gmail (mail.google.com)
- Click on the Gear icon and select Settings
- Select Labs menu
- Search for a lab: "Undo Send"
- Click on "Enable" radio button
- Click on "Save Changes" button
- Try to undo sent email:
--- Compose a message to an email account, recipient example, user@gmail.com
--- Click the Send button (Ctrl+Enter)
--- Click the "Undo" link at the top popped-up message "Your message has been sent. Undo View Message"
--- With this, your email will not be sent

Saturday

Firefox v30.0: Show Menu Bar and Tab Groups Toolbar

 Show Menu Bar:
- Right-click on any area on the right hand side of the address bar
- Click on the "Menu Bar" to show the menu bar in the Firefox

Show Tab Groups Icon on the Firefox Toolbar:
- Right-click on any area on the right hand side of the address bar
- Click on the "Customize..."
- Drag and drop "Tab Groups" icon from the "Additional Tools and Features" main frame to the left hand side of the "Open menu (with three horizontal bars)" toolbar
- The keyboard shortcut to open the tab groups is "Ctrl+Shift+E"

Copy and Paste using Mouse

- Highlight any text to copy. To highlight any text, left mouse click, drag and release the click.
- Click the middle mouse button to paste.

Friday

Linux Mint: How to remove an application from the Start Menu ?

- Click on the Start Menu
- Point to highlight any application you want it to be removed from the menu. For example, 3D Chess.
- Right-click on it and select "Uninstall".
- Remove 3dchess? Click the button "Remove" and the application will be uninstalled.

Wednesday

Where to get Desktop Operating System that comes with start menu, taskbar, a bottom panel and system tray?

Get the Linux Mint Long Term Support (LTS) release at https://www.linuxmint.com/download.php. Choose the latest one.

Desktop Operating System that comes with start menu, taskbar (bottom panel) and system tray make the keyboard and mouse users to be much more productive.

Thursday

LibreOffice Writer: Make the odt file size smaller: Export it as PDF

- Open an odt LibreOffice Writer odt file
- Menu > File > Export as PDF
- Click on General tab
- Under Images, tick “Reduce image resolution” checkbox and set it to 150 DPI
- Under General, tick only one checkbox which is the “Export bookmarks”. The rest of the checkboxes should not be ticked
- Click on the Export button
- Done

Linux Mint Mate: How to install CodeBlocks as C++ IDE by pointing and clicking?

- Start Menu > Software Manager. You may press the "Ctrl + LinuxWindow" on the keyboard to open the start menu
- Search for codeblocks
- Double-click on the codeblocks from the search results frame
- Click on the button Install
- From the start menu, right-click on CodeBlocks under Programming sub-menu and select "Add to desktop"
- Run CodeBlocks application
- Open any C++ file
- Highlight, right-click on the highlighted area and then select "Format this file (AStyle)"

Tuesday

Google Document: How to set page orientation from Portrait to Landscape mode?

Menu > File > Page setup > Landscape under Orientation section 

Google Internet Apps:
Google Document
Google Presentation
Google Spreadsheet
Google Form
Google Drawing
Connect more apps

Sunday

Firefox: Manual Update

Steps are:
- Go to menu, click on Tools > Options > Advanced icon > Update tab
- Firefox updates: Never check for updates radio button
- Click OK button to close the Options frame
- To test, go to menu, click on Help > About Firefox. Then, click the button "Check for Updates"

Tuesday

Firefox: How do we save a web page as one single file?

+ Click on “Add to Firefox” button to install the add-on. 
+ Restart the browser.
+ Visit any web page.
+ Click on Menu > File > Save Page As. 
+ Give a file name. 
+ Save as type: Web Archive, MAFF (*.maff).
+ Click on Save button.
+ Menu > Tools > Add-ons > Mozilla Archive Format > Options.
+ Select Interface tab.
+ Untick the checkbox beside the "Tab bar context menu".
+ Press OK button.
+ Done for now.

Wish List:
Make maff file type as part of the Firefox's installation.

Saturday

How to code your own function in R programming language?

Advantage of a function

To automate certain tasks that you have to repeat over and over

Syntax

<object name> = function(<set of parameters>) {
    <set of R statements>
}


Examples

# Firstly, check the new function name
# so that this name is not the built-in functions in R
> getBasicStats
Error: object 'getBasicStats' not found

> getBasicStats = function(x) {
    stats = list()
    stats$length = length(x)  #$ used to reference an item
                              #in the list by its key name
    stats$mean = mean(x)
    stats$sd = sd(x)
    stats$median = median(x)
    unlist(stats)  #show stats as a horizontal vector
                   #instead of as a vertical list
}

> getBasicStats(c(1,2,3,4,5))
  length     mean       sd   median
5.000000 3.000000 1.581139 3.000000


/* */

Formula for the Parametric Representation of a Straight Line

Parametric representation of a straight line is also known as "convex combination of two points". Geometrically, the convex combination of two points means that a point is on the straight line between the two points.

Given three points p1=(x1,y1), p2=(x2,y2) and p3=(x3,y3),
p3 is a point between the straight line between p1 and p2 iff ∃t where 0<=t<=1 such that:

(i) x3=(t)x1+(1−t)x2
(ii) y3=(t)y1+(1−t)y2

Formula / Equation:

The point p3 equation is written as:

(iii) p3=(t)p1+(1−t)p2 iff ∃t where 0<=t<=1.

Visually:

                    t=0.3
   |--------------|------|
   x1             x3     x2


Examples:
 
Let x1=0 and x2=10.
Use formula (i).

When t=0.3,
then x3=(0.3)0+(0.7)10=7.

When t=0,
then x3=(0)0+(1)10=10.

When t=1,
then x3=(1)0+(0)10=0.

Therefore, you can see that the points p3 with 0<=t<=1 make up the straight line segment between the two given points p1 and p2.

Equivalent formula:
The point p3 formula (iii) p3=(t)p1+(1−t)p2 can also be written as:
(iv) p3=p2+t(p1−p2)
Perhaps, you recognize this as the parametric equation of a straight line through a point p2 with the direction vector (p1−p2) with t as the parameter.

Notes:
Analytical Proof = textually, consisting of words or text.
Geometric Proof = visually, consisting of figures or visuals.

If a hater attacked your age and not the goodness of you

Whether young or old, I've always been known what endures. I've known the very idea of people that were all created equal and deserv...