Facebook Twitter Gplus RSS
formats

Snippet:301 redirect for versions of ISAPI_Rewrite

Published on April 2, 2013, by in Seo.

ISAPI_Rewrite is the component of windows server, it’s used link apache’s mod_rewrite, with this you can make cleaner urls and do something like our post title – 301 redirect.
This article is just for a simple summary, if you have to rewrite your domain or write to 301 redirect rule in different version of ISAPI_Rwrite, here is a good place to start.

1. Rewrite domain www.dev-tricks.com to dev-tricks.com with no ‘www’

2. 301 redirect from other domain

3. redirect your page to another page

Finally, i want to write rewrite rule i used frequently:

This article just covers how to start 301 redirect for versions of ISAPI_Rewrite. Wish it will be helpful!

formats

Snippet:just for your own html5 template

Published on March 31, 2013, by in Css, Html5.

I find something fantastic snippets for web designers, actually i am new to html5, the snippets below may be parts of your base template.
1. Basic html5 template

Internet Explorer has many rendering engines ready for use. What this line of code basically does is force IE to use the most up to date rendering engine that it has available, so that your pages will render as well as possible. It then goes on to talk about Chrome Frame. Chrome Frame is a plugin for IE6, 7, and 8 which brings all the rendering, and js power of Google Chrome to IE. If the user has it installed, we render our site using it.

2. Conditional body tag

3. jQuery loading fallback
A vast majority of sites these days make use of the jQuery JavaScript library. A vast majority also make use of Google’s hosted version of the library for faster loading speed’s, and better cross site caching. However, what if there is ever a problem and jQuery is not loaded from Google? Well here is your backup. What it basically does is check if jQuery is loaded from Google. If not, then we load it locally from our own version of jQuery.

4. Html5 ready reset
Plenty of you will have used Eric Meyer’s css reset before now. It is included in many frameworks and so on, like 960.gs. This is a revamped version of that reset, that brings it into the present with full support for html5. It sets all the new structural tags as block level, and resets all their default styling as expected.

5. Force scrollbar
Sometimes, pages can be shorter than the browser view-port, and when you load a page on the same site that has longer content and uses a scrollbar, content can jump side to side. By forcing a scrollbar no matter the height of our content, we stop this small, but annoying issue.

6. Aligning Labels
Alignment of labels with their relevant inputs can be a horrible task to achieve in older browsers. This snippets solves that for us by making it consistent across browsers!

7.Print styles
Any decent site should be print ready, as even though we live in a technology driven time, people still like to have a hard copy of some information. This snippet firstly uses a css media declaration, allowing you to include this in your main stylesheet, and not having to place another link in the head of your document. This benefits load time, as even when the page inst being printed, a browser will always download that extra css file, generating an extra http request. The snippet then goes on to include some useful print styles such as printing our link urls, and so on.

8. X-UA-Compatible Server sided
This is the same as the html version mentioned above, forcing the latest rendering engine in IE, and Chrome Frame if it exists. The benefit of including this in your .htaccess file is that it saves you having to declare this in the head of each and every html document you produce.

9. Gzip compression
Gzip compression allows us to drastically reduce out file sizes. This .htaccess snippet does the gzipping for us.

I am learning Laravl and Backbonejs for a few days, someone has the same preference please have an email with me, i want to build something special for Chinese programmers, and the new project is on its way now.

Tags: ,
formats

Tip:the best way to resolve position:fixed

Published on March 15, 2013, by in Css.

In modern web design, you may met this situation:
Your page is designed to fix one bar to the top, button, or other places the designer recommended, but you find that is a mess when you testing ie6. The problem is that position:fixed not take effect in ie6.
I have found many solutions, use css filter, javascript .. All those methods may slow down your page render. Last day, i find this solution, i think that is a simulation, you can refer to this when you run into the problem.

I think this solution is the best way to do it.
If you have any problem when using it, let me know – Get the best way to solve position:fixed.

formats

Tutorial: how to open mysql slow query?

Published on March 15, 2013, by in Mysql.

1.what does mysql slow query do?
Slow query will log queries that execute longer than your setting, then you can optimize them.
2.how to open slow query?
Use command line, input this command:

Screenshot:

Then you see the log_slow_queries variable is set to off.
Otherwise, you can step this blow:
Find your my.ini file, then add the statement blow [mysqld], be careful of this tip.

Or you can use command like this, but you need the root user to do this.

I use the first method, and the second had not been tested.
You have set the log_slow_query to on, min query time to 2 seconds and the log file location.
After done this, you should restart your mysql service, and use the command check if your settings take effect.
3.Test the settings
You can test your settings this way:

The result shows that:
1.Your statement start query time
2.Execute user
3.Query time
4.Query statement

This is what i had done, wish will be helpful to you.

formats

Snippet:cakephp ngnix rewrite rule

Published on February 19, 2013, by in Linux, Php.

Last day, i want to install cakephp in my local nginx environment, but when open with the test url, it respone only with one database error.
Finally, i found it was because the rewrite rule made no sense on nginx.
Here is my nginx virtual host configuration:

I’m not quite sure about the rewrite rule,but it really made sense,if you have better one please let me know.

formats

Tips:Compile and run java in Sublime text 2

Published on December 12, 2012, by in Java.

