Skip to content

Send email with CodeIgnitor on Godaddy.com

2011 October 2
tags:
by milaneuo


/**
* Send email
*
* @param $to
* @param $subject
* @param $body content of the email
* @param $attachments (optional)
*
* @return boolean
*/
function mySendMail($to, $subject, $body, $attachments = array()) {

$CI =& get_instance();
$CI->load->library('email');
$config = array('protocol' => 'sendmail', 'smtp_host' => 'relay-hosting.secureserver.net', 'mailtype' => 'html');
$CI->email->initialize($config);

$CI->email->from('webmaster@xxx.com', 'xxx');
$CI->email->to($to);
$CI->email->subject($subject);
$CI->email->message($body);
foreach ($attachments as $attachment) {
$CI->email->attach($attachment);
}

if ($CI->email->send()) {

// echo 'success!';
return true;
} else {

// echo $CI->email->print_debugger();
return false;
}
}

Enable PATH_INFO in Godaddy

2011 September 27
tags:
by milaneuo

    Create a file named “php5.ini”, add this text “cgi.fix_pathinfo = On”
    Upload this file to the root directory of your website, wait for some minutes. Then it works fine. :)

Code auto-complete for QT in VS2008 and Visual Assist X

2011 May 7
by milaneuo

For VS 2008
    Tools => Options => Projects and solutions => VC++ directories, Choose “Include Files”, Add
D:\Qt\4.7.2\include
D:\Qt\4.7.2\include\QtGui
PS: D:\Qt is the installation directory for QT.

For Visual Assist X
    In the configuration page of VS assistantX, Projects=>C/C++ Directories=>ustom, Add
D:\Qt\4.7.2\include
D:\Qt\4.7.2\include\QtGui
D:\Qt\4.7.2\include\Qt

Error “Access violation” in OpenGL.

2011 April 7
tags:
by milaneuo

    I ran the project “Triangle”(Chapter 2, OpenGL SuperBible) on my computer, and got the following error: Unhandled exception at 0×00000000 in Triangle.exe: 0xC0000005: Access violation, which thrown from the statement “shaderManager.InitializeStockShaders();”
    Solution: update the display adapater driver to the latest version.

Clear svn/cvs information.

2011 March 8
tags: ,
by milaneuo

Repaste from http://gaogengzhi.javaeye.com/blog/697159
    Sometimes we need a clean copy(which doesn’t contain the .svn/.cvs Folder).
    There is a method to do this:
For svn
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""

For cvs
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteCVS]
@="Delete CVS Folders"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing CVS Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.cvs) DO RD /s /q \"%%f\" \""

    Save the above text as “DeleteSvnFolder.reg”/”DeleteCvsFolder.reg”. Double-click it to import it to the registry. Then you’ll find that there will be a item “Delete SVN Folder”/”Delete CVS Folder” in your windows context menu.

Apache error: “Apache Faulting Module Ntdll.dll”

2011 March 8
tags:
by milaneuo

    My apache server cannot start up one day. I get the error message “Apache Faulting Module Ntdll.dll” from windows event log viewer. I thought that there were some conflicts between apache and other softwares. So I tried to uninstall softwares which installed recently.
    However, the apache cannot start up. I still got the same error message.
    The problem was resolved until I read a web page, which point out that this error may caused by the conflict between PHP extension dlls and windows dlls. I removed all PHP extensions in the php.ini, then restarted apache. Thank goodness, apache works fine at last.

Mysql issue “marked as crashed and should be repaired”

2011 March 1
tags:
by milaneuo

    I got the message “the table `user` marked as crashed and should be repaired” when I execute a sql statement in my Mysql server.
    I thought there should be something wrong with the table `user`. Then I sought help from Google and got the solution at last:
    open the command line prompt, change the directory to mysql/bin
cd D:\Program Files\MySQL\bin
    use the “myisamchk” tool to repair the table
myisamchk -f ‘D:\Program Files\MySQL\MySQL Server 5.1\data\dbName\user.MYI’
    PS: the “dbName” stands for the name of the database which the table in. :)

Using Dispatcher.BeginInvoke in VB.net

2011 February 28
tags:
by milaneuo

Sometimes, we need use the Dispatcher.BeginInvoke. You can call it by anonymous delegate if you use C#. Like this:

Dispatcher.BeginInvoke(delegate
{
    Method1();
    Method2();
});

VB.Net doesn’t support anonymous delegate. You cannot call the Dispatcher.BeginInvoke like in C#. However, VB.NET supports Lambda Expressions, which with a single statement. For example:

Dispatcher.BeginInvoke(Function() DisposeTimer())
Private Function DisposeTimer() As Integer
    Me._timer.Stop()
    Me._timer = Nothing
    Return 0
End Function

How to keep checkbox state in IE6 with Colorbox

2010 November 17
by milaneuo

Problem
I use colorbox to display an inline list of checkboxes to choose.
It works fine with FF & IE7 & IE8, but it lose the selection on IE6 when I close the colox window.
Here’s a example page to reproduce this problem.

<script src="js/jQuery/jquery-1.3.2.min.js" type="text/javascript"><!--mce:0--></script>
<script src="js/jQuery/colorBox/jquery.colorbox-1.3.9.min.js" type="text/javascript"><!--mce:1--></script>
<script type="text/javascript"><!--mce:2--></script>
 
<a id="colorBoxLink">Open checkbox page</a>
 
<div style="display: none;">
<div id="chkBoxContainer">
<input name="chkbox1" type="checkbox" value="1" /> 1
<input name="chkbox2" type="checkbox" value="2" /> 2</div>
</div>

Solution
However, I found that this probelem doesn’t caused by colorBox but jQuery. The original state would be lost if a checkbox moved by jQuery in the DOM in ie6.
So you can use the event hooks to detect which boxes have been checked, then re-check them after colorbox has been opened, then re-check them again after coloxbox has been
closed.
You can do such things with the following function so as to solve the tricky problem. Please attach the function to the body of $(document).ready(function() {}).
You can also get the function  here

View Code JAVASCRIPT
function fixColorBoxBugInIe6() {
 
	if (navigator.appName == "Microsoft Internet Explorer") {
 
		var arrVersion = navigator.appVersion.split("MSIE");
		if (parseFloat(arrVersion[1]) == 6) { // if the browser is ie6
 
			var $checked = null;
			$().bind('cbox_open', function() {
 
			    $checked = $('input:checked');
			}).bind('cbox_complete', function() {
 
			    $checked.attr('checked', true);
			}).bind('cbox_cleanup', function() {
 
			    $checked = $('input:checked');
			}).bind('cbox_closed', function() {
 
			    $checked.attr('checked', true);
			});
		}
	}
}

Hello World!

2010 November 13
by milaneuo

This site was built to provide elegant codes and focus on trouble shooting. Just enjoy!