Sunday, October 30, 2011

Creating your own Screen Saver is as easy as ABC

Are you getting bored with the default screen savers that comes with your personal computers? Have you heard of an interactive screen saver before? Or a screen saver that works is a game like snake, pac-man, etc? Or ever had a dream of creating or customizing a screen saver yourself? This seems to be a dream but you can now have your dreams fulfilled by using...


The above logo was taken from the website of Screentime Media.
Screentime Media.

So why do are my reasons for recommending Screentime Media?
  • Supports OS like Windows and Mac
  • Gives you an option of creating a screensaver that can only be closed either by a mouse movement or a keyboard input
  • Allows the screensaver to detects for the existence of an internet connection
  • Customizable installation settings like preview window, installer window, settings window, etc
  • and much much more...

* Click here for the website of Screentime Media.

Saturday, October 22, 2011

An exciting new Android phone which is a the collaboration between Google and Samsung

Ever since the 'Nexus One' phone that was released close to 2 years ago, this was the first time I was so excited about a new phone. The name of the phone would be ...


(Image taken from the Official website of Nexus Galaxy.)
the 'Nexus Galaxy' phone from Google and Samsung.

One would ask what makes the phone so exciting?
Well, this is because...
  • Looking at how good 'Nexus One' was back then, I don't see why one could resist Nexus Galaxy
  • 'Nexus One' comes with pure Android UI, which is a plus and you don't need to spend time playing with the UI that Samsung had created.
  • First priority in getting all the latest Android version
  • Conclusion... this is definitely a Geek's best friend

* Click here to access the website of 'Galaxy Nexus'.
^ Click here to access the website of 'Nexus One'.

Simple PHP demo for file uploading

Uploading of files can be very useful from time to time. This time round, I am going to show you how to upload a file into the server using PHP.

This demo will start from a simple html file.
<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" /> 
<br />
<input type="submit" name="submit" value="Submit" />
</form>

</body>
</html>

And a simple PHP file that will handle all the uploading...
<?php

//Maximum filesize that can be uploaded through this file
$filesize = 1000;
//The folder that all the uploads will be place in
$folderName = "uploads/";

// detect slash/backslash nomenclature dirname
$path = dirname( __FILE__ );
$slash = '/'; strpos( $path, $slash ) ? '' : $slash = '\\';
define( 'BASE_DIR', $path . "/" );
$dirPath = BASE_DIR . $folderName;   // folder path
//If the filesize of the file is smaller than the maximum filesize
if ($_FILES["file"]["size"] < $filesize)
{
 //If there is an error
 if ($_FILES["file"]["error"] > 0)
 {
  echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
 }else{
  //Display more info about the uploaded file
  echo "Upload: " . $_FILES["file"]["name"] . "<br />";
  echo "Type: " . $_FILES["file"]["type"] . "<br />";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
  echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
  //If the folder hasn't been created yet, create it now
  if(!is_dir($dirPath))
   mkdir($dirPath,0777);
  //If the file already exist
  if (file_exists($dirPath . $_FILES["file"]["name"]))
  {
   echo $_FILES["file"]["name"]." file exist". "<br />";
  }else{
   //Copy the uploaded file into the specified folder
   move_uploaded_file($_FILES["file"]["tmp_name"],
   $dirPath . $_FILES["file"]["name"]);
   echo "Stored in: " . $dirPath . $_FILES["file"]["name"]. "<br />";
  }
  echo "The URL of the file would be:<a href='";
  echo removeFileName(). $folderName . $_FILES["file"]["name"]."'>here</a>";
 }
}else{
 echo "Invalid file";
}

//Function to get the url of the current page
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":";
  $pageURL .= $_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

//Function to get the url of the current page and remove the filename of this page
function removeFileName(){
 $pageURL = curPageURL();
 $pieces = explode("/", $pageURL);
 $piecesLength = count($pieces);
 $pageURL = "";
 for ( $counter = 0; $counter < ($piecesLength - 1); $counter ++) {
  $pageURL = $pageURL. $pieces[$counter]."/";
 }
 return $pageURL;
}
?>
... okay the file isn't so easy after all...

Some additional Notes:
  • Remember to set the write permission into the folder that you have placed the php files
  • My example currently only allows files that are lesser than 1000 bytes, but you can change the maximum file size by increasing it in the php file.


