Thứ Sáu, 31 tháng 5, 2013

Regular Expressions cơ bản cho php - hay và hữu ích ^^ thank tác giả

Regular Expressions
1. Regular expression là gì?
+ Biểu thức chính quy.
+ Hiểu nôm na là 1 chuỗi có quy tắc để mô tả những chuỗi(string) khác
2. Cú pháp cơ bản (ở đây mình chỉ trình bày và ví dụ cho ngôn ngữ php)
Example:

PHP Code:
<?php
$re 
= '/hello/'; // biểu thức chính quy cho một string có chuỗi “hello” ở trong đó.$str = 'hello world';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
?>
Output: Yes
+ Ký hiệu “^” và “$”: bắt đầu và kết thúc 1 string
Example:
PHP Code:
<?php
$re 
= '/^hello/';  // biểu thức chính quy cho một string bắt đầu bởi chuỗi “hello”$str = 'hello world';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
 else {
    echo 
'No';
}
?>
Output: Yes
PHP Code:
<?php
$re 
= '/hello$/'; // biểu thức chính quy cho một string kết thúc bởi chuỗi “hello”$str = 'hello world';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
 else {
    echo 
'No';
}
?>
Output: No
+ Ký hiệu: “*”, “+”, “?”
$re = '/^ab*$/' ; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là 0 hoặc nhiều b (ví dụ: a, ab, abb, abbb, …);
$re = '/^ab+$/' ; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là 1 hoặc nhiều b (ví dụ: ab, abb, abbb, …);
$re = '/^ab?$/' : // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là b hoặc là không (ví dụ: ab hoặc a).
Example:
PHP Code:
<?php
$re 
= '/^ab*$/'; $str = 'abbc';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
 else {
    echo 
'No';
}
?>
Output: No
+ Sử dụng: {}:
$re = '/^ab{2}$/'; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là 2 chũ b (là abb);
$re = '/^ab{2,}$/'; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là ít nhất 2 chũ b (ví dụ: abb, abbb, abbbb, …);
$re = '/^ab{2,5}$/'; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là ít nhất 2 chũ b và nhiều nhất là 5 chữ b (ví dụ: abb, abbb, abbbb, abbbbb);

+ Sử dụng : () và |
$re = '/^a(bc)*$/'; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là 0 hoặc nhiều 'bc' (ví dụ abc, abcbc, abcbcbcbc, …)
$re = '/^a(b|c)*$/'; // biểu thức chính quy cho một string bắt đầu bởi a, và kết thúc là 0 hoặc nhiều 'b' hoặc nhiều 'c' hoặc 'b' 'c' lẫn lộn :D (ví dụ abc, abbcccccccccc, abccccbbbcbc, …)
+ Sử dụng symbol '.': đại diện cho một ký tự đơn bất kỳ
$re = '/^.{3}$/'; //Biểu thức chính quy cho một chuỗi có đúng 3 ký tự bất kỳ.
PHP Code:
<?php
$re 
= '/^.{3}$/';
 
//Biểu thức chính quy cho một chuỗi có đúng 3 ký tự bất kỳ.$str = '&#%';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
 else {
    echo 
'No';
}
?>
Output: Yes
+ Sử dụng: '-':
[0-9] : Một chữ số
[a-zA-Z]: một ký tự A->Z, a->z
[a-d] : ~ (a|b|c|d)
[^a-zA-Z]: một ký tự không phải là A->Z, a->z
[^0-9]: một ký tự không phải là số
+ Sử dụng: '\'
\d - Chữ số bất kỳ ~ [0-9]
\D - Ký tự bất kỳ không phải là chữ số (ngược với \d) ~ [^0-9]
\w - Ký tự từ a-z, A-Z, hoặc 0-9 ~ [a-zA-Z0-9]
\W - Ngược lại với \w (nghĩa là các ký tự không thuộc các khoảng: a-z, A-Z, hoặc 0-9) ~[^a-zA-Z0-9]
\s - Khoảng trắng (space)
\S - Ký tự bất kỳ không phải là khoảng trắng.

