This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename C, C first, C last> | |
class EnumIterator { | |
private: | |
typedef typename std::underlying_type<C>::type val_t; | |
public: | |
EnumIterator(C const &f) : val(f) {} | |
EnumIterator() : val(first) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# called with: rake db:migrate:touch['123456_migration_file.rb'] | |
namespace :db do | |
namespace :migrate do | |
desc "Touch migration - Renames file with new version and runs db:migrate:down with old version and db:migrate:up with new version" | |
task :touch, [:filename] => [:environment] do |t, args| | |
migrate_path = ActiveRecord::Migrator.migrations_path | |
filename = args[:filename] | |
next_version = ActiveRecord::Migrator.current_version.to_i + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// double wrapping performance test: http://jsperf.com/check-jquery-wrap | |
$.extend({ | |
ensure: function(el) { | |
return !(el instanceof jQuery) ? $(el) : el; | |
} | |
}); | |
// example use | |
function doSomethingWithEl(el) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
module Querying | |
delegate :or, :to => :all | |
end | |
end | |
module ActiveRecord | |
module QueryMethods | |
# OrChain objects act as placeholder for queries in which #or does not have any parameter. | |
# In this case, #or must be chained with any other relation method to return a new relation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
names = ['Mike Smith', 'McDonald, John', 'Jill Doe'] | |
names.map { |e| e.split(/,\s*/).reverse!.join(' ') } | |
# => ["Mike Smith", "John McDonald", "Jill Doe"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label>All starting with:</label> | |
<g:each in="${'a'..'z'}" var="ch"> | |
<g:link action="list" params="[searchLetter: ch]">${ch}</g:link> | | |
</g:each> |