This file contains hidden or 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
x = lambda do |*args| | |
row, col = *({ :row => nil, :col => nil}.merge(args.first).values rescue args) | |
end | |
x.call(4,2) => [4,2] | |
x.call(row:4, col:2) => [4,2] | |
x.call(row:4) => [4,nil] | |
x.call(4) => [4,nil] | |
x.call(col:2) => [nil,2] |
This file contains hidden or 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
class DebugMachineCache | |
remove_const :COMMANDS rescue nil#TODO remove this | |
# assemble format strings for movement commands | |
movmts = Hash[[:hpa,:vpa,:cup,:home,:setaf].zip( | |
[`tput hpa`, `tput vpa`, `tput cup`,`tput home`,`tput setaf`].collect do |fmt| | |
fmt.split(/(%[pPg][\d\w])|(%.)/).each_with_object '' do |i,m| | |
if i == '%d' | |
m << '%d' |
This file contains hidden or 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 BlackMagick | |
def keys &block | |
define_method :keys, &block | |
end | |
end | |
class LeThing | |
extend BlackMagick | |
end |
This file contains hidden or 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
has_many :user_favorite_markets | |
:class_name => "UserFavoriteMarket", | |
:foreign_key => :user_id | |
has_many :favorite_markets, | |
:class_name => "FarmersMarket", | |
:through => :user_favorite_markets | |
:source => :market | |
# I think this is the general idea. You have to have an association for the join table as well. |
This file contains hidden or 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
class Factory | |
class << self | |
def new_thing name | |
klass = Class.new(self) do | |
attr_accessor :name | |
define_method :initialize do | |
@name = name | |
end | |
end | |
const_name = name.camelize.intern |
This file contains hidden or 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 Thing | |
module Constants | |
BOO = 2 | |
end | |
module Methods | |
extend ActiveSupport::Concern | |
include Constants | |
module InstanceMethods |
This file contains hidden or 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
$('#particles > .particle').draggable({ | |
containment: '#mainpage', | |
helper: 'clone', | |
appendTo : '#mainpage', | |
zIndex: 1000, | |
start: function(){ $(this).toggle(); }, | |
stop: function(){ $(this).toggle(); } | |
}); |
This file contains hidden or 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
function! s:Logger.put(string) dict | |
if g:ruby_debugger_debug_mode | |
let string = 'Vim plugin, ' . strftime("%H:%M:%S") . ': ' . a:string | |
execute('set verbosefile=' . g:RubyDebugger.logger.file) | |
silent verbose echo substitute(string,'/^\s*/','',"") | |
execute('set verbosefile=""') | |
endif | |
endfunction | |
This file contains hidden or 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
<div id="main_image" class="<%= content_for :image_width -%>"> | |
<a href="<%= @product.image_file.downcase %>" rel="popup"> | |
<%= render :layout => false do %> | |
<% options, itag = medium_image :id => "primary" -%> | |
<% content_for :image_width do | |
options[:width] > 362 ? "wide_image" : "narrow_image" | |
end %> | |
<%= itag %> | |
<% end -%> | |
</a> |
OlderNewer