3. Các hàm cơ bản vận dụng regular expression
+ preg_match : http://php.net/manual/en/function.preg-match.php
int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] )
Cơ bản là để tìm kiếm 1 string có làm việc theo một $re.
Ví dụ:
PHP Code:
<?php
$re 
= '/^\w+$/';
 
// một string toàn ký tự A->Z, a->z, 0->9$str = 'quya*';
if(
preg_match($re, $str)) {
    echo 
'Yes';
}
 else {
    echo 
'No';
}
?>
Output: No
+ preg_replace: http://www.php.net/manual/en/function.preg-replace.php
mixed preg_replace ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
Cơ bản là để tìm kiếm trong 1 string những chuỗi có cấu trúc theo $re để thay thế
Ví dụ:
PHP Code:
<?php
$re 
= '/\w+$/';$str = '*quya';
echo 
preg_replace($re, 'hi', $str);?>
Output: *hi
+ preg_split: http://php.net/manual/en/function.preg-split.php
array preg_split ( string $pattern , string $subject [, int $limit = -1 [, int $flags = 0 ]] )
Ví dụ:
Các bạn xem tạm ví dụ ở trong php manual nhé. Mệt rùi.
Để viết ra bài này, mình đã tham khảo nhiều nguồn trên mạng, và kiến thức từ những lần sử dụng regular expressions.
Có zì sai hay chưa đủ thì các bạn pm để mình bổ xung thêm.
Thanks.

Thứ Hai, 27 tháng 5, 2013

Top 5 Best Free Clipboard Manager For Windows

Clipboard Manager is a software program which adds features or functionality to default clipboard of an operating system. A clipboard basically copies the data from the host application, so that it can be pasted anywhere in the computer after closing that application. Now clipboard manager basically stores data which is copied to clipboard. It stores several clips and makes them available from the history whereas the basic clipboard generally deletes the previous clip when a new clip is added. So a clipboard manager allows user to keep multiple clips in the clipboard by enhancing it basic functionality like cut, copy and paste operation; searching for saved data, tagging the clips, storing clips for long-term. Clipboard manager can store data objects, formatted text, URL’s and media content. It increases speed and efficiency of a clipboard which further increases the productivity. Here is a list of five best free software in this category.

1. Spartan Lite Multi Clipboard

Spartan Lite Multi Clipboard is a multi functioning enhanced clipboard for windows. It is a freeware program which can do much more than just copy and paste for you. For example, it can send emails, fill forms, run programs, save addresses, save screen shots, dial telephone numbers, to do lists and bookmark websites etc. It has capacity to store 500 permanent clips. It is easier to find clips or data in this clipboard manager as you can arrange things by color or by position which can then be sorted. Recently saved clips are nicely stored in spreadsheet style. It has a self explanatory and simple interface with a help guide which makes it easier to use.

2. Clipboard Magic

Clipboard Magic is freeware clipboard enhancement software which stores all the copied text once it starts running in your computer. It sits in the system tray and you just have to run this application once, it will then automatically store the copied text while you are working normally at your computer. This clipboard manager greatly improves your productivity as it is loaded with features like text can be edited and added, text drag and drop, clip management and sorting, color coding, items can be back copied to windows clipboard, stores unlimited data, supports multiple language and much more. All in all, this is a customizable and intuitive program which increases your efficiency.

3. Free Clipboard Viewer

Free Clipboard Viewer is a freeware clipboard management program which simply lets you view whatever is there on your clipboard at any point of time and that too in different formats. An online help file for this program is available which helps in making the program easier to use. Free clipboard viewer is a simple program with a simple interface but a very helpful tool for those who frequently use clipboard.

4. M8 Free Multi Clipboard

M8 Free Multi Clipboard is a freeware clipboard manager which will do more than just copy and paste for you. It automatically stores almost everything you cut and paste from the host application once you set it to run in your windows. It is loaded with multiple features. For example, it can save any form of data like text, graphics, image etc; icon stays hidden in the taskbar; customizable keyboard shortcuts; clip management is easier with sorting; color coding and many more. This program has capacity to keep 500 clips and helps a lot in increasing your productivity with its inbuilt features.

