Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@brennanMKE
brennanMKE / backup.sh
Last active August 29, 2015 13:56
Backup to thumbdrive on a Mac which ignores folders which do not need a backup like Dropbox and GitHub
#!/bin/sh
# set the strict mode
set -e
if [ -d "/Volumes/Thumbdrive" ]; then
if [ ! -d "/Volumes/Thumbdrive/Backups" ]; then
mkdir "/Volumes/Thumbdrive/Backups"
fi
@brennanMKE
brennanMKE / Vagrantfile
Last active August 29, 2015 13:56
Vagrant Setup
# encoding: utf-8
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "precise64.box"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# config.vm.box = "opscode-ubuntu-12.04_chef-11.4.0"
@brennanMKE
brennanMKE / server.sh
Created February 24, 2014 07:28
Node Server Script
#!/bin/sh
# Based On: https://github.com/chovy/node-startup/blob/master/init.d/node-app
# strict
set -e
NODE_ENV="development"
NODE_APP='app.js'
APP_DIR='.';
@brennanMKE
brennanMKE / immediate.js
Last active August 29, 2015 13:56
JavaScript Promise with immediate response
var Promise = require('promise');
// Always return a promise for immediate or delayed responses
var doAsync = function(nbr) {
if (nbr === 1) {
// use static function to resolve with data immediately
return Promise.resolve('Success already!');
}
else if (nbr === 2) {
// use static function to reject with an error immediately
@brennanMKE
brennanMKE / chaining.js
Last active August 29, 2015 13:56
Chaining promises with just a single error handler
var Promise = require('promise');
var limit = 3;
var doAsync = function(nbr) {
var promise = new Promise(function (resolve, reject) {
setTimeout(function() {
if (nbr <= limit) {
// increment the given value by 1
resolve(nbr+1);
@brennanMKE
brennanMKE / package.json
Created March 2, 2014 19:04
Promise Package
{
"name": "promise-sample",
"description": "Promise Sample",
"version": "0.0.1",
"private": true,
"dependencies": {
"promise": "~4.0.0"
}
}
@brennanMKE
brennanMKE / CircleButton.podspec
Created March 14, 2014 16:50
CircleButton.podspec
Pod::Spec.new do |s|
s.name = "CircleButton"
s.version = "0.0.2"
s.summary = "Easy way to create buttons masked in a circle with colored border without the anti-aliasing distortion"
s.description = <<-DESC
When setting the corner radius, border color and border width there is often bleeding through to the
edges as is seen with the screenshot from the StackOverflow question below. This approach eliminates
the bleeding by embedding the masked view without a superview which can also be made circular.
DESC
s.homepage = "http://www.smallsharptools.com/"
@brennanMKE
brennanMKE / pi.sh
Created March 14, 2014 21:17
Run `pod install` and check if Ruby will require sudo
#!/bin/sh
RUBY=`which ruby`
if [[ $RUBY = '/usr/bin/ruby' ]] ; then
echo "error: You must run the following command from the command-line."
echo "sudu gem pod install"
else
if [[ -e 'Podfile' ]]; then
gem pod install
@brennanMKE
brennanMKE / wta.sh
Last active August 29, 2015 13:57
What The Archive
#!/bin/sh
// What The Archive!
// The argument passed in should be the Xcode project name so it can find and run lipo on each archive to
// look for each of the supported architectures to help the developer see what is there and what is missing.
// It looks in the DerivedData folder for the most recent matching folder using the given project name.
PROJECT_NAME=$1
BASE_DIR=~/Library/Developer/Xcode/DerivedData/
@brennanMKE
brennanMKE / indexPathForViewInTableView.m
Last active August 29, 2015 13:57
indexPathForView:inTableView:
- (NSIndexPath *)indexPathForView:(UIView *)view inTableView:(UITableView *)tableView {
UIView *superview = view;
while (superview && ![superview isKindOfClass:[UITableViewCell class]]) {
superview = superview.superview;
}
if ([superview isKindOfClass:[UITableViewCell class]]) {
NSIndexPath *indexPath = [tableView indexPathForCell:(UITableViewCell *)superview];
return indexPath;
}