Skip to content

Instantly share code, notes, and snippets.

@harukizaemon
harukizaemon / garlic-chili-noodles.md
Created August 2, 2022 06:17
Garlic chili noodles

Garlic chili noodles

Ingredients

  • 100g extra firm tofu
  • 4-5 pieces garlic
  • small piece ginger
  • 3 sticks green onion
  • 3 tbsp avocado oil
  • 3 tsp dark soy sauce
  • 150g knife pare noodles
if (myOptionalThing.isPresent()) {
myOptionalThing.get().doSomething();
}
// vs
myOptionalThing.ifPresent(MyOptionalThing::doSomething);
// vs
public static boolean isPresent(final Optional<?> ... optionals) {
for (final Optional<?> optional : optionals) {
if (!optional.isPresent()) {
return false;
}
}
return optionals.length > 0;
}

Keybase proof

I hereby claim:

  • I am harukizaemon on github.
  • I am haruki_zaemon (https://keybase.io/haruki_zaemon) on keybase.
  • I have a public key whose fingerprint is F16A BCF7 8D71 631E 4810 8091 FCFC 89CE 3725 4EF6

To claim this, I am signing this object:

@harukizaemon
harukizaemon / gist:0c5dd4db7406d119b166
Created July 9, 2014 03:50
Replace assertThat with assertEquals
assertThat\((.*), is\((.*)\)\);
assertEquals($2, $1);
assertThat\((.*), nullValue\(\)\);
assertNull($1);
@harukizaemon
harukizaemon / gist:5075599
Created March 3, 2013 10:34
Example of the kinds of TODO's I write. It's not really a todo, more of a "TODON'T" but it's also a reminder to do something else in the future say, for example, if we were to drop iPhone 4 support.
// TODO: Using the main context as the parent of the background context works
// fantastically on the iPhone 5 but not so much on the 4 where it takes
// too much processing from on the main thread and makes it jerky and
// unresponsive. Same goes for merging changes the old-fashioned way.
//
// As a compromise, we use old-fashioned merging but only deletions, as
// these would otherwise cause the main context to barf if/when trying
// to save an object that was deleted in the background. *phew*
- (void)performUsingBlock:(void (^)(NSManagedObjectContext *context))block {
[self performBlock:^{
block(self);
}];
}
- (void)performUsingBlockAndWait:(void (^)(NSManagedObjectContext *context))block {
[self performBlockAndWait:^{
block(self);
}];
@harukizaemon
harukizaemon / gist:3993004
Created November 1, 2012 10:45
Enumerating over results from an asynchronous network call

I have a facade over an asynchronous network call—that also performs pagination, ie multiple network calls in order to handle very large result sets—along the lines of this but I now want to use it in a context where knowing when it's finished iterating is important (e.g in an NSOperation):

[enumerateFoosAtURL:URL usingBlock:^(id foo, BOOL *stop) {
  ...
} failure:^(NSError *error) {
  ...
}];
@harukizaemon
harukizaemon / gist:2251098
Created March 30, 2012 12:09
Load a custom view from a XIB
- (id)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];
if (self) {
[self addSubview:[[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil] objectAtIndex:0]];
}
return self;
}
@harukizaemon
harukizaemon / gist:1597334
Created January 11, 2012 23:01
Gender balance statistics
Employed persons by detailed occupation, sex, race, and Hispanic or Latino ethnicity:
ftp://ftp.bls.gov/pub/special.requests/lf/aat11.txt
Google searches for articles relating to gender imbalance in various professions: Literally google searches for "gender imbalance in <profession>"
accounting = 303,000
nursing = 192,000
teaching = 503,000
policing = 261,000