Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Friday, November 14, 2014

"JavaScript: The Good Parts" - book review

In this post I'll explain my thoughts on "JavaScript: The Good Parts" written by Douglas Crockford. It is fairly old book written in 2008 but still does the good job of teaching you what to use and what not to use from JavaScript. As the author says, this book has lot of information packed in about 150 pages, which means you have to read at least twice each chapter. Yes I passed each chapter twice and also spent some time writing the code from the book in Firefox/Firebug just to see how it goes. I think more examples to practice would be much better for the book as it lacks them. But in the end you would certainly need to read another book to learn how to code proper JavaScript modules, patterns, etc... I am planning to read another book because this one is not enough to get you going with JS. My recomendation for next book would be this one: "JavaScript Patterns" - by Stoyan Stefanov, it has about 240 pages which is enough.

The book is structured in 10 chapters and with 5 appendices, A-E. My suggestion is to read all chapters includding the appendices. Appendix D is just the railway diagrams, so you may skip it.
Chapters:
  1. Good Parts. This chapter contains basic info about JS and how to set up testing ground for other code examples in the book. Don't skip it. 
  2. Grammar. Contains basic information about reserved keywords in JS, data types, expressions, functions etc...
  3. Objects. Explain how to work with Objects in JavaScript, how to create new object, how to retrieve infrormation from object, object prototype, reflection, enumeration, delete operator, etc...
  4. Functions. Dives into JavaScript function basics. How to create new function, how to invoke a function, this and arguments objects of a function, its connection with objects. Each function is an object so you can add a function to its prototype. Function scope, closure, function modules, cascade (builder pattern), curry and memoization.
  5. Ineritance. Inheritance types, implementing standard OOP in JS (pseudoclassical) inheritance, prototypal and functional inheritance. Very important chapter, don't skip it.
  6. Arrays. Array basics, length property, useful array methods, delete operator, enumeration, etc...
  7. Regular Expressions. Dives into JS regular expressions, what are they and how to use them. Couple of basic rules how do RE work. Very useful thing, especially when processing strings. 
  8. Methods. This chapter explains implemented methods that come with JavaScript itself. You may want to skip this chapter but it would be helpful if you read it. 
  9. Style. This chapter explains some techniques how to write error prone JavaScrtipt code. My suggestion is to not skip this chapter. 
  10. Beautiful features. Read this chapter to learn what are the best parts of JavaScript that you should use. Functions as a first class object, Dynamic objects with prototypal inheritance and Object litrals and array literals.
  11. Appendix A. Awful Parts. Explains all of the worse parts in JS and how to avoid them.Global variables, scope, semicolon insertion, reserved words, unicode, typeof operator, parseInt function, + operator, floating point, NaN, phony arrays, falsy values, hasOwnProperty function and Object.
  12. Appendix B. Bad parts. Things you can live with but still should avoid. == vs === operators, with statement, eval function, continue statement, switch fall trough, block-less statements, ++ and -- operators vs += and -= operators, bitwise operators, function statement vs function expression, typed wrappers, new operator, void keyword.
  13. Appendix C. JSLint. An online tool build by Douglas himself. Use it whenever possible to debug your JS code. You may find this tool also useful, http://jsbeautifier.org/
  14. Appendix D. Syntax Diagrams. If you are beginner at programming, these railway diagrams will help you get going. 
  15. Appendix E. JSON. Explains what is JSON, JSON syntax, how to use it securely and a complete script of JSON parser in JavaScript.
 I think this book is not recommended for beginner programmers, but it is good if you are learning JavaScript. Still it lacks more code examples and practices, so you have to read another JS book. My opinion of this book is 4.5/5. It does the job for what is meant to do, aka teaching you pros and cons of JavaScript and how to use or avoid them. You must read this book if plan to code JS programs in future.

Thursday, July 31, 2014

SEO basic notes, Onpage | Offpage optimizations, White | Black hat SEO

I this post I plan to share what I have learned by reading a SEO book.

There are onpage and offpage optimizations.

Onpage optimizations include: 

  • using your main keywords in <h1> tag, 
  • using secondary most important keywords in <h2> tag. 
  • Put several of your main keywords to construct the <title> tag usually separated with | sign. 
  • Avoid repeating same keywords in the title tag because Google may detect it as spamming and ban your site. 
  • Every <image> tag in your site should contain alt attribute with your main keywords plus the word image or picture. It is meant for blind people and to give additional info when the image was not fetched properly. 
  • Put your site url and main keywords in a footer of every of your site pages
  • Usually it is always better to let Google read first your body text then continue with navigational links if they stand in a left hand sided panel. Put an empty cell or row above your navigational panel so the page parsing could start with the body text
  • Use Google Trends or WordTracker or other tool to find best keywords for your website. Avoid using keywords that are used by many websites because the competition will be very fierce and you will achieve nothing. 
  • Google does NOT use keyword metatag for calculating your page rank. Check this page: http://googlewebmastercentral.blogspot.com/2009/09/google-does-not-use-keywords-meta-tag.html
  • Google may use description metatag if it finds it is something useful and show it as a snippet in the search result. Yes you should always try to describe your website within description metatag or your <header> tag.
  • You should also bold and or italicize keywords at some place if you think it looks appropriate for the website design. It will help in the search results.
  • Avoid using hidden text, because Google can see it and if there is keyword spamming it may ban your site. 
  • Avoid image tag spamming, meta tag stuffing, and title tag stuffing with keywords. You will surely get banned. 
  • Keep good inner website structure, aka every webpage should be linked to some hub page where we all can easily find it. This is commonly known as a site map. Google checks this and it doesn't like orphan pages.
  • If you want to use keywords in your url you should separate them with hyphen, not with underscore. And yes Google, MSN and Yahoo index pages that contain keywords in their url however smaller search engines may or may not use this information to index your page. Check this page: http://www.webrankinfo.com/english/seo-news/keywords-in-url.php