5. Pastebin Desktop

Pastebin Desktop is an online clipboard management utility which allows you to store all the copied text online, so that you can use it from anywhere. This application is a freeware which does copy and paste for you in social networking form. Once installed, it sits on system tray and is very easy to use. You need to register on pastebin for using this software.



Thứ Bảy, 25 tháng 5, 2013

Thứ Hai, 20 tháng 5, 2013

Trang web tổng hợp Icon

http://www.iconarchive.com



 

Thứ Bảy, 11 tháng 5, 2013

Thư viện hình nền


 

 Download file

http://www.mediafire.com/?zn34gvbpwcbbh23

Thứ Hai, 6 tháng 5, 2013

Upload nhiều file cùng 1 lúc

 

html

<form action="demo_form.asp" enctype="multipart/form-data"  >
  Select images: <input type="file" name="img" multiple>
  <input type="submit">
</form> 

Function php
forech($_FILE[]){

uploadimg_many
} 

function uploadimg_many($vt,$images, $delpic, $thumb, $thumb_width, $upath) {

    global $max_size, $width;

    if ($delpic == "yes") {

    @unlink("".INCLUDE_PATH."".$upath."/".$images."");

    @unlink("".INCLUDE_PATH."".$upath."/small_".$images."");

    $images = "";

    }

 

    if (is_uploaded_file($_FILES['userfile']['tmp_name'][$vt])) {

        @unlink("".INCLUDE_PATH."".$upath."/".$images."");

    @unlink("".INCLUDE_PATH."".$upath."/small_".$images."");

    $images = "";

        $realname = $_FILES['userfile']['name'][$vt];

    $file_size = $_FILES['userfile']['size'][$vt];

    $file_type = $_FILES['userfile']['type'][$vt];

    $f_name = end(explode(".", $realname));

    $f_extension = strtolower($f_name);

    $loaiimg_ext = array("gif","jpg","jpeg","pjpeg","bmp","png");

    $loaiimg_mime = array("image/gif", "image/pjpeg", "image/jpeg",  "image/bmp",  "image/png");

    if ($file_size > $max_size) {

    info_exit("<br><br><center>"._EROR1." ".$file_size." "._EROR2." $max_size byte.<br><br>"._GOBACK."</center><br><br>");

    }

    if(!in_array($file_type,$loaiimg_mime) || !in_array($f_extension,$loaiimg_ext)) {

        info_exit("<br><br><center>"._EROR6."<br><br>"._GOBACK."</center><br><br>");

    }

    $datakod = date(U).rand();

    $picname = "".$datakod.".nv.".$f_extension."";

    if(! @copy($_FILES['userfile']['tmp_name'][$vt], "".INCLUDE_PATH."".$upath."/".$picname."") ) {

        if (! move_uploaded_file($_FILES['userfile']['tmp_name'][$vt], "".INCLUDE_PATH."".$upath."/".$picname."")) {

            info_exit("<br><br>"._UPLOADFAILED."<br>");

        }

    }

    if (file_exists("".INCLUDE_PATH."".$upath."/".$picname."")) {

    $images = $picname;

    if ($f_extension == "jpg" AND extension_loaded("gd")) {

        $size = @getimagesize("".INCLUDE_PATH."".$upath."/".$images."");

        $thc = 0;

        if ($size[0] > $width) {

            $thc = 1; $sizemoi = $width;

        } elseif($size[0] > $thumb_width AND $size[0] < ($thumb_width+20)) {

            $thc = 1; $sizemoi = $thumb_width;

        }

        if ($thc == 1) {

            $src_img= ImageCreateFromJpeg("".INCLUDE_PATH."".$upath."/".$images."");

            $src_width= ImagesX($src_img);

            $src_height= ImagesY($src_img);

            $dest_width = $sizemoi;

            $dest_height = $src_height/($src_width/$dest_width);

            $dest_img=ImageCreateTrueColor($dest_width, $dest_height);

            ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);

            ImageJpeg($dest_img, "".INCLUDE_PATH."".$upath."/".$images."", 90);

            ImageDestroy($dest_img);

        }

        $size = @getimagesize("".INCLUDE_PATH."".$upath."/".$images."");

        if($thumb==1 AND $size[0] > $thumb_width) {

            $picname_thumb = "small_".$picname."";

            if(! @copy($_FILES['userfile']['tmp_name'][$vt], "".INCLUDE_PATH."".$upath."/".$picname_thumb."") ) {

                @move_uploaded_file($_FILES['userfile']['tmp_name'][$vt], "".INCLUDE_PATH."".$upath."/".$picname_thumb."");

            }

            if (file_exists("".INCLUDE_PATH."".$upath."/".$picname_thumb."")) {

                    $src_img= ImageCreateFromJpeg("".INCLUDE_PATH."".$upath."/".$picname_thumb."");

                    $src_width= ImagesX($src_img);

                    $src_height= ImagesY($src_img);

                    $dest_width = $thumb_width;

                    $dest_height = $src_height/($src_width/$dest_width);

                    $dest_img=ImageCreateTrueColor($dest_width, $dest_height);

                    ImageCopyResampled($dest_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);

                    ImageJpeg($dest_img, "".INCLUDE_PATH."".$upath."/".$picname_thumb."", 90);

                    ImageDestroy($dest_img);

            }

        }

    }

    }

    }

    return($images);

}

