Skip to content

Instantly share code, notes, and snippets.

@bjhomer
bjhomer / gist:8047113
Last active December 31, 2015 21:29
I lived in Spain for two years, but don't speak it regularly any more. So it's possible I've missed the nuance in a word here or there. The overall content is correct, though.

Biscuit, the app that returns "beautiful" to Reddit.

Although Reddit is one of the most important communities in the Internet, its aesthetics might lead you to believe otherwise. To fix this problem, an app has been created.

We're talking about Biscuit, an app for iPad that profoundly changes the appearance of this social news website.

Reddit is a platform that allows any person to upload images, share news, or create topics for community debate. Other users can comment and contribute to the topic.

Biscuit transforms all this disorder into something more pleasant to the eyes. Following the minimalist line of Apple's products, it intends to organize all the articles and categories.

@bjhomer
bjhomer / glyph_crash.md
Last active December 30, 2015 20:39
Any idea what could cause this crash?

A user is reporting a crash, and I cannot see how it could possibly be happening.

The code in question (in frame #18 below) is this:

NSFont *font = [NSFont fontWithName:@"Helvetica Neue" size:13];
// some other code
NSGlyph typicalGlyph = [font glyphWithName:@"e"];
@bjhomer
bjhomer / delay.m
Last active December 29, 2015 09:29
An ObjC-level equivalent to dispatch_after
[[NSOperationQueue mainQueue] addOperationAfterDelay:2 withBlock:^{
NSLog(@"I'm in the future!");
}];
@bjhomer
bjhomer / class_name_ideas.md
Last active December 28, 2015 08:59
Naming things is hard

Naming things is hard

So let's work together

Instead of having one controller object that does everything, I've been trying to split things out into various task-focused. This means I have to come up with names for these objects, such as "CoverAnimationDriver", etc. Naming things is hard, so I want your help. Aside from domain-specific bag-of-properties model objects, what nouns have you used in class names? In my experience, these are usually used as a suffix on the class name.

Here's what I've come up with so far:

  • View
  • Controller
  • Manager
  • Data Source
@bjhomer
bjhomer / after.m
Last active December 24, 2015 22:49
- (BOOL)shouldShowMenuIcon
{
return [AgentManager sharedManager].shouldShowInMenuBar;
}
- (void)setShouldShowMenuIcon:(BOOL)enabled
{
AgentManager *manager = [AgentManager sharedManager];
manager.shouldLaunchAtStartup = enabled;
manager.shouldShowInMenuBar = enabled;
@bjhomer
bjhomer / 1pxline.m
Created September 13, 2013 16:11
Drawing a 1px line on both 1x and 2x screens.
// A 1pt rect along the bottom of the view
NSRect bottomLineRect = NSMakeRect(0 , NSHeight(self.bounds) - 1, NSWidth(self.bounds), 1);
// Convert to the backing rect, and make sure that it is only 1px tall.
NSRect backingRect = [self convertRectToBacking:bottomLineRect];
backingRect.size.height = 1;
bottomLineRect = [self convertRectFromBacking:backingRect];
@bjhomer
bjhomer / config.fish
Last active March 20, 2019 21:30
This is a modified version of the built-in fish git prompt. It uses the colors I like. :)
if status --is-interactive
set -gx PATH /usr/local/bin ~/Applications/ $PATH;
set -gx EDITOR "subl -nw"
end
# My colors
set -g fish_color_autosuggestion 444444
set -g fish_color_command 00ff00
set -g fish_color_comment red
set -g fish_color_cwd cyan
@bjhomer
bjhomer / gist:5369684
Last active December 16, 2015 03:29
Explaining complex multiplication as rotation.

Imagine that a number line lives on a 2D plane. "Positive" on the number line is in the 0° direction, and "Negative" on the number line is in the 180° direction.

"1" is a vector of length 1, pointing in the direction 0°.

"-3" is a vector of length 3, pointing in the direction 180°.

Multiplication of these vectors can be understood as multiplying the lengths and adding the angle of each vector.

"1 * -3" is a vector of length (1*3 = 3), pointing in the direction (0° + 180° = 180°). In other words, "1 * -3" is a vector of length 3, pointing in the negative direction.

@bjhomer
bjhomer / bad.m
Last active December 15, 2015 19:49
-Wformat-nonliteral is picky
NSString *template = NSLocalizedString(@"My name is %@", @"A label for displaying the user's name");
NSString *str = [NSString stringWithFormat:template, @"John"];
// warning: format string is not a string literal [-Wformat-nonliteral]
label.text = str;
@bjhomer
bjhomer / main.m
Last active December 15, 2015 16:59
Forward declaration of primitive variables. Turns out it's legal.
#import <Foundation/Foundation.h>
int foo;
int foo;
int foo;
int foo;
int foo = 4;
int main(int argc, const char **argv) {
NSLog(@"foo: %i", foo); // Prints '4'