Skip to content

Instantly share code, notes, and snippets.

View ryanfitz's full-sized avatar

Ryan Fitzgerald ryanfitz

View GitHub Profile
int resultsSize = [self.dataController.products count]; //data is the previous array of data
[self.dataController.products addObjectsFromArray:products];
[self.productsView performBatchUpdates:^{
NSMutableArray *arrayWithIndexPaths = [NSMutableArray array];
for (int i = resultsSize; i < resultsSize + products.count; i++) {
[arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
}
[self.productsView insertItemsAtIndexPaths:arrayWithIndexPaths];
}
@ryanfitz
ryanfitz / s3_list.swift
Created August 3, 2014 23:48
list s3 buckets using the aws sdk
AWSS3.defaultS3().listBuckets(nil).continueWithBlock {
(task: BFTask!) -> AnyObject! in
let output : AWSS3ListBucketsOutput = task.result() as AWSS3ListBucketsOutput
println("found \(output.buckets.count) buckets")
for bucket in output.buckets as [AWSS3Bucket] {
println("Found bucket \(bucket.name)")
}
return nil
for (NSDictionary *data in responseObject[@"discussions"]) {
NFTDiscussionModel *discussion = [MTLJSONAdapter modelOfClass:[NFTDiscussionModel class]
fromJSONDictionary:data error:nil];
[items addObject:discussion];
}
success([items firstObject]);
@ryanfitz
ryanfitz / sample.js
Created October 12, 2014 14:47
dynamodb document example
var AWS = require("aws-sdk");
var DOC = require("dynamodb-doc");
var path = require('path');
var util = require('util');
var _ = require('lodash');
var async = require('async');
var internals = {};
@ryanfitz
ryanfitz / asyncDataReload.swift
Created March 8, 2015 17:08
example function for reloading sections of ASTableViews
func dataSource(dataSource: ASTableViewDataSource, removedSections: NSIndexSet?, insertedSections: NSIndexSet?, movedSections: [MovedIndex]?) {
dispatch_async(dispatch_get_main_queue()) {
self.tableView.ins_endPullToRefresh()
}
tableView.beginUpdates()
var del = NSMutableIndexSet()
var add = NSMutableIndexSet()
heightForHeaderInSection 0
heightForHeaderInSection 0
heightForHeaderInSection 1
heightForHeaderInSection 1
heightForHeaderInSection 2
heightForHeaderInSection 2
heightForHeaderInSection 3
heightForHeaderInSection 3
heightForHeaderInSection 4
heightForHeaderInSection 4
@ryanfitz
ryanfitz / ASTableViewManager.swift
Created June 16, 2015 21:56
asdk table view manager
//
// ASTableViewManager.swift
// cinch
//
// Created by Ryan Fitzgerald on 3/9/15.
// Copyright (c) 2015 cinch. All rights reserved.
//
import Foundation
import RFSectionDelta
private func unrotateImage(image : UIImage) -> UIImage {
let size = image.size
UIGraphicsBeginImageContext(size)
image.drawInRect(CGRectMake(0, 0, size.width, size.height))
let newImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return newImage
}
require 'rubygems'
require 'httparty'
require 'pp'
module NflKnockout
class Client
include HTTParty
format :xml
base_uri 'http://football.myfantasyleague.com'
require 'test/unit'
require 'nfl_scores'
require 'rubygems'
require 'fakeweb'
class NflScoresTest < Test::Unit::TestCase
def setup
FakeWeb.allow_net_connect = false
FakeWeb.register_uri(:get, "http://football.myfantasyleague.com/2009/export?TYPE=nflSchedule&W=1", :body => nfl_schedule_xml)
end