This works on Mac.

First install Python 2 and Python 3 in your computer. Then, install virtualenv and virtualenvwrapper so that each django project that we create will have different environment from each other, e.g. python version.

Then, make a virtual environment with your desired python version. Use workon and deactivate to work on and deactivate the virtual environment. Now, we want to work on virtual environment. Deactivate the virtual environment after finishing the tutorial.

If you want to use PostgreSQL instead of the default SQLite, install Postico and Postgres app.

Run the following to install Django:

Run the following to start a Django project:

Run the following to run the Django project:

and hopefully you can see the url from your command prompt, paste it in your browser and you will see the default Django page.

Routing means when a person enters the URL of your website, be it http://localhost:8000/blog, http://localhost:8000/faq, how will Laravel handle what happens next, which page to show?

For Laravel 5.3, the documentation on routing is here.

By default, when you run php artisan serve for the first time, Laravel will show you the default Laravel page at http://localhost:8000.

Laravel 5.3 default welcome page

Laravel 5.3 default welcome page

The way Laravel works to show you this page is go to /routes/web.php.

You will see

The / means that when you are at the root url http://localhost:8000/, laravel will return view named welcome. Where is this view stored? Go to /resources/views/welcome.blade.php. Feel free to edit this file to whatever you want, like changing the background color.

So the web.php file in routes folder will match your url, and present the view located at resources/views folder.

The blade.php of the views file shows that Laravel is using Laravel blade templating system. It lets you insert variable from your routing/ controller to view, etc, which we will delve into later.

Disclaimer: For this journey, I am using Windows.

According to the documentation, you have to download Composer first.

Then run composer global require "laravel/installer" from your command prompt to download laravel.

Also press the start button to search for PATH, choose Edit environment variable with your path. Go to the PATH and edit, add ;C:\Users\Shaun Ling\AppData\Roaming\Composer\vendor\bin, replace Shaun Ling with your computer name. This will let you use laravel command.

Then, go to the folder you want to install your laravel project in. Then type laravel new blog in your command prompt. This will create a laravel project named blog. This will install the latest version of laravel.

Some host does not have high enough version of PHP, so it cannot run the latest Laravel.
So, instead of laravel new blog, you can composer create-project laravel/laravel=5.2 your-project-name --prefer-dist, replace the 5.2 with the version of laravel you want and your-project-name to your project name.

Then, cd into your directory, and run php artisan serve. You can now access your development website at http://localhost:8000.

On 18 June 2016, I participated in the 11th National Mathematics Competition at UTAR Sungai Long Campus organized by Universiti Tunku Abdul Rahman (UTAR).

There were many students from different universities joining the competition, totalling 300 students. There were students from National University of Singapore, UTAR, USM, MRSM, Sunway, etc.

Competition categories

There were 3 categories, A, B, and C. I joined category A and B (individual categories), so I had no idea what category C is about, I only know it is a team based category.

For category A and B, participants are separated and guided to their own computer labs.

Category A consists of 20 questions from topics such as discrete mathematics, probability and statistics, linear algebra, algebra and number theory, and calculus. The participants are given 30 minutes to answer them, 1 mark for one correct answer, and -1 mark for one wrong answer.

Category B consists of 100 questions. The participants are given 30 minutes to answer them, 1 mark for one correct answer, and -1 mark for one wrong answer. The questions are simple arithmetic question requiring only +, -, *, and /. Example: 6783 – 8939 * 9102. You can win the Superman Trophy if you answered all 100 questions correctly.

Category C, I had no idea. But, I know from talking to one guy from Sunway that the organizer can choose team mates for you if you cannot find 2 people to join you during registration. I could have opted for that! Argh.

Category A – analysis of some questions (the ones I remember)

  1. Find all non isomorphic 5 vertex tree (connected with no cycle)
    Answer: http://math.stackexchange.com/questions/537295/how-to-find-non-isomorphic-trees
    Comment: I learnt this in discrete structure subject. Learn what is graph, isomorphism, isomorphism.
  2. You are to catch some flies, there are a delay before catching each fly, catching a fly happens at an instant. The delay to catch the first fly is 1 second. The delay to catch the 2m-th fly is the same as that of m-th fly. The delay to catch the 2m-th fly is less than 1 compared to that of 2m + 1-th fly. How long does it take to catch the 98th fly?
  3. Sum to infinity k^2/k!
  4. Two circles r inner radius, 1 outer radius, another circle o tangent to this circle, find ratio of both area as r approaching 1-

The book is Kurose’s Computer Networking: A Top-Down Approach. This book introduces the internet based on the layers of internet, namely application layer, transport layer, network layer, link layer, physical layer, one chapter for each layer, and also a wireless and mobility chapter because the world is going wireless and mobile.

There are PowerPoint notes prepared by Kurose based on the book available online.

If you are preparing for quiz or exams, it is good to google quiz and exam questions online. This will help you tackle questions more practically.

Quiz/ Exam questions:

