Skip to content

Instantly share code, notes, and snippets.

View bensheldon's full-sized avatar
🏊‍♂️
Swimming through code.

Ben Sheldon [he/him] bensheldon

🏊‍♂️
Swimming through code.
View GitHub Profile
class MyController < UIViewController
def viewDidLoad
@button = UIButton.alloc.init
@button.when_tapped do
weak_self = WeakRef.new(self) # <--- create a weak reference to self
@alert = UIAlertView.alertViewWithTitle "Alert",
message: "Message",
cancelButtonTitle: "Dismiss",
@bensheldon
bensheldon / app_delegate.rb
Last active May 16, 2020 18:09
Creating a flat navigation bar in a RubyMotion iOS iPhone app. (screenshot in the comments)
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
# ...
navigation_appearance
#...
end
def navigation_appearance
# Background Color
@bensheldon
bensheldon / rubymotion_crash.rb
Last active December 19, 2015 01:49
Press the back button for awfulness
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
@nav_controller = UINavigationController.alloc.initWithRootViewController(UIViewController.alloc.init)
@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@window.rootViewController = @nav_controller
@window.makeKeyAndVisible
@nav_controller.pushViewController(MyController.alloc.init, animated:true)
true
end
@bensheldon
bensheldon / distribution.rake
Created June 29, 2013 16:23
RubyMotion rake tasks for deployng adhoc and release builds while pushing dsyms to Crittercism and (for adhoc) pushing builds to TestFlight without using any SDKs.
def build_path
"build/iPhoneOS-6.0-Release/"
end
def ipa_name
'"Today\'s Shirts.ipa"'
end
def dsym_name
'"Today\'s Shirts.dSYM"'
@bensheldon
bensheldon / production.rb
Created July 3, 2013 21:48
Ensure models are loaded by Rails 3.2.13 during rake tasks when running in `threadsafe!` mode
RavelServer::Application.configure do
# Enable threaded mode
config.threadsafe!
# Ensure eager loading during rake tasks
config.dependency_loading = true if $rails_rake_task
# Ensure lib is eagerly loaded too
config.eager_load_paths += Dir["#{config.root}/lib", "#{config.root}/lib/**/"]
end
@bensheldon
bensheldon / affiliate.md
Last active January 15, 2017 00:31
List of Affiliate Networks

Affiliate Forums and Directory Websites

  • ABestWeb
  • PerformanceIN
  • A4U

Affiliate Networks

  • Affiliate Window or Buy.at
  • affiliate.com
@bensheldon
bensheldon / realworld-bootstrap3.md
Last active December 20, 2015 15:09
Bootstrap 3 examples and accessibility info
@bensheldon
bensheldon / organization.rb
Last active December 21, 2015 05:08
Using serializable hash
class Organization
include ActiveModel::Serialization
has_many :grants, as: :grants_made
has_many :grants, as: :grants_received
def grants_received_total
grants_received.map(&:amount).inject(0, :+) # or .sum if you're all into ActiveSupport
end
@bensheldon
bensheldon / Growth Tools
Created August 23, 2013 17:48
Promotion Tools
Tools
WebEngage
Qualaroo
Analytics
========
Net Promoter Score - http://www.netpromotersystem.com/about/measuring-your-net-promoter-score.aspx
Products.all.sort{|a,b| PriceNormalizer.on(a.price) <=> PriceNormalizer.on(b.price)}