I wanted to be one front-end developer, but for my job’s need, i have to use php and learn java now. So now, i’m one new javaer. Sometimes, i find it quite funny when coding and loving it day by day.
Since i step into the programer world, i had used notepad++, editplus, e-text editor, gvim, eclipse, but i choose sublime text in the end, i find it awesome! Easy to use and easy to custom your own plugin.
Today i want to tell you how do i combine my sublime text with java’s needs, that is compile and run your java code inside sublime text.
Here is a HelloWorld.java program:

In sublime text you can use ctrl+B to compile the program, for the reason of new to java and the programs are simple, son i want to run it in the right while.
The ultimate solution:
Preference -> Browser packages, find the file JavaC.sublime-build, the javac command executed in sublime text is wrote in this file.

We can modify it, and let it run the program after compile.

I think you will understand the code rightly. After do this, when you use ctrl+B, the result will be:

Here i want to tell you another skill of use sublime text, you can also use the editor to update your changes in the run time. Plugin name: FTPsync

formats

Snippet:webkit notification API example

Published on December 2, 2012, by in Javascript.

I used to working on chrome browser, once i made one chrome extension for my project with the Notification API. It’s cool with the notification, though the function is quite simple.
Here is one simple Webkit Notification API example.
Quick tips:
1. when it comes out, you grant permissions to the site.

2.Your code should contains the notification api support checker.
Here we go.

Was this post useful to you?

formats

Snippet:One iis7 rewrite rules example

Published on November 30, 2012, by in Seo.

When working with server 2008, iis7 will be used. And the rewrite rules are quite different from that on lower version. This is my first time to use iis 7 rewrite, it shows me funny and smart.
The iis7 rewrite rules will be writen by xml, one important and powerful tool for your developing.
The example rewrite rules are for CodeIgniter, the original rules:

The iis7 rewirte rules:

More details about iis7 rewrite rule and steps on how to add rewrite rule on iis7, i recommand you read Creating Rewrite Rules for the URL Rewrite Module.

formats

Tutorial:How to install nodejs on centos 6.3

Published on November 21, 2012, by in Nodejs.

You know, nodejs is very popular.You may want to install the latest nodejs package on your new installed CentOS 6.3.
The nodejs official installation guide have an empty installation introduction for installing the latest version of nodejs.
I am new to linux, so i had to try and try… to show you how to install nodejs v0.8.14 on centos 6.3.
Here is the Debian install process:

It’s obvious that you can also do it like that. I have not the apt package, so i will install it with yum.
First step: download nodejs package

Second step: install compiler
Before you compile the package, you may find lose of compiler.

Last step: compile node
Switch to the nodejs file folder.

That’s will take a long time to compile, and the terminal displays mess of process information.
You can test node by type:

Tags:
formats

Tutorial:Install php 5.4 and mysql 5.5 on nginx

Published on November 21, 2012, by in Linux.

Last day, i had showed you how to install nginx on centos 6.3, as a php developer, i also need to install php and mysql on the server, here i will show you how to install php 5.4 and mysql 5.5 on nginx.
First of all, i learned one new linux command rpm, as we all know that, this command is a powerful package manager for linux, you can find the total usage from rpm command cheat sheet for Linux or RPM Commands.

Why i introduced nrp command first?
When i installed php 5.4 or other rpm packages, i also had some mysql like packages installed, and that caused mysql install failed. When you encountered, you can do this to uninstall the package.

Now, let’s start to setting your php develop environment.

1.Install php 5.4
One thing you should know is that, you will install php-fpm as a system service to control fastCGI. Learn more details about php-fpm and fastCGI.
Add REMI repo:

Install Nginx, PHP 5.3.8 and PHP-FPM and PHP modules:

PHP Module list:
APC (php-pecl-apc) – APC caches and optimizes PHP intermediate code
CLI (php-cli) – Command-line interface for PHP
PEAR (php-pear) – PHP Extension and Application Repository framework
PDO (php-pdo) – A database access abstraction module for PHP applications
MySQL (php-mysql) – A module for PHP applications that use MySQL databases
PostgreSQL (php-pgsql) – A PostgreSQL database module for PHP
MongoDB (php-pecl-mongo) – PHP MongoDB database driver
SQLite (php-sqlite) – Extension for the SQLite V2 Embeddable SQL Database Engine
Memcache (php-pecl-memcache) – Extension to work with the Memcached caching daemon
Memcached (php-pecl-memcached) – Extension to work with the Memcached caching daemon
GD (php-gd) – A module for PHP applications for using the gd graphics library
XML (php-xml) – A module for PHP applications which use XML
MBString (php-mbstring) – A module for PHP applications which need multi-byte string handling
MCrypt (php-mcrypt) – Standard PHP module provides mcrypt library support

Fire up PHP-FPM:

Add PHP-FPM on boot:

2.Install mysql5.5
Add required repo:

I will be installing all of software with Yum.

You have installed php 5.4 and mysql 5.5 on nginx successfully!
I’m new on linux, and it’s very different from other tutorials online about configure your php develop environment, but i made it truthfully, if you have any question, i would like to have mails with you.

Last, append my nginx configuration to this post.



And some more detials about this nginx configuration you can find it here. One tip, I can’t install PHP-FPM this article.

Tags: