Skip to content

Instantly share code, notes, and snippets.

View mitchellporter's full-sized avatar

Mitchell Porter mitchellporter

  • Seattle, WA
View GitHub Profile
@mitchellporter
mitchellporter / Angle.swift
Last active August 29, 2015 06:10
Angle.swift
// Playground - noun: a place where people can play
import Foundation
func DegreesToRadians (value:Double) -> Double {
return value * M_PI / 180.0
}
func RadiansToDegrees (value:Double) -> Double {
return value * 180.0 / M_PI
@interface NPClientAPI : AFHTTPSessionManager
- (instancetype)initWithBaseURL:(NSString *)baseURL;
/**
Singleton object.
*/
+ (NPClientAPI *)sharedAPI;
/**
// These two need to be declared outside the try/catch
// so that they can be closed in the finally block.
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
// Will contain the raw JSON response as a string.
String forecastJsonStr = null;
try {
// Construct the URL for the OpenWeatherMap query
console.log('Checking newly uploaded file');
var AWS = require('aws-sdk');
var s3 = new AWS.S3({apiVersion: '2006-03-01'});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012-09-25',
region: 'us-east-1'
});
// ID of pipeline
var pipelineId = 'myID';
// ID of ET's web output preset
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
@interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UIImageOrientation scrollOrientation;
CGPoint lastPos;
}
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView.isDragging) {
UIView *myView = cell.contentView;
CALayer *layer = myView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
// setup initial state (e.g. before animation)
cell.layer.shadowColor = [[UIColor blackColor] CGColor];
cell.layer.shadowOffset = CGSizeMake(10, 10);
cell.alpha = 0;
cell.layer.transform = CATransform3DMakeScale(0.5, 0.5, 0.5);
cell.layer.anchorPoint = CGPointMake(0, 0.5);
// define final state (e.g. after animation) & commit animation
[UIView beginAnimations:@"scaleTableViewCellAnimationID" context:NULL];
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
console.log('Checking newly uploaded file');
var AWS = require('aws-sdk');
var s3 = new AWS.S3({apiVersion: '2006-03-01'});
var eltr = new AWS.ElasticTranscoder({
apiVersion: '2012-09-25',
region: 'us-east-1'
});
// ID of pipeline
var pipelineId = 'myID';
// ID of ET's web output preset
@mitchellporter
mitchellporter / demo.js
Last active August 29, 2015 14:24 — forked from russau/demo.js
console.log('Loading event');
var AWS = require('aws-sdk');
exports.handler = function(event, context) {
console.log('Received event:');
console.log(JSON.stringify(event, null, ' '));
// Get the object from the event and show its content type
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;
var output = Math.random().toString(36).substring(7) + ".webm";