jQuery get list of form element ids as text

Here is a little JavaScript snippet to run in a browsers console – I created this to a form and lists the ids of all the form elements (so I could do things with them in PHP)

var temp;
$(':input').each(function () {temp += "'" + ($(this).attr('id')) + "',"});
temp;

It declares a global variable, finds all the elements and appends their id’s along with quotes into the variable and finally displays the contents in the browser console.

SQL query to alter email addresses for testing

The SQL query below can be used to change email addresses in test data so they don’t get sent to real people accidentally.

The at sign in the original address is replaced with an asterisk character and then a new domain is appended to the end.

UPDATE test_data SET email = CONCAT(REPLACE(email, '@', '*'), '@trash-mail.com') WHERE email != '';

trash-mail.com is a disposable email service where you don’t even need to create an account.

Stop postfix from sending email for testing

This applies to CentOS 6. You may want to do this when testing some code and you’re not sure if it is going to send emails or not.

Edit /etc/postfix/main.cf

Add following lines at the bottom:

myhostname = localhost
mydomain = localdomain
inet_interfaces = $myhostname, localhost
mydestination = $myhostname, localhost.$mydomain, localhost
mynetworks_style = host
default_transport = error:outside mail is not deliverable

Save the file then run the following commands (as root)

postfix upgrade-configuration
postfix check
newaliases

Test by mailing something to yourself

mail username@example.com

Check that it just gets put in the root mailbox

mail

Enter the number of the email you want to read and it appears, d to delete it, z to return to the list, q to quit.

Sublime Text – British dictionary for spelling

If you want a British English dictionary in Sublime Text 3 for spell checking, choose Preferences / Settings and add the following line:

"dictionary": "Packages/Language - English/en_GB.dic"

Running Laravel on shared hosting subdomain

Running Laravel 5 on a shared host subdomain (I use Vidahost) is a little daunting because Laravel requires the web root to point to the /public folder and generally with a subdomain the website root is the root folder that is created for you.

My solution was to create a directory in the subdomain root folder and copy all the code into there. I then copied the contents of the /public folder into the subdomain root folder and edited index.php.

The two require lines need modifying to remove the ‘..’ characters and replace with the actual path.

//require __DIR__.'/../bootstrap/autoload.php';
require __DIR__.'/mysubdirectory/bootstrap/autoload.php';

It’s not pretty but it worked OK.

The little application I wrote is to help with non-verbal reasoning tests, to memorise the numeric equivalents of the alphabet: Alphabet to Numbers.

Folder structure for running Laravel from site root folder
Folder structure for running Laravel from site root folder