Skip to content

Instantly share code, notes, and snippets.

@brockboland
brockboland / example.swift
Created May 23, 2017 16:17
Instance method reference on class
import UIKit
class Foo {
private let someID: String
init() {
self.someID = UUID().uuidString
}
@brockboland
brockboland / bookmarklet.js
Last active July 11, 2016 17:16
Bookmarklet to expand outdated GitHub comments
// From BrendanAnnable: https://coderwall.com/p/akdgoq/expand-all-outdated-diff-comments-in-a-github-pull-request#comment_27799
javascript:Array.from(document.getElementsByClassName('outdated-diff-comment-container')).forEach(l => l.classList.add('open'));
@brockboland
brockboland / how.js
Created February 20, 2016 15:43
Bookmarklet to figure out how I wound up on a page
javascript:if(document.referrer) window.open(document.referrer, '_blank'); else alert("No referrer found");
@brockboland
brockboland / gist:11272776
Last active August 29, 2015 14:00
Auto-sized UITableViewCells. This has *terrible* performance: a table with ~15 rows was noticeably jittery. It might be OK for very small tables with only a couple cells.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
/**
* As long as your custom cell classes are laid out in Interface Builder and
* have Autolayout constraints to the top and bottom edges of the content view,
* the size of the cell can be computed based on how tall it needs to be.
*
* USE AT YOUR OWN RISK. This causes a noticable performance hit on a table of
* only about 15 cells. It might work OK on tables with only a few cells, but
* be sure to test it for your actual use case. I'm only sharing this on gist
* because I found it interesting.
@brockboland
brockboland / gist:9863500
Last active August 29, 2015 13:57
iOS 7: Resize the bottom constraint on a view when the keyboard displays. Don't copy-paste directly: the property needs to go in the interface, and be connected to the constraint from IB.
// Based on http://stackoverflow.com/a/12925659/2185
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *bottomConstraint;
- (void)viewDidLoad {
[super viewDidLoad];
// Subscribe to the keyboard will show notification
[[NSNotificationCenter defaultCenter] addObserver:self
-(BOOL)isDarkImage:(UIImage*) inputImage {
BOOL isDark = FALSE;
CFDataRef imageData = CGDataProviderCopyData(CGImageGetDataProvider(inputImage.CGImage));
const UInt8 *pixels = CFDataGetBytePtr(imageData);
int darkPixels = 0;
int length = CFDataGetLength(imageData);
@brockboland
brockboland / gist:8921355
Created February 10, 2014 18:22
Better video-to-gif
# Convert a movie file to a gif. Better quality!
# The output file is the original file with .gif tacked on
# See http://superuser.com/a/556031/1090
function goodgif {
if [ -z "$1" ]
then
# No parameter passed, show usage
echo "Usage: goodgif filename.mov"
echo "Resulting gif is stored as out.gif"
else
@brockboland
brockboland / gist:7361176
Created November 7, 2013 20:19
Places to change your name if you legally change it
  • Social Security Card
  • Passport
  • Driver's license
  • Life insurance
  • Health insurance
  • Dental insurance
  • Renter's Insurance
  • HR at work
  • Checking/savings account
  • Order new checks
@brockboland
brockboland / gist:7269148
Created November 1, 2013 17:51
I'm not good at remembering long commands, so my .bash_profile is littered with things like this. This one converts a movie file into a gif. See https://gist.github.com/dergachev/4627207 for details.
# Convert a movie file to a gif. Crappy quality, only good for short screen cap
# See https://gist.github.com/dergachev/4627207
function gifify {
if [ -z "$1" ]
then
# No parameter passed, show usage
echo "Usage: gifify filename.mov"
echo "Resulting gif is stored as out.gif"
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif
-(void) initStringValue: (NSString *) newValue {
myString = newValue;
}
-(void) changeStringValue: (NSString *) newValue {
// Something needs to change here
myString = newValue;
}
MyClass * objA = [[MyClass alloc] init];