* Click here to view the demo of this example:
^ Click here for the source files of this demo.

Saturday, October 15, 2011

A paradise for Geeks?

Sim Lim Square would probably be the best place to source for all the computer parts and accessories that a Geek would need. Besides for all the computer related products, they also have 3 levels of shops selling all sorts of electronic products ranging from tv to music/video players to cameras, you can find all these electronics products in one building. Isn't that convenient?

Pictures of Sim Lim Square.


Some info:
  • Try to ask around for the price of the same product first before making an purchase
  • Try not to go there as an individual (Chances that you get con can be pretty high, unless you know the shop owners pretty well)
  • Sometimes, Cash payment can help you to get more discounts

* Click here for the website of 'Sim Lim Square'.
^ Click here for the location of 'Sim Lim Square'.

Friday, October 14, 2011

Playing with LinkList (2)

I had introduced the use of LinkList in my previous post. So what can you do with a LinkList? And how can it help you?

Let us take a look at a simple example.
If you are staying in a house with many rooms and each room have a few cupboards or shelves fully occupied with books, you probably will have a list like the following.
Click here for the list.

I have created a simple flex application to sort all the data in a orderly manner.
Buy let us take a look at some parts of the codes first.

On top of the CustomLinkList class that I had introduced in the previous post, I had build a room class on top of the CustomLinkList class.
package List
{
 public class RoomsList extends CustomLinkList
 {
  public function RoomsList()
  {
   super();
  }
  
  //Override the add Value function in the CustomLinkList class
  override public function addValue(tempValue:*):void{
   var newNode:Node = new RoomNode(tempValue);
   var baseNode:Node = head;
   var tempNode:Node;
   if(baseNode == null){
    head = newNode;
   }else{
    var hasCheck:Boolean = false;
    while(hasCheck == false){
     //While moving from one node to the next,
     //do a comparison between the nodes
     //and find the best place to place the new node
     if(compareRoomName(baseNode, newNode)){
      hasCheck = true;
      if(baseNode.prev == null){
       head = newNode;
      }
      tempNode = baseNode.prev;
      if(tempNode != null){
       tempNode.next = newNode;
      }
      newNode.prev = baseNode.prev;
      newNode.next = baseNode;
      baseNode.prev = newNode;
     }else{
      if(baseNode.next == null){
       baseNode.next = newNode;
       newNode.prev = baseNode;
       hasCheck = true;
      }else{
       baseNode = baseNode.next;
      }
     }
    }
   }
   count ++;
  }
  
  //Function to compare 2 node and if the new node that was pass into
  //this function had a smaller value, it will return true, else false 
  //We are going to sort the room by their room_name value
  public function compareRoomName(tempNode1:Node, tempNode2:Node):Boolean{
   var name1:String = String(tempNode1.value.room_name).toLowerCase();
   var name2:String = String(tempNode2.value.room_name).toLowerCase();
   var tempArray:Array = new Array();
   tempArray.push(name1);
   tempArray.push(name2);
   tempArray.sort();
   if(name2 == tempArray[0]){
    return true;
   }else{
    return false;
   }
   return false;
  }
 }
}

