Skip to content

Instantly share code, notes, and snippets.

View markrickert's full-sized avatar

Mark Rickert markrickert

View GitHub Profile
@markrickert
markrickert / ScrollToBottom.js
Last active July 15, 2016 18:16
Scrolling to the bottom of a React Native ScrollView or ListView
import React, { PropTypes } from 'react'
import {View, ListView, Text } from 'react-native'
export default class ScrollToBottomExample extends React.Component {
constructor (props) {
super(props)
// Set up our two placeholder values.
this.listHeight = 0
@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 / 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 / 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 / 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 / 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 / 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 / aliases.bash
Created January 22, 2014 21:36
wo - "Work On", a bash alias for quickly cd-ing into directories
# wo = work on
wo() {
code_dir=~/Dropbox # replace it with your development directory
cd $(find $code_dir -type d -maxdepth 3 | grep -i $* | grep -Ev Pods --max-count=1)
}
@markrickert
markrickert / fix-xcode.rb
Last active February 2, 2020 01:31
Quick fix to all your Xcode SDK issues. When you update Xcode, just run this script and all is well.
#!/usr/bin/env ruby
# fix-xcode
# Mark Rickert <mjar81@gmail.com>
# Symlinks all your old SDKs to Xcode.app every time it is updated.
# Create a directory called /SDKs and run this script.
#
# Each time you upgrade Xcode, run fix-xcode.
@markrickert
markrickert / statesscreen.rb
Created September 2, 2013 13:38
Example on how to set the background color/view of a ProMotion GroupedTableScreen
class StatesScreen < PM::TableScreen
title "States"
def will_appear
view.backgroundView = nil
view.backgroundColor = UIColor.redColor
end
def table_style