$ source .bash_profile
Wednesday, May 9, 2012
PEAR/PECL MAMP 2.x Error : Notice: unserialize()
When i run my pecl/pear from MAMP bin folder , i got error message :
Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.
Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050
ERROR: The default config file is not a valid config file or is corrupted.
to fix :
- Remove the pear.conf in MAMP folder OR
- Find pear.conf, edit and change the "php_dir";s:44 into "php_dir";s:43
How to add python path to import external module (tested on python 2.7 mac osx)
option #1 : using site-packages folder
The location of python 2.7 framework is in /Library , this is different with python 2.6 which is installed in /System/Library. So inside the python framework folder , find the site-packages folder :
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
you can (choose one) :
- put any external modules here, python will look up external modules from here automatically OR
- keep the external modules in any folder you want , then in the 'site-packages' folder above, put/create any text file and name it <name>.pth , you can use any generic name like : mypath.pth etc. Then inside this file , type your path where the modules are located
Now open python shell and type module you want to import. ex: import myModule
option #2 : sys module
in the python file, add these code :
import sys
sys.path.append(path_to_modules) #ex: sys.path.append('/data/lib')
import <myModules_name> #test calling/import module
you can insert path into the beginning of the path list, by insert to index(0) :
sys.path.insert(0, path_to_module)
option #3 : .bash_profile
add these code into .bash_profile
# add python path
PYTHONPATH='path_to_modules_folder : $PYTHONPATH'
export PYTHONPATH
or
export PYTHONPATH = "/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/"
Tuesday, May 8, 2012
Metacharacter in Linux Regular Expression
Note : * and ? in grep means repetition. It does not behave as a wildcard in regular expression syntax (as it is in UNIX or DOS patterns). The * / ? / + are part of regex metacharacter.
*literal means normal character (not metacharacter or escape or any other special character) , so it will be interpreted as is.
source : http://www.zytrax.com/tech/web/regex.htm#more-notes
Metacharacter | Meaning |
| ? | 0 or 1 o? matches '' or 'o' but not 'oo' bo?k matches : bk, bok but doesn't match : book,booooook |
| * | 0 or more a* matches '' , 'a' , 'aa' , 'aaa' ga*z matches : gz, gaz, gaaz, gaaaz but doesn't match : goz,giz |
| + | 1 or more u+ matches 'u', 'uuu' but not '' mu+te matches : mute,muute but not : mte,mate |
| {n} | Matches the preceding character, or character range, n times exactly, for example, to find a local phone number we could use [0-9]{3}-[0-9]{4} which would find any number of the form 123-4567. Note: The - (dash) in this case, because it is outside the square brackets, is a literal*. Value is enclosed in braces (curly brackets). |
| {n,m} | Matches the preceding character at least n times but not more than m times, for example, 'ba{2,3}b' will find 'baab' and 'baaab' but NOT 'bab' or 'baaaab'. Values are enclosed in braces (curly brackets). |
source : http://www.zytrax.com/tech/web/regex.htm#more-notes
how to setup PHP remote debug using komodo IDE & xdebug in Mac OS X
Step 1 - Copy the Debugging Extension to the Web Server
Before debugging PHP scripts in Komodo, PHP must be configured to use the Xdebug extension (php_xdebug.dll or xdebug.so).
Find the appropriate extension for the version of PHP you are running and manually copy it into a directory on the server that the PHP interpreter and web server can access. The Xdebug files can be found in the php sub-directory of the Komodo installation. For example:
- File:
xdebug.so - Location:
<komodo-install-directory>/Contents/SharedSupport/lib/support/php/debugging/<PHP-version>/
zend_extension_tsorzend_extension- Should be set to the full path to the xdebug library on your system. Use
zend_extension_ts("thread safe") on Windows andzend_extensionon other platforms. xdebug.remote_enable- Enables remote debugging.
xdebug.remote_handler- Should be set to
dbgpfor use with Komodo. xdebug.remote_mode- Set to
reqto have the script connect to Komodo when it starts. Set tojitto connect only on an error condition (see PHP Just-in-Time Debugging / Break on Exception). xdebug.remote_host- Set to the hostname or IP address of the computer running Komodo or the DBGP Proxy. Use 'localhost' or '127.0.0.1' if Komodo and the web server are running on the same system.
xdebug.remote_port- Set to the same value as the debugging listener port configured in the Debugger Connection preferences (or the system assigned Host Port displayed under Debug|Listener Status)
xdebug.idekey(optional)- If you are using the DBGP Proxy, set this to the Proxy Key configured in the Debugger Connection preferences.
Once the php.ini file is updated, verify that Xdebug is configured by running the following command:
Starting and Stopping a PHP Remote Debugging Session
Once remote PHP debugging is configured, the PHP interpreter can contact Komodo and initiate a remote debugging session when a PHP script is executed on the web server.
To initiate remote debugging from a web browser:
- Ensure PHP is installed and configured properly for your web server.
- Ensure Komodo and PHP are configured for remote debugging (as described in "Configuring Remote PHP Debugging").
- Click Debug | Listen for Debugger Connections.
- In your browser, enter the URL of the script you want to debug. Append
?XDEBUG_SESSION_START=1to the end of the URL (an HTTP GET with a true boolean value). For example:http://example.org/sample.php?XDEBUG_SESSION_START=1
If you are using the DBGP Proxy, the value for the GET method should match the Proxy Key value shown in Debug|Listener Status. For example:http://example.org/sample.php?XDEBUG_SESSION_START=jdoe
It is also possible to callXDEBUG_SESSION_STARTby adding it in aninputelement of an HTML form. For example:<input type="hidden" name="XDEBUG_SESSION_START" value="jdoe" />
Note: This is only required for the first request. After that, Xdebug tracks the debugging session with a cookie. For more information on how this works, see www.xdebug.org/docs-debugger.php#browser_session - A PHP debugging session starts in Komodo. On the Debug menu, click Step In or Go/Continue to run to the first breakpoint.
Subscribe to:
Posts (Atom)