SSH and SecureCRT

1. Environment
Ubuntu Server 10.10
SecureCRT 6
OpenSSH 5.3


2. OpenSSH Installations
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ sudo apt-get install openssh-server openssh-client
$ sudo vi /etc/ssh/sshd_config

[/codesyntax]

PasswordAuthenitcation, Port 22, Protocol 2,1

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ sudo /etc/init.d/sshd restart

[/codesyntax]


3. SecureCRT Configurations
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ ifconfig

[/codesyntax]

get your ip addr -> myipaddr

Config your SecureCRT :

Protocol : SSH2

Host : myipaddr

Port : 22

Firewall : none

User : someone

Done and start connection


4. Using RSA with SecureCRT
SecureCRT -> Tools -> Create Pubkey (OpenSSH format)
Upload the public key Identity.pub to server
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ su root
$ cd /root
$ mkdir .ssh; chmod 700 .ssh; cd .ssh;
$ mv /path/to/Identity.pub ./authorized_keys2
$ vi /etc/ssh/sshd_config

[/codesyntax]

(optional : to only allow ssh2 rsa auth)

Protocol 2

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys2

PasswordAuthentication no

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ sudo /etc/init.d/sshd restart

[/codesyntax]

Use PublicKey when using SecureCRT to connect your server


5. Multi-users with SecureCRT

Upload other user’s Identity.pub to server

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ sudo echo `cat /path/to/Identity.pub` >> /root/.ssh/tmp
$ sudo echo `cat /root/.ssh/authorized_keys2` >> /root/.ssh/tmp
$ sudo mv -f /root/.ssh/tmp /root/.ssh/authorized_keys2

[/codesyntax]

To login with another user, set your default path of SecureCRT connection :

SecureCRT -> Global Options -> SSH2 -> PublicKey

Posted in Ubuntu | Tagged , , | Leave a comment

HTML5 Skills

HTML5 Tutorial : http://www.w3schools.com/html5/default.asp




1. HTML5 doctype

[codesyntax lang=”html4strict”]

<!DOCTYPE html>

[/codesyntax]

2. Figure
[codesyntax lang=”html4strict”]

<figure>
    <img src="http://kbs.kimbs.cn/img/php5-zce-logo-new.gif" alt="About image" />
    <figcaption>
        <p>This is an image.</p>
    </figcaption>
</figure>

[/codesyntax]

3. Small
[codesyntax lang=”html4strict”]

<small>© Copyright</small>

[/codesyntax]

4. No “type” any more
[codesyntax lang=”html4strict”]

<link rel="stylesheet" href="path/to/stylesheet.css" />
<script src="path/to/script.js"></script>

[/codesyntax]

5. Unnecessary quotes (different from XHTML)
[codesyntax lang=”html4strict”]

<p class=myClass id=someId> Start the reactor. </p>

[/codesyntax]

6. Content editable
[codesyntax lang=”html4strict”]

<ul contenteditable="true">
    <li> Break mechanical cab driver. </li>
    <li> Drive to abandoned factory </li>
    <li> Watch video of self </li>
</ul>

[/codesyntax]

7. Email field
[codesyntax lang=”html4strict”]

<form action="" method="get">
    <label for="email">Email:</label>
    <input id="email" name="email" type="email" />
    <button type="submit"> Submit Form </button>
</form>

[/codesyntax]

8. Placeholder
[codesyntax lang=”html4strict”]

<input name="email" type="email" placeholder="doug@givethesepeopleair.com" />

[/codesyntax]

9. Local Storage (no time limit)
[codesyntax lang=”javascript”]

<script>
// the localStorage object
alert(localStorage);

// page visit count in local storage
if (localStorage.pagecount) {
    localStorage.pagecount = Number(localStorage.pagecount) + 1;
} else {
    localStorage.pagecount = 1;
}
document.write("Visits " + localStorage.pagecount + " time(s).");
</script>

[/codesyntax]

10. Session Storage (clear when closing brower)

[codesyntax lang=”javascript”]

<script>
// the sessionStorage object
alert(sessionStorage);

// page visit count in current session storage
if (sessionStorage.pagecount) {
    sessionStorage.pagecount = Number(sessionStorage.pagecount) + 1;
} else {
    sessionStorage.pagecount = 1;
}
document.write("Visits " + sessionStorage.pagecount + " time(s) this session.");
</script>

[/codesyntax]

11. Header and Footer
[codesyntax lang=”html4strict”]

<header>
this is the header
</header>
body
<footer>
this is the footer
</footer>

[/codesyntax]

12. HTML5 and IE (announce those elements)
[codesyntax lang=”css”]

header, footer, article, section, nav, menu, hgroup {
    display: block;
}

[/codesyntax]

[codesyntax lang=”javascript”]

document.createElement("article");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("nav");
document.createElement("menu");

[/codesyntax]

13. The h group
[codesyntax lang=”html4strict”]

