# Catch Exception

## Nov 19

### Trigonometry

I’ve always been bad at trig, so it was nice to finally have a breakthrough with some of the math. As with my grid equations, here are the basics for [my] reference.

Get the angle between two points

atan2(y2-y1,x2-x1);

Get the x and y of an object around a radius, given an angle.

You can create weird orbits by changing the result of sin. For example:

And of course, add offset X and Ys if your circle isn’t at 0,0.

(Thanks Charlie!)

Get the distance between two points.

sqrt(pow(y2-y1,2) + pow(x2-x1,2))

## Nov 18

### The Creative Process

I don’t like to look at other executions out there. I prefer natural inspiration - if there’s a thing I discover and think it’s awesome, other normal regular people out there probably also have a positive view of said thing. I’d prefer to base my tactics on that. I guess it’s a variation of going with my gut.

Image via AD TEACHINGS via Awful Drawings

## Nov 17

### OSC + Objective-C

Haven’t played with this yet, but it looks pretty straightforward and easy to do. Might experiment with this later and post more finding. Link

## Nov 16

### Find the index of an item in a grid.

I realized I posted one half of dealing with grids - finding the X and Y given an index - but not finding the index given an X and Y. I’d typically just cache this variable so I never gave it a thought. The equation looks like this:

index = (y*rows)+x

Fun!

## Nov 15

### Local and Remote Git Branches

Another thing I always forget - when cloning a repo from a remote repository, how do you start to manipulate from a remote branch? It’s certainly easy to start messing with the default (typically master) branch, but what if you want to start from a different place?

git branch —track local_branch remote_branch

For me, this most often looks like the following:

git branch —track develop remotes/origin/develop

## Nov 14

### Vocab rehash.

I always forget these things so I’m writing them down so I don’t forget.

Unsigned vs. Signed

Signed effectively means “supports negative numbers”. Basically, a signed int can range from -2147483648 to 2147483647, after which you hit the preverbial kill screen. Note that last number. 0 technically sort of counts as a positive number in programming terms, so the negative range is just a little further.

Unsigned supports only positive numbers 0 to 4294967295. In other words if you never need a negative number (such as an auto-incrementing id in MySQL) there’s no reason to sign it.

Atomic vs. Nonatomic

I typically think of this as an Objective-C problem, but I’m sure it applies across the spectrum of computer programming.

This is mostly about the @synthesize declaration and has to do with threading. Atomic operators will do their best to insure things accessing that variable across threads will happen sequentially. Otherwise threads could feasibly change properties in the middle of execution, which can get really confusing.

Basically: Nonatomic is faster, atomic is safer.

More on this here.

Mutable vs. Immutable

Mutable can be added to and changed. Immutable cannot.

## Nov 13

I always wondered how some Facebook vendors were able to create one-click installs for adding tabs to a page. Turns out it’s pretty straightforward. Who would’ve thought?

``<a target="_blank" href="http://facebook.com/add.php?api_key=YOUR_APP_KEY&pages=1&page=YOUR_PAGE_ID">PAGE NAME</a>``

Source

## Nov 12

### Find the X,Y of an item in a grid.

I’ve done so much work with grids but I always precalculated this stuff. This is so much simpler. Assuming you know how many columns the grid has and the index of an item in the grid:

X = index%cols

Y = floor(index/cols)

Awesome.

## Nov 09

### MailChimp’s API is awesome.

Check this out. Detailed explanations on everything possible with an API key, plus examples in PHP. Wrappers in every conceivable language already built, most of them time by 3rd parties with credit and links to GitHub. There’s even a CodeIgniter library.