Skip to content

Instantly share code, notes, and snippets.

View ryanfitz's full-sized avatar

Ryan Fitzgerald ryanfitz

View GitHub Profile
@ryanfitz
ryanfitz / dynamoLocal.js
Created November 23, 2015 14:07
connect vogels to local dynamo db instance
var opts = { endpoint : 'http://dynamodb-local:8000', apiVersion: '2012-08-10' };
var localDynamo new AWS.DynamoDB(opts);
vogels.dynamoDriver(localDynamo);
@ryanfitz
ryanfitz / PurchaseSchema.js
Last active October 24, 2015 02:41 — forked from Hmachalani/PurchaseSchema.js
Purchase Schema
var vogels = require('vogels'),
Joi = require('joi');
vogels.AWS.config.loadFromPath('./config.json');
var Purchase= vogels.define('Purchase', {
hashKey : 'uid',
rangeKey: 'tok',
// enable timestamps support
timestamps : true,
%s/^\(.*\)$/"\1"\,/
@ryanfitz
ryanfitz / hash.js
Last active September 4, 2015 17:29
// npm install --save string-hash
var stringHash = require('string-hash');
var d = new Date();
var dateStr = d.getFullYear() + '-' + d.getMonth() + '-' + d.getDay()
var hashKey = dateStr + ':' + stringHash(account.id) %100;
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
}
@ryanfitz
ryanfitz / indexAccountsToCloudsearch.js
Created July 17, 2015 18:46
index dynamodb data to cloudsearch using AWS Lambda
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
var cloudsearchdomain = new AWS.CloudSearchDomain({endpoint: 'doc-dev-cinch-accounts-ltmqj5gt5mjb5hg5eyqaf2v5hu.us-east-1.cloudsearch.amazonaws.com'});
var documents = event.Records.map(function(record) {
var data = {id : record.dynamodb.Keys.id.S};
if (record.eventName === 'REMOVE') {
data.type = 'delete'
@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
@ryanfitz
ryanfitz / header.swift
Created June 15, 2015 04:11
asdk header node workaround
func tableView(tableView: UITableView!, viewForHeaderInSection section: Int, delegate : PollHeaderNodeDelegate?) -> UIView! {
var view = tableView.dequeueReusableHeaderFooterViewWithIdentifier("Header") as? UITableViewHeaderFooterView
if view == nil {
view = UITableViewHeaderFooterView(reuseIdentifier: "Header")
}
view?.backgroundView = UIImageView()
let contentView = view!.contentView
heightForHeaderInSection 0
heightForHeaderInSection 0
heightForHeaderInSection 1
heightForHeaderInSection 1
heightForHeaderInSection 2
heightForHeaderInSection 2
heightForHeaderInSection 3
heightForHeaderInSection 3
heightForHeaderInSection 4
heightForHeaderInSection 4
@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()