Strangely enough, there is no way in the Cocoa or Cocoa Touch frameworks to read a stream of bytes as a sequence of characters line by line. The option of creating a string from a file, with methods such as stringWithContentsOfFile of NSString, and then generating an array of lines with componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet] certainly seems […]
A quick way to truncate a file to zero length without affecting any other attributes (owner, permissions, and so on)? Here goes… In the terminal window, type the following command at the prompt : > filename.ext The file called filename.ext will be reduced to zero bytes (emptied, basically). Everything else stays as it is, apart […]
When working in PHP, the most convenient way of dealing with timestamps is through the time() function, which returns an integer representing the number of seconds from the UNIX epoch (1 Jan 1970 at 00:00 GMT). That’s perfect for passing around your code modules, calculating time differences and easy conversion to string with the date() […]
I’m using SVN for my XCode projects, but have soon realised that XCode support for SVN is not powerful enough. So I have decided to go the old good command-line way… One of the most fundamental things I want to be able to do is ignore files – there is a lot of stuff in […]
It’s often useful to be able to split big archived files into smaller chunks, move them to – say – an external FAT32 hard drive (that won’t take anything bigger than 4Gb), and then recompose the original by combining the pieces. The MacOS X native archiver doesn’t handle that, and I didn’t like the idea […]
I’ve just found out about two convenient shell commands that can be used to check out and change/remove file associations in Windows. The first one is ftype, that allows you to define aliases for executable files to be invoked. The other one is assoc, whereby you can associate file name extensions to the aforementioned aliases.
After spending almost an hour trying to understand why an extended method would just not be available to the extended object types, I found out about a limit of this feature that I will make a note of, for future reference.
Compared to Java and C/C++, the switch statement as implemented in the C# language offers more flexibility. It can be used with a wider range of types and offers a more complex fall-through mechanism.