First of all, thank you Linus Torvalds for being brilliant. Also, curse you Linus Torvalds for being brilliant. But mostly thank you.
Git is awesome, powerful, and frankly simply better than svn. In order to keep it that way, I'm posting a couple simple tricks to help me remember how to get things done and keep myself from cursing such a brilliant and productive man. Yeah, I know I'm (slightly) miss-using git.
Creating a shared repository (one that more than one person can push to). I am very well aware that git is not designed to be a centralized repository system, and that it works better as a distributed system, but I'm just not willing to take the time to securely share my repository over the internet with my colleagues. Nor do I have the simple way to execute push and pull commands to random repositories in my head. Hence, I need a shared repository to simplify things for me. I don't think that's too much of a problem: I'm not developing a linux kernel, after all.
git --bare init --shared
easy, huh? Now what happens after cloning and attempting to push to the repository?
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
error: failed to push some refs to 'blahblahblahblah'
It's a simple configuration problem - user error. I need to specify where and what to push:
git push origin master
Thursday, January 27, 2011
Monday, January 17, 2011
Git on Windows (7)
For anyone who hasn't heard of git, the cvs system designed and written by Linus Torvalds, git is awesome. I mean, line by line commits? And it's so easy!
My apollogies if this article isn't fancy and error free; I'm sick & tired (I love the kids, but hate what they carry).
First thing's second: we can actually skip installing git and go straight to the gui interface, because that will give us the option to install git. I'm not terribly keen on Tortoise - it's a pain to navigate the right-click menu - so I'm testing git extensions.
Installing Git Extensions:
Install MsysGit.
Install KDiff3.
Progress through a few default options; it's nice to see that it will integrate into Visual Studio 2010! I wonder what that will look like?
After installation is complete, open up Git Extensions and add a name, etc. These are, of course, to identify you as the author of any code you commit.
My apollogies if this article isn't fancy and error free; I'm sick & tired (I love the kids, but hate what they carry).
First thing's second: we can actually skip installing git and go straight to the gui interface, because that will give us the option to install git. I'm not terribly keen on Tortoise - it's a pain to navigate the right-click menu - so I'm testing git extensions.
Installing Git Extensions:
Install MsysGit.
Install KDiff3.
Progress through a few default options; it's nice to see that it will integrate into Visual Studio 2010! I wonder what that will look like?
After installation is complete, open up Git Extensions and add a name, etc. These are, of course, to identify you as the author of any code you commit.
Friday, August 6, 2010
Copy-Paste Code: Opening up Settings.plist
So you've bundled a Settings.plist, and now you want to know why you can't edit it? It's because it's not in a writable directory. Let's put that baby where she belongs:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
settingsPlistPath = [[documentsDirectory stringByAppendingPathComponent:@"Settings.plist"] copy];
NSFileManager *fileManager = [[NSFileManager alloc] init];
if (![fileManager fileExistsAtPath:settingsPlistPath]) {
NSString *bundledSettings = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"];
[fileManager copyItemAtPath:bundledSettings toPath:settingsPlistPath error:NULL];
}
self.settingsDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPlistPath];
NSString *documentsDirectory = [paths objectAtIndex:0];
settingsPlistPath = [[documentsDirectory stringByAppendingPathComponent:@"Settings.plist"] copy];
NSFileManager *fileManager = [[NSFileManager alloc] init];
if (![fileManager fileExistsAtPath:settingsPlistPath]) {
NSString *bundledSettings = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"];
[fileManager copyItemAtPath:bundledSettings toPath:settingsPlistPath error:NULL];
}
self.settingsDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPlistPath];
A Quick Way to Syntax Highlight Code
How to make code pretty before posting: it's easier than you think
Some people would prefer spending the time to set up a script that will highlight their code for them. There definitely advantages to this approach. Not wanting to spend the time and resources to set something like this up (as simple as it seemed to me to be), I opted for a google search: syntax highlight objective-c code online. There are plenty of options out there, but http://quickhighlighter.com/ is the one I liked the best. It has one drawback: you have to copy and paste two bits of HTML into your blog instead of one (it separates the css).
There are plenty of options to choose from, and you can even copy and paste the highlighted text into blogger, but (at least with Google Chrome) you loose the pretty gray box the code comes in.
Monday, August 2, 2010
Finding Memory Leaks - the easy way
From the iPhone Development Guide, "Debugging Applications"
Finding Memory Leaks
If you fix a leak and your program starts crashing, your code is probably trying to use an already-freed object or memory buffer. To learn more about memory leaks, see "Finding Memory Leaks".
You can use the NSZombieEnabled facility to find the code that accesses freed objects. When you turn on NSZombieEnabled, your application logs accesses to deallocated memory, as shown here:
2008-10-03 18:10:39.933 HelloWorld[1026:20b] *** -[GSFont ascender]: message sent to deallocated instance 0x126550
To activate the NSZombieEnabled facility in your application:
iPhone 3.1 SDK introduces the Leaks instrument, which you can use in the Instruments application to easily find memory leaks. For more information, see Instruments User Guide.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-05-28)
Finding Memory Leaks
If you fix a leak and your program starts crashing, your code is probably trying to use an already-freed object or memory buffer. To learn more about memory leaks, see "Finding Memory Leaks".
You can use the NSZombieEnabled facility to find the code that accesses freed objects. When you turn on NSZombieEnabled, your application logs accesses to deallocated memory, as shown here:
2008-10-03 18:10:39.933 HelloWorld[1026:20b] *** -[GSFont ascender]: message sent to deallocated instance 0x126550
To activate the NSZombieEnabled facility in your application:
- Choose Project > Edit Active Executable to open the executable Info window.
- Click Arguments.
- Click the add (+) button in the “Variables to be set in the environment” section.
- Enter NSZombieEnabled in the Name column and YES in the Value column.
- Make sure that the checkmark for the NSZombieEnabled entry is selected.
iPhone 3.1 SDK introduces the Leaks instrument, which you can use in the Instruments application to easily find memory leaks. For more information, see Instruments User Guide.
© 2010 Apple Inc. All Rights Reserved. (Last updated: 2010-05-28)
Saturday, July 31, 2010
Downgrading iPhone OS
Yes, sometimes you need to. Like if you have an iPhone 3G and you install OS 4 on it. And you don't like how unresponsive the OS got. Well, here's an excellent how-to. Don't forget the step with RecBoot - it's worth downgrading your phone just to see the message RecBoot gives you when you're done!
Saturday, July 24, 2010
SQLite: Easy as 1 2 3 ...4 (Practically Painless)
Yes, SQLite is an excellent SQL solution for the iPhone.
So, how to add support to a project?
I'm assuming that you have an SQLite database already. If you don't, try SQLite Database Browser. It isn't perfect, but it works well enough, and you can use it to create and edit tables. I also assume that you know how to use what SQLite retrieves in your iPhone project. For a more complete guide, you might try this tutorial, but I like to keep my posts focussed. Eventually I'll take the time to learn the pros and cons of using Core Data - I've been led to believe it can do some of the same things that SQLite can do (it can even write to a file in SQLite format) - but until I understand it better I'll stick with what I know: SQL.
Adding the SQLite Framework to your project
It's as easy as 1 2 3 ...4...
- Right-click on Frameworks
- Click Add -> Existing Frameworks
- In the drop-down, select Dylibs
- Select libsqlite3.0.dlib and click Add
Accessing your SQLite database
I'm using fmdb to access the database (it has an MIT license), rather than write my own object for accessing the db. I've copied over the project into a folder I aptly named "FMDB". From there on it should be calm seas! FMDB even comes with a "fmdb.m" file that can be used to see the code in action.
Subscribe to:
Posts (Atom)