Snippets

Here's some of my tips, tweaks and tuts, ranging from PHP, Linux, MySQL and more!

Snippets / PhoneGap

Virtual Keyboard PhoneGap Overlapping Content

Recently I came across a problem when building a mobile app with a form. When I focused on a lt;input> element the keyboard just completely overlapped all the majority of the content and made it near impossible to see what you were writing. First I added a preference for the keyboard setting in my config.xml and this worked in the lat...

20th Feb, 2014 | » Read more Snippets like this | » Read More

Snippets / PhoneGap

Config changes hydrated apps (PhoneGap Build)

It took me a while to figure out that if you have a app with hydration enabled on PhoneGap Build, it will not display any significant changes you make to the config.xml without completely re-building the app or deleting and re-adding it. Delete the App Re-Add the App ...

15th Feb, 2014 | » Read more Snippets like this | » Read More

Snippets / PhoneGap

Play local audio on iOS device with PhoneGap

Recently I had a problem getting audio files to play in iOS with PhoneGap (2.9.0) while it was working perfectly fine on android devices. Here's the example code I was using: // console audio after playing function audio_win(response) { console.log('Audio FAILED' + response); } function audio_fail(response) { console.log('Audio WINNER...

11th Feb, 2014 | » Read more Snippets like this | » Read More

Snippets / JavaScript

List all global variables in JavaScript

An easy way to list all of the global variables available the window object: keys(window); // returns array obj // ["window", "location", "external", "chrome", "document", "$", "jQuery", "_gaq"] ...

1st Feb, 2014 | » Read more Snippets like this | » Read More

Snippets / Plesk

Outgoing Mail Treated as "local" Plesk

So I originally came across this problem with a PLESK server I was maintaining. For this example we can call it domain.com. However, the MX records for domain.com are NOT set to the plesk server but to other external servers. (So there's no need for PLESK to handle mail) This domain.com's mail settings in PLESK were also disabled. I...

12th Jun, 2012 | » Read more Snippets like this | » Read More

Snippets / Linux

Fix: Firewall is stopped (iptables) in linux

I came across this quick fix when trying to restart the firewall for my linux box. $ service iptables status Firewall is stopped. Trying to start it? The obvious solution was to just do service iptables start but this didnt do anything. Solution We just need to save the firewall rules before we start the service. ...

25th Apr, 2012 | » Read more Snippets like this | » Read More

Snippets / MySQL

Exclude "The", "An" & "A" from MYSQL Ordered list

The aim was to display results from my database in alphabetical order and not having words such "an" or "the" to impact on the alphabetical order (similar to iTunes album order). So for example The Doors would be displayed in the "D" artists A Solution (Slow one) One way of doing this I thought we could trim the appending name...

6th Dec, 2011 | » Read more Snippets like this | » Read More

Snippets / MySQL

Delete Duplicate Rows in MySQL

Over time tables can contain duplicate entries, one of the main reasons is the system inserting the data is either not preparing it correctly, or not checking against existing records. The Statement Before you run the query make sure you backup the table as it will remove data, an extra check you could always do a SELECT query inste...

11th Oct, 2011 | » Read more Snippets like this | » Read More

Snippets / HTML

Use PHP to round up to a nearest multiple

With this handy little function you can easily round up a given number to the nearest multiple of your choice. The function /** * Round up to the nearest multiple of your choice. * * @param int $number * @param int $near * @return int */ function get_nearest_multiple( $number, $near ) { $nearest = round($numbe...

6th Oct, 2011 | » Read more Snippets like this | » Read More

Snippets / Linux

Copy files from one linux machine to another

It's fairly easy to transfer files from one Linux server to another using the scp command. An example scp -pv user@123.456.78:source-file.tar /home/user/source-file.tar Options -p Preserves the modification and access times, as well as the permissions of the source-file in the destination-file -q Do not display th...

4th Oct, 2011 | » Read more Snippets like this | » Read More