Skip to content

Instantly share code, notes, and snippets.

View raphaelschaad's full-sized avatar

Raphael Schaad raphaelschaad

View GitHub Profile
@mpospese
mpospese / CGRectIntegralScaled.m
Created February 28, 2013 03:34
Pixel aligns rectangles, taking the device's screen scale into account.
CGRect CGRectIntegralScaledEx(CGRect rect, CGFloat scale)
{
return CGRectMake(floorf(rect.origin.x * scale) / scale, floorf(rect.origin.y * scale) / scale, ceilf(rect.size.width * scale) / scale, ceilf(rect.size.height * scale) / scale);
}
CGRect CGRectIntegralScaled(CGRect rect)
{
return CGRectIntegralScaledEx(rect, [[UIScreen mainScreen] scale]);
}
@dlackty
dlackty / oclint.rb
Created February 7, 2013 09:57
Homebrew formula for OCLint 0.6.
require 'formula'
class Oclint < Formula
homepage 'http://oclint.org'
url 'http://archives.oclint.org/releases/0.6/oclint-0.6-x86_64-apple-darwin12.tar.gz'
version '0.6'
sha1 '9fb4bdfb6dbce14986d863d8b672870c0ae08ec8'
depends_on 'llvm'
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@drance
drance / gist:4546014
Created January 16, 2013 09:57
Workaround to vanilla UICollectionView+UICollectionViewFlowLayout using non-integral origins, leading to blurry cells.
@implementation BHSCollectionViewFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in allAttrs) {
attributes.frame = CGRectIntegral(attributes.frame);
}
return allAttrs;
}
anonymous
anonymous / yearofedits.py
Created January 8, 2013 22:16
Given a OpenStreetMap changeset download, and a population density download, plots the global edits-per-population density
#!/usr/bin/env python
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
from math import floor, log
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from colorsys import hsv_to_rgb
import numpy as np
import os.path
@ishikawa
ishikawa / objcfmt.py
Created March 13, 2010 11:28
The code formatter for Objective-C source programs.
#!/usr/bin/env python
# vim: set filetype=python :
"""
Synopsis
================================
*objcfmt* is the code formatter for Objective-C source programs.