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 / hapi-https.js
Last active August 29, 2015 14:19
hapi https
var options = {
tls: {
key: fs.readFileSync(path.join(__dirname, "private/key/key.pem"), 'utf-8'),
cert: fs.readFileSync(path.join(__dirname, "private/key/certificate.pem"), 'utf-8')
}
};
var https = new hapi.Server("localhost", configuration["api-port"], options);
@cbess
cbess / realm-helper.swift
Created February 14, 2015 07:23
Realm Helper
import Foundation
/**
Provides the default transaction block for perform a Realm transaction.
:param: block The block to perform the transaction. The realm is used to store the transaction.
*/
func realmTransaction(block: (realm: RLMRealm) -> Void) {
let realm = RLMRealm.defaultRealm()
@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;
@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 / 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 / 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 / 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 / dev-choices.txt
Created October 28, 2013 21:37
Basic Software Development Choices
Speed, Quality, Cost... Pick two.