Skip to content

Instantly share code, notes, and snippets.

View atomkirk's full-sized avatar

Adam Kirk atomkirk

View GitHub Profile
@atomkirk
atomkirk / submodules.md
Created May 27, 2013 17:05
Submodule notes

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 / remove_git_submodule.md
Last active August 1, 2016 15:00
Remove a Git Submodule

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/
@atomkirk
atomkirk / timeout_interval_lion.md
Created May 24, 2013 22:41
NSMutableURLRequest timeout problem on lion

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 / weak_self.md
Last active December 17, 2015 10:29
weak self

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 / dup_pg_db.md
Created May 16, 2013 02:08
Duplicate a postgres DB

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;"

@atomkirk
atomkirk / download_heroku_db.md
Last active December 17, 2015 09:39
Download Heroku DB
  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)