Tuesday, June 1, 2010

Power management settings

In order to leave processess running in background under MacOS while you don't use your computer you must configure some power management settings. This is needed because MacOS will sleep the computer if the keyboard or mouse are not used after a time.
You can configure this from the graphical interface, but if you need to setup this to a remote computer (or if you think that using GUIs is just not geek enough for you) the commands to do this are:

pmset sleep 0
pmset disksleep 0

To see the current settings:

pmset -g

Insert issues on SQLite3

If you are inserting a large number of entries in a SQLite3 table, it is highly recommended that the table doesn't have any indexes (primary keys included), because in indexed tables the time that takes each new insert becomes longer. In contrast, if the table isn't indexed, the insert time is always the same. If you need and indexed table, you could always add indexes after massive insertions.

SQL list each element one time

If you have a table like this :
CREATE TABLE data { id INTEGER , type INTEGER }

You can list each id one time with the following query :
SELECT id , MIN( type ) FROM data GROUP BY id


This work in MySQL

SQL group count with conditions

If you have a table like this :
CREATE TABLE data { id INTEGER , type INTEGER }

You can list the times that each id appears in the table with the following query :
SELECT id , count( type ) FROM data GROUP BY id

Now, if you want to list the same data but adding some condition, like list only the elements that appears more than one time, then you can perform that with the help of some aliases and nested query :
SELECT d.id , d.c FROM (SELECT id , count( type ) as c FROM data GROUP BY id ) d WHERE d.c > 1


This work in MySQL

Monday, March 15, 2010

Code 19: Windows cannot start this hardware device because its configuration information (in the registry) is incomplete or damaged

Remove/Delete the LowFilter and/or UpperFilter (you might have only one od these) entries from this registry area:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E965-E325-11CE-BFC1-08002BE10318}


Note: You will have several identical keys like this {4D36E965-E325-11CE-BFC1-08002BE10318}. The one you are looking for will have DVD/CD Rom Drives as the top entry. Reboot after deleting the LowFilter and/or UpperFilter entries.

Source