simple

simple

(0 comments, 57 posts)

This user hasn't shared any profile information

Home page: http://www.macmanitou.de

Yahoo Messenger: macmanitou

Jabber/GTalk: macmanitou

AIM: macmanitou

Posts by simple

VirtualBox: VMDK and VDI conversion and resize

0

Since VirtualBox 4.0 it is possible to resize vdi disk images, that is quit simple using the following command:

VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB

SIZE_IN_MB reflects the new disk size so if you want to increase your image to 25GB, just use:

VBoxManage modifyhd darwin.vdi --resize 25000

Sometimes it happens that you do not use a vdi with VirutalBox, but a VMWare Image (VMDK). That is also no problem, to convert from VMDK to VDI you can use:

VBoxManage clonehd –format vdi /path/to/original.vmdk /path/to/converted.vdi

4 months ago

Steve Jobs 1955-2011

I was completely shocked when I read this morning on my iPhone that Steve passed away. All my thoughts and sympathy goes out to his family and friends. Please be strong and accept the condolences of me and my family.

This day in my life is dedicated to Steve Jobs, I will think of him as of the great man he was and the one person who changed and influenced my life the most. Every single piece of software I write, every graphical user interface I create has a touch of his visions and so he will live on in me, till my time comes to meet him in another place.

I will miss you – Take care where ever you are,
Sascha Müllner

Database: Migration from SQLite to MySQL

0

After working with some sqlite databases for one of my iOS projects lately, I have now decided to also add an online service for the project. But how can I migrate from sqlite to MySQL?

Here are the basic three steps, I figured out that are needed to extract and modify the DDL to be ready for an import to MySQL:

  1. 1. Export the SQLite database with sqlite and command parameter “.dump” – as an example :