Thứ Bảy, 4 tháng 5, 2013

Thứ Sáu, 26 tháng 4, 2013

Get biến từ trang khác dùng file_get_contents()




Filedown http://www.mediafire.com/?lqgu74d3k4n4vkj

Thứ Năm, 25 tháng 4, 2013

Cặp đôi hoàn hảo _ khi chèn title vào video Format Factory + Aegisub

Format Factory + Aegisub






 
 

Tạo file ass


Gắn file vào video









Thứ Tư, 24 tháng 4, 2013

Script popup sử dụng cookie






<script type="text/javascript">
$(document).ready(function() { 

         // cookie cho popup
        if($.cookie("popup")!=1 && $("#dialog .content_popup").html()!=""){

                var id = '#dialog';
           
                //Lấy chiều cao và rộng của màn hình nè
                var maskHeight = $(document).height();
                var maskWidth = $(window).width();
   
                //Rùi định dạng chiều cao và rộng cho cái vùng div chứa cái popup
                $('#mask').css({'width':
maskWidth,'height':maskHeight});
               
                //hiệu ứng xuất hiện   
                $('#mask').fadeIn(1000);
                $('#mask').fadeTo("slow",0.8);
               
                //làm cho cái popup canh phia tren màn hình
                $(id).css('top',  maskHeight/10);       
                $(id).css('left', maskWidth/2-$(id).width()/2);
               
                //hiệu ứng cho cái popup xuất hiện (xuất hiện từ từ trong vòng 2s)
                $(id).fadeIn(2000);    
               
                //Nếu người ta click vào nút close nè
                $('.window .close').click(function (e) {
                        //Cancel the link behavior
                        e.preventDefault()       
                        $('#mask').hide();
                        $('.window').hide();
                });       
               
                //Nếu vùng div id mask được click thì ẩn nó đi nè
                $('#mask').click(function () {
                    $(this).hide();
                    $('.window').hide();
                });       
        }//cookie
        $.cookie("popup",1);
});
</script>

background-box - Colorful




download: http://www.mediafire.com/?40vbzvtlb8876ek

Bkosborne jQuery Waterwheel Carousel













 
 

Thứ Hai, 22 tháng 4, 2013

Công sức ngày 22/4/2013

Hỏi đáp quản lý theo thành viên

Gán trạng thái mặc định của jquery ui ^^

    $.extend($.ui.dialog.prototype.options, {
        modal: true,
        resizable: false,
        draggable: false
    });

Thứ Ba, 16 tháng 4, 2013

