Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Rickert markrickert

View GitHub Profile
@markrickert
markrickert / ScrollToBottom.js
Last active Jul 15, 2016
Scrolling to the bottom of a React Native ScrollView or ListView
View ScrollToBottom.js
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 Apr 21, 2015
RubyMotion image capturing module
View capture_image.rb
# 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 Aug 8, 2014
MFMailComposeViewController extracted from UIViewController
View mailman.h
#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 Aug 29, 2015
Cartesian Power Example
View cartesian_power.rb
# 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 Aug 29, 2015
RubyMotion In App Purchase example
View example_usage.rb
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
RubyMotion BigDecimal conversion methods.
View bigdecimal.rb
class BigDecimal
def to_s
self.stringValue
end
def to_f
self.floatValue
end
def to_i
@markrickert
markrickert / server_setup.sh
Last active Aug 29, 2015
DigitalOcean Dokku Server Setup
View server_setup.sh
# 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 Jan 22, 2014
wo - "Work On", a bash alias for quickly cd-ing into directories
View aliases.bash
# 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 Feb 2, 2020
Quick fix to all your Xcode SDK issues. When you update Xcode, just run this script and all is well.
View fix-xcode.rb
#!/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 Sep 2, 2013
Example on how to set the background color/view of a ProMotion GroupedTableScreen
View statesscreen.rb
class StatesScreen < PM::TableScreen
title "States"
def will_appear
view.backgroundView = nil
view.backgroundColor = UIColor.redColor
end
def table_style