Monthly Archives: August 2013

eCommerce via WordPress

Here is what you need to do for eCommerce using WordPress.

  1. Install WordPress with MAMP locally for your experimental web site
  2. How to use WordPress
  3. Choose theme
  4. Install plugins (wooCommerce)
  5. Membership considerations
  6. Setup ssl and test the purchase
  7. Multi-langual considerations
  8. Subscribe to Web Hosting
  9. Move your experimental site to online web hosting (set SSL)
Install WordPress with MAMP locally for your experimental web site

Why I suggest you to install it locally ?  Why not simply find a web hosting, subscribe to it and start the site building right away ?

Because:

  1. You don’t need to expose your web site before you have completed the construction.
  2. Lower your starting cost.  Sooner you subscribe to online services implies earlier you start to pay.  It takes some  time for you to build the web site, especially if you are beginner for site building.  While you are still developing your web site, your web store is not functioning and does not make income for you.  It would be better if you can save money in this stage.
  3. Developing locally is more efficient, you are not suffering from the internet bandwidth, nor any storage limit (local storage is usually cheaper than web hosting storage, though most web hosting allows you to have 100GB+ storage).  You can act on the files directly.  On the other side, web hosting company normally request you to operate your site files by control panel via web browser.  That is not as convenient as if you operate directly in your computer.
  4. Another efficient example.  If you want to make huge modification to your site, say, you want to import some demo data for a particular theme.  You can start with a folder as your first web site directory (see Install WordPress locally in Your Mac With MAMP for details), then simply duplicate the whole folder, and set the MAMP Preferences to use the new folder in the Apache.  You can now import demo data to one site, and can even switch between the two sites to compare them.
Install wooCommerce plugins

wooCommerce is a free plugin for creating eCommerce web site.  Trouble with wooCommerce is: the documentation and available help is poor.

Open a topic for Machine Learning and Technical Analysis

In early 2013, I made a proposal to HKUSPACE as well as School of Continuing & Professional Studies, The Chinese University of Hong Kong.  The proposal is about opening a General Short Course for the about topic.

Machine learning (an topic in AI) is an interesting subject and find its application in modern live. Many web site, google, facebook, amazon, … uses the technology to entertain their customer as well as to make their advertisement more effective.

The ML is not rocket science and can be understood by general public with high school education. On the other side, the maths and model behind it may threaten most population. Further, learning something without solid example makes the student feels boring and lost the initiative.

Technical Analysis for finance forecasting is an interesting subject to many people. They have a lot of doubts about the feasibility of it. This course will use Technical Analysis as an subject to attract the audience to learn ML and use the technique to verify if Technical Analysis works or not.

The objective of the course is to teach the general concept as well as the practical use of the ML in data analysis.

The course is actually a 2 courses in 1. In every lecture, the first part will talk a topics in TA, and teach the student how to verify if a TA works or not. The second part of each lecture will be a topic in ML. Gradually, the student will discover the ML is very useful for them to understand / interpret TA.

Unfortunately, there is no any response from both parties.  I thought of to book classroom to carry out such course on my own, but it involves a lot cost and advertisement.  Also quite difficult to book the lecture hall in government facility.  Finally, I decided to take a more relax approach, I write them in a blog.

Lect Part I Part II
1 Introduction ML Problem Statement
2 Tools for backtest The Linear Model
3 Backtest moving average, AMA Error and Noise, Overfitting
4 Backtest RSI and oscillators Training versus Testing
5 Backtest Momentum Theory of Generalization
6 Backtest MACD The VC Dimension
7 Backtest OBV Bias-Variance Tradeoff
8 Stochastic oscillator Neural Networks
9 Candle sticks patterns Regularization
10 Martingale strategy Validation
11 Elliott wave principle Support Vector Machines
12 Data snooping, look-ahead bias Kernel Methods, RBF
13 Traps in ML

Theme comment: Customizr

Customizr

  • is a responsive theme
  • you can select from 8 different colors (blue, green, yellow, orange, red, purple, grey, black)

First impression, the theme looks quite good.  To me, it has following disadvantage:

  • if a menu has submenu, then this menu page will not be displayed
  • does not declare WooCommerce support

Display php code in WordPress posts

In developer’s blog, you sometimes need to display program code. For most programming language, its easy, you simply enclose your code in the pre tags. But its troublesome for php codes, even if you follow WP’s procedure to change all the greater and less sign to html code. It still crashed. The trick is, you should do all your editing under the Text pane instead of the Visual pane in the editor. If you accidentally clicked the Visual pane, you need to click back to Text pane and leave the page by giving up you latest changes; otherwise, if you save your work, everything is going to be messed up.

Other tricks includes

  • You can use plugin to highlight the code.  The pre tag actually results in not nice looking outcome.  I use the FV Code Highlighter.
  • If you use vi editor to convert your php code to html text, you can run the following two lines to search and replace all the greater and less symbols.
    :%s/>/\>/g
    :%s/</\&lt;/g

Add summary of all posts

