Skip to content

Instantly share code, notes, and snippets.

View cbess's full-sized avatar
💭
Coding for Jesus' glory. Soli Deo gloria

C. Bess cbess

💭
Coding for Jesus' glory. Soli Deo gloria
View GitHub Profile
@cbess
cbess / convert-to-cggeometry.py
Last active December 24, 2015 22:39
TextMate command to convert `frame` dot notation to equivalent CGGeometry function calls
#!/usr/bin/python
# Created by C. Bess (2013)
# Converts the frame dot notation to CGGeometry function calls
#
# ref: http://manual.macromates.com/en/environment_variables.html
#
# Usage:
# After selecting the text that contains the target text, use
# 'Select Bundle Item' menu item, then find this command and press enter
@cbess
cbess / xcode5-ios6-sdk.sh
Last active December 25, 2015 00:19
Links iOS 6 SDK into Xcode SDKs. Allowing you to build/link against iOS 6.x within Xcode 5.
# links the Xcode4.6.x 6.1 SDK to Xcode5 sdks
# by C. Bess (2013)
# For simulators run (ex: iOS 6 sdk/app in iOS 7 simulator):
# - Works if you haven't installed iOS 6 sdk yet
# ln -s Xcode-4.6.3.app/.../iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk Xcode.app/.../iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk
echo Linking iOS 6 SDK to Xcode 5
# name of the Xcode bundles (in Applications)
@cbess
cbess / time-nsstring.m
Last active December 25, 2015 14:39
Time formatted string from seconds.
/**
* Returns the human-readable string that represents the specified seconds.
* @discussion Ex: seconds = 4017 -> "01:06:57"
*/
- (NSString *)timeStringFromSeconds:(NSInteger)seconds
{
int hours = seconds / 3600;
int rem = seconds % 3600;
int minutes = rem / 60;
int remSecs = rem % 60;
@cbess
cbess / url-mutating.md
Created October 17, 2013 15:59
URL manipulation
@cbess
cbess / dev-choices.txt
Created October 28, 2013 21:37
Basic Software Development Choices
Speed, Quality, Cost... Pick two.
@cbess
cbess / setup-dev-box.sh
Last active July 19, 2018 12:27
Smarter Homebrew dev box installer script (mini-boxen). OS X 10.8+
#!/bin/bash
# installs tools and apps for basic dev operations
# Created by Christopher Bess (2014)
# License: MIT
# updated: 2014-02-11
function msg() {
echo "> $1"
}
@cbess
cbess / position-cell.m
Last active August 29, 2015 13:56
Adjust the position of a UICollectionViewCell.
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout*) self.collectionView.collectionViewLayout;
// CGFloat maxOffset = (kItemWidth + flowLayout.minimumInteritemSpacing) * kMaxCount;
NSInteger item = (targetContentOffset->x / (kItemWidth + flowLayout.minimumInteritemSpacing));
NSIndexPath *targetPath = [NSIndexPath indexPathForItem:item inSection:0];
UICollectionViewLayoutAttributes *attrs = [self.collectionView layoutAttributesForItemAtIndexPath:targetPath];
DebugLog(@"target cell attrs: %@", attrs);
@cbess
cbess / split-cell-animation.m
Last active August 29, 2015 13:56
Split UICollectionViewCell (or any view) into two pieces, then send (animation off screen) in opposite directions.
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView cellForItemAtIndexPath:indexPath];
// we are placing it above the collection view, in the VC.view,
// so convert the rect to that coord. region
CGRect cellRect = [collectionView convertRect:cell.frame toView:self.view];
CGRect cellBounds = cell.bounds;
// get an image of the cell
@cbess
cbess / cmd-app-script.scpt
Created February 14, 2014 06:04
Command line access with AppleScript
-- open Terminal and do stuff
tell application "Terminal"
set currentTab to do script ("python")
delay 1
do script ("import sys") in currentTab
do script ("sys.path") in currentTab
delay 1
--close front window
@cbess
cbess / flip.m
Created May 8, 2014 17:38
iOS UIView flip examples
@interface FNViewController () {
BOOL isFlipped;
BOOL isTransitioning;
CALayer *topLayer;
CALayer *bottomLayer;
}
@property (weak, nonatomic) IBOutlet UIImageView *oneImageView;
@property (weak, nonatomic) IBOutlet UIImageView *twoImageView;
@property (nonatomic, assign) BOOL displayingFront;