Skip to content

Instantly share code, notes, and snippets.

@rutgerfarry
rutgerfarry / iOS-Makefile
Last active May 13, 2017 21:18
Simple Makefile for iOS projects. Helps when developing w/o Xcode
APPNAME=
ORG=
SCHEME=$(APPNAME) # default scheme name, yours may be different
BUNDLEID=com.$(ORG).$(APPNAME) # default bundle name, yours may be different
CC=xcodebuild # if using xcbuild or other, enter that here
OS=10.3
DEVICE=iPhone 7
all: build run
import numpy as np
import sys
try:
filename = sys.argv[1]
inFile = open(filename, "r")
outFile = open("best-output.txt", "w+")
except:
print("Error: Must provide valid filename as a command line argument")
raise
import numpy as np
import sys
try:
filename = sys.argv[1]
inFile = open(filename, "r")
outFile = open("best-output.txt", "w+")
except:
print("Error: Must provide valid filename as a command line argument")
raise
@rutgerfarry
rutgerfarry / best_path.py
Last active October 20, 2015 00:14
follows the yellow brick road
import numpy as np
arr = np.array([[1, 2, 5],
[8, 7, -7],
[-3, -1, 6]])
# Main Algorithm, takes a numpy array as
def mostValuablePath(arr):
arrHeight = arr.shape[0] - 1
arrWidth = arr.shape[1] - 1
def maxSubArrayDynamic(arr):
maxSum = currentSum = 0
for i in arr:
if currentSum + i > 0:
currentSum = currentSum + i
else:
currentSum = 0
if currentSum > maxSum:
maxSum = currentSum
return maxSum
def maxSubArray(arr):
maxSum = 0
# try all subarray lengths
for j in range(0, len(arr)):
# compute first subarray sum
curSum = 0
for element in arr[0 : j]:
curSum += element
# try all subarray locations
for i in range(0, len(arr) - j):
def maxSubArray(arr):
maxSum = 0
# try all subarray lengths
for j in range(0, len(arr)):
# try all subarray locations
for i in range(0, len(arr) - j):
currentSum = 0
# sum subarray
for element in range(arr[i], arr[i+j]):
currentSum += element
@rutgerfarry
rutgerfarry / server.js
Created April 11, 2015 15:55
A simple static web server written in node
var http = require('http'),
url = require('url'),
path = require('path'),
fs = require('fs'),
port = process.argv[2] || 8888;
http.createServer (function (request, response) {
var uri = url.parse(request.url).pathname,
filename = path.join(process.cwd(), uri);
/// ❤️
UIBezierPath* bezierPath = UIBezierPath.bezierPath;
[bezierPath moveToPoint: CGPointMake(91.68, 7.32)];
[bezierPath addCurveToPoint: CGPointMake(91.68, 42.68) controlPoint1: CGPointMake(101.44, 17.09) controlPoint2: CGPointMake(97.44, 32.91)];
[bezierPath addCurveToPoint: CGPointMake(49.5, 85.99) controlPoint1: CGPointMake(85.91, 52.44) controlPoint2: CGPointMake(50.44, 90.64)];
[bezierPath addCurveToPoint: CGPointMake(7.32, 42.68) controlPoint1: CGPointMake(48.56, 90.64) controlPoint2: CGPointMake(13.09, 52.44)];
[bezierPath addCurveToPoint: CGPointMake(7.32, 7.32) controlPoint1: CGPointMake(1.56, 32.91) controlPoint2: CGPointMake(-2.44, 17.09)];
[bezierPath addCurveToPoint: CGPointMake(42.68, 7.32) controlPoint1: CGPointMake(17.09, -2.44) controlPoint2: CGPointMake(32.91, -2.44)];
[bezierPath addCurveToPoint: CGPointMake(49.5, 15.01) controlPoint1: CGPointMake(46.28, 10.93) controlPoint2: CGPointMake(48.56, 10.36)];
[bezierPath addCurveToPoint: CGPointMake(56.32, 7.32) controlPoint1: CGPointMake(50.4