Categories
Uncategorized

Finder stuck “Deleting xxx,xxx files” and then “Stopping…”

Note to self: Have to look up the exact messages and add them here.

Normally this occurs when deleting too many files using the trash in the empty trash phase. So because of some strange reason mac OS wants to show you the number of files to delete and starts counting them. Well many files are hard to count, right?! So it takes time and time… and you decide to cancel (stop) the process. Well now you have a non dismissable window on your screen that takes a lot of time until it disappears. So you will probably restart and then when you try to empty again the trash… guess what that happens again.

When the window is open trying to stop the empty trash action just move the folder with too many files outside of the .Trashes folder.

Here is how I did it:

1. Open a terminal
2. Run the command

sudo mv /Volumes/BackupDisk/.Trashes/501/Backups.backupdb /Volumes/BackupDisk/

3. To actually delete the files run the command:

sudo rm -rf /Volumes/BackupDisk/Backups.backupdb

Have a nice life!

Categories
Apache Web Server Linux mail PHP

PHP mail() function not sending email and no error was reported

The problem was that mail() method worked when invoked with php -r "mail('address@domain.tld', 'Subject', 'Message'); but when I tried it via the web server (apache in my case), in a php script, no email was sent and the mail method returned false. On top of this no error was displayed or logged anywhere not even error_get_last function did not return anything and I had display_errors and error_reporting activated and full E_ALL.

After trying all the possible tests that I could imagine I tried to send an email by executing the sendmail command form a php script. When I tried php’s shell_exec with sendmail:

shell_exec('/usr/sbin/sendmail');

and checked apache’s error logs got the error sh: /usr/sbin/sendmail: Permission denied. After I got this error it was obvious that the fix was to change the permissions for /var/qmail/bin/qmail-inject and /var/qmail/bin/sendmail so that apache can execute them.

Then said to myself: Happy developing! and that was it.

Categories
PHP Uncategorized

PHP Unknown error: Collator::__construct(): collator_create: unable to open ICU collator in Unknown on line 0

Full error message that occurred on mac (mavericks) homebrew version of php (php54, php55, php56) with php-intl (php54-intl, php55-intl, php56-intl) with intl.use_exceptions=1 and intl.error_level=E_ALL :

Unknown error: Collator::__construct(): collator_create: unable to open ICU collator in Unknown on line 0
PHP Fatal error: Uncaught exception 'IntlException' with message 'collator_create: unable to open ICU collator' in -:2
Stack trace:
#0 -(2): Collator->__construct('en_US')
#1 {main}
thrown in - on line 2

or without the default ini settings

PHP Fatal error: Call to a member function getLocale() on a non-object in - on line 3

Fatal error: Call to a member function getLocale() on a non-object in – on line 3

or in symfomny2

PHP Fatal error: Call to a member function asort() on null in APP_DIR/vendor/symfony/icu/Symfony/Component/Icu/IcuRegionBundle.php on line 79

After couple of hours I found the error to be inside icu4c library installed via homebrew.

The fix for this error is to reinstall the icu4c library, php and php-intl

brew reinstall icu4c php55 php55-intl

Categories
Linux mail postfix

NOQUEUE: reject: RCPT from unknown[xxx.xxx.xxx.xxx]: 553 5.7.1 : Sender address rejected: not owned by user

This error was written in my maillog when I was trying to send an email with Thunderbird.

It seams that the reason for this error was the fact that I used on the outgoing server’s options a port number that was used for imap instead of the needed smtp server.

This error is really weird:

Mar 27 10:33:32 somehost postfix/smtpd[34322]: NOQUEUE: reject: RCPT from unknown[127.0.0.1]: 553 5.7.1 : Sender address rejected: not owned by user login_and_sender@example.com; from= to= proto=ESMTP helo=

To fix this check out the outgoing server settings to have set the correct smtp port number.

Categories
Linux

Slow ssh and slow vsftpd login – Centos 6

The reason that the ssh commands were slow and sluggish (had to wait for seconds after enter was pressed to execute the command). There was nothing in the logs (that I could find) to help me identify this issue. I used google and many ideas from different forums without any luck.

I discovered that the changes I did to iptables some time before were wrong. Being a newbie I removed a rule that seamed suspicious (to me this rule looked too permissive):

ACCEPT all -- anywhere anywhere

To fix the issue I added the following rule back to my iptables. “This rule will allow all incoming packets destined for the localhost interface to be accepted.”

