Skip to content

Instantly share code, notes, and snippets.

View wndxlori's full-sized avatar

Lori M Olson wndxlori

View GitHub Profile
@wndxlori
wndxlori / options_for_select.rb
Created May 29, 2009 17:49
Monkey patch for "options_for_select", which forces a title attribute on the option
#
# Monkey patch for "options_for_select", which forces a title attribute on the option which is the same as the text
# value which will be displayed in the select box.
#
# For what purpose, you ask? Well, it's like this. Selects have fixed widths and cannot be made to expand to fill
# available space :-p so you must choose a width when creating it, and hope for the best. If the data to be
# displayed in the select is too wide, then you just can't see the whole thing. With this patch, you will at least
# have access to the entire string as as hover-text, using the title attribute.
#
# If you don't like this, then just delete this file from the plugin, and you will be back to normal.
Starts with prototype in header:
void* _CalcImageBlobParam(
void *pBlob,
PERFECTLYCLEARCALLBACK callbackfn = NULL,
void *pUserData = NULL
);
Modified for use in Objective-C:
// From:
// http://www.stone.com/The_Cocoa_Files/Thanks_A_Bundle_.html
// here's how we determine the size of the actual image in the ImageView:
// I reused this code from PhotoToWeb, since it worked already!
- (float)photoReduction {
NSSize size = [[self image] size];
NSRect iFrame = [self bounds];
if (NSWidth(iFrame) > size.width && NSHeight(iFrame) > size.height) return 1.0; // it fits
@wndxlori
wndxlori / gist:800525
Created January 28, 2011 16:44
Shared example group to stub out acl9 authorizations
ignore_access_control_helper.rb:
shared_examples_for "IgnoreAccessControl" do
before(:each) do
controller.stub!(:current_user).and_return(mock(:has_role? => true))
end
end
users_controller_spec.rb:
@wndxlori
wndxlori / settings_view_controller.rb
Created July 4, 2012 17:12
RubyMotion with UILocalNotification
def setup_alarm_notification(for_day, with_switch)
alarm_date = App::Persistence[for_day]
alarm_is_set = App::Persistence[with_switch];
if (alarm_is_set && alarm_date && (alarm_date > Time.now))
local_notification = UILocalNotification.alloc.init
local_notification.fireDate = NSDate.dateWithString( alarm_date.to_s )
local_notification.alertBody = "Time to get up! #{alarm_date.strftime('%H:%M')}"
local_notification.soundName = UILocalNotificationDefaultSoundName
local_notification.applicationIconBadgeNumber = 1
@wndxlori
wndxlori / beer_map_controller.rb
Created July 4, 2012 21:23
Custom image for MKAnnotationView in RubyMotion
ViewIdentifier = 'ViewIdentifier'
def mapView(mapView, viewForAnnotation:beer)
if view = mapView.dequeueReusableAnnotationViewWithIdentifier(ViewIdentifier)
view.annotation = beer
else
view = MKAnnotationView.alloc.initWithAnnotation(beer, reuseIdentifier:ViewIdentifier)
view.image = UIImage.imageNamed('signpost.png')
view.canShowCallout = true
# view.animatesDrop = true
button = UIButton.buttonWithType(UIButtonTypeDetailDisclosure)
@wndxlori
wndxlori / bootstrap.rb
Created August 29, 2012 21:31 — forked from jamiepenney/bootstrap.rb
Form builder for Twitter Bootstrap v2 form elements
# This file goes in config/initializers
require 'bootstrap_form_builder'
# Make this the default Form Builder. You can delete this if you don't want form_for to use
# the bootstrap form builder by default
ActionView::Base.default_form_builder = BootstrapFormBuilder::FormBuilder
# Add in our FormHelper methods, so you can use bootstrap_form_for.
ActionView::Base.send :include, BootstrapFormBuilder::FormHelper
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="../">Calgary FieldTrips</a>
<div class="nav-collapse" id="main-menu">
@wndxlori
wndxlori / Gemfile
Created December 20, 2012 20:09
Recommended Jasmine setup for Rails 3.2
group :development, :test do
gem 'jasmine'
gem 'jasmine-phantom'
# Works with the asset pipeline
gem 'jasmine-jquery-rails'
end
@wndxlori
wndxlori / deploy-failure
Created March 13, 2013 21:07
JRuby deploy failure
$ cap deploy:setup
LoadError: load error: openssl -- java.lang.NoClassDefFoundError: org/bouncycastle/asn1/DEREncodable
require at org/jruby/RubyKernel.java:1027
(root) at /Users/lori/.rvm/gems/jruby-1.7.2@rails3-bootstrap-devise-cancan/gems/net-ssh-2.6.6/lib/net/ssh/transport/openssl.rb:2
require at org/jruby/RubyKernel.java:1027
(root) at /Users/lori/.rvm/gems/jruby-1.7.2@rails3-bootstrap-devise-cancan/gems/net-ssh-2.6.6/lib/net/ssh/buffer.rb:1
require at org/jruby/RubyKernel.java:1027
(root) at /Users/lori/.rvm/gems/jruby-1.7.2@rails3-bootstrap-devise-cancan/gems/net-ssh-2.6.6/lib/net/ssh/buffer.rb:2
require at org/jruby/RubyKernel.java:1027
(root) at /Users/lori/.rvm/gems/jruby-1.7.2@rails3-bootstrap-devise-cancan/gems/net-ssh-2.6.6/lib/net/ssh/transport/algorithms.rb:1