Google PageRank – the principle

I think everyone knows Google, the most known company that starts with a search engine. Every day, over 2 million search queries are being sent to Google and you get the things you want because they have special algorithms to find out the important links.

Have you wondered how can Google does that? In here I’m going to tell you how. It’s a number called PageRank that defines the importance of a page and the result is sorted according to the PageRank.

A PageRank of a page is actually the probability of a user clicking the link. Every page will be given a same PageRank when Google first indexed them. Then each time Google indexed a page, it’ll recalculate the PageRank of every page by the following rules:

  1. If the page has been linked by other sites, their PageRank will transfer to the page.
  2. Then, if there’s more page linked to the current page, a PageRank of the PageRank of the page divided by the number of link to the current page will be transferred.

Therefore, the formulae of a page’s PageRank is:

PageRank Math

(Where u denotes the current page, v denotes the pages that linked to the site u and L() is the amount of links to site u.)

This formulae helps Google to choose what is useful to the users. Also, the higher the number, the more likely a user will go to your site. This makes PageRank an important mark of how popular your site will be.

Create a simple web spider in node.js

I’ve seen many web crawlers written in other languages like PHP, Python, Ruby, etc. However, there’s no one that notices node.js is also good in doing these kind of things. So I utilizes asynchronous network I/O provided by node.js to create a fast, stable web crawler (spider) in node.js and it’s very simple. Here I’ll reveal the logic of a web crawler and allow you to create your own.

A web spider is a long-running program that finds websites and record them. After that we can search the records generated by web spiders to find information we want. It’s the basic unit of a search engine.

First, we need to search for links from a base webpage and record the webpage to the database. Then, follow the links found and repeat the first step to discover more webpages.

Here are some modules that helps us coding a web spider:

  1. request (helps fetching webpages)
  2. cheerio (helps parsing webpages)
  3. mysql (for indexing pages)
  4. async (helper library)

And here’s the code:







Here’s how it works:

First, it crawls the base page specified in config.json first. Then it tries to find all links from the page content and add them to the queue, then the first item on the queue will be executed. This process continues again and again…

Also, we store the queue in a MySQL database for scalability. This script can be spawned across multiple machines.

My own Text-To-Speech (TTS) Service!

Update: Multi-language support added.

I’m now release my own Text-To-Speech Service made with node.js. I think an easy-to-use TTS service is necessary for web applications nowadays. However, creating your own one isn’t easy. So I created one based on eSpeak and hosted an API for you to use easily.

The API is fairly simple. Just issue a HTTP GET or HTTP POST request to the address below (https protocol also supported):

http://licson-node.hp.af.cm/tts

And it’ll return a wave file representing the result. Here’s some parameters you need to provide with the request.

  1. text – The text to read. (required)
  2. speed – The speed of reading. (optional) Default: 180 (Range 10-300)
  3. pitch – The pitch of reading. (optional) Default: 50 (Range 0-100)
  4. wordgap – The addtional time delay between each word. (optional) Default: 0
  5. lang – The language of the text. (optional) Default: en/en  See all language options below.

Here’s an example of using the API through HTTP GET requests:

http://licson-node.hp.af.cm/tts?text=Hi!+I+can't+wait+to+meet+you.&speed=185&lang=en/en-us

Supported languages:

  1. ca (Catalan)
  2. cs (Czech)
  3. de (German)
  4. el (Greek)
  5. en/en (English)
  6. en/en-n (English, regional)
  7. en/en-rp (English, regional)
  8. en/en-sc (English, Scottish)
  9. en/en-us (English, US)
  10. en/en-wm (English, regional)
  11. eo (Esperanto)
  12. es (Spanish)
  13. es-la (Spanish, Latin America)
  14. fi (Finnish)
  15. fr (French)
  16. hu (Hungarian)
  17. it (Italian)
  18. kn (Kannada)
  19. la (Latin)
  20. lv (Latvian)
  21. nl (Dutch)
  22. pl (Polish)
  23. pt (Portuguese, Brazil)
  24. pt-pt (Portuguese, European)
  25. ro (Romanian)
  26. sk (Slovak)
  27. sv (Swedish)
  28. tr (Turkish)

