- Keep classes and similar below 100 lines.
- Keep methods below ten lines, preferably five.
- Don't check state variables or type to determine behavior (make a new type).
- Make data sources their own type.
- View controllers should subscribe to no more than two delegate protocols.
- Classes manage their own behavior.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
rubocop --format emacs $BB_DOC_PATH | sed 's/W:/warning:/g' | sed 's/C:/note:/g' | sed 's/F:/error:/g' | bbresults -p gcc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require "socket" | |
class Connection | |
def initialize(client:, server:) | |
@client = client | |
@server = server | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
#include <getopt.h> | |
#include <string.h> | |
static struct config { | |
bool yell; | |
} cfg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "async" | |
# Simple method to measure how long an operation takes. | |
def measure_time | |
start = Time.now | |
yield | |
puts "Duration: #{Time.now - start}" | |
end |
- Keep classes and similar below 100 lines.
- Keep methods below ten lines, preferably five.
- Don't check state variables or type to determine behavior over making a type.
- Make data sources their own type.
- View controllers should subscribe to no more than two delegate protocols.
- Make classes manage their own behavior.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rss' | |
require 'open-uri' | |
class Blog | |
def initialize(name) | |
@name = name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define bitread(value, bit) (((value) >> (bit)) & 0x01) | |
#define bitset(value, bit) ((value) |= (1UL << (bit))) | |
#define bitclear(value, bit) ((value) &= ~(1UL << (bit))) | |
#define bitwrite(value, bit, bitvalue) (bitvalue ? bitset(value, bit) : bitclear(value, bit)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
public extension UITableView { | |
public func deselectSelectedRowAnimated(animated: Bool) { | |
if let indexPath = indexPathForSelectedRow() { | |
deselectRowAtIndexPath(indexPath, animated: animated) | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by Collin Donnell on 7/22/15. | |
// Copyright (c) 2015 Collin Donnell. All rights reserved. | |
// | |
import CoreData | |
extension NSManagedObjectContext { | |
convenience init(parentContext parent: NSManagedObjectContext, concurrencyType: NSManagedObjectContextConcurrencyType) { |
NewerOlder