Skip to content

Instantly share code, notes, and snippets.

@mattsgarrison
mattsgarrison / cloudSettings
Last active August 16, 2020 03:11
VSCode settings
{"lastUpload":"2020-08-16T03:11:05.521Z","extensionVersion":"v3.4.3"}
module RubyMotionQuery
module Stylers
class UIPageControlStyler < UIControlStyler
# Your custom styler methods here
def current_page
view.currentPage
end
def current_page=(value)
@mattsgarrison
mattsgarrison / pg_backup.rake
Created December 17, 2013 15:32
A couple rake tasks to back up and restore Postgres databases in Rails using your Rails Environment variable.
namespace :db do
desc "Runs pg_dump against the environment's database."
task pg_dump: :environment do
db_config = Rails.application.config.database_configuration[Rails.env]
system "pg_dump -U #{db_config['username']} #{db_config['database']} -f dump_#{Rails.env}.sql"
end
desc "Loads a pg_dump file into the environment's database."
task pg_restore: :environment do
db_config = Rails.application.config.database_configuration[Rails.env]
Teacup::Stylesheet.new :root_style do
style :label,
text: "Label",
backgroundColor: :gray,
font: :bold.uifont(15),
textColor: :white,
shadowColor: :black,
textAlignment: :right,
layer: {
@mattsgarrison
mattsgarrison / welcome_helper.rb
Created May 21, 2013 02:42
Rails image_tag helper for when an image may or may not exist.
def image_tag_or_default(image_name, options = {})
if RailsApplicationName::Application.assets.find_asset("#{image_name}").nil?
image_tag("default_category.png",options)
else
image_tag("#{image_name}",options)
end
end
@mattsgarrison
mattsgarrison / crystal_report.rb
Created January 5, 2013 01:47
This is a rough proof of concept just to see if it was feasible to run one of my workplace's legacy Crystal Reports through JRuby and eventually scheduled and queued through a Torquebox app. The particular .rpt I was playing with had DB connection info required, but no parameters passed into it. This was just a class file I tossed in the /lib fo…
class CrystalReport
require 'java'
# Some cargo cult programming inclusions.
# This is just every jar file provided as part of the runtime package here:
# http://www.sdn.sap.com/irj/boc/index?rid=/webcontent/uuid/b0f67412-9ac0-2b10-5982-dfdf6376cd99
require 'vendor/jars/crystal/com.azalea.ufl.barcode.1.0.jar'
require 'vendor/jars/crystal/commons-lang-2.1.jar'

With Heroku's new JRuby support you may have already seen that you can run TorqueBox Lite on Heroku. But, that only gives you the web features of TorqueBox. What about scheduled jobs, backgroundable, messaging, services, and caching?

With a small amount of extra work, you can now run the full TorqueBox (minus STOMP support and clustering) on Heroku as well! I've successfully deployed several test applications, including the example Rails application from our Getting Started Guide which has a scheduled job, a service, and uses backgroundable and messaging.

The version of TorqueBox you'll be running on Heroku is almost identical (two commits newer) than TorqueBox 2.2.0. We had to expose a small extra flag to control when TorqueBox actually binds to the HTTP port since Heroku uses that as the trigger that your application is up and ready to serve reque

@mattsgarrison
mattsgarrison / payment_form.coffee
Created August 16, 2012 13:34
Stripe Credit Card Processing
jQuery ->
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
subscription.setupForm()
subscription =
setupForm: ->
$('#new_subscription input[type=submit]').click ->
$(this).attr('disabled', true) #disable to prevent doubleclicks·
subscription.processCard()
@mattsgarrison
mattsgarrison / dump.m
Created June 12, 2012 03:12 — forked from gavingmiller/dump.m
Objective-C Dump Views
static void dumpViews(UIView* view, NSString *text, NSString *indent)
{
Class cl = [view class];
NSString *classDescription = [cl description];
while ([cl superclass])
{
cl = [cl superclass];
classDescription = [classDescription stringByAppendingFormat:@":%@", [cl description]];
}
@mattsgarrison
mattsgarrison / Rakefile
Created June 2, 2012 18:29
RubyMotion Rakefile configured for submitting to the App Store.
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require 'bubble-wrap'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'Chatoms'
app.version = "2.0"
app.deployment_target = '5.1'
app.identifier = "com.iconoclastlabs.chatoms"