These parameters can be sent as query parameters or form body when using HTTP POST. Beware that long passages should be splitted in parts to avoid long processing times. If you need to render a long passage, send the text with HTTP POST because query parameters have a length limit of 2,000 characters.

Here’s an example of the speech: http://ow.ly/kHtxK. If you like, please help me do this survey in order to improve the service.

Create smooth animations with CSS3 animations

CSS3 Animations Module that solves all these problems. In this new specification, the animation are keyframe-based which allows more complicated animations to be done easily and the syntax is pretty easy. First, let’s understand the syntax. You need to define a set of keyframes with the @keyframes rule first. Here’s an example:

@keyframes animation {
    from {
        transform: translateX(0px);
    }
    to {
        transform: translateX(-100px);
    }
}

In this example, it defines a set of keyframes called animation. It starts from the original position and moves to left by 100px. You can also add more than 2 keyframes by using percentages to indicate the position of the keyframe. Here’s an example:

@keyframes animation {
    from {
        transform: translateX(0px);
    }
    60% {
        transform: translateX(36px);
    }
    to {
        transform: translateX(-100px);
    }
}

DEMO In this example, the animation will first moves from its original position to it right by 36px then at the 60% of the whole animation it starts to move from the right to the left by 100px. This creates a bouncing animation. You can also animate more than one property at a time to create even more complex animations. After we have created the keyframes, we need to add the keyframes to the element that we want to animate by using the animation CSS3 property. Here’s the syntax:

animation: <keyframe_name> <duration> [<timing_function> <iteration>];

Where <keyframe_name> is the name of the keyframe you want to add, <duration> is the length of the animation in seconds, <timing_function> is a string indicates the progress of the animation and <iteration> is the times of repeated animations. Here’s an example:

.element {
    animation: animation 2s;
}

This will play an animation with a set of keyframes called animation in 2 seconds once. You can also make more changes to make an animation to look more natural by adding a timing function of ease

How to do vocal removal nicely with Adobe Audition

Today one of my friends asked me how to do vocal removal nicely. He told me that he had tried some other softwares like Audacity and the result wasn’t good. I think many people may have these kind of problems too so I should help others.

In this article, I’ll use an audio editing software called Adobe Audition. (Beware: It’s not a freeware and you can get a trial version from Adobe easily.)

P.S. I’m using Adobe Audition CS6 but the method I mentioned here also works in the previous versions.

First, open Audition and load the audio file in.

Audition startup

Audition user interface

Then, click [Favorites -> Remove Vocals].

Favorites -> Remove Vocals

Removing Vocals

After the processing, it is basically finished. However, if you want to remove the vocals even further, you can follow the steps below:

Click [Effects -> Special -> Vocal Enhancer].

Click [Effects -> Special -> Vocal Enhancer]

Then click [Music -> Apply]. The music will get enhanced and the vocal will be further suppressed.

Vocal Enhancer

Finally, save the file and you’re finished!

Multiplayer Piano – a nice website for playing music together

http://www.multiplayerpiano.com/

This website is for people to play songs together. I first discovered this in Chrome Experiments and it looked attractive. I found it good so I’m going to share it.

The user interface of this website is pretty straightforward. It has a piano with all 88 keys and a simple chat interface. You can click on the keys to play, or you can use your keyboard. It also has a cool feature that allows you to plug in your own MIDI keyboard and play the notes directly and that suits me very much as I have a MIDI keyboard.

When using the MIDI keyboard you may get problems with those delayed notes. To solve the problem you just need to minimize the window and it’ll get better soon.

The chat interface are fairly simple: you just need to type in the words and press enter to send. The only thing that hurts is the colour of the text makes checking typing errors difficult.

Overall, it’s a really good website, so definitely worth to be used, before or while looking for best piano keyboard to practice at home.