Skip to content

Instantly share code, notes, and snippets.

@SlaunchaMan
SlaunchaMan / JKTableViewCell.h
Created August 13, 2011 05:08
A subclass of UITableViewCell to allow for images to be added after cell creation
#import <UIKit/UIKit.h>
@interface JKTableViewCell : UITableViewCell
@end
@SlaunchaMan
SlaunchaMan / gist:2696148
Created May 14, 2012 19:51
Fun with C strings
NSString *c = @"C";
NSString *a = @"A";
const char *cValue = [c cStringUsingEncoding:NSASCIIStringEncoding];
const char *aValue = [a cStringUsingEncoding:NSASCIIStringEncoding];
NSLog(@"The value of 'C' - 'A' is %d", (int)(cValue[0] - aValue[0]));
@SlaunchaMan
SlaunchaMan / gist:3613715
Created September 3, 2012 21:27
Getting Image Data in iOS
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
size_t numberOfComponents = CGColorSpaceGetNumberOfComponents(colorSpace) + 1; // Add 1 for the alpha channel
size_t bitsPerComponent = 8;
size_t bytesPerPixel = (bitsPerComponent * numberOfComponents) / 8;
size_t bytesPerRow = bytesPerPixel * width;
uint8_t *rawData = (uint8_t*)calloc(width * height * numberOfComponents, sizeof(uint8_t));
CGContextRef context = CGBitmapContextCreate(rawData,
@SlaunchaMan
SlaunchaMan / make_non_retina_graphics.sh
Created December 7, 2012 15:57
Making non-Retina graphics
#!/bin/bash
# Your designer should be making you assets in both resolutions.
# By that, I mean they don’t just resize in Photoshop and export,
# but they actually *design* for both resolutions. Failing that,
# run this. You’ll need ImageMagick installed and in your PATH.
# The script will operate on *all* images in the current directory
# with the suffix @2*.png. Why @2* instead of @2x? In case you do
# this for iPhone 5:
@SlaunchaMan
SlaunchaMan / JKAppDelegate.m
Created January 3, 2013 03:10
Loading a nib remotely.
//
// JKAppDelegate.m
// RemoteNibLoading
//
// Created by Jeff Kelley on 1/2/13.
// Copyright (c) 2013 Jeff Kelley. All rights reserved.
//
#import "JKAppDelegate.h"

Blurb

Scala is a sometimes-intimidating programming language that is Object-Oriented, functional, statically typed and wicked badass. It comes batteries-included, featuring a rich collections API, Type inference, and dead-simple concurrency. Perhaps most poignantly though, it's also a 30MB JVM library that can compile to dalvik.

Come take a heads first dive into crafting an APK with glorious, nutritionally

@SlaunchaMan
SlaunchaMan / test.m
Created November 19, 2013 18:42
Checking if an Objective-C class implements required protocol methods using Kiwi
it(@"should implement the required methods in the protocol", ^{
unsigned int methodCount;
struct objc_method_description *methodList =
protocol_copyMethodDescriptionList(NSProtocolFromString(@"ProtocolName"),
YES,
YES,
&methodCount);
@SlaunchaMan
SlaunchaMan / build.sh
Last active February 21, 2019 08:34
Enumerate all schemes in a project, archive them, and export as IPAs.
#!/bin/bash
# Builds all targets and places IPAs in build/
# Constants
SIGNING_IDENTITY="iPhone Distribution: Detroit Labs, LLC"
# Get a list of all schemes, then build each.
xcodebuild -project PROJECT.xcodeproj -list | \
sed -n '/Schemes/,/^$/p' | \
@SlaunchaMan
SlaunchaMan / primes-test.sh
Last active August 29, 2015 13:56
Prime Factors Kata in Bash with Roundup
#!/usr/bin/env roundup
describe "prime factors"
it_succeeds_for_two() {
test "$(./primes.sh 2)" == "2"
}
it_succeeds_for_three() {
test "$(./primes.sh 3)" == "3"
@SlaunchaMan
SlaunchaMan / goddammit.m
Last active August 29, 2015 13:57
Why the heck doesn’t this work?
- (void)doTheThingAnimated:(BOOL)animated
{
CGFloat buttonAlpha = 1.0f;
CGFloat leftLabelAlpha = 1.0f;
CGFloat rightLabelAlpha = 1.0f;
if ([BUSINESS LOGIC]) {
buttonAlpha = 0.0f;
rightLabelAlpha = 0.0f;
}