I hereby claim:
- I am jtbandes on github.
- I am jtbandes (https://keybase.io/jtbandes) on keybase.
- I have a public key whose fingerprint is 916E DA3E 8754 7C0B 173E D8E3 A6BB C78B 72E6 00C6
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// Battery logger | |
// Jacob Bandes-Storch | |
// April 22, 2015 | |
import Foundation | |
import IOKit | |
func write(s: String, to file: UnsafeMutablePointer<FILE>) |
#if os(iOS) | |
import UIKit | |
#else | |
import AppKit | |
#endif | |
/// A set of constraints prepared from a visual format string, in the style of | |
/// `NSLayoutConstraint.constraintsWithVisualFormat()`, with the additional ability | |
/// to supply views and metrics in a string interpolation. | |
/// |
// Before realizing that NSFastGenerator exists... | |
func enumerate(c: NSFastEnumeration) -> SequenceOf<AnyObject> { | |
return SequenceOf<AnyObject> { () -> GeneratorOf<AnyObject> in | |
let bufSize = 16 | |
var objects = UnsafeMutablePointer<AnyObject?>.alloc(bufSize) | |
var state = NSFastEnumerationState() | |
var currentCount = 0 |
[merge] | |
conflictstyle = diff3 | |
[alias] | |
b = branch | |
ci = commit | |
co = checkout | |
cp = cherry-pick | |
di = diff | |
ds = diff --stat | |
f = fetch -pt |
// The free monoid | |
protocol Free { | |
class var ε: Self { get } | |
func +(lhs: Self, rhs: Self) -> Self | |
} | |
extension String: Free { | |
static var ε: String { return "" } | |
} |
func sift<T, S: Sequence where S.GeneratorType.Element == Optional<T>>(xs: S) -> GeneratorOf<T> { | |
var gen = xs.generate() | |
return GeneratorOf<T> { | |
var next: T?? | |
do { | |
next = gen.next() | |
if !next { return nil } | |
} while !(next!) | |
return next! | |
} |
func bytes<T: UnsignedInteger>(val: T) -> GeneratorOf<UInt8> { | |
var current = val as UInt64 | |
var step = 0 | |
return GeneratorOf<UInt8> { | |
if step >= sizeof(T) { return nil } | |
current >>= 8; step++ | |
return UInt8(current & UInt64(UInt8.max)) | |
} | |
} |
#import "JTAsynchronousImageView.h" | |
@interface JTAsynchronousImageView () | |
@property (nonatomic, copy) void (^loadingBlock)(JTAsynchronousImageViewLoadCompletionHandler completionHandler); | |
@property (nonatomic, strong) void (^cancellationBlock)(); | |
@end | |
@implementation JTAsynchronousImageView { | |
// Queue for the image that is currently loading. | |
dispatch_queue_t _currentQueue; |
require "json" | |
require "zlib" | |
require "open-uri" | |
require "pp" | |
scores = Hash.new {|h,k| h[k] = [] } | |
for user in %w[13414 9388 9495 8318 4408 3117 219 292 13 5472 218] | |
print "Fetching page #{p}..." | |
response = JSON.parse Zlib::GzipReader.new(open("http://api.stackexchange.com/2.0/users/#{user}/answers?key=U4DMV*8nvpm3EOpvf69Rxw((&page=1&pagesize=35&fromdate=1331856000&todate=1333367940&order=desc&sort=votes&site=apple&filter=!b3Wz0N7mYj4b)3")).read |