Skip to content

Instantly share code, notes, and snippets.

@lanephillips
lanephillips / table47a.csv
Last active July 15, 2023 13:52
Astronomical Algorithms, Second Edition, Jean Meeus, Tables 47.A and 47.B, pp. 339-341
0 0 1 0 6288774 -20905355
2 0 -1 0 1274027 -3699111
2 0 0 0 658314 -2955968
0 0 2 0 213618 -569925
0 1 0 0 -185116 48888
0 0 0 2 -114332 -3149
2 0 -2 0 58793 246158
2 -1 -1 0 57066 -152138
2 0 1 0 53322 -170733
2 -1 0 0 45758 -204586
@lanephillips
lanephillips / gist:bca41e8f812f69875362a5e633f99b3a
Created January 12, 2020 14:53
Create a list of Friendly Fire podcast episode titles
curl http://feeds.feedburner.com/FriendlyFirePod | sed -n -e 's/<itunes:title>//p' | sed -n -e 's/<.*$//p' | tail -r > ~/Downloads/ff.txt
@lanephillips
lanephillips / UpdateRevisionNumbers.sh
Last active August 29, 2015 13:57
Xcode Run Script build phase to copy Subversion revision info into a string constant.
VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/MyProject/MyProject-Info.plist"`
BUILD=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/MyProject/MyProject-Info.plist"`
REV=`svnversion -n`
DATE=`date "+%Y-%m-%d %H:%M:%S %Z"`
VS="Version: $VERSION Build: $BUILD\nRevision: $REV\nDate: $DATE"
echo "// This file is generated at build time." > ${PROJECT_DIR}/Revision.h
echo "// Do not edit it or add it to version control." >> ${PROJECT_DIR}/Revision.h
echo "#define kSOSRevision @\"$VS\"" >> ${PROJECT_DIR}/Revision.h
@lanephillips
lanephillips / CGRectAspectFit.m
Created October 7, 2013 21:05
Objective-C code to fit a CGRect inside or outside another CGRect while maintaining aspect ratio. The fitted rectangle is centered on the target rectangle.
CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget)
{
// first try to match width
CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit);
// if we scale the height to make the widths equal, does it still fit?
if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) {
return s;
}
// no, match height instead
return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit);