Tuesday, April 29, 2014

Remove white and black backgrounds in photoshop

Today I have a fairly quick Photoshop tip on how to remove white or black backgrounds from images in Photoshop to create areas of transparency. There are several ways to do this, you could use the magic eraser, or just make a selection of the white or black background and then delete it, but I want to show you how to use a blending slider to do it. As well as the blending modes available in the Layers palette, you can play around with blending sliders in the Layer Style dialog box. Let’s get started.
1. Open an image in Photoshop with a predominantly white or black background.
2. Open the Layer Style dialog box by doing one of the following:
  • Click the little fx button at the bottom of the Layers panel and choose Blending Options.
  • Double-click its layer thumbnail in the Layers panel.
  • Choose Layer > Layer Style > Blending Options.
Note: The Blending sliders won’t work on a locked Background layer; you have to double-click the layer first to make it editable.

At the bottom of the resulting dialog box, you’ll see two pairs of sliders-one set for the This Layer bar and another for the Underlying Layer bar. Each of these sliders lets you make parts of your image transparent based on the brightness value of the pixels. The left slider represents the shadows (blacks) in your image and the right one represents the highlights (whites). If you want to change the background of the currently active layer, then tweak the This Layer slider.
3. If you want to hide a white background, drag the highlight slider (the one on the right) toward the middle until the white part is transparent.
As you drag, you’ll see the white areas of the image disappear and the checkerboard pattern (or underlying layer) will appear. Note that any white area will disappear so you need to be careful how far you drag.
Likewise, if the background of your currently active layer is black and the subject (or object in the foreground) is much brighter, you can hide the black part by dragging the shadow slider (the one on the left) toward the middle until the black part is transparent. Very easy and quick.
If you’re keen to learn more about Photoshop, you may find this recent article on getting started with Photoshop of great interest.


Sunday, April 27, 2014

What is the difference between functional and Non-functional requirements

For a software system, there are two kinds of requirements, i.e., Functional and Non-functional Requirements.
Functional Requirements: specify the functionality of the system.
Non-functional Requirements: specify the quality of the system,  is mostly related to the satisfiability of the user.
We use a simplistic Travel Agency Service (TAS) as an example to illustrate the concept. The workflow of the TBS is described as follows. When the request from the user is received, it invokes the other two services based on the request of the user. If the user prefers to Travel by Road, then the Car Booking Service (CBS) is invoked, otherwise if the user prefers to travel by flight, the Flight Booking Service (FBS) is invoked. Subsequently, Hotel Booking Service (HBS) is invoked for booking a hotel for the user, and then the result of the bookings are replied to the user.
In such scenario, the functional requirements of TAS could be:
1) When Travel By Road is chosen, then the CBS will always be invoked.
2) When Travel By Air is chosen, then the FBS will always be invoked.
3) HBS will only be invoked after either CBS or FBS is invoked.
4) HBS and FBS – exactly one of them would be invoked for each request.
etc.
The non-functional requirement of TAS would be
1) TAS responds to users within 3 seconds.
2) The availability of TAS is 99.999%.
etc.
As you can see non-functional is mostly related to the satisfiability of the user; therefore it is often an important clause in service-level agreements (SLAs), which is the contractual basis between service consumers and service providers on the expected Quality of Service (QoS) level.  For example, the SLAs of Amazon.com can be found here.
There are many other non-functional requirement attributes (e.g., Throughput, Latency Time), a more complete list could be found here: http://en.wikipedia.org/wiki/Non-functional_requirement.

Wednesday, April 23, 2014

wordpress - crayon syntax highlighter

<pre class="lang:java" title="something">
type your code here...
</pre>

Monday, April 21, 2014

Installation Guide for Internet Explorer VPC image on Virtual PC

Different versions of Internet Explorer (IE) have presented challenges for testing the Web application. In order to test on multiple browsers concurrently, Microsoft has kindly provided free downloadable disk images for IE 7, 8, 9, which could be run under their Virtual PC software, so that you could test all browsers under the virtual machine.

This post is a step-by-step guide on how to set up the VPC images for IE 7, 8, 9. In particular, the following versions of IE are available in Windows virtual machines.
  • IE7 in Windows Vista – The install files for IE8 and IE9 are also available for install in this virtual machine.
  • IE8 in Windows 7 with install files for IE9 – The install files for IE9 are also available for install in this virtual machine.
  • IE9 in Windows 7

Step by Step Installation Guide:


Prerequisite:
1. Download Virtual PC here.
2. Download VPC images here.

Steps:

To install Virtual PC, double-click on the .msu file you downloaded.


 A confirmation dialog box displays. Click Yes to install the update.



Read through the license terms and click I Accept to continue with the installation.


The progress of the installation displays.


When the installation of the update is finished, the following dialog box displays. To restart your PC immediately, click Restart Now. If you want to make sure everything is closed before restarting, click Close. However, be sure to restart your PC before using Virtual PC.




To expand an IE virtual machine, double-click on the .exe file, which is the first part of the compressed files. For this example, we are going to extract the IE8 Windows 7 virtual machine and import it into Virtual PC.


If the Open File – Security Warning dialog box displays, click Run to continue with the installation.



Read through the License Agreement and click Accept to continue extracting the virtual machine files.


The WinRAR self-extracting archive dialog box displays. Either accept the default location for the Destination folder, which should be the current location of the compressed files, or click Browse to select a different location for the resulting virtual machine files. We accepted the default location. Click Install.


The installation progress displays.


When the files have been extracted, you will see a .vhd file, which is the virtual machine hard drive, and a .vmc file which contains the settings for the virtual machine.


To open Virtual PC, select Windows Virtual PC from the Windows Virtual PC folder on the Start menu.


A Windows Explorer window opens to the location of the Virtual Machines, if any existed. Click the Create virtual machine button on the toolbar. If you can’t see the button, click the double right-pointing arrow button and select Create virtual machine from the drop-down menu.



The Create a virtual machine wizard displays. Enter a name for the virtual machine in the Name edit box. Accept the default Location for the virtual machine file. It will be placed in the Virtual Machines folder that opened in the Windows Explorer window when you started Virtual PC. Click Next.


The Specify memory and networking options screen displays. Enter the amount of RAM, in megabytes, you want the virtual machine to use in the edit box. To connect the virtual machine to your network, select the Use computer network connections check box. You will most likely need to turn on this option so your virtual machine can access the internet through your network.



On the Add a virtual hard disk screen, select the Use an existing virtual hard disk radio button, and click Browse.


On the Select virtual hard disk dialog box, navigate to the folder where you extracted the .vhd and .vmc virtual machine files. Select the .vhd file and click Open.


Select the Enable Undo Disks check box.

NOTE: The Enable Undo Disks option allows you to return to the initial settings that exist when you first set up the virtual machine in Virtual PC. This is helpful because the versions of Windows in these virtual machines are not activated. They are essentially in trial mode. From the Microsoft site:

“You may be required to activate the OS as the product key has been deactivated. This is the expected behavior. The VHDs will not pass genuine validation. Immediately after you start the Windows 7 or Windows Vista images they will request to be activated. You can cancel the request and it will login to the desktop. You can activate up to two “rearms” (type slmgr –rearm at the command prompt) which will extend the trial for another 30 days each time OR simply shutdown the VPC image and discard the changes you’ve made from undo disks to reset the image back to its initial state. By doing either of these methods, you can technically have a base image which never expires although you will never be able to permanently save any changes on these images for longer than 90 days.”

We will explain later in this article how to undo changes and reset the virtual machine to the initial settings.

Click Create.


You should see a .vmcx file in the Virtual Machines folder in the Explorer window that opened when you started Virtual PC.


To open the virtual machine, select the .vmcx file and then click the arrow button next to the Open button that becomes available. Select Windows Virtual PC from the drop-down menu.


Two users display on the virtual machine screen during boot up. Each virtual machine has two users, but only one seems to work. Choose the following usernames for each of the virtual machines:

