PVA – Archives

Sưu tầm những bài viết hay trên internet…

(Vim) Find by file content In Your Project

From: http://lostechies.com/derickbailey/2010/05/11/vim-grep-find-all-occurrences-of-text-in-your-project/

The search pattern is as easy as any other / search, with a few different options:

:vim[grep][!] /{pattern}/[g][j] {file} ...
  • The /pattern/ is a standard vim search pattern
  • The “g” option find all matches – including multiple matches on the same line.
  • The “j” option turns off the auto-goto first match feature.
  • The file list allows you to specify individual files, or wild-card searches, including recursive search with file globs

There are a lot of great tips and tricks on that wikia page. You’ll want to read up on them to get an idea of what you can really do with this.

Read more of this post

PHP Formatter in eclipse

https://github.com/dmeybohm/Eclipse-PHP-Formatter/tree/master/bin

http://sourceforge.jp/users/atlanto/pf/eclipse/files/?id=752  (go to “misc” folder)

Zend Captcha is not shown – Zend 1.11.9 issue

From: http://stackoverflow.com/questions/6726987/zend-1-11-9-form-decorators-captcha. Thank to Koncz Szabolcs

Solution: add ‘decorators’ to the options of teh captcha and had to specify there all the decorators.

//Add a captcha    
$this->addElement('captcha', 'captcha',
 array(        
 'label'      => 'Please enter the 5 letters displayed below:',        
 'required'   => true,        
 'captcha'    => array(            
 'captcha' => 'Figlet',            
 'wordLen' => 5,            
 'timeout' => 300        
 ),         
 'decorators' => array('Captcha', 'Errors', 'Labels', etc)    
)); 

Cannot change Apache default Document Root

I changed apache default DocumentRoot (/srv/http) to another place (/home/pva/www) but I got Error 403. Follow this post, I discovered that my home folder have 700 permission. So I had to change it to 755 then the problem has been solved.

cài đặt YAOURT trong Achlinux

From: http://tutroc77.blogspot.com/2010/07/repoarchlinuxfr-kho-bo-xung-cho.html

Địa chỉ kho: http://repo.archlinux.fr

Kho này có nhiều gói phần mềm hay, như gói “yaourt” (bình thường phải cài gói này thông qua AUR), hay gói “bin32-wine” (WINE 32-bit dành cho Archlinux x86_84)

Thêm kho này bằng cách sửa file /etc/pacman.conf

# nano /etc/pacman.conf

Đối với Archlinux 32-bit, thêm vào cuối 2 dòng sau:

[archlinuxfr]
Server = http://repo.archlinux.fr/i686

Đối với Archlinux 64-bit, thêm vào cuối 2 dòng sau:

[archlinuxfr]
Server = http://repo.archlinux.fr/x86_64

Bây giờ, để cài đặt YAOURT, chỉ cần dùng pacman:

# pacman -Sy
# pacman -S yaourt

Thật đơn giản

show all error in Social Engine 4

Search the following in application/index.php

// Main app
else {

Then add the following after that

ini_set(‘error_reporting’,-1);
ini_set(‘display_errors’,1);
ini_set(‘display_startup_errors’,1);

gnome3 – No default terminal command has been defined

Description of problem:
Modify keyboard settings, shortcut and set Alt-t to launch terminal. Close,
pres Alt-t and adialog saying "No terminal command has been defined".

Version-Release number of selected component (if applicable):
Fedora 16 Beta

How reproducible:

Steps to Reproduce:
1. Launch Settings Keyboard
2. Modify shortcut for launching terminal to Alt-T
3. Pres Alt-T

Actual results:
Error dialog

Expected results:
Launching new instance of terminal

How did i fix it?
gconftool-2 --type=string --set "/desktop/gnome/applications/terminal/exec" "gnome-terminal"

Auto link – Php automatic plain text to link conversion

function makeClickableLinks($text) {

$text = eregi_replace(‘(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)’,
‘<a href=”\\1″>\\1</a>’, $text);
$text = eregi_replace(‘([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)’,
‘\\1<a href=”http://\\2″>\\2</a>’, $text);
$text = eregi_replace(‘([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})’,
‘<a href=”mailto:\\1″>\\1</a>’, $text);

return $text;

}

Read more of this post

Regex (regular expression) to match a URL

http://snipplr.com/view/2371/

http://snipplr.com/view/36992/improvement-of-url-interpretation-with-regex/

function link($text){
return preg_replace(‘@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@’, ‘<a href=”$1″>$1</a>’, $text);
}

or

$text = preg_replace(‘@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@’, ‘<a href=”$1″>$1</a>’, $text);

resize image using imagecopyresampled function in php

From: http://imagecopyresampled.r3.sk/

(PHP 4 >= 4.0.6, PHP 5)

imagecopyresampled — Copy and resize part of an image with resampling

Description

bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )

imagecopyresampled() copies a rectangular portion of one image to another image, smoothly interpolating pixel values so that, in particular, reducing the size of an image still retains a great deal of clarity.

In other words, imagecopyresampled() will take an rectangular area from src_image of width src_w and height src_h at position (src_x,src_y) and place it in a rectangular area of dst_image of width dst_w and height dst_h at position (dst_x,dst_y).

If the source and destination coordinates and width and heights differ, appropriate stretching or shrinking of the image fragment will be performed. The coordinates refer to the upper left corner. This function can be used to copy regions within the same image (if dst_image is the same as src_image) but if the regions overlap the results will be unpredictable. Read more of this post

Follow

Get every new post delivered to your Inbox.