iptables -A INPUT -i lo -j ACCEPT

Categories
HTML PHP

Strange empty text line appearing inside my page

Usually you see an empty text line and you look at the source and you see nothing there just a space…

That happens often when the files that are outputted are using the encoding UTF8 with signature, instead of using the correct encoding UTF8 without signature.

Categories
JavaScript

Delayed javascript function/handler gets the right variable/parameter values

So we have a function that adds a handler function that is called after an ajax load or at a later time and we need to execute the handler function code for each item inside an array allowing the function to access the array values. Usually with the simplest try you would get some code that get’s executed with invalid variable values. Examples are below.

The wrong code:

//the function that will do the stuff for each array
var dostuff = function (arr) {
var n = arr.length,
    i;
    for(i = 0; i 

You can load the code into your javascript console to see it in action.
The output appears after 1 second and it is like this:

4
4
4
4

I don't need that. I need something that works so we need to wrap the handler call into a function call that will pass the current values as parameters.

var dostuff = function (arr) {
var n = arr.length,
    i;
    for(i = 0; i 

The output appears after 1 second and it is like this:

1
2
3
4

The final best solution would be to have the function inside for already defined so you don't define it on every loop:

var dostuff_item = function (y) {
            setTimeout(function () {
                console.log(y);
         }, 1000);
 }
var dostuff = function (arr) {
var n = arr.length,
    i;
    for(i = 0; i 

Tada!

Categories
Apache Web Server PHP

SoftException in Application.cpp:544: Directory “/path/dir” is writeable by group

Full error message: SoftException in Application.cpp:544: Directory “/path/to/directory” is writeable by group

The error apeared in cpanel logs at a hosting company and was related to a directory I created via ftp and where I tried to run some php script. When accessing the script from the web browser i got the error “500 Internal Server Error”

The problem is that Apache 2.0 server doesn’t allow in some cases (i don’t know these cases yet) that the directories created with write access rights set to all unless it’s set by the same unix user as the user running apache process. In order to fix this we need to create the folder from the same user as apache user. To do this we need to create the folder or to change the access rights from php.

The fix is to upload a small php file with the following code:

<?php
chmod("./dir", 0755);
?>

After we set the access right on “dir” to 777 we run the  php script then the error should not appear anymore.

Categories
Firefox HTML Internet Explorer JavaScript

base html tag does not apply correctly to all javascript and style files

Problem: The

<base href="http://example.com/path/to/res/">

  did not work at all on Internet Explorer – no javascript or style files were loaded and worked partially in Mozilla Firefox – a few javascript files were not pointing to the path that should be transformed by base href attribute.

Example:

Array(
[0] => 1
)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="http://example.com/path/to/res/">
<link rel="stylesheet" href="./css/styles.css" type="text/css" />
<scrupt src="./js/jquery.js" type="text/javascript"></script>
<scrupt src="./js/j1.js" type="text/javascript"></script>
<scrupt src="./js/j2.js" type="text/javascript"></script>

This code produced a page with no style files and  no javascript files included in Interenet Explorer 8 and a few javascript files (j1.js and j2.js) were not included in Firefox 3.5 because base tag was not applied. After several tests and all kind of different arrangements we discovered that the problem was the output before the page source the

Array ...

thing.

Solution: no output before the page’s headers otherwise you can get all kind of strange results including a html base tag not working correctly.

Categories
Internet Explorer JavaScript

Object doesn’t support property or method. Adding options in a <select> from a child window on Internet Explorer

Full error message:  Object doesn’t support property or method. I got this error message in Internet Explorer 7 every time i tried to run code similar to the next snippet:

window.opener.form.select[select.length]  = new Option(text, value);

The problem is that on Internet Explorer due to some mysterious security restrictions you are not allowed to add new options in a select element that resides in the parent (opener) window. In order to do this you need a workaround.

The easiest workaround is to write a function in the parent window that adds elements in the select element. The function should look something like this:

function addOptionToSelect(formName, selectName, optionText, optionValue) {
var elem = document.forms[formName].elements[selectName];
elem.options[elem.length] = new Option(optionText, optionValue);
}

This function has to be written in the parent window’s javascript and it will be accessed from child window with some code like this:

window.opener.addOptionToSelect(formName, selectName, optionText, optioValue);

Conclusion: Internet Explorer sucks.