IE7 in Windows Vista: Administrator
IE8 in Windows 7: IEUser
IE9 in Windows 7: Administrator


Use the password “Password1” (without the quotes) for each of the virtual machines to log in to Windows.




The Windows Activation dialog box displays saying that the activation period has expired. Click Cancel in the lower, right corner of the dialog box.



The Microsoft Security Essentials dialog box may display. Click Close.


Once Windows has started in the virtual machine, click the Internet Explorer icon on the Taskbar to open IE.




IE opens. You can set your default home page and view any web pages you need to test in this version of IE.


You can check the version by selecting About Internet Explorer from the Help menu.



To close the virtual machine, select Close from the Action menu.


In the Windows Virtual PC dialog box, select Shut down from the drop-down list. If you want Shut down to be the default option, select the Make it the default and don’t show this message again check box. Click OK.



You can change the settings for a virtual machine once it is shut down. To do so, select the .vmcx file for the virtual machine you want to change. Click Settings on the toolbar in Explorer.




If you are getting to end of your 30-day trial period in your Windows virtual machine, you can reset the virtual machine to the initial settings, therefore resetting the trial period. To do so, select Undo Disks in the list on the left of the Windows Virtual PC Settings dialog box. Make sure the Enable Undo Disks check box is selected and then click Discard changes.



A warning dialog box displays. To continue resetting the virtual machine settings, click Continue. Remember that any changes you made to the Windows system in your virtual machine will be lost.


You are returned to the Settings dialog box. Click OK to close it.



You can install IE8 or IE9 in the IE7 virtual machine. There are icons on the desktop to easily install either version. Remember, however, that installing IE8 or IE9 replaces IE7.


In the IE8 virtual machine, you’ll find the file to install IE9 in the C:\Internet Explorer Versions directory.


Once you have opened the virtual machine once, the login process is a little different. The following dialog box displays the next time you open the virtual machine.



Click IEUser and enter “Password1” in the edit box. Click OK.


A dialog box displays while the integration features of the virtual machine are enabled.



The virtual machine opens and you can run IE.


Side Note:
1. Be warned that the Windows 7 and Vista VHD files are large and are split across several files. Download all the files for each virtual machine for the versions of IE you want to run. We will show you how to unpack these files so they create the complete VHD file. You will also need to download Microsoft Virtual PC, which is actually an update to Windows. The download links for the virtual machines and Virtual PC are at the end of this article. To download Virtual PC, you must validate Windows. The download links are at the end of this article.

2. If you install a later version of IE in one of the virtual machines, it replaces the earlier version. If you need to run all three versions, create a virtual machine for each version.

Saturday, April 19, 2014

Crowdpruning for evolutionary algorithm


Make use of crowd pruning to increase diversity

Nsga-ii use crowd pruning for pruning the excessive items (more than n), it prefers things at less crowded areas. (crowd pruning)


IBEA (indicator-based)

Torrent downloader

I have encountered a new torrent downloader which I have never heard before, and it works pretty well for downloading torrent.


Tixati

Record slides to pdf from camera

1. Batch Rotate - Right click the images and select "Rotate Clockwise" or  "Rotate counterclockwise"
2. Batch crop -
File > Preferences > Special, Uncheck Update PPI on Crop (If not it will appear to small after the pdf merge)
Edit  > Synchronize Crops, to get the selection apply to all slides.
3. PDF Merge - Select the images and right click and choose "Combine files in Acrobat"

4. Reduce Image Size (for Adobe XI) - Choose Save as Others > Reduced Size PDF.

Wednesday, April 2, 2014

CMS

http://stackoverflow.com/questions/243655/what-is-the-best-open-source-net-content-management-system-cms

Magento

Install with IIS


Successful e-commerce involves a long list of to-do's, from
payment methods, shipping methods, products, content, e-mail templates, forms,

and much more. 

Online Advertising Knowledge

Networks
Exchanges
Supply side platforms (SSP)
Demand Side platforms (DMP)
Data management platforms (DMP)

Real Time Bidding

IPOnline

DSP->DMP
<100ms

Jscamp.asia
NUSHACKERS

