Skip to content

Instantly share code, notes, and snippets.

View chelseatroy's full-sized avatar

Chelsea Troy chelseatroy

View GitHub Profile
@chelseatroy
chelseatroy / ListOfFruitsViewControllerTest.swift
Created January 26, 2017 02:32
Passing Information With Segues Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import FruitApp
class ListOfFruitsViewControllerTest: XCTestCase {
...
func testShowsFruitDetailsWhenFruitRowIsTapped() {
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Last active January 27, 2017 23:24
Load from Storyboard Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
var fakeExampleService: FakeExampleService!
override func setUp() {
@chelseatroy
chelseatroy / ExampleViewControllerTest.swift
Last active January 27, 2017 23:26
Load from Storyboard Example iOS
import XCTest
import Hamcrest
import FutureKit
@testable import MyExampleApp
class ExampleViewControllerTest: XCTestCase {
...
@Configuration
@EnableBatchProcessing
public class XmlParsingApplication {
@Bean
public StaxEventItemReader itemReader() throws Exception {
StaxEventItemReader reader = new StaxEventItemReader<>();
reader.setName("birthday");
reader.setResource(new ClassPathResource("all_members.xml"));
@chelseatroy
chelseatroy / VillainService.swift
Last active March 30, 2017 21:31
Asynchronous Calls with FutureKit
import FutureKit
import SwiftyJSON
class VillainService {
let url: String
var session: URLSession = URLSession.shared
func getVillainList() -> Future<VillainResponse> {
let promise = Promise<VillainResponse>()
@chelseatroy
chelseatroy / VillainServiceTest.swift
Last active March 30, 2017 21:34
Testing Asynchronous Calls With FutureKit
import XCTest
import Nimble
import SwiftyJSON
import FutureKit
@testable import VillainApp
class VillainServiceTest: XCTestCase {
var service: VillainService!
@chelseatroy
chelseatroy / NetworkingMocks.swift
Created March 30, 2017 21:48
Testing Asynchronous Calls with FutureKit
class MockSession: URLSession {
var completionHandler: ((Data?, URLResponse?, Error?) -> Void)?
var request: URLRequest?
let stubbedDataTask: MockURLSessionDataTask = MockURLSessionDataTask()
override func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTask {
self.completionHandler = completionHandler
self.request = request
return stubbedDataTask
@chelseatroy
chelseatroy / VillainsMasterViewController.swift
Last active March 30, 2017 22:13
Asynchronous Calls With FutureKit
import FutureKit
import UIKit
class VillainsMasterViewController: UIViewController {
let villainService: VillainService?
...
func viewDidLoad() {
villainService?.getVillainList()
@chelseatroy
chelseatroy / linear_regressor.py
Created April 9, 2017 15:45
Linear Regressor
class LinearRegressor(Object):
def gradient_descent(self, x, y, alpha, max_iterations):
num_rows = x.shape[1] + 1
w = np.array([random.random() for item in range(num_rows)]).reshape(num_rows,1)
best_weights = []
lowest_cost = None
iter = 1
@chelseatroy
chelseatroy / learner.py
Created April 12, 2017 21:17
Autograd Regressor
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import autograd.numpy as np # Thinly-wrapped numpy
from autograd import grad as compute_grad # The only autograd function you may ever need
class learner():
def __init__(self,**args):