Skip to content

Instantly share code, notes, and snippets.

View wndxlori's full-sized avatar

Lori M Olson wndxlori

View GitHub Profile
@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:
// 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
Starts with prototype in header:
void* _CalcImageBlobParam(
void *pBlob,
PERFECTLYCLEARCALLBACK callbackfn = NULL,
void *pUserData = NULL
);
Modified for use in Objective-C:
@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.