Analytics.adzhub.com


text-to-speech synthesizers

Yii


how to change cwidget->how to create a theme
how to validate
user roles
how to change the site login

site/index.php and so on is the default
 'components' => array(
        'user' => array(
            // enable cookie-based authentication
            'allowAutoLogin' => true,
            'loginUrl' => array
            (
                '0' => '/admin/login/site/login'
            )
        ),
To change default login page




110 (drop down list)
remember to set this
<?php
$yii='/wwwroot/framework/yii.php';
$config=dirname( FILE ).'/protected/config/main.php';

With this con guration, we can access the DB connection object using Yii::app()->db
at any place in our code. Note that Yii::app() returns the application instance that we
create in the entry script.

LoginForm.php
$duration=$this->rememberMe ? 3600*24*30 : 0; // 30 days
Yii::app()->user->login($this->_identity,$duration);

validation rules set in models rules method

<?php echo CHtml::activeDropDownList($post,'status',Lookup::items('PostStatus')); ?>

Tag::model()->updateFrequency($this-> oldTags, $this->tags);

access controller

$dataProvider=new CActiveDataProvider('Post', array(
'pagination'=>array(
'pageSize'=>Yii::app()->params['postsPerPage'],
),
'criteria'=>$criteria,
));

<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>' view',
'template'=>"fitemsgnnfpagerg",
)); ?>


cgridview

<?php $this->widget('CAutoComplete', array(
'model'=>$model,
'attribute'=>'tags',
'url'=>array('suggestTags'),
'multiple'=>true,
'htmlOptions'=>array('size'=>50),
)); ?>

$this->redirect(array('index'));


smartgit
open project
stage
commit
push to


C:\wamp\www\emplify\api\protected\views\layouts\main.php

Yii::app()->params['basetitle']

Git

Got to new folder, create new repository: git init
Current status: git status (-s)
Commit to index: git add readme.txt
Commit from index to snapshot: git commit
History: git log
Git gui ctrl+t ctrl +u commit
git log --pretty=raw

git checkout readme.txt (restore file)




git config --global alias.lg "log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr %an)%Creset' --abbrev-commit --date=relative"
git config --global alias.wipe '!git reset --hard;git clean -fd'
git config --global color.ui auto
git config --global core.editor "nano -Y patch"


Coding convention

    The objective of everything is memoriless:
  1. You still know your code when 10 years after you come back and look at it.
  2. You know exactly where to change the stuff

  3. Method Signature is important
  4. Common sense (clear when judging the signature itself)
  5. Brief (don't put createNewNode, put create Node)
  6. General e.g.
  7. Not so good
     private string getNewName(string prefix, string suffix, List<TreeNode> trs, int startNumber)
    Good
     private string getNewName(string prefix, string suffix, List<string>  usedName,  int startNumber)

    Organization is important, separate when necessary
  8. Separate specific from general (hiearchical relationship)
  9. Separate task like UI and logic

  10. Naming
  11. Use precise name, not first name in your mind like if it is a start number used startNumber, don't use counter
  12. Remove redundant node like createNewNode->createNode


  13. Coding
  14. Code one function by one function, other leave as stuff and code later
  15. Make the correct architecture when start coding, so any additional task you can add later


Tuesday, April 1, 2014

XPath and How to use it in chrome

//input[@id="searchinput"]
//input[@id="searchinput"][@name="search"]  %two must be satisfies
//input[starts-with(@id,"search")]  %id that prefix with search
//input[substring(@id,2)=='earchInput']
//input[substring(@id,2,5)=='earch']
//title[text()='hello']  %innertext is hello
//title[normalize-space(.)='hello']  %innertext is hello, . means text
//input[contains(@id, 'hello')]  %id contains hello

//input[@id= 'hello']/following-sibling::select 
Select all <select> sibiling after <input id="hello">

following-sibling (XPath Axes) - Selects all siblings after the current node


To use XPath in Chrome
Click F12 to show the developer window
and click the following icon
to make the console open

Then type $x("your xpath here")  in the console to test the xpath