Development
4 months ago
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
0After 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. Export the SQLite database with sqlite and command parameter “.dump” – as an example : sqlite3 mySQLiteDataBase .dump .quit >> myDumpSQLite
- 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. 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:
Oracle: How to get a formatted string from a date?
0If 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
0When 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
0To 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
0Sometimes 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:
How to drop multiple tables in MySQL
0If 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!!!
iPhone OS: Enterprise Business Tools
0If you need to manage iPhones or iPads in a big enterprise business, your should read Apples Support Documents:
http://www.apple.com/de/support/iphone/enterprise/
and in any case download the iPhone Configuration Tools for Mac OS X:
http://support.apple.com/kb/DL851
and for Windows:
http://support.apple.com/kb/DL926
You can then setup configuration profiles, that reflect the setup of your environment:
• Passcode-Richtlinien
• Funktions-Einschränkungen
• Wi-Fi-Einstellungen
• RADIUS-Authentifizierung
• VPN-Einstellungen
• E-Mail-Einstellungen
• LDAP
• CalDAV
http://www.docstoc.com/docs/1811411/Apple-iPhone-and-iTouch-Enterprise-Deployment-Guide
iPhone OS: Design a nice InApp Purchase View
0To get up a nice InAppPurchase View for Apple’s AppStore, we first need some good looking buttons:
http://code.google.com/p/iphonegradientbuttons/
http://undefinedvalue.com/2010/02/27/shiny-iphone-buttons-without-photoshop/
http://iphonedevelopment.blogspot.com/2010/05/improved-gradient-buttons.html
http://stackoverflow.com/questions/422066/gradients-on-uiview-and-uilabels-on-iphone/
There are also some tweaks for the UITableView you might consider using:
http://stackoverflow.com/questions/400965/how-to-customize-the-background-border-colors-of-a-grouped-table-view/
http://stackoverflow.com/questions/986392/programmatically-force-a-uiscrollview-to-stop-scrolling-for-sharing-a-table-view/
more information upcoming…
iPhone OS: Setup an additional Security Layer
0As you might already know the iPhone is itself not that secure that people might think (news is german):
http://www.heise.de/security/meldung/Luecke-in-Datenverschluesselung-des-iPhones-1007818.html
How do you prevent intrusion of your customers data? As a really pragmatic approach, we can just set up additional encryption for our application data:
http://stackoverflow.com/questions/2579453/nsdata-aes-class-encryption-decryption-in-cocoa
http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html
http://pastie.org/974094/
So if you use for example core data, then on application start you decrypt the database and after termination encrypt it, using the AES class. These are only some basic thoughts and I think that you are better of using higher encryption like blowfish 448bit or even combine it with AES256bit. These encryption is
Your data might live now a little bit securer, but to prevent also code intrusion, you REALLY should strip symbols and obfuscate your code:
http://stackoverflow.com/questions/2442189/write-secure-cocoa-code
and never ever store any secrets or keys in your code!
Also there are some nice reads from Apple you might consider looking at:
http://images.apple.com/iphone/business/docs/iPhone_Security_Overview.pdf
