Blog2Works

This is the blog of freelance website designer and developer Ben Johnson, with thoughts on design, programming, frameworks, jquery and the latest technology.
  • WAMP Setup Guide

    Author: Ben Johnson

    Tags: , , , , ,

    This is a quick reference guide on setting up WAMP for development on Windows 7 with: Memcached Send Mail 1. Download/Install WAMP. Latest is not always the best and well supported. I had a issue with ionCube only suport 32 bit versions of PHP http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1d-x32.exe/download Apache: 2.2.17MySQL: 5.5.8PHP: 5.3.4 Set auto start: Right click My Computer -> Manager -> Services and Applications -> Services: Enabled services: "wampmysqld/wampapache", right clicking select properties and set to Auto. Also WAMP can sometimes cause conflict with Skype when they try to start together. 2. Memcached Download: http://code.jellycan.com/memcached into: c:\wamp\memcached Edit properties of memechaced.exe set "Run as administrator" Run -> cmd- c:\wamp\memcached\memcached.exe -d install- c:\wamp\memcached\memcached.exe -d start- c:\wamp\memcached\memcached.exe -d runservice -m 512 (increase memory limit) Download: http://code.google.com/p/thinkam/downloads/detail?name=php_memcache-cvs-20090703-5.3-VC6-x86.zipInto: c:\wamp\bin\php\php5.3.4\ext\php_memcache.dll php.ini add: extension=php_memcache.dll (or do this all later) 3. Send Mail Download: http://glob.com.au/sendmail into: c:\wamp\sendmailUpdate setting with your email address or make up a testing gMail account. Ensure you enable the settings in gmail to allow external smtp_server=mail.domain.co.ukauth_username=mail@domain.co.ukauth_password=password;pop3_server=;pop3_username=;pop3_password=hostname= yourdomain.co.uk 3. Set Apache Settings From the WAMP icon on the desktop, left click: Apache -> Apache Modules Enabled the follows, or ensure they are selected: autoindex_module expires_module filter_module headers_module rewrite_module vhost_alias_module (c:\wamp\bin\apache\Apache2.2.17\conf\extras) 4. Set PHP.ini Settings From the WAMP icon on the desktop: PHP -> php.ini (Or manually open from C:\wamp\bin\apache\Apache2.2.17\bin\php.ini) Find/Update the following options. Manily so there is no limit whne importing into phpmyadmin and you can run large utility scripts via the browser. post_max_size = 256Mmax_execution_time = 5000max_input_time = 5000memory_limit = 1000M upload_max_filesize = 750Minclude_path = ".;c:\wamp\www\php\includes"sendmail_path = c:\wamp\sendmail\sendmail.exe –t extension=php_curl.dllextension=php_memcache.dll Create the php include directory: c:\wamp\www\php\includes MySQL Settings: To fix this error: ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA From the WAMP icon open: MySQL -> my.ini Added/replace: log_bin_trust_function_creators = 1lower_case_table_names=2 Fix Apache Auto Index Icons: Edit: c:\wamp\bin\apache\Apache2.2.17\conf\extra\httpd-autoindex.confFind: "/httpd-2.2-x64/icons" or some reference to a locations/folders and replace with: Alias /icons/ "c:/wamp/bin/apache/Apache2.2.17/icons/"     ** MAKE SURE YOU HAVE FORWARD SLASH AT END    <Directory "c:/wamp/bin/apache/Apache2.2.17/icons"> Example vHost: <VirtualHost *>    ServerName www.example.local    ServerAlias example.local *.example.local    DocumentRoot "c:\wamp\www\"    <Directory "c:\wamp\www\">        Options Indexes FollowSymLinks Includes        AllowOverride All        Order allow,deny        Allow from all    </Directory></VirtualHost>


  • Restore address book for Mozilla Thunderbird

    Author: Ben Johnson

    Tags:

    On windows 7: CLOSE THUNDERBIRD. Open the address book from the backup eg: R:backup123\Users\*\AppData\Roaming\Thunderbird\Profiles Select the profile eg: 6sdgakb6.default Find file: abook.mab Select Start menu. Type: %appdata% Open: Thunderbird\Profiles Select the profile eg: 6sdgadf6.default Replace file: abook.mab Open Thunderbird Reference: http://kb.mozillazine.org/Moving_address_books_between_profiles


  • Different types of Domain Names

    Different types of Domain Names There are three main types of domain names: Nominet Domains (.uk): .co.uk .org.uk .me.uk Top Level Domains (TLD’s): .com .net .org .biz .info .mobi .name .eu .tv .cc CentralNic Domains: ae.org .cn.com .de.com .eu.com .gb.com .gb.net .kr.com .qc.com .sa.com .us.com .se.net .se.com .uy.com .br.com .no.com .hu.com .ru.com .jpn.com .uk.net .uk.com .za.com


  • Fix missing icons for autoindex

    Author: Ben Johnson

    Tags:

    When enabling the auto index on WAMP you will need to make a small cahnge to the apache: httpd-autoindex.conf This can be found (apending on your version) here: c:\wamp\bin\apache\Apache2.2.17\conf\extra\httpd-autoindex.conf Find: Alias /icons/ "/apache/icons/" <Directory "/apache/icons/"> Replace: "/apache/icons/" with the absolute path to your Apache Icons directory. E.g: C:/wamp/bin/apache/Apache2.2.21/icons/ Restart APACHE. DONE You need to make sure that you use FORWARD SLASH not BACK SLASH if you are copy/paste from windows.


  • useful VI bash commands

    Author: Ben Johnson

    Tags: , ,

    First of all you need to know how to close vi: ctrl-c : q!   These are some of the basic and most common used command to get you started. :q -> quit :w -> save :q! -> quit and don't save :x -> save and quit :[number] -> go to line number G -> go to end of file dd -> delete line p -> "put" line yy -> "copy" line :s/[searchfor] -> searchu -> undo last type word Further examples can be found at: http://vim.wikia.com/wiki/Best_Vim_Tips http://www.digilife.be/quickreferences/QRC/Vi%20Reference%20Card.pdf


  • PHP Upgrade: Cannot load the ionCube PHP Loader - it was built with configuration 2.2.0, whereas running engine is API220090626,NTS

    Author: Ben Johnson

    Tags: , , ,

    Cannot load the ionCube PHP Loader - it was built with configuration 2.2.0, whereas running engine is API220090626,NTS This PHP error is being caused because IonCube is trying to load the old version. To update this on Debian: EDIT: /etc/php5/conf.d/aa_ioncube.iniFIND: zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.2.soREPLACE: zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.3.so This error was caused when upgrading from PHP 5.2 to 5.3, I wanted to make sure no configuration files was overwritten. So when upgrading via apt-get, I made sure to always select the option for the local configuration files.  


  • Clear browser cache

    Author: Ben Johnson

    Tags:

    In order to speed up web browsing, modern web browsers are built to download web pages and store them locally on your computer's hard drive. So when you visit the same page for a second time, the browser speeds up loading time by loading the page locally from cache instead of downloading everything again. Although storing Internet cache makes web browser faster you sometimes want to overwrite this defualt behaviour, for example to see recent changes made to a webpage you just uploaded. Clearing Cache Memory This is done by doing what is called a "force refresh" by pressing both control and F5 buttons simultaneously on your keyboard (depending on your browser). Depending on your operating system all you need to do is the following key combination: Windows: ctrl + F5 Mac/Apple: Apple + R or command + R Linux: F5 If you find this does not work you can find step by step guides for Chrome, Firefox 3, Firefox 2, Internet Explorer 8, Internet Explorer 7, Internet Explorer 6, Safari.


  • Common MySQL data types

    Author: Ben Johnson

    Tags: , ,

    When designing a new database, each time I have to re-think what types should be used for one or the other columns. So I decided to make my own mainly just for reference but somebody may find this useful. Column Data Type Comment id INT AUTO_INCREMENT, UNSIGNED page name VARCHAR(64)   meta title VARCHAR(150)   meta description VARCHAR(160)   meta keyword VARCHAR(255)   status enum('ENABLED','DISABLED') DEFAULT "DISABLED" featured TINYINT(1) DEFAULT "0" content TEXT username VARCHAR(32) password VARCHAR(64) email address VARCHAR(100) phone/mobile VARCHAR(20) firstname/company VARCHAR(32) address_1 VARCHAR(128) postcode VARCHAR(10) file VARCHAR(255)   price DECIMAL (7,2)  UNSIGNED order INT(11)   ip VARCHAR(15) DEFAULT "0" modified TIMESTAMP on update CURRENT_TIMESTAMP create DATETIME DEFAULT "0000-00-00 00:00:00" forien_key INT(11)  


  • jQuery Selectors

    Author: Ben Johnson

    Jquery Selectors are used to specify which element from the HTML document you would like to use. If you are familuar with CSS 1-3 you will noticed the simularity. All meta-characters ( such as !"#$%&'()*+,./:;<=>?@[\]^`{|}~ ) must be escapes with two backslashes: \\.  All Selector ("*")Select all elements Contains Prefix Selector [name|="value"]Selects elements that have the specified attribute with a value either equal to a given string or starting with that string followed by a hyphen (-). Contains Selector [name*="value"]Selects elements that have the specified attribute with a value containing the a given substring. Contains Word Selector [name~="value"]Selects elements that have the specified attribute with a value containing a given word, delimited by spaces Ends with Selector [name$="value"]Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive. Equals Selector [name="value"]Selects elements that have the specified attribute with a value exactly equal to a certain value. Not Equal Selector [name!="value="]Select elements that either don't have the specified attribute, or do have the specified attribute but not with a certain value Starts with Selector [name^="value"]Selects elements that have the specified attribute with a value beginning exactly with a given string :animated SelectorSelect all elements that are in the progress of an animation at the time the selector is run :button SelectorSelects all button elements and elements of type button. :checkbox SelectorSelects all elements of type checkbox :checked SelectorMatches all elements that are checked Child Selector ("parent > child")Selects all direct child elements specified by "child" of elements specified by "parent" Class Selector (".class")Selects all elements with the given class :contains() SelectorSelect all elements that contain the specified text Descendant Selector ("ancestor descendant")Selects all elements that are descendants of a given ancestor :disabled SelectorSelects all elements that are disabled Element Selector ("element")Select all elements with the given tag name :empty SelectorSelect all elements that have no children (including text nodes) :enabled SelectorSelects all elements that are enabled :eq() SelectorSelect the element at index n within the matched set :even/:odd SelectorSelects even elements, zero-indexed and odd :file SelectorSelect all elements of type file :first-child SelectorSelects all elements that are the first child of their parent. :first SelectoSelects the first matched element. :focus selectorSelects element if it is currently focused. :gt() SelectorSelect all elements at an index greater than index within the matched set. Has Attribute Selector [name]Selects elements that have the specified attribute, with any value. :has() SelectorSelects elements which contain at least one element that matches the specified selector. :header SelectorSelects all elements that are headers, like h1, h2, h3 and so on. :hidden SelectorSelects all elements that are hidden. ID Selector (“#id”)Selects a single element with the given id attribute. :image SelectorSelects all elements of type image. :input SelectorSelects all input, textarea, select and button elements. :last-child SelectorSelects all elements that are the last child of their parent. :last SelectorSelects the last matched element. :lt() SelectorSelect all elements at an index less than index within the matched set. Multiple Attribute Selector [name="value"][name2="value2"]Matches elements that match all of the specified attribute filters. Multiple Selector (“selector1, selector2, selectorN”)Selects the combined results of all the specified selectors. Next Adjacent Selector (“prev + next”)Selects all next elements matching "next" that are immediately preceded by a sibling "prev". Next Siblings Selector (“prev ~ siblings”)Selects all sibling elements that follow after the "prev" element, have the same parent, and match the filtering "siblings" selector. :not() SelectorSelects all elements that do not match the given selector. :nth-child() SelectorSelects all elements that are the nth-child of their parent. :only-child SelectorSelects all elements that are the only child of their parent. :parent SelectorSelect all elements that are the parent of another element, including text nodes. :password SelectorSelects all elements of type password. :radio SelectorSelects all elements of type radio. :reset SelectorSelects all elements of type reset. :selected SelectorSelects all elements that are selected. :submit SelectorSelects all elements of type submit. :text SelectorSelects all elements of type text. :visible SelectorSelects all elements that are visible. Reference Manual: Jquery, W3C http://api.jquery.com/category/selectors/


  • Install SmartyPDT Plugin into Zend Studio

    Author: Ben Johnson

    Tags: , , , , ,

    This guide explains how to install Smarty PDT with Zend Studio. Smarty PDT is a Smarty template syntax colouring, a feature that is not available by default with Zend Studio. Installing Smarty PDT into Zend Studio Be sure to check that the .tpl fule are not associated with any content type. Go to Window -> Prefences -> General -> Content Types Download the latest SmartyPDT .zip (currently 0.9.0) from http://code.google.com/p/smartypdt/ Go to Help -> Install New Software Click Add then click Archive button and select the .zip downloaded previously By default the Group item by category ensure you unselect this Click Next, accept the condition and restart Zend Studio If you are prompted that this is an unsigned package, just ignore the warning and install it anyway. Right click on the PHP project in the PHP Explorer and Select Configure -> Add Smarty Support Update/Fixes if this does not work by default Check you have the Smarty Editor selected as default for *tpl file in File Association in Preferences -> Ceneral -> Editors -> File Associations If after restarting Zend Studio you may find that the .tpl file type is locked. The only option I found was to remove the .tpl directly from the plugin PDT.  Firstly close Zend Studio to edit the core files:Go to the plugins folder where Zend Studio is installed (Mine was C:\\Program Files\Zend\Zend Studio - 8.0.0\plugins File the file org.eclipse.php.core_2.2.1.vxxxxxxxx-xxxx.jar - the exact version of the plugin may change with updates to the PDT You can infact open this file as a normal archieve file just like a .zip file. Right click a select open with is this does not open by default, if this does not work try renaming the file extension. Extract all the file and edit the the plugin.xml file Search for "tpl", this was line number 53 and remove "tpl" from the list



1 2 3 4