Skip to content

Instantly share code, notes, and snippets.

View henrytkirk's full-sized avatar

Henry T Kirk henrytkirk

View GitHub Profile
@henrytkirk
henrytkirk / gist:f0fb46901e7657d03372cdb66c6f5ce2
Created February 18, 2019 03:45
Stock Functions for Google Sheets
/// 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 December 15, 2014 02:07
MergeSort with Objective-C
- (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 December 15, 2014 02:04
QuickSort with Objective-C
- (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