If u want to add a summary page for all posts rather than the typical Archives Page.  Follow the steps in Add an Archive page but use following text as the php code:

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
29
30
31
32
33
34
35
36
37
<?php
/*
Template Name: TOC
*/
get_header(); ?>

<?php
//for each category, show all posts
$cat_args=array(
  'orderby' => 'name',
  'order' => 'ASC'
   );
$categories=get_categories($cat_args);
  foreach($categories as $category) {
    $args=array(
      'showposts' => -1,
      'category__in' => array($category->term_id),
      'caller_get_posts'=>1
    );
    $posts=get_posts($args);
      if ($posts) {
        echo '<p><h3>Category: <a href="' . get_category_link(
$category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ),
$category->name ) . '" ' . '>' . $category->name.'</a> </h3></p> ';
        foreach($posts as $post) {
          setup_postdata($post); ?>
          <a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title();
?></a><br>
          <?php
        } // foreach($posts
      } // if ($posts
    } // foreach($categories
?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Then the output will looks like this:

130829x

Further References:

How To List All WordPress Posts From A Category On One Page Or Post

Install WordPress locally in Your Mac With MAMP

If you’re a website designer, developer or blogger, the ability to test websites locally can be remarkably useful. It could serve as a testing environment before uploading a new page to your website, or provide a way to work on a website project without an internet connection.

Although OS X comes bundled with a basic web server installed, a more user-friendly solution is available in the form of MAMP. Following tells you how to set up a local server with MAMP.

Pick a directory where you want to put the root of the local web server.  E.g., /Volumes/Public/project/MAMP/

130901m

Download WordPress from here into the above directory.  Unzipped the WordPress download if necessary.  The unzipped folder name should be wordpress.  Change the name to what you want.  In this example, I will use the name myDemo2.  I suggest you not to use wording like “wordpress” as your subdirectory and database name, as this is too common throughout the wordpress files, which can lead to trouble when you need to do some ad hoc customisation later.

Therefore, in our example, I will have the directory /Volumes/Public/project/MAMP/wordpress after download and unzip, and renamed it as /Volumes/Public/project/MAMP/myDemo2

Size of the unzipped WordPress (version 3.6) is around 15MB.

Install the MAMP.  You can download it from the MAMP website. MAMP requires that your Mac be running Mac OS X 10.6.6 or later.  The installation is like a typical Mac software.

Run the MAMP.  Click on the “Preferences…” button.

130827o

Click on the Apache, set the document root path as said earlier, click OK.

130901u

The server should restart.  If not click “Start Servers”.  The MAMP start page should open in your default web browser. If not, click on “Open start page” in the MAMP window. Once that’s open, click phpMyAdmin tag from the webpage.  The click Databases tag under this sub frame.  Create the database with name such as “myDemo2″ in our example.

130901t

Point your web browser to localhost:8888/myDemo2 and you will see an error page:

130901v

Click “Create a Configuration File”.  A page shows you some information. Click “Let’s go!”.  Then you need to fill in some information.

130901w

If you are going to run single WordPress installations (if you are a novice, I assume you will run single), and you created the database named “myDemo2″, you only need to change the 1st, 2nd and the 3rd field.  Such name and password are used because that is the typical setup by MAMP.  If you know what that mean and how to change, you sure will go ahead.  This presentation is just to make simple for new user, it doesn’t mean I am using a good practice.  Then click “Run the install”.

You will be prompted to input your site title, username, password and email.  If you did not enter a password, note the password given to you. If you did not provide a username, it will be admin.  Don’t worry, you can always change these settings later.  Click “Submit”. Click “Install WordPress” in next page.

The installer should then send you to the login page. Sign in with the username and password you chose during the installation. After login, you can always click on “Profile” to change the password.

Congratulations !  Your WordPress local site is installed, you can start to use it !

Change size of editor missing in WP 3.5 ?

There are enquiry in the internet about this problem.  Not sure if that is a bug since WP 3.5 or conflict with plugin.

130826r2

If you are using WP 3.5 or 3.6, qtranslate plugin installed,  and have same problem.  The following change work for me.

From Dashboard, choose Plugins -> Editor.  Select the file qtranslate/qtranslate_hooks.php and change the line as shown:

130826v

Here, I added the “height:600px” into the line.

How to add border to an image

For example, if you want to add a border for following image:

130826y

After you inserted the image via “Add Media”, select it, then you will see two little icons at the top left corner:

130826t

Click on the left one, and you will see a pop up diaglog:

130826u

Click the “Advanced Settings” tag, and fill in the width of border you like (this example use 5). Click update, and Publish or Update your post.

130826y

That’s it !

Following instruction tells how to set different colour for the frame.  First, you need to modify the style.css file, add the following line:

.frame { border: 5px solid #cc9900; padding: 10px; }

Then, in the dialog box, do not choose border; instead, add the word “frame” into the CSS Class:

130826m

Then you will have:

130826y

You can change the #CC9900 in the style.css to other value for different colour.

Quick reference for the colour code.