Development
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
iPhone OS: ffmpeg for the iphone – Part 1
0I am just checking if it is possible to get WMV9 support for one of my applications on the iphone using ffmpeg.
The good point a lot of people tried to get these working, but actually none covered if his application was approved for the AppStore. Due to Apples guidelines there might be some problems to get an approval. For now just some informations, I already collected:
http://code.google.com/p/ffmpeg4iphone/
http://github.com/yuvi/gas-preprocessor/
http://stackoverflow.com/questions/1679649/using-ffmpeg-library-with-iphone-sdk-for-video-encoding
These where basically my first finds – interesting reads, but after some more searching I found what I was really looking for, build scripts for Cortex8, arm1176jzf and i386 (aka iPhone Simulator)
http://github.com/gabriel/ffmpeg-iphone-build
If you combine these with the iFrameExtractor example project I found here:
http://www.codza.com/extracting-frames-from-movies-on-iphone
you got a really nice demo project for the use of ffmpeg, which is also able to run in the iPhone Simulator. Lots of video formats are supported out of the box and you can also for example play Adobe Flash files. Streaming capabilities are there, but for flash you might need to fiddle a bit.
I will setup a demo project and ask the codza guys if they have no problem if I host it here.
Terminal: Search and Replace text in all files in a folder and its subfolders
0I just stumbled across a neat idea using perl to replace the content in files
To replace all occurances of a string:
find ./ -name “*.txt” | xargs perl -pi -e ‘s/stringtoreplace/replacementstring/g’
for every of these examples you can also use sed
find ./ -name “*.txt” | xargs sed -i ‘s/stringtoreplace/replacementstring/’
or rpl
rpl stringtoreplace “replacementstring” ./
or numeros other solutions …
To replace the first occurance:
find /your/home/dir -name “*.txt” | xargs perl -pi -e ‘s/stringtoreplace/replacementstring/’
To replace all files in a folder:
for arg in `ls -C1`; do perl -pi -e ‘s/stringtoreplace/replacementstring/g’; done;
you can do more cool tricks using the for shell command as demonstrated above. you can add more specific searches. However, you might be better off just writing a shell script. Here is an example of the first find:
for arg in `find /your/home/dir -name “*.txt”` ; do perl -pi -e ‘s/string/replacement/g’ $arg; done;
Scalable second-generation distributed database
0A good friend of mine just showed me two links to scalable second-generation distributed database, I want to share with you.
This approach is my favorite one – as it is the underlying database of Digg, Facebook, Twitter and many others. It is written in Java and released under the Apache License:
The other approach is written in C and released under the GNU General Public License Version:
MySQL Replication Setup
0On the Master we first flush the tables in the database setting a read lock:
USE phpMyWebcam; FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS;
The last command will show something like this
| +——————+———-+————–+——————+ | File | Position | Binlog_do_db | Binlog_ignore_db | +——————+———-+————–+——————+ | mysql-bin.015586 | 364167 | phpMyWebcam | | +——————+———-+————–+——————+ 1 row in set (0.00 sec) |
We write down this information, as we will need it later on the slave!
We leave the MySQL shell and execute:
mysqldump -u root -p<password> –opt phpMyWebcam > phpMyWebcam.sql (Replace <password> with the real password for the MySQL user root! Important: There is no space between -p and <password>!)
This will create an SQL dump of phpMyWebcam in the file phpMyWebcam.sql. Transfer this file to your slave server!
Finally we have to unlock the tables in phpMyWebcam:
mysql -u root -p Enter password:
mysql> UNLOCK TABLES;
quit;
Now the configuration on the master is finished. On to the slave…
If you have made an SQL dump of phpMyWebcam on the master and have transferred it to the slave, then it is time now to import the SQL dump into our newly created phpMyWebcam on the slave:
mysql -u root -p<password> phpMyWebcam < /path/to/phpMyWebcam.sql (Replace <password> with the real password for the MySQL user root! Important: There is no space between -p and <password>!)
Finally, we must do this:
mysql -u root -p
Enter password:
SLAVE STOP;
In the next command (still on the MySQL shell) you have to replace the values appropriately:
CHANGE MASTER TO MASTER_HOST=‘localhost’, MASTER_PORT=13306, MASTER_USER=’replicant’, MASTER_PASSWORD=’<some_password>’, MASTER_LOG_FILE=’mysql-bin.015586′, MASTER_LOG_POS=364167;
- MASTER_HOST is the IP address or hostname of the master (in this example it is localhost).
- MASTER_PORT is the port to which the sql master listens (in this example it is 13306).
- MASTER_USER is the user we granted replication privileges on the master.
- MASTER_PASSWORD is the password of MASTER_USERon the master.
- MASTER_LOG_FILE is the file MySQL gave back when you ran SHOW MASTER STATUS;on the master.
- MASTER_LOG_POS is the position MySQL gave back when you ran SHOW MASTER STATUS; on the master.
Now all that is left to do is start the slave. Still on the MySQL shell we run
START SLAVE;
quit;
That’s it! Now whenever phpMyWebcam is updated on the master, all changes will be replicated to phpMyWebcam on the slave. Test it!
To see the status of your slave you can every time run this command on the slave:
SHOW SLAVE STATUS;
Resolve IP Address for hostname on the iPhone
0On the Mac you might use NSHost, but as this is missing on the iPhone you are of using CFHost. Or much simpler use some standard C functions and you can easily get an IP Address for a hostname on the iPhone:
#include <netdb.h>
#include <arpa/inet.h>
// Get host entry info for given host
struct hostent *remoteHostEnt = gethostbyname(“apple.com”);
// Get address info from host entry
struct in_addr *remoteInAddr = (struct in_addr *) remoteHostEnt->h_addr_list[0];
// Convert numeric addr to ASCII string
char *sRemoteInAddr = inet_ntoa(*remoteInAddr);
NSString *s = [[NSString alloc] initWithFormat: @“Remote IP: %s\n”, sRemoteInAddr];
Do not forget that their might be more that one IP assigned to a hostname!
You can also get a nice tutorial at:
Cocoa: Core-Plot for MacOS X and iPhone
0If you want to draw nice plots or graphs on the Mac or the iPhone, then you will come across core-plot. This opensource project really works well and following some of the links should give you a good start
Google Code Page:
http://code.google.com/p/core-plot
Tutorials:
http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application
http://blogs.remobjects.com/blogs/mh/2010/01/26/p973
Purge MySQL Database
0If you run out of disk space on your server, it might be a good time to check your mysql binary logs. If there is really to much space used than just issue some SQL commands and you can delete them.
To delete all binary logs older than 7 days:
mysql> PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);
To purge all logs before a specific date:
mysql> PURGE MASTER LOGS BEFORE ’2008-01-01 00:00:00′;
To purge logs automatically (every Monday at 3am) you could use a Unix cron job:
0 3 * * mon mysql -uroot -e “PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);”