Friday 29 May 2015

Inside the array literal, add three object literals. In other words, the objects array should have three values. Each object should have 2 property/value pairs.

var objects = [
  {
    object: 'Car',
    description: 'A2B'    
  }, 
  {
    object: 'Surfboard',
    description: 'Fun'   
  }, 
  {
    object: 'house',
    description: 'home' 
  } 
];

 

Tuesday 19 May 2015

Drupal zend server 'The specified file temporary://* could not be copied '

The specified file temporary://f* could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.



In Drupal 7 Admistration Go to the Media paths configurations.

> /admin/config/media/file-system

Set up the ‘Temporary Directory’ 

for example ‘/tmp’ 


In the scenario you’ll need to create and chmod a folder to 755 

ZendServer_init has not been started because it does not have the proper security settings

Here's the error I'm getting

“Library/StartupItems/ZendServer_init” has not been started because it does not have the proper security settings.  

And in the log file a 'zend server fix Symbolic links issue' warning.



I'm using Mac OsX Mavericks


$ ls -la /Library/StartupItems/ZendServer_init
total 32
drwxr-xr-x 5 root zend 170 Oct 28 11:44 .
drwxr-xr-x 3 root wheel 102 Nov 12 12:59 ..
-rw-r--r-- 1 root zend 274 Oct 3 2011 StartupParameters.plist
-rwxr-xr-x 1 root zend 312 Oct 3 2011 ZendServer_init
-rwxr-xr-x 1 root zend 5097 Mar 11 2013 zendctl.sh

$ sudo chown -R root:wheel /Library/StartupItems/ZendServer_init

$ ls -la /Library/StartupItems/ZendServer_init
total 32
drwxr-xr-x 5 root wheel 170 Jun 25 08:20 .
drwxr-xr-x 4 root wheel 136 Oct 31 11:45 ..
-rw-r--r-- 1 root wheel 274 Oct 3 2011 StartupParameters.plist
-rwxr-xr-x 1 root wheel 312 Oct 3 2011 ZendServer_init
-rwxr-xr-x 1 root wheel 5097 Mar 11 2013 zendctl.sh

Monday 18 May 2015

MaxMinds GeoIp could be the solution for you if you want to run country specific redirects.



First off you’ll need to get a License Key.  

In your index.php ( or sub category etc that you want to redirect from )


At the top of this page call the JavaScript file from MaxMind . 


First of all lets make a variable called ‘redirect’ and implement the redirection 

var redirect = (function () {


Next up lets build the URL . To do this we make a variable call ‘redirectBrowser’  and inside that pass a Site variable to build the uri . The site variable will be assigned once we’ve made decision on which countries IP we are passing onto.   Here’s that variable and it’s function. 

var redirectBrowser = function (site) {
  var uri = "http://" + site;
  window.location = uri;
};

The variable ‘sites’ which is different to ‘site’  is an array of all the country codes we’ll be using.   You can find a list of the ‘Maxmind Country Codes’ here. 


In the following code I assign Nordic IPs and GB.  

var sites = {
  "no": true,
  "se": true,
  "gb": true,
  "dk": true,
  "fi": true
};

Change these to Lower Case

var code = geoipResponse.country.iso_code.toLowerCase();

Let’s have a look at this example .  As long as the sites are listed in the county codes then if they have no redirect here then they’ll stay on the existing website.  Otherwise they’ll be forwarded to the ‘else’ redirect. 

if ( sites[code] ) {

  if (code == 'gb'){
    var site = “theukwebsite.co.uk"
      redirectBrowser(site);
  }
}
else {
  redirectBrowser(“theworldwidewebwebsite.com");
}

So eventhough we don’t mention the Nordic countries here they will still be dealt with differently to countries that aren’t listed in the ‘sites’ variable. 

Let’s add onError forwarding also.  So here’s the full code. 

var redirect = (function () {
  /* This implements the actual redirection. */
  var redirectBrowser = function (site) {
    var uri = "http://" + site;
    window.location = uri;
  };

  /* These are the country codes for the countries we have sites for.
   * We will check to see if a visitor is coming from one of these countries.
   * If they are, we redirect them to the country-specific site. If not, we
   * redirect them to world.example.com */
  var sites = {
    "no": true,
    "se": true,
    "gb": true,
    "dk": true,
    "fi": true
  };
  var defaultSite = "gb";

  var onSuccess = function (geoipResponse) {
    /* There's no guarantee that a successful response object
     * has any particular property, so we need to code defensively. */
    if (!geoipResponse.country.iso_code) {
      redirectBrowser("gb");
      return;
    }

    /* ISO country codes are in upper case. */
    var code = geoipResponse.country.iso_code.toLowerCase();

    if ( sites[code] ) {

  if (code == 'gb'){
    var site = “theukwebsite.co.uk"
      redirectBrowser(site);
  }
}
else {
  redirectBrowser(“theworldwidewebwebsite.com");
}

  /* We don't really care what the error is, we'll send them
   * to the default site. */
  var onError = function (error) {
    redirectBrowser("theworldwidewebwebsite.com
");
  };

  return function () {
    geoip2.country( onSuccess, onError );
  };
}());

redirect();

Tuesday 12 May 2015

zend server how to find my web server document root directory on Mac OS X

Explains that a default installation of Zend installs at 


usr/local/zend/apache2/htdocs/

mac Mamp issue - Do you already have another mysqld server running on port: 3306

I’m using Mamp and am setting up Zend Server Z-Ray.  After installation I noticed the SQL on my other site ( running on MAMP ) failed. 

To fix this in MAMP - 

Click on the General tab.  

In Mysql Port -> select a new number > valid numbers are from 1024 to 65535


Monday 11 May 2015

How to turn off jshint on grunt.js .

Near the end of the Gruntfile.js file we have the code 

grunt.registerTask('build', [
  'compass:dist',
    'jshint'
]);


Changing this to 


grunt.registerTask('build', [
  'compass:dist',
    'jshint'
]);

solved my issue.