Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Kirk atomkirk

View GitHub Profile
@atomkirk
atomkirk / download_heroku_db.md
Last active Dec 17, 2015
Download Heroku DB
View download_heroku_db.md
  1. Use heroku pgbackups to get url of latest backup:

     heroku pgbackups:url
    
  2. Download the .dump file.

  3. Create a db to restore into:

     psql -c "create database firehose_live_backup"
    

(note: show current dbs with psql then \list)

@atomkirk
atomkirk / dup_pg_db.md
Created May 16, 2013
Duplicate a postgres DB
View dup_pg_db.md

To create a copy of a database, first make sure the destination doesn't exist:

psql -c "DROP DATABASE firehose_development;"

Then:

psql -c "CREATE DATABASE firehose_development WITH TEMPLATE firehose_test;"

View weak_self.md

There really needs to be an easier way to do this built into the language, but until then, I use my handy CodeBox app to paste in this whenever I need a weak reference to self:

__weak typeof(self) celf = self;
[self block:^{
  celf.foo = bar;
}];

It's a nifty trick, but Apple, please... I shouldn't have to declare a weak self, I should be able to use self with a predefined symbol for "self" that the compiler will then write the weak self declaration for me.

@atomkirk
atomkirk / timeout_interval_lion.md
Created May 24, 2013
NSMutableURLRequest timeout problem on lion
View timeout_interval_lion.md

If you set the timeoutInterval value on NSMutableURLConnection to -1, on mountain lion, it'll never time out, on Lion, it'll time out immediately.

@atomkirk
atomkirk / remove_git_submodule.md
Last active Aug 1, 2016
Remove a Git Submodule
View remove_git_submodule.md

How to completely remove a submodule:

  1. Run git rm -rf path/to/submodule (use --cached if it's already gone)
  2. Remove entry in .gitmodules
  3. Remove entry in .git/config
  4. Run rm -rf .git/modules/
View submodules.md

To a parent project, a submodule is essentially a subdirectory in your project that is viewed by the parent repo as a simple text file with a name and a commit number. So, when you pull down a project that uses submodules:

git submodule add <path to repo>

It will add that sub directory and an entry to its .gitmodules file (with the name and commit number). So when you git add . and git commit -am 'message' in the parent repo, the only thing you are adding and committing is the current commit of the submodule.

The git submodule command is how to work beyond this narrow view of a text file with a commit message. As shown above, you would use git submodule add <path to repo> to ADD it, but all you're adding is the text file with a name and commit. To actually pull down the files, you would run:

git submodule update --init --recursive
@atomkirk
atomkirk / cg_as.md
Created May 27, 2013
core graphics & application services
View cg_as.md

You can't mix CoreGraphics and ApplicationServices on mac. If you have two targets, and you want to use things like CGFloat, etc. link to CoreGraphics on iOS and ApplicationServices on OSX. On 10.8, it's fine, it'll work, but you're still suppose to use ApplicaitonServices. On 10.7, it'll build, launch and crash with an error about mismatched ApplicationServices versions because CoreGraphics is calling 10.8's ApplicationServices version. (or some such...)

@atomkirk
atomkirk / cocoapod_dep_trees.md
Created May 27, 2013
Cocoapod dependency trees
View cocoapod_dep_trees.md

After wresting the traditional git submodule + static library dependency chain, it became a giant headache. I tried to get it all to work for a long time. You must:

  1. Create a workspace and drag your child projects in.
  2. Add their targets as binary linked libraries.
  3. Manually add header search paths.
  4. And all your dependency projects must be set up a certain way for this to work too. So that's a lot of work.

A much better way is to use submodules to include the child projects into the parent project and then use cocoapods to include those child projects (instead of linking them in statically and dealing with the millions of headaches that brings).

For example, I've added my dependency tree as a series of git submodules and then I have a Podfile that looks like this:

View sparkle_gatekeeper.md

I forgot that I had turned on this:

![http://d.pr/i/GF8z/3KaIrTfS]

And so the Sparkle.framework for auto updating mac apps was offering to update, downloading, offering to install and relaunch and then would just quit and not update. It said finish_installation' failed: 22 which was because gatekeeper was keeping the app from updating itself.

Turned off entitlements and it works great.

View custom_fonts_mac.md

On iOS, to use custom fonts, you add them to your plist:

<key>UIAppFonts</key>
	<array>
		<string>GoodDog_New.otf</string>
		<string>ProximaNova-Bold.otf</string>
		<string>ProximaNova-Reg.otf</string>
	</array>

on Mac, you just add: