query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Format the capabilities hash for the response. Mutates opts. | def add_capabilities!(opts, klass, item = nil)
raise ArgumentError, 'klass must be a class' unless klass.is_a?(Class)
raise ArgumentError, 'opts must be a hash' unless opts.is_a?(Hash)
filter_settings = klass&.try(:filter_settings)
# check we can get filter settings and that capabilities are defined for this class
unless filter_settings in {capabilities: Hash}
opts[:capabilities] = nil
return
end
capabilities = filter_settings[:capabilities]
opts[:capabilities] = capabilities.transform_values { |capability|
evaluate_capability(item, klass, capability)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capability\n one_data_response(\"CAPABILITY\").transform{ |response| response.data }\n end",
"def capabilities\n data[:capabilities]\n end",
"def capabilities\n attributes.fetch(:capabilities)\n end",
"def capabilities\n attributes.fetch(:capabilities)\n ... | [
"0.61760354",
"0.60260826",
"0.5902325",
"0.5902325",
"0.57180935",
"0.5643129",
"0.5603182",
"0.55876094",
"0.55612147",
"0.5493477",
"0.5493069",
"0.5477153",
"0.54564697",
"0.5446709",
"0.54348576",
"0.53967774",
"0.5391662",
"0.5382048",
"0.5368699",
"0.53175426",
"0.5303... | 0.49125934 | 66 |
Create and execute a query based on a filter request. | def response(params, query, model, filter_settings)
# extract safe params and ensure we're dealing with a HWIA
params = params.to_h if params.is_a? ActionController::Parameters
unless params.is_a? HashWithIndifferentAccess
raise ArgumentError, 'params needs to be HashWithIndifferentAccess or an ActionController::Parameters'
end
filter_query = Filter::Query.new(params, query, model, filter_settings)
# query without paging to get total
new_query = filter_query.query_without_paging_sorting
paged_sorted_query, opts = add_paging_and_sorting(new_query, filter_settings, filter_query)
# build complete api response
opts[:filter] = filter_query.filter unless filter_query.filter.blank?
opts[:projection] = filter_query.projection unless filter_query.projection.blank?
opts[:capabilities] = filter_query.capabilities unless filter_query.capabilities.blank?
opts[:additional_params] = filter_query.parameters.except(
model.to_s.underscore.to_sym,
:filter, :projection,
:action, :controller,
:format, :paging, :sorting,
:page, :items
)
[paged_sorted_query, opts]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute()\n filters = prepare_filters\n return_filtered_model(filters)\n end",
"def retrieve_query\n if params[:set_filter] or !session[:query] or session[:query].project_id\n # Give it a name, required to be valid\n @query = Query.new(:name => \"_\", :executed_by => logged_in_user)\n ... | [
"0.7040638",
"0.6903925",
"0.67462677",
"0.67462677",
"0.6683041",
"0.65770584",
"0.65406793",
"0.6527802",
"0.63660246",
"0.63273615",
"0.6300142",
"0.628879",
"0.62843037",
"0.6220728",
"0.619216",
"0.6190783",
"0.6187244",
"0.615467",
"0.6126082",
"0.6086615",
"0.60362107"... | 0.0 | -1 |
if lower is higher than upper, lower will have priority | def restrict_to_bounds(value, lower = 1, upper = nil)
value_i = value.to_i
value_i = upper if !upper.blank? && value_i > upper
value_i = lower if !lower.blank? && value_i < lower
value_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def priority(*) end",
"def priority=(*) end",
"def by_priority; end",
"def priority\r\n 25\r\n end",
"def <=>(other)\n priority <=> other.priority\n end",
"def <=>(b)\n return 1 if @priority.nil?\n return -1 if b.priority.nil?\n @priority <=> b.priority\n end",
"def base_priority\n ... | [
"0.674945",
"0.66187286",
"0.6558326",
"0.6518456",
"0.6429413",
"0.6389426",
"0.6361317",
"0.63303035",
"0.6284671",
"0.6258306",
"0.6246963",
"0.6229435",
"0.6190598",
"0.61641496",
"0.61347735",
"0.61345685",
"0.61301297",
"0.61301297",
"0.6104764",
"0.6102104",
"0.6080214... | 0.5602426 | 63 |
Determines the capability either for a list of items or for specific item. When determining for a list of items, the item parameter should be nil. | def evaluate_capability(item, klass, capability)
if item.nil?
capability[:can_list]&.call(item)
else
capability[:can_item]&.call(item)
end => can
details = capability[:details]&.call(can, item, klass)
{ can:, details: }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capability imap, res = nil\n return imap.capability unless res\n\n data = res.data\n\n if data.code and data.code.name == 'CAPABILITY' then\n data.code.data.split ' '\n else\n imap.capability\n end\n end",
"def capability\n one_data_response(\"CAPABILITY\").transform{ |respon... | [
"0.6203026",
"0.59185624",
"0.5847494",
"0.57367843",
"0.5657364",
"0.5562245",
"0.5494813",
"0.5458076",
"0.54070127",
"0.5352993",
"0.5350936",
"0.53284585",
"0.531759",
"0.53129876",
"0.53129876",
"0.52844596",
"0.52818584",
"0.5270602",
"0.5264837",
"0.5259203",
"0.525560... | 0.73360115 | 0 |
just for the sake of RSpec testing | def initialize(contenders)
@contenders = contenders
@referee = Referee.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spec; end",
"def spec; end",
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; ... | [
"0.7479604",
"0.7479604",
"0.69118875",
"0.65606153",
"0.65606153",
"0.65606153",
"0.65606153",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029",
"0.639029"... | 0.0 | -1 |
OpenID assist bar (mode is one of :signup or :login) | def open_id_link_bar(mode)
content_tag(:div, :id => "open_id_assist_bar") do
link_to_known_open_id(:google, mode) + " | " +
link_to_known_open_id(:google_profile, mode) + " | " +
link_to_known_open_id(:yahoo, mode) + " | " +
link_to_known_open_id(:aol, mode) + " | " +
link_to_known_open_id(:myopenid, mode) + " | " +
link_to_known_open_id(:verisign, mode) + " | " +
link_to_known_open_id(:wordpress, mode) + " | " +
link_to_known_open_id(:blogger, mode)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authorization_mode=(mode); end",
"def authorization_mode; end",
"def show\n authorize HighschoolCompletion\n end",
"def type_authentication!()\n @type = TAC_PLUS_AUTHEN\n end",
"def nav_login_button\r\n \r\n end",
"def authen_type_chap!()\n @authen_type = TAC_PLUS_AUTHEN_TYPE... | [
"0.566561",
"0.5650944",
"0.56048375",
"0.55008346",
"0.53615344",
"0.53613234",
"0.5355409",
"0.533947",
"0.53386253",
"0.53172475",
"0.5312398",
"0.528623",
"0.52801",
"0.5254539",
"0.5235122",
"0.52313054",
"0.5229778",
"0.5170306",
"0.5159982",
"0.5142842",
"0.51216173",
... | 0.6405569 | 0 |
this method accepts moves and if any of the moves can force the computer's opponent into checkmate, this move will be immediately chosen. if any moves can force the computer's opponent into check, it will be included as one of the moves that must eventually be chosen in highest_value_capture_filter. | def force_check_filter(board, moves)
force_check_moves = Hash.new { |hash, key| hash[key] = [] }
moves.each do |start_pos, end_positions|
end_positions.each do |end_pos|
new_board = DeepClone.clone(board)
new_board.move_piece(start_pos, end_pos)
if new_board.in_checkmate?(opponent_color)
@end_pos = end_pos
return start_pos
elsif new_board.in_check?(opponent_color)
force_check_moves[start_pos] << end_pos
end
end
end
new_moves = force_check_moves.empty? ? moves : force_check_moves
highest_value_capture_filter(board, new_moves)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_value_capture_filter(board, moves)\n capture_data = Hash.new { |hash, key| hash[key] = {} }\n\n moves.each do |start_pos, end_positions|\n end_positions.each do |end_pos|\n piece = board[end_pos]\n capture_data[start_pos][end_pos] = piece.type\n end\n end\n\n highest... | [
"0.6507889",
"0.6326228",
"0.6223593",
"0.60323936",
"0.60248494",
"0.60067946",
"0.6004688",
"0.5996007",
"0.5984671",
"0.587494",
"0.5863592",
"0.58465326",
"0.58393705",
"0.5807058",
"0.56798184",
"0.5665363",
"0.563762",
"0.56346655",
"0.5609707",
"0.560369",
"0.5599093",... | 0.71566397 | 0 |
this method will evaluate if the computer has more than one capture opportunity available. If so, it will capture the piece with the 'highest value', i.e. computer will take a Queen over a Pawn. | def highest_value_capture_filter(board, moves)
capture_data = Hash.new { |hash, key| hash[key] = {} }
moves.each do |start_pos, end_positions|
end_positions.each do |end_pos|
piece = board[end_pos]
capture_data[start_pos][end_pos] = piece.type
end
end
highest_value_capture = 0
start_position = nil
end_position = nil
capture_data.each do |start_pos, end_pos_data|
end_pos_data.each do |end_pos, piece_type|
if PIECE_VALUES[piece_type] > highest_value_capture
highest_value_capture = PIECE_VALUES[piece_type]
start_position = start_pos
end_position = end_pos
end
end
end
start_position ||= random_start_pos(moves.keys)
end_position ||= random_end_pos(moves[start_position])
@end_pos = end_position
start_position
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_piece(capture_list)\r\n piece = nil\r\n until piece and piece.is_a?(Piece) and piece.is_friendly?(self) and piece.valid_moves\r\n print \"\\nSelect a piece to move: \"\r\n location = gets.chomp\r\n if (location =~ /^[1-9][1-9]$/) == 0\r\n piece = find_piece(location)\r\n ... | [
"0.6111901",
"0.59939873",
"0.59520924",
"0.5866265",
"0.57460284",
"0.57449216",
"0.57421947",
"0.57210314",
"0.5703163",
"0.5622947",
"0.56093305",
"0.559193",
"0.5581691",
"0.55407846",
"0.553705",
"0.5534378",
"0.54697734",
"0.5457465",
"0.54284996",
"0.5388651",
"0.53566... | 0.64329845 | 0 |
Overwriting the Devise sign_out redirect path method | def after_sign_out_path_for(resource_or_scope)
new_user_session_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end",
"def after_sign_out_path_for(resource_or_scope)\n \"/app/users/sign_in\"\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_path\n end",
"def after_sign_out_path_for(_resource_or_scope)\n user_session_p... | [
"0.8172538",
"0.81657386",
"0.8147026",
"0.8147026",
"0.8147026",
"0.8147026",
"0.8135589",
"0.81185824",
"0.8088362",
"0.8056733",
"0.80546564",
"0.80298716",
"0.8025647",
"0.8025647",
"0.8025647",
"0.8025647",
"0.8025647",
"0.8003675",
"0.797711",
"0.79712164",
"0.79652894"... | 0.7778225 | 81 |
Logical AND. Usage: myParser >> otherParser | def >>(other)
Parser.new do |input|
first = run(input)
matched = ""
output = []
if first.ok?
matched = matched + first.matched
output += first.output
second = other.run(first.remaining)
if second.ok?
matched = matched + second.matched
output = [*output, second.output]
ParserResult.ok(output, matched: matched, remaining: second.remaining)
else
ParserResult.fail(input)
end
else
first
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AndExpr(path, parsed); end",
"def and!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n\n type = AND\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 125:7: '&&'\n match( \"&&\" )\n\n... | [
"0.66416913",
"0.65574884",
"0.6520519",
"0.638346",
"0.63425344",
"0.62938863",
"0.62650687",
"0.6257682",
"0.6179618",
"0.61734146",
"0.61210746",
"0.60890573",
"0.6051636",
"0.60374945",
"0.60291255",
"0.6027748",
"0.60252637",
"0.6021294",
"0.5974504",
"0.5964725",
"0.591... | 0.59283435 | 20 |
Match this, other is optional | def >(other)
Parser.new do |input|
first = run(input)
matched = ""
output = []
if first.ok?
matched = first.matched
output += first.output
second = other.run(first.remaining)
if second.ok?
matched = matched + second.matched
output = [*output, second.output]
ParserResult.ok(output, matched: matched, remaining: second.remaining)
else
first
end
else
ParserResult.fail(input)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match!( other )\n return false unless prefers?( other ) && !matched?( other )\n matches << other\n other.matches << self\n end",
"def match(other)\n return @type.match(other)\n end",
"def matched?( other = nil )\n return full? if other.nil?\n matches.include? other... | [
"0.73914886",
"0.67607355",
"0.672376",
"0.6506262",
"0.64309764",
"0.6264516",
"0.6262949",
"0.6229173",
"0.6191244",
"0.6161579",
"0.61143374",
"0.6056707",
"0.60497063",
"0.60467637",
"0.5987131",
"0.5944738",
"0.5944738",
"0.5927736",
"0.59038955",
"0.59027624",
"0.587248... | 0.5260667 | 66 |
Match other, this is optional | def <(other)
Parser.new do |input|
first = run(input)
matched = ""
output = []
remaining = input
if first.ok?
matched = first.matched
output += first.output
remaining = first.remaining
end
second = other.run(remaining)
if second.ok?
matched = matched + second.matched
output = [*output, second.output]
ParserResult.ok(output, matched: matched, remaining: second.remaining)
else
ParserResult.fail(input)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match!( other )\n return false unless prefers?( other ) && !matched?( other )\n matches << other\n other.matches << self\n end",
"def match(other)\n return @type.match(other)\n end",
"def matched?( other = nil )\n return full? if other.nil?\n matches.include? other... | [
"0.7682804",
"0.72650784",
"0.67639285",
"0.6610057",
"0.64860153",
"0.64123595",
"0.6329983",
"0.6305329",
"0.62685734",
"0.6240532",
"0.61721975",
"0.61672455",
"0.605391",
"0.605391",
"0.60297126",
"0.5999208",
"0.59959996",
"0.5976509",
"0.5967833",
"0.5966469",
"0.595573... | 0.52283984 | 85 |
Match this, other is ignored but consumed | def >=(other)
Parser.new do |input|
first = run(input)
if first.ok?
second = other.run(first.remaining)
if second.ok?
ParserResult.ok(first.output, matched: first.matched, remaining: second.remaining)
else
first
end
else
ParserResult.fail(input)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def *(other)\r\n Parser.new do |input|\r\n first = run(input)\r\n matched = \"\" \r\n \r\n if first.ok?\r\n matched += first.matched\r\n second = other.run(first.remaining)\r\n if second.ok?\r\n matched += second.matched\r\n ParserResult.ok(second.outpu... | [
"0.7575598",
"0.7359929",
"0.6971164",
"0.67466295",
"0.64603394",
"0.6368375",
"0.6315641",
"0.63054425",
"0.6304715",
"0.6018963",
"0.6018963",
"0.5948917",
"0.59217906",
"0.5897466",
"0.5890005",
"0.58659095",
"0.5854565",
"0.57825035",
"0.57570297",
"0.57570297",
"0.57521... | 0.54555273 | 36 |
Match other, this is ignored but consumed | def <=(other)
Parser.new do |input|
first = run(input)
remaining = input
remaining = first.remaining if first.ok?
second = other.run(remaining)
second.ok? ? second : ParserResult.fail(input)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def *(other)\r\n Parser.new do |input|\r\n first = run(input)\r\n matched = \"\" \r\n \r\n if first.ok?\r\n matched += first.matched\r\n second = other.run(first.remaining)\r\n if second.ok?\r\n matched += second.matched\r\n ParserResult.ok(second.outpu... | [
"0.7360159",
"0.7315379",
"0.71822625",
"0.6821532",
"0.6757335",
"0.6727719",
"0.66026604",
"0.6473662",
"0.64392906",
"0.6106261",
"0.59864825",
"0.5893444",
"0.5832901",
"0.5832901",
"0.5814502",
"0.5799897",
"0.57952696",
"0.5771203",
"0.5753837",
"0.5753837",
"0.56941634... | 0.5593987 | 30 |
Match this, other is QUIETLY consumed | def /(other)
Parser.new do |input|
first = run(input)
matched = ""
if first.ok?
matched = matched + first.matched
second = other.run(first.remaining)
if second.ok?
matched = matched + second.matched
ParserResult.ok(first.output, matched: matched, remaining: second.remaining)
else
ParserResult.fail(input)
end
else
first
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match!( other )\n return false unless prefers?( other ) && !matched?( other )\n matches << other\n other.matches << self\n end",
"def *(other)\r\n Parser.new do |input|\r\n first = run(input)\r\n matched = \"\" \r\n \r\n if first.ok?\r\n matched += first.... | [
"0.7279645",
"0.71666515",
"0.6466588",
"0.6361062",
"0.62821364",
"0.6208436",
"0.62007064",
"0.6177351",
"0.6177263",
"0.5977928",
"0.5934408",
"0.59318686",
"0.59318686",
"0.5894343",
"0.5832792",
"0.5832039",
"0.5814844",
"0.5773182",
"0.57327914",
"0.5697852",
"0.5691170... | 0.69726497 | 2 |
Match other, this is QUIETLY consumed | def *(other)
Parser.new do |input|
first = run(input)
matched = ""
if first.ok?
matched += first.matched
second = other.run(first.remaining)
if second.ok?
matched += second.matched
ParserResult.ok(second.output, matched: matched, remaining: second.remaining)
else
ParserResult.fail(input)
end
else
first
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match!( other )\n return false unless prefers?( other ) && !matched?( other )\n matches << other\n other.matches << self\n end",
"def match(other)\n return @type.match(other)\n end",
"def /(other)\r\n Parser.new do |input|\r\n first = run(input)\r\n matched = \"... | [
"0.7525035",
"0.7066797",
"0.6829415",
"0.6658574",
"0.635369",
"0.6244874",
"0.6244874",
"0.62068295",
"0.615179",
"0.61512655",
"0.613777",
"0.60879105",
"0.6085491",
"0.60663986",
"0.605456",
"0.6045661",
"0.6017222",
"0.60055333",
"0.59916204",
"0.5955564",
"0.5933731",
... | 0.68359673 | 2 |
other needs to fail for this to succeed; other is only peeking, not consuming | def !=(other)
Parser.new do |input|
second = other.run(input)
if second.ok?
ParserResult.fail(input)
else
run(input)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def peek; end",
"def peek; end",
"def peek\n end",
"def peek\n end",
"def peek()\n \n end",
"def reconsume; end",
"def consume; end",
"def consume; end",
"def consume; end",
"def peek\n first.nil? ? nil : first.data\n end",
"def peek_next()\n return nil if @at_end\n\n begi... | [
"0.6569636",
"0.6569636",
"0.6183702",
"0.6183702",
"0.61317277",
"0.60597605",
"0.60168797",
"0.60168797",
"0.60168797",
"0.5823068",
"0.57212484",
"0.57122177",
"0.5705513",
"0.5705513",
"0.56686497",
"0.5637091",
"0.5608257",
"0.5608257",
"0.5599791",
"0.5583014",
"0.55791... | 0.50164986 | 96 |
GET /blogs/1 GET /blogs/1.xml | def show
@blog = Blog.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @blog }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @blogs = Blog.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @blogs }\n end\n end",
"def index\n @mini_blogs = MiniBlog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml =>... | [
"0.75675976",
"0.7041089",
"0.687987",
"0.68646884",
"0.67798275",
"0.66650033",
"0.66015506",
"0.66015506",
"0.65977395",
"0.65851426",
"0.65532595",
"0.65532595",
"0.64719003",
"0.64669937",
"0.645303",
"0.6429664",
"0.6383779",
"0.6381864",
"0.6358612",
"0.6356602",
"0.634... | 0.6917531 | 2 |
Formats hash for elasticsearch. | def as_indexed_json(_options = {})
as_json methods: [:purchased_product_ids]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_sha(hash)\n # converts a hash to a SHA256\n return Digest::SHA256.hexdigest(JSON.dump(hash))\nend",
"def format_hash(hash)\n return hash.to_json\n end",
"def hexhash\n hash.to_s(16)\n end",
"def index_signature\n Digest::SHA256.new(@gems.keys.sort.join(',')).to_s\n end",
"d... | [
"0.63345295",
"0.631949",
"0.6136256",
"0.6058136",
"0.6037141",
"0.60188615",
"0.5984513",
"0.59808147",
"0.5906533",
"0.5894032",
"0.5878055",
"0.58170336",
"0.5815719",
"0.5801294",
"0.5801294",
"0.5801294",
"0.5801294",
"0.5801294",
"0.5801294",
"0.5801294",
"0.5796581",
... | 0.0 | -1 |
Define abilities for the passed in user here all actions must map to one of :read, :create, :update and :destroy | def initialize(user)
# Admins can do everything
if user.has_role? :admin
can :manage, :all
elsif user.has_role? :user
can :manage, :all
elsif user.has_role? :manager
can :manage, :all
else
can :read, :all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permits_read_acccess_for(user)\n end",
"def admin_actions(user)\n can_act_as_logged_in_user(user)\n can_view_any_profile\n can_view_any_gallery\n can_edit_saved_queries\n can_curate\n can_update_metadata\n can_administer\n end",
"def user_actions(user)\n can_act_as_logged_in_use... | [
"0.72404003",
"0.708542",
"0.7065996",
"0.7032902",
"0.6980593",
"0.69474715",
"0.6906283",
"0.6841716",
"0.6840753",
"0.6830086",
"0.6821917",
"0.68113625",
"0.6801826",
"0.6787446",
"0.67681736",
"0.6757758",
"0.6715448",
"0.67115086",
"0.6709978",
"0.6694957",
"0.6611906",... | 0.63182676 | 45 |
1) get the absolute value of the given int 2) if remainder of modulus 2 is 0, int is even 3) return false if even | def is_odd?(int)
int.abs % 2 == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd_using_remainder(int)\n int.remainder(2).abs == 1\nend",
"def is_odd?(int)\n \n # int.abs.odd? # #abs, #remainder\n\n # int.abs.remainder(2) == 1 # #abs and #remainder \n \n # int.remainder(2) == 1 || int.remainder(2) == -1 # remainder only\n \n int % 2 == 1 # #modulo % always has the sig... | [
"0.8155102",
"0.7989479",
"0.7913301",
"0.7911301",
"0.7900171",
"0.788383",
"0.7875258",
"0.7819344",
"0.78178805",
"0.77201325",
"0.7719269",
"0.76944417",
"0.7691849",
"0.7655406",
"0.7652833",
"0.7648933",
"0.76387006",
"0.7626929",
"0.7614453",
"0.7602958",
"0.7602709",
... | 0.75982064 | 21 |
Examples: puts is_odd?(2) => false puts is_odd?(5) => true puts is_odd?(17) => true puts is_odd?(8) => false puts is_odd?(0) => false puts is_odd?(7) => true | def is_odd?(int)
int.abs.remainder(2) == 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_odd?(num)\n num.odd?\nend",
"def is_odd?(num)\n num.odd?\nend",
"def is_odd?(n)\n n % 2 == 1\nend",
"def is_odd?(number)\n number % 2 == 1\nend",
"def is_odd?(num)\n num % 2 == 1\nend",
"def is_odd?(num)\n num % 2 == 1\nend",
"def is_odd?(num)\n num % 2 == 1\nend",
"def is_odd?(num)\n ... | [
"0.86251545",
"0.86251545",
"0.8577581",
"0.85632896",
"0.8560284",
"0.8560284",
"0.8560284",
"0.8560284",
"0.8560284",
"0.8558503",
"0.85578585",
"0.85578585",
"0.85411346",
"0.8539875",
"0.85338485",
"0.8532553",
"0.85318536",
"0.8507283",
"0.84922826",
"0.84922826",
"0.849... | 0.80976015 | 70 |
Parse the model from a string restricted to valid taxonomy models | def parse_model(category)
parsed = Object.const_get category.camelize
# category is a valid class, but not part of the taxonomy
raise TaxonomyCategoryError, 'Invalid taxonomy model' unless TAXONOMY_MODELS.include?(parsed)
parsed
rescue NameError
# category is not a class name
raise TaxonomyCategoryError, 'Invalid taxonomy model'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_classification(str = nil)\n self.class.parse_classification(str || classification)\n end",
"def parse(str)\n read_items(tokenize(str))\n end",
"def string_to_model(model_string)\n return nil if model_string.nil?\n begin\n class_name = Helper.classify(model_string)\n... | [
"0.62034065",
"0.5932946",
"0.5886837",
"0.5802161",
"0.56479216",
"0.5466261",
"0.53875995",
"0.53543335",
"0.52693117",
"0.5256628",
"0.5211876",
"0.5161932",
"0.5112799",
"0.5106325",
"0.5064706",
"0.5062906",
"0.50590456",
"0.5045913",
"0.5044629",
"0.5041108",
"0.5025386... | 0.71206045 | 0 |
The path used after confirmation. | def after_confirmation_path_for(resource_name, resource)
if signed_in?(resource_name)
signed_in_root_path(resource)
else
new_session_path(resource_name)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_confirmation_path_for(resource_name, resource)\n root_path\n end",
"def after_confirmation_path_for(resource_name, resource)\n '/'\n end",
"def after_confirmation_path_for(resource_name, resource) \n send(\"edit_#{resource.class.name.underscore}_path\",resource)\n end",
"def after_confi... | [
"0.66349876",
"0.66043603",
"0.6573877",
"0.6555062",
"0.65253043",
"0.6417593",
"0.64080113",
"0.6401703",
"0.63872176",
"0.6336483",
"0.6322352",
"0.6284309",
"0.6257149",
"0.6255734",
"0.6243767",
"0.6235097",
"0.6198236",
"0.6198236",
"0.6198236",
"0.618294",
"0.618294",
... | 0.58636045 | 59 |
TODO: Use this to divide the business logic of filter/paginate etc to different classes | def data_type
case query.class
when ActiveRecord::Relation then
'ActiveRecord'
when Array then
'Array'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filters\n end",
"def index\n if params.has_key?(:filters) && (params[:filters].has_key?(:with_category) || params[:filters].has_key?(:with_filter_category)) \n if params[:filters].has_key?(:with_category)\n approved_posts = Category.find(params[:filters][:with_category]).posts.approved\n ... | [
"0.68699884",
"0.6805359",
"0.6771609",
"0.6771609",
"0.6745628",
"0.66547203",
"0.65280807",
"0.65180904",
"0.6482598",
"0.64562076",
"0.6455163",
"0.64424753",
"0.64330465",
"0.6403332",
"0.6383995",
"0.6380859",
"0.63245934",
"0.6306504",
"0.6303307",
"0.62736267",
"0.6237... | 0.0 | -1 |
to support the helper methods | def method_missing(meth, *args, &block)
if @template.respond_to?(meth)
@template.send(meth, *args)
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def schubert; end",
"def custom; end",
"def custom; end",
"def formation; end",
"def probers; end",
"def suivre; end",
"def wrapper... | [
"0.7349231",
"0.67209494",
"0.67209494",
"0.67209494",
"0.6488915",
"0.6488915",
"0.6488915",
"0.6488915",
"0.6366008",
"0.6313106",
"0.6313106",
"0.62379044",
"0.6233126",
"0.6149767",
"0.60889626",
"0.6002597",
"0.6002597",
"0.5987161",
"0.5979048",
"0.5975604",
"0.59474206... | 0.0 | -1 |
Creates a new user session | def create
u = User.authenticate(params[:username],params[:pass])
if u.nil?
flash[:error] = "Incorrect username or password"
redirect_to login_path
elsif u.unit_ids.empty?
flash[:warning] = "You are not permitted to any units!"
render error_page
else
session[:username] = u.username
unit = Unit.find(u.unit_ids.first)
if params[:redirect].present?
redirect_to params[:redirect]
else
redirect_to dashboard_path
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_session\n @user = User.new(nickname: User.temp_user_name)\n @user.save\n session[:user_id] = @user.id\n @user\n end",
"def create_user_session\n password = '12345678'\n user = User.make!(\n password: password,\n password_confirmation: password\n )\n UserS... | [
"0.82859564",
"0.827315",
"0.8232315",
"0.7810846",
"0.77945787",
"0.7789419",
"0.77879214",
"0.77688676",
"0.7712219",
"0.7686182",
"0.7638238",
"0.76297677",
"0.7623936",
"0.7578841",
"0.75757337",
"0.7565223",
"0.7560115",
"0.75599605",
"0.7552574",
"0.7550635",
"0.7548139... | 0.0 | -1 |
Logs the user out of the current session | def destroy
session[:username] = nil
session[:unit_id] = nil
flash[:notice] = "You have been logged out of your session"
redirect_to login_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n reset_session\n @current_user = nil\n end",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_ou... | [
"0.90313727",
"0.90194225",
"0.90194225",
"0.90194225",
"0.90194225",
"0.90184355",
"0.90036446",
"0.8979998",
"0.8979273",
"0.8961106",
"0.89605933",
"0.89605933",
"0.89605933",
"0.89605933",
"0.89605933",
"0.89400697",
"0.89395934",
"0.89395934",
"0.89395934",
"0.89395934",
... | 0.0 | -1 |
POST /doses or /doses.json | def create
@dose = Dose.new(dose_params)
# params[:cocktail_id] = params[:dose][:cocktail_id]
# puts params
unless params[:cocktail_id]
params[:cocktail_id] = params[:dose][:cocktail_id]
end
# we need `cocktail_id` to associate dose with corresponding cocktail
@cocktail = Cocktail.find(params[:cocktail_id])
@dose.cocktail = @cocktail
if @dose.save
redirect_to cocktail_path(@cocktail)
else
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dose_params\n params.require(:dose).permit(:description, :cocktail_id, :ingredient_id)\n end",
"def create\n @dino = Dino.new(dino_params)\n\n respond_to do |format|\n if @dino.save\n format.html { redirect_to @dino, notice: 'Post was successfully created.' }\n format.json { render :sh... | [
"0.6195037",
"0.6093273",
"0.6045265",
"0.6045265",
"0.6008908",
"0.5949011",
"0.5939928",
"0.59249616",
"0.589916",
"0.5898053",
"0.58951515",
"0.58813566",
"0.58512306",
"0.5844822",
"0.58379114",
"0.5822551",
"0.5808132",
"0.58019817",
"0.5798987",
"0.57919616",
"0.5791949... | 0.53711295 | 98 |
PATCH/PUT /doses/1 or /doses/1.json | def update
respond_to do |format|
if @dose.update(dose_params)
format.html { redirect_to @dose, notice: "Dose was successfully updated." }
format.json { render :show, status: :ok, location: @dose }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @dose.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @dato = Dato.find(params[:id])\n\n respond_to do |format|\n if @dato.update_attributes(params[:dato])\n format.html { redirect_to @dato, notice: 'Dato was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | [
"0.6464308",
"0.63969034",
"0.6177823",
"0.6163817",
"0.6149591",
"0.61449516",
"0.6137483",
"0.61171657",
"0.61126965",
"0.6096866",
"0.6096866",
"0.6095977",
"0.60756403",
"0.60415494",
"0.60414",
"0.603132",
"0.6021616",
"0.6019254",
"0.60008323",
"0.59889174",
"0.5988343"... | 0.65665126 | 0 |
DELETE /doses/1 or /doses/1.json | def destroy
@dose.destroy
respond_to do |format|
format.html { redirect_to doses_url, notice: "Dose was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", ... | [
"0.7076688",
"0.69645673",
"0.69007015",
"0.6869136",
"0.6863619",
"0.68361866",
"0.67845535",
"0.67676026",
"0.67522967",
"0.6735489",
"0.6720011",
"0.67160106",
"0.66968083",
"0.66906",
"0.668819",
"0.668819",
"0.66842425",
"0.6671394",
"0.6671394",
"0.66708255",
"0.6664196... | 0.6957521 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_dose
@dose = Dose.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def dose_params
params.require(:dose).permit(:description, :cocktail_id, :ingredient_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69480115",
"0.6813417",
"0.68023044",
"0.67950493",
"0.67457634",
"0.6741017",
"0.65274155",
"0.6519536",
"0.6491671",
"0.64317423",
"0.64317423",
"0.64317423",
"0.63975054",
"0.6354703",
"0.63543284",
"0.6346128",
"0.63437325",
"0.63382536",
"0.6327421",
"0.6327421",
"0.6... | 0.0 | -1 |
permit only content to be changed modification to the title will not be updated in db | def post_update_params
params.require(:post).permit(:content)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit(title, content)\n if title.empty? || content.empty?\n puts \"Empty parameters are not allowed!\"\n else\n self.title = title\n self.content = content\n end\n end",
"def protect_update\n unless self.changes.keys == [\"text\"] && self.changes[\"text\"].first.blank?\n raise... | [
"0.69768894",
"0.68970186",
"0.6588974",
"0.6588974",
"0.6526899",
"0.63768554",
"0.6371761",
"0.6318203",
"0.6141232",
"0.6107424",
"0.60378736",
"0.60150915",
"0.6005922",
"0.5985029",
"0.5971156",
"0.5947433",
"0.59125954",
"0.5911662",
"0.59087795",
"0.58831906",
"0.58824... | 0.0 | -1 |
GET /certificate_types GET /certificate_types.json | def index
@certificate_types = CertificateType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_types\n @certificate_types ||= get('ssl/v1/types')\n end",
"def certificate_type(type)\n case type.to_sym\n when :mac_installer_distribution\n return [\n Spaceship::ConnectAPI::Certificate::CertificateType::MAC_INSTALLER_DISTRIBUTION\n ]\n when :distribut... | [
"0.8104255",
"0.65836036",
"0.6425439",
"0.6350234",
"0.6322824",
"0.6230423",
"0.6203095",
"0.6030114",
"0.60202694",
"0.59811676",
"0.5977528",
"0.59132385",
"0.58979917",
"0.58531004",
"0.5830979",
"0.5749992",
"0.57461816",
"0.5745408",
"0.57342404",
"0.568818",
"0.564480... | 0.7308189 | 1 |
GET /certificate_types/1 GET /certificate_types/1.json | def show
@certificate_type = CertificateType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def certificate_types\n @certificate_types ||= get('ssl/v1/types')\n end",
"def index\n @certificate_types = CertificateType.all\n end",
"def set_certificate_type\n @certificate_type = CertificateType.find(params[:id])\n end",
"def create\n @certificate = Certificate.new\n @certificate.... | [
"0.7566159",
"0.71460354",
"0.6487943",
"0.6350391",
"0.633836",
"0.6091273",
"0.57609403",
"0.5752859",
"0.5729344",
"0.5683841",
"0.56778467",
"0.566153",
"0.5661328",
"0.56149423",
"0.5598419",
"0.5521393",
"0.5521393",
"0.54931074",
"0.54878336",
"0.54726267",
"0.5471704"... | 0.69859225 | 2 |
POST /certificate_types POST /certificate_types.json | def create
@certificate_types = CertificateType.all
@certificate_type = CertificateType.create(certificate_type_params)
=begin
@certificate_type = CertificateType.new(certificate_type_params)
respond_to do |format|
if @certificate_type.save
format.html { redirect_to @certificate_type, notice: 'Certificate type was successfully created.' }
format.json { render :show, status: :created, location: @certificate_type }
else
format.html { render :new }
format.json { render json: @certificate_type.errors, status: :unprocessable_entity }
end
end
=end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @certificate = Certificate.new\n @certificate.user_id = current_user.id\n @certificate.type_certificate_id = params[:type_certificate_id]\n @certificate.type_status_certificate_id = \"1\"\n respond_to do |format|\n if @certificate.save\n format.html { redirect_to certificate... | [
"0.69338155",
"0.6844316",
"0.66757464",
"0.61917603",
"0.6135828",
"0.6108459",
"0.6041339",
"0.5720406",
"0.5720406",
"0.5694849",
"0.5677712",
"0.5677712",
"0.56286657",
"0.55464506",
"0.55341625",
"0.5527153",
"0.5500955",
"0.5471626",
"0.5468538",
"0.54672587",
"0.544849... | 0.6662436 | 3 |
PATCH/PUT /certificate_types/1 PATCH/PUT /certificate_types/1.json | def update
@certificate_types = CertificateType.all
@certificate_type = CertificateType.find(params[:id])
@certificate_type.update_attributes(certificate_type_params)
=begin
respond_to do |format|
if @certificate_type.update(certificate_type_params)
format.html { redirect_to @certificate_type, notice: 'Certificate type was successfully updated.' }
format.json { render :show, status: :ok, location: @certificate_type }
else
format.html { render :edit }
format.json { render json: @certificate_type.errors, status: :unprocessable_entity }
end
end
=end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @certificate = Certificate.new\n @certificate.user_id = current_user.id\n @certificate.type_certificate_id = params[:type_certificate_id]\n @certificate.type_status_certificate_id = \"1\"\n respond_to do |format|\n if @certificate.save\n format.html { redirect_to certificate... | [
"0.6333524",
"0.62886536",
"0.6218417",
"0.61700803",
"0.6091305",
"0.60303044",
"0.60258335",
"0.602001",
"0.59338444",
"0.5886907",
"0.5873122",
"0.5865945",
"0.5850348",
"0.584226",
"0.58271945",
"0.58150136",
"0.5810973",
"0.58024776",
"0.5797321",
"0.57758254",
"0.575896... | 0.700078 | 0 |
DELETE /certificate_types/1 DELETE /certificate_types/1.json | def destroy
@certificate_types = CertificateType.all
@certificate_type = CertificateType.find(params[:id])
@certificate_type.destroy
=begin
@certificate_type.destroy
respond_to do |format|
format.html { redirect_to certificate_types_url, notice: 'Certificate type was successfully destroyed.' }
format.json { head :no_content }
end
=end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @certificate_request.destroy\n respond_to do |format|\n format.html { redirect_to certificate_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @certificate.destroy\n respond_to do |format|\n format.html { redirect_to certificates_path}\n ... | [
"0.7054653",
"0.70482177",
"0.6925532",
"0.6846456",
"0.6809663",
"0.67895067",
"0.6718862",
"0.6715019",
"0.6709539",
"0.6686777",
"0.6680193",
"0.66801316",
"0.6662887",
"0.6658996",
"0.66581297",
"0.66442895",
"0.6642985",
"0.66384417",
"0.6631496",
"0.66069263",
"0.660287... | 0.7335979 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_certificate_type
@certificate_type = CertificateType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def certificate_type_params
params.require(:certificate_type).permit(:certificate_type_title, :notes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
define_index do activity_object_index end | def parent_post
self.post_activity.parent.direct_object
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_index\n end",
"def index ; @index ; end",
"def index activity\n default_fields = {\n \"user_id\" => activity.actor.id,\n \"action\" => activity.verb,\n \"published_date\" => activity.published,\... | [
"0.695959",
"0.65478635",
"0.64821345",
"0.64515054",
"0.63985515",
"0.6387041",
"0.63653505",
"0.63279486",
"0.61860895",
"0.61366147",
"0.6130462",
"0.6104183",
"0.60743684",
"0.5999753",
"0.59713614",
"0.59684956",
"0.59684956",
"0.59423524",
"0.59395105",
"0.5928189",
"0.... | 0.0 | -1 |
after_create callback Increment comment counter in parent's activity_object with a comment | def increment_comment_count_and_touch
return if self.post_activity.parent.blank?
self.post_activity.parent.direct_activity_object.increment!(:comment_count) unless self.post_activity.parent.direct_activity_object.blank?
self.post_activity.parent.direct_object.touch unless self.post_activity.parent.direct_object.blank?
self.post_activity.parent.direct_activity_object.touch unless self.post_activity.parent.direct_activity_object.blank?
self.post_activity.parent.touch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_create\n super\n\n parent = self.parent\n parent.comment_count += 1\n parent.skip_timestamp_update = true\n parent.save\n\n true\n end",
"def increment_comment_count\n self.comments_count += 1\n self.save\n end",
"def increment_num_comments\n\n end",
"def de... | [
"0.75655276",
"0.71291536",
"0.69698304",
"0.68919057",
"0.6699023",
"0.63902295",
"0.63199794",
"0.63199794",
"0.63199794",
"0.6202352",
"0.61733323",
"0.6154313",
"0.61397946",
"0.61345136",
"0.61261076",
"0.61199003",
"0.60867524",
"0.60606205",
"0.60568607",
"0.6056152",
... | 0.75560576 | 1 |
before_destroy callback Decrement comment counter in parent's activity_object when comment is destroyed | def decrement_comment_count
return if self.post_activity.blank? or self.post_activity.parent.blank? or self.post_activity.parent.direct_activity_object.blank?
self.post_activity.parent.direct_activity_object.decrement!(:comment_count)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_destroy(comment)\n expire_cache_for(comment)\n end",
"def before_destroy\n return false unless super\n\n parent = self.parent\n parent.comment_count -= 1\n parent.skip_timestamp_update = true\n parent.save\n\n true\n end",
"def decrement_comments_count\n return... | [
"0.71092385",
"0.6999157",
"0.6964054",
"0.69132113",
"0.65815014",
"0.6385498",
"0.6287307",
"0.6241904",
"0.6207548",
"0.61595756",
"0.6157368",
"0.61291933",
"0.61263585",
"0.61225367",
"0.6089419",
"0.60752416",
"0.60453826",
"0.60340065",
"0.6022162",
"0.60126555",
"0.60... | 0.7533259 | 0 |
respond to options requests with blank text/plain as per spec | def cors_preflight_check
logger.info ">>> responding to CORS request"
render :text => '', :content_type => 'text/plain'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n render plain: ''\n end",
"def options\n render plain: ''\n end",
"def options\n render plain: ''\n end",
"def options(request, response)\n OK\n end",
"def display_options\n puts \"Please, write a type of request you want to send: GET or POST.\"\n puts \"Write EXIT to... | [
"0.7156246",
"0.7156246",
"0.7156246",
"0.7052231",
"0.68785197",
"0.67877954",
"0.6758028",
"0.67430913",
"0.6725061",
"0.6581845",
"0.6502666",
"0.640191",
"0.63130814",
"0.6311623",
"0.62861645",
"0.6278224",
"0.62780493",
"0.61513525",
"0.6149256",
"0.61180335",
"0.611375... | 0.0 | -1 |
For all responses in this controller, return the CORS access control headers. | def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Headers'] = 'X-AUTH-TOKEN, X-API-VERSION, X-Requested-With, Content-Type, Accept, Origin'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
headers['Access-Control-Max-Age'] = "1728000"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_headers(env)\n cors_origin(env) ? cors_headers(env) : {}\n end",
"def cors_set_access_control_headers\n headers['Access-Control-Allow-Origin'] = '*'\n headers['Access-Control-Expose-Headers'] = 'ETag'\n headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS'... | [
"0.7619958",
"0.7606048",
"0.7606048",
"0.75027907",
"0.7487557",
"0.7425582",
"0.74099994",
"0.74074537",
"0.7405096",
"0.7394521",
"0.73921406",
"0.7384172",
"0.73771304",
"0.7372764",
"0.7372764",
"0.7372764",
"0.73598355",
"0.7350838",
"0.7333332",
"0.7333332",
"0.728667"... | 0.72555816 | 33 |
Go through each line looking for effects. Note that the data id is currently hardcoded to 0 since we don't really need it. | def load_notetag_effect_manager
@effects ||= []
@effect_checked = true
# check for effects
results = self.note.scan(Effect_Manager::Effect_Regex)
results.each {|code, trigger, args|
code = Effect_Manager.get_effect_code(code.to_sym)
if code
check_effect(code, trigger, args)
@effects[-1].trigger = trigger ? trigger.gsub!("-", "") : nil
end
}
# check for conditional effects
results = self.note.scan(Effect_Manager::CondEff_Regex)
results.each {|code, trigger, cond, args|
code = Effect_Manager.get_effect_code(code.to_sym)
if code
check_effect(code, trigger, args)
@effects[-1].trigger = trigger ? trigger.gsub!("-", "") : nil
@effects[-1].condition = cond
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_effects\n @reflect_sprites = []\n return if not $game_map.use_reflection\n $game_map.events.values.each do |event|\n push_reflect(event.id, event)\n end\n i = 0\n $game_map.vehicles.each do |vehicle|\n id = [:vehicle, i]\n push_reflect(id, vehicle)\n i += 1\n end... | [
"0.5549563",
"0.55165404",
"0.5426722",
"0.5384776",
"0.5202745",
"0.51933545",
"0.5167577",
"0.51632774",
"0.5068507",
"0.50553095",
"0.5029323",
"0.5020759",
"0.50107205",
"0.49559227",
"0.49550647",
"0.49375147",
"0.49177548",
"0.48597726",
"0.48597726",
"0.48597726",
"0.4... | 0.5557481 | 0 |
Adds a message to the list of effect messages that should be displayed | def add_effect_message(msg)
@effect_results.push(msg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notice(msg)\n @notices << msg\n blah @notices.last\n end",
"def msg(message)\n output[:messages] << message\n end",
"def msg(message)\n output[:messages] << message\n end",
"def add_message(name, message)\n\t\tend",
"def add_message(message,opts={})\n # Append ... | [
"0.6669496",
"0.63974345",
"0.63386595",
"0.62550586",
"0.61707664",
"0.614828",
"0.609866",
"0.6028703",
"0.5989081",
"0.5980638",
"0.5957568",
"0.59370935",
"0.5912262",
"0.5817197",
"0.58017135",
"0.5777515",
"0.5766301",
"0.5734362",
"0.5716786",
"0.5715853",
"0.5715853",... | 0.8274196 | 0 |
new. Trigger turn start effects | def on_turn_start
check_turn_start_effects
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_turn\n write('START_TURN')\n end",
"def check_turn_start_effects\n check_effects(effect_objects, \"turn_start\")\n end",
"def start\n self.started = true\n self.my_turn = true\n self.save\n end",
"def start_turn\n puts \"----- NEW TURN -----\"\n @turn += 1\n if (@turn.odd... | [
"0.6914494",
"0.6747525",
"0.6552256",
"0.6501796",
"0.64189965",
"0.62700546",
"0.6227817",
"0.6227273",
"0.6173956",
"0.6151766",
"0.6059663",
"0.60369337",
"0.60298884",
"0.5984758",
"0.5983596",
"0.59660244",
"0.5959272",
"0.59279466",
"0.5925159",
"0.5901028",
"0.5885008... | 0.77043873 | 0 |
Trigger state removal effects | def erase_state(state_id)
super
check_state_remove_effects(state_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_rem_state\n return unless PONY::ERRNO::check_sequence(current_act)\n current_action_targets.each do |target|\n state_id = @acts[1]\n chance = @acts[2] || 100\n chance = chance / 100.0 if c.integer?\n target.remove_state(state_id) if rand < chance\n end\n end",
"def o... | [
"0.686129",
"0.6764139",
"0.6627334",
"0.64822656",
"0.6468644",
"0.61762106",
"0.6141799",
"0.6133024",
"0.6039592",
"0.6000979",
"0.5930841",
"0.58792895",
"0.5837878",
"0.5780357",
"0.5774075",
"0.57637376",
"0.57552075",
"0.57552075",
"0.57540476",
"0.5747303",
"0.5745485... | 0.72207284 | 0 |
============================================================================= Apply the effect ============================================================================= | def get_effect_method_name(effect, type="", trigger="")
method_name = Effect_Manager.method_table[effect.code].to_s
return "" unless method_name
# no specific effect trigger specified, then assume any trigger valid
# or maybe it is just a default effect
if effect.trigger.nil?
if trigger.empty?
method_name = sprintf("%s_effect_%s", type, method_name)
else
method_name = sprintf("%s_effect_%s_%s", type, method_name, trigger)
end
# otherwise, check if it's the specified trigger
elsif effect.trigger == trigger
method_name = sprintf("%s_effect_%s_%s", type, method_name, trigger)
else
method_name = ""
end
return method_name.to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intermediate_effect(_effects); end",
"def draw_effect\n end",
"def final_effect(_effects); end",
"def do_effect(target)\n end",
"def ppEffectAdjust _obj, _args\n \"_obj ppEffectAdjust _args;\" \n end",
"def apply_effect effect\n\t\timage_url = \"#{Rails.root}/public\"+image_url(:image).to_s... | [
"0.74591553",
"0.7212173",
"0.7149852",
"0.6916583",
"0.68970025",
"0.6773354",
"0.6734518",
"0.6400969",
"0.6400969",
"0.6159917",
"0.6106256",
"0.60932356",
"0.6093075",
"0.6092728",
"0.60806066",
"0.60325366",
"0.60325366",
"0.5974747",
"0.5912678",
"0.58981967",
"0.588939... | 0.0 | -1 |
Apply custom effects. This should ignore all default effects since they don't have anything special and shouldn't be called here anyways | def effect_apply(user, obj, effect, type, trigger)
return if effect.code.is_a?(Fixnum)
return unless check_effect_condition(user, effect)
method_name = get_effect_method_name(effect, type, trigger)
if respond_to?(method_name)
# someone used this against this battler
if user
send(method_name, user, obj, effect)
# effect was triggered by the system
else
send(method_name, obj, effect)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intermediate_effect(_effects); end",
"def final_effect(_effects); end",
"def merge_effects(expr, effects, results); end",
"def do_effect(target)\n end",
"def paint_effects(effects = Array.new)\n effects.concat(theme[:effect] ? [theme[:effect]] : [])\n effects.concat((theme[:effects].kind_of? Arr... | [
"0.75503385",
"0.69618124",
"0.64256537",
"0.6402147",
"0.63213015",
"0.61765856",
"0.6090598",
"0.6072554",
"0.60130584",
"0.59516454",
"0.58809674",
"0.58809674",
"0.583811",
"0.5804388",
"0.5767953",
"0.57523984",
"0.57203376",
"0.5659859",
"0.5643215",
"0.5625744",
"0.559... | 0.57357234 | 16 |
overwritten. Table is now grabbed from a dynamicallycreated table | def item_effect_apply(user, item, effect)
return unless check_effect_condition(user, effect)
method_name = Effect_Manager.method_table[effect.code]
unless method_name.to_s.start_with?("item_effect")
method_name = get_effect_method_name(effect, "item", "")
end
send(method_name, user, item, effect) if respond_to?(method_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebuild(table); end",
"def _table; @table end",
"def initialize_dynamic_table(table, run_control)\n table_model = @main_tab.getControl(table).getModel\n initialize_table_checks(table_model)\n run_control.addActionListener do |_e|\n table_model.uncheckDisplayedRecords\n table_model.setRec... | [
"0.7099603",
"0.6878936",
"0.6722737",
"0.67113125",
"0.66318446",
"0.66318446",
"0.66318446",
"0.66318446",
"0.663179",
"0.65028197",
"0.63778645",
"0.6347676",
"0.6327487",
"0.6298138",
"0.6280162",
"0.6255016",
"0.62518114",
"0.62518114",
"0.62518114",
"0.62518114",
"0.625... | 0.0 | -1 |
Check if there are effects to apply other than the item used This method basically checks the effects for all effect objects | def check_effects(objects, trigger, user=nil, item=nil)
objects.each {|obj|
type = type || Effect_Manager::Effect_Types[obj.class]
obj.effects.each {|effect|
effect_apply(user, obj, effect, type, trigger)
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_effects_valid?\n item_target_actors.any? do |target|\n target.item_test(user, item)\n end\n end",
"def item_effects_valid?\r\n item_target_actors.any? do |target|\r\n target.item_test(user, item)\r\n end\r\n end",
"def check_battle_start_effects\n check_effects(effect_object... | [
"0.74180835",
"0.74179405",
"0.7098898",
"0.707059",
"0.6858989",
"0.6724837",
"0.67233604",
"0.6667375",
"0.66333836",
"0.6620822",
"0.66168445",
"0.65889025",
"0.6587787",
"0.658105",
"0.6546316",
"0.6461285",
"0.6458046",
"0.6444325",
"0.63529986",
"0.63077486",
"0.6274781... | 0.75554085 | 0 |
Triggers for all effect objects Triggered after basic damage calculation is done, but before damage is executed | def check_pre_attack_effects(user, item)
check_effects(user.effect_objects, "pre_attack", user, item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def setup_damage\n return if item_in_use.nil?\n item = copy(item_in_use) \n # Copy item. In case if you want to modify anything\n \n # ----- Evaluate skill ------- #\n if @acts[1].is_a?(String) # Change formula? No prob ~... | [
"0.77676654",
"0.77676654",
"0.67348254",
"0.67213273",
"0.6656531",
"0.6620137",
"0.6593273",
"0.6578581",
"0.6532442",
"0.6469453",
"0.64622366",
"0.6399432",
"0.63811433",
"0.6336712",
"0.63295126",
"0.63154227",
"0.6293706",
"0.6248694",
"0.62204546",
"0.61899495",
"0.617... | 0.58680356 | 35 |
Same as attack_damage, except on the guard side | def check_pre_guard_effects(user, item)
check_effects(effect_objects, "pre_guard", user, item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack_effect_damage\r\n self.hp -= self.damage\r\n end",
"def attack_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end",
"def attack_effect_base_damage(attacker)\r\n atk = [attacker.atk - self.pdef / 2, 0].max\r\n self.damage = atk * (20 + attacker.str) / 20\r\n end",
... | [
"0.80858403",
"0.7746437",
"0.77327913",
"0.7637266",
"0.74669105",
"0.7453957",
"0.7432589",
"0.7432589",
"0.7378648",
"0.73056585",
"0.729929",
"0.7245455",
"0.72361195",
"0.7232463",
"0.71967363",
"0.7183662",
"0.7183548",
"0.71817195",
"0.71817195",
"0.71592546",
"0.71304... | 0.0 | -1 |
Attack effects are applied whenever the battler successfully hits | def check_attack_effects(user, item)
check_effects(user.effect_objects, "attack", user, item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack_effect(attacker)\n # Clear critical flag\n self.critical = false\n # First hit detection\n hit_result = (rand(100) < attacker.hit)\n # If hit occurs\n if hit_result == true\n # Calculate basic damage\n atk = [attacker.atk - self.pdef / 2, 0].max\n self.damage = atk * (20... | [
"0.76807034",
"0.76280373",
"0.76280373",
"0.7326887",
"0.72388315",
"0.71883166",
"0.71694964",
"0.71694964",
"0.7168242",
"0.715727",
"0.71519095",
"0.7151633",
"0.7130912",
"0.71011144",
"0.70770574",
"0.7040985",
"0.7012352",
"0.6975442",
"0.69624084",
"0.69531244",
"0.69... | 0.67569387 | 30 |
Guard effects are applied whenever you are hit | def check_guard_effects(user, item)
check_effects(effect_objects, "guard", user, item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end",
"def skill_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end",
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def attack_effect(attacker)\n # Clear critical flag\n ... | [
"0.70578396",
"0.68442637",
"0.6522457",
"0.6522457",
"0.6420868",
"0.63868666",
"0.63868475",
"0.6274915",
"0.6261857",
"0.62483776",
"0.6186749",
"0.6167283",
"0.6152152",
"0.61505705",
"0.61239815",
"0.61033195",
"0.60439557",
"0.6043334",
"0.59841925",
"0.5980636",
"0.595... | 0.6400668 | 5 |
Critical effects applied when critical hit is dealt | def check_critical_effects(user, item)
check_effects(user.effect_objects, "crit_attack", user, item)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attack_effect_setup\r\n self.critical = false\r\n end",
"def critical_hit?\n @critical\n end",
"def skill_effect_setup\r\n self.critical = false\r\n end",
"def set_normal\n self.critical = false\n end",
"def item_effect_setup\r\n self.critical = false\r\n end",
"def attack... | [
"0.7260045",
"0.692407",
"0.68784696",
"0.6794885",
"0.67899007",
"0.67458355",
"0.672129",
"0.6642491",
"0.6550263",
"0.65057015",
"0.6401203",
"0.61737764",
"0.61737764",
"0.6115077",
"0.6115077",
"0.6078776",
"0.6073759",
"0.6062666",
"0.5966451",
"0.5963692",
"0.5911697",... | 0.6031321 | 18 |
Effects are applied at the start of the battle | def check_battle_start_effects
check_effects(effect_objects, "battle_start")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_new_effect\n if $game_party.in_battle && SceneManager.scene_is?(Scene_Battle_TBS)\n return unless @character\n if !@balloon_sprite && @character.balloon_id > 0\n @balloon_id = @character.balloon_id\n start_balloon\n end\n if !@character_visible && @character.alive?\n ... | [
"0.779279",
"0.73522866",
"0.73522866",
"0.71167123",
"0.7060648",
"0.6915007",
"0.6805167",
"0.67292035",
"0.67247665",
"0.67246014",
"0.670039",
"0.668972",
"0.6681346",
"0.6551592",
"0.6508661",
"0.64790064",
"0.6475511",
"0.64628935",
"0.6457264",
"0.6435193",
"0.63826704... | 0.6807382 | 6 |
Effects triggered at the end of the battle | def check_battle_end_effects
check_effects(effect_objects, "battle_end")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def final_effect(_effects); end",
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def after_battle_effect\n case $game_process\n when 0\n framed_narration('After having a quick break in the tent, you felt refreshed.(HP restored)')\n @player[:hp] = 45\n when 1\n ... | [
"0.7921852",
"0.73836774",
"0.73836774",
"0.68576336",
"0.68403256",
"0.677691",
"0.6772665",
"0.6761501",
"0.67542183",
"0.6741755",
"0.6741755",
"0.67303663",
"0.6691122",
"0.6676174",
"0.65901977",
"0.65509",
"0.6535546",
"0.6498733",
"0.6498733",
"0.6498733",
"0.6498733",... | 0.7249299 | 3 |
Effects triggered at the start of each turn | def check_turn_start_effects
check_effects(effect_objects, "turn_start")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_turn_start\n check_turn_start_effects\n end",
"def start_effect(effect_type)\n @effect_type = effect_type\n case @effect_type\n when :appear\n @effect_duration = 16\n @battler_visible = true\n when :disappear\n @effect_duration = 32\n @battler_visible = false\n when ... | [
"0.7556023",
"0.70175576",
"0.68072474",
"0.6738526",
"0.6666355",
"0.65449625",
"0.6489179",
"0.6489179",
"0.64221007",
"0.62872285",
"0.6275834",
"0.6193637",
"0.617615",
"0.6158138",
"0.61468935",
"0.6138041",
"0.61038184",
"0.61026114",
"0.6097902",
"0.6089337",
"0.608484... | 0.6800614 | 3 |
Effects triggered at the end of each turn | def check_turn_end_effects
check_effects(effect_objects, "turn_end")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def final_effect(_effects); end",
"def intermediate_effect(_effects); end",
"def perform_damage_effect\n end",
"def perform_damage_effect\n end",
"def do_effect(target)\n end",
"def draw_effect\n end",
"def victory_end\n RPG::BGM.fade(500) unless skip?\n 20.times do; Graphics.update; end\n ... | [
"0.790666",
"0.69511825",
"0.66982555",
"0.66982555",
"0.65520173",
"0.65059274",
"0.63934845",
"0.63908273",
"0.6373414",
"0.6346203",
"0.63437474",
"0.622195",
"0.61957675",
"0.61521536",
"0.6121029",
"0.61181104",
"0.6106548",
"0.60841495",
"0.60829306",
"0.6060354",
"0.60... | 0.6781513 | 2 |
Triggers for specific objects | def check_equip_effects(equip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def triggers\n\n end",
"def notifycollision(obj); end",
"def notifycollision(obj); end",
"def register( *objects )\n objects.each do |object|\n append_hook( :owner => object, \n :trigger => YesTrigger.new, \n :action => MethodAction.new(:handle) )\n end\n e... | [
"0.6612149",
"0.6575589",
"0.6575589",
"0.6340758",
"0.6299564",
"0.627547",
"0.616567",
"0.6162994",
"0.5945214",
"0.5867033",
"0.5847435",
"0.5845495",
"0.5827038",
"0.5822469",
"0.5812233",
"0.5796368",
"0.57792425",
"0.57570815",
"0.5711262",
"0.57070506",
"0.56717855",
... | 0.0 | -1 |
Write a method that takes an integer flight_length (in minutes) and an array of integers movie_lengths (in minutes) and returns a boolean indicating whether there are two numbers in movie_lengths whose sum equals flight_length. | def movie(movie_lengths, flight_length)
movies = []
movie_lengths.each do |first_movie_length|
second_movie_length = flight_length - first_movie_length
if movies.include?(second_movie_length)
p true
break
else
movies << first_movie_length
p false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_two_movies_fill_flight(movie_lengths, flight_length) \n\n #movie lengths we've seen so far\n\n movie_lengths_seen = Set.new\n\n movie_lengths.each do |first_movie_length|\n matching_second_movie_length = flight_length - first_movie_length\n\n if movie_lengths_seen.include?(matching_second_movie_le... | [
"0.8109801",
"0.7986078",
"0.73181015",
"0.68194026",
"0.62689227",
"0.6107957",
"0.5951175",
"0.59475696",
"0.59475696",
"0.5898552",
"0.5873075",
"0.5865871",
"0.5852237",
"0.5837386",
"0.5820688",
"0.57778406",
"0.574252",
"0.5738749",
"0.57204705",
"0.5676736",
"0.5675747... | 0.7717901 | 2 |
If one numerical argument is given, the graph is drawn at 4/3 ratio according to the given width (800 results in 800x600, 400 gives 400x300, etc.). Or, send a geometry string for other ratios ('800x400', '400x225'). Looks for Bitstream Vera as the default font. Expects an environment var of MAGICK_FONT_PATH to be set. (Uses RMagick's default font otherwise.) | def initialize(target_width=800)
if not Numeric === target_width
geometric_width, geometric_height = target_width.split('x')
@columns = geometric_width.to_f
@rows = geometric_height.to_f
else
@columns = target_width.to_f
@rows = target_width.to_f * 9/16
end
initialize_ivars
reset_themes()
theme_keynote()
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_text_width(text, params)\n\t\tpointsize = params[:pointsize] || 20\n\t\tfont_family = params[:font_family] || nil\n\t\tfont_style = params[:font_style] || nil\n\t\tdensity_fraction = RVG::dpi\n\t\tgc = Magick::Draw.new\n\t\timg = Magick::Image.new(900,50){\n\t\t\tself.density=\"#{density_fraction}x#{densit... | [
"0.5971235",
"0.5423264",
"0.53317046",
"0.5310532",
"0.5307301",
"0.52719855",
"0.5264429",
"0.52403593",
"0.5200085",
"0.5187206",
"0.5178781",
"0.5163712",
"0.5143764",
"0.50670797",
"0.50561464",
"0.504868",
"0.503036",
"0.5003994",
"0.49928245",
"0.49802253",
"0.49785158... | 0.0 | -1 |
Set instance variables for this object. Subclasses can override this, call super, then set values separately. This makes it possible to set defaults in a subclass but still allow developers to change this values in their program. | def initialize_ivars
# Internal for calculations
super
@marker_font_size = 21.0 * 9/16
@legend_font_size = 20.0 * 9/16
@title_font_size = 36.0 * 9/16
@top_margin = TOP_MARGIN
@bottom_margin = BOTTOM_MARGIN
@left_margin = LEFT_MARGIN
@right_margin = RIGHT_MARGIN
@legend_margin = LEGEND_MARGIN
@title_margin = TITLE_MARGIN
@legend_box_size = 20.0 * 9/16
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(*attrs)\n options = attrs.empty? ? {} : attrs.first\n options = self.class.defaults.merge(options)\n set_instance_variables options\n end",
"def set_default_values\n self.class.defaults.each do |key, default|\n self[key] ||= default\n end\n end",
"def set_uninitiali... | [
"0.6584614",
"0.6563287",
"0.6538091",
"0.6342016",
"0.6332123",
"0.6330527",
"0.6309592",
"0.6292111",
"0.62848276",
"0.6280694",
"0.62452507",
"0.6237234",
"0.61882603",
"0.61869144",
"0.61869144",
"0.61752385",
"0.61369735",
"0.6110364",
"0.61034256",
"0.6102725",
"0.61023... | 0.0 | -1 |
A color scheme similar to the popular presentation software. | def theme_keynote
# Colors
@blue = '#6886B4'
@yellow = '#FDD84E'
@green = '#72AE6E'
@red = '#D1695E'
@purple = '#8A6EAF'
@orange = '#EFAA43'
@white = 'white'
@colors = [@yellow, @blue, @green, @red, @purple, @orange]
self.theme = {
:colors => @colors,
:marker_color => 'white',
# :font_color => 'white',
# :background_colors => ['black', '#4a465a']
:font_color => 'black',
:background_colors => ['white', 'white']
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hsla_color; end",
"def colors; end",
"def red\n colorize(31)\n end",
"def crisis_color\n return Color.new(255, 255, 64)\n end",
"def purple\n colorize(35)\n end",
"def crisis_color\n return text_color(17)\n end",
"def color(color); end",
"def color; end",
"def color; end",
"de... | [
"0.737778",
"0.72017676",
"0.7196767",
"0.7154139",
"0.7115612",
"0.69944936",
"0.6915528",
"0.6902813",
"0.6902813",
"0.6902813",
"0.68406016",
"0.6833507",
"0.68313175",
"0.6803802",
"0.67841864",
"0.67700315",
"0.67590165",
"0.6749452",
"0.6737062",
"0.67336786",
"0.673109... | 0.0 | -1 |
Calculates size of drawable area, general font dimensions, etc. | def setup_graph_measurements
@marker_caps_height = calculate_caps_height(@marker_font_size)
@title_caps_height = calculate_caps_height(@title_font_size)
@legend_caps_height = calculate_caps_height(@legend_font_size)
if @hide_line_markers
(@graph_left,
@graph_right_margin,
@graph_bottom_margin) = [LEFT_MARGIN, RIGHT_MARGIN, BOTTOM_MARGIN]
else
longest_left_label_width = 0
if @has_left_labels
longest_left_label_width = calculate_width(@marker_font_size,
labels.values.inject('') { |value, memo| (value.to_s.length > memo.to_s.length) ? value : memo }) * 1.25
else
longest_left_label_width = calculate_width(@marker_font_size,
label(@maximum_value.to_f))
end
# Shift graph if left line numbers are hidden
line_number_width = @hide_line_numbers && !@has_left_labels ?
0.0 :
(longest_left_label_width + LABEL_MARGIN * 2)
@graph_left = LEFT_MARGIN +
line_number_width +
(@y_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN * 2)
# Make space for half the width of the rightmost column label.
# Might be greater than the number of columns if between-style bar markers are used.
last_label = @labels.keys.sort.last.to_i
extra_room_for_long_label = (last_label >= (@column_count-1) && @center_labels_over_point) ?
calculate_width(@marker_font_size, @labels[last_label])/2.0 :
0
@graph_right_margin = RIGHT_MARGIN + extra_room_for_long_label
@graph_bottom_margin = BOTTOM_MARGIN +
@marker_caps_height + LABEL_MARGIN
end
@graph_right = @raw_columns - @graph_right_margin
@graph_width = @raw_columns - @graph_left - @graph_right_margin
# When @hide title, leave a TITLE_MARGIN space for aesthetics.
# Same with @hide_legend
@graph_top = TOP_MARGIN +
(@hide_title ? TITLE_MARGIN : @title_caps_height + TITLE_MARGIN * 2) +
(@hide_legend ? LEGEND_MARGIN : @legend_caps_height + LEGEND_MARGIN * 2)
@graph_bottom = @raw_rows - @graph_bottom_margin -
(@x_axis_label.nil? ? 0.0 : @marker_caps_height + LABEL_MARGIN)
@graph_height = @graph_bottom - @graph_top
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pixel_size; size.x * size.y; end",
"def size\n size_dependencies = [calculated_width, calculated_height]\n if size_dependencies != @size_dependencies\n # avoid repeating calculations\n calculated_width, calculated_height = @size_dependencies = size_dependencies\n ... | [
"0.69434357",
"0.6867119",
"0.67938316",
"0.6781092",
"0.67696583",
"0.67489994",
"0.6717583",
"0.6717583",
"0.6648408",
"0.66015536",
"0.6585871",
"0.65843314",
"0.6541698",
"0.6528772",
"0.6524483",
"0.6524483",
"0.65104765",
"0.6501702",
"0.647112",
"0.6462353",
"0.6372919... | 0.0 | -1 |
GET /user_has_credibilities/1 GET /user_has_credibilities/1.json | def show
@user_has_credibility = UserHasCredibility.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_has_credibility }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @user_has_credibility = UserHasCredibility.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_has_credibility }\n end\n end",
"def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authori... | [
"0.6223481",
"0.60870856",
"0.5933138",
"0.59306246",
"0.5894325",
"0.5837764",
"0.57843286",
"0.5770996",
"0.5739856",
"0.5728366",
"0.5713899",
"0.5685456",
"0.56693226",
"0.5659763",
"0.56585205",
"0.5654571",
"0.56504744",
"0.56250167",
"0.5578209",
"0.55749905",
"0.55703... | 0.7032469 | 0 |
GET /user_has_credibilities/new GET /user_has_credibilities/new.json | def new
@user_has_credibility = UserHasCredibility.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_has_credibility }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @user_has_credibility = UserHasCredibility.new(params[:user_has_credibility])\n\n respond_to do |format|\n if @user_has_credibility.save\n format.html { redirect_to @user_has_credibility, notice: 'User has credibility was successfully created.' }\n format.json { render json: @... | [
"0.7133942",
"0.6999831",
"0.6863542",
"0.67059505",
"0.6694661",
"0.6680295",
"0.6677642",
"0.6654778",
"0.6624364",
"0.6617908",
"0.6617234",
"0.6611359",
"0.66099423",
"0.66013235",
"0.6596718",
"0.6571054",
"0.6570091",
"0.6567225",
"0.6566883",
"0.65615577",
"0.65592283"... | 0.7861898 | 0 |
POST /user_has_credibilities POST /user_has_credibilities.json | def create
@user_has_credibility = UserHasCredibility.new(params[:user_has_credibility])
respond_to do |format|
if @user_has_credibility.save
format.html { redirect_to @user_has_credibility, notice: 'User has credibility was successfully created.' }
format.json { render json: @user_has_credibility, status: :created, location: @user_has_credibility }
else
format.html { render action: "new" }
format.json { render json: @user_has_credibility.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @user_has_credibility = UserHasCredibility.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_has_credibility }\n end\n end",
"def show\n @user_has_credibility = UserHasCredibility.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.59924906",
"0.5688857",
"0.5553704",
"0.5512104",
"0.5433746",
"0.53875804",
"0.5368355",
"0.53638715",
"0.53446203",
"0.53337383",
"0.5311699",
"0.5309768",
"0.52331126",
"0.5228896",
"0.52288216",
"0.5223308",
"0.51988965",
"0.51988965",
"0.51972026",
"0.5184875",
"0.518... | 0.6380101 | 0 |
PUT /user_has_credibilities/1 PUT /user_has_credibilities/1.json | def update
@user_has_credibility = UserHasCredibility.find(params[:id])
respond_to do |format|
if @user_has_credibility.update_attributes(params[:user_has_credibility])
format.html { redirect_to @user_has_credibility, notice: 'User has credibility was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @user_has_credibility.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_update_credibilty\n params.require.permit(:profile).permit(:credibility)\n end",
"def update\n @user = User.find(params[:id])\n flag = !params[:user][:fellow_flag].nil? ? true :false\n #raise flag.inspect\n respond_to do |format|\n if @user.update_attributes(params[:user])\n ... | [
"0.6101291",
"0.59159863",
"0.58944774",
"0.580295",
"0.57846755",
"0.5777275",
"0.5765004",
"0.5727695",
"0.56748563",
"0.56699616",
"0.5602131",
"0.5591861",
"0.55641794",
"0.5532826",
"0.55146724",
"0.5513859",
"0.5488025",
"0.5479285",
"0.5465876",
"0.54655236",
"0.546112... | 0.6904752 | 0 |
DELETE /user_has_credibilities/1 DELETE /user_has_credibilities/1.json | def destroy
@user_has_credibility = UserHasCredibility.find(params[:id])
@user_has_credibility.destroy
respond_to do |format|
format.html { redirect_to user_has_credibilities_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @user_credit.destroy\n respond_to do |format|\n format.html { redirect_to user_credits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @guidances_user.destroy\n respond_to do |format|\n format.html { redirect_to guidances_users_url }\n forma... | [
"0.67287785",
"0.6713646",
"0.6510049",
"0.6504948",
"0.644461",
"0.6438211",
"0.64254516",
"0.6419053",
"0.64020413",
"0.63998324",
"0.63874954",
"0.63765955",
"0.6363414",
"0.6346915",
"0.6337589",
"0.63333344",
"0.6332866",
"0.632101",
"0.63203657",
"0.6318516",
"0.6307655... | 0.7599205 | 0 |
Build url from host, path and parameters | def build_url(host)
host.protocol + host.url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_url(query_params: nil)\n url = [add_version(''), *@url_path].join('/')\n url = build_query_params(url, query_params) if query_params\n URI.parse(\"#{@host}#{url}\")\n end",
"def build_url(path, params={})\n full_path = @uri.path + path\n full_url = \"#{@uri.scheme}://#{... | [
"0.83554685",
"0.83034885",
"0.8073421",
"0.8073421",
"0.8073421",
"0.78805137",
"0.7744274",
"0.7725429",
"0.76787424",
"0.75864506",
"0.74574924",
"0.74503803",
"0.74241024",
"0.73650897",
"0.7357294",
"0.7336072",
"0.731767",
"0.7288275",
"0.72774494",
"0.7275497",
"0.7257... | 0.8170226 | 2 |
PATCH/PUT organizations/:organization_id/c/:campaign_id/posts/:post_id/reactions/:id PATCH/PUT organizations/:organization_id/c/:campaign_id/posts/:post_id/reactions/:id.json | def update
respond_to do |format|
if reaction_params.present? && @reaction.update(reaction_params)
if @reaction.flagged?
flash.now[:notice] = "Reaction flagged!"
else
flash.now[:warning] = "Reaction unflagged!"
end
format.js { render :update }
else
format.js { render json: @reaction.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_request_review_comment_reactions(repo, id, options = {})\n options = ensure_api_media_type(:reactions, options)\n get \"#{Repository.path repo}/pulls/comments/#{id}/reactions\", options\n end",
"def update\n respond_to do |format|\n if @reaction.update(reaction_params)\n ... | [
"0.557392",
"0.5539047",
"0.54348713",
"0.5362114",
"0.52726245",
"0.5271412",
"0.5270199",
"0.5267256",
"0.52342975",
"0.52342975",
"0.52249473",
"0.52121055",
"0.5209308",
"0.5200979",
"0.51877016",
"0.5185517",
"0.51813155",
"0.51803935",
"0.5175455",
"0.51443607",
"0.5133... | 0.5140772 | 20 |
Never trust parameters from the scary internet, only allow the white list through. | def reaction_params
params.require(:reaction).permit(:flagged)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
It works a lot like Bundler. We provide some core modules by default. This ensures at least the ability to construct a basic environment. Shortcut for a module from GitHub's boxen organization | def github(name, *args)
options ||= if args.last.is_a? Hash
args.last
else
{}
end
if path = options.delete(:path)
mod name, :path => path
else
version = args.first
options[:repo] ||= "boxen/puppet-#{name}"
mod name, version, :github_tarball => options[:repo]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extended_modules; end",
"def bootstrap!\n reset!\n require_relative 'kernel'\n end",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, *args)\n mod name, :path => \"#{ENV['HOME']}/src/boxen/puppet-#{name}\"\nend",
"def dev(name, ... | [
"0.58826554",
"0.5635004",
"0.5609608",
"0.5609608",
"0.5609608",
"0.5609608",
"0.5609608",
"0.5609608",
"0.5609608",
"0.56072927",
"0.56072927",
"0.56072927",
"0.55849236",
"0.55732656",
"0.5523258",
"0.5521057",
"0.5489954",
"0.5489349",
"0.54728574",
"0.54353255",
"0.54338... | 0.0 | -1 |
Shortcut for a module under development | def dev(name, *args)
mod name, :path => "#{ENV['HOME']}/src/boxen/puppet-#{name}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def definition\n \"module #{full_name}\"\n end",
"def dev(name, *args)\n mod \"puppet-#{name}\", :path => \"#{ENV['HOME']}/src/puppet/modules/#{name}\"\nend",
"def deactivated_module\n true\n end",
"def print_module(*) end",
"def developer\n end",
"def extended_modules; end",
"def extended(a_... | [
"0.6761091",
"0.65103877",
"0.64638495",
"0.6364197",
"0.62840474",
"0.62490857",
"0.6217045",
"0.6112087",
"0.6019488",
"0.6011549",
"0.6011549",
"0.6003587",
"0.6003587",
"0.6003587",
"0.5954369",
"0.59472775",
"0.5944601",
"0.589041",
"0.589041",
"0.589041",
"0.589041",
... | 0.6209157 | 11 |
def can_show_comments?(question) admin? || meeting_manager? || item.users.include?(User.current) end def can_create_comments?(question) meeting_manager? || item.users.include?(User.current) end | def can_show_protocol?(protocol)
admin? || (meeting_manager? && (author?(protocol) || member?(protocol) || approver?(protocol) || watcher?(protocol) || asserter?(protocol)))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_see_comment?(comment); comment.user.admin?; end",
"def comments?\n !!user && user.admin?\n end",
"def allow_comment?(user) \n # for now, we allow everyone\n return true \n end",
"def comments_admin?\n admin?\n end",
"def can_create_comment?(post); true; end",
"def allows_comment?(a_p... | [
"0.7927884",
"0.7874287",
"0.7647349",
"0.7627877",
"0.7262564",
"0.71954036",
"0.71951187",
"0.7154983",
"0.7035278",
"0.7020229",
"0.7010864",
"0.6969873",
"0.6947203",
"0.6907053",
"0.6786356",
"0.67852885",
"0.6761332",
"0.6743624",
"0.66353583",
"0.66217476",
"0.6560325"... | 0.0 | -1 |
An array for optional fields | def optionals
%w[
participant
token
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _optional\n @optional & [*@opts[:extra_fields]].map(&:to_sym)\n end",
"def required_fields\n []\n end",
"def optional(*fields)\n self._optional_fields = fields\n end",
"def list_optional\n @optional ||= []\n end",
"def optional_fields(value = nil)\n config(:optional_f... | [
"0.7634312",
"0.7435686",
"0.73922294",
"0.7151104",
"0.7137127",
"0.6849599",
"0.6849599",
"0.6718591",
"0.66455024",
"0.65724224",
"0.6560664",
"0.6514089",
"0.6514089",
"0.65052354",
"0.65002245",
"0.6497793",
"0.6466",
"0.6465347",
"0.64178264",
"0.6403578",
"0.6347347",
... | 0.0 | -1 |
An array for nullable fields | def nullables
[]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_with_nils\n to_a\n end",
"def nullable\n self['nullable']\n end",
"def null_controlled_fields!(attrs)\n ::ScoobySnacks::METADATA_SCHEMA.controlled_field_names.each do |field_name|\n # do not null fields that are not being changed\n next unless attrs.keys.include?(\"#{field_... | [
"0.6697973",
"0.666948",
"0.65385157",
"0.6450971",
"0.6424679",
"0.6424679",
"0.63460094",
"0.6257392",
"0.6225403",
"0.6219842",
"0.6148053",
"0.60957277",
"0.6021685",
"0.60198313",
"0.60173994",
"0.59935284",
"0.59411293",
"0.59411293",
"0.59411293",
"0.5940643",
"0.59229... | 0.8074736 | 7 |
now generate_cytoscape_data can create graphs with publications, studies and awards | def generate_cytoscape_data(investigator, max_depth, include_publications, include_awards, include_studies, depth=0, node_array=[], edge_array=[])
node_array = handle_investigator_nodes(investigator, max_depth, include_publications, include_awards, include_studies, depth, node_array )
edge_array = handle_investigator_edges(investigator, max_depth, include_publications, include_awards, include_studies, node_array, edge_array)
{
:nodes => node_array,
:edges => edge_array
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_cytoscape_publication_nodes(investigator, max_depth, node_array=[], depth=0, add_intermediate_nodes=false)\n # nodes: [ { id: \"n1\", label: \"Node 1\", score: 1.0 },\n # { id: \"n2\", label: \"Node 2\", score: 2.2 },\n # { id: \"n3\", label: \"Node 3\", sc... | [
"0.634246",
"0.60262036",
"0.56915283",
"0.5598914",
"0.543725",
"0.5380612",
"0.5361769",
"0.52967256",
"0.5280504",
"0.5271136",
"0.52452964",
"0.51900893",
"0.51785934",
"0.51493365",
"0.50947374",
"0.5088229",
"0.5073581",
"0.5069803",
"0.50678474",
"0.5053408",
"0.503665... | 0.78558236 | 0 |
GET /tasks GET /tasks.json | def index
params.permit(:day)
if params[:day] then
@tasks = current_user.tasks.where(day: [nil, Date.parse(params[:day])])
else
@tasks = current_user.tasks
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tasks\n uri = URI(BASE_URL + TASKS_ENDPOINT)\n\n make_request(uri)\n end",
"def tasks\n @todos = Todo.all\n render json: @todos\n end",
"def index\n render json: {\n tasks: tasks.map(&:to_hash)\n }\n end",
"def index\n @tasks = Task.all\n\n render json: @tasks\n end",
"... | [
"0.7889766",
"0.77525216",
"0.76207197",
"0.75984627",
"0.75941116",
"0.75040185",
"0.74664825",
"0.74333096",
"0.73828924",
"0.7343939",
"0.73216754",
"0.73216754",
"0.73216754",
"0.73042434",
"0.7262646",
"0.72469246",
"0.72427016",
"0.72333676",
"0.716545",
"0.7160594",
"0... | 0.0 | -1 |
GET /tasks/1 GET /tasks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @task = Task.find(params[:id])\n\n render json: @task\n end",
"def task(name)\n get \"#{base_url}/tasks/#{name}\"\n end",
"def show\n render :json => Project.find(params[:project_id]).tasks.find(params[:id])\n end",
"def show\n \n @task = @project.tasks.find(params[:i... | [
"0.76098794",
"0.7556112",
"0.745625",
"0.7447727",
"0.7346079",
"0.73356533",
"0.7332821",
"0.72567064",
"0.72433645",
"0.7227382",
"0.72081524",
"0.7204091",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",
"0.7203856",... | 0.0 | -1 |
POST /tasks POST /tasks.json | def create
# This prevents
@task = current_user.tasks.build(task_params)
respond_to do |format|
if @task.save
format.html { redirect_to @task, notice: 'Task was successfully created.' }
format.json { render action: 'show', status: :created, location: @task }
else
format.html { render action: 'new' }
format.json { render json: @task.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end",
"def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, status: :created\n else\n render json: @task.errors, status: :unprocessable_entit... | [
"0.7529737",
"0.74976224",
"0.7411092",
"0.7389878",
"0.7261207",
"0.72587913",
"0.7183996",
"0.7147952",
"0.71120256",
"0.70759165",
"0.70639485",
"0.70576006",
"0.70560944",
"0.70294535",
"0.7016957",
"0.7012058",
"0.70110804",
"0.7009976",
"0.6993863",
"0.69896185",
"0.698... | 0.65713674 | 91 |
PATCH/PUT /tasks/1 PATCH/PUT /tasks/1.json | def update
respond_to do |format|
if @task.update(task_params)
format.html { redirect_to @task, notice: 'Task was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @task.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end",
"def update\n task = Task.find(params[:id])\n if task.update(t... | [
"0.7445893",
"0.7291994",
"0.7264724",
"0.7264724",
"0.7139033",
"0.70768815",
"0.70251286",
"0.69656086",
"0.69626784",
"0.69530314",
"0.69110453",
"0.69073725",
"0.69073725",
"0.69073725",
"0.6897303",
"0.6897303",
"0.6897303",
"0.6897303",
"0.6897303",
"0.6897303",
"0.6897... | 0.6760706 | 41 |
DELETE /tasks/1 DELETE /tasks/1.json | def destroy
@task.destroy
respond_to do |format|
format.html { redirect_to tasks_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_task id\n request :delete, \"tasks/#{id}\"\n nil\n end",
"def delete_task\n @task = Task.find_by(id: params[:id])\n @task.destroy\n render :json => @task.as_json(:only => [:id])\n end",
"def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\n respond_to do |f... | [
"0.78329164",
"0.75888187",
"0.756588",
"0.7565148",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7531433",
"0.7440601",
"0.73988724",
"0.7384872",
"0.7368785",
... | 0.7490252 | 21 |
Return a hash of task hashes keyed by :id | def format_tasks(tasks)
result = {}
tasks.each do |t|
# logger.info t.inspect
obj = {}
[:id, :title, :description, :duration, :start, :priority, :day].each do |i|
obj[i] = t[i]
end
result[t.id] = obj
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [task_id, title, category_id, due_date, completed_date_utc, publicly_visible, completed, project_id, opportunity_id, milestone_id, pipeline_id, stage_id, details, status, priority, percent_complete, start_date, assigned_by_user_id, parent_task_id, owner_visible, responsible_user_id, assigned_team_i... | [
"0.7370199",
"0.7148031",
"0.7017469",
"0.67617434",
"0.66786665",
"0.66562253",
"0.6636615",
"0.66246414",
"0.66121477",
"0.65823144",
"0.64873946",
"0.6445161",
"0.64268064",
"0.63602394",
"0.6351611",
"0.6351611",
"0.63349265",
"0.62515616",
"0.6248527",
"0.6211306",
"0.62... | 0.6816809 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_task
@task = current_user.tasks.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def task_params
params.require(:task).permit(:title, :description, :duration, :start, :priority, :day)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
define simple fibonacci method | def fibonacci( n )
return n if ( 0..1 ).include? n
( fibonacci( n - 1 ) + fibonacci( n - 2 ) )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci(n)\n \nend",
"def fibonacci(n)\n \nend",
"def fibonacci(num)\n # Enter code here\nend",
"def fib(n)\n \nend",
"def fibonacci(n)\n # your code here :)\nend",
"def fibs(n)\nend",
"def fib(n)\n # your work here\nend",
"def fib(n)\n\nend",
"def fib(n)\nend",
"def fib(n)\nend",
... | [
"0.8650295",
"0.8641343",
"0.8569424",
"0.8524582",
"0.84693784",
"0.8455377",
"0.84456336",
"0.8438841",
"0.8425106",
"0.8425106",
"0.819867",
"0.8129878",
"0.8129878",
"0.8129878",
"0.8129878",
"0.8129878",
"0.8020002",
"0.7989073",
"0.79753774",
"0.7958741",
"0.79571253",
... | 0.0 | -1 |
puts fibonacci( 10 ) define fibonacci method outputting array | def fib(n)
n.times.each_with_object([0,1]) { |num, obj| obj << obj[-2] + obj[-1] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fibonacci (integer)\n\tfib_arr = [0, 1]\n\t(integer-2).times do |index|\n\t\tresult = fib_arr[index+1] + fib_arr[index]\n\t\tfib_arr << result\n\tend\n\t\np fib_arr\nend",
"def fibonacci( n )\r\n fib_nums = []\r\n return n if n <= 1\r\n fib_nums << fibonacci( n - 1 )\r\n fib_nums << fibonacci( ... | [
"0.8449519",
"0.84418267",
"0.80959547",
"0.8072466",
"0.80026966",
"0.80026966",
"0.798813",
"0.7980726",
"0.79630274",
"0.7941169",
"0.794073",
"0.7937409",
"0.79291415",
"0.7927477",
"0.7924488",
"0.7908526",
"0.7899388",
"0.78474665",
"0.7845177",
"0.7838783",
"0.78368115... | 0.0 | -1 |
Logs out the current user | def log_out
session.delete(:user_id)
@current_user = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_out\n reset_session\n @current_user = nil\n end",
"def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend",
"def log_ou... | [
"0.88226247",
"0.87969023",
"0.87865835",
"0.87865835",
"0.87865835",
"0.87865835",
"0.8786293",
"0.8759179",
"0.8759179",
"0.8759179",
"0.8759179",
"0.8759179",
"0.8694265",
"0.86914647",
"0.86914647",
"0.86914647",
"0.86914647",
"0.86914647",
"0.8691377",
"0.8687488",
"0.86... | 0.8679721 | 46 |
Returns true if given user is current user | def current_user?(user)
user == current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_current_user(user)\n if user == current_user\n return true\n else\n return false\n end\n end",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def current_user?(user)\n\t\tuser == current_user\n\tend",
"def ... | [
"0.9020946",
"0.895383",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.8953723",
"0.89508694",
"0.89429593",
"0.89429593",
"0.89429593",
"0.89429593",
"0.89429593",
"0.89429593",
"0.89429593",
"0.893802... | 0.0 | -1 |
Returns the current loggedin user, and nil if no loggedin user | def current_user
# find_by only executes when current user hasn't been assigned yet
@current_user ||= User.find_by(id: session[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user\n if session[:user_id]\n User.find(session[:user_id])\n else\n nil\n end\n end",
"def current_user\n if session[:user_id]\n return User.find(session[:id])\n else\n return nil\n end\n end",
"def get_logged_in_user\n if logged_in?\n use... | [
"0.8735304",
"0.87316793",
"0.86566776",
"0.8652054",
"0.8644394",
"0.86136293",
"0.85734594",
"0.8503139",
"0.8503139",
"0.8503139",
"0.8503139",
"0.84972703",
"0.84843516",
"0.8481306",
"0.845889",
"0.84555656",
"0.84508663",
"0.8442001",
"0.8439782",
"0.8439782",
"0.842838... | 0.0 | -1 |
Returns true if the user is logged in, false otherwise Useful for code to show one set of links if the user is logged in and another set of links otherwise, e.g. Links for logged in users Links for nonlogged in users | def logged_in?
!current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logged_in?\n !!link_to_account_detail_page\n end",
"def logged_in?\n (current_user ? login_access : false).is_a?(User)\n end",
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def authenticated_via_link\n self.is_... | [
"0.78850305",
"0.7096658",
"0.7017646",
"0.7017366",
"0.7015413",
"0.7010412",
"0.6951448",
"0.69171244",
"0.6888738",
"0.68822724",
"0.68822724",
"0.68606883",
"0.68605673",
"0.68454546",
"0.68454546",
"0.68448776",
"0.6839194",
"0.683882",
"0.68300277",
"0.6824763",
"0.6799... | 0.0 | -1 |
Redirect to stored location/default | def redirect_back_or(default)
redirect_to(session[:forwarding_url] || default)
session.delete(:forwarding_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end",
"def redirect_ba... | [
"0.8130047",
"0.8112981",
"0.7761019",
"0.7746305",
"0.7455699",
"0.74192303",
"0.74058145",
"0.7322095",
"0.73136765",
"0.72074485",
"0.71907663",
"0.7162672",
"0.7160986",
"0.71553236",
"0.7127611",
"0.7116524",
"0.71057606",
"0.71041554",
"0.7094155",
"0.7092892",
"0.70874... | 0.0 | -1 |
Store URL attempting to be accessed | def store_location
session[:forwarding_url] = request.original_url if request.get?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n raise\n end",
"def url=(_); end",
"def store_location\n # store last url as long as it isn't a /users path\n\tsession[:previous_url] = request.fullpath unless request.fullpath =~ /\\/users/ or request.fullpath =~ /\\/json/ or request.fullpath =~ /\\/static/\n\t\n end",
"def url_server\n... | [
"0.693685",
"0.6773465",
"0.6702153",
"0.6696309",
"0.6635697",
"0.65976083",
"0.65976083",
"0.65976083",
"0.65976083",
"0.65976083",
"0.65976083",
"0.65701294",
"0.65051746",
"0.64877826",
"0.6487276",
"0.6480889",
"0.64764243",
"0.64751065",
"0.6450071",
"0.64487547",
"0.64... | 0.0 | -1 |
Checks that the user is a manager or admin | def check_manager_or_admin
unless current_user && (current_user.privilege_manager? || current_user.privilege_admin?)
flash[:danger] = "You do not have permission to perform this operation"
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_manager?\n user_type == \"manager\"\n end",
"def manager?\n return ( self.user_type == User::USER_TYPE_MANAGER or self.user_type == User::USER_TYPE_ADMIN )\n end",
"def is_admin?\n role == \"manager\"\n end",
"def is_manager\n return current_user.role == User::MANAGER\n end",... | [
"0.82470006",
"0.82312965",
"0.81924105",
"0.79915303",
"0.7805755",
"0.77738863",
"0.7690699",
"0.76676637",
"0.76484495",
"0.76408905",
"0.7591522",
"0.7584636",
"0.75744116",
"0.7568256",
"0.75608844",
"0.75579065",
"0.7556297",
"0.7552213",
"0.75371224",
"0.74900836",
"0.... | 0.80682564 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.