Skip to content

Instantly share code, notes, and snippets.

import UIKit
extension UIColor {
convenience init(hex: Int) {
let alpha = CGFloat((hex >> 24) & 0xff)/255
let red = CGFloat((hex >> 16) & 0xff)/255
let green = CGFloat((hex >> 8) & 0xff)/255
let blue = CGFloat((hex >> 0) & 0xff)/255
self.init(red: red, green: green, blue: blue, alpha: alpha)
}
import UIKit
@objc public protocol CenteredFlowLayoutDelegate: UICollectionViewDelegate {
func centeredFlowLayout(layout: CenteredFlowLayout, sizeAtIndexPath indexPath: NSIndexPath) -> CGSize
}
public class CenteredFlowLayout: UICollectionViewLayout {
@IBOutlet weak var delegate: CenteredFlowLayoutDelegate?
function roleCheck(user, roles) {
var promise = new Parse.Promise();
if (user) {
var roleQuery = new Parse.Query(Parse.Role);
roleQuery.containedIn("name", roles);
roleQuery.equalTo("users", user);
roleQuery.first({useMasterKey: true}).then(function(role) {
if (role) {
promise.resolve();
func refreshHeightsFromRow(fromRow: Int, toRow: Int) {
let objects = objects[fromRow..<toRow]
let width = tableView.bounds.size.width
dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), { () -> Void in
var heights: [CGFloat] = []
for o in objects {
if let question = o as? Question {
let h = min(maximumCellHeight, QuestionCell.heightForQuestion(question, width: width))
iOS 8
Error Domain=AVFoundationErrorDomain Code=-11810 "Recording Stopped" UserInfo=0x1700fb580 {NSLocalizedFailureReason=The recording reached the maximum allowable length., NSLocalizedDescription=Recording Stopped, AVErrorTimeKey=CMTime: {150/30 = 5.000}, NSUnderlyingError=0x17425a760 "The operation couldn’t be completed. (OSStatus error -16413.)"}
iOS 9
Error Domain=AVFoundationErrorDomain Code=-11810 "Recording Stopped" UserInfo={NSLocalizedDescription=Recording Stopped, NSLocalizedFailureReason=The recording reached the maximum allowable length., AVErrorRecordingSuccessfullyFinishedKey=true, AVErrorTimeKey=CMTime: {150/30 = 5.000}, NSUnderlyingError=0x13d5f1090 {Error Domain=NSOSStatusErrorDomain Code=-16413 "(null)"}}
> db.serverCmdLineOpts()
{
"argv" : [
"/usr/bin/mongod",
"--config",
"/etc/mongod.conf"
],
"parsed" : {
"config" : "/etc/mongod.conf",
"net" : {
Sent: 2800, total: 343432, expected: 1179608, 29.114079%
Sent: 2800, total: 335408, expected: 1305534, 25.691250%
Sent: 2800, total: 338208, expected: 1305534, 25.905722%
Sent: 2800, total: 341008, expected: 1305534, 26.120193%
Sent: 2800, total: 343808, expected: 1305534, 26.334665%
Sent: 2800, total: 346608, expected: 1305534, 26.549137%
Sent: 2800, total: 349408, expected: 1305534, 26.763607%
Sent: 2800, total: 346232, expected: 1179608, 29.351446%
Sent: 2800, total: 349032, expected: 1179608, 29.588812%
Sent: 2800, total: 352208, expected: 1305534, 26.978079%
public protocol PagedTableLoaderDelegate<T: PFObject> {
func pagedTableLoader(pagedTableLoader: PagedTableLoader<T>, queryFromDate fromDate: NSDate?, toDate: NSDate?, count: Int) -> PFQuery
}
class A {
func test() {
print("A")
}
}
class B: A {
override func test() {
print("B")
}
@property (nonatomic, strong) dispatch_source_t serverPollTimer;
/* ___ */
__weak typeof(self) weakSelf = self;
self.serverPollTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue());
dispatch_source_set_timer(self.serverPollTimer, dispatch_walltime(NULL, 7*NSEC_PER_SEC), 7*NSEC_PER_SEC, 1e8);
dispatch_source_set_event_handler(self.serverPollTimer, ^{
[weakSelf updateCurrentJobState];
});