Tổng hợp kỹ thuật SEO Website

      SEO đã trở thành một thuật ngữ khá quen thuộc, nhưng để có thể SEO website lên top google và duy trì thứ hạng không phải là điều đơn giản.

    Việc đầu tiên và luôn là đầu tiên đó chính là tên miền. Tên miền luôn là thứ được các cỗ máy tìm kiếm ưu tiên nên chúng ta cần:


    1. Chuẩn bị tên miền (domain)

    1. Tên miền nên phù hợp với sản phẩm hoặc phù hợp với định hướng nội dung từ khóa quan tâm của khách hàng. Ví dụ đăng ký tên miền với nhadangkytenmien.vn
    2. Nếu tên miền không phù hợp thì làm subdomain phù hợp hoặc folder chứa web phù hợp. Ví dụ internetmarketing.inet.vn, onlinemarketing.inet.vn
    3. Bạn nên mua thêm các domain .net .org .biz… và redirect nó về site của bạn

    2. Chuẩn bị nền tảng website

    Nhóm công việc tếp theo, tôi nghĩ là chúng ta nên chọn nền tảng website. Bạn có thể tự làm lấy 1 cái nhưng nó rất mất công. Và không chỉ mất công mà còn thiệt thòi nhiều thứ.
    1. Nếu được nên dùng wordpress
    2. Không thì dùng Jomla
    3. Nếu là diễn đàn thì nên dùng VBB vì nó có công cụ VBBSeo để làm SEO.

Các tool mới




Thứ Năm, 11 tháng 4, 2013

15 Useful jQuery Image Zoom Plugins

1. Featured Image Zoomer

Featured Image Zoomer
This script lets you view a magnified portion of any image upon moving your mouse over it. A magnifying glass appears alongside the image displaying the magnified area on demand. The user can toggle the zoom level by using the mousewheel.  It’s great to use on product images, photos, or other images with lots of details you want users to be able to get into on command.

Thứ Hai, 8 tháng 4, 2013

2 trang web hữu ích cho web design

Icon finder


Colour lovers


40 Incredibly Useful Web Design Tools You Should Use Daily

1. Deviantart

Deviantart is one of the largest artist showcases on internet. You can find some great inspiration here.
%tutke

2. Web design library

Web Design Library is an internationally refereed resource that provides a platform for the dissemination of design thinking and research. It covers all theoretical and practice-oriented aspects of the effective, efficient and attractive presentation of information on-line.
%tutke

CSS Menu Maker - Thư viện menu tiện dụng




  1. http://cssmenumaker.com/css-flyout-menus

Thứ Bảy, 23 tháng 3, 2013

Jquery tooltip





 http://www.mediafire.com/?lcp0c1o1f9b6hok

Up và review hình nhóm sp






http://www.mediafire.com/?32cpyrqt8c5ur59

Thứ Năm, 21 tháng 3, 2013

Thứ Ba, 19 tháng 3, 2013

Thứ Hai, 18 tháng 3, 2013

Một số trang web phối màu






https://kuler.adobe.com




http://colorschemedesigner.com

Trang về webdesign hay

http://webdesignledger.com/


 http://2cweb.vn/




 http://all-free-download.com/free-vector/wedding-background-borders-for-free.html





http://www.webstyleguide.com/wsg3/8-typography/index.html





http://www.ebooks-share.net









http://bloghoctap.com/




Clean html code

http://www.dirtymarkup.com/


Cấu trúc của 1 file gọi ajax tương tác database



Cấu trúc của 1 file gọi ajax tương tác database

Chủ Nhật, 17 tháng 3, 2013

Thứ Tư, 6 tháng 3, 2013

element web

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSyCIqPmsrbiC8EHrJNAmMwWm-31iLxPSMFv5e1E2pYcfRKPQepz1YRes8PR48-sCttps3l4-CWsElg-IwiOim_Ot2Fr3fu05PKIxxtLT0hyaHlFcxM2VDtJQPjuaauqBOSuVgtnOg01DG/s792/New+Folder.jpg

http://www.mediafire.com/?1b5s1i39bbdp91b