IPHONE: Saving data on exit

Totatlly forgot how to do this, so I had to look it up...

Use the following methods to catch application exit notifications:
- (void)applicationWillTerminate:(UIApplication *)application

Use this method to catch application interrupt notification:
- (void)applicationWillResignActive:(UIApplication *)application

Use this method to catch application resume notification:
- (void)applicationDidBecomeActive:(UIApplication *)application

Grep recursive search

find . | xargs grep -s "text to grep"

POSTGRESQL: Removing POSTGRESQL

The following manual uninstallation guide was grabbed from 2 separate sites. One is for removing 8.3, and the other for removing 8.4.

In Mac OSX: (Assuming Default Locations)

Via uninstaller:

1) In the installation directory, there will be a uninstall-postgresql.app file will be there, executing (double clicking) that will uninstall the postgresql installation.

Manual Uninstallation:

1) Stop the server
sudo /sbin/SystemStarter stop postgresql-8.3

sudo launchctl unload /Library/LaunchDaemons/com.edb.launchd.postgresql-
8.4.plist

2) Remove menu shortcuts
sudo rm -rf /Applications/PostgreSQL/8.3
sudo rm -rf /Applications/PostgreSQL/8.4

3) Remove the ini file
sudo rm -rf /etc/postgres-reg.ini
sudo rm -f /etc/postgres-reg.ini

4) Removing startup items
sudo rm -rf /Library/StartupItems/postgresql-8.3
sudo rm -f /Library/LaunchDaemons/com.edb.launchd.postgresql-8.4.plist

5) Remove the data and installed files
sudo rm -rf /Library/PostgreSQL/8.3
sudo rm -rf /Library/PostgreSQL/8.4

6) Delete the user postgres
sudo dscl . delete /Users/postgres

SYMBIAN: NewLC vs. NewL

It all has to do with the way you implement NewLC and NewL, but the STANDARD difference between NewLC and NewL is whether or not you have to CleanupStack->pop the object created.

Let's first start with the typical implementation of NewL and NewLC

static CObject* newL();
CObject* CObject::NewL() {
----CObject* self = NewLC();
----CleanupStack::Pop(self);
----return self;
}

static CObject* newLC();
CObject* CObject::NewLC() {
----CObject* self = new (ELeave)CObject();
----CleanupStack::PushL(self);
----self->Construct();
----return self;
}


As such, you would instantiate a CObject by using either of the following:

CObject* obj = CObject::NewL();


or

CObject* obj = CObject::NewLC();
// do something with obj that may require cleanup ie. cptrArray->AppendL(obj);
CleanupStack::Pop(obj);


If you do not pop the object, the stack will be messed up and you'll have a very difficult time figuring out why that is.

C++: CONST CAST

Spent about 20 minutes trying to figure out why this wasn't compiling.

void CImageLoader::LoadImageL(const TDesC& filename) {
----TDesC* tmp = &filename; // COMPILER ERROR
}


It's because filename is CONST. So we'll have to 'unconst' it for this line to work:

TDesC* tmp = &(const_cast(filename));

OPENGL ES: Basics

Here's how I usually set up my quads:

Coordinates
D C
A B

Vertices
A B
D C

Here's are the coordinates:
vertices = {-1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1};
coords = {TEX(0, 0), TEX(255, 0), TEX(255, 255), TEX(0, 255)}; // assumes 256x256 texture image
normal = {0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1};
triangles = {1, 0, 3, 1, 3, 2};

Where TEX(u,v) is defined as (GLbyte)( (u) - 128 ) , (GLbyte)( (v) - 128 )

Draw code

glMatrixMode(GL_MODELVIEW);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_BYTE, 0, vertices);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_BYTE, 0, coordinates);

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_BYTE, 0, normals);

glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glDrawElements(GL_TRIANGLES, 2 * 3, GL_UNSIGNED_BYTE, triangles);

OS X: Splitting & Joining large files

Took me a VERY long time to figure this out, but...

Problem: Files over 4GB cannot be dragged onto your external HDD if the external HDD is using FAT32 file-system.

Solution: Split the file up using terminal into chunks smaller than 4GB and transfer as usual. You can use terminal to join the file up again at a later time.

To split the file up into 1GB chunks:
split -b 1024m filename.file PREFIX_

To join the file from the separated chunks:
cat sub1 sub2 sub3 sub4 > output.file

I read somewhere the older macs cannot handle splits larger than 2047mb. This is not true on my mac because I just made chunks that are 3gb FTW.