Visit my new Wedding DJ Service in the Bristol area
Offering one of the best Wedding DJ Services in Bristol and Somerset
You can get an instant availability check and book online at my website.
Offering the best possible service at the best possible prices using state of the are DJ audio and lighting technologies to wow your guests.
Make sure your visit Wedding DJ Bristol to get your quote today.
Monday, 25 February 2019
Monday, 12 September 2016
PHP 7.0 ZendDebugger.so for 64bit Linux
It's really hard to find ZendDebugger.so for php7.0 linux, but here it is:
ZendDebugger.so PHP7.0
; Specifies the hosts that are allowed to connect (hostmask list) with Zend Debugger when running a remote debug session with Zend Studio zend_debugger.allow_hosts=127.0.0.0/8,<YOUR IP ADDRESS> ; Specifies the hosts that are not allowed to connect (hostmask list) with the Zend Debugger when running a remote debug session with Zend Studio zend_debugger.deny_hosts= ; A list of hosts (hostmask list) that can use the machine on which Zend Server is installed to create a communication tunnel for remote debgging with Zend Studio. This is done to solve firewall connectivity limitations zend_debugger.allow_tunnel= ; The user ID of the httpd process that runs the Zend Debugger (only for tunneling) zend_debugger.httpd_uid=-1 ; A range of ports that the communication tunnel can use. This defines the minimum value for the range zend_debugger.tunnel_min_port=1024 ; A range of ports that the communication tunnel can use. This defines the maximum value for the range zend_debugger.tunnel_max_port=65535 ; Define whether to expose the presence of the Zend Debugger to remote clients zend_debugger.expose_remotely=2 ; The Debugger's timeout period (in seconds) to wait for a response from the client (Zend Studio) (units: seconds) zend_debugger.passive_mode_timeout=20 ; Enables fast time sampling which is dependent on CPU cycles and frequency, otherwise, the directive uses operating system timing (which may be less accurate) zend_debugger.use_fast_timestamp=1 ; Enable code-coverage feature, should only be true on local debugger zend_debugger.enable_coverage=1 zend_debugger.xdebug_compatible_coverage=0
Tuesday, 26 July 2016
How to decode encoded html entities in javascript:
<?php
/**
* Decode a string with encoded characters like &
* @param string encodedString - string to encode
* @return string
*/
function decodeEntities(encodedString) {
var textArea = document.createElement('textarea');
textArea.innerHTML = encodedString;
return textArea.value;
}
console.log(decodeEntities("Keith & Hards"));
output: "Keith & Hards"
Wednesday, 20 July 2016
Passing JSON into php function as a parameter
Here is an example of hot to pass JSON into a php function as a parameter:
<?php
function print_details($json) {
$args = json_decode($json);
echo "My first name is {$args->first_name}<br />";
echo "My last name is {$args->last_name}<br />";
echo "My age is {$args->age}<br />";
}
print_details('{
"first_name": "keith",
"last_name": "hards",
"age": 37
}');
Wednesday, 6 July 2016
Thursday, 5 May 2016
Some examples of using PHP CURL under various circumstances including cookies and callback's
https://curl.haxx.se/libcurl/php/examples/callbacks.html
https://curl.haxx.se/libcurl/php/examples/callbacks.html
Thursday, 5 November 2015
Enable Fast and unsecure Ciphers on Recent Versions of OpenSSH
When trying to use webdrive and turnkey lamp I couldn't connect over SFTP. It turns out this is because by default turnkey lamp 14.0 has secure ciphers and webdrive does not support these.
So I added this to
/etc/ssh/sshd_config:Ciphers 3des-cbc,blowfish-cbc,cast128-cbc,arcfour,arcfour128,arcfour256,aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
Friday, 16 October 2015
How to change composers install path
If you need to install composer modules to a custom install path other than vendors, then add the following to your config substituting XXXX/XXXXX to the custom install path that you require.
"config": {
"vendor-dir": "XXXX/XXXXX"
},
Thursday, 10 September 2015
Zend Server Optimizer+ cache problems
If Zend Optimizer is caching your files and new changes are not reflected when the code is running, in PHP you can call:
accelerator_reset()
This will clear the Optimizer cache.
http://files.zend.com/help/Zend-Server-5/zend_optimizer+_-_php_api.htm
accelerator_reset()
This will clear the Optimizer cache.
http://files.zend.com/help/Zend-Server-5/zend_optimizer+_-_php_api.htm
Debugging PHP constants
Handy tip:
If you'r bodded down in old legacy PHP code and you need to know what constants are defined at any point during execution, simply call:
You can either add this to Zend Debugger as an expression or error_log with print_r it.
Thursday, 27 November 2014
Listing running crontab tasks and killing them
- ps -o pid,sess,cmd afx | grep -A20 "cron$"
3693 3693 /usr/sbin/cron
27050 3693 \_ /USR/SBIN/CRON
27055 27055 \_ /bin/sh -c /var/somescript
27058 27055 \_ /bin/sh -c /var/somescript
3706 3706 /usr/sbin/dovecot -c /etc/dovecot/dovecot.conf
3730 3706 \_ dovecot-auth
3737 3706 \_ dovecot-auth -w
902 3706 \_ imap-login
1339 3706 \_ imap-login
2398 3706 \_ pop3-login
2649 3706 \_ pop3-login
2837 3706 \_ pop3-login
2838 3706 \_ imap-login
3807 3807 pure-ftpd
Find the process you want above
- pkill -s 27055
That's it.
Thursday, 25 September 2014
Password-less login over SSH
You can login to a remote Linux server without entering password using ssky-keygen and ssh-copy-id.
ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file.
ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.
1, Create public and private keys using ssh-key-gen on local-host
me@local-host$ ssh-keygen
me@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
me@remote-host's password:
Now try logging into the machine, with
Login to remote-host without entering the password
me@local-host$ ssh remote-host
Last login: Sun Nov 15 12:22:33 2008 from 191.128.6.2
me@remote-host$ [Note: You are on remote-host here]
ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host’s public key to the remote-host’s authorized_keys file.
ssh-copy-id also assigns proper permission to the remote-host’s home, ~/.ssh, and ~/.ssh/authorized_keys.
1, Create public and private keys using ssh-key-gen on local-host
me@local-host$ ssh-keygen
Generating public/private rsa key pair.Step 2: Copy the public key to remote-host using ssh-copy-id
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host
me@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
me@remote-host's password:
Now try logging into the machine, with
ssh 'remote-host'"check in .ssh/authorized_keys
Login to remote-host without entering the password
me@local-host$ ssh remote-host
Last login: Sun Nov 15 12:22:33 2008 from 191.128.6.2
me@remote-host$ [Note: You are on remote-host here]
Sunday, 10 August 2014
Regex way of saying "search until X but not including X" is:
Regex way of saying "search until X but not including X" is:
(?:(?!X).)*
where
This is using a lookahead assertion, more specifically a negative lookahead. Explanation:
(?:(?!X).)*
where
X can be any regular expression.This is using a lookahead assertion, more specifically a negative lookahead. Explanation:
(?: # Match the following any number of times: (?!lazy) # (first assert that it's not possible to match "lazy" here
. # then match any character
)* # end of group, zero or more repetitions.Tuesday, 29 July 2014
PHP onject to array
Handy bit of PHP to convert and object to an array
public function objectToArray($obj)
{
if(!is_array($obj) && !is_object($obj))
return $obj;
if(is_object($obj))
$obj = get_object_vars($obj);
return array_map(array($this, 'objectToArray'), $obj);
}
Wednesday, 23 July 2014
Mobile DJ site for Somerset and Bristol.
The website for Keith Hards Wedding and Mobile DJ Somerset is now live, bookings can be made from January 2015. I will be available throughout Somerset and Bristol, have an all new setup including 8 scanner lights, Wharfedale Pro sound system and windup truss system.
Tuesday, 24 June 2014
VMware network problem after sleep and wakeup on windows
After putting your windows machine to sleep and waking up, you will most likely find that the networking no longer works. I have encountered this problem on several machines.
Not to fear I have a solution.
Create a windows batch file .bat and insert the following commands. These commands will reset the VMware network adaptor.
Not to fear I have a solution.
Create a windows batch file .bat and insert the following commands. These commands will reset the VMware network adaptor.
net stop vmnetbridge
net start vmnetbridge
pause
You will need to execute the batch file as Administrator
Wednesday, 11 June 2014
Shameless plug for my fathers online model engine store
My dad's online model engine shop nitrosteamengines.co.uk looks like it needs a bit of an update. It's time to drop oscommerce as good as it's been over the last 5/6 years!
Time to investigate Magento, OpenCart and Zen Cart to see if they will offer a better solution.
Time to investigate Magento, OpenCart and Zen Cart to see if they will offer a better solution.
Monday, 24 February 2014
PHP Array to stdClass <–> stdClass to Array
Function to Convert stdClass Objects to Multidimensional Arrays
<?php function objectToArray($d) { if (is_object($d)) { // Gets the properties of the given object // with get_object_vars function $d = get_object_vars($d); } if (is_array($d)) { /* * Return array converted to object * Using __FUNCTION__ (Magic constant) * for recursive call */ return array_map(__FUNCTION__, $d); } else { // Return array return $d; } } ?> |
Function to Convert Multidimensional Arrays to stdClass Objects
<?php function arrayToObject($d) { if (is_array($d)) { /* * Return array converted to object * Using __FUNCTION__ (Magic constant) * for recursive call */ return (object) array_map(__FUNCTION__, $d); } else { // Return object return $d; } } ?> |
Function usage
// Create new stdClass Object $init = new stdClass; // Add some test data $init->foo = "Test data"; $init->bar = new stdClass; $init->bar->baaz = "Testing"; $init->bar->fooz = new stdClass; $init->bar->fooz->baz = "Testing again"; $init->foox = "Just test"; // Convert array to object and then object back to array $array = objectToArray($init); $object = arrayToObject($array); // Print objects and array print_r($init); echo "\n"; print_r($array); echo "\n"; print_r($object); |
Test output:
stdClass Object
(
[foo] => Test data
[bar] => stdClass Object
(
[baaz] => Testing
[fooz] => stdClass Object
(
[baz] => Testing again
)
)
[foox] => Just test
)
Array
(
[foo] => Test data
[bar] => Array
(
[baaz] => Testing
[fooz] => Array
(
[baz] => Testing again
)
)
[foox] => Just test
)
stdClass Object
(
[foo] => Test data
[bar] => stdClass Object
(
[baaz] => Testing
[fooz] => stdClass Object
(
[baz] => Testing again
)
)
[foox] => Just test
)
Wednesday, 15 January 2014
Mutex's and Semaphores - The toilet Example.
Mutex:
Is a key to a toilet. One person can have the key - occupy the toilet - at the time. When finished, the person gives (frees) the key to the next person in the queue.
Officially: "Mutexes are typically used to serialise access to a section of re-entrant code that cannot be executed concurrently by more than one thread. A mutex object only allows one thread into a controlled section, forcing other threads which attempt to gain access to that section to wait until the first thread has exited from that section." Ref: Symbian Developer Library
(A mutex is really a semaphore with value 1.)
Semaphore:
Is the number of free identical toilet keys. Example, say we have four toilets with identical locks and keys. The semaphore count - the count of keys - is set to 4 at beginning (all four toilets are free), then the count value is decremented as people are coming in. If all toilets are full, ie. there are no free keys left, the semaphore count is 0. Now, when eq. one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next person in the queue.
Officially: "A semaphore restricts the number of simultaneous users of a shared resource up to a maximum number. Threads can request access to the resource (decrementing the semaphore), and can signal that they have finished using the resource (incrementing the semaphore)." Ref: Symbian Developer Library
Tuesday, 7 January 2014
Subscribe to:
Posts (Atom)

