The Last Night At Stony Brook

It’s my last night at Stony Brook, and possibly the last night as a student. So thoughtful and thoughtless~!

4 ways to redirect URL




Doing URL Redirection is quite common in web development. There are 4 different approaches for URL redirection.


1) Meta Refresh

The meta refresh is a pure HTML way of redirecting URL, it can be inserted in the head element of the HTML document. In the following example, “0″ is the number of seconds before redirecting url.

<meta http-equiv="refresh" content="0;url=http://flmyshe.tk/" />


2)Server Side Redirect

This approach use server side language to perform the redirect on the server. Typically this is done in PHP or Servlet.

<?php
	header("Location: http://flmyshe.tk/");
?>
String url = "http://flmyshe.tk/";
response.sendRedirect(response.encodeRedirectURL(url));


3)Client Side Redirect

This is done with javascript.

<html>
    <head>
        <title>Javascript URL Redirect</title>
        <script type="text/javascript">
             function redr(){
                  window.location = "http://flmyshe.tk/";
             }
        </script>
    </head>
    <body onload="setTimeout('redr()','1000')">
         <-- Display custom HTML Redirect message here -->
    </body>
</html>


4)301 Redirect

This approach uses the .htaccess file to perform the URL redirect. It’s also the preferred way of doing URL redirect.

#redirecting the whole website to another website
#Syntax: Redirect 301 [root directory] [website being redirected to]
Redirect 301 / http://flmyshe.tk/

Either approach has its advantages and drawbacks. Meta refresh is the simplest way but it lacks of flexibility. The javascript approach is not recommended since some browsers may disable javascript. Server Side redirect is simple but yet flexible. 301 redirect is the most powerful way of doing URL redirect. It’s very flexible. However, it requires you to have Apache server running and you must have sufficient permission to modify .htaccess.

Switching to 000webhost

After experiencing 90% downtime with my old web host – Adwardspace, I decided to switch to a new domain – 000webhost . Adwardspace has been giving me hard time. In the first couple weeks, the uptime is still good, then the blog start experiencing downtime. The homepage is down for 95% of the time. Although some other pages are still accessible, it’s just intolerable. This is due to the fact that they limit the functionalities of PHP 5. I totally understand why they want to limit certain PHP functions, like fopen(). However, 000webhost offers full php support, which is a major plus for building wordpress blog. Now I can use plugins that were not supported by Adwardspace. Another thing to mention is that, after switching, the blog is no longer blocked by GFW.

MyISAM vs InnoDB

There are many different storage engines in MySQL, but the most frequently used engines are MyISAM, InnoDB.

MyISAM - The default engine in MySQL. It’s not transaction safe, but it requires less disk space, less memory, and runs faster than InnoDB. It’s appropriate for tables with frequent look-ups.

InnoDB – It’s transaction safe, providing ACID for the database. InnoDB supports foreign key constraint while MyISAM does not. It supports commit and rollback features. It promises the integrity of the database. It’s considered to be slowed than MyISAM due to the overhead of transaction. However, it’s recommended to use InnoDB for transaction critical application, such as financial transactions.

Transaction Safe

Transaction Safe == “All or Nothing”
When conducting a transaction, we want nothing to be changed if the transaction fails. In the case the transaction fails, MyISAM will just simply changes the database/tables according to the queries executed prior to the point when the transaction fails, therefore the state of the database/tables has changed as of before the transaction begin. This might mess up the database.

Consider the following situation: (A transfer $100 to B)
1) $100 is deducted from A
2) $100 is added to B
3) Log the transaction

If at step 2, the transaction fails. Then $100 from A just disappears. Therefore, in this case, we need to rollback to the state before the transaction, and we need Innodb.

Modeling 3D airjet with Carrara

1.In the Assemble Room, create a vertex object

2.Map the front, top, and side view of the plane.

3.Use the polyline tool to trace the plane

4.Rearrange the polylines so that they sketch out the shape of a plane


5.Use the ruled surface to draw the plane body.


6.Use the polyline tool to model the wing and attach the wing to the plane body.


7. Using the same procedure for modeling a wing, model the fins and also attach them to the plane body.

8.Now we have half of the plane, duplicate it with symmetry.


9. Use the welding tool to weld the vertices together.


10.Now we have the prototype of the plane. Then we create the windshield using the polyline tool and the rule surface tool.


11.Define the shader domain for different part of the plane. Using texture mapping for the wings.

12.Using the polyline tool to draw a circle and then use the Lathe tool to make it into a wheel. Then position the wheels.

13.Now we need to model the propeller as a separate vertex object. In the Assemble Room, insert another vertex object then insert a Cone and change the object definition to 4. Scale the object so it looks like the following.

Use the Dynamic Exclusion Tool to model the blades

Scale the blades and rotate them to a certain angle. Then set the subdivision of the whole object to smooth(Modeling: level 2, Rendering: level 1). The following picture shows the effect.


14.Go back to the Assemble Room, scale and duplicate the propeller. Position these two propeller to the proper place with respect to the plane. Set the propeller objects as the plane’s children.


15. Final plane model.