<header>
    <hgroup>
        <h1> Recall Fan Page </h1>
        <h2> Only for people who want the memory of a lifetime. </h2>
    </hgroup>
</header>

[/codesyntax]

14. Required attribute
[codesyntax lang=”html4strict”]

<form method="post" action="">
    <label for="someInput"> Your Name: </label>
    <input type="text" id="someInput" name="someInput" placeholder="Douglas Quaid" required="required" />
    <button type="submit">Go</button>
</form>

[/codesyntax]

15. Autofocus
[codesyntax lang=”html4strict”]

<input type="text" name="someInput" placeholder="Douglas Quaid" autofocus="autofocus" />

[/codesyntax]

16. Audio
[codesyntax lang=”html4strict”]

<audio autoplay="autoplay" controls="controls">
    <source src="audiofile.ogg" />
    <source src="audiofile.mp3" />
    <a href="file.mp3">Download this file. (for compatibility)</a>
</audio>

[/codesyntax]

17. Video
[codesyntax lang=”html4strict”]

<video>
    <source src="videofile.ogg" />
    <source src="videofile.mp4" />
</video>

[/codesyntax]

18. Video preload
[codesyntax lang=”html4strict”]

<video preload="preload">
    <source src="largevideo.ogg" />
    <source src="largevideo.mp4" />
</video>

[/codesyntax]

19. Video controls
[codesyntax lang=”html4strict”]

<video preload="preload" controls="controls">
    <source src="largevideo.ogg" />
    <source src="largevideo.mp4" />
</video>

[/codesyntax]

20. Pattern
[codesyntax lang=”html4strict”]

<form action="" method="post">
    <label for="username">Create a Username: </label>
    <input type="text" name="username" id="username" placeholder="4 <> 10" pattern="[A-Za-z]{4,10}" autofocus required />
    <input type="submit" />
</form>

[/codesyntax]

21. Attributes support checking
[codesyntax lang=”javascript”]

<script>
if (!'pattern' in document.createElement('input') ) {
    alert("Your brower does not support this attribute!");
    // do client/server side validation
}
</script>

[/codesyntax]

22. Mark
[codesyntax lang=”html4strict”]

<h3> Search Results </h3>
<p> They were interrupted, just after Quato said, <mark>"Open your Mind"</mark>. </p>

[/codesyntax]

23. Articles
[codesyntax lang=”html4strict”]

<article>
    <a href="http://blog.netscape.com/2007/12/28/end-of-support-for-netscape-web-browsers">Netscape is dead</a>
    <br />
    AOL has a long history on the internet, being one of the first companies to really get people online.....
</article>

[/codesyntax]

24. navigation
[codesyntax lang=”html4strict”]

<nav>
    <a href="default.php">Home</a>
    <a href="previous.php">Previous</a>
    <a href="next.php">Next</a>
</nav>

[/codesyntax]

25. Use descriptive tags instead of <div> for layout
[codesyntax lang=”html4strict”]

<header>
    header
</header>

<nav>
    the navigation
</nav>

<aside>
    extra information or related links
</aside>

<article>
    main content
</article>

<footer>
    footer
</footer>

[/codesyntax]

26. Canvas API
[codesyntax lang=”html4strict”]

<canvas id="myCanvas"></canvas>

<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#FF0000';
ctx.fillRect(0,0,80,100);
</script>

[/codesyntax]

27. Price range
[codesyntax lang=”html4strict”]

<input type="range" name="price" min="100" max="10000" />

[/codesyntax]


Resources :

HTML5 Grayscale Image Hover


end

Posted in DHTML | Tagged | Leave a comment

Xdebug for PHP Profile

Windows

1. Download xdebug extension :
http://www.xdebug.org/files/php_xdebug-2.1.0-5.2-vc6.dll

2. Add xdebug extension into php :
E:\xampp\php\ext\php_xdebug-2.1.0-5.2-vc6.dll

3. Modify php.ini :
[codesyntax lang=”ini”]

extension = "php_xdebug-2.1.0-5.2-vc6.dll"
[xdebug]
zend_extension = "E:\xampp\php\ext\php_xdebug-2.1.0-5.2-vc6.dll"
xdebug.remote_enable = true
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "E:\xampp\tmp\xdebug"
xdebug.auto_trace = 1
xdebug.trace_output_dir = "E:\xampp\tmp\xdebug"
xdebug.dump.GET = *
xdebug.show_local_vars = 1

[/codesyntax]

4. Restart apache :
see phpinfo() for xdebug section

5. Download winCacheGrind and start profiling :
http://sourceforge.net/projects/wincachegrind/




Linux

1. Download and Install xdebug.so
[codesyntax lang=”bash”]

$ wget http://www.xdebug.org/files/xdebug-2.1.0.tgz
$ tar -xzf xdebug-2.1.0.tgz
$ cd xdebug-2.1.0/
$ /usr/local/php/bin/phpize
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make
$ make install

[/codesyntax]

2. Modify php.ini
[codesyntax lang=”bash”]

