CodeIgniter set_select default value

The CodeIgniter documentation is vague on how to set the default value in a select tag when you are using the form helper. There’s a third parameter to the set_select method that’s a boolean.

I recommend using something like the following code snippet:


So you have to check the value of the $option variable with each iteration of the loop and if it matches another variable (which you should set in your controller) it sets the TRUE that the set_select method requires.

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"