And a RoomNode class that builds on top of the Node class.
package List
{
 public class RoomNode extends Node
 {
  private var shelvesList:ShelvesList = new ShelvesList();
  //After passing in the value of this node for room,
  //Pass in all the relevant data for creating the 
  //respective shelves
  public function RoomNode(tempValue:*):void {
   // constructor code
   super(tempValue);
   for(var i:int = 0; i < this.value.shelfs.shelf.length(); i ++){
    shelvesList.addValue(this.value.shelfs.shelf[i]);
   }
  }
  
  public function get roomContents():ShelvesList{
   return shelvesList;
  }
 }
}
And this would be my main application class.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute"
    width="100%"
    height="100%"
     creationComplete="creationCompleteHandler(event)">
 <mx:Style>
  VBox{
   paddingTop:5;
   paddingBottom:5;
   paddingLeft:5;
   paddingRight:5;
  }
 </mx:Style>
 <mx:Script>
  <![CDATA[
   import List.*;
   
   import mx.events.FlexEvent;
   
   //Embed a xml file that contents data
   [Embed(source="xml/booksData.xml")]
   private var dataXml:Class;
   
   //Create a list for rooms
   private var tempRoomList:RoomsList = new RoomsList();
   
   protected function creationCompleteHandler(event:FlexEvent):void{
    var strOutput:String = "";
    var tempDataXML:XML = dataXml.data as XML;
    //Pass all the data into the list for rooms
    for(var i:int = 0; i < tempDataXML.room.length(); i ++){
     tempRoomList.addValue(tempDataXML.room[i]);
    }
    var roomObject:RoomNode;
    var shelfObject:ShelfNode;
    //Display all the contents in the list for rooms
    for(i = 0; i < tempRoomList.length(); i ++){
     roomObject = tempRoomList.getNodeAt(i);
     strOutput += "Room Name = " + 
      String(roomObject.value.room_name);
     strOutput += "\n";
     for(var j:int = 0; j < roomObject.roomContents.length(); j ++){
      shelfObject = roomObject.roomContents.getNodeAt(j);
      strOutput += "-> Shelf Name = " + 
       String(shelfObject.value.shelf_name);
      strOutput += "\n";
      for(var k:int = 0; k < shelfObject.shelfContents.length(); k ++){
       strOutput += "   -> Book Title = " + 
        String(shelfObject.shelfContents.getNodeAt(k).value.book_title);
       strOutput += ", Written By " + 
        String(shelfObject.shelfContents.getNodeAt(k).value.author);
       strOutput += "\n";
      }
     }
    }
    txtMessage.text = strOutput;
   }
   
  ]]>
 </mx:Script>
 <mx:VBox width="100%" height="100%">
  <mx:TextArea id="txtMessage" width="100%" height="100%"/>
 </mx:VBox> 
