Skip to content

Instantly share code, notes, and snippets.

Avatar

Henry T Kirk henrytkirk

View GitHub Profile
View gist:f0fb46901e7657d03372cdb66c6f5ce2
/// Usage: =getStockPrice("AAPL")
/// Returns: 150.00
function getStockPrice(ticker) {
const stockURL = "https://ws-api.iextrading.com/1.0/stock/";
var response = UrlFetchApp.fetch(stockURL + ticker + "/price");
return JSON.parse(response);
}
/// Usage: =getStockChangePercent("AAPL")
/// Returns: "1.0%"
@henrytkirk
henrytkirk / MergeSort
Created Dec 15, 2014
MergeSort with Objective-C
View MergeSort
- (NSArray *)mergeSort:(NSArray *)array {
if (array.count == 1) {
return array;
}
// Split array in two
NSInteger firstHalfCount = array.count/2;
NSInteger secondHalfCount = array.count - firstHalfCount;
NSArray *arrayOne = [array subarrayWithRange:NSMakeRange(0, firstHalfCount)];
@henrytkirk
henrytkirk / QuickSort
Created Dec 15, 2014
QuickSort with Objective-C
View QuickSort
- (NSArray *)quickSortWithArray:(NSArray *)array {
if (array.count == 0) {
return array;
}
// Use first item as pivot
NSNumber *pivot = array[0];
// Creat temp arrays to hold values