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 |
|---|---|---|---|---|---|---|
Merge the local results into the ancestor result hash. | def render!
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merged_result; end",
"def merged_result\n # conceptually this is just doing `merge_results(resultset_path)`\n # it's more involved to make syre `synchronize_resultset` is only used around reading\n resultset_hash = read_resultset\n command_names, coverage = merge_valid_results(res... | [
"0.67083436",
"0.6518971",
"0.62164724",
"0.62161964",
"0.6183703",
"0.6104718",
"0.60974944",
"0.60974944",
"0.609749",
"0.6073796",
"0.60690373",
"0.605404",
"0.60513556",
"0.6041792",
"0.6041792",
"0.6041792",
"0.5952141",
"0.58916056",
"0.58490264",
"0.5814436",
"0.581148... | 0.0 | -1 |
Return the jsonencoded result hash. | def to_json
MultiJson.encode(result)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n\n json = {\n :errorCode => @server_id,\n :transactionReceipt => @api_key\n }\n\n if @message_results.length > 0\n e = Array.new\n @message_results.each do |value|\n e.push(value.to_hash)\n ... | [
"0.71402216",
"0.70310307",
"0.7001798",
"0.69816375",
"0.6981057",
"0.6981057",
"0.69720805",
"0.69235444",
"0.6844965",
"0.6837753",
"0.6802685",
"0.6796259",
"0.6784472",
"0.6756732",
"0.6756398",
"0.67051995",
"0.66957545",
"0.6682542",
"0.6680088",
"0.6658828",
"0.662246... | 0.0 | -1 |
Add attributes to the result hash in a variety of ways | def attributes(*args, &block)
if current_object.nil?
raise(ArgumentError, "You cannot use #attributes when inferred object is not present.")
end
args.each do |arg|
if arg.is_a?(Hash)
merge_result!(arg.keys.first, current_object.send(arg.values.first))
else
merge_result!(arg, current_object.send(arg))
end
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_attributes(attr_hash)\n return unless attr_hash\n attr_hash.each_pair{ |k,v| self.add_attribute(k, v) }\n end",
"def add_attrs! attrs\n raise \"InvalidAttributesFormat\" unless attrs.is_a?(Hash)\n self.attributes.merge!attrs\n end",
"def add_student_attributes(attributes_hash)... | [
"0.6698538",
"0.6583141",
"0.646759",
"0.6326051",
"0.63176715",
"0.62962383",
"0.6254876",
"0.6244898",
"0.62373084",
"0.6173945",
"0.6171681",
"0.6171439",
"0.61409885",
"0.61389065",
"0.61293733",
"0.6116245",
"0.6096952",
"0.6071564",
"0.6053079",
"0.6048596",
"0.60350424... | 0.0 | -1 |
Merges values into the "local" result hash. | def merge_result!(key, val)
if key
result[key] = massage_value(val)
else
result.merge!(massage_value(val))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(other_hash); end",
"def merge!(*other_hashes, &blk); end",
"def merged_result; end",
"def hash_merger(query_vals)#another hash that is nested)\n merged_hash = Hash.new\n # for each key_val_set\n # check if ... | [
"0.6855965",
"0.6855965",
"0.6855965",
"0.6712077",
"0.65920377",
"0.6506063",
"0.64907116",
"0.6488673",
"0.6447995",
"0.6431979",
"0.637143",
"0.6289147",
"0.62711084",
"0.6247436",
"0.6230498",
"0.6217351",
"0.62100965",
"0.6153013",
"0.61451745",
"0.6130036",
"0.6099848",... | 0.6741713 | 3 |
put any specializations in here | def massage_value(val)
if block = Bldr.handlers[val.class]
return block.call(val)
else
val
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def specializations\n @specializations ||= Specialization.from_models(self, @models)\n end",
"def spec_type(desc, *additional); end",
"def register_spec_type(*args, &block); end",
"def extensions_for(template_class); end",
"def extensions_for(template_class); end",
"def types(types); end",
"def... | [
"0.61253786",
"0.60208654",
"0.5963748",
"0.59382904",
"0.59382904",
"0.59060836",
"0.57499653",
"0.55216056",
"0.550007",
"0.54944545",
"0.54944545",
"0.54944545",
"0.54944545",
"0.5388674",
"0.5388674",
"0.537798",
"0.5338946",
"0.53368664",
"0.5322478",
"0.5298045",
"0.529... | 0.0 | -1 |
String representation of the grammatical category. | def to_s
"Grammatical category: #{self.tag} - '#{self.name}'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_string\n categories.pluck(:name).flatten.compact.uniq.join(', ')\n end",
"def category\n return '' if self.categories.empty?\n self.categories.join(', ')\n end",
"def categories_as_string\n categories.map(&:title).sort.join(', ')\n\n end",
"def cate... | [
"0.7226081",
"0.69705087",
"0.68056196",
"0.67046916",
"0.6691956",
"0.6684867",
"0.6640186",
"0.6604781",
"0.6555169",
"0.6547275",
"0.6545283",
"0.64379144",
"0.63994837",
"0.6389162",
"0.63754874",
"0.6367628",
"0.6335599",
"0.6310271",
"0.6302742",
"0.6287388",
"0.6244091... | 0.8598717 | 0 |
Returns a symbol representation of the category. | def to_sym
self.tag
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n return self.symbol\n end",
"def to_s \n self.symbol\n end",
"def to_s\n \"#{symbol}\"\n end",
"def category_label\n Categories::LABELS[category]\n end",
"def to_s\n \"Grammatical category: #{self.tag} - '#{self.name}'\"\n end",
"def category_name\n ... | [
"0.6498329",
"0.6364069",
"0.6353104",
"0.62913716",
"0.6284162",
"0.6265759",
"0.6264143",
"0.6169924",
"0.5931704",
"0.593073",
"0.59150445",
"0.5910688",
"0.59010756",
"0.5880927",
"0.58337337",
"0.58181757",
"0.5805329",
"0.57892",
"0.5781974",
"0.5767561",
"0.5740013",
... | 0.5877217 | 14 |
============================================================================== bench methods ============================================================================== note : pre db.clear and post db.close are included. | def rufus_cabinet_bench (bench_title, db)
db.clear
2.times { puts }
puts bench_title
Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
b.report('inserting one') do
db['a'] = 'A'
end
b.report('inserting N') do
N.times { |i| db["key #{i}"] = "value #{i}" }
end
b.report('finding all keys') do
db.keys
end
unless db.class.name.match(/^Rufus::Edo::/)
b.report('finding all keys (native)') do
db.keys(:native => true).free
end
end
b.report('finding all keys (pref)') do
db.keys(:prefix => 'key ')
end
b.report('finding all keys (r pref)') do
db.keys.select { |k| k[0, 4] == 'key ' }
end
b.report('finding all') do
db.values
end
b.report('iterate all') do
db.each { |k, v| }
end
b.report('find first') do
db["key #{0}"]
end
b.report('delete first') do
db.delete("key #{0}")
end
txt = 'delete_keys_with_prefix "1"'
txt += ' (M)' if db.class.name == 'Rufus::Edo::Cabinet'
b.report(txt) do
db.delete_keys_with_prefix('key 1')
end
b.report('del keys with prefix "2" (m)') do
ks = db.keys(:prefix => 'key 2')
ks.each { |k| db.delete(k) }
end
end
db.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flushdb; end",
"def teardown\n @db.close\n super\n end",
"def close_database\n @database = nil\n @writable_database = nil\n GC.start\n end",
"def close_database\n @database = nil\n @writable_database = nil\n GC.start\n end",
"def fl... | [
"0.7380121",
"0.6886238",
"0.6855445",
"0.6855445",
"0.68533057",
"0.6840378",
"0.6751368",
"0.66847813",
"0.6566881",
"0.65323424",
"0.64841413",
"0.641949",
"0.6387517",
"0.63486296",
"0.63454753",
"0.63007295",
"0.63007295",
"0.62566835",
"0.6255936",
"0.62432283",
"0.6238... | 0.5651084 | 68 |
Tokyo Cabinet tables only do strings = memcache === tiny test for memcache_client gem note : space is an illegal char in keys here ! | def limited_bench (bench_title, db)
2.times { puts }
puts bench_title
Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
b.report('inserting one') do
db['a'] = 'A'
end
b.report('inserting N') do
N.times { |i| db["key#{i}"] = "value #{i}" }
end
b.report('find first') do
db["key#{0}"]
end
b.report('delete first') do
db.delete("key#{0}")
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_store_type\n \"memcache\"\n end",
"def get_memcache_key_object\n MemcacheKey.new('aml.all_aml_match')\n end",
"def cached?(key)\n not @memcache.get(key).nil?\n end",
"def get_memcache_key_object\n MemcacheKey.new('aml.aml_search')\n end",
"def short_name\n '... | [
"0.65002775",
"0.60814196",
"0.5852536",
"0.5838486",
"0.57218456",
"0.5676869",
"0.5647209",
"0.562902",
"0.56267077",
"0.5591895",
"0.5556496",
"0.55473286",
"0.5407236",
"0.5391554",
"0.53385764",
"0.533775",
"0.53327465",
"0.52898294",
"0.52898294",
"0.5282626",
"0.524738... | 0.0 | -1 |
note : pre db.clear and post db.close are included. | def rufus_table_bench (bench_title, db)
2.times { puts }
puts bench_title
Benchmark.benchmark(' ' * 31 + Benchmark::Tms::CAPTION, 31) do |b|
db.clear
db.clear
db.set_index('name', :lexical)
b.report('inserting data (index set)') do
DATA1.each_with_index { |e, i| db["key #{i.to_s}"] = e }
end
db.clear
db.set_index('name', :remove)
b.report('inserting data (no index)') do
DATA1.each_with_index { |e, i| db["key #{i.to_s}"] = e }
end
b.report('finding all keys') do
db.keys
end
b.report('finding all keys (pref)') do
db.keys(:prefix => 'key ')
end
b.report('finding all keys (r pref)') do
db.keys.select { |k| k[0, 4] == 'key ' }
end
b.report('finding all') do
db.query { |q| }
end
b.report('find last') do
db["key #{DATA.size.to_s}"]
end
b.report('delete last') do
db.delete("key #{DATA.size.to_s}")
end
b.report('find Alphonse') do
db.query { |q| q.add('name', :equals, DATA1[0]['name']) }
end
b.report("setting index (#{DATA.size} rows)") do
db.set_index('name', :lexical)
end
b.report('find Alphonse (index set)') do
db.query { |q| q.add('name', :equals, DATA1[0]['name']) }
end
b.report('delete_keys_with_prefix "1"') do
db.delete_keys_with_prefix('key 1')
end
#b.report('del keys with prefix "2" (m)') do
# ks = db.keys(:prefix => 'key 2')
# ks.each { |k| db.delete(k) }
#end
end
db.close
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flushdb; end",
"def close()\n @db.close()\n end",
"def close\n db.close\n end",
"def teardown\n @db.close\n super\n end",
"def close\n @db.close\n end",
"def flushdb\n end",
"def close_database\n @database = nil\n @writable_database = ni... | [
"0.8017672",
"0.8003482",
"0.7964477",
"0.79576695",
"0.79547226",
"0.7762445",
"0.7713137",
"0.7713137",
"0.7583649",
"0.75371397",
"0.7520301",
"0.7483301",
"0.7483301",
"0.7478101",
"0.7447181",
"0.7447181",
"0.73035866",
"0.7292043",
"0.72798586",
"0.7228022",
"0.72170347... | 0.0 | -1 |
Get all of the parts for a given type TODO Have this return an enumerable of parts so we can fitler by parttype. We can filter this by type from whatever is calling it if we blow open some new types... | def parts(type)
xml.xpath("//xmlns:Override[@ContentType='#{type}']").map{ |n| n['PartName'] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parts(user_id = nil)\n part_elements = []\n if is_a_node?\n if user_id\n part_elements = Element.part_elements_for_element_id_by_user_id(self.id, user_id)\n else\n part_elements = Element.part_elements_for_element_id(self.id)\n end\n end\n return part_elements\n end",
... | [
"0.59806436",
"0.5977293",
"0.57885796",
"0.5783526",
"0.5768775",
"0.5576938",
"0.5576938",
"0.55630565",
"0.55246824",
"0.55246824",
"0.55246824",
"0.55094117",
"0.54108685",
"0.53605956",
"0.5333895",
"0.5328548",
"0.52733123",
"0.52691305",
"0.5267567",
"0.525953",
"0.523... | 0.64470756 | 0 |
Append a part to ContentTypes | def append(part)
# Don't write the part again if it already exists ya dummy
return nil if exists? part
edit_xml do |xml|
xml.at_xpath('/xmlns:Types').tap do |types|
types << Nokogiri::XML::Node.new("Override", xml).tap do |n|
n['PartName'] = part.path
n['ContentType'] = part.class::CONTENT_TYPE
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_content_type(extension, type); end",
"def << part\n @parts << part\n end",
"def add_part(part)\n @parts ||= Array.new\n @parts << part\n end",
"def <<(content)\n @parts << content\n end",
"def << part\n case part\n when RDoc::Markup::Document then\n unless ... | [
"0.68168235",
"0.67053103",
"0.66667956",
"0.647054",
"0.6213678",
"0.60317475",
"0.6005277",
"0.59842056",
"0.59021443",
"0.5891802",
"0.57783264",
"0.57701594",
"0.57565355",
"0.5729698",
"0.5664052",
"0.55524606",
"0.5550688",
"0.5471156",
"0.5471156",
"0.5463317",
"0.5460... | 0.780444 | 0 |
Test if the part already exists so we don't write it multiple times. | def exists?(part)
!! xml.at_xpath("//xmlns:Override[@ContentType='#{part.class::CONTENT_TYPE}' and @PartName='#{part.path}']")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate_part(part)\n duplicate = part.dup\n duplicate.add_content_id(part.content_id) unless part.content_id.nil?\n duplicate\n end",
"def already_stored?\n !file_uniqueness\n end",
"def add_if_not_exists()\n\tif record_exists()\n\t\tprintf(\"EXISTS %s\\n\",self.digest)\... | [
"0.63035345",
"0.6251102",
"0.61025524",
"0.6090519",
"0.6068634",
"0.6061846",
"0.60607815",
"0.60209554",
"0.59828377",
"0.59471416",
"0.59217346",
"0.5902865",
"0.59002686",
"0.58318543",
"0.58318543",
"0.58080286",
"0.58072037",
"0.58004963",
"0.57955277",
"0.5778076",
"0... | 0.0 | -1 |
GET /account/new GET /account/new.xml | def new
@account = Account.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @job }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\n end\n end",
"def new\n @account = Account.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @account }\... | [
"0.78234375",
"0.78234375",
"0.78234375",
"0.7822262",
"0.7814345",
"0.78114384",
"0.7665048",
"0.76641136",
"0.76237977",
"0.7428634",
"0.7207884",
"0.71446705",
"0.70970106",
"0.70845264",
"0.708054",
"0.708054",
"0.708054",
"0.708054",
"0.708054",
"0.7073275",
"0.701499",
... | 0.7152347 | 11 |
This prints the board | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_board\n\t\tputs \"**********************************\"\n\t\tputs \"| ♔ ♚ ♕ ♛ ♖ ♜ ♗ ♝ ♘ ♞ ♙ ♟ |\"\n\t\tputs \"| Actual board |\"\n\t\tputs \"| ♔ ♚ ♕ ♛ ♖ ♜ ♗ ♝ ♘ ♞ ♙ ♟ |\"\n\t\tputs \"**********************************\"\n\t\t@board.each_index do |i|\n\t\t\t@board[i].each_in... | [
"0.912189",
"0.88865775",
"0.8880699",
"0.8822096",
"0.8814379",
"0.87795323",
"0.8720118",
"0.87068605",
"0.87050074",
"0.86798745",
"0.8672375",
"0.86657983",
"0.8656733",
"0.8652426",
"0.86493194",
"0.8633315",
"0.86251116",
"0.8625003",
"0.86223125",
"0.8611828",
"0.86094... | 0.0 | -1 |
Checks if position is already taken | def position_taken?(board, position)
!(board[position] == "" || board[position] == " " || board[position] == nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(index)\n @board[index] == \"X\" || @board[index] == \"O\"\n end",
"def position_taken?\nend",
"def position_taken?(index)\n ((@board[index] == \"X\") || (@board[index] == \"O\"))\n end",
"def position_taken?(position)\n @board[position] != \" \"\n end",
"def position_t... | [
"0.7555294",
"0.7524301",
"0.75096864",
"0.74630916",
"0.7401194",
"0.7384155",
"0.7382516",
"0.7340435",
"0.733096",
"0.733096",
"0.73286694",
"0.73074114",
"0.7291124",
"0.7287067",
"0.72860986",
"0.72836024",
"0.7267499",
"0.72665644",
"0.7241557",
"0.72345066",
"0.720437"... | 0.0 | -1 |
checks if move is valid | def valid_move?(board, position)
position = (position.to_i - 1)
if position.between?(0, 8) && !position_taken?(board, position)
true
else false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_move_valid(move)\n @moves.include? move\n end",
"def valid_move?(move)\n\t\tif in_bounds?(move) && empty_space?(move) && any_converted_pieces?(move)\n\t\t\treturn true\n\t\telse \n\t\t\treturn false\n\t\tend \n\tend",
"def valid_move?(move)\n move.to_i.between?(1,9) && !taken?(move)\n end",
"... | [
"0.84806347",
"0.83525056",
"0.83269006",
"0.8323307",
"0.83062106",
"0.82856065",
"0.8222756",
"0.8198662",
"0.81965184",
"0.81256986",
"0.8086587",
"0.8070863",
"0.80679417",
"0.80097437",
"0.7989664",
"0.79601264",
"0.7947462",
"0.79464006",
"0.7921848",
"0.7902719",
"0.79... | 0.7558249 | 88 |
defines a turn. asks user for input and loops if invalid. | def turn(board)
puts "Please enter 1-9:"
position = gets.strip()
valid = false
while valid == false
if valid_move?(board, position)
move(board, position, current_player(board))
valid = true
else
puts "Invalid Move. Please enter 1-9:"
position = gets.strip()
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn\n while true\n puts \"Please enter 1-9:\"\n answer = gets.chomp\n if(valid_move?(answer))\n move(answer)\n display_board\n return\n end\n end\n end",
"def take_turn\n puts \"#{player.name}'s turn. Enter 0-9:\"\n input = gets.strip\n if board.va... | [
"0.7670551",
"0.7667789",
"0.7618827",
"0.75318205",
"0.75185335",
"0.7506626",
"0.7491193",
"0.74801195",
"0.7477733",
"0.7466927",
"0.74490637",
"0.7443907",
"0.7439268",
"0.7423114",
"0.73930234",
"0.73921907",
"0.73921907",
"0.73790777",
"0.73764664",
"0.7375603",
"0.7371... | 0.69738567 | 80 |
Counts the number of turns that have been played | def turn_count(board)
turn_counter = 0
board.each do |turn|
if turn == "X" || turn == "O"
turn_counter += 1
end
end
turn_counter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count\n turns_played = 0\n @board.each do |index|\n if index != \" \"\n turns_played += 1\n end\n end\n return turns_played\n end",
"def turn_count\n count = 0\n @board.each do |player|\n if player == 'X' || player == 'O'\n count += 1\n end\n end\... | [
"0.8064959",
"0.79076695",
"0.7888602",
"0.78305924",
"0.7827466",
"0.78259647",
"0.7804267",
"0.78042066",
"0.7801203",
"0.7786617",
"0.77736056",
"0.7733551",
"0.7703273",
"0.766613",
"0.76647145",
"0.7597591",
"0.7593198",
"0.7592888",
"0.75802505",
"0.75784916",
"0.757778... | 0.7062202 | 67 |
Uses the turn_count method to determine if it is "X" or "O" turn. | def current_player(board)
turn_count(board) % 2 == 0 ? "X" : "O"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_count\n @board.count{|token| token == \"X\" || token == \"O\"}\n end",
"def turn_count #counts occupied positions!\n turn = 0 #start at position 0.\n @board.each do |index| #iterating through each spot on the board. Is it occupied?\n if index == \"X\" || index == \"O\" #if there is an X or ... | [
"0.79763603",
"0.79566556",
"0.79362917",
"0.7906085",
"0.790215",
"0.7877868",
"0.7849504",
"0.78430694",
"0.7822989",
"0.77852035",
"0.7778221",
"0.7773456",
"0.7757436",
"0.77327853",
"0.7729393",
"0.7728167",
"0.7725383",
"0.7718589",
"0.77140474",
"0.77095824",
"0.770033... | 0.0 | -1 |
begining of game status checks for win combinations and prints winning combo, or nil | def won?(board)
WIN_COMBINATIONS.each do |combo|
if (board[combo[0]] == board[combo[1]] && board[combo[0]] == board[combo[2]] && board[combo[0]] != " " && board[combo[0]] != "" && !board[combo[0]].nil?)
return combo
break
end
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_game_status\n # create all winning combinations in a variable using an array\n winning_combos = [[@board[0],@board[1],@board[2]], [@board[3],@board[4],@board[5]], [@board[6],@board[7],@board[8]], [@board[0],@board[3],@board[6]], [@board[1],@board[4],@board[7]], [@board[2],@board[5],@board[8]], [@bo... | [
"0.7708189",
"0.7102432",
"0.7102285",
"0.7071653",
"0.7049752",
"0.7016944",
"0.70160806",
"0.701148",
"0.69719565",
"0.6945492",
"0.6941701",
"0.69380283",
"0.6912952",
"0.6906618",
"0.69010764",
"0.6891594",
"0.6879269",
"0.68765354",
"0.68699837",
"0.686527",
"0.68458503"... | 0.0 | -1 |
returns true if every element of the board is full | def full?(board)
if !(won?(board))
board.each do |e|
if (e != "X" && e != "O")
return false
end
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isBoardFull()\n #\n # TO DO: add your code below\n #\n for i in 0...@size\n for j in 0...@size\n if (@board[i][j]==EMPTY)\n return false\n end\n end\n end\n\n # DO NOT DELETE THE LINE BELOW\n\t\treturn true;\n\tend... | [
"0.8843037",
"0.88111204",
"0.8728713",
"0.8623876",
"0.858383",
"0.85729814",
"0.8564752",
"0.856049",
"0.85387486",
"0.85120463",
"0.85120463",
"0.84112716",
"0.8379702",
"0.8340113",
"0.8340113",
"0.8321056",
"0.82815343",
"0.82795346",
"0.8271862",
"0.8271862",
"0.8265151... | 0.0 | -1 |
end of game status main application method responsible for game loop | def play(board)
while !(over?(board))
display_board(board)
turn(board)
end
if won?(board) != false
puts "Congratulations #{winner(board)}!"
elsif draw?(board)
puts "Cats Game!"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_game\n\n end",
"def end_game\n end",
"def main_end\r\n # Refresh map\r\n $game_map.refresh\r\n # If switching to title screen\r\n if $scene.is_a?(Scene_Title)\r\n # Fade out screen\r\n Graphics.transition\r\n Graphics.freeze\r\n end\r\n # If switching from battle te... | [
"0.7868033",
"0.7835601",
"0.7824509",
"0.7634437",
"0.7603135",
"0.7529829",
"0.7408827",
"0.73540515",
"0.7340615",
"0.7283339",
"0.7239709",
"0.7217348",
"0.7120029",
"0.7067559",
"0.70627016",
"0.7003624",
"0.6978254",
"0.69382876",
"0.6924994",
"0.69168586",
"0.6909244",... | 0.0 | -1 |
Shows list of Players (for admin). ==== Format HTML | def index
@players = Player.all
respond_to do |format|
format.html # index.html.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pmplayers = Pmplayer.all\n end",
"def index\n @players = Player.all\n\n respond_to do |format|\n format.html # index.html.haml\n format.json { render json: @players }\n end\n end",
"def show\n @players = @team.players\n end",
"def list_all_players\n jso... | [
"0.71804583",
"0.71802056",
"0.7094666",
"0.70259684",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69779086",
"0.69267803",
"0.69240576",... | 0.7079668 | 3 |
Shows detail of _Player_ (for admin). ==== Required params _id_:: id of _Player_ that should be shown. ==== Format HTML | def show
@player = Player.find(params[:id])
respond_to do |format|
format.html # show.html.erb
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @player = Player.find(params[:id])\n end",
"def show\n @player = Player.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @player }\n end\n end",
"def show\n @player = Player.find(params[:id])\n respond_... | [
"0.7839618",
"0.78126955",
"0.7735972",
"0.76310664",
"0.7547737",
"0.7348806",
"0.7348806",
"0.7348806",
"0.7348806",
"0.7348806",
"0.7201806",
"0.7195121",
"0.71787214",
"0.7174951",
"0.7112462",
"0.70890814",
"0.70375544",
"0.7010983",
"0.69979554",
"0.69338286",
"0.693319... | 0.77347946 | 3 |
Shows form that serves to create new _Player_. ==== Format HTML | def new
@player = Player.new
respond_to do |format|
format.html {
@buttons = [
{ :body => I18n.t("messages.players.form.back_to_list"), :url => players_path, :html_options => {} }
]
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @player = Player.new(params[:player])\n\n respond_to do |format|\n if @player.save\n# ToDo 0 => Wenn Spieler erstellt wurde, schließe das Fenster und aktualisiere die Spielerliste bzw. die Spielerübersicht\n format.html { redirect_to home_path, notice: 'Player was successfully create... | [
"0.7257123",
"0.7161786",
"0.71383244",
"0.7124603",
"0.7094017",
"0.7094017",
"0.7094017",
"0.7094017",
"0.7088989",
"0.7088296",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70821893",
"0.70... | 0.7629703 | 0 |
Shows form to edit the _Player_. ==== Required params _id_:: id of _Player_ to be edited. ==== Format HTML | def edit
@player = Player.find(params[:id])
respond_to do |format|
format.html {
@buttons = [
{ :body => I18n.t("messages.players.form.back_to_detail"), :url => @player , :html_options => {} },
{ :body => I18n.t("messages.players.form.back_to_list"), :url => players_path, :html_options => {} }
]
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @player = Player.find(params[:id])\n end",
"def edit\n # @player = Player.find(params[:id])\n end",
"def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to [:admin, @player], notice: ... | [
"0.8022309",
"0.79251647",
"0.72188413",
"0.7170389",
"0.7027778",
"0.6979421",
"0.6979421",
"0.6979421",
"0.6979421",
"0.6979421",
"0.6979421",
"0.69792104",
"0.6964781",
"0.6916975",
"0.686116",
"0.686116",
"0.6844647",
"0.68252224",
"0.67955005",
"0.677978",
"0.6774313",
... | 0.7179732 | 3 |
Creates new _Player_ based of params, sent from "new form". ==== Required params _player_:: contains all attributes of _Player_ which should be created. ==== Format HTML | def create
@player = Player.new(params[:player])
respond_to do |format|
if @player.save
format.html {
redirect_to @player, notice: I18n.t("messages.players.create.success")
}
else
format.html {
@errors = @player.errors
render action: "new"
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @player = Player.new(player_params)\n\n respond_to do |format|\n if @player.save\n format.html { redirect_to @player, notice: 'Player was successfully created.' }\n format.json { render :show, status: :created, location: @player }\n else\n format.html { render :new... | [
"0.79812723",
"0.79812723",
"0.79812723",
"0.79812723",
"0.79812723",
"0.79812723",
"0.79694045",
"0.7965806",
"0.79553896",
"0.79508805",
"0.7945333",
"0.7945333",
"0.7945333",
"0.7945333",
"0.79193145",
"0.79193145",
"0.79193145",
"0.79193145",
"0.7910081",
"0.78857356",
"0... | 0.7936719 | 14 |
Updates _Player_ based of params, sent from "edit form". ==== Required params _id_:: id of _Player_ to be updated. _player_:: contains all attributes of _Player_ which should be updated. ==== Format HTML | def update
@player = Player.find(params[:id])
respond_to do |format|
if @player.update_attributes(params[:player])
format.html {
redirect_to @player, notice: I18n.t("messages.players.update.success")
}
else
format.html {
@errors = @league.errors
render action: "edit"
}
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @player = Player.find(params[:id])\n\n respond_to do |format|\n if @player.update(player_params)\n format.html { redirect_to [:admin, @player], notice: 'Player was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { rend... | [
"0.8323834",
"0.8152856",
"0.81502503",
"0.8148995",
"0.81228137",
"0.8122738",
"0.8122738",
"0.8122738",
"0.8122738",
"0.8122738",
"0.8122738",
"0.8115571",
"0.80991334",
"0.80336255",
"0.80336255",
"0.80027324",
"0.7968097",
"0.7920487",
"0.7893469",
"0.7893469",
"0.7893469... | 0.7707456 | 39 |
Deletes _Player_. ==== Required params _id_:: id of _Player_ that should be deleted. ==== Format HTML | def destroy
@player = Player.find(params[:id])
@player.destroy
respond_to do |format|
format.html {
redirect_to players_url
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @player = Player.find(params[:id])\n if @player.destroy\n flash[:success] = \"Player was deleted.\"\n else\n flash[:error] = \"Player could not be deleted.\"\n end\n redirect_to players_path\n end",
"def destroy\n @player = Player.find(params[:id])\n @player.... | [
"0.77954197",
"0.7697658",
"0.76735634",
"0.75682646",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7497589",
"0.7478423",
"0.7478423",
"0.7456991",
"0.7401319",
"0.7393691",
"0.738467",
"0.738467",
"0.738467",
"0.738467",
"0... | 0.75768006 | 3 |
Adds black mark to _Player_. ==== Required params _count_:: number of added dots. _id_:: id of _Player_ to which black mark should be added. _reason_:: number of reason or undefined when reason id should be null. _description_:: additional description of reason (text). ==== Format JSON | def add_black_dot
reason = params[:reason] != nil && params[:reason] != "" ? params[:reason].to_i : nil
count = params[:count] != nil && params[:count] != "" ? params[:count].to_i : 1
desc = params[:description] != nil && params[:description] != "" ? params[:description] : nil
ActiveRecord::Base.transaction do
@dot = BlackDot.new
@dot.count = count
@dot.player_id = params[:id]
@dot.reason = reason
@dot.description = desc
@res1 = @dot.save
@player = Player.find(params[:id])
@player.dots_total = @player.dots_total + count
@res2 = @player.save
end
respond_to do |format|
format.json {
render json: {
:status => @res1 && @res2,
:dot => @dot,
:reason => @dot.reason == nil ? nil : I18n.t("messages.black_dot_reason.reason" + @dot.reason.to_s),
:description => @dot.description
}
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bad\n \tunless is_numeric? params[:id]\n \t\t@player = Player.create({ gamertag: params[:id] })\n \telse\n \t\t@player = Player.find(params[:id])\n \tend\n\n \t@player.rating = \"bad\"\n \t@player.save\n\n \trespond_to do |format|\n \t\tformat.js\n \tend\n end",
"def good\n \tunless is_numeric? p... | [
"0.51552796",
"0.4701075",
"0.4634198",
"0.44908682",
"0.44851646",
"0.43117198",
"0.43054128",
"0.42076096",
"0.4191373",
"0.41531503",
"0.4138608",
"0.41342637",
"0.41165262",
"0.41022447",
"0.4003534",
"0.3988427",
"0.39752242",
"0.39675748",
"0.39430532",
"0.39313093",
"0... | 0.6180549 | 0 |
Increases _beer_paid_ attribute of _Player_. ==== Required params _id_:: id of _Player_ which attribute _beer_paid_ should be increased. ==== Format JSON | def pay_beer
@player = Player.find(params[:id])
@player.beer_paid = @player.beer_paid + 1
@res = @player.save
respond_to do |format|
format.json {
render json: {
:status => @res,
:player => @player
}
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increase_insurance_premium\n self.insurance_premium += 100\n end",
"def increase_insurance_premium\n self.insurance_premium += 100\n end",
"def increment_points(points)\n self.balance = self.balance.to_i + points.to_i\n self.save\n end",
"def pay!\n update_attributes paid: true, pai... | [
"0.58982944",
"0.58711165",
"0.5836379",
"0.58351606",
"0.57814634",
"0.5766293",
"0.5667446",
"0.5664226",
"0.5623893",
"0.5562069",
"0.55351895",
"0.55323076",
"0.5525465",
"0.5524702",
"0.54698724",
"0.5468731",
"0.5445076",
"0.5423665",
"0.5415927",
"0.5410741",
"0.538495... | 0.8105451 | 0 |
Realizing the actual importance of code formatting | def fed
( p p )
p?a a?p
q= p q =p
p %%.....%% q
dne end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beautify; end",
"def beautify; end",
"def code_format_print(code)\n indent = 0\n l = 1\n code.each_line do |ln|\n ln = ln.strip\n if(ln.match(/^end/))\n indent -= 4\n end\n indent = 0 if indent < 0\n ll = \" \"\n if(l<10)\n ll = \"00#... | [
"0.714464",
"0.714464",
"0.6775815",
"0.67662513",
"0.6688448",
"0.6566475",
"0.6558145",
"0.6558145",
"0.6544236",
"0.65372205",
"0.65372205",
"0.65372205",
"0.6506864",
"0.6506864",
"0.6506864",
"0.6506864",
"0.6506864",
"0.6506864",
"0.6506864",
"0.6506864",
"0.65035534",
... | 0.0 | -1 |
GET /bar68s or /bar68s.json | def index
@bar68s = Bar68.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_... | [
"0.6062327",
"0.6025169",
"0.59530115",
"0.5924268",
"0.5870208",
"0.5806346",
"0.5778083",
"0.5746901",
"0.5712355",
"0.5683639",
"0.56712085",
"0.5658685",
"0.5645185",
"0.56428504",
"0.5616093",
"0.56131077",
"0.5599265",
"0.5566004",
"0.556595",
"0.5539394",
"0.5534587",
... | 0.602136 | 2 |
GET /bar68s/1 or /bar68s/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @barrack }\n end\n end",
"def show\n @bar = Bar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { rend... | [
"0.62303185",
"0.61753106",
"0.60511845",
"0.5967835",
"0.5953472",
"0.59522194",
"0.5909464",
"0.5838846",
"0.58371335",
"0.5826596",
"0.58252764",
"0.5803539",
"0.5793828",
"0.5751416",
"0.5745294",
"0.57166857",
"0.57166857",
"0.57095236",
"0.56948847",
"0.5686634",
"0.568... | 0.0 | -1 |
POST /bar68s or /bar68s.json | def create
@bar68 = Bar68.new(bar68_params)
respond_to do |format|
if @bar68.save
format.html { redirect_to @bar68, notice: "Bar68 was successfully created." }
format.json { render :show, status: :created, location: @bar68 }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @bar68.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @bar80 = Bar80.new(bar80_params)\n\n respond_to do |format|\n if @bar80.save\n format.html { redirect_to @bar80, notice: \"Bar80 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar80 }\n else\n format.html { render :new, sta... | [
"0.6280484",
"0.61147785",
"0.6080365",
"0.60739577",
"0.6058968",
"0.60417044",
"0.6035992",
"0.6002331",
"0.596649",
"0.5910943",
"0.59073275",
"0.58393246",
"0.58381164",
"0.5814874",
"0.5796918",
"0.578256",
"0.5780741",
"0.57701945",
"0.5768486",
"0.5706695",
"0.5698048"... | 0.64867765 | 0 |
PATCH/PUT /bar68s/1 or /bar68s/1.json | def update
respond_to do |format|
if @bar68.update(bar68_params)
format.html { redirect_to @bar68, notice: "Bar68 was successfully updated." }
format.json { render :show, status: :ok, location: @bar68 }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @bar68.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @bar77.update(bar77_params)\n format.html { redirect_to @bar77, notice: \"Bar77 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar77 }\n else\n format.html { render :edit, status: :unprocessable_entity }... | [
"0.6718046",
"0.6685876",
"0.66405016",
"0.6616602",
"0.66161853",
"0.6613844",
"0.661159",
"0.66055024",
"0.6593854",
"0.6579685",
"0.6569437",
"0.6564225",
"0.6558422",
"0.65565634",
"0.6550364",
"0.65436465",
"0.6540005",
"0.65352577",
"0.6527858",
"0.6489772",
"0.647327",... | 0.6740213 | 0 |
DELETE /bar68s/1 or /bar68s/1.json | def destroy
@bar68.destroy
respond_to do |format|
format.html { redirect_to bar68s_url, notice: "Bar68 was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash... | [
"0.67019",
"0.6633845",
"0.6626538",
"0.6600448",
"0.65777886",
"0.65484816",
"0.65409064",
"0.65267766",
"0.6513855",
"0.6470938",
"0.64658636",
"0.64658636",
"0.6462062",
"0.64619285",
"0.64557457",
"0.6436844",
"0.6406543",
"0.6404426",
"0.6403605",
"0.6393535",
"0.6371468... | 0.65439785 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_bar68
@bar68 = Bar68.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def bar68_params
params.require(:bar68).permit(:foo1, :foo2, :foo3, :foo4, :foo5)
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.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
actually might not need the new and create actions since user registration is being handled by devise | def new
@student = Student.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_user\n \n end",
"def newUser\n end",
"def create\n\n (super and return) if request.format.html?\n\t user = User.new(allow_registration_parameters)\n\t if user.save\n\t render :json=> { :status => 201, :user => user , :token => user.authentication_token }\n\t return\n\t else\n\t war... | [
"0.73073465",
"0.7286683",
"0.7195135",
"0.7118714",
"0.70851284",
"0.7084818",
"0.7028504",
"0.7018612",
"0.6981577",
"0.6922201",
"0.69186085",
"0.6916251",
"0.68766665",
"0.68730956",
"0.68713564",
"0.68543804",
"0.6848034",
"0.6845089",
"0.6838803",
"0.682362",
"0.6819858... | 0.0 | -1 |
Padrino's asset handling needs to pass through ours | def asset_path(kind, source)
return source if source =~ /^http/
asset_folder = case kind
when :css then settings.css_dir
when :js then settings.js_dir
when :images then settings.images_dir
else kind.to_s
end
source = source.to_s.gsub(/\s/, '')
ignore_extension = (kind == :images) # don't append extension
source << ".#{kind}" unless ignore_extension or source =~ /\.#{kind}/
result_path = source if source =~ %r{^/} # absolute path
result_path ||= asset_url(source, asset_folder)
timestamp = asset_timestamp(result_path)
"#{result_path}#{timestamp}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolve_asset; end",
"def resolve_asset; end",
"def assets; end",
"def assets; end",
"def assets; end",
"def asset_file?; end",
"def asset_file?; end",
"def asset_host; end",
"def asset_host; end",
"def assets=(_arg0); end",
"def assets=(_arg0); end",
"def assets=(_arg0); end",
"def ass... | [
"0.7437381",
"0.7437381",
"0.7250617",
"0.7250617",
"0.7250617",
"0.7032444",
"0.7032444",
"0.68833894",
"0.68833894",
"0.6676499",
"0.6676499",
"0.6676499",
"0.66683966",
"0.66683966",
"0.6537513",
"0.6537513",
"0.6313475",
"0.6312442",
"0.6229604",
"0.6145517",
"0.6087644",... | 0.0 | -1 |
Creates a client connection to Riakpb's Protobuf Listener | def initialize(options={})
self.host = options[:host] || "127.0.0.1"
self.port = options[:port] || 8087
self.client_id = options[:client_id] unless options[:client_id].blank?
read_quorum = options[:r] || options[:read_quorum]
write_quorum = options[:w] || options[:write_quorum]
replica_commit = options[:dw] || options[:replica_commit]
return_body = options[:rb] || options[:return_body] || true
@options = options.slice!(:host, :port, :client_id, :r, :read_quorum, :w, :write_quorum, :dw, :replica_commit, :rb, :return_body)
@options[:r] = read_quorum unless read_quorum.blank?
@options[:w] = write_quorum unless write_quorum.blank?
@options[:dw] = replica_commit unless replica_commit.blank?
@options[:return_body] = return_body unless return_body.blank?
@buckets = []
@bucket_cache = Hash.new{|k,v| k[v] = Riakpb::Bucket.new(self, v, @options)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_message_listener\n begin\n message = @client.gets\n init_message(message)\n end until @client.closed?\n end",
"def initialize(listener)\n @listener = listener\n end",
"def open_listener\n @listener = PCAPRUB::Pcap.open_live(IFACE, 65535, false, 1)\n @listener.s... | [
"0.61132884",
"0.5746174",
"0.5737131",
"0.5733513",
"0.57036215",
"0.5699631",
"0.5673083",
"0.5664639",
"0.5643266",
"0.55858773",
"0.5562572",
"0.5560142",
"0.55301726",
"0.5480431",
"0.5445003",
"0.54343826",
"0.5417622",
"0.54106706",
"0.53998333",
"0.539048",
"0.5383147... | 0.51606417 | 45 |
Establish a connection to the riak node, and store the Rpc instance | def rpc(options={})
options[:client_id] ||= @client_id if @client_id
@rpc ||= Rpc.new(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawn_connection\n connect\n end",
"def establish\n @proxy = XMLRPC::Client.new(@hostname, '/RPC2', @port).proxy(@proxy_name)\n end",
"def connect\n return true if @status == :connected\n connection_options = {\n host: @host,\n port: @port,\n user: @user,\n pas... | [
"0.65165484",
"0.6503018",
"0.6361423",
"0.63182664",
"0.6288404",
"0.6281889",
"0.62625355",
"0.62207127",
"0.61796784",
"0.6151615",
"0.60898405",
"0.6034493",
"0.60091716",
"0.5935398",
"0.5919064",
"0.5916248",
"0.5912539",
"0.5912539",
"0.5895548",
"0.58930236",
"0.58743... | 0.55937105 | 43 |
Tests connectivity with the Riakpb host. | def ping?
rpc.request Util::MessageCode::PING_REQUEST
return rpc.status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_connection\n response = send_api_request(:index)\n response[:returncode]\n end",
"def test_connection\n response = send_api_request(:index)\n response[:returncode]\n end",
"def test_connection\n end",
"def test_conn_1p_0000\n assert @conn.open?\n end",
"def test_... | [
"0.6756367",
"0.6756367",
"0.6638944",
"0.65829134",
"0.65554047",
"0.6508153",
"0.6396695",
"0.6356738",
"0.6287228",
"0.6275995",
"0.6275995",
"0.62727135",
"0.6268059",
"0.62204564",
"0.62169874",
"0.61831933",
"0.6170404",
"0.61594516",
"0.6050791",
"0.6025588",
"0.602272... | 0.0 | -1 |
Retrieves basic information from the riak node. | def info
response = rpc.request Riakpb::Util::MessageCode::GET_SERVER_INFO_REQUEST
@node = response.node
@server_version = response.server_version
{:node => @node, :server_version => @server_version}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def info\n CouchRest.get \"#{@uri}/\"\n end",
"def info\n request('getinfo')\n end",
"def get_info(jid,node)\n iq = Iq.new(:get,jid)\n iq.from = @stream.jid\n discoinfo = Discovery::IqQueryDiscoInfo.new\n discoinfo.node = node\n iq.add(discoinfo)\n info... | [
"0.6485314",
"0.63724726",
"0.63476044",
"0.62544376",
"0.62421924",
"0.6230913",
"0.6226347",
"0.61459154",
"0.60947365",
"0.60947365",
"0.60075223",
"0.599211",
"0.59124357",
"0.59124357",
"0.59124357",
"0.5871939",
"0.5860016",
"0.57710177",
"0.5753367",
"0.57347697",
"0.5... | 0.529909 | 62 |
I need bucket! Bring me bucket! (Retrieves a bucket from Riakpb. Eating disorder not included.) | def bucket(bucket)
return(@bucket_cache[bucket]) if @bucket_cache.has_key?(bucket)
self.bucket!(bucket)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket\n @bucket ||= connection.directories.get(@bucket_name, :prefix => @prefix)\n end",
"def bucket!(bucket)\n request = Riakpb::RpbGetBucketReq.new(:bucket => bucket)\n response = rpc.request(\n Util::MessageCode::GET_BUCKET_REQUEST,\n ... | [
"0.7721133",
"0.76851845",
"0.7665383",
"0.7629119",
"0.74088997",
"0.7403094",
"0.7271967",
"0.7188265",
"0.71869516",
"0.71458876",
"0.71458876",
"0.71254855",
"0.7082634",
"0.70641756",
"0.70021856",
"0.69898665",
"0.69884795",
"0.6930846",
"0.6918151",
"0.6912644",
"0.690... | 0.6817716 | 24 |
I need bucket! Bring me bucket! (Retrieves a bucket from Riakpb, even if it's already been retrieved.) | def bucket!(bucket)
request = Riakpb::RpbGetBucketReq.new(:bucket => bucket)
response = rpc.request(
Util::MessageCode::GET_BUCKET_REQUEST,
request
)
@bucket_cache[bucket].load(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket\n @bucket ||= connection.directories.get(@bucket_name, :prefix => @prefix)\n end",
"def bucket\n @gapi[\"bucket\"]\n end",
"def bucket\n begin\n # Find existing bucket:\n bucket = service.buckets.find(s3_bucket)\n rescue ::S3::Error::NoSuchBucket =... | [
"0.7986586",
"0.77440417",
"0.76587373",
"0.74959445",
"0.7488384",
"0.7478043",
"0.74388045",
"0.74309736",
"0.7400208",
"0.7400208",
"0.72770715",
"0.7245517",
"0.72098434",
"0.7192114",
"0.71753293",
"0.7158192",
"0.7128064",
"0.71210116",
"0.70805734",
"0.70633465",
"0.70... | 0.7931453 | 1 |
Set the properties for a given bucket, and then reload it. | def set_bucket(bucket, props)
props = Riakpb::RpbBucketProps.new(props) if props.is_a?(Hash)
raise TypeError.new t('invalid_props') unless props.is_a?(Riakpb::RpbBucketProps)
begin
request = Riakpb::RpbSetBucketReq.new(:bucket => bucket, :props => props)
response = rpc.request(
Util::MessageCode::SET_BUCKET_REQUEST,
request
)
self.bucket!(bucket)
return(true)
rescue FailedRequest
return(false)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_bucket_props(bucket, props, type = nil)\n stringify_keys!(props)\n\n bucket_props = bucket_data(bucket, type)[:props]\n bucket_props.merge!(props)\n bucket_props\n end",
"def update!(**args)\n @bucket_uri = args[:bucket_uri] if args.key?(:bucket_uri)\n end... | [
"0.727621",
"0.6453831",
"0.6453831",
"0.6441342",
"0.6341936",
"0.6246016",
"0.6107328",
"0.6082025",
"0.6082025",
"0.6082025",
"0.60035",
"0.5996953",
"0.59581214",
"0.59426",
"0.5911148",
"0.59064204",
"0.5873359",
"0.58295226",
"0.5803203",
"0.5745791",
"0.57206",
"0.57... | 0.62728393 | 5 |
Retrieves a key, using RpbGetReq, from within a given bucket, from Riakpb. | def get_request(bucket, key, quorum=nil)
request = Riakpb::RpbGetReq.new({:bucket => bucket, :key => key})
quorum ||= @read_quorum
unless quorum.blank?
quorum = quorum.to_i
request.r = quorum
end
response = rpc.request(
Util::MessageCode::GET_REQUEST,
request
)
return(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_object(bucket, key, options = {})\n result = bucket_data(bucket, options[:type])[:keys][key]\n raise ProtobuffsFailedRequest.new(:not_found, t('not_found')) unless result\n \n load_object(RObject.new(bucket, key), result)\n end",
"def get_key request_pb, options = nil\n... | [
"0.6757603",
"0.67241526",
"0.6472178",
"0.6472178",
"0.6457516",
"0.64295375",
"0.6339738",
"0.63080096",
"0.6253491",
"0.6206004",
"0.6198651",
"0.61705315",
"0.61681396",
"0.6132592",
"0.61062163",
"0.6050953",
"0.6024107",
"0.5988777",
"0.5952282",
"0.595207",
"0.58513194... | 0.73711395 | 0 |
Inserts a key into riak, using RpbPutReq. | def put_request(options)
raise ArgumentError, t('invalid_bucket') if options[:bucket].empty?
raise ArgumentError, t('empty_content') if options[:content].nil?
options[:w] ||= @write_quorum unless @write_quorum.nil?
options[:dw] ||= @replica_commit unless @replica_commit.nil?
options[:return_body] = @return_body unless options.has_key?(:return_body)
request = Riakpb::RpbPutReq.new(options.slice :bucket, :key, :vclock, :content, :w, :dw, :return_body)
response = rpc.request(
Util::MessageCode::PUT_REQUEST,
request
)
return(true) if response == ""
return(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_key(key)\n post(\"/api/v1/ssh_keys\", :key => key).to_s\n end",
"def put(namespace, key, entry); end",
"def put(key, value)\n \n end",
"def put(key, value); end",
"def add_key(key)\n post(\"/users/ssh_keys\", {:key => key}, :accept => 'json').to_s\n end",
"def put(key, value)\n... | [
"0.62929225",
"0.6084296",
"0.6075017",
"0.6066843",
"0.6017247",
"0.5926804",
"0.5918413",
"0.5906067",
"0.58739495",
"0.58547604",
"0.5847226",
"0.5847226",
"0.5835634",
"0.5823613",
"0.5786138",
"0.5768722",
"0.57184654",
"0.56984687",
"0.569525",
"0.5687137",
"0.5668134",... | 0.58148575 | 14 |
Deletes a key, using RpbDelReq, from within a given bucket, from Riakpb. | def del_request(bucket, key, rw=nil)
request = Riakpb::RpbDelReq.new
request.bucket = bucket
request.key = key
request.rw ||= rw
response = rpc.request(
Util::MessageCode::DEL_REQUEST,
request
)
return(true) if response == ""
return(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bucket_delete_object(key)\n http.delete(\"/#{key}\", bucket: bucket, key: key)\n end",
"def delete\n connection.delete(\"/#{URI.escape(@key)}\", @bucket_name)\n end",
"def delete_key request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if re... | [
"0.7128815",
"0.70396614",
"0.6782836",
"0.6631057",
"0.6541163",
"0.633033",
"0.6293411",
"0.6293411",
"0.6293411",
"0.6293411",
"0.6293411",
"0.62906814",
"0.62820756",
"0.6280255",
"0.6275988",
"0.62635785",
"0.6246439",
"0.6196306",
"0.6108938",
"0.6104523",
"0.61007875",... | 0.8234502 | 0 |
Sends a MapReduce operation to riak, using RpbMapRedReq, and returns the Response/phases. | def map_reduce_request(mr_request, content_type)
request = Riakpb::RpbMapRedReq.new
request.request = mr_request
request.content_type = content_type
response = rpc.request(
Util::MessageCode::MAP_REDUCE_REQUEST,
request
)
return(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mapred(mr, &block)\n results = []\n inputs = []\n\n # Generate the list of objects to act as inputs into the map/reduce functions\n if mr.inputs.is_a?(String)\n bucket = mr.inputs\n list_keys(bucket).each do |key|\n inputs << [bucket, key]\n end... | [
"0.60963875",
"0.540774",
"0.53623384",
"0.51605296",
"0.5030062",
"0.48076388",
"0.47771114",
"0.4710285",
"0.47099197",
"0.47099197",
"0.47029185",
"0.46856683",
"0.46546808",
"0.46464658",
"0.46345624",
"0.4597326",
"0.45805436",
"0.4570553",
"0.45663828",
"0.4546522",
"0.... | 0.7805435 | 0 |
[Yes, No, Inactive] application_fee (float) renewal_schedule_in_years, | def map_exam_required
# Return list of required exams split by ,
if self.exam_required
(self.exam_required.join ", ").gsub(/, $/, '')
else
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def application_fee\n self[:application_fee] || (unit_price * (COMMISSION_RATE / 100) + TRANSACTION_COST / 100).round(2) || BigDecimal(0)\n end",
"def assistance_fee\n ROADSIDE_ASSISSTANCE_FEE_PER_DAY * duration\n end",
"def application_fee_without_tax\n application_fee * (1 - tax_rate / 100)\n en... | [
"0.7083792",
"0.66952085",
"0.63984054",
"0.61315197",
"0.6065965",
"0.59469116",
"0.58892107",
"0.58567846",
"0.5822668",
"0.5762425",
"0.5701278",
"0.5681439",
"0.5674794",
"0.56666344",
"0.5627841",
"0.56168014",
"0.5615803",
"0.5609673",
"0.5608684",
"0.55949587",
"0.5587... | 0.0 | -1 |
add_item accepts a title and a price and increases the total also accepts an optional quantity doesn't forget about the previous total | def add_item (title, price, quantity=1)
self.total += price * quantity
quantity.times do
@items << title
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(title, price, quantity=1)\n #and increases the total\n self.total += price * quantity\n #times.do for all the items\n quantity.times do\n @items << title\n end\n #doesn't forget about the previous total\n self.last_transaction = price * quant... | [
"0.88109183",
"0.87535137",
"0.86145264",
"0.8517917",
"0.85166854",
"0.8487527",
"0.8483714",
"0.8397211",
"0.8358682",
"0.8340887",
"0.825319",
"0.8236478",
"0.82202965",
"0.81615055",
"0.8109122",
"0.81018835",
"0.80452096",
"0.78962755",
"0.7825504",
"0.7732733",
"0.76846... | 0.8702204 | 2 |
items returns an array containing all items that have been added apply_discount the cash register was initialized with an employee discount applies the discount to the total price returns success message with updated total reduces the total the cash register was not initialized with an employee discount returns a string error message that there is no discount to apply | def apply_discount
if discount !=0
self.total = total- (total*(discount/100.to_f)).to_i
"After the discount, the total comes to $#{self.total}."
else
"There is no discount to apply."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_discount(items)\n 0\n end",
"def test_discount_on_item_not_valid_for_discount\n # Add 3 green tea to line items\n line_items = [ @green_tea_in_cart_1, @green_tea_in_cart_2, @green_tea_in_cart_3]\n @bulk_discount.apply(line_items)\n\n # Test if the discount is applied\n assert_equal @... | [
"0.71192497",
"0.6838979",
"0.67270625",
"0.657363",
"0.6438931",
"0.64371127",
"0.64347684",
"0.6391531",
"0.6341032",
"0.62799567",
"0.6277437",
"0.62678355",
"0.6240369",
"0.62104785",
"0.6193512",
"0.6191669",
"0.6188366",
"0.61827564",
"0.61759144",
"0.6169311",
"0.61647... | 0.0 | -1 |
void_last_transaction subtracts the last transaction from the total | def void_last_transaction
@total-=self.total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def void_last_transaction\n @total = @total - @last_transaction_amt\n end",
"def void_last_transaction\n self.total = self.total - self.last_transaction\n end",
"def void_last_transaction\n self.total = self.total - self.last_transaction\n end",
"def void_last_transaction\n self.total = ... | [
"0.88955647",
"0.8789714",
"0.8789714",
"0.8789714",
"0.8662823",
"0.8505989",
"0.8334916",
"0.828992",
"0.8222375",
"0.8113807",
"0.7971079",
"0.7955742",
"0.7713947",
"0.76934713",
"0.7257942",
"0.63174844",
"0.62684506",
"0.6005022",
"0.5990571",
"0.59840107",
"0.5886206",... | 0.84848934 | 6 |
GET /foo91s or /foo91s.json | def index
@foo91s = Foo91.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(path, **args); end",
"def GET; end",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.json/\", args)\nend",
"def list_all_aos_versions(args = {}) \n get(\"/aosversions.json/all\", args)\nend",
"def http( *args )\n p http_get( *args )\n end",
"def get_aos_version_by_name(ar... | [
"0.5870235",
"0.58688706",
"0.58610505",
"0.5745187",
"0.5716675",
"0.5706757",
"0.5673086",
"0.5645496",
"0.563858",
"0.5626887",
"0.5600305",
"0.55972075",
"0.5576869",
"0.5574741",
"0.5556026",
"0.5555883",
"0.5545138",
"0.553712",
"0.5512892",
"0.5512892",
"0.5508374",
... | 0.51883996 | 88 |
GET /foo91s/1 or /foo91s/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_aos_version_by_name(args = {}) \n get(\"/aosversions.json/version/#{args[:aosVersionName]}\", args)\nend",
"def get(path, **args); end",
"def get_aos_version(args = {}) \n get(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def list_active_aos_versions(args = {}) \n get(\"/aosversions.jso... | [
"0.60760486",
"0.6040446",
"0.593873",
"0.59266245",
"0.58210444",
"0.5770206",
"0.5726346",
"0.5718768",
"0.5706767",
"0.5691218",
"0.5673726",
"0.56736785",
"0.5626185",
"0.56199014",
"0.5615353",
"0.5606875",
"0.56060904",
"0.56053865",
"0.56053865",
"0.5604031",
"0.560162... | 0.0 | -1 |
POST /foo91s or /foo91s.json | def create
@foo91 = Foo91.new(foo91_params)
respond_to do |format|
if @foo91.save
format.html { redirect_to @foo91, notice: "Foo91 was successfully created." }
format.json { render :show, status: :created, location: @foo91 }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @foo91.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(path, **args); end",
"def post_json(path, body)\n uri = build_uri(path)\n puts \"*** POST #{path}\"\n puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostn... | [
"0.6262167",
"0.5959549",
"0.59119457",
"0.5901785",
"0.5881628",
"0.5876262",
"0.58638185",
"0.58558434",
"0.5832176",
"0.58291316",
"0.58195233",
"0.5811533",
"0.577161",
"0.5738022",
"0.5732125",
"0.57199883",
"0.5713084",
"0.5692667",
"0.5665253",
"0.5662356",
"0.5659618"... | 0.571961 | 16 |
PATCH/PUT /foo91s/1 or /foo91s/1.json | def update
respond_to do |format|
if @foo91.update(foo91_params)
format.html { redirect_to @foo91, notice: "Foo91 was successfully updated." }
format.json { render :show, status: :ok, location: @foo91 }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @foo91.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch!\n request! :patch\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patc... | [
"0.65227926",
"0.63594806",
"0.6279403",
"0.6272962",
"0.62227356",
"0.6129994",
"0.611725",
"0.60883826",
"0.6076311",
"0.6040519",
"0.6021801",
"0.6013734",
"0.6010367",
"0.601013",
"0.601013",
"0.60049385",
"0.5999497",
"0.5998313",
"0.5996826",
"0.5977811",
"0.59506947",
... | 0.6273329 | 3 |
DELETE /foo91s/1 or /foo91s/1.json | def destroy
@foo91.destroy
respond_to do |format|
format.html { redirect_to foo91s_url, notice: "Foo91 was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete(*rest) end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def http_delete(path, data = n... | [
"0.694556",
"0.6626908",
"0.65868354",
"0.646368",
"0.6453266",
"0.64302903",
"0.6411858",
"0.6411858",
"0.6354994",
"0.6354599",
"0.6352906",
"0.6343519",
"0.6343519",
"0.6327255",
"0.6301713",
"0.62971777",
"0.62939644",
"0.62869596",
"0.6286874",
"0.62839246",
"0.62792635"... | 0.64242345 | 6 |
Use callbacks to share common setup or constraints between actions. | def set_foo91
@foo91 = Foo91.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def foo91_params
params.require(:foo91).permit(:foo1, :foo2, :foo3, :foo4, :foo5)
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.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Returns the decoder stub that is adjusted for the size of the buffer being encoded. | def decoder_stub(state)
# add one xor operation for the key (see comment below)
number_of_passes=state.buf.length/4+1
raise InvalidPayloadSizeException.new("The payload being encoded is too long (#{state.buf.length} bytes)") if number_of_passes > 10240
raise InvalidPayloadSizeException.new("The payload is not padded to 4-bytes (#{state.buf.length} bytes)") if state.buf.length%4 != 0
# 16-bits not (again, see below)
reg_14 = (number_of_passes+1)^0xFFFF
decoder = Metasm::Shellcode.assemble(Metasm::MIPS.new(:little), <<EOS).encoded.data
;
; MIPS nul-free xor decoder
;
; (C) 2006 Julien TINNES
; <julien at cr0.org>
;
; The first four bytes in encoded shellcode must be the xor key
; This means that you have to put the xor key right after
; this xor decoder
; This key will be considered part of the encoded shellcode
; by this decoder and will be xored, thus becoming 4NULs, meaning nop
;
; This is Linux-only because I use the cacheflush system call
;
; You can use shellforge to assemble this, but be sure to discard all
; the nul bytes at the end (everything after x01\\x4a\\x54\\x0c)
;
; change 2 bytes in the first instruction's opcode with the number of passes
; the number of passes is the number of xor operations to apply, which should be
; 1 (for the key) + the number of 4-bytes words you have in your shellcode
; you must encode ~(number_of_passes + 1) (to ensure that you're nul-free)
;.text
;.align 2
;.globl main
;.ent main
;.type main,@function
main:
li macro reg, imm
; lui reg, ((imm) >> 16) & 0ffffh
; ori reg, reg, (imm) & 0ffffh
addiu reg, $0, imm ; sufficient if imm.abs <= 0x7fff
endm
li( $14, #{reg_14}) ; 4 passes
nor $14, $14, $0 ; put number of passes in $14
li( $11,-73) ; addend to calculated PC is 73
;.set noreorder
next:
bltzal $8, next
;.set reorder
slti $8, $0, 0x8282
nor $11, $11, $0 ; addend in $9
addu $25, $31, $11 ; $25 points to encoded shellcode +4
; addu $16, $31, $11 ; $16 too (enable if you want to pass correct parameters to cacheflush
; lui $2, 0xDDDD ; first part of the xor (old method)
slti $23, $0, 0x8282 ; store 0 in $23 (our counter)
; ori $17, $2, 0xDDDD ; second part of the xor (old method)
lw $17, -4($25) ; load xor key in $17
li( $13, -5)
nor $13, $13, $0 ; 4 in $13
addi $15, $13, -3 ; 1 in $15
loop:
lw $8, -4($25)
addu $23, $23, $15 ; increment counter
xor $3, $8, $17
sltu $30, $23, $14 ; enough loops?
sw $3, -4($25)
addi $6, $13, -1 ; 3 in $6 (for cacheflush)
bne $0, $30, loop
addu $25, $25, $13 ; next instruction to decode :)
; addiu $4, $16, -4 ; not checked by Linux
; li $5,40 ; not checked by Linux
; li $6,3 ; $6 is set above
; .set noreorder
li( $2, 4147) ; cacheflush
;.ascii "\\x01JT\\x0c" ; nul-free syscall
syscall 0x52950
; .set reorder
; write last decoder opcode and decoded shellcode
; li $4,1 ; stdout
; addi $5, $16, -8
; li $6,40 ; how much to write
; .set noreorder
; li $2, 4004 ; write
; syscall
; .set reorder
nop ; encoded shellcoded must be here (xor key right here ;)
; $t9 (aka $25) points here
EOS
# put the key at the end of the decoder
state.decoder_key_offset = decoder.length - 4
return decoder
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decoder_stub(state)\n\t\tif (state.decoder_stub == nil)\n\t\t\tblock = generate_decoder_stub(state) || (raise BadGenerateError)\n\t\t\tstate.decoder_key_offset = block.index('XORK')\n\t\t\tstate.decoder_stub = block\n\t\tend\n\n\t\tstate.decoder_stub\n\tend",
"def decoder_stub(state)\n len = state.buf.len... | [
"0.69858676",
"0.6581347",
"0.6360701",
"0.54129624",
"0.5331713",
"0.5296336",
"0.5275721",
"0.5110416",
"0.50310355",
"0.49725616",
"0.49459594",
"0.4922418",
"0.4910436",
"0.490991",
"0.48910376",
"0.48803258",
"0.48755118",
"0.4873656",
"0.48458695",
"0.48404115",
"0.4832... | 0.521334 | 7 |
Merges this query list with another. The returned query list queries for the intersection between the two inputs. Both query lists should be resolved. | def merge(other)
new_queries = queries.map {|q1| other.queries.map {|q2| q1.merge(q2)}}.flatten.compact
return if new_queries.empty?
QueryList.new(new_queries)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersect(other)\n\t\t\tc = Xmms::Collection.new(Xmms::Collection::TYPE_INTERSECTION)\n\t\t\tc.operands << self\n\t\t\tc.operands << other\n\t\t\tc\n\t\tend",
"def intersect(other)\n set_operation(other, :intersect, distinct: true)\n end",
"def intersect(results_list)\n intersection_hits = self.... | [
"0.65731716",
"0.64676946",
"0.6419824",
"0.635614",
"0.6240802",
"0.6103736",
"0.6079205",
"0.60788554",
"0.5973304",
"0.5971937",
"0.596858",
"0.59236866",
"0.59108394",
"0.57837355",
"0.574916",
"0.56583667",
"0.56556636",
"0.5654523",
"0.5567013",
"0.55310977",
"0.5529876... | 0.7463428 | 0 |
Returns the CSS for the media query list. | def to_css
queries.map {|q| q.to_css}.join(', ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def css_render\n css_list.join(\"\\n\")\n end",
"def css_styles\n @css_styles ||= []\n end",
"def media_colors\n return @media_colors\n end",
"def media_styles_croppable_list\n list = Ubiquo::Config.context(:ubiquo_media).get(:media_styles_list)\n # The... | [
"0.6412106",
"0.57231975",
"0.560444",
"0.55454755",
"0.54734623",
"0.5353245",
"0.5317996",
"0.5287653",
"0.52215517",
"0.5210243",
"0.52072406",
"0.5194655",
"0.51916623",
"0.5149517",
"0.5143761",
"0.5143761",
"0.511654",
"0.5111628",
"0.5094868",
"0.50911117",
"0.507322",... | 0.66031283 | 0 |
Returns a deep copy of this query list and all its children. | def deep_copy
QueryList.new(queries.map {|q| q.deep_copy})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone\n q = super\n q.attrs = self.attrs.clone\n return q\n end",
"def deep_copy\n Query.new(\n modifier.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},\n type.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},\n expressions.map {|e| e.ma... | [
"0.6835412",
"0.66094726",
"0.63128006",
"0.6281369",
"0.6242736",
"0.6209777",
"0.61723334",
"0.6091195",
"0.6061811",
"0.5970495",
"0.59669834",
"0.596342",
"0.59093624",
"0.5879351",
"0.5858945",
"0.5858945",
"0.58115286",
"0.5810082",
"0.5805728",
"0.58056194",
"0.5804239... | 0.8258115 | 0 |
Merges this query with another. The returned query queries for the intersection between the two inputs. Both queries should be resolved. | def merge(other)
m1, t1 = resolved_modifier.downcase, resolved_type.downcase
m2, t2 = other.resolved_modifier.downcase, other.resolved_type.downcase
t1 = t2 if t1.empty?
t2 = t1 if t2.empty?
if (m1 == 'not') ^ (m2 == 'not')
return if t1 == t2
type = m1 == 'not' ? t2 : t1
mod = m1 == 'not' ? m2 : m1
elsif m1 == 'not' && m2 == 'not'
# CSS has no way of representing "neither screen nor print"
return unless t1 == t2
type = t1
mod = 'not'
elsif t1 != t2
return
else # t1 == t2, neither m1 nor m2 are "not"
type = t1
mod = m1.empty? ? m2 : m1
end
Query.new([mod], [type], other.expressions + expressions)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intersect(other)\n set_operation(other, :intersect, distinct: true)\n end",
"def intersect(other)\n\t\t\tc = Xmms::Collection.new(Xmms::Collection::TYPE_INTERSECTION)\n\t\t\tc.operands << self\n\t\t\tc.operands << other\n\t\t\tc\n\t\tend",
"def intersect(other)\n Intersection.new(self, oth... | [
"0.67638135",
"0.65890235",
"0.65204906",
"0.6408978",
"0.6408978",
"0.6266415",
"0.6180291",
"0.61776996",
"0.6147979",
"0.6088569",
"0.60722184",
"0.60289437",
"0.59464574",
"0.59423137",
"0.5833187",
"0.5816566",
"0.56936026",
"0.5661878",
"0.5645876",
"0.56013787",
"0.553... | 0.5070247 | 56 |
Returns the CSS for the media query. | def to_css
css = ''
css << resolved_modifier
css << ' ' unless resolved_modifier.empty?
css << resolved_type
css << ' and ' unless resolved_type.empty? || expressions.empty?
css << expressions.map do |e|
# It's possible for there to be script nodes in Expressions even when
# we're converting to CSS in the case where we parsed the document as
# CSS originally (as in css_test.rb).
e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.to_sass : c.to_s}.join
end.join(' and ')
css
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_css\n queries.map {|q| q.to_css}.join(', ')\n end",
"def to_css\n queries.map {|q| q.to_css}.join(', ')\n end",
"def css(query)\n\t\treturn is_valid ? @doc.css(query) : nil\n\tend",
"def css\n Sass::Tree::Visitors::ToCss.new.visit(self)\n end",
"def css_render\n cs... | [
"0.6234313",
"0.6234313",
"0.60894257",
"0.5817209",
"0.5793036",
"0.5729869",
"0.5691349",
"0.56565017",
"0.54895437",
"0.54452384",
"0.5416019",
"0.5335661",
"0.5329268",
"0.5329268",
"0.5329268",
"0.5321578",
"0.53081816",
"0.53059435",
"0.5300194",
"0.52846247",
"0.527812... | 0.52532005 | 21 |
Returns a deep copy of this query and all its children. | def deep_copy
Query.new(
modifier.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
type.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
expressions.map {|e| e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_copy\n QueryList.new(queries.map {|q| q.deep_copy})\n end",
"def deep_copy\n QueryList.new(queries.map {|q| q.deep_copy})\n end",
"def clone\n q = super\n q.attrs = self.attrs.clone\n return q\n end",
"def deep_copy\n Query.new(\n modifier.map {|c| c.is_... | [
"0.75652254",
"0.75652254",
"0.72111434",
"0.6724821",
"0.6652218",
"0.65483296",
"0.6526057",
"0.65101665",
"0.6416113",
"0.6393255",
"0.62028533",
"0.6183667",
"0.6183667",
"0.6167999",
"0.6119969",
"0.61152375",
"0.6106077",
"0.6083217",
"0.59995073",
"0.5968258",
"0.59321... | 0.7017192 | 3 |
solution number 2 with bitwise XOR operator | def stray(numbers)
numbers.reduce(&:^)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xor_b\n end",
"def xor(a,b)\n (a | b) - (a & b)\n end",
"def xor_c\n end",
"def xor(x, y)\n\nend",
"def xor_l\n end",
"def xor_e\n end",
"def xor_d\n end",
"def xor_a\n end",
"def xor_d8\n end",
"def xor(argument1, argument2)\n argument1 && !argument2... | [
"0.7760825",
"0.7709126",
"0.7590266",
"0.75561017",
"0.750193",
"0.74455273",
"0.7440278",
"0.74336374",
"0.7238307",
"0.72370285",
"0.70961106",
"0.70602673",
"0.7036923",
"0.7026291",
"0.70116496",
"0.7010116",
"0.6998041",
"0.69966793",
"0.6978643",
"0.69718885",
"0.69609... | 0.0 | -1 |
GET /accounting_actions GET /accounting_actions.json | def index
@q = AccountingAction.ransack(params[:q])
@accounting_actions = @q.result(distinct: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @accounting_entries = AccountingEntry.all\n\n authorize AccountingEntry\n end",
"def actions\n return @actions if @actions\n @actions = Client.get(\"/organizations/#{id}/actions\").json_into(Action)\n end",
"def index\n @wallet_actions = WalletAction.all\n end",
"def set_a... | [
"0.6761725",
"0.660253",
"0.65338796",
"0.6523973",
"0.6495803",
"0.63214195",
"0.6217173",
"0.61983156",
"0.612494",
"0.6096261",
"0.60802764",
"0.60781306",
"0.60246146",
"0.5999102",
"0.59821355",
"0.59202373",
"0.5909086",
"0.59068245",
"0.58836776",
"0.58461237",
"0.5804... | 0.70398366 | 0 |
GET /accounting_actions/1 GET /accounting_actions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @q = AccountingAction.ransack(params[:q])\n @accounting_actions = @q.result(distinct: true)\n end",
"def set_accounting_action\n @accounting_action = AccountingAction.find(params[:id])\n end",
"def index\n @accounting_entries = AccountingEntry.all\n\n authorize AccountingEntry\... | [
"0.6820698",
"0.6751092",
"0.6464188",
"0.6462399",
"0.63931745",
"0.63807964",
"0.6253348",
"0.61621183",
"0.6077183",
"0.6070772",
"0.6046184",
"0.60236084",
"0.6017479",
"0.5997635",
"0.5943969",
"0.5914122",
"0.5914122",
"0.58570606",
"0.58531004",
"0.5845312",
"0.584212"... | 0.0 | -1 |
POST /accounting_actions POST /accounting_actions.json | def create
@accounting_action = AccountingAction.new(accounting_action_params)
respond_to do |format|
if @accounting_action.save
format.html { redirect_to @accounting_action, notice: 'Ação foi criada com sucesso.' }
format.json { render :show, status: :created, location: @accounting_action }
else
format.html { render :new }
format.json { render json: @accounting_action.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accounting_action_params\n params.require(:accounting_action).permit(:codigo, :descricao, :exercise_id)\n end",
"def set_accounting_action\n @accounting_action = AccountingAction.find(params[:id])\n end",
"def collection_post_action(action)\n action = action.to_s.gsub('bulk_', '').to_s... | [
"0.6284859",
"0.626547",
"0.5944006",
"0.58842224",
"0.5829392",
"0.58125216",
"0.57616407",
"0.5703602",
"0.5680716",
"0.56638485",
"0.56456524",
"0.56299907",
"0.55586106",
"0.5556023",
"0.5502889",
"0.54391885",
"0.54363555",
"0.54347336",
"0.542592",
"0.5409714",
"0.54069... | 0.68680024 | 0 |
PATCH/PUT /accounting_actions/1 PATCH/PUT /accounting_actions/1.json | def update
respond_to do |format|
if @accounting_action.update(accounting_action_params)
format.html { redirect_to @accounting_action, notice: 'Ação foi atualizada com sucesso.' }
format.json { render :show, status: :ok, location: @accounting_action }
else
format.html { render :edit }
format.json { render json: @accounting_action.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n head :forbidden\n\n #@action = Action.find(params[:id])\n\n #if @action.update_attributes(params[:action])\n # head :no_content\n # else\n # render json: @action.errors, status: :unprocessable_entity\n # end\n end",
"def patch(action, **args); end",
"def update\n @payab... | [
"0.6559312",
"0.6180124",
"0.61647856",
"0.61513054",
"0.61207145",
"0.60961133",
"0.6085956",
"0.60728",
"0.6069418",
"0.60690975",
"0.60685164",
"0.60589963",
"0.6055047",
"0.60198826",
"0.60186505",
"0.601076",
"0.5995826",
"0.5948335",
"0.59387714",
"0.59358305",
"0.59310... | 0.69639516 | 0 |
DELETE /accounting_actions/1 DELETE /accounting_actions/1.json | def destroy
@accounting_action.destroy
respond_to do |format|
format.html { redirect_to accounting_actions_url, notice: 'Ação foi destruída com sucesso.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end",
"def delete(action, **args); end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def api_delete(action, data)\n api_request(action, data, 'DELETE')\n end",
"def incident_delete(sta... | [
"0.7379961",
"0.68510187",
"0.6750856",
"0.67353356",
"0.6643555",
"0.66296476",
"0.66043776",
"0.6600791",
"0.6600791",
"0.6593604",
"0.6579225",
"0.65561295",
"0.65194035",
"0.6510677",
"0.6510677",
"0.6510677",
"0.6510677",
"0.6507833",
"0.6506663",
"0.6498255",
"0.6485366... | 0.72398055 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_accounting_action
@accounting_action = AccountingAction.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 accounting_action_params
params.require(:accounting_action).permit(:codigo, :descricao, :exercise_id)
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.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
GET /facultads GET /facultads.json | def index
@facultads = Facultad.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ads = Ad.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end",
"def index\n @ads = Ad.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ads }\n end\n end",
"def... | [
"0.66060245",
"0.6595312",
"0.6508431",
"0.6376407",
"0.6260962",
"0.6250794",
"0.6207674",
"0.6201946",
"0.619315",
"0.619315",
"0.619315",
"0.6184212",
"0.61769783",
"0.6137919",
"0.611267",
"0.61098826",
"0.6099774",
"0.60900086",
"0.6081118",
"0.6073202",
"0.60653996",
... | 0.72913426 | 0 |
GET /facultads/1 GET /facultads/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @facultads = Facultad.all\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ad }\n end\n end",
"def show\n @ad = Ad.find(params[:id])\n\n respond_to do |format|\n format.html # sho... | [
"0.7070108",
"0.6730687",
"0.6730687",
"0.6730687",
"0.6633119",
"0.6617508",
"0.6455344",
"0.6397225",
"0.6388993",
"0.63712746",
"0.63526756",
"0.6316881",
"0.6288255",
"0.62807703",
"0.6263859",
"0.6259303",
"0.6213569",
"0.62095803",
"0.62015563",
"0.6193738",
"0.61843807... | 0.0 | -1 |
POST /facultads POST /facultads.json | def create
@facultad = Facultad.new(facultad_params)
respond_to do |format|
if @facultad.save
format.html { redirect_to @facultad, notice: 'Facultad was successfully created.' }
format.json { render :show, status: :created, location: @facultad }
else
format.html { render :new }
format.json { render json: @facultad.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @facultad = Facultad.new(facultad_params)\n\n respond_to do |format|\n if @facultad.save\n format.html { redirect_to facultade_path(@facultad), notice: \"Facultad fue creada correctamente.\" }\n format.json { render :show, status: :created, location: @facultad }\n else\n ... | [
"0.65177464",
"0.631646",
"0.6312829",
"0.62912595",
"0.6236799",
"0.6200291",
"0.6165413",
"0.60846835",
"0.60358524",
"0.6008719",
"0.60035914",
"0.5994915",
"0.5886182",
"0.58849823",
"0.58768916",
"0.5853262",
"0.58451164",
"0.5837635",
"0.5834386",
"0.5811399",
"0.580471... | 0.6584896 | 0 |
PATCH/PUT /facultads/1 PATCH/PUT /facultads/1.json | def update
respond_to do |format|
if @facultad.update(facultad_params)
format.html { redirect_to @facultad, notice: 'Facultad was successfully updated.' }
format.json { render :show, status: :ok, location: @facultad }
else
format.html { render :edit }
format.json { render json: @facultad.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @facult.update(facult_params)\n format.html { redirect_to @facult, notice: 'Facult was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @facult.er... | [
"0.66114604",
"0.65853953",
"0.6457552",
"0.6439625",
"0.6432518",
"0.6423681",
"0.6365431",
"0.63600934",
"0.63593006",
"0.6349805",
"0.6325292",
"0.631922",
"0.631922",
"0.63149345",
"0.63098145",
"0.63076884",
"0.6291455",
"0.62908506",
"0.6287608",
"0.6283915",
"0.6268649... | 0.6741723 | 0 |
DELETE /facultads/1 DELETE /facultads/1.json | def destroy
@facultad.destroy
respond_to do |format|
format.html { redirect_to facultads_url, notice: 'Facultad was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @ad = Ad.find(params[:id])\n @ad.destroy\nrender json: 1\n end",
"def destroy\n @facult.destroy\n respond_to do |format|\n format.html { redirect_to facults_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad = Ad.find(params[:id])\n @ad.dest... | [
"0.721781",
"0.7063725",
"0.70537746",
"0.7037346",
"0.70180774",
"0.6994423",
"0.6971863",
"0.6966238",
"0.69628984",
"0.6944445",
"0.69440275",
"0.6929412",
"0.69126105",
"0.6891235",
"0.68901837",
"0.68723595",
"0.6872174",
"0.6868168",
"0.68680644",
"0.68605125",
"0.68458... | 0.7341869 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_facultad
@facultad = Facultad.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 facultad_params
params.require(:facultad).permit(:Nombre_facultad, :Direccion)
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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
01/01/2015 Sample code to list instances from Atlantic.net using Ruby | def list_instances
puts "OK, Listing instances.."
response = RestClient.post(
$uri,
'Version' => '2010-12-30',
'ACSAccessKeyId' => $ACSAccessKeyId,
'Format' => 'json',
'Timestamp' => $current_time,
'Rndguid' => $rndguid,
'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),
'Action' => "list-instances")
puts response
puts response.code
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instances; end",
"def instances; end",
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def list\n attrcheck = { 'compartment' => @options[:compartment] }\n @validat... | [
"0.59593034",
"0.59593034",
"0.59511757",
"0.5877539",
"0.57154125",
"0.560014",
"0.55762017",
"0.55451024",
"0.55445963",
"0.55358726",
"0.5522449",
"0.5522449",
"0.5511502",
"0.5506903",
"0.54855984",
"0.54754263",
"0.5474711",
"0.5456025",
"0.54385316",
"0.5430289",
"0.542... | 0.57979727 | 4 |
Prepares the UID/GID settings for a single folder. | def prepare_permission(machine, perm, opts)
key = "map_#{perm}".to_sym
return nil if opts.has_key?(key) && opts[key].nil?
# The options on the hash get priority, then the default
# values
value = opts.has_key?(key) ? opts[key] : machine.config.nfs.send(key)
return value if value != :auto
# Get UID/GID from guests user if we've made it this far
# (value == :auto)
return machine.guest.capability("read_#{perm}".to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def folder_data\n @folder_data ||= Unan::folder_data + \"user/#{id}\"\n end",
"def nfs_opts_setup()\n @folders.each do |k, opts|\n if !opts[:linux__nfs_options]\n opts[:linux__nfs_options] ||= [\"rw\", \"no_subtree_check\", \"all_squash\", \"insecure\"]\n e... | [
"0.6155748",
"0.591959",
"0.5774387",
"0.574445",
"0.56300026",
"0.55959296",
"0.5515075",
"0.54770964",
"0.54734045",
"0.54668486",
"0.545837",
"0.5449234",
"0.5424296",
"0.5412621",
"0.5410193",
"0.5410193",
"0.5410193",
"0.5410193",
"0.5410193",
"0.5410193",
"0.5410193",
... | 0.0 | -1 |
I can't decide whether this is clever or really dirty just to satisfy authorities_service_spec.rb Pros: It is a legitimate comparison for this object in its current conception. Cons: makes the code slightly less maintainable and harder to extend extra thing to think about if this object needs to be changed. | def == other_authority
same_name_and_id = @name == other_authority.name && @id == other_authority.id
unless (@filename.nil? && other_authority.filename.nil?)
return same_name_and_id && @filename == other_authority.filename
end
same_name_and_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n access_token_strategy == o.access_token_strategy &&\n allowed_cors_origins == o.allowed_cors_origins &&\n audience == o.audience &&\n authorization_code_grant_access_token_lifespan == o.authorizatio... | [
"0.5884113",
"0.57734025",
"0.57579345",
"0.56387544",
"0.56277317",
"0.5547639",
"0.5523812",
"0.54792064",
"0.5468909",
"0.5465693",
"0.5452924",
"0.54393137",
"0.5439201",
"0.5380313",
"0.5369564",
"0.5328425",
"0.5304993",
"0.52943856",
"0.5293179",
"0.5289431",
"0.528203... | 0.0 | -1 |
Redirect to the stored path or a default | def redirect_to_stored(default='/')
return_to = session[:return_to] || default
session[:return_to] = nil
redirect return_to
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_path(name, default = nil)\n stored_redirect_path(name) || default || root_path\n end",
"def redirect_back_or_default(default)\n redirect_to(... | [
"0.7685314",
"0.74524176",
"0.7273553",
"0.7263497",
"0.7078865",
"0.69759434",
"0.6954229",
"0.68746746",
"0.6843526",
"0.6836822",
"0.68191373",
"0.6817303",
"0.6790331",
"0.6761267",
"0.67529535",
"0.6739468",
"0.67341745",
"0.67171645",
"0.671073",
"0.67013484",
"0.669695... | 0.7871603 | 0 |
Automatically detect a URLMapped Rack application and prepend the correct prefix before sending the redirect | def redirect(location, *args)
unless request.path == request.path_info
path = request.path.split('/')
info = request.path_info.split('/')
prefix = (path - info).join('/')
location = File.join('/', prefix, location)
end
super(location, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_full_path_name\n if request.fullpath.match(/^\\/[trg]$/)\n redirect_to \"/#{Blog.translate_context_to_route(@context)}\", :status => '301'\n elsif request.fullpath.match(/^\\/s$/)\n redirect_to \"/real-estate-spotlight\", :status => '301'\n end\n end",
"def fixup_url\n unless @v... | [
"0.57018113",
"0.56810373",
"0.5668323",
"0.5636792",
"0.5613893",
"0.558237",
"0.55177534",
"0.55115724",
"0.5461647",
"0.54175335",
"0.5415657",
"0.5414016",
"0.540368",
"0.53591543",
"0.53413856",
"0.5325551",
"0.53238803",
"0.5306657",
"0.5300654",
"0.5280809",
"0.5263909... | 0.5407507 | 12 |
override to allow for using slug as id | def verify_key(key, context = nil)
key && String(key)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n slug\n end",
"def id\n object.slug\n end",
"def id\n object.slug\n end",
"def slug_base_string\n self.id || sluggify\n end",
"def to_param\n slug || id\n end",
"def to_param\n slug ? slug.to_friendly_id : id.to_s\n end",
"def normalize_friendly_id(string)\n if slug.b... | [
"0.8369108",
"0.7882107",
"0.7882107",
"0.7860176",
"0.7826516",
"0.780266",
"0.75388557",
"0.75356805",
"0.7533118",
"0.74925786",
"0.74925786",
"0.74925786",
"0.7432156",
"0.7432156",
"0.73919153",
"0.73794067",
"0.73794067",
"0.7358023",
"0.7305277",
"0.7305277",
"0.730527... | 0.0 | -1 |
The bearer token that can be used directly in API request headers | def bearer_token
"Bearer #{token}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bearer_token(token)\n @header.merge!({ 'Authorization' => \"Bearer #{token}\" })\n end",
"def bearer_auth_header\n \"Bearer #{access_token}\"\n end",
"def bearer_authorization_header\n if token && token['access_token']\n {AUTHORIZATION => \"Bearer #{token['access_token']}\"}... | [
"0.87099963",
"0.8669175",
"0.8514714",
"0.85004777",
"0.82622635",
"0.81969756",
"0.8128076",
"0.8125128",
"0.809818",
"0.8065219",
"0.8041136",
"0.8013682",
"0.7991964",
"0.79799247",
"0.79799247",
"0.7966171",
"0.7955397",
"0.79262006",
"0.7925171",
"0.7919325",
"0.7856909... | 0.8805196 | 0 |
Returns the access token if it is still valid, or refreshes it if it is not (or about to expire) | def token
return @access_token if @access_token && !needs_refresh?
update_access_token
@access_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_access_token\n\t\t\t\t# The token we have stored is expired - fetch a new one using the refresh token\n\t\t\t\tself.refresh_access_token if self.access_token_expired?\n\n\t\t\t\tself.access_token\n\t\t\tend",
"def valid_access_token\n self.access_token_expired? ? self.refresh_access_token! : self.ac... | [
"0.8641398",
"0.8559956",
"0.85573274",
"0.82309383",
"0.81023806",
"0.80696386",
"0.8045107",
"0.78940094",
"0.78896165",
"0.7755664",
"0.77240986",
"0.75344205",
"0.74539703",
"0.7366186",
"0.7357246",
"0.73560435",
"0.7340601",
"0.72907376",
"0.7268342",
"0.7219535",
"0.71... | 0.77385294 | 10 |
Checks if the token needs a refesh by checking if the token is nil or (about to) expire(d) | def needs_refresh?
@access_token.nil? ||
(Time.now + TOKEN_BUFFER) > @expires_at
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_expired?\n @token.nil? || Time.now >= @token_expires_on + expiration_threshold\n end",
"def token_expired\n @token.nil? || Time.now >= @token_expires_on + expiration_threshold\n end",
"def token_expired?\n return true\n expires_at < Time.now if expires_at?\n end",
"def token_... | [
"0.77848905",
"0.77534103",
"0.7365735",
"0.7357167",
"0.7348214",
"0.7289499",
"0.7273703",
"0.72273326",
"0.71565",
"0.7098255",
"0.70725983",
"0.70725983",
"0.70694137",
"0.7040754",
"0.699659",
"0.69791883",
"0.6956492",
"0.69498557",
"0.694866",
"0.6942055",
"0.6921797",... | 0.69156355 | 21 |
Fetches a new access token and stores it and its expiry date | def update_access_token
response = fetch_access_token
store_access_token(response.result)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fresh_token\n refresh! if expired?\n access_token\n end",
"def fresh_token\n refresh! if token_expired?\n access_token\n end",
"def refresh_access_token\n new_token = FireCloudClient.generate_access_token(self.service_account_credentials)\n new_expiry = Time.zone.now + new_token['expire... | [
"0.7862805",
"0.78125745",
"0.78091955",
"0.77942175",
"0.77459115",
"0.7533844",
"0.75099",
"0.75034916",
"0.7409117",
"0.73745674",
"0.73525053",
"0.733773",
"0.73235583",
"0.73169035",
"0.7205781",
"0.7152392",
"0.7148212",
"0.71401495",
"0.71336514",
"0.7132626",
"0.71221... | 0.76162064 | 5 |
Fetches a new access token | def fetch_access_token
client.unauthenticated_request(:POST, '/v1/security/oauth2/token',
grant_type: 'client_credentials',
client_id: client.client_id,
client_secret: client.client_secret)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fresh_token\n refresh! if token_expired?\n access_token\n end",
"def update_token\n client.authorization.update_token!(oauth_data)\n if client.authorization.refresh_token && client.authorization.expired?\n client.authorization.fetch_access_token!\n end\n end",
"def fresh_tok... | [
"0.77791345",
"0.7716003",
"0.7706114",
"0.76284635",
"0.76284397",
"0.7589101",
"0.7462341",
"0.7450183",
"0.7437448",
"0.7434031",
"0.74107265",
"0.7403465",
"0.7371638",
"0.7363965",
"0.7320902",
"0.7306013",
"0.72838026",
"0.72780585",
"0.7252591",
"0.72446483",
"0.722489... | 0.74952424 | 6 |
Store an access token and calculates the expiry date | def store_access_token(data)
@access_token = data['access_token']
@expires_at = Time.now + data['expires_in']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_access_token\n self.expires_at = Time.now + 3600 \n save\n end",
"def access_token_expires\n return nil unless (temp_access_token_expires = read_attribute(:access_token_expires))\n # logger.debug2 \"temp_access_token_expires = #{temp_access_token_expires}\"\n encrypt_remove_pre_and... | [
"0.75884575",
"0.7466272",
"0.7466272",
"0.74192274",
"0.7403891",
"0.73633766",
"0.7249434",
"0.7160198",
"0.7129825",
"0.7110655",
"0.70820415",
"0.70564413",
"0.7045412",
"0.69969326",
"0.69928527",
"0.69101036",
"0.6870241",
"0.6809017",
"0.6788108",
"0.6788108",
"0.67706... | 0.812647 | 0 |
JSON method for listing/unlisting course | def list
@course = find_course_by_slug(params[:id])
cohort = Cohort.find_by(title: cohort_params[:title])
unless cohort
render json: {
message: "Sorry, #{cohort_params[:title]} is not a valid cohort."
}, status: 404
return
end
ListCourseManager.new(@course, cohort, request).manage
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @course\n end",
"def show\n render json: course\n end",
"def course\n\t\t@course = Course.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respo... | [
"0.7265224",
"0.7218653",
"0.71860796",
"0.7105367",
"0.70431274",
"0.7003885",
"0.69818217",
"0.6977082",
"0.68863916",
"0.68660736",
"0.68660736",
"0.6859482",
"0.6853806",
"0.67557496",
"0.67463326",
"0.67200017",
"0.6648524",
"0.66350806",
"0.66322565",
"0.6601128",
"0.65... | 0.0 | -1 |
GET /egresos GET /egresos.json | def index
@egresos = Egreso.all.paginate(:per_page => 4, :page => params[:page])
if params[:fecha_fin] == nil || params[:fecha_fin] == ""
params[:fecha_fin]=Date.today
@egresos = Egreso.order("fecha DESC").paginate(:per_page => 4, :page => params[:page]).where("fecha <= ?", params[:fecha_fin].to_date)
else
if params[:fecha_inicio] != nil && params[:fecha_fin] != nil
@egresos = Egreso.order("fecha DESC").paginate(:per_page => 4, :page => params[:page]).where("fecha >= ? and fecha <= ?", params[:fecha_inicio].to_date, params[:fecha_fin].to_date)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @ores = Ore.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ores }\n end\n end",
"def index\n @ordenes = Orden.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ordenes }\n ... | [
"0.6681978",
"0.649372",
"0.6453615",
"0.64527774",
"0.63053507",
"0.62851405",
"0.62781173",
"0.62663895",
"0.6256521",
"0.6237189",
"0.62178934",
"0.6208452",
"0.6179376",
"0.61765134",
"0.61563206",
"0.61477417",
"0.61129606",
"0.6085213",
"0.6040708",
"0.60372585",
"0.603... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.