</mx:Application>
* Click here to view the demo in this post.
^ Click here for the source files of the demo
` Click here to follow the other post on LinkList.

Sunday, October 9, 2011

Playing with LinkList

In most of the older Programming language that I had used before or played before requires the developer to enter a value for the number of items that you are going to store in a Array. This can be quite a nuisance sometimes, but luckily there is something known as a Link List in the programming world. :D With the help of a Link List, it had definitely solved a lot of length issues in various Programming Language.

This is a simple example that I had created for Flex but the classes were also usable in Flash Professional Projects.
This is the source file for the main Application - LinkList.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" width="100%" height="100%"
    creationComplete="creationCompleteHandler(event)">
 <mx:Style>
  VBox{
   paddingTop:5;
   paddingBottom:5;
   paddingLeft:5;
   paddingRight:5;
  }
 </mx:Style>
 <mx:Script>
  <![CDATA[
   import List.*;
   
   import mx.events.FlexEvent;
   
   private var tempObject:Object = {x:100,y:100};
   private var dataArray:Array = new Array("Data",12345,3.14,tempObject);
   
   private var tempList:CustomLinkList = new CustomLinkList();
   
   protected function creationCompleteHandler(event:FlexEvent):void
   {
    var strOutput:String = "";
    //Adding values to the List
    for(var i:int = 0; i < dataArray.length; i ++)
    {
     tempList.addValue(dataArray[i]);
    }
    strOutput = "Show Contents of List";
    strOutput += "\nList has " + tempList.length() + " items.";
    strOutput += "\n";
    //Display the objects in the List
    for(i = 0; i < tempList.length(); i ++)
    {
     strOutput += String(tempList.getValueAt(i)) + " ";
    }
    strOutput += "\nRemove Item number 3";
    //Method to remove an object of a particular position
    strOutput += "\n" + String(tempList.removeValueAt(2)) +
     " have been removed.";
    strOutput += "\nShow Contents of List Again";
    strOutput += "\nList has " + tempList.length() + " items.";
    strOutput += "\n";
    //Display the objects in the List
    for(i = 0; i < tempList.length(); i ++)
    {
     strOutput += String(tempList.getValueAt(i)) + " ";
    }
    strOutput += "\nRemove All Items";
    while(tempList.length() != 0)
    {
     strOutput += "\n" + String(tempList.removeValueAt(0)) +
      " have been removed.";
    }
    strOutput += "\nShow Contents of List Again";
    strOutput += "\nList has " + tempList.length() + " items.";
    strOutput += "\n";
    for(i = 0; i < tempList.length(); i ++)
    {
     strOutput += String(tempList.getValueAt(i)) + " ";
    }
    txtMessage.text = strOutput;
   }
   
  ]]>
 </mx:Script>
 <mx:VBox width="100%" height="100%">
  <mx:TextArea id="txtMessage" width="100%" height="100%"/>
 </mx:VBox> 
</mx:Application>

This is a basic Link List class that I had written
package List{
 public class CustomLinkList {
  private var _head:Node;
  private var _count:int;
  public function CustomLinkList() {
   // constructor code
   head = null;
   count = 0;
  }
  
  //count = number of items Getters and Setters
  protected function get count():int
  {
   return _count;
  }

  protected function set count(value:int):void
  {
   _count = value;
  }

  //Start of the Node
  protected function get head():Node
  {
   return _head;
  }

  protected function set head(value:Node):void
  {
   _head = value;
  }

  //Creating and adding a new Node
  //And connect the 2 way Link List properly
  public function addValue(tempValue:*):void{
   var newNode:Node = new Node(tempValue);
   var currNode:Node = head;
   if(currNode == null){
    head = newNode;
   }else{
    while(currNode.next != null){
     currNode = currNode.next;
    }
    currNode.next = newNode;
    newNode.prev = currNode;
   }
   count ++;
  }
  
  //Removing a node and returning 
  //the value of the Node at the same time
  //And connect the 2 way Link List properly
  public function removeValueAt(tempInt:int):*
  {
   var i:int = 0;
   var currNode:Node = head;
   if(tempInt < count)
   {
    var nextNode:Node;
    var prevNode:Node;
    while(i != tempInt){
     currNode = currNode.next;
     i ++;
    }
    if(currNode)
    {
     nextNode = currNode.next;
     prevNode = currNode.prev;
     if(nextNode)
      nextNode.prev = prevNode;
     if(prevNode)
      prevNode.next = nextNode;
     if(currNode == head)
     {
      head = nextNode;
     }
    }
    if(count > 0)
     count --;
    return currNode.value;
   }else{
    return null;
   }
  }
  
  //Get the value of a Node of a particular position
  public function getValueAt(tempInt:int):*{
   var i:int = 0;
   var currNode:Node = head;
   if(tempInt < count)
   {
    while(i != tempInt){
     currNode = currNode.next;
     i ++;
    }
    return currNode.value;
   }else{
    return null;
   }
  }
  
  //Returns the length of the LinkList
  public function length():int{
   return count;
  }
 }
}
This is a simple Node class
package List{
 public class Node {
  protected var _value:* = null;
  protected var _next:Node;
  protected var _prev:Node;
  public function Node(tempValue:*) {
   // constructor code
   _value = tempValue;
   _next = null;
   _prev = null;
  }
  
  //Previous Node Getters and Setters
  public function get prev():Node
  {
   return _prev;
  }

  public function set prev(value:Node):void
  {
   _prev = value;
  }
  
  //Next Node Getters and Setters
  public function get next():Node
  {
   return _next;
  }

  public function set next(value:Node):void
  {
   _next = value;
  }
  
  //Previous Content of the Node
  public function set value(tempValue:*):void{
   _value = tempValue;
  }
  
  public function get value():*{
   return _value;
  }
 }
}
* Click here to view the demo in this post. ^ Click here for the source files of the demo

Sunday, October 2, 2011

One of Windows OS missing component - Partitioning Your Hard Disk

Being a Windows user for more than 10 years, I have encounter numerous situations where I have bought a PC or Laptop from a Vendor and there was only one partition in the System. As I have been using Windows XP since a few years ago, I would use 'Partition Magic' to solve all these partition issues. Especially when the default Windows Disk Management Utility was pretty slow and step intensive. (Especially, when a user was required to sit in front of the monitor to wait for the completion of one step before he can move on and select the next step...) As for Partition Magic, an user can create a series of task and let them run at one go. Isn't it useful?


But with the discontinuation of supplying the number of updates to 'Partition Magic' and the uprising of Windows Vista and Windows 7, an user cannot use 'Partition Magic' any more, which is kinda sad. :(

Although, its pretty sad that we cannot use 'Partition Magic' any more, there seems to be some other potential alternatives to 'Partition Magic'.
For Example:

Image taken from Arconis Website
Click the above image or here to access the website of Acronis Disk Manager.


Image taken from Aomei Website
Click the above image or here to access the website of Aomei Partition Assistant.

* Click here to find out more about 'Partition Magic'