Skip to content

Instantly share code, notes, and snippets.

View topgenorth's full-sized avatar

Tom Opgenorth topgenorth

  • Sherwood Park, AB, Canada
View GitHub Profile
@topgenorth
topgenorth / sorted_publishers_select_tag.rb
Created January 8, 2011 01:38
should get a list of publishers, sort them by display name, and create a select with a default value as the first option
def sorted_publishers_select_tag(default_option = nil)
publishers = Publisher.accessible_by(current_user.ability)
publishers.sort!{ |a,b| a.display_name.downcase <=> b.display_name.downcase }
options_tag = options_from_collection_for_select(publishers, 'id', 'display_name', params[:publisher_id])
if default_option.nil?
options = {}
else
# after sorting we need to stick in the default value so it's at the top
options = {:include_blank => default_option }
<%= sorted_publishers_select_tag('All') =%>
<!-- instead of -->
<dd><%= select_tag 'publisher_id', options_from_collection_for_select(@publishers, 'id', 'display_name', params[:publisher_id]), {:include_blank => 'All'} %></dd>
@topgenorth
topgenorth / gist:785395
Created January 18, 2011 23:41
Trying to use annotate on my user. Ruby 1.9.2/Rails 3.0.3.
[litdisco (annotate)]$ annotate User
/home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require': no such file to load -- annotate/annotate_models (LoadError)
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `block in require'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:591:in `new_constants_in'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.1/lib/active_support/dependencies.rb:239:in `require'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/tasks/annotate_models.rake:3:in `block in <top (required)>'
from /home/tom/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.8.7/lib/ra
@topgenorth
topgenorth / Resources.Designer.cs
Created January 5, 2012 02:39
M4A gist of resources in a sample file...
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
@topgenorth
topgenorth / Resources.Designer.cs
Created January 5, 2012 03:05
M4A gist of resources in a sample file (with a Resource.Layout.main) now
// ------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Mono Runtime Version: 4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
// ------------------------------------------------------------------------------
@topgenorth
topgenorth / gist:2285353
Created April 2, 2012 17:21
Weird M4A activation error
04-02 11:06:42.447: E/AndroidRuntime(1952): FATAL EXCEPTION: main
04-02 11:06:42.447: E/AndroidRuntime(1952): java.lang.UnsatisfiedLinkError: n_activate
04-02 11:06:42.447: E/AndroidRuntime(1952): at mono.android.TypeManager.n_activate(Native Method)
04-02 11:06:42.447: E/AndroidRuntime(1952): at mono.android.TypeManager.Activate(TypeManager.java:7)
04-02 11:06:42.447: E/AndroidRuntime(1952): at com.xamarin.sample.fragments.Activity1.<init>(Activity1.java:19)
04-02 11:06:42.447: E/AndroidRuntime(1952): at java.lang.Class.newInstanceImpl(Native Method)
04-02 11:06:42.447: E/AndroidRuntime(1952): at java.lang.Class.newInstance(Class.java:1409)
04-02 11:06:42.447: E/AndroidRuntime(1952): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-02 11:06:42.447: E/AndroidRuntime(1952): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1672)
04-02 11:06:42.447: E/AndroidRuntime(1952): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
@topgenorth
topgenorth / gist:2312573
Created April 5, 2012 17:11
Link exception in Mono For Android on VS2010
Packaging application..
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.261]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 4/5/2012 11:09:13 AM.
Project "U:\tom\Dropbox\XamarinDocs\Content\1.5 - Developmental Edits\Mono for Android\fragments\Fragments Walkthrough\code\FragmentSample.csproj" on node 1 (SignAndroidPackage target(s)).
_GenerateAndroidAssetsDir:
Skipping target "_GenerateAndroidAssetsDir" because it has no outputs.
_ResolveMonoAndroidSdks:
------ Rebuild All started: Project: FragmentSample, Configuration: Release Any CPU ------
C:\Program Files\MSBuild\Novell\Novell.MonoDroid.Common.targets(403,3): error MSB4064: The "AcwMapFile" parameter is not supported by the "ConvertResourcesCases" task. Verify the parameter exists on the task, and it is a settable public instance property.
C:\Program Files\MSBuild\Novell\Novell.MonoDroid.Common.targets(401,2): error MSB4063: The "ConvertResourcesCases" task could not be initialized with its input parameters.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Build Summary
-------------
00:00.862 - Failed - Release Any CPU - FragmentSample.csproj
Total build time: 00:00.915
// For Android 2.3, we have to do this:
ListView.ChoiceMode = (int) ChoiceMode.Single; // ListChoice mode is an Int32
ShowDetails(_currentPlayId);
// For Android 3.1, we have to do this:
ListView.ChoiceMode = ChoiceMode.Single; // ListChoice mode has changed to Android.Widget.ChoiceMode
ShowDetails(_currentPlayId);
@topgenorth
topgenorth / gist:2348162
Created April 10, 2012 03:32
Invalid Bridge callback?
04-09 21:30:59.580 I/ActivityThread( 8153): Pub net.opgenorth.yeg.buildings.__mono_init__: mono.MonoRuntimeProvider
04-09 21:30:59.580 D/dalvikvm( 8153): Trying to load lib /data/data/net.opgenorth.yeg.buildings/lib/libmonodroid.so 0x4080c970
04-09 21:30:59.580 D/dalvikvm( 8153): Added shared lib /data/data/net.opgenorth.yeg.buildings/lib/libmonodroid.so 0x4080c970
04-09 21:30:59.590 W/MonoDroid-Debugger( 8153): Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8897,server=y,embedding=1
04-09 21:30:59.620 W/MonoDroid-Debugger( 8153): Accepted stdout connection: 39
Invalid bridge callback version. Expected 1 but got 2
04-09 21:31:00.980 I/monodroid-gc( 8153): environment supports jni NewWeakGlobalRef
The program 'Mono' has exited with code 255 (0xff).