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
Get the x and y of an object around a radius, given an angle.
x = cos(radians(angle)) * radius
y = sin(radians(angle)) * radius
You can create weird orbits by changing the result of sin. For example:
y = sin(radians(angle))/2 * radius;
And of course, add offset X and Ys if your circle isn’t at 0,0.
x = (cos(radians(angle)) * radius) + offsetX
y = (sin(radians(angle)) * radius) + offsetY
Get the distance between two points.
sqrt(pow(y2-y1,2) + pow(x2-x1,2))
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
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
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
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
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.
Mutable vs. Immutable
Mutable can be added to and changed. Immutable cannot.
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>
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)
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.
Facebook could learn a lot about documentation from this.
How come car companies can’t come out with annual feature changes the same way Apple does? Tesla seems best geared to think this way and there’s certainly no shortage of inspiring model cars, but it seems like there’s a decided lack of interest in the rest of the mechanics of the car.
Is it that car companies invest everything in safety and exterior design? There’s nobody interested in thinking about EZ pass integration in the car? In changing the way the windows slide up and down?