$ vi /usr/local/webserver/php/etc/php.ini
[xdebug]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.profiler_enable=on
xdebug.trace_output_dir="/data/xdebug"
xdebug.profiler_output_dir="/data/xdebug"
xdebug.profiler_output_name="script"

[/codesyntax]

3. Restart nginx and php-fpm (or apache) :
[codesyntax lang=”bash”]

$ /usr/local/webserver/nginx/sbin/nginx -s reload
$ /usr/local/webserver/php/sbin/php-fpm restart

[/codesyntax]

4. Start profiling :
Download kCacheGrind http://kcachegrind.sourceforge.net/
or
Download webgrind http://code.google.com/p/webgrind/

Posted in PHP | Tagged , | Leave a comment

SEO Skills

1. What is SEO

 

SEO on wiki

SEO on baidu

 


 

2. Skills

 

(1) Keywords in url, but not much

 

http://kbs.kimbs.cn/blog/list/post/30/title/using-ajax/  —  it’s right, but too long

http://kbs.kimbs.cn/blog/using-ajax/  —  it’s the answer

 

(2) Keywords in head

 

[codesyntax lang=”html4strict”]

<title>kimbs.cn - category - sub-category - detail</title>
<meta name="Robots" content="index,follow,all" />
<meta name="Keywords" content="kimbs.cn,Php,Zend Framework,Zend Framework information,Zend Framework practice" />
<meta name="Description" content="kimbs.cn is the place in which sharing the lastest news and tech. in php and zend framework" />

[/codesyntax]

 

3. 403/404/500 error pages

 

[codesyntax lang=”text”]

ErrorDocument 403 /path/to/your/error/file/or/script
ErrorDocument 404 /path/to/your/error/file/or/script
ErrorDocument 500 /path/to/your/error/file/or/script

[/codesyntax]

 

4. ajax : as few as possible

 

5. check ref="nofollow"

 

[codesyntax lang=”html4strict”]

<a href="http://www.example.com/" rel="nofollow">discount drugs</a>

[/codesyntax]

 

6. h1,h2,h3 for keywords

 

[codesyntax lang=”html4strict”]

<h1>Big Title</h1>
<h2>Sub Title</h2>
<h3>Article Title</h3>
<h4>Author</h4>

[/codesyntax]

 

7. Alt and Title

 

[codesyntax lang=”php”]

<a href="http://www.example.com" title="http://www.example.com">example link</a>
<img src="http://www.example.com/example.png" alt="this is an example" title="this is an example" />

[/codesyntax]

 

8. flash : use embed background text with keywords

 

[codesyntax lang=”html4strict”]

<script language="javascript">
// use your javascript to embed flash
</script>
<noscript>
// use noscript for seo
<object>
<param ... />
<param ... />
...
</object>
</noscript>

[/codesyntax]

 

9. url canonicalization

 

[codesyntax lang=”php”]

RewriteCond %{HTTP_HOST} !^www.kimbs.cn$ [NC]
RewriteRule ^(.*)$ http://www.kimbs.cn/$1 [L,R=301]

[/codesyntax]

 

10. image src with keywords

 

[codesyntax lang=”php”]

<img src="http://www.example.com/keyword-1/keyword-2/example.png" alt="this is an example" title="this is an example" />

[/codesyntax]

 

11. strong or italic your words

 

<b><strong>, <i><em><cite>

 

12. use "click here" in your subsites or partner sites

 

[codesyntax lang=”html4strict”]

<a href="http://www.example.com" title="http://www.example.com">click here</a>

[/codesyntax]

 

13. no index.php or *.php in url

 

[codesyntax lang=”text”]

RewriteCond %{REQUEST_URI} index.php [NC]
RewriteRule ^.*$ http://www.kimbs.cn/ [L,R=301]

[/codesyntax]

 

14. ending url with ‘/’

 

http://kbs.kimbs.cn/blog/using-ajax  —  right, but not perfect

http://kbs.kimbs.cn/blog/using-ajax/  —  perfect

 

15. separate keywords with ‘-‘, separate numbers with ‘_’

 

/for-example-keywords-like-this.html

/2_3_p5.html

 

16. no special chars in url

 

[a-zA-Z0-9], + – _ : / ? & .

 

17. 301 redirections of urls in manner to preserve current ranking

 

[codesyntax lang=”text”]

RewriteCond %{HTTP_HOST} ^kimbs.cn$ [NC]
RewriteRule ^(.*)$ http://www.kimbs.cn/$1 [L,R=301]

[/codesyntax]

 

18. Keywords in page header and footer

 

19. Categories and Urls

http://www.example.com/category/

http://www.example.com/category/sub-category/

http://www.example.com/category/sub-category/product-list/

http://www.example.com/category/sub-category/product-list/product_id/

 

20. Rss

 

21. Sitemaps

 

http://www.sitemaps.org

 

22. Backlinks in search engine

 

link:www.kimbs.cn

Posted in SEO | Tagged | 1 Comment