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 |
|---|---|---|---|---|---|---|
End Method: Delete Method:search | def search
@query = params[:query]
@wards = Ward.search @query, :page => params[:page], :per_page => 10
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search\n end",
"def search \n\n end",
"def search\n\n end",
"def search; end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\... | [
"0.7548457",
"0.7508332",
"0.7452624",
"0.7452585",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.74480504",
"0.73854023",
"0.73747945",
"0.73590827",
"0.7275584",
"0.67185986",
"0.6640643",
"0... | 0.0 | -1 |
End:search method: Report Generation | def wardreport
@wards = Ward.find(:all)
html = render :layout => false
kit = PDFKit.new(html)
kit.stylesheets << RAILS_ROOT + '/public/stylesheets/styles.css'
send_data(kit.to_pdf, :filename => "wardreport.pdf", :type => 'application/pdf')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report\n\t\tend",
"def report\n \n end",
"def write_report\n\n end",
"def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutp... | [
"0.79120684",
"0.79120684",
"0.79120684",
"0.79120684",
"0.79120684",
"0.749927",
"0.74716115",
"0.71795744",
"0.6927922",
"0.6701208",
"0.6614777",
"0.6534684",
"0.65137124",
"0.6450949",
"0.6378863",
"0.63788235",
"0.63788235",
"0.6353773",
"0.6348502",
"0.6322957",
"0.6300... | 0.0 | -1 |
12. Opening two files with double_open | def double_open(first, second)
open(first) do |f1|
open(second) do |f2|
until f1.eof? or f2.eof?
yield f1, f2
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def double_open filename1, filename2\n open( filename1 ) do |f1|\n open( filename2 ) do |f2|\n yield f1, f2\n end\n end\nend",
"def compare_file(a, b)\r\n return false unless File.size(a) == File.size(b)\r\n File.open(a, 'rb') {|fa|\r\n File.open(b, 'rb') {|fb|\r\n return compare_s... | [
"0.843787",
"0.5975874",
"0.5948317",
"0.5943479",
"0.5926213",
"0.5741442",
"0.57233196",
"0.5595898",
"0.5580995",
"0.5580995",
"0.5580995",
"0.551922",
"0.5505091",
"0.54963064",
"0.54666215",
"0.5460171",
"0.54436195",
"0.5439831",
"0.54186344",
"0.5392027",
"0.5390843",
... | 0.810713 | 1 |
Make sure newattr handles required features correctly. | def test_newattr_and_required_features
# Make a type with some features
type = mktype
type.feature :fone, "Something"
type.feature :ftwo, "Something else"
type.newparam(:name) {}
# Make three properties: one with no requirements, one with one, and one with two
none = type.newproperty(:none) {}
one = type.newproperty(:one, :required_features => :fone) {}
two = type.newproperty(:two, :required_features => [:fone, :ftwo]) {}
# Now make similar providers
nope = type.provide(:nope) {}
maybe = type.provide(:maybe) { has_feature :fone}
yep = type.provide(:yep) { has_features :fone, :ftwo}
attrs = [:none, :one, :two]
# Now make sure that we get warnings and no properties in those cases where our providers do not support the features requested
[nope, maybe, yep].each_with_index do |prov, i|
resource = type.new(:provider => prov.name, :name => "test#{i}", :none => "a", :one => "b", :two => "c")
case prov.name
when :nope
yes = [:none]
no = [:one, :two]
when :maybe
yes = [:none, :one]
no = [:two]
when :yep
yes = [:none, :one, :two]
no = []
end
yes.each { |a| assert(resource.should(a), "Did not get value for #{a} in #{prov.name}") }
no.each do |a|
assert_nil(resource.should(a), "Got value for unsupported %s in %s" % [a, prov.name])
if Puppet::Util::Log.sendlevel?(:info)
assert(@logs.find { |l| l.message =~ /not managing attribute #{a}/ and l.level == :debug }, "No warning about failed %s" % a)
end
end
@logs.clear
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_old_attributes!\n unless node['build_essential'].nil?\n Chef::Log.warn <<-EOH\nnode['build_essential'] has been changed to node['build-essential'] to match the\ncookbook name and community standards. I have gracefully converted the attribute\nfor you, but this warning and conversion will ... | [
"0.65315807",
"0.63309616",
"0.6277827",
"0.61755395",
"0.61755395",
"0.60566485",
"0.60518825",
"0.5913943",
"0.58840096",
"0.5821686",
"0.57761514",
"0.57496905",
"0.57213974",
"0.5704856",
"0.5640651",
"0.55847126",
"0.5548127",
"0.5532438",
"0.5514481",
"0.55018044",
"0.5... | 0.71580374 | 0 |
Make sure the 'check' metaparam just ignores nonproperties, rather than failing. | def test_check_allows_parameters
file = Puppet::Type.type(:file)
klass = file.attrclass(:check)
resource = file.new(:path => tempfile)
inst = klass.new(:resource => resource)
{:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs|
assert_nothing_raised("Could not set check to a single #{attrtype} value") do
inst.value = attrs[0]
end
if attrtype == :property
assert(resource.property(attrs[0]), "Check did not create property instance during single check")
end
assert_nothing_raised("Could not set check to multiple #{attrtype} values") do
inst.value = attrs
end
if attrtype == :property
assert(resource.property(attrs[1]), "Check did not create property instance during multiple check")
end
end
# But make sure actually invalid attributes fail
assert_raise(Puppet::Error, ":check did not fail on invalid attribute") do
inst.value = :nosuchattr
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def property_checks\n errors.add(:base, \"You can't have a Thing without properties\") if property_keys.empty?\n\n self.property_keys.each do |key|\n errors.add(:properties, \"'#{key}' is an invalid property for this List\") unless available_property_keys.include?(key)\n end\n end",
"def complete_... | [
"0.66893196",
"0.6668856",
"0.6270437",
"0.62491965",
"0.62491965",
"0.62241244",
"0.6138547",
"0.6045893",
"0.6044393",
"0.60154456",
"0.59875864",
"0.5949148",
"0.5921843",
"0.5914604",
"0.5914604",
"0.5865721",
"0.58511627",
"0.57901496",
"0.5771006",
"0.5756976",
"0.57294... | 0.71518445 | 0 |
build and return +EventSource+ instance, ready for pushing out data or named events. checks accept header in the request, then responds with valid headers for beginning an SSE stream | def initialize stream:, headers: {}
@closed = false
@stream = stream
@parser = @stream.stream
@headers = headers
@gzip = false
@deflate = false
check_accept_header
check_accept_encoding
init_response
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_response\n headers = SSE_HEADER.merge @headers\n @parser.headers stringify_headers(headers)\n rescue ::HTTP2::Error::StreamClosed\n @stream.log :warn, \"stream closed early by client\"\n end",
"def start\n super\n log.trace \"splunk-http-eventcollector(star... | [
"0.64046067",
"0.5482215",
"0.54251885",
"0.52875096",
"0.5285375",
"0.5283788",
"0.5279608",
"0.51758975",
"0.51758975",
"0.51741457",
"0.516801",
"0.5125665",
"0.51073194",
"0.5074401",
"0.49345782",
"0.49215254",
"0.48731032",
"0.48600584",
"0.48571447",
"0.48422855",
"0.4... | 0.4682037 | 34 |
checks the request for acceptencoding headers and processes data & events accordingly | def check_accept_encoding
if accept = @stream.request.headers[ACCEPT_ENCODING_KEY]
accept.split(',').map(&:strip).each do |encoding|
case encoding
when GZIP_ENCODING
if @stream.connection.server.options[:gzip]
@gzip = true
@headers[CONTENT_ENCODING_KEY] = GZIP_ENCODING
break
end
# "deflate" has issues: https://zlib.net/zlib_faq.html#faq39
#
when DEFLATE_ENCODING
if @stream.connection.server.options[:deflate]
@deflate = true
@headers[CONTENT_ENCODING_KEY] = DEFLATE_ENCODING
break
end
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_encoding_hooks; end",
"def content_encoding_hooks; end",
"def enforce_accept(request, config)\n return unless request.accept_header?\n\n accept_types = ::Rack::Utils.q_values(request.accept).map(&:first)\n return if accept_types.any? { |mime_type| accepted_mime_type?(mime... | [
"0.6471714",
"0.6471714",
"0.6263065",
"0.6044916",
"0.6044916",
"0.6006868",
"0.59987044",
"0.5911975",
"0.58943343",
"0.58575684",
"0.5829048",
"0.58235013",
"0.575923",
"0.57305735",
"0.5687982",
"0.5674869",
"0.5646535",
"0.56024736",
"0.5570853",
"0.5569836",
"0.55286837... | 0.77638584 | 0 |
responds with SSE headers on this stream | def init_response
headers = SSE_HEADER.merge @headers
@parser.headers stringify_headers(headers)
rescue ::HTTP2::Error::StreamClosed
@stream.log :warn, "stream closed early by client"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def headers; end",
"def processed_headers; end",
"def raw_headers; end",
"def send_stream_header\n feature... | [
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.62162983",
"0.6183462",
"0.61682683",
"0.60528296",
"0.60412073",
"0.60171366",
"0.5926392",
"0.5898968",
"0.58911484",
"0.57668746",
"0.5733",
"0.... | 0.6824582 | 0 |
emit a final frame on this stream with +end_stream+ flag | def close
@parser.data ''
@closed = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emit_end\n @end_callback.call unless @end_callback.nil?\n end",
"def close\n send(\"</stream:stream>\")\n super\n end",
"def feed_end()\n @appsrc.end_of_stream()\n end",
"def end_frame\n end",
"def emit_eof\n logger.debug \"Emiting EOF: #{self.class.name} -> #{@_o... | [
"0.6465255",
"0.64343613",
"0.63910806",
"0.6331243",
"0.629446",
"0.628922",
"0.6245586",
"0.6239629",
"0.6226772",
"0.61892563",
"0.61723673",
"0.6049661",
"0.5853853",
"0.5841136",
"0.57939994",
"0.5766453",
"0.5760053",
"0.57142985",
"0.5673068",
"0.56678253",
"0.5667159"... | 0.0 | -1 |
contentencoding helper for event and data methods | def encode_content str
str = ::Zlib.gzip str if @gzip
str = ::Zlib.deflate str if @deflate
str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_encoding_hooks; end",
"def content_encoding_hooks; end",
"def convert_encoding(content); end",
"def encode_event(exi_event)\n end",
"def encode\n @content.serialize_to_string\n end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
"def encoding; end",
... | [
"0.71298134",
"0.71298134",
"0.666948",
"0.6560059",
"0.63908714",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
"0.63841146",
... | 0.0 | -1 |
Backported from: ...to support running the installer w/ Ruby 1.8.7 | def shellescape(str)
# An empty argument will be skipped, so return empty quotes.
return "''" if str.empty?
str = str.dup
# Treat multibyte characters as is. It is caller's responsibility
# to encode the string in the right encoding for the shell
# environment.
str.gsub!(/([^A-Za-z0-9_\-.,:\/@\n])/, "\\\\\\1")
# A LF cannot be escaped with a backslash because a backslash + LF
# combo is regarded as line continuation and simply ignored.
str.gsub!(/\n/, "'\n'")
return str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install\n #python executable files\n end",
"def install_ruby\n # remove the bootstrap version of ruby to install the best available one.\n remove_packages %w(ruby ruby1.8 ruby1.9.1 ruby2.0)\n install_ruby_20 || install_ruby_19\n end",
"def install\n bin.install \"java-switcher\"\n end",
... | [
"0.6392192",
"0.6363796",
"0.62169504",
"0.61029935",
"0.5997243",
"0.5865469",
"0.5862594",
"0.58615464",
"0.58413416",
"0.57999766",
"0.57990474",
"0.5783423",
"0.5769544",
"0.57621574",
"0.5750842",
"0.5747436",
"0.57397974",
"0.5736989",
"0.57287747",
"0.57199025",
"0.571... | 0.0 | -1 |
copied from and modified | def fork_and_run(job, &block)
# run a job in forked child and retrieve the results into the job object.
r, w = IO.pipe
pid = fork do
r.close
result = block.call
Marshal.dump(result, w)
exit!(0) # skips exit handlers.
end
w.close
job[:result] = r
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy\n \n end",
"def copy(from, to)\n \n end",
"def copy_to(other); end",
"def copy_list \n\n\tend",
"def copy_from(original)\n self.template = original.template\n self.position = original.position\n self.data = original.data\n self\n end",
"def copy... | [
"0.7485452",
"0.7252765",
"0.6946347",
"0.6858209",
"0.68208855",
"0.67226845",
"0.670594",
"0.670594",
"0.670594",
"0.67051333",
"0.67051333",
"0.6703947",
"0.666714",
"0.66589046",
"0.66021514",
"0.66021514",
"0.66021514",
"0.66021514",
"0.66021514",
"0.65924233",
"0.659137... | 0.0 | -1 |
Staggered Caps (Part 2) exercise Small Problems exercises from LaunchSchool | def staggered_case1(str)
staggered_chars = str.chars.map.with_index do |char, index|
index.even? ? char.upcase : char.downcase
end
staggered_chars.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hamstrings_stretch\n \"Remaining seated, extend one leg outward. Reach toward your toes. Hold for 10 to 30 seconds. Repeat on the other side. Be sure to do this one leg at a time, as doing this exercise with both legs out can cause back issues.\"\nend",
"def swasify(word)\r\n word = word.upcase.gsub(' ',... | [
"0.64340276",
"0.64089364",
"0.60715616",
"0.60508204",
"0.60036665",
"0.5945557",
"0.5929478",
"0.5882539",
"0.5864406",
"0.5840242",
"0.58308476",
"0.58161104",
"0.58132684",
"0.5804645",
"0.5793284",
"0.57899606",
"0.5728999",
"0.5714881",
"0.5699537",
"0.5690973",
"0.5626... | 0.5394277 | 56 |
============================================================================= Initialization of the battle scene ============================================================================= | def pbLoadUIElements(battle)
if USENEWUI
@sprites["battlebox0"]=PokemonNewDataBox.new(battle.battlers[0],battle.doublebattle,@viewport,battle.pbPlayer)
@sprites["battlebox1"]=PokemonNewDataBox.new(battle.battlers[1],battle.doublebattle,@viewport,battle.pbPlayer)
if battle.doublebattle
@sprites["battlebox2"]=PokemonNewDataBox.new(battle.battlers[2],battle.doublebattle,@viewport,battle.pbPlayer)
@sprites["battlebox3"]=PokemonNewDataBox.new(battle.battlers[3],battle.doublebattle,@viewport,battle.pbPlayer)
end
pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/newBattleMessageBox",@viewport)
@sprites["messagebox"].z=90
@sprites["messagebox"].visible=false
@sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].z=90
@sprites["messagewindow"]=Window_AdvancedTextPokemon.new("")
@sprites["messagewindow"].letterbyletter=true
@sprites["messagewindow"].viewport=@viewport
@sprites["messagewindow"].z=100
@sprites["commandwindow"]=CommandMenuDisplay.new(@viewport) # Retained for compatibility
@sprites["commandwindow"].visible=false # Retained for compatibility
@sprites["fightwindow"]=FightMenuDisplay.new(nil,@viewport) # Retained for compatibility
@sprites["fightwindow"].visible=false # Retained for compatibility
@commandWindow=NewCommandWindow.new(@viewport,@battle)
@fightWindow=NewFightWindow.new(@viewport)
10.times do
@commandWindow.hide
@fightWindow.hide
end
else
@sprites["battlebox0"]=PokemonDataBox.new(battle.battlers[0],battle.doublebattle,@viewport)
@sprites["battlebox1"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)
if battle.doublebattle
@sprites["battlebox2"]=PokemonDataBox.new(battle.battlers[2],battle.doublebattle,@viewport)
@sprites["battlebox3"]=PokemonDataBox.new(battle.battlers[3],battle.doublebattle,@viewport)
end
pbAddSprite("messagebox",0,Graphics.height-96,"Graphics/Pictures/battleMessage",@viewport)
@sprites["messagebox"].z=90
@sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize("",0,0,32,32,@viewport)
@sprites["helpwindow"].visible=false
@sprites["helpwindow"].z=90
@sprites["messagewindow"]=Window_AdvancedTextPokemon.new("")
@sprites["messagewindow"].letterbyletter=true
@sprites["messagewindow"].viewport=@viewport
@sprites["messagewindow"].z=100
@sprites["commandwindow"]=CommandMenuDisplay.new(@viewport)
@sprites["commandwindow"].z=100
@sprites["fightwindow"]=FightMenuDisplay.new(nil,@viewport)
@sprites["fightwindow"].z=100
pbShowWindow(MESSAGEBOX)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(battle_scene)\n @battle_scene = battle_scene\n @screenshot = $scene.snap_to_bitmap\n # All the battler by bank\n @battlers = {}\n # All the bars by bank\n @info_bars = {}\n # All the team info bar by bank\n @team_info = {}\n # All the animation currently ... | [
"0.73634946",
"0.72285116",
"0.721439",
"0.7198796",
"0.7192915",
"0.71723235",
"0.70462555",
"0.70132977",
"0.69515735",
"0.6934283",
"0.6924939",
"0.6907729",
"0.6787777",
"0.67417884",
"0.674015",
"0.67161226",
"0.6710401",
"0.6683982",
"0.6621934",
"0.66197973",
"0.660883... | 0.0 | -1 |
============================================================================= All the various types of displaying messages in battle ============================================================================= | def clearMessageWindow
@sprites["messagewindow"].text=""
@sprites["messagewindow"].refresh
@sprites["messagebox"].visible=false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_message _type\n \"<div class=\\\"#{_type}\\\">#{h message[_type]}</div>\" if message[_type]\n end",
"def process_messages(type)\n message_hash = {\n '_correct' => [\n 'Correct!',\n 'That\\'s right',\n 'Nice, good choice!',\n 'A fine letter you picked',\n ... | [
"0.76350456",
"0.7032632",
"0.69357777",
"0.6564537",
"0.65585357",
"0.6524328",
"0.647713",
"0.64497936",
"0.6411036",
"0.631432",
"0.63126034",
"0.63091266",
"0.625626",
"0.62529254",
"0.62445",
"0.61879635",
"0.61835206",
"0.61835206",
"0.61835206",
"0.6175804",
"0.6165714... | 0.0 | -1 |
Start of the game | def on_start
game.local_speed = 0
puts "Analyzing map..."
Bwapi::BWTA.readMap
Bwapi::BWTA.analyze
puts "Map data ready"
@state = AI::State.new(game)
@strategy = ZergStrategy.new(state)
rescue Exception => e
puts "-------------"
puts e.message
puts e.backtrace
puts "-------------"
sleep 5
exit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_... | [
"0.8291336",
"0.8012601",
"0.80023867",
"0.78998405",
"0.7802769",
"0.77805185",
"0.7707356",
"0.7684988",
"0.7670101",
"0.7657288",
"0.7609213",
"0.7569799",
"0.75534034",
"0.75401944",
"0.753324",
"0.75253236",
"0.7519455",
"0.7519455",
"0.751223",
"0.751223",
"0.751223",
... | 0.0 | -1 |
execute a step that is not satisfied, and execute it, if its requirements are met. | def execute
strategy_steps.values.reject {|s|s.satisfied? || s.in_progress?}.each do |step|
if step.requirements_met?
puts "Executing: #{step.name}"
step.execute
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute(step)\n end",
"def check_execute\n unless executed?\n execute\n end\n end",
"def run\n until halted?\n step\n end\n end",
"def before_step(step)\n # Do nothing\n end",
"def fail_script_unless(condition, message)\n fail_script message unless condition\n ... | [
"0.6296357",
"0.5941633",
"0.5910877",
"0.57953584",
"0.57339925",
"0.57339925",
"0.56160885",
"0.5610313",
"0.5601016",
"0.55851895",
"0.555072",
"0.55449224",
"0.54979527",
"0.5482077",
"0.54388314",
"0.54261994",
"0.5386653",
"0.53863496",
"0.53840554",
"0.53663766",
"0.53... | 0.77810186 | 0 |
makes the strategy consisting of steps | def initialize_strategy
main_position = player.command_centers.first.position
_, *unscouted_bases = BWTA.start_locations.to_a.map(&:position).sort do |a, b|
main_position.getDistance(b) <=> main_position.getDistance(a)
end.reverse
overlord_target = nil
#Basic Strategy:
strategy_step "Every idle worker should mine" do
precondition { player.workers.any? &:idle? }
postcondition { false } #this step should be repeated
order do
center = player.command_centers.first
minerals = state.units.values.select{|u| u.type.mineral_field? }.sort do |a, b|
b.distance(center) <=> a.distance(center)
end
player.workers.select(&:idle?).each do |worker|
worker.mine(minerals.pop)
end
end
end
#When there is less than 5 supply and a spawning pool does not exist, a drone should be spawned
strategy_step "Spawn a drone" do
precondition { player.minerals >= 50 && player.supply_used < 10 }
postcondition { false } #this step should be repeated
order { spawn UnitType.Zerg_Drone }
end
#When there is not enough supply an overlord should be spawned
strategy_step "Spawn an overlord" do
precondition { player.minerals >= 100 && player.supply_total <= player.supply_used && player.larva_available? } #not smart
progresscondition { player.units.values.any? {|unit| unit.has_order? "Spawn Overlord" } }
postcondition { false }#this step should be repeated
order { spawn UnitType.Zerg_Overlord }
end
strategy_step "Early overlord scout" do
overlord = nil
target = nil
precondition do
overlords = player.get_all_by_unit_type(UnitType.Zerg_Overlord)
if overlords.count == 1
overlord = overlords.first
target = unscouted_bases.shift
overlord_target = target
true
end
end
progresscondition { overlord && target }
postcondition { overlord.position == target if overlord }
order { overlord.move(target) if overlord }
end
strategy_step "Drone scout" do
drone_scout = nil
target = nil
precondition do
if player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 && target = unscouted_bases.shift
drone_scout = player.workers.first
true
end
end
order do
# TODO why is if drone_scout necessary?
drone_scout.move(target) if drone_scout
end
end
#At 5 supply, 200 minerals a spawning pool should be made
strategy_step "Make a spawning pool at 5 supply" do
precondition { player.minerals > 200 && player.supply_total >= 10 }
postcondition { player.units.values.any? {|u| u.type == UnitType.Zerg_Spawning_Pool} }
progresscondition { player.units.values.any? {|u| u.has_order? "Build SpawningPool" } }
order do
player.workers.first.build(UnitType.Zerg_Spawning_Pool, build_location(UnitType.Zerg_Spawning_Pool))
end
end
#When there is a spawning pool and enough minerals and supply, a zergling should be made
strategy_step "Make zerglings" do
precondition { player.minerals > 50 && player.supply_left >= 2 && player.larva_available? }
precondition { player.get_all_by_unit_type(UnitType.Zerg_Spawning_Pool).count > 0 }
postcondition { false } #this step should be repeated
order do
while (player.minerals > 50 && player.supply_left >= 2 && player.larva_available?) do
spawn UnitType.Zerg_Zergling #spawn many zerglings in one frame
end
end
end
strategy_step "Move in!" do
precondition { zerglings.count >= 1 && enemy.units.count == 0 }
postcondition { false }
order do
target = unscouted_bases.shift || overlord_target
zerglings.each do |z|
puts "Ordering zerglings to move"
z.move(target)
end
end
end
#When there are 5 zerglings, they should attack
strategy_step "Attack!" do
precondition { zerglings.count >= 5 && enemy.units.count > 0 }
postcondition { false } #just keep on doin' it
order do
puts "Ordering zerglings to attack"
zerglings.each { |z| attack_nearest_enemy(z) }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_steps\n\t#make calls to step here...\nend",
"def steps\n find_solution\n end",
"def execute(step)\n end",
"def test_steps; end",
"def test_steps; end",
"def make_step\n @result\n end",
"def step_result; end",
"def step1\n\n end",
"def steps(n)\nend",
"def step1\n \n end",
... | [
"0.72107303",
"0.69788516",
"0.6922222",
"0.6801404",
"0.6801404",
"0.6709997",
"0.6623276",
"0.6487009",
"0.64645916",
"0.64623475",
"0.6448107",
"0.6446199",
"0.6368474",
"0.63577443",
"0.63372314",
"0.63324547",
"0.63241774",
"0.63045204",
"0.6279414",
"0.622949",
"0.62062... | 0.67292506 | 5 |
make the methods of the state available here | def method_missing(name, *params)
if state.respond_to? name
state.send name, *params
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_state_accessor; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def state; end",
"def method_missing(method, *args, &block)\n # ensure the state is initialized before calling any methods\n ... | [
"0.76515925",
"0.7517629",
"0.7517629",
"0.7517629",
"0.7517629",
"0.7517629",
"0.7517629",
"0.7517629",
"0.7517629",
"0.74129146",
"0.7408176",
"0.7215746",
"0.7071313",
"0.6911946",
"0.6902267",
"0.6902267",
"0.68960375",
"0.68621975",
"0.6841766",
"0.67980784",
"0.6794982"... | 0.64290845 | 50 |
Move a piece. Move parsing needs a color so we have to guess the turn belongs to opponent of last move or white. (Board is not turn based, see GameBoard) | def move(move_str)
color = last_move ? opponent(last_move.piece.color) : :white
MoveParser.instance.parse(self, color, move_str).apply
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_piece(move, color) \n squares = find_start_and_end(move) # [start, end]\n\n return false if @display[squares[0][0]][squares[0][1]].guest == ' '\n\n start_piece = @display[squares[0][0]][squares[0][1]].guest\n\n return false if start_piece.color != color \n\n moves = get_legal_moves(squares[... | [
"0.77299803",
"0.7641723",
"0.75682926",
"0.750263",
"0.74017984",
"0.7387335",
"0.7375806",
"0.7369311",
"0.72649276",
"0.72571725",
"0.72268116",
"0.71862864",
"0.71385777",
"0.7116405",
"0.71156585",
"0.7092307",
"0.70628774",
"0.70376533",
"0.70370895",
"0.7036427",
"0.69... | 0.73197603 | 8 |
Move using absolute from and to squares | def move_abs(from, to)
piece = self.at(from)
if piece and mv = piece.move_leading_to(to)
mv.apply
else
raise Exception.new("Invalid move.")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to to\n\t\td = Distance.get( @square, to)\n\t\tmove d.dir( @square), to\n\tend",
"def move_to(x, y); end",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def move_to!(x, y, z)\n @a1[0] = @a2[0] = @b1[0] = @b2[0] = x\n @a1[1] = @a2[1] = @d1[1] = @d2[1] = y\n @a1[... | [
"0.7639855",
"0.72428316",
"0.70303315",
"0.69289076",
"0.6927883",
"0.690434",
"0.6861046",
"0.6774326",
"0.6774326",
"0.6738029",
"0.6738029",
"0.6725959",
"0.6725959",
"0.6711",
"0.6693337",
"0.66405",
"0.6629424",
"0.66225415",
"0.66225415",
"0.66188484",
"0.6591558",
"... | 0.7052681 | 2 |
resets the board, setting pieces to initial position | def reset
set InitialPosition
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def reset\n\t\tfor i in (0...9)\n\t\t\t@board[i] = nil\n\t\tend\n\tend",
"def reset_board_variables\r\n @color_on_turn = :... | [
"0.7636619",
"0.7563156",
"0.75247383",
"0.75014424",
"0.74834937",
"0.7453922",
"0.7401225",
"0.7396748",
"0.7350629",
"0.7330511",
"0.7250651",
"0.7093439",
"0.7065714",
"0.6996712",
"0.6907623",
"0.6904087",
"0.68660027",
"0.67932403",
"0.6793154",
"0.6769162",
"0.67688614... | 0.6867995 | 16 |
N.B. does not take history into account | def ==(other)
self.to_s == other.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def history; end",
"def history; end",
"def history; end",
"def history_added; end",
"def history=(_arg0); end",
"def history=(_arg0); end",
"def history_added=(_arg0); end",
"def history\r\n\r\n end",
"def write_history; end",
"def history\n # blank\n end",
"def get_next_history\r\n f... | [
"0.74478126",
"0.74478126",
"0.74478126",
"0.7080395",
"0.70518667",
"0.70518667",
"0.6915241",
"0.69095576",
"0.68526006",
"0.6633802",
"0.65099555",
"0.64757663",
"0.6456454",
"0.6407054",
"0.6350867",
"0.6350867",
"0.6285489",
"0.6270573",
"0.62292314",
"0.62292314",
"0.61... | 0.0 | -1 |
This is commented out, so the minimize menu item is disabled def on_minimize(menu) end window/zoom | def on_zoom(menu)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimize_window(win)\n # noop\n end",
"def minimize()\r\n $jssh_socket.send(\"#{WINDOW_VAR}.minimize();\\n\", 0)\r\n read_socket()\r\n end",
"def minimize\n Skype.send_ :command => \"MINIMIZE\"\n end",
"def minimized\n @ole.Minimized\n end",
"def min... | [
"0.7189099",
"0.6685514",
"0.664629",
"0.6446019",
"0.6446019",
"0.6069244",
"0.60562855",
"0.60160875",
"0.60160875",
"0.59427994",
"0.5890645",
"0.58572656",
"0.5690531",
"0.56902784",
"0.55578804",
"0.5530823",
"0.5528396",
"0.54394835",
"0.5427386",
"0.5410035",
"0.532443... | 0.62887704 | 13 |
for now its random, but it should grab it from the data | def get_advice
advice = [
{:message => "#{self.name.capitalize}'s blood pressure is a little high. Help #{self.gender_label} relax by sending a funny picture of #{self.gender_label} grandchildren.", :action =>"picture"},
{:message => "#{self.name.capitalize}'s number of steps this week was below average. Encourage #{self.gender_label} to go out of the house by sending #{self.gender_label} a movie ticket.", :action => "gift"},
{:message => "Congratulate #{self.name.capitalize} on #{self.gender_label} amazing weight loss. Send #{self.gender_label} a treat.", :action => "gift"},
{:message => "Thinking about #{self.name.capitalize}? Give #{self.gender_label} a call to tell #{self.gender_label} you are proud of #{self.gender_label}.", :action => "call"},
{:message => "Help #{self.name.capitalize} maintain #{self.gender_label} weight by sending a low sodium entree from #{self.gender_label} favorite restaurant.", :action => "food"},
{:message => "Have a family event you would love #{self.name.capitalize} to attend? Send a personal driver to pick #{self.gender_label} up.", :action => "taxi"},
{:message => "Busy with your child's first dance showcase? Lighthouse taxi will take care of #{self.name.capitalize} from pickup to drop-off.", :action => "taxi"},
{:message => "It's time to pay it forward. Arrange a date to a cooking class. Low sodium of course!", :action => "gift"}
]
return advice[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random()\n \n end",
"def get_random()\n \n end",
"def randomkey; end",
"def randomkey; end",
"def random_pokemon_data\n id = rand(1..807)\n request(\"pokemon/#{id}\")\n end",
"def pick\n @gommis_count = Gommi.count\n @gommis = Gommi.offset(rand(Gommi.count)).fir... | [
"0.69218504",
"0.69218504",
"0.6568187",
"0.6568187",
"0.6288061",
"0.6235547",
"0.6159083",
"0.61452",
"0.610954",
"0.6103002",
"0.61028135",
"0.60920227",
"0.60874623",
"0.6079965",
"0.6039631",
"0.6027977",
"0.6019264",
"0.59958476",
"0.5990416",
"0.5990416",
"0.5964393",
... | 0.0 | -1 |
GET /news_letters GET /news_letters.json | def index
@news_letters = NewsLetter.order("sent_status asc,created_at desc ").paginate(:per_page => 2,:page => params[:page])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @news_letters }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n respond_to do |format|\n @newsletters = Newsletter.all\n format.json { render template: 'newsletters/index', status: :ok }\n end\n end",
"def show\n respond_to do |format|\n format.json { render template: 'newsletters/show', status: :ok }\n end\n end",
"def index\n @... | [
"0.7903022",
"0.7818563",
"0.77975386",
"0.7304834",
"0.72451997",
"0.7023919",
"0.6922387",
"0.68597764",
"0.6841745",
"0.6620807",
"0.6555415",
"0.65225464",
"0.6442759",
"0.6215192",
"0.62049425",
"0.6194205",
"0.61186534",
"0.6013328",
"0.5958167",
"0.59159",
"0.5912539",... | 0.7030254 | 5 |
GET /news_letters/1 GET /news_letters/1.json | def show
@news_letter = NewsLetter.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @news_letter }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n respond_to do |format|\n format.json { render template: 'newsletters/show', status: :ok }\n end\n end",
"def index\n respond_to do |format|\n @newsletters = Newsletter.all\n format.json { render template: 'newsletters/index', status: :ok }\n end\n end",
"def index\n @... | [
"0.78344667",
"0.76839656",
"0.7638502",
"0.7203853",
"0.71985614",
"0.6893741",
"0.6879209",
"0.6759324",
"0.67561764",
"0.6571871",
"0.65366393",
"0.6431856",
"0.6396724",
"0.6335227",
"0.63351554",
"0.6187179",
"0.6142226",
"0.61212736",
"0.6069978",
"0.60207504",
"0.60200... | 0.7526659 | 3 |
GET /news_letters/new GET /news_letters/new.json | def new
@news_letter = NewsLetter.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @news_letter }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @newsletters_template = Newsletters::Template.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newsletters_template }\n end\n end",
"def new\n @newsletter = Newsletter.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | [
"0.8118677",
"0.76243937",
"0.7224668",
"0.7216466",
"0.71652347",
"0.7165225",
"0.71643716",
"0.71596926",
"0.70801044",
"0.70712686",
"0.6999617",
"0.69901204",
"0.69901204",
"0.6988562",
"0.69541657",
"0.6947446",
"0.6937448",
"0.690123",
"0.68994826",
"0.68984586",
"0.689... | 0.8201053 | 0 |
POST /news_letters POST /news_letters.json | def create
@news_letter = NewsLetter.new(params[:news_letter])
respond_to do |format|
if @news_letter.save
format.html { redirect_to admin_news_letter_url(@news_letter), notice: 'News letter was successfully created.' }
format.json { render json: @news_letter, status: :created, location: @news_letter }
else
format.html { render action: "new" }
format.json { render json: @news_letter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @newsletter = Newsletter.new(newsletter_params)\n\n respond_to do |format|\n if @newsletter.save\n format.json { render template: 'newsletters/show', status: :created }\n else\n format.json { render template: 'newsletters/show', json: @newsletter.errors, status: :unproces... | [
"0.6790505",
"0.6771542",
"0.65927297",
"0.6510354",
"0.645195",
"0.640957",
"0.63995343",
"0.6375688",
"0.6343541",
"0.63417786",
"0.62922496",
"0.61717516",
"0.6110005",
"0.6056334",
"0.6021779",
"0.59932595",
"0.5984832",
"0.59306943",
"0.59135276",
"0.58722466",
"0.584709... | 0.73642975 | 0 |
PUT /news_letters/1 PUT /news_letters/1.json | def update
@news_letter = NewsLetter.find(params[:id])
respond_to do |format|
if @news_letter.update_attributes(params[:news_letter])
format.html { redirect_to admin_news_letter_url(@news_letter), notice: 'News letter was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @news_letter.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @newsletters_template = Newsletters::Template.find(params[:id])\n\n respond_to do |format|\n if @newsletters_template.update_attributes(params[:newsletters_template])\n format.html { redirect_to @newsletters_template, notice: 'Template was successfully updated.' }\n format.jso... | [
"0.6401582",
"0.62421596",
"0.60890955",
"0.6078829",
"0.60256755",
"0.59620696",
"0.59484565",
"0.58994347",
"0.58950657",
"0.5865462",
"0.58652824",
"0.585812",
"0.5855001",
"0.5854349",
"0.5845916",
"0.5817876",
"0.5796967",
"0.5794911",
"0.57943565",
"0.57708156",
"0.5769... | 0.68219864 | 0 |
DELETE /news_letters/1 DELETE /news_letters/1.json | def destroy
@news_letter = NewsLetter.find(params[:id])
@news_letter.destroy
respond_to do |format|
format.html { redirect_to admin_news_letters_url,:notice => "News letter was successfully deleted." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n newsletter = Newsletter.find_by_id(params[:id])\n newsletter.logo.destroy\n newsletter.headline.destroy\n newsletter.body.destroy\n newsletter.social.destroy\n newsletter.destroy\n\n render json: newsletter\n end",
"def destroy\n @newsletters_t... | [
"0.7482367",
"0.7288317",
"0.72611576",
"0.7192319",
"0.70817304",
"0.7057626",
"0.7012602",
"0.6997339",
"0.6980273",
"0.6968549",
"0.6957023",
"0.6948449",
"0.6939685",
"0.69179434",
"0.69050866",
"0.69046974",
"0.6858177",
"0.6852814",
"0.68458164",
"0.6841593",
"0.6834437... | 0.7526544 | 0 |
Create the new inspector. | def initialize(listeners)
@inspectors = INSPECTORS.map do |inspector|
inspector.new(listeners)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @inspector = Inspector.new(inspector_params)\n\n respond_to do |format|\n if @inspector.save\n format.html { redirect_to @inspector, notice: 'Inspector was successfully created.' }\n format.json { render :show, status: :created, location: @inspector }\n else\n form... | [
"0.7195851",
"0.717599",
"0.58011353",
"0.5754919",
"0.56287766",
"0.56226593",
"0.5542593",
"0.5530788",
"0.5522705",
"0.54971796",
"0.5484928",
"0.5475845",
"0.54736525",
"0.5470935",
"0.5466214",
"0.5411538",
"0.54073477",
"0.5403635",
"0.53997666",
"0.5397223",
"0.5387141... | 0.0 | -1 |
Exercises from Other Stuff chapter Intro to Programming LaunchSchool | def divide(a,b)
begin
answer = a / b
rescue ZeroDivisionError => e
puts e.message
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exercise_119 (number)\n end",
"def proof_of_stake\n title(\"Proof of Stake\")\n\n eco_scale = \"https://en.wikipedia.org/wiki/Economies_of_scale\"\n pros1 = \"Energy efficient\"\n pros2 = \"More expensive to attack for attackers\"\n pros3 = \"Not susceptible to ecnomies of scale \\n\\t (for more ... | [
"0.6389184",
"0.6374014",
"0.61073035",
"0.60363084",
"0.6032732",
"0.6011245",
"0.59218156",
"0.5829035",
"0.58108425",
"0.576697",
"0.5753454",
"0.57450736",
"0.5728214",
"0.57275146",
"0.56585276",
"0.564563",
"0.5611696",
"0.56005144",
"0.55896866",
"0.558399",
"0.5582844... | 0.0 | -1 |
Writes bytes to the underlying +IO+ object. === Parameters +str+ is the data to write. | def write(str)
writing { write0 str }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(string)\n @handle.write(string)\n end",
"def write(str)\n\t\tlog \"Write: #{str.inspect}\", :traffic\n\t\t\n\t\tbegin\n\t\t\tstr.each_byte do |b|\n\t\t\t\t@device.putc(b.chr)\n\t\t\tend\n\t\t\n\t\t# the device couldn't be written to,\n\t\t# which probably means that it has\n\t\t# crashed or... | [
"0.7053177",
"0.68732864",
"0.68715787",
"0.68715787",
"0.6837397",
"0.6669941",
"0.6645796",
"0.6622127",
"0.65987957",
"0.6520411",
"0.64869004",
"0.6444483",
"0.6423544",
"0.6415274",
"0.6415274",
"0.6397533",
"0.6390944",
"0.63885295",
"0.6365809",
"0.6362031",
"0.6359783... | 0.7585315 | 0 |
Appends a newline to a string and writes it to the underlying +IO+ object. === Parameters +str+ is the data to write. | def writeline(str)
writing { write0 str + "\r\n" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def puts(str = '')\n @io << str << \"\\n\"\n end",
"def writeline(str)\n\t\t\tputs(\"writing #{(str+\"\\r\\n\").inspect}\") if $DEBUG\n\t\t\t@connection.write(str + \"\\r\\n\")\n\t\tend",
"def write(str)\n writing { write0 str }\n end",
"def print(str)\n @io << str\n end",
"def prin... | [
"0.7155978",
"0.7095719",
"0.6952288",
"0.69298214",
"0.69298214",
"0.6910994",
"0.6889309",
"0.68706447",
"0.67431283",
"0.66358024",
"0.64082956",
"0.639727",
"0.6394034",
"0.636074",
"0.633188",
"0.62929225",
"0.6245982",
"0.6244275",
"0.61845785",
"0.6169908",
"0.61611825... | 0.77726626 | 0 |
GET /employments GET /employments.json | def index
@employments = Employment.confirmed
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @employments = Employment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employments }\n end\n end",
"def index\n @employes = Employe.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render j... | [
"0.77812546",
"0.7118651",
"0.7082072",
"0.65925944",
"0.65861475",
"0.6584641",
"0.65362865",
"0.6530468",
"0.65064114",
"0.65064114",
"0.64953756",
"0.6443437",
"0.6436455",
"0.6383641",
"0.6379152",
"0.63485795",
"0.6323434",
"0.62981975",
"0.6246186",
"0.62403107",
"0.615... | 0.6420902 | 13 |
GET /employments/1 GET /employments/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @employments = Employment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @employments }\n end\n end",
"def show\n @employ = Employ.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {... | [
"0.7674284",
"0.72866184",
"0.7218996",
"0.7190509",
"0.71441233",
"0.7138783",
"0.7078026",
"0.6648032",
"0.6643271",
"0.65746135",
"0.65723807",
"0.65723807",
"0.65506095",
"0.6549337",
"0.6541194",
"0.65195984",
"0.6484016",
"0.64557177",
"0.6397713",
"0.6381587",
"0.63798... | 0.0 | -1 |
POST /employments POST /employments.json | def create
@employment = Employment.new(employment_params)
respond_to do |format|
if @employment.save
format.html { redirect_to @employment, notice: 'Employment was successfully created.' }
format.json { render :index, status: :created, location: @employment }
else
format.html { render :new }
format.json { render json: @employment.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @employ = Employ.new(params[:employ])\n\n respond_to do |format|\n if @employ.save\n format.html { redirect_to @employ, notice: 'Employ was successfully created.' }\n format.json { render json: @employ, status: :created, location: @employ }\n else\n format.html { r... | [
"0.6879933",
"0.66577846",
"0.6624114",
"0.6435128",
"0.6434013",
"0.64268816",
"0.63630956",
"0.6304861",
"0.61992204",
"0.61361855",
"0.6135802",
"0.612231",
"0.6104611",
"0.6094726",
"0.605178",
"0.6016292",
"0.60145843",
"0.6010834",
"0.60089254",
"0.59880286",
"0.5974267... | 0.65550977 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_employment
@employment = Employment.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 employment_params
params.require(:employment).permit(:first_name, :second_name, :third_name, :photo, :birth_date, :decription, :phone, :is_confirmed, :specialty_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.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 |
Returns a hash :year => [payment_date, payment_date, ..] | def payment_dates_up_to_date(date)
self.payment_dates_array_up_to_date(date).group_by(&:year)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialized_year_hash\n year_in_range = self.startDate.year\n year_hash = {}\n while year_in_range <= self.endDate.year\n year_hash[year_in_range] = BigDecimal(0.0, 10)\n year_in_range += 1\n end\n year_hash\n end",
"def graduation_rate_by_year\n year = @graduation_rate.map { |ha... | [
"0.6817896",
"0.6385422",
"0.63757175",
"0.6367782",
"0.62488365",
"0.62488365",
"0.6223339",
"0.62074316",
"0.6187442",
"0.61788",
"0.61659706",
"0.6124791",
"0.6124587",
"0.6082443",
"0.60817873",
"0.6070847",
"0.60615265",
"0.60516214",
"0.60460305",
"0.6039845",
"0.601610... | 0.6695476 | 1 |
Returns an array of payment dates up do given date | def payment_dates_array_up_to_date(date)
start_enrollment = self.order('enrollment_date ASC').limit(1).first
stop_enrollment = self.order('cancel_date DESC').limit(1).first
if start_enrollment and stop_enrollment
start = start_enrollment.enrollment_date
stop = stop_enrollment.cancel_date
payment_dates_array = []
if date < stop_enrollment.cancel_date
length_in_months = Date.length_in_months_including_last(start, date)
else
length_in_months = Date.length_in_months_including_last(start, stop)
end
length_in_months.times do |add_month|
payment_dates_array << ((start + Payment::DATE_SPACER) >> add_month)
end
return payment_dates_array
else
return []
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payment_dates_up_to_date(date)\n self.payment_dates_array_up_to_date(date).group_by(&:year)\n end",
"def generate_payments start_date, end_date\n \tdates = start_date.step( end_date ).\n \t select { |date| date.day == bill.due_on }.\n \t map { |date| Payment.from date, bill, self }\n end",
"d... | [
"0.7679374",
"0.69312954",
"0.63154316",
"0.60780096",
"0.607328",
"0.607328",
"0.60502785",
"0.6016551",
"0.58814746",
"0.58599406",
"0.5849992",
"0.5792596",
"0.57861596",
"0.57692283",
"0.57675785",
"0.5749037",
"0.573352",
"0.5725147",
"0.5724637",
"0.5721903",
"0.5689482... | 0.789159 | 0 |
Public: get the search provider | def search_provider
return @search_provider unless @search_provider.nil?
return nil unless @search_provider_class.is_a?(Class)
@search_provider = @search_provider_class.new(index_name, self, custom_mapping, scopes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider\n get(PROVIDER)\n end",
"def service\n :search\n end",
"def provider\n @provider\n end",
"def provider\n providers.first\n end",
"def my_provider\n self.class.my_provider\n end",
"def search_model\n self.class._search_model\n end",
"def provi... | [
"0.7033291",
"0.68978024",
"0.68793845",
"0.6607233",
"0.6545539",
"0.65278476",
"0.65041584",
"0.6471864",
"0.6337944",
"0.6218347",
"0.620551",
"0.6187885",
"0.616795",
"0.6134184",
"0.6133248",
"0.6058191",
"0.604916",
"0.604916",
"0.6042515",
"0.602474",
"0.6002971",
"0... | 0.79136294 | 0 |
Public: create a new document content Hash or an Array content of the document options an options Hash with extra attributes :repo rugged repository object when loading an existing document. (optional). Not meant to be used directly | def new(raw_content, opts = {})
opts[:type] = self
Document.new(raw_content, opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_document(opts={})\n raise ArgumentError, \":title is required\" if opts[:title].nil?\n raise ArgumentError, \":body is required\" if opts[:body].nil?\n raise ArgumentError, \":url is required\" if opts[:url].nil?\n \n if opts[:tags].is_a?(Array)\n opts[:tags] = opts[:tags].j... | [
"0.65131235",
"0.6375256",
"0.6291727",
"0.60732263",
"0.6028711",
"0.59934163",
"0.597991",
"0.5954686",
"0.5947163",
"0.5841869",
"0.58160293",
"0.5786109",
"0.57288027",
"0.5681895",
"0.562336",
"0.5610846",
"0.5592366",
"0.55857307",
"0.558089",
"0.55662113",
"0.555341",
... | 0.55380356 | 23 |
Public: Open the document specified by `id`, optionally at a revision `rev` id id of the document rev revision to load (optional) Returns a Document instance | def open(id, rev = nil)
begin
unless Colonel.config.rugged_backend.nil?
repo = Rugged::Repository.bare(File.join(Colonel.config.storage_path, id), backend: Colonel.config.rugged_backend)
else
repo = Rugged::Repository.bare(File.join(Colonel.config.storage_path, id))
end
rescue Rugged::OSError
return nil
end
Document.new(nil, id: id, repo: repo, type: self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document(docid)\n Document.new(\"#{@uri}/docs\", docid)\n end",
"def initialize(id, rev, doc = {})\n raise(InvalidDocId, 'doc id must be string') unless id.respond_to?(:to_str)\n id = id.to_str\n raise(InvalidDocId, 'doc id may not start with underscore') if id =~ /^_/\n\n sel... | [
"0.6546062",
"0.65220684",
"0.61867005",
"0.6176814",
"0.6125917",
"0.6097173",
"0.6082023",
"0.60406595",
"0.5933378",
"0.59193575",
"0.58869576",
"0.5710551",
"0.57065004",
"0.56702864",
"0.56702864",
"0.5635662",
"0.55901784",
"0.55694526",
"0.55415267",
"0.5531898",
"0.55... | 0.8322573 | 0 |
Public: List all the documents of this type. See ElasticsearchProviderlist | def list(opts = {})
search_provider.list(opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n documents\n end",
"def all\n include_docs!\n docs\n end",
"def all; @docs.values end",
"def all\n @document = Document.all\n end",
"def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end",
"def index\n @documents = Document... | [
"0.77303505",
"0.77215314",
"0.72274554",
"0.72138834",
"0.72004324",
"0.7156905",
"0.7156905",
"0.7156905",
"0.7156905",
"0.7156905",
"0.7156905",
"0.7156905",
"0.7150905",
"0.7109752",
"0.6943943",
"0.69379616",
"0.6920334",
"0.687793",
"0.68298346",
"0.6809743",
"0.6745662... | 0.0 | -1 |
Public: Search documents of this type. See ElasticsearchProvidersearch | def search(*args)
search_provider.search(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_for(*args, &block)\n __elasticsearch__.search(*args, &block)\n end",
"def index\n query = search_params[\"search\"]\n if query\n @documents = Document.search(query)\n else\n @documents = Document.all\n end\n end",
"def search\n @documents = api.form(\"everything\")\... | [
"0.7754238",
"0.76133424",
"0.75529975",
"0.740852",
"0.71868634",
"0.7185258",
"0.70523286",
"0.70441014",
"0.70062935",
"0.69957376",
"0.69657326",
"0.6953614",
"0.6951307",
"0.6947621",
"0.69385993",
"0.6938451",
"0.69072855",
"0.69072855",
"0.69072855",
"0.69072855",
"0.6... | 0.71348715 | 6 |
Public: Get the DocumentType instance for a nem type_name string, name of the type, e.g. 'document' | def get(type_name)
@types ||= {}
register_default unless @types['document']
type = @types[type_name]
raise RuntimeError, "Unknown Type #{type} (know #{@types.keys.join(',')})" unless type
type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def document_type name=nil\n @document_type = name || @document_type || implicit(:document_type)\n end",
"def document_type name=nil\n @document_type = name if name\n @document_type || klass.model_name.to_s.underscore\n end",
"def document_type=(name)\n @docume... | [
"0.7427096",
"0.7406995",
"0.7090043",
"0.7090043",
"0.68861836",
"0.64211226",
"0.6394755",
"0.63813406",
"0.6316917",
"0.62978715",
"0.62712157",
"0.6262257",
"0.6227515",
"0.62047476",
"0.61841583",
"0.6180333",
"0.6111493",
"0.60353786",
"0.60339725",
"0.6021798",
"0.6016... | 0.81105757 | 0 |
Public: Iterate through all the known types Returns an iterator if no block is passed, otherwise yields a (name, type) pair to the block | def all(&block)
to_enum(:all) unless block_given?
@types ||= {}
register_default unless @types['document']
@types.each(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n __types__.each {|t| yield t }\n end",
"def each_type\n types.values.each do |type|\n yield(type)\n end\n end",
"def each\n if @abstract_type\n yield(@type)\n else\n @types.each { |t| yield(t) }\n end\n end",
"def each_type(&bl... | [
"0.8612853",
"0.8354021",
"0.8217866",
"0.7966226",
"0.75462806",
"0.7048775",
"0.6884334",
"0.6881524",
"0.66431797",
"0.64340377",
"0.6378907",
"0.6378907",
"0.6324186",
"0.62960273",
"0.62541246",
"0.61877245",
"0.61826557",
"0.6157919",
"0.61506534",
"0.6124011",
"0.60744... | 0.63672686 | 12 |
GET /contacts GET /contacts.json | def index
redirect_to new_contact_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contacts(options = {})\n send_request(\"get\", contacts_url, body: options.to_json)\n end",
"def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end",
"def contacts\n respond_with_entity(api.get('/api/v1/profile/contacts'),\n NexaasID::Ent... | [
"0.8066792",
"0.7946341",
"0.7844447",
"0.78007257",
"0.772669",
"0.7677997",
"0.75948757",
"0.7492899",
"0.7467818",
"0.7349719",
"0.7331462",
"0.73076427",
"0.7196529",
"0.71886516",
"0.7187755",
"0.7179098",
"0.71699095",
"0.71061826",
"0.71061826",
"0.70991296",
"0.709773... | 0.0 | -1 |
POST /contacts POST /contacts.json | def create
@contact = Contact.new(contact_params)
if @contact.save
respond_to do |format|
format.html { redirect_to new_contact_path, notice: 'Thanks for contacting us, we will get back to you shortly.' }
format.json { render :show, status: :created, location: @contact }
end
else
flash[:alert] = @contact.errors.full_messages.join("<br/>").html_safe
render :new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @contact = Contact.create!(contact_params)\n render json: Contact.all\n end",
"def create\n @contact = @current_user.contacts.new(contact_params)\n if @contact.save\n render json: {status: 201, contact: @contact}\n else\n render json: {status: 400}\n end\n end",
"def ... | [
"0.75767535",
"0.7489912",
"0.73792636",
"0.72857213",
"0.71954143",
"0.7163311",
"0.71241444",
"0.70903546",
"0.7083217",
"0.7067553",
"0.7018867",
"0.7013148",
"0.6966274",
"0.69249797",
"0.69042265",
"0.6890879",
"0.68734777",
"0.686979",
"0.6859895",
"0.6859895",
"0.68598... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def contact_params
params.require(:contact).permit(:name, :email, :message)
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 |
Initializes a client using a configuration. | def initialize(client_secrets_path)
@client_secrets_path = client_secrets_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(**options)\n @config = Configuration.new(**options)\n @client = Client.new(config)\n end",
"def initialize(config, client = nil)\n @host = config[:host]\n\n raise ArgumentError, 'No API host is provided.' if @host.nil?\n\n if client.nil? # rubocop:disable Style/Co... | [
"0.79912204",
"0.7610233",
"0.73575264",
"0.7265384",
"0.7258005",
"0.712619",
"0.7122503",
"0.71217346",
"0.7068605",
"0.6998247",
"0.697649",
"0.6972954",
"0.6952357",
"0.69509244",
"0.69011366",
"0.6837082",
"0.68314135",
"0.68303996",
"0.68296653",
"0.68113035",
"0.679986... | 0.0 | -1 |
Boots a client by discovering the API's services and then authorizes by fetching an access token. If the config has a cache_file the client tries to load discovery | def boot!
@api_client = Google::Apis::AndroidpublisherV3::AndroidPublisherService.new
authorize!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boot!\n @api_client = Google::APIClient.new(\n application_name: config.application_name,\n application_version: config.application_version,\n user_agent: user_agent\n )\n discover!\n authorize!\n end",
"def client_prefetch\n logger.inf... | [
"0.716693",
"0.60742515",
"0.60668766",
"0.60168487",
"0.59470844",
"0.58636755",
"0.5816512",
"0.5815681",
"0.58126414",
"0.58126414",
"0.5802034",
"0.5764828",
"0.5755521",
"0.5711286",
"0.5699575",
"0.5694046",
"0.5682665",
"0.5652532",
"0.5650109",
"0.56497735",
"0.563462... | 0.5348572 | 54 |
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client. | def verify(package, product_id, token)
@api_client.get_purchase_product(
package,
product_id,
token
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProductApi.product_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n ... | [
"0.65979445",
"0.6474967",
"0.6404827",
"0.6371924",
"0.6359606",
"0.63467395",
"0.6322021",
"0.6305744",
"0.62407607",
"0.6233969",
"0.6209326",
"0.6203533",
"0.61212057",
"0.6106991",
"0.6097634",
"0.60838777",
"0.60588366",
"0.6024491",
"0.59785074",
"0.5953422",
"0.591349... | 0.0 | -1 |
Calls the remote API to load the product information for a specific combination of parameter which should be loaded from the client. | def verify_subscription(package, subscription_id, token)
@api_client.get_purchase_subscription(
package,
subscription_id,
token
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ProductApi.product_get ...\"\n end\n # verify the required parameter 'api_key' is set\n if @api_client.config.client_side_validation && api_key.nil?\n ... | [
"0.65984184",
"0.6475907",
"0.6404447",
"0.6370248",
"0.63596946",
"0.63459253",
"0.6320962",
"0.6306194",
"0.62410235",
"0.62348133",
"0.6210298",
"0.62034583",
"0.6122511",
"0.6108187",
"0.60976183",
"0.6084188",
"0.6059637",
"0.60243136",
"0.59790725",
"0.59535587",
"0.591... | 0.0 | -1 |
Acknowledges a subscription purchase. | def acknowledge_purchase_subscription(package, subscription_id, token)
@api_client.acknowledge_purchase_subscription(
package,
subscription_id,
token
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acknowledge subscription, *ack_ids\n subscriber.acknowledge subscription: subscription_path(subscription), ack_ids: ack_ids\n end",
"def acknowledge\n api_call(\"acknowledge\")\n self\n end",
"def ack(subscription_headers, message)\n #p [:ack, message.headers[\"messa... | [
"0.7577853",
"0.6904794",
"0.68101865",
"0.64118695",
"0.63706553",
"0.63533276",
"0.6268258",
"0.6243523",
"0.6233512",
"0.6223872",
"0.6030922",
"0.602263",
"0.6001711",
"0.59448904",
"0.59171784",
"0.591637",
"0.58995354",
"0.5824777",
"0.58189386",
"0.580298",
"0.57727724... | 0.77894014 | 0 |
Optional destroy appointments since it was mentioned in the Supported requests but not in the appointment model description | def destroy
@schedule = Schedule.find_by_id(params[:schedule_id])
if @schedule
#Here is a quick check to make sure that the validations have passed
@appointment = Appointment.find_by_id(params[:id])
if @appointment
#if the validations pass save the appointment
@appointment.destroy
render json: @schedule, status: :ok
else
render json: {errorMessage: "no appointment with id: #{@appointment.errors.full_messages}"}
end
else
render json: {errorMessage:"no schedule with id: #{params[:schedule_id]}"}, status: :not_found
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy_appointments\n appointments.destroy_all\n end",
"def destroy\n begin\n @appointment = Appointment.find(params[:id])\n rescue\n respond_info('error', 'internal_server_error', 'Delete Appointment Failed', :internal_server_error)\n return\n end\n @appointment.destroy\n ... | [
"0.7483628",
"0.71673256",
"0.71551585",
"0.713581",
"0.71306497",
"0.7097257",
"0.7094068",
"0.70795995",
"0.70711136",
"0.69965726",
"0.69965726",
"0.69889164",
"0.69677824",
"0.69677824",
"0.69677824",
"0.69649726",
"0.6959504",
"0.6948305",
"0.69468194",
"0.6927599",
"0.6... | 0.6146626 | 73 |
C Defaults the apartment number to nil | def initialize(building, number = nil)
self.building = building
self.number = number
@@apartments << self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ag_apartment\n @ag_apartment = Ag::Apartment.find(params[:id])\n end",
"def set_apartment\n @apartment = Apartment.find(params[:id])\n end",
"def set_apartment\n @apartment = Apartment.find(params[:id])\n end",
"def set_apartment\n @apartment = Apartment.find(params[:id])... | [
"0.590889",
"0.58728415",
"0.58728415",
"0.58728415",
"0.58728415",
"0.58728415",
"0.5729685",
"0.5729685",
"0.5724681",
"0.56979316",
"0.56209296",
"0.5527958",
"0.5312668",
"0.5307019",
"0.525423",
"0.524916",
"0.5244744",
"0.5239927",
"0.52221125",
"0.51784617",
"0.5155835... | 0.4851489 | 39 |
Returns the available locales/languages | def available_locales
locales = Language.sorted_by_abbreviation.pluck(:abbreviation).presence if Language.table_exists?
(locales.presence || [default_locale])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_locales\n evaluate_localization_option!(:available_locales)\n end",
"def available_locales\r\n ::LinguaFranca.available_locales\r\n end",
"def available_locales\n resource.translations.all(:fields => [:locale_tag], :unique => true).map { |t| t.locale }\n end",
... | [
"0.85281676",
"0.8440915",
"0.83951914",
"0.8384379",
"0.8373167",
"0.83573365",
"0.83573365",
"0.8150228",
"0.81392914",
"0.8123333",
"0.81128436",
"0.801682",
"0.7929361",
"0.78864497",
"0.7850812",
"0.7842243",
"0.7786589",
"0.77284116",
"0.765161",
"0.765161",
"0.757445",... | 0.8499175 | 1 |
Converts the locale to the i18n format (e.g. `enGB`) | def to_i18n(locale:)
join_char = Rails.configuration.x.locales.i18n_join_character
locale = default_locale if locale.blank?
convert(string: locale, join_char: join_char)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def locale\n I18n.locale.to_s\n end",
"def locale\n I18n.locale.to_s\n end",
"def to_gettext(locale:)\n join_char = Rails.configuration.x.locales.gettext_join_c... | [
"0.7804183",
"0.7409646",
"0.7409646",
"0.71115404",
"0.68270564",
"0.67868096",
"0.67841107",
"0.6766",
"0.6765006",
"0.6737419",
"0.66405046",
"0.6639006",
"0.6605414",
"0.65716",
"0.6557218",
"0.65024185",
"0.64779747",
"0.64608353",
"0.6457509",
"0.6444432",
"0.6416271",
... | 0.77709115 | 1 |
Converts the locale to the i18n format (e.g. `en_GB`) | def to_gettext(locale:)
join_char = Rails.configuration.x.locales.gettext_join_character
locale = default_locale if locale.blank?
convert(string: locale, join_char: join_char)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_locale\n self.locale = self.locale.gsub('_', '-').split(',').first.split('-').first if self.locale.present?\n end",
"def to_i18n(locale:)\n join_char = Rails.configuration.x.locales.i18n_join_character\n locale = default_locale if locale.blank?\n convert(string: locale, join_cha... | [
"0.79560155",
"0.77112746",
"0.72846276",
"0.72846276",
"0.6908215",
"0.6828479",
"0.68116885",
"0.67894465",
"0.6762374",
"0.67447644",
"0.67407894",
"0.66838527",
"0.6617812",
"0.6538037",
"0.6518675",
"0.6500676",
"0.6494061",
"0.64829046",
"0.6474295",
"0.6467644",
"0.644... | 0.704107 | 4 |
active admin and serialized fields workaround: | def persons_raw
persons.join("\n") unless persons.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_deserializers()\n return super.merge({\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app... | [
"0.6385324",
"0.62704074",
"0.6264868",
"0.6214438",
"0.61926985",
"0.6180021",
"0.613893",
"0.613893",
"0.613893",
"0.6134547",
"0.61184055",
"0.61184055",
"0.61184055",
"0.60146093",
"0.60058546",
"0.59465647",
"0.5945512",
"0.592455",
"0.59141886",
"0.58956605",
"0.5869288... | 0.0 | -1 |
active admin and serialized fields workaround: | def persons_raw=(values)
self.persons = []
self.persons = values.split("\n").map(&:strip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_deserializers()\n return super.merge({\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app... | [
"0.6385324",
"0.62704074",
"0.6264868",
"0.6214438",
"0.61926985",
"0.6180021",
"0.613893",
"0.613893",
"0.613893",
"0.6134547",
"0.61184055",
"0.61184055",
"0.61184055",
"0.60146093",
"0.60058546",
"0.59465647",
"0.5945512",
"0.592455",
"0.59141886",
"0.58956605",
"0.5869288... | 0.0 | -1 |
active admin and serialized fields workaround: | def tags_raw
tags.join("\n") unless tags.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_deserializers()\n return super.merge({\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app... | [
"0.63847685",
"0.62693566",
"0.62638354",
"0.6213867",
"0.6191419",
"0.6178865",
"0.61379445",
"0.61379445",
"0.61379445",
"0.6133965",
"0.6116681",
"0.6116681",
"0.6116681",
"0.60146207",
"0.6004995",
"0.5945074",
"0.5944594",
"0.5923994",
"0.591377",
"0.58942884",
"0.586841... | 0.0 | -1 |
active admin and serialized fields workaround: | def tags_raw=(values)
self.tags = []
self.tags = values.split("\n").map(&:strip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_field_deserializers()\n return super.merge({\n \"isActive\" => lambda {|n| @is_active = n.get_boolean_value() },\n })\n end",
"def get_field_deserializers()\n return super.merge({\n \"appId\" => lambda {|n| @app... | [
"0.6384641",
"0.62688917",
"0.6263232",
"0.62137014",
"0.61908203",
"0.61779624",
"0.61368954",
"0.61368954",
"0.61368954",
"0.6132967",
"0.611707",
"0.611707",
"0.611707",
"0.6013609",
"0.60041356",
"0.5944765",
"0.5944118",
"0.59233737",
"0.5913981",
"0.5894377",
"0.5867778... | 0.0 | -1 |
Actions Show post page based on url id | def show
@post = Post.find(params[:id])
@user = @post.blog.user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n\t@post=Post.find(params[:id])# URL is used to get the post id to find\n end",
"def show\n post = Post.find(params[:id])\n redirect_to post.permalink\n end",
"def show\n redirect_to pretty_post_url(@post) + \"#comment_#{params[:id]}\"\n end",
"def show\n # going to get a single post ... | [
"0.7247582",
"0.71945715",
"0.7126305",
"0.71124536",
"0.70703334",
"0.7045681",
"0.70356756",
"0.6993123",
"0.6991635",
"0.6886314",
"0.6870511",
"0.6859812",
"0.6847507",
"0.6835251",
"0.6831392",
"0.6818589",
"0.68028647",
"0.67894775",
"0.6787206",
"0.67759037",
"0.677144... | 0.0 | -1 |
Post form needs a new object | def new
@post = Post.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit\n @new = New.new\n end",
"def post_request(object)\n end",
"def create\n @object_ = @obj.new(self.object_params)\n if @object_.save\n session[:user_id] = @object_.id\n redirect_to @object_\n else\n flash[:errors] = @object_.errors.full_messages\n render :n... | [
"0.71748865",
"0.6720906",
"0.6528168",
"0.64336777",
"0.64031297",
"0.6402064",
"0.62696725",
"0.62305945",
"0.62272584",
"0.6223194",
"0.62153447",
"0.62152225",
"0.6208285",
"0.62047505",
"0.6202397",
"0.61966926",
"0.61913097",
"0.6188481",
"0.6188481",
"0.6183336",
"0.61... | 0.61482567 | 51 |
Try to create a new post | def create
# Associate with logged in user and use strong parameters
@post = logged_in_user.blog.posts.build(post_strong_params)
# If post params pass validations
if @post.save
# Show success message on next request
flash[:info] = "New post created!"
# Redirect to created post
redirect_to @post
# Some parameters didn't pass
else
# Render new with error messages attached to @post
render 'new'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n isSavePost = PostService.createPost(post_params)\n if isSavePost\n redirect_to posts_path\n else\n render :new\n end\n end",
"def create\r\n @post = Post.new(params[:post])\r\n @post.save!\r\n redirect_to post_path(@post)\r\n rescue Active... | [
"0.7988223",
"0.7808885",
"0.77428436",
"0.76479864",
"0.7630345",
"0.7617755",
"0.7585603",
"0.75852287",
"0.7550559",
"0.7540666",
"0.7508276",
"0.7484717",
"0.7482104",
"0.7480705",
"0.7479628",
"0.74708855",
"0.7464908",
"0.74638695",
"0.7444332",
"0.74394363",
"0.7437856... | 0.0 | -1 |
Show edit page based on url id | def edit
@post = Post.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_edit\n cname = self.class.classname.to_s.downcase\n return \"?show=#{cname}_edit&#{cname}_id=#{self.id}\"\n end",
"def visit_edit_page(model, **opt, &block)\n action = opt[:id] ? :edit : :edit_select\n visit_action_page(model, action, **opt, &block)\n end",
"def edit(id)\n records = ... | [
"0.7636836",
"0.7456873",
"0.7386232",
"0.73478764",
"0.7334906",
"0.7278483",
"0.71864074",
"0.71431214",
"0.7116444",
"0.71101713",
"0.70904607",
"0.70805275",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225",
"0.7080225... | 0.0 | -1 |
Try to update post data based on editform | def update
# Get post from db
@post = Post.find(params[:id])
# Post parameters passed validations
if @post.update_attributes(post_strong_params)
# Show message to indicate success
flash[:info] = "Post edit was successful"
# Redirect to post page
redirect_to @post
# Some parameters didn't pass
else
# Render edit page with error messages attached to @post
render 'edit'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_post\n isPostUpdate = PostService.updatePost(post_form_params)\n if isPostUpdate\n redirect_to posts_path\n else \n render :edit\n end\n end",
"def post_edit_form\n @post_update_form = PostUpdateForm.new(post_update_form_params)\n unless @post... | [
"0.723555",
"0.7140473",
"0.70310336",
"0.69538367",
"0.6928191",
"0.6926511",
"0.6885268",
"0.6877524",
"0.68416864",
"0.6838254",
"0.68369675",
"0.6816749",
"0.68052626",
"0.67972",
"0.677164",
"0.6759073",
"0.67498845",
"0.6745351",
"0.6725823",
"0.6699053",
"0.6697943",
... | 0.6572062 | 47 |
Kill a blog post | def destroy
# Fetch the right post
sentenced = Post.find(params[:id])
# Save title for message and blog for redirect
title = sentenced.title
blog = sentenced.blog
# Commit murder
sentenced.destroy
# Show message of successful murder
flash[:info] = "You successfully destroyed blog post: " + title
# Back to index
redirect_to blog_path(blog)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @blog_post.destroy\n end",
"def delete_post(post_num_input)\n BLOG.delete_at(post_num_input)\n puts \"\\nSuccessfully deleted!\"\n puts ''\n display_posts_by_title\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n @title = \"Kill Post\"\n\n respo... | [
"0.68401074",
"0.6733621",
"0.6523221",
"0.64963084",
"0.6478219",
"0.6478219",
"0.64641327",
"0.64100456",
"0.6343575",
"0.6311563",
"0.6300915",
"0.62775576",
"0.62571764",
"0.62506944",
"0.6225452",
"0.62132937",
"0.6186476",
"0.61836433",
"0.6181877",
"0.61623925",
"0.613... | 0.65165883 | 3 |
Show all blog posts with pagination | def index
@posts = Post.paginate(page: params[:page])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @blog_posts = BlogPost.all.\n order(publish_date: :desc).\n paginate(page: params[:page], per_page: 5)\n end",
"def index\n filter_by_type unless filter_by_tag\n @blog_posts ||= BlogPost.all\n @blog_posts = @blog_posts.paginate(page: pa... | [
"0.845083",
"0.81099355",
"0.79961365",
"0.798832",
"0.78619677",
"0.7753491",
"0.77403367",
"0.7712236",
"0.7708804",
"0.76926064",
"0.76670873",
"0.7635835",
"0.75779384",
"0.7530142",
"0.7513026",
"0.74703443",
"0.746668",
"0.74651563",
"0.74635184",
"0.7455032",
"0.742673... | 0.74861866 | 15 |
Protect against form mass assignment Returns only required and permitted parameters | def post_strong_params
params.require(:post).permit(:title, :content, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mass_assign_protected_attributes\n @admin.systems_enabled = params[:admin][:systems_enabled] || []\n @admin.active = params[:admin][:active]\n @admin.permissions_attributes = params[:admin][:permissions_attributes] || {}\n @admin.can_act_as_customer = params[:admin][:can_act_as_customer]\n @admi... | [
"0.6831547",
"0.679534",
"0.66478527",
"0.6564871",
"0.6557207",
"0.6557207",
"0.6514734",
"0.65136737",
"0.651276",
"0.6499989",
"0.6463829",
"0.64314336",
"0.64314336",
"0.6406372",
"0.63881344",
"0.6384604",
"0.63806605",
"0.6377094",
"0.6370237",
"0.6360126",
"0.63205415"... | 0.0 | -1 |
Return true if post owner and accessing user match | def check_post_user
# Fetch post by id
@post = Post.find(params[:id])
# Redirect to home page if wrong user or not admin
unless @post.blog.user == logged_in_user || logged_in_user.admin?
redirect_to root_url
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner?(post_owner) # <= User object\n current_user == post_owner\n end",
"def check_post_owner\n json_response({ error: 'Not authorized' }, :unauthorized) unless @post.user_id == current_user.id\n end",
"def authorized_to_edit?(post)\n post.user == current_user\n end",
"def authorized... | [
"0.8408837",
"0.7862473",
"0.7634228",
"0.7634228",
"0.74482745",
"0.73757136",
"0.7352791",
"0.73270893",
"0.73008215",
"0.7204498",
"0.71925133",
"0.71898514",
"0.71877235",
"0.7186912",
"0.71784014",
"0.717761",
"0.7147059",
"0.7131866",
"0.71251625",
"0.712433",
"0.711659... | 0.66047406 | 95 |
Use callbacks to share common setup or constraints between actions. | def set_product
@product = Product.friendly.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 product_params
params.require(:product).permit(:name, :slug, :currency, :value, :tags, :description, :status)
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 |
upload users with bikes | def import_user_bikes
begin
raise "Please select File" unless params[:file]
User.import_user_bikes(params[:file])
flash[:success] = "Users With Bikes Uploaded Successfully"
redirect_to :back
rescue StandardError => e
flash[:error] = "Uploading Failed with error::#{e.message}"
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_user_bikes\n end",
"def upload_file(upload, user, client_name)\n if upload != nil\n if user.link_picture != nil\n File.delete('public/images/' << user.link_picture)\n end\n name = upload['img'].original_filename\n directory = 'public/images/' + client_name + '/users/' + u... | [
"0.8743962",
"0.64321977",
"0.64160967",
"0.6161058",
"0.6161058",
"0.6140648",
"0.6100707",
"0.5853102",
"0.58392733",
"0.5818048",
"0.581525",
"0.5802187",
"0.5740934",
"0.5736652",
"0.57287556",
"0.5718581",
"0.5717038",
"0.5704502",
"0.57033676",
"0.56880516",
"0.56873715... | 0.6722858 | 1 |
for my bikes with user | def upload_user_bikes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end",
"def return_bikes\n fix_bikes... | [
"0.68500865",
"0.64969796",
"0.63234687",
"0.62801546",
"0.61204576",
"0.61204576",
"0.602112",
"0.5869901",
"0.586827",
"0.5836494",
"0.5832814",
"0.5827657",
"0.58244354",
"0.58192635",
"0.57533467",
"0.57448864",
"0.5723227",
"0.57132256",
"0.57075375",
"0.57022065",
"0.56... | 0.70547605 | 0 |
Should be an integer, and account for leap years. If you're not sure what the rules for that are, Google it! ... Seriously though, Googling things is highly underrated. Your Code Here | def days_in_year
365.25
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leap_year?(input_int)\n if input_int % 400 == 0 && input_int % 100 == 0 then true\n elsif input_int % 100 == 0 then false\n elsif input_int % 4 == 0 then true\n else false\n end\nend",
"def leap_year?(int)\n case \n when int % 400 == 0 && int % 100 == 0 then true\n when int % 4 == 0 && int % 10... | [
"0.80410767",
"0.7964291",
"0.7931902",
"0.7881005",
"0.7878883",
"0.7834863",
"0.77778816",
"0.7774655",
"0.775671",
"0.77465856",
"0.76605",
"0.7657408",
"0.76529",
"0.763001",
"0.7622852",
"0.7621626",
"0.76144093",
"0.76105917",
"0.7609508",
"0.75994253",
"0.75944453",
... | 0.0 | -1 |
GET /emails GET /emails.json | def index
@emails = Email.where("category=?", current_user.id%2).paginate(:page => params[:page])
# @emails = Email.where("category=?", current_user.id%2)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emails\n respond_with_entity(api.get('/api/v1/profile/emails'),\n NexaasID::Entities::Profile::Emails)\n end",
"def index\n @emails = @user.emails\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @emails }\n end\n end",
"d... | [
"0.79467475",
"0.78577834",
"0.78577834",
"0.77086604",
"0.7691464",
"0.76483065",
"0.7586645",
"0.7542485",
"0.74366343",
"0.74366343",
"0.73130214",
"0.72669536",
"0.71988344",
"0.7087799",
"0.7055724",
"0.70553267",
"0.70552593",
"0.70493215",
"0.68191856",
"0.67520946",
"... | 0.0 | -1 |
GET /emails/1 GET /emails/1.json | def show
#TRACKER.track(current_user['email'], "READ_EMAIL", {"email_id" => @email.id, "email_reference" => @email.reference_id})
TRACKER.track(current_user['email'], "READ_EMAIL", @email.id, @email.reference_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @email = @user.emails.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @email }\n end\n end",
"def show\n @email = @user.emails.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format... | [
"0.75243914",
"0.75243914",
"0.7498489",
"0.7498489",
"0.7384737",
"0.7383269",
"0.7270882",
"0.7253918",
"0.7206913",
"0.71922094",
"0.7129582",
"0.6930351",
"0.685702",
"0.685702",
"0.68153083",
"0.6757216",
"0.6691029",
"0.6641171",
"0.66158587",
"0.661162",
"0.660488",
... | 0.0 | -1 |
POST /emails POST /emails.json | def create
@email = Email.new(email_params)
respond_to do |format|
if @email.save
format.html { redirect_to @email, notice: 'Email was successfully created.' }
format.json { render :show, status: :created, location: @email }
else
format.html { render :new }
format.json { render json: @email.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @email = @user.emails.new(email_params)\n\n respond_to do |format|\n if @email.save\n format.html { redirect_to @email, notice: 'Email was successfully created.' }\n format.json { render json: @email, status: :created, location: @email }\n else\n format.html { rend... | [
"0.6777921",
"0.65204203",
"0.64981073",
"0.643656",
"0.6322239",
"0.6321505",
"0.62524074",
"0.62325287",
"0.6186312",
"0.617552",
"0.61224264",
"0.610081",
"0.6056992",
"0.6007148",
"0.6006584",
"0.59830004",
"0.5968781",
"0.5965257",
"0.5927124",
"0.5907867",
"0.587163",
... | 0.60634893 | 13 |
PATCH/PUT /emails/1 PATCH/PUT /emails/1.json | def update
respond_to do |format|
if @email.update(email_params)
format.html { redirect_to @email, notice: 'Email was successfully updated.' }
format.json { render :show, status: :ok, location: @email }
else
format.html { render :edit }
format.json { render json: @email.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @email = @user.emails.find(params[:id])\n\n respond_to do |format|\n if @email.update_attributes(email_params)\n format.html { redirect_to @email, notice: 'Email was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \... | [
"0.7065868",
"0.67504084",
"0.6723775",
"0.6713236",
"0.6709041",
"0.6623054",
"0.6534367",
"0.65249485",
"0.65125287",
"0.65071625",
"0.64775634",
"0.639925",
"0.6388726",
"0.6363993",
"0.6272909",
"0.61651367",
"0.6155926",
"0.6141829",
"0.6115174",
"0.61121583",
"0.6104049... | 0.6469069 | 15 |
DELETE /emails/1 DELETE /emails/1.json | def destroy
@email.destroy
respond_to do |format|
format.html { redirect_to emails_url, notice: 'Email was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @email = @user.emails.find(params[:id])\n @email.destroy\n\n respond_to do |format|\n format.html { redirect_to emails_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n result = access_token.delete(\"/api/v1/emails/#{params[:id]}\")\n display_api_res... | [
"0.77535933",
"0.7700855",
"0.748818",
"0.74816334",
"0.74816334",
"0.74770635",
"0.7461006",
"0.74187106",
"0.7345985",
"0.72079587",
"0.71741194",
"0.715896",
"0.7151699",
"0.7143039",
"0.70670164",
"0.70592934",
"0.7025591",
"0.70198095",
"0.7019725",
"0.7006016",
"0.70026... | 0.7161642 | 18 |
returns [nodename] [score] ordered by node_text def getscore(node_arr, node_text) ret = [] node_text.each do |n1| node_arr.each do |n2| if() end end end | def geternode(text)
#@prnode = Prnode.where("pgscore > 0").first.pgnodename
@prnodes = Prnode.select(:pgnodename)
puts "DEBUGHEeeeeeeeeeeeeeeee"
# puts @prnodes.inspect
#[@prnodes.first.pgnodename, @prnodes.first.pgscore]
FuzzyMatch.new(@prnodes).find(text)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classify_with_score(text)\n (classifications(text).sort_by { |a| -a[1] })[0]\n end",
"def node_score\n @property_hash[:node_score]\n end",
"def score\n\n return NULL_SCORE if query_words.empty?\n return NULL_SCORE if reference_words.empty?\n my_scores = []\n\n query_words.ea... | [
"0.6319934",
"0.6117569",
"0.61102724",
"0.60764",
"0.6030969",
"0.6020046",
"0.601951",
"0.6004263",
"0.5894416",
"0.58860034",
"0.58817285",
"0.5850817",
"0.5849919",
"0.58266735",
"0.5786279",
"0.5769456",
"0.5742363",
"0.5706834",
"0.56999654",
"0.5696805",
"0.5694692",
... | 0.5836356 | 13 |
Use callbacks to share common setup or constraints between actions. | def set_email
@email = Email.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 email_params
params.require(:email).permit(:reference_id, :path)
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 |
this is for tree to get only directories | def _directories wd
$log.debug " directories got XXX: #{wd} "
d = Dir.new(wd)
ent = d.entries.reject{|e| !File.directory? File.join(wd,e)}
$log.debug " directories got XXX: #{ent} "
ent.delete(".");ent.delete("..")
return ent
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def directories\n directory.directoires\n end",
"def directories; end",
"def directories; end",
"def getDirs dir\n\t\tFind.find(dir)\t\n\tend",
"def dirs; end",
"def dirs; end",
"def GetLevelDirs()\n directories = Dir.entries($level_folder)\n\n for i in 0...directories.length do\n\n ... | [
"0.75267166",
"0.72045517",
"0.72045517",
"0.713952",
"0.70857096",
"0.70857096",
"0.70351005",
"0.6997921",
"0.6893026",
"0.68419653",
"0.68333125",
"0.6831411",
"0.68063545",
"0.6771952",
"0.67365104",
"0.6733895",
"0.67258614",
"0.667112",
"0.66655463",
"0.666498",
"0.6652... | 0.72858965 | 1 |
Wait for all Prototype effects to be processed (the wait happens in the browser). Credits to | def wait_for_effects(options={})
builder = JavascriptExpressionBuilder.new active_javascript_framework(options)
wait_for_condition builder.no_pending_effects.script,
options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_effect\n update_for_wait\n update_for_wait while @spriteset.effect?\n end",
"def wait_for_effects(timeout = 30)\n wait_for(timeout) { @browser.document.js_eval(\"document.defaultView.Effect.Queue.size()\").to_i == 0 }\n end",
"def wait_for_effect_on(selector)\n wait_until_zero(\"$('#... | [
"0.7319401",
"0.70391",
"0.66593814",
"0.66451085",
"0.66451085",
"0.66451085",
"0.6524733",
"0.643508",
"0.63741034",
"0.63741034",
"0.6335345",
"0.63105774",
"0.6298916",
"0.6268042",
"0.61423135",
"0.6112682",
"0.6103456",
"0.6099283",
"0.60741913",
"0.6042178",
"0.5998588... | 0.67831635 | 2 |
Wait for an element to be present (the wait happens in the browser). | def wait_for_element(locator, options={})
builder = JavascriptExpressionBuilder.new
builder.find_element(locator).append("element != null;")
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_until_element_present(element)\n element.when_present.exists?\n end",
"def wait_for_element(element)\n self.send(element).wait_until_present(@ole.explicit_wait)\n end",
"def wait_for_element(element)\n @wait.until {\n bool = false\n\n if(element.displayed?)\n ... | [
"0.85794383",
"0.8473024",
"0.823151",
"0.81870335",
"0.8059645",
"0.7979638",
"0.7821453",
"0.7784806",
"0.77189153",
"0.7553194",
"0.75529253",
"0.7548801",
"0.7530439",
"0.7478695",
"0.7461069",
"0.7419508",
"0.73109883",
"0.72937423",
"0.7279002",
"0.72744125",
"0.7271911... | 0.74746335 | 14 |
Wait for an element to NOT be present (the wait happens in the browser). | def wait_for_no_element(locator, options={})
builder = JavascriptExpressionBuilder.new
builder.find_element(locator).append("element == null;")
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_element_to_disappear(element)\n @wait.until {\n begin\n !element.displayed?\n rescue\n break\n end\n }\n end",
"def assert_element_not_present(locator)\n wait_for(:message => \"Expected element '#{locator}' not to be present, but it was\") do\n !seleni... | [
"0.7833622",
"0.76593864",
"0.76403075",
"0.7484952",
"0.7468738",
"0.7445263",
"0.7434056",
"0.7270909",
"0.71542823",
"0.7094279",
"0.7018523",
"0.6975471",
"0.6859545",
"0.6835009",
"0.6820983",
"0.6761918",
"0.67414707",
"0.67027515",
"0.66966265",
"0.66639465",
"0.661064... | 0.79746944 | 0 |
Wait for some text to be present (the wait is happening browser side). wait_for_text will search for the given argument within the innerHTML of the current DOM. Note that this method treats a single string as a special case. ==== Parameters wait_for_text accepts an optional hash of parameters: :element a selenium locator for an element limiting the search scope. :timeout_in_seconds duration in seconds after which we time out if text cannot be found. ==== Regular Expressions In addition to plain strings, wait_for_text accepts regular expressions as the pattern specification. ==== Examples The following are equivalent, and will match "some text" anywhere within the document: wait_for_text "some text" wait_for_text /some text/ This will match "some text" anywhere within the specified element: wait_for_text /some text/, :element => "container" This will match "some text" only if it exactly matches the complete innerHTML of the specified element: wait_for_text "some text", :element => "container" | def wait_for_text(pattern, options={})
builder = JavascriptExpressionBuilder.new
builder.find_text(pattern, options).append("text_match == true;")
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_text(text)\n Watir::Wait.until { @browser.text.include? text }\n end",
"def text_is_on_page(text, timeout = WAITING_TIMEOUT)\n self.wait_until(timeout, \"\\n\\nERROR! Text '#{text}' was not found after #{timeout} seconds of waiting!\\n\") do\n self.text.include? text\n end\n end",
... | [
"0.6831311",
"0.6599348",
"0.658341",
"0.6482455",
"0.63565695",
"0.6153361",
"0.60997504",
"0.6088859",
"0.58212256",
"0.5810101",
"0.57739216",
"0.5696091",
"0.56811106",
"0.55265063",
"0.54934376",
"0.54664284",
"0.53363305",
"0.5322258",
"0.5273844",
"0.5246114",
"0.52381... | 0.67138255 | 1 |
Wait for some text to NOT be present (the wait happens in the browser). See wait_for_text for usage details. | def wait_for_no_text(pattern, options={})
builder = JavascriptExpressionBuilder.new
builder.find_text(pattern, options).append("text_match == false;")
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_text_to_exclude(locator, string)\n wait_for { text(locator).exclude?(string) }\n end",
"def wait_for_text(text)\n Watir::Wait.until { @browser.text.include? text }\n end",
"def assert_element_does_not_contain_text(locator, text, message=nil, timeout=default_wait_for_time)\n wait_for({... | [
"0.7678206",
"0.76028115",
"0.73633206",
"0.7174691",
"0.70610696",
"0.7018579",
"0.6772574",
"0.6547701",
"0.64338595",
"0.6309635",
"0.6291745",
"0.62339747",
"0.6198171",
"0.619005",
"0.61795807",
"0.6166712",
"0.6146751",
"0.61324894",
"0.61216134",
"0.61149234",
"0.60356... | 0.7332255 | 3 |
Wait for a field to get a specific value (the wait happens in the browser). | def wait_for_field_value(locator, expected_value, options={})
builder = JavascriptExpressionBuilder.new
builder.find_element(locator).element_value_is(expected_value)
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n wait_until_exists\n @text_field.value\n end",
"def input_data(field, value)\n if field.eql?('username')\n query(\"* id:'login_etUserName'\", setText: \"#{value}\")\n sleep(STEP_PAUSE)\n elsif field.eql?('password')\n sleep(STEP_PAUSE)\n query(\"* id:'login_etPass'\", setTex... | [
"0.7112418",
"0.658243",
"0.6355911",
"0.62583256",
"0.62091404",
"0.62091404",
"0.61215097",
"0.61215097",
"0.60677105",
"0.606261",
"0.60583824",
"0.60426307",
"0.5988918",
"0.5988848",
"0.598643",
"0.5971091",
"0.5963679",
"0.59494054",
"0.5948963",
"0.593",
"0.59192973",
... | 0.754242 | 0 |
Wait for a field to not have a specific value (the wait happens in the browser). | def wait_for_no_field_value(locator, expected_value, options={})
builder = JavascriptExpressionBuilder.new
builder.find_element(locator).element_value_is_not(expected_value)
wait_for_condition builder.script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for_field_value(locator, expected_value, options={})\n builder = JavascriptExpressionBuilder.new\n builder.find_element(locator).element_value_is(expected_value)\n wait_for_condition builder.script, options[:timeout_in_seconds]\n end",
"def has_no_field_value?(locator, text)\n ... | [
"0.6706323",
"0.6672068",
"0.6318664",
"0.62103546",
"0.616771",
"0.6104972",
"0.60406065",
"0.60170144",
"0.5994833",
"0.5915402",
"0.58671147",
"0.5849247",
"0.5842377",
"0.5799301",
"0.5751115",
"0.5689487",
"0.56865",
"0.56813186",
"0.56749177",
"0.56749177",
"0.5673072",... | 0.79177475 | 0 |
Wait for something to be visible (the wait happens in the browser). | def wait_for_visible(locator, options={})
builder = JavascriptExpressionBuilder.new
wait_for_condition builder.visible(locator).script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_visible!(timeout=@wait)\n self.el\n wait_for(timeout: timeout, message: \"Element at #{location} is not visible\") { visible? }\n end",
"def wait_for_render(how, what)\n @wait.until {element_visible?(how, what)}\n end",
"def wait_for_visible(locator)\n wait_for { find_element(locator).di... | [
"0.8130703",
"0.80675083",
"0.79692066",
"0.78702277",
"0.7701689",
"0.76794636",
"0.74242204",
"0.7411068",
"0.74019855",
"0.73560464",
"0.71853644",
"0.7162898",
"0.71246076",
"0.70796967",
"0.70414495",
"0.6966631",
"0.69570476",
"0.6914667",
"0.6913506",
"0.6913506",
"0.6... | 0.74941134 | 6 |
Wait for something to not be visible (the wait happens in the browser). | def wait_for_not_visible(locator, options={})
builder = JavascriptExpressionBuilder.new
wait_for_condition builder.not_visible(locator).script, options[:timeout_in_seconds]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_not_visible!(timeout=@wait)\n self.el\n wait_for(timeout: timeout, message: \"Element at #{location} is still visible\") { !visible? }\n end",
"def wait_not_visible!(timeout=@wait)\n wait_for(timeout: timeout, message: \"Element at #{locator} is still visible\") { !visible? }\n end",
... | [
"0.8389478",
"0.8321682",
"0.7915149",
"0.7886821",
"0.7557288",
"0.7467154",
"0.7378481",
"0.7306767",
"0.7283194",
"0.72568715",
"0.7233995",
"0.71715045",
"0.7164785",
"0.7121071",
"0.69322354",
"0.6909922",
"0.6871646",
"0.68613744",
"0.68083334",
"0.6807323",
"0.67615604... | 0.75860524 | 4 |
, :only => :new | def new
@question_id = (@exam_session.exam.questions.find :first,
:offset => (@exam_session.current_question - 1)).id
@exam_session.update_attribute(:updated_at, Time.now)
@question = Question.find_by_id_and_return_xml_table(@question_id)
@choices = { 'choiceA' => @question.choice_a,
'choiceB' => @question.choice_b,
'choiceC' => @question.choice_c,
'choiceD' => @question.choice_d,
'choiceE' => @question.choice_e,
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\n end",
"def new\n\tend",
"def new\n\tend",
"def new\n\tend",
"def new\n\ten... | [
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.8273555",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",
"0.819384",... | 0.0 | -1 |
Fallback for unexpected/uncommon http errors | def describe_http_error(error_description)
error_description.section("Unexpected API Request Failure:", format_rest_error)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fallback\n head :ok\n end",
"def respond_bad_request; make_response(nil, false, 400, \"Bad Request\") end",
"def handle_error (url, res)\n puts \"#{url} was not found\" if res.code.to_i == 404\n puts \"#{url} requires authorization\" if res.code.to_i == 401\n puts \"#{url} retur... | [
"0.69469607",
"0.6898235",
"0.6855744",
"0.6828954",
"0.6816006",
"0.6810729",
"0.6810729",
"0.68036646",
"0.6778808",
"0.663956",
"0.65867156",
"0.6546201",
"0.6540267",
"0.65350175",
"0.653484",
"0.653484",
"0.6521185",
"0.6511645",
"0.6469148",
"0.64583427",
"0.6433105",
... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.