Skip to content

Instantly share code, notes, and snippets.

View aaronjensen's full-sized avatar

Aaron Jensen aaronjensen

View GitHub Profile
private static IEnumerable<Type> GetTypesInDirectoryWithExtension(string path, string extension)
{
foreach (FileInfo file in new DirectoryInfo(path).GetFiles(extension, SearchOption.AllDirectories))
{
Type[] types = null;
try
{
Assembly a = Assembly.LoadFrom(file.FullName);
types = a.GetTypes();
[Serializable]
public class Cache<TKey, TValue> : IIndexer<TKey, TValue> where TValue : class
{
readonly ReaderWriterLockSlim _lock = new ReaderWriterLockSlim();
readonly IDictionary<TKey, TValue> _values;
Func<TValue, TKey> _getKey = delegate { throw new NotImplementedException(); };
Action<TValue> _onAddition = x => { };
Func<TKey, TValue> _onMissing = delegate(TKey key)
routes.MapRouteTo<DiagnosticsController>(Urls.root.debug, x => x.Index());
routes.MapRouteTo<DiagnosticsController>(Urls.root.diagnostics.ok, x => x.Ok());
routes.MapRouteTo<DiagnosticsController>(Urls.root.diagnostics.raise, x => x.Raise());
routes.MapRouteTo<LoginController>(Urls.root.login, x => x.Login(null));
routes.MapRouteTo<LoginController>(Urls.root.logout, x => x.Logout());
routes.MapRouteTo<StyleguideController>(Urls.root.styleguide, x => x.Styleguide());
@aaronjensen
aaronjensen / zen_to_hipchat.rb
Created January 14, 2011 06:05
Connects Zen's XMPP to your HipChat. Run with ruby zen_to_hipchat.rb start
# Needs Ruby 1.8.7
# gem install hipchat
# gem install xmpp4r-simple
# gem install daemons
# run with ruby zen_to_hipchat.rb start
require 'rubygems'
require 'hipchat'
require 'xmpp4r-simple'
<%= semantic_form_for @decision do |form| %>
<%= form.inputs(:name => "Questions", :for => :answer_to_questions) do |field| %>
<%= field.input :decision_question_id, :as => :hidden %>
<%= field.input :decision_answer, :as => :radio, :collection => field.object.decision_question.decision_answers, :label => field.object.decision_question.text %>
<% end %>
<%= form.inputs do %>
<%= form.input :category_id, :as => :hidden %>
<% end %>
<%= form.buttons do %>
# Needs Ruby 1.8.7
# gem install hipchat
# gem install xmpp4r-simple
# gem install daemons
# run with ruby zentc_to_hipchat.rb start
require 'rubygems'
require 'hipchat'
require 'xmpp4r-simple'
require 'spec_helper'
#Note that while this spec is quite sexy, it shouldn't be taken too far
#this syntax hides deeper meaning that may very well be important.
#I'm using this for a quick spike and I think it's acceptable in certain
#scenarios, but use with caution! Don't get distracted by the shiny...
describe User do
its(:user_profile) { should be }
end
group :development, :test do
# gem 'webrat'
gem 'autotest-rails'
gem 'autotest-growl'
gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git"
gem "rspec-rails", '~> 2.4.1'
gem 'rr'
gem "spork", :git => "git://github.com/timcharper/spork.git"
gem "guard-spork"
gem "rb-fsevent"
# A sample Guardfile
# More info at http://github.com/guard/guard#readme
guard 'spork' do
watch('^config/application.rb$')
watch('^config/environment.rb$')
watch('^config/environments/.*\.rb$')
watch('^config/initializers/.*\.rb$')
watch('^spec/spec_helper\.rb$')
watch('^spec/factories\.rb$')
Autotest.add_hook(:initialize) {|at|
%w{.git .svn .hg .swp .DS_Store ._* tmp}.each do |exception|
at.add_exception(exception)
end
at.clear_mappings # take out the default (test/test*rb)
at.add_mapping(%r%^(spec|third_party)/.*_spec.rb$%) { |filename, _|
filename
}