This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func drawLineFrom(fromPoint: CGPoint, toPoint: CGPoint, color: UIColor, brushWidth: CGFloat) { | |
UIGraphicsBeginImageContext(view.frame.size) | |
let context = UIGraphicsGetCurrentContext() | |
paintCanvas.image?.drawInRect(CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)) | |
let colorConverted = CIColor(color: color)! | |
let redComp = colorConverted.red() | |
let greenComp = colorConverted.green() | |
let blueComp = colorConverted.blue() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gravity.action = { () -> (Void) in | |
for paintBall in self.paintBalls { | |
if !contains(self.paintBallsToBeRelocated, paintBall) { | |
self.drawLineFrom(paintBall.lastPoint, toPoint: paintBall.center, color: paintBall.backgroundColor!, brushWidth: self.paintBallRadius * 2) | |
paintBall.lastPoint = paintBall.center | |
if self.shouldRelocatePaintBall(paintBall) { | |
if !contains(self.paintBallsToBeRelocated, paintBall) { | |
self.paintBallsToBeRelocated.append(paintBall) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func stairs(n: Int) -> [[Int]] { | |
if n == 0 { | |
return [] | |
} else if n == 1 { | |
let one = [[1]] + stairs(n - 1) | |
let one2 = stairs(n - 1) + [[1]] | |
return one + one2 | |
} else if n == 2 { | |
let one = [[1]] + stairs(n - 1) | |
let two = [[2]] + stairs(n - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* Name : stairclimber.cpp | |
* Author : | |
* Date : | |
* Description : Lists the number of ways to climb n stairs. | |
* Pledge : | |
******************************************************************************/ | |
#include <iostream> | |
#include <vector> | |
#include <algorithm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let group = dispatch_group_create() | |
dispatch_group_enter(group) | |
self.analyticCrawler.fetchLikes { (succeeded, likes) -> (Void) in | |
if succeeded { | |
self.likes = likes | |
} else { | |
self.likes = [] | |
} | |
dispatch_group_leave(group) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"quotes": [ | |
{ | |
"author": "Abraham Lincoln", | |
"quote": "Things may come to those who wait, but only the things left by those who hustle.", | |
"image": "http://upload.wikimedia.org/wikipedia/commons/1/1b/Abraham_Lincoln_November_1863.jpg" | |
}, | |
{ | |
"author": "Adam Smith", | |
"quote": "The great secret of education is to direct vanity to proper objects.", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// Programming Assignment 4 - Water Jugs (Swift) | |
// | |
// Created by Zachary Shakked on 10/21/15. | |
// Copyright © 2015 Zachary Shakked. All rights reserved. | |
// | |
import Foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// Programming Assingment 4 - Water Jugs | |
// | |
// Created by Zachary Shakked on 10/21/15. | |
// Copyright © 2015 Zachary Shakked. All rights reserved. | |
// | |
#include <iostream> | |
#include <vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func follow(account: Account, user: User, completion : (Bool) -> (Void)) { | |
let urlString = "https://api.instagram.com/v1/users/\(user.id)/relationship?access_token=\(account.accessToken)" | |
let parameters = ["action" : "follow"] | |
let jsonSerialization = try! NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions.PrettyPrinted) | |
let json = String(data: jsonSerialization, encoding: NSUTF8StringEncoding)! | |
let dict = ["body" : json] | |
manager.responseSerializer = AFJSONResponseSerializer() | |
manager.POST(urlString, parameters: dict, success: { (operation, result) -> Void in | |
let result = result as! NSDictionary | |
let data = result["data"] as! NSDictionary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Instagram = require('instagram-node').instagram({port : process.env.PORT || 443, enforce_signed_requests : true}); | |
var Datapoint = require('./datapoint.js'); | |
var CronJob = require('cron').CronJob; | |
// Every call to `ig.use()` overrides the `client_id/client_secret` | |
// or `access_token` previously entered if they exist. | |
Instagram.use({ access_token: '215615213.156af3d.fccd9a4872aa42738ea71a649f365a85' }); | |
Instagram.use({ client_id: '156af3d753824c2aba64eb83ab10f53d', client_secret: '809b9a46b5e94817b1a65ae3069370a1' }); | |
var Parse = require('parse/node').Parse; | |
Parse.initialize("OfPZoW3GA3aKIgT61enhVaNydnEvICdH9GCReAKM", "fPByJ4b9CmVbLBC9jQZhjqlswhVTNchnStLwGZVe"); |
OlderNewer