Skip to content

Instantly share code, notes, and snippets.

View markrickert's full-sized avatar

Mark Rickert markrickert

View GitHub Profile
@markrickert
markrickert / server_setup.sh
Last active August 29, 2015 13:57
DigitalOcean Dokku Server Setup
# Create a DigitalOcean Ubuntu 12.04.3x64 droplet.
# DO NOT USE 13.10. There's a known issue with Dokku
# https://github.com/progrium/dokku#requirements
# On the server, install dependencies and Dokku
apt-get update && apt-get upgrade -y
apt-get install -y software-properties-common python-software-properties
wget -qO- https://raw.github.com/progrium/dokku/v0.2.2/bootstrap.sh | sudo DOKKU_TAG=v0.2.2 bash
# Put the app's hostname into the Dokku VHOST file
@markrickert
markrickert / bigdecimal.rb
Created May 23, 2014 21:12
RubyMotion BigDecimal conversion methods.
class BigDecimal
def to_s
self.stringValue
end
def to_f
self.floatValue
end
def to_i
@markrickert
markrickert / example_usage.rb
Last active August 29, 2015 14:03
RubyMotion In App Purchase example
def purchase_single_product(identifier)
NSLog "Starting purchase process for #{identifier}."
@iap_helper = IAPHelper.new(NSSet.setWithArray([identifier]))
@iap_helper.cancelled = cancelled_transaction
@iap_helper.success = transaction_successful
@iap_helper.request_product_info do |success, products|
if success && products.is_a?(Array) && products.count == 1
@iap_helper.buy_product(products.first)
else
@markrickert
markrickert / cartesian_power.rb
Last active August 29, 2015 14:03
Cartesian Power Example
# Usage
#
[:true, :false].cartesian_power(2) {|l| p l.inspect }
# "[:true, :true]"
# "[:true, :false]"
# "[:false, :true]"
# "[:false, :false]"
#
[:true, :false].cartesian_power(3) {|l| p l.inspect }
# "[:true, :true, :true]"
@markrickert
markrickert / mailman.h
Created August 8, 2014 14:22
MFMailComposeViewController extracted from UIViewController
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@interface MailMan : NSObject <MFMailComposeViewControllerDelegate> {
}
@property (nonatomic) UIViewController *vc;
- (id)initWithParentVC:(UIViewController *)vc;
@markrickert
markrickert / capture_image.rb
Created April 21, 2015 19:55
RubyMotion image capturing module
# Requires BubbleWrap gem with 'bubble-wrap/camera' required.
module ImageCapture
# Usage:
# capture_image({}) do
# # @captured_image should be an instance of UIImage
# end
#
# Options:
# {
# allows_editing: true,
@markrickert
markrickert / SSZipArchiveUsage.m
Created September 14, 2011 14:32
SSZipArchive Usage
[SSZipArchive unzipFileAtPath:(NSString *)
toDestination:(NSString *)destinationFolderPath];
@markrickert
markrickert / ImageViewMadness.m
Last active September 27, 2015 05:08
Setting an ImageView from the web
imageView.image = [UIImage imageWithData:
[UIData dataWithContentsOfURL:
[NSURL urlWithString:
[NSString stringWithFormat:@"http://my.imageurl.com/imagepath/%@", imageName]
]
]
];
@markrickert
markrickert / SDWebImageUsage.m
Created September 14, 2011 14:38
SDWebImage Usage
[imageView setImageWithURL:(NSURL *)url];
@markrickert
markrickert / SBJSONUsage.m
Created September 14, 2011 14:38
SBJSON Usage
NSDictionary *myJsonDict = [parser objectWithString:myJSONString];