This file contains hidden or 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
<html> | |
<head> | |
<title>tile calc</title> | |
</head> | |
<body> | |
<script> | |
const degToRad = Math.PI/180; | |
function getTileZXY(zxyStr) { // e.g. 12/773/1447 |
This file contains hidden or 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
class Vector { | |
constructor(a, b) { | |
if (a instanceof Point && b instanceof Point) { | |
this.x = b.x - a.x; | |
this.y = b.y - a.y; | |
this.z = b.z - a.z; | |
} | |
else { | |
this.x = a || 0; | |
this.y = b || 0; |
This file contains hidden or 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
function leapYear(year) { | |
return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0); | |
}; | |
/** | |
* Converts a decimal date, e.g. January 15th 2017 would be 14 / 365 + 2017 = 2017.0384 (days start at 0) | |
* @param decimalDate | |
*/ | |
function convertDecimalDate(decimalDate) { | |
const year = parseInt(decimalDate); |
This file contains hidden or 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
/*** | |
Adobe Illustrator script to generate PNG icons for apps. | |
Current for Xcode 9 and iOS 11 as far as icon sizes go, but set icon sizes in the pixelSizes array to get what you neeed. | |
Will generate images for each storyboard in a document, in the format {docName}{artboardName}_{pixelSize}, e.g. | |
"myDocAB1_120.png" | |
Tested with Adobe Illustrator CC 22.0.0 and Xcode 9 | |
***/ | |
function saveFile(destFolder, fileName, pixelSize) { |
This file contains hidden or 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 courseAvgX: Double = 0 | |
var courseAvgY: Double = 0 | |
func getVectorAvg(latestReading: Double) -> Double { | |
let deg2Rad = 180 / Double.pi | |
// convert reading to radians | |
var theta = latestReading / deg2Rad | |
// running average |
This file contains hidden or 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
public static List<List<T>> SubdivideList<T>(List<T> inputList, int divisionSize = 2) | |
{ | |
var subdivisionsList = new List<List<T>>(); | |
for (var i = 0; i < inputList.Count; i += divisionSize) | |
{ | |
subdivisionsList.Add(inputList.GetRange(i, Math.Min(divisionSize, inputList.Count - i))); | |
} | |
return subdivisionsList; |
This file contains hidden or 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
import UIKit | |
import XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
// all angles need to be converted to radians | |
func Degrees2Radians(degrees: Double) -> CGFloat{ | |
return CGFloat( degrees * M_PI / 180) | |
} |
This file contains hidden or 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
import UIKit | |
// all angles need to be converted to radians | |
func Degrees2Radians(degrees: Double) -> CGFloat{ | |
return CGFloat( degrees * M_PI / 180) | |
} | |
// set width and height that will be used by the view and layers | |
let width = 600 |
This file contains hidden or 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
import Foundation | |
import XCPlayground | |
// Allows execution to be indefinite, giving delays or callbacks time to play | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
// Delay function | |
func delayer(duration: Double, closure:()->()){ | |
This file contains hidden or 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
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<div id="timerDiv" class="timerDiv">123</div> | |
<input id="triggerTimer" type="button" value="timer" /> |
NewerOlder