sqlite3 mySQLiteDataBase .dump .quit >> myDumpSQLite
  2. 2. Adapt the dump to get it compatible for MySQL
  – Replace “ (double-quotes) with ` (grave accent)
  – Remove “BEGIN TRANSACTION;” “COMMIT;”, and lines related to “sqlite_sequence”
  – Replace “auto increment” with “auto_increment
  3. 3. The dump is ready to get imported in a MySQL server

Luckily the modifications can be done with a simple python script Axel Steiner wrote. You can find it on his website:

http://www.treibsand.com/2008/02/15/sqlite_mysql/

Oracle: How to get a formatted string from a date?

0

If you work with SQL on Oracle you sometimes want to extract additional informations from a date field and also limit this result to a distinct set.
So for example to get all distinct years of a date field from a data set, you can use the following statement, which uses a subquery:

SELECT year FROM
(SELECT distinct TO_CHAR(wtp.delivery_date, 'YYYY') AS year FROM world_transport wtp)
ORDER BY year ASC;

We can further optimize the query, removing the subquery:

SELECT distinct TO_CHAR(wtp.delivery_date, 'YYYY') year
FROM world_transport wtp
ORDER BY year ASC;

If you now only want to order the result set, but also group it, remember that the alias year is not known when “GROUP BY” is invoked. To work around this simply use the same “TO_CHAR” function, instead of the alias:

SELECT TO_CHAR(wtp.delivery_date, 'YYYY') year
FROM world_transport wtp
GROUP  BY TO_CHAR(wtp.delivery_date, 'YYYY')
ORDER BY year ASC;

If you want to know the year, but want to preserve the data type date, you can do this by using the function”TRUNC” instead of “TO_CHAR” function:

SELECT TRUNC(wtp.delivery_date, 'YEAR') year
FROM world_transport wtp
GROUP  BY TRUNC(wtp.delivery_date, 'YEAR')
ORDER BY year ASC;

Any comments or additions are welcome!

Oracle: Escape ampersand (&) characters in SQL*Plus

0

When importing a backup you might have run into the problem that the ampersands (&) or colon () characters are used as bind variables in PL/SQL. This is actually no real problem, as you can simply change the substitution character using the DEFINE setting in SQL*Plus:

SET DEFINE ~

The usual substitution mechanism an ampersands would trigger, is now suppressed.

Other methods:
Define an escape character:

SET ESCAPE '\'
SELECT '\&abc' FROM dual;

Don’t scan for substitution variables:

SET SCAN OFF
SELECT '&ABC' x FROM dual;

Another way to escape the & would be to use concatenation, which would not require any SET commands -

SELECT 'Laurel ' || '&' || ' Hardy' FROM dual;

Use the 10g Quoting mechanism:

Syntax
 q'[QUOTE_CHAR]Text[QUOTE_CHAR]'
 Make sure that the QUOTE_CHAR followed by an ' doesn't exist in the text.
SELECT q'{This is Orafaq's 'quoted' text field}' FROM DUAL;

You can also turn off substitutions by setting define to off:

SET DEFINE OFF

When you need it, just turn it on again:

SET DEFINE ON

Reference:

http://kwatog.com/blog/oracle/enable-disable-bind-variable-in-sqlplus/

Oracle: Drop All Trigger and Drop All Database

0

To drop all triggers in a schema, simply execute:

begin
for i in (select trigger_name,owner from dba_triggers where trigger_name like '%') LOOP
execute immediate 'DROP TRIGGER '||i.owner||'."'||i.trigger_name||'"';
END LOOP;
END;

To get drop queries for all tables in a schema, simply execute:

select 'drop table '||table_name||' cascade constraints;' from user_tables;

or you can get drop queries for all user objects in a schema by executing:

select 'drop ' || object_type || ' ' || object_name || ';' from user_objects where object_type != 'INDEX'

Oracle: Disable ArchiveLog Mode

0

Sometimes it is unnecessary to use ArchiveLog mode with the Oracle database. If you do not know what ArchiveLog Mode is – here is a short statement:

“Any Oracle database that contains important data should be running in ARCHIVELOG mode. Running in Archive log mode enables you to take hot backups and perform point-in-time recovery.”
So if you do not want this feature you can disable it following these steps:

        - Login to your server as oracle user
        - start sqlplus as sysdba
                sqlplus “/ as sysdba”
        - run the following commands
                shutdown abort
                startup mount
                alter database noarchivelog;
                alter database open;
        - to test if you where successful just run the query:
                select name, log_mode from v$database;

Remember that once you disable archive log mode you need to take a fresh backup once archive log mode is turned back on.
Be aware that if a disk failure occurs while in NOARCHIVELOG mode, you can only restore the database to the point of the most recent full database backup.
To switch back from archivelog to noarchivelog mode, just repeat the relevant steps above specifying: ALTER DATABASE NOARCHIVELOG;

For RAC environments, read the following link:

http://www.dba-oracle.com/bk_disable_archive_log_mode.htm

How to drop multiple tables in MySQL

0

If you want to drop multiple tables in MySQL (current version 5.05 or before) you will find no command for that. But there is a simple way using some console commands, just hit your shell and simply paste this snippet:

mysqldump -u [USER] -p [PASSWORD] --add-drop-table --no-data [DATABASE]  | grep ^DROP | mysql -u [USER]  -p [PASSWORD]  [DATABASE]

Do not forget to replace [USER], [PASSWORD] and [DATABASE] with your settings. As always with remove operations be careful and backup!!!

ISPConfig3: Mail aliases for login to Dovecot

0

If you knew ISPConfig2 you probably remember the user login approach which was done there:

Login: web23p2
Password: OurBrilliant Password

Now with ISPConfig3 this has changed to the better by using the users email address – sounds cool – it is!
But what about migration from ispconfig 2 to ispconfig 3 – you do not want to drive around and setup every user account again – or send emails and then the user fails to set it up.

To prevent that you can just add an alias column to the mail user table

ALTER TABLE `mail_user` MODIFY COLUMN `alias` varchar(255) NOT NULL DEFAULT '' AFTER `email`;

Then just fill it with the old logins like webXpX using phpMyAdmin, Sequel Pro or even the console.

If you are done with that, just login to your server and change the dovecot sql config file:

nano /etc/dovecot/dovecot-sql.conf

by changing the user and password queries:

password_query = SELECT password FROM mail_user WHERE (email = '%u' OR alias = '%u') AND disable%Ls = 'n'

user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage=', quota) AS quota, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (email = '%u' OR alias = '%u') AND disable%Ls = 'n'

I will update this post when I figure out the postfix stuff…

You are done – hope that this saved your weekend ;)

Mac OS X: Ever wanted to integrate your Macs in a Active Directory environment with Two-factor authentication (Part 1)?

0

Simple AD Integration using knowledge as authentication key, is for some data to protect not enough. So if you want to raise the bar you add ownership (Smartcard, USB Dongle, e.g.) to the knowledge only authentication system.

So first stone on your way if you use Snow Leopard, you have to be aware that the Directory Utility has been moved from the Utility folder to Core Services. /System/Library/CoreServices/

Then you might want to enable the smart card login feature of Mac OS X using Apple’s nice walk-trough

http://support.apple.com/kb/TA24244

If can not get you Smart Card based solution running using Apple’s on board tools, you might consider using Centrify’s active directory Implementation:

http://www.centrify.com/directcontrol/mac_os_x.asp

If you are still unsure what you really need, there is a very good post about alternative authentication methods for Mac OS X from Ryan Faas @peachpit

http://www.peachpit.com/articles/article.aspx?p=725691

Of course you might ran in some problems and traps, to prevent you from going wild, there are some ongoing discussions at the Apple Boards:

http://discussions.apple.com/thread.jspa?threadID=2131654&start=30&tstart=15

simple's RSS Feed
Go to Top