Before we understand Dijkstra algorithm, let’s introduce the concept of graph. A graph consists of vertices and edges connecting them. A graph has many applications because it mimics the connection between nodes/ vertices in network, social media, map with buildings as nodes and roads as edges connecting them, etc.

Dijkstra algorithm is an algorithm to find the shortest path from a source vertex to a destination vertex in a graph. For example, the graph may be a map. This is useful because a person may want to drive from home to school using the shortest path possible.

Each edge/ “road” is given a value, this is the path cost or the cost to travel this particular road. The shortest path will have the lowest sum of path costs of the edges it travelled.

There may be variations for the implementation of Dijkstra algorithm. For any implementations, each vertex will have a current cost which is continually updated until it reaches the minimum.

Implementation

To start, we have two sets, S, and N. S contains the vertices that have been processed and N contains the vertices that have not. Initially, S is {} and N is {a, v1, v2, v3, v4, v5, v6, z}.

In Iteration 0, set the current cost of the source vertex as 0 and the current cost of the rest of vertices to a very big value, that is, infinity.

Note: Keep track of current cost of all vertices as we will update the current cost of certain vertices of all vertices during each iteration. For now, after iteration 0, one vertex has 0 as current cost and the rest has infinity as current cost.

In Iteration 1, select the vertex from N that has the lowest current cost and move to S. Then, we will update the current cost of neighbours of the vertex we chose. The new currenct cost of the neighbours will be updated by adding the currenct cost of the vertex we chose, and the path cost from the vertex chosen and the neighbour itself.

Note: We only update the current cost of neighbour to new currenct cost if it is lower than its current cost. Example, we chose v4, v5 is one of the neighbours of v4, the current cost of v5 is 15, the updated current cost of v5 is the current cost of v4 plus the path cost from v4 to v5, 12 + 6 = 18. Since 18 is more than 15, we don’t update the current cost of v5 to 18.

Note: When choosing a vertex from N that has the lowest current cost, sometimes there are two or more vertices with the same currenct cost in N, choose whichever one will do.

Subsequent iterations are the same as Iteration 1.

We continue the iterations until the destination vertex is moved to set S. The current cost of the destination vertex is the shortest distance from source vertex to destination vertex.

Example implementation: https://gist.github.com/shaunlgs/861276b2ff0ba49dc0eb1f3cf10accd0

Note: The graph information is stored in a matrix where the row and column are the vertex and the value is the path cost. Example, row 1 (The row are indexed from 0, so row 1 is actually the second row) and column 3, this means from v1 to v3, the path cost is 8.

Today I learnt 1 new idea and refreshed my mind about 1 idea that I knew . I got this knowledge from Wikipedia.

Triangle

If you want to know if a triangle is possible based on its three lengths, you can do this. Take any two sides, add it up, it must be more than or equals to the third side. The case where it is equal to the third side is called a degenerate triangle, it has zero area, but its still a triangle nonetheless.

Bubble sort

Bubble sort, go through an array, if the value of the element is greater than the value of the next element, swap them. Keep going through the array multiple times, until you can go through the array without swapping any elements. This is called bubble sort because it is like bubble, the big numbers floats up to the top.

If you are given a list of X and Y values, that are the coordinates of points on a graph. How do you find a single straight line that fits the points such that the straight line is the best match for the points?

We will make use of two equations:

    \[ \frac{ f - \bar{y}}{s_y} = r_{xy} \frac{ x - \bar{x}}{s_x} \]

and

    \[r_{xy} = \frac{ \overline{xy} - \bar{x}\bar{y} }{ \sqrt{ \left(\overline{x^2} - \bar{x}^2\right)\left(\overline{y^2} - \bar{y}^2\right)} }\]

where
\bar{x} is the average of x values of all coordinates,
\bar{y} is the average of y values of all coordinates,
s_x is the standard deviation of y values of all coordinates,
s_y is the standard deviation of y values of all coordinates,
r_{xy} can be found using the second equation.

Rearranging the first equation, we get

    \[f = \frac{s_y\times r_{xy}}{s_x}x - \frac{s_y\times r_{xy}\times\bar{x}}{s_x} + \bar{y}\]

This is the equation of the linear regression. f and x are variable, and we are finding the gradient, K and intercept, B which are \frac{s_y\times r_{xy}}{s_x} and - \frac{s_y\times r_{xy}\times\bar{x}}{s_x} + \bar{y} respectively.

Reference: https://en.wikipedia.org/wiki/Simple_linear_regression

Sometimes you are at some place and you want to tag the place as your status update, but found that the place does not exist yet in Facebook, you can follow the steps below to add new location to Facebook:

Note: Adding new location to Facebook can only be done through mobile.

Step 1: At your news feed, click on status.

fb_add_location_1

Step 2: Click check in.

fb_add_location_2

Step 3: Type in your new location name e.g. Shaun tower.

fb_add_location_3

Step 4: Click on “Add a new place”.

 

fb_add_location_4

Step 5: Choose a category for your new location.

fb_add_location_5

Step 6: Fill in the information (different information depending on the category you chose).

That’s all!