Skip to main content

Posts

Showing posts from October, 2015

Configure Display Resolution in Raspberry Pi

Raspberry Pi 2 supports its HDMI display for 1080p resolution. But, when you want a smaller resolution whether it is in a large display panel, you can configure it manually from terminal.
1) Get the lists of supported resolutions and modes of your monitor tvservice -d edid
edidparser edid
2) Edit the configuration file nano /boot/config.txt
3) Find configuration for HDMI group and HDMI mode. The mode is the code shown in the result of first step. DMT group is 2 and CEA group is 1. For example, hdmi_group=2 #(DMT)
hdmi_mode=85 #(code 85)
4) Restart your Raspberri Pi

More References: http://www.cpmspectrepi.webspace.virginmedia.com/raspberry_pi/MoinMoinExport/OptimisedDisplaySettings.html

Sends Email in The Background in PHP

If you send email in PHP with any library through SMTP server, the process will take a while (2 seconds or more). The process isn't necessary to be sequential. Clients don't need to wait and know the sending process had finished or not. So, the sending process is better to be run as background process. If you use Linux, you can use exec method. If you're in Windows environment, you can use popen method. Then you send the result to the background.
In Linux, you can use wget command to be executed to access email sending application script. The message contents can be setup and maintain in database before this action is run.

exec("wget -qO- http://domain.com/send.php &> /dev/null &");
Or you can pass the contents directly as parameters for PHP arguments which is executed.

exec("php /path/to/your/mailer/script \"arg1\" \"arg2\" > /dev/null 2> /dev/null &");
If you are in Windows

pclose(popen("start /B php /path/t…

Custom Error Messages Location with jQuery Validation

jQuery Validation is a simple tools to validate a form with jQuery. We can custom error message location using this library. If you just want to set a box to gather all error messages, you can use this scheme.
Javascript
$('#form').validate({ rules:{ first:{ required:true}, second:{ required:true}}, messages:{}, errorElement :'div', errorLabelContainer:'.errorTxt'});
HTML
<formid="form"method="post"action=""><inputtype="text"name="first"/><inputtype="text"name="second"/><divclass="errorTxt"></div><input