Offpage optimizations include: 

  •  Onpage optimization is what you should do, however offpage is what really brings traffic to your website.
  • Do NOT use Google, MSN or Yahoo submit pages to submit your site to their index. It is worthless and may give worse results than leaving search engines to index your page by them selves.
  • You site may appear in Google's index in 1 or 2 days without effort on your side. 
  • You can purchase reciprocial links to your site from link directory sites like http://www.textlinkbrokers.com/
  • One site of PR 5 pointing to your site may increase traffic several times in difference with several sites with PR 2 or 3.
  • Google and other well known search engines use several criteria to evaluate your website. That include: Which websites point to your site, the number of sites pointing to your site, PR value of sites pointing to our site, page title of websites pointing to your site, anchor text used in the link linking to them, the number and type of links linking to your site, the number of sites linking to sites that link to your site, are these sites deemed as authority sites by Google, the IP address of sites linking to your site (are they all on same IP address).
  • You should use "link" keyword in Google to check all sites that contain that url address. Example: type in Google: link: http://www.domainname.com
  • Google checks IP address of sites linking to your site and it cannot be tricked by pages pointing to your site that lay on same IP address.
  • You can search link directories for link exchange using this technique, type in Google: keyword "Please also suggest my link to the linkpartners.com directory". Replace keyword with your own keyword. I have tried this, it brings some results but not much what I expected. You can contact sites with a submit form for link exchange. 
  • Avoid linking to site that doesn link back to your site. You PR value suffers.
  • Use SEO Elite to check for sites with PR 0 whether they are banned by Google. If yes, they don't exist in Google's index than you may NOT want to link them anymore, because your site will get penailzed or banned too.
  • You should create link hub pages with up to 25 reciprocial links to other sites withing your website. 
  • You can calculate your page rank with a formula. Check this wiki page: http://en.wikipedia.org/wiki/PageRank, this also may come in handy http://checkpagerank.net You can also use some of the GoodKeywords tools to check your page rank, or Google's toolbar.
 There are two types of SEO techniques, White hat SEO and Black hat SEO.

 Black hat SEO is more concentrated on search engines and for short term financial return.That means using agressive techniques like keyword stuffing and spamming, that leads to fast financial return but for sure your site will get banned by search engines sooner or later.

White hat SEO includes using SEO techniques according to search engine guidlines. It means doing all things that will not harm your site's page rank, for a long term results and meant for real people. Wirting human readable articles, onpage/offpage optimisations, without using keyword stuffing or spamming. Maintaining goot site structure, recirprocial links etc...

You may want to recall to this post http://tunephp.blogspot.com/2014/07/search-engine-optimization-made-easy-by.html

Wednesday, August 31, 2011

JQuery basics

In this post I will explain the basics of JQuery, what it is and what it is used for.

JQuery is cross browser javascript library that is easy to learn and easy to use. It has two versions one is for production which is compressed (about 31KB) and other which is not compressed (about 230KB) and is for development. So when developing or learning you should use the development version and when you are publishing some website use the production version.
JQuery is written by several IT proffesionals whose main mission is to make JQuery the best javascript library for web.

You might wanna visit JQuery .
There are several other good javascript libraries like prototype, scriptaculous, Google Web Toolkint, and many others list of js libs. What makes JQuery so popular is that it is cross-browser, CSS3 compliant, easy to learn and to use. It has a wide variety of tools built on it like widgets, interactions, utilities, special effects.
For example implementing simple accordion with text data is no more than writing div tags and importing js files in your html.

I will be writing some tutorials on using JQuery with AJAX, implementing widgets like accordion, slider, progressbar etc. so make sure you have Firefox with firebug installed or maybe Chrome. About IE I haven't used it much so maybe I will make some tut on it in future.

Saturday, July 16, 2011

Basic quickstart commands on MongoDB

In this post I will explain the basic commands for inserting, retrieving, limiting the data sent from/to the database.

Ok so now we have inserting data to the db.

go to /bin folder and type mongo. The shell appears.
Now type insert these three documents:


> db.movies.save({title:"Harry Potter",year:2010, duration: "120 min"});
> db.movies.save({title:"Expendables",year:2010,duration:"140 min"});
> db.movies.save({title:"Green Lantern",year:2011,duration:"150 min"});


We are creating collection called movies and add three documents for movies. (Note: The data here is maybe not correct, it is just for example). So these commands corespond to the SQL statement

insert into movies (title,year,duration) values ("Harry Potter", 2010,"120 min");
insert into movies (title,year,duration) values ("Expendables", 2010,"140 min");
insert into movies (title,year,duration) values ("Green Lantern", 2011,"150 min");

 Now use this command

> db.movies.find();

This will list all documents in the movies collection. Now we will create a script with for statement.

> for (var i = 1; i <= 25; i++) db.script.save({blog:"TunePHP", j : i});
 
This script will create a collection called "script" and add documents in the format 
{blog:"TunePHP", j : i}. 
 
run > db.script.find(); 
 
Now the limit of the find command is 20 rows. In case where there
are more than 20 documents in a collection we use the it command. So now in terminal run
 
> it 
 
it will show the rest docs in the script collection.