- 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 hidden or 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 hidden or 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 |
- 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 hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 |
OlderNewer