Aug31

PHP read from a mounted drive

Posted by: Brian Chan | Filed in: technology | Tags: , | 03:14 pm, August 31st, 2011 No Comments »

Recently, I needed to read from a mounted drive on osx using Apache and PHP. I need to grab some file names in a certain directory using opendir or scandir, then dynamically populate a select dropdown box.

The issue is, the default apache user is _www being in the _www group, while the mounted drive allows only the “staff” group to enter.

In my case, I cannot change the mounted drive access permissions.

So, what options are left? I guess I can only change the apache user. If you decide to take this path, there are two options. One is to add the “staff” group to your default _www user. Read the man page yourself… The other option is to assign an existing user (who has access to the mounted drive) to apache. I picked the latter, don’t ask me why… ok, coz I am lazy…

Open up your /etc/apache2/httpd.conf , you will need to sudo.

Find the line that has “User _www”. Change that to say “User john_smith”. Then change the next line to the right group. If you don’t know what user and group to use here, just do an “ls -ld /Volumes/mounted_drive/” and use the user and group there.

Save it. Then restart apache by issuing “sudo apachectl restart”.

That should do it.



Aug20

Tech companies chinese names

Posted by: Brian Chan | Filed in: Uncategorized | Tags: | 10:54 am, August 20th, 2011 1 Comment »

Adobe 奧多比
Amazon 亞馬遜
AMD 超微
Apple 苹果电脑
Cisco 思科
Dell 戴尔
eBay 易贝
Facebook 臉書
Google 谷歌
Hewlett-Packard 惠普
IBM 國際商業機器
Intel 英特爾
Microsoft 微软
Oracle 甲骨文
Sony 索尼
Yahoo 雅虎



Aug15

dataTables editable plugin multiple select

Posted by: Brian Chan | Filed in: Uncategorized | Tags: | 02:10 pm, August 15th, 2011 1 Comment »

If you are using the jQuery datatable with the editable extension, you probably know that you can only highlight one single row (tr). In my opinion, that’s really for the purpose of integrating the single row add/delete functions.

If you need to implement multiple row operations, thus needing multiple row selection, here is how you can do it:

  1. Open up jquery.dataTables.editable.js
  2. Toward the end of the file, look for

    $(oTable.fnSettings().aoData).each(function () {
        $(this.nTr).removeClass(properties.sSelectedRowClass);
    });

  3. Comment that out.

Obviously by doing this we are breaking the single row add/del feature. So, you will need to make sure you are not using the builtin add/del buttons, namely btnAddNewRow and btnDeleteRow.

Now, how to grab the highlighted rows? If you follow the user manual, each of your tr should have an ID.

1
2
3
4
$('#myTable_id .row_selected').each(function () {
	item_id = this.id;
	// then do something with this id
});

Whatever you do, consider refreshing your table or the whole page to reflect the latest table content.



Aug9

Password strength

Posted by: Brian Chan | Filed in: fun | Tags: | 11:15 pm, August 9th, 2011 No Comments »

ref link: http://xkcd.com/936/



Aug3

Grandpa box

Posted by: Brian Chan | Filed in: fun | Tags: | 07:38 pm, August 3rd, 2011 No Comments »

Dilbert.com