Tuesday, April 15, 2014

How to Move a Git Submodule

I was in Git hell for more than a day. Word to the wise: copy the entire directory before doing anything crazy using your OS. Even reflog cannot get you back when your submodules get screwed up.

Anyway, here's how to move a git submodule. Hint: you cannot do it with git mv.


Thursday, March 6, 2014

Pragma Mark Scheme for iOS Dev


If you want to be like all the smart people you read about on the Internet, you'll keep your files really well-organized. If you have such long files that you need to use pragma marks (which some people, including Jeff Atwood, I recall, think means that your files are too long) you have a basic organizational problem. Now the solution to this is, of course, "bust the file up into sections and stick to those." But what would those sections be? So I'm usually going by functionality, but then I inevitably lose it and end up with no organization at all, or (worse) using it in half the file.

The reason that I failed is that I cannot use a scheme that requires you to know what each method does. That's very time-consuming and, in a sense, redundant with the messages you see passed in the code.

So here's my new scheme, which is very easy to use because it doesn't require you to think. I've been trying this for a while and it's great.

#pragma mark - class methods
#pragma mark - initializers, dealloc, and lifecycle methods
// like didMoveToSuperview
#pragma mark - property accessors
#pragma mark - public overrides
#pragma mark - public property accessor overrides
#pragma mark - public methods
#pragma mark - protocol A methods
#pragma mark - protocol B methods
#pragma mark - dependent-object lifecycle
// like viewDidLoad, viewDidAppear, etc., NOT like hideView
#pragma mark - Methods not in public interface
#pragma mark - Not Implemented

Monday, December 17, 2012

Date and Timestamp Trigger in OSX

I'm so proud that I finally just took on Applescript a bit and did a date script. It was a hassle, but I even did a method (whoot!). So you put this in with the script editor and then save it to a .scpt file (default).

2013-10-02 01:35
Now using Spark (link). Awesome.

Sunday, December 9, 2012

Occasional Markdown Plugin

I'm not too into PHP now, nor was I ever into programming for Wordpress. However, I was not happy with the Markdown options available.

I want this:

<pre class="markdown">
**Markdown here!**
</pre>

**this is not markdown**

<pre class="markdown">
**More markdown here!**
</pre>

To come out like this:

Markdown here!

**this is not markdown**

More markdown here!

So I made a plugin in Wordpress to do that. Of course, all the work was already done. Also, I have no idea if this is safe or not for your Wordpress installation. I haven't tested with comments, especially, which are user input, so be careful.

Anyway, check it out in my Github fork.


Thursday, November 29, 2012

Everwatch, Evernote, Marked

Updated Instructions

I love Brett Terpstra's Marked, and its integration with Evernote is barebones and cool. Anyway, the instructions are:
  1. Get the everwatch.rb script from here
  2. As written about here change line 8 to say  
    watch_folder = File.expand_path("~/Library/Application Support/Evernote/accounts/Evernote")
  3. Run it in the background by using something
    ~/scripts/everwatch.rb &

I've Been Checking It Out, Now It's Broken!

You'll notice at some point that the script blows up, and if you're observant (or lucky, as I was) you'll note that it's the apostrophes that make it blow up. So replace the line that says:

      # convert the contents to plain text
      txtnote = %x{echo '#{note}'|textutil -stdin -convert txt -stdout}

with this whole shebang

      note = note.gsub("'","APOSTROPHEEE") 
      # convert the contents to plain text
      txtnote = %x{echo '#{note}'|textutil -stdin -convert txt -stdout}
      txtnote = txtnote.gsub("APOSTROPHEEE", "'") 

While I'm here, I'll add my meager attempt to translate the bullets. It actually works (well, so far):

      txtnote = txtnote.gsub("\t•","-")     # 1st indent
      txtnote = txtnote.gsub("\t◦","    -") # 2nd indent becomes 4 spaces
      # evernote numbering, but only one level
      txtnote = txtnote.gsub(/\t\d{1,4}\.\t/, "1. ")  

And then  you'll notice that second level Markdown bullets don't work, so add this:

      txtnote = txtnote.gsub("\302\240", " ") # some bizarre space-looking character textutil or Evernote uses

Then I went crazy and redid the script a bit. Now it opens Marked on it's own (if you have the filetypes associated) and is less brittle to changes. Performance is the same (and Command-S in Evernote does help):

Monday, October 1, 2012

Don't Commit If Submodule Is Dirty

Thanks to my question here I wrote this script: Like in all things, you probably don't want to commit if the submodules are dirty ;)

Thursday, September 27, 2012

Get Properties of Type in Self

This Objective-C category is of extremely limited utility, since it will not handle a hierarchy deeper than super and subclass. However, it saved me today, and that's what I needed.


Use it like this: