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 |
|---|---|---|---|---|---|---|
DELETE /movers/1 DELETE /movers/1.json | def destroy
@mover.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n en... | [
"0.73285717",
"0.6927342",
"0.6804239",
"0.6769565",
"0.67591625",
"0.67119193",
"0.67022914",
"0.668431",
"0.667599",
"0.66255075",
"0.66076225",
"0.65931666",
"0.65872884",
"0.6570591",
"0.6567346",
"0.6560736",
"0.65507025",
"0.65507025",
"0.6540325",
"0.6532836",
"0.65213... | 0.0 | -1 |
before_filter :authenticate , :except => [:get_dealers, :get_zones] | def index
@users = get_model.paginate :page => params[:page]
@countries = get_countries.all
@roles = get_roles.all
respond_to do |format|
format.html
format.js { render :partial => 'list', :object => [ @roles, @users ] }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_filter; end",
"def authorize\n redirect_to '/' unless current_user || current_dealer\n end",
"def before_each(req)\n if dealership(req).nil? then not_found\n elsif !authenticated?(req) then unauthenticated\n elsif !authorized?(role(req), session_user(req)) then unauthorized\n ... | [
"0.68926954",
"0.67334634",
"0.6531955",
"0.64141935",
"0.62292796",
"0.6224203",
"0.61926466",
"0.61796427",
"0.6172221",
"0.6140805",
"0.61108935",
"0.61011034",
"0.61011034",
"0.6080525",
"0.6064698",
"0.60575485",
"0.60575485",
"0.60575485",
"0.60575485",
"0.60575485",
"0... | 0.0 | -1 |
pirates_say_arrrrrrrrr("are you really learning Ruby?") => "eenu" pirates_say_arrrrrrrrr("Katy Perry is on the radio!") => "rya" pirates_say_arrrrrrrrr("Pirates say arrrrrrrrr") => "arrrrrrrr" | def pirates_say_arrrrrrrrr(string)
new_string = []
string.split(//).each_with_index do |l, i|
if l == "r" || l == "R"
new_string << string[i + 1]
end
end
new_string.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pirates_say_arrrrrrrrr(string)\n\nend",
"def offer_rose (string)\r\n \"Would you take this rose, #{string}, in exchange for giving an old beggar woman shelter from the bitter cold?\" \r\nend",
"def pirates_say_arrrrrrrrr(string)\n\nstring.downcase!\nsplitsplat = string.split(//)\nresult = \"\"\n\nspl... | [
"0.7582853",
"0.7221111",
"0.7166108",
"0.7000308",
"0.6918801",
"0.6901277",
"0.6896448",
"0.68805456",
"0.68634295",
"0.6854863",
"0.6852092",
"0.6848121",
"0.68022496",
"0.6780184",
"0.672969",
"0.6727635",
"0.67212564",
"0.66923374",
"0.66913617",
"0.6689932",
"0.66816777... | 0.6280563 | 100 |
Search User with given search string. Param : +search_string+:: the search string Returns : json format of search result. | def search_user
search = Sunspot.search User do
fulltext search_params
end
r = Hash.new
search.results.each do |u|
r.store(u.id,u)
end
render :json => r.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_by_name\n query = params[:query]\n users = User.search_users(query)\n render :json => users.to_json(:check_user => current_user)\n end",
"def search(query_string, page = 1)\n oauth_response = access_token.get(\"/api/v1/search.json\", :search => query_string, :page => page)\n JSON.p... | [
"0.6749811",
"0.6660052",
"0.66419387",
"0.6637043",
"0.6519637",
"0.6513587",
"0.6498677",
"0.6483692",
"0.63838154",
"0.6362096",
"0.63606346",
"0.6356656",
"0.63477385",
"0.6344594",
"0.627396",
"0.62249964",
"0.6224557",
"0.6208137",
"0.6202906",
"0.62022847",
"0.6193012"... | 0.67567044 | 0 |
Whitelist the required fields in params hash | def search_params
params.require(:search_string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_attributes!(keys)\n keys.each do |key|\n bad_request!(key) unless params[key].present?\n end\n end",
"def required_attributes!(keys)\n keys.each do |key|\n bad_request!(key) unless params[key].present?\n end\n end",
"def validate_params!\n self.params ||=... | [
"0.7635751",
"0.7635751",
"0.7295643",
"0.71705216",
"0.712372",
"0.71105945",
"0.7103987",
"0.7066571",
"0.6986981",
"0.6957311",
"0.6943916",
"0.6938119",
"0.6931988",
"0.69087815",
"0.69083166",
"0.6882444",
"0.6875311",
"0.68642014",
"0.684964",
"0.6845869",
"0.68415564",... | 0.0 | -1 |
for locale sensitive transliteration with friendly_id | def normalize_friendly_id(input)
input.to_s.to_slug.normalize.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end",
"def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end",
"def normalize_friendly_id(text)\n text.to_slug.normalize! transliterations: :russian\n end",
"def normalize_f... | [
"0.784157",
"0.784157",
"0.784157",
"0.76804805",
"0.74155873",
"0.7400233",
"0.7400233",
"0.7400233",
"0.7226008",
"0.71514297",
"0.70323867",
"0.6992389",
"0.6964565",
"0.6912709",
"0.6861595",
"0.6850003",
"0.682335",
"0.6747979",
"0.66526747",
"0.66428006",
"0.6642008",
... | 0.668178 | 20 |
convert parameters with hyphen to parameters with underscore. deep_transform_keys has been removed in Rails 5.1 | def transform_params
params.transform_keys! { |key| key.underscore }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform\n params.transform_keys! { |key| key.tr('-', '_') }\n end",
"def transform_params\n params.transform_keys! { |key| key.tr(\"-\", \"_\") }\n end",
"def transform_param_keys_casing\n params.transform_keys!(&:underscore)\n end",
"def normalize_keys(hash)\n hash.inject(HashWithIn... | [
"0.83179075",
"0.80978477",
"0.7838634",
"0.69487405",
"0.6860742",
"0.6818881",
"0.68116105",
"0.67156476",
"0.66917235",
"0.6674035",
"0.66411376",
"0.6572811",
"0.65596545",
"0.65286756",
"0.6525203",
"0.6471799",
"0.6468641",
"0.64488655",
"0.62814033",
"0.62770873",
"0.6... | 0.79714274 | 2 |
Building an mxmlc line | def get_compile_line(input, output)
libs_path = LIBRARY_PATH.map{ |lib| "-library-path+='#{File.join(current_path, lib)}'"}.join(" ")
sources_path = SOURCE_PATH.map{ |lib| "-sp+='#{File.join(current_path, lib)}'"}.join(" ")
line = "mxmlc #{File.join(current_path(), input)} -o=#{File.join(current_path(), output)} -debug=#{DEBUG} #{libs_path} #{sources_path} #{EXTRA}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comp_line\n @xml += \"<#{@tokens[@i].type}> #{@tokens[@i].val} </#{@tokens[@i].type}> \"\n @i += 1\n end",
"def build_line_content_tag(line_content, container_attributes)\n result = Nokogiri::XML::Element.new('td', doc)\n result['class'] = 'line-content'\n\n line_pre = Nokogiri::XML::Element... | [
"0.6535489",
"0.6103469",
"0.5983788",
"0.5969462",
"0.5962474",
"0.5828589",
"0.55920625",
"0.5582747",
"0.54876465",
"0.54665154",
"0.54589987",
"0.54263324",
"0.5389798",
"0.5347669",
"0.5347669",
"0.5347669",
"0.5347669",
"0.5347669",
"0.5347669",
"0.5347669",
"0.5347669"... | 0.6235582 | 1 |
Get the current path | def current_path
File.expand_path(File.join(__FILE__,"../"))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_path\n current_folder.path\n end",
"def get_current_path\n decompress_value(session['app.current_path']).tap do |path|\n session.delete('app.current_path') if path.blank?\n end\n end",
"def current\n\t\t\t\t\treturn Pathname.new(\".\")\n\t\t\t\tend",
"def current path=nil\n c... | [
"0.8477773",
"0.8474798",
"0.8282554",
"0.8233582",
"0.8005608",
"0.8002216",
"0.7988916",
"0.7974565",
"0.7925812",
"0.78865093",
"0.7722694",
"0.7659557",
"0.7651106",
"0.7559208",
"0.7547554",
"0.75152457",
"0.7393415",
"0.7378526",
"0.7376576",
"0.726565",
"0.7188195",
... | 0.79835343 | 7 |
rerender and cache this template/key combination for each language | def refresh(template_name,key,args={},&prerender_block)
# @logger.debug("\trender_base.refresh(#{template_name},#{key})") if @logger
result={}
@languages.each do |language|
result[language] = refresh_one_language(template_name,language,key,args,&prerender_block)
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_one_language(template_name,language,key,args={},&prerender_block)\n # @logger.debug(\"\\t\\trender_base.refresh_one_language(#{template_name},#{language},#{key})\") if @logger\n\n renderer=get_renderer(template_name)\n key ||= renderer.get_key(args)\n rendered=renderer.render(lan... | [
"0.7255774",
"0.63926667",
"0.60329664",
"0.60078907",
"0.57929796",
"0.5736165",
"0.5713645",
"0.56191",
"0.5592546",
"0.55683136",
"0.55079514",
"0.5491279",
"0.5478338",
"0.5453145",
"0.54496485",
"0.54337054",
"0.53969634",
"0.5385297",
"0.535207",
"0.5342463",
"0.5330953... | 0.75529647 | 0 |
rerender and cache this template/key combination for ONE language | def refresh_one_language(template_name,language,key,args={},&prerender_block)
# @logger.debug("\t\trender_base.refresh_one_language(#{template_name},#{language},#{key})") if @logger
renderer=get_renderer(template_name)
key ||= renderer.get_key(args)
rendered=renderer.render(language,args,{:render_mode => :refresh},&prerender_block)
put_page_into_s3(language,key,rendered)
return rendered
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh(template_name,key,args={},&prerender_block)\n # @logger.debug(\"\\trender_base.refresh(#{template_name},#{key})\") if @logger\n result={}\n @languages.each do |language|\n result[language] = refresh_one_language(template_name,language,key,args,&prerender_block)\n end\n ... | [
"0.73324925",
"0.6522461",
"0.6261616",
"0.5951001",
"0.5816642",
"0.5722953",
"0.5720778",
"0.56825167",
"0.5602317",
"0.55857486",
"0.5581559",
"0.5577895",
"0.5548715",
"0.54909766",
"0.54816586",
"0.54650223",
"0.53913945",
"0.5382071",
"0.5382071",
"0.5376518",
"0.537651... | 0.75145096 | 0 |
try the cache first. if not in cache render and put in cache | def read_or_render(template_name,language,key,render_args={},&prerender_block)
# @logger.debug("render_base.read_or_render(#{template_name},#{language},#{key})") if @logger
#check cache
renderer=nil
unless key
#try to generate the key
renderer ||= get_renderer(template_name)
key=renderer.get_key( render_args)
end
if key
result=peek(language,key)
end
unless result
template_name,key,render_args = process_prerender_block(
template_name,
key,
render_args,
&prerender_block)
renderer ||= get_renderer(template_name)
result=renderer.render(language,render_args,{})
put_page_into_s3(language,key,result)
else
# @logger.debug("got it from cache") if @logger
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cached?; end",
"def cached_render\n if Global.file_cache\n cached_render_file\n else\n cached_render_memory\n end\n end",
"def move_to_... | [
"0.7420183",
"0.7420183",
"0.7420183",
"0.7420183",
"0.7420183",
"0.7420183",
"0.7420183",
"0.7379275",
"0.7371972",
"0.7242854",
"0.7154603",
"0.70867604",
"0.70867604",
"0.70867604",
"0.70719224",
"0.70075667",
"0.6972006",
"0.6972006",
"0.6861038",
"0.68379897",
"0.6828975... | 0.6242836 | 73 |
to test room paths | def test_room_paths()
# the parameter is the (name, description) in initialize in class Room
# to create new room of center/north/south
center = Room.new("Center", "Test room in the center.")
north = Room.new("North", "Test room in the north.")
south = Room.new("South", "Test room in the south.")
# to add path of center room
center.add_paths({:north => north, :south => south})
# check if center.go(:north) really goes to north
assert_equal(center.go(:north), north)
# check if center.go(:south) really goes to south
assert_equal(center.go(:south), south)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_simple_path_for\n path_finder = Amazeingly::PathFinder.new(rooms_collection: @rooms_collection)\n expected = Amazeingly::Path.new([\n { room: Amazeingly::Room.new(@rooms[2]), collected_objects: ['Knife'] }\n ])\n\n assert_equ... | [
"0.712498",
"0.6654616",
"0.60118854",
"0.60033345",
"0.58961827",
"0.5893172",
"0.58754987",
"0.5729186",
"0.5726042",
"0.5669198",
"0.5629313",
"0.56133276",
"0.56133276",
"0.56133276",
"0.56133276",
"0.56133276",
"0.5610616",
"0.55882484",
"0.55882484",
"0.55882484",
"0.55... | 0.80948585 | 0 |
Returns the name of the company | def employee_name
@employee_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def company_name\t\t\t# Getter method - return nil if name is not found\n\t\tcompany.try(:name)\n\tend",
"def company_name\n @company_name\n end",
"def name\n company.blank? ? full_name : \"#{company} (#{full_name})\"\n end",
"def company_name\n element_with_value('CompanyName', opts... | [
"0.86295986",
"0.8539934",
"0.8473931",
"0.8299938",
"0.8276819",
"0.8212174",
"0.8108807",
"0.8044838",
"0.79729766",
"0.7822352",
"0.77791184",
"0.7730765",
"0.7670152",
"0.7627004",
"0.7617805",
"0.7617805",
"0.7617035",
"0.76146644",
"0.75624",
"0.75319386",
"0.7505568",
... | 0.0 | -1 |
Try writing the above program without using the sort method. A large part of programming is solving problems, so get all the practice you can! | def sort_array2
arr = []
begin
puts "Please give me a word."
ans = gets.chomp
arr << ans
end while ans != ''
new_arr = []
n = arr.length
for i in 1..n
new_arr << arr.min
arr.delete(arr.min)
end
puts new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorting(arr)\n#display orig array\n p arr \n p \"**************************************************\"\n # do something to the array\n # compare each value of an array to the value on its left\n # if the value is less than the value on its left, switch places\n # do this by placing the lesser ... | [
"0.7074742",
"0.7071043",
"0.6968346",
"0.69415516",
"0.68486744",
"0.67531735",
"0.67439705",
"0.6732928",
"0.67306083",
"0.6674136",
"0.6660055",
"0.6657538",
"0.66439736",
"0.6637575",
"0.66282403",
"0.66282403",
"0.66164404",
"0.65989476",
"0.6590009",
"0.65879804",
"0.65... | 0.6340105 | 54 |
Rewrite your Table of Contents program (from the chapter on methods). Start the program with an array holding all of the information for your Table of Contents (chapter names, page numbers, etc.). Then print out the information from the array in a beautifully formatted Table of Contents. | def justify_again
content = ['Table of Contents', 'Chapter 1: Numbers', 'page 1', 'Chapter 2: Letters', 'page 72', 'Chapter 3: Variables', 'page 118']
lineWidth = 40
puts (content[0].center(lineWidth))
puts (content[1].ljust(lineWidth/2) + content[2].rjust(lineWidth/2))
puts (content[3].ljust(lineWidth/2) + content[4].rjust(lineWidth/2))
puts (content[5].ljust(lineWidth/2) + content[6].rjust(lineWidth/2))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_of_contents\n puts(\"Table of Contents\".center(50))\n puts(\"Chapter 1\".ljust(15) + \"Getting Started\".ljust(20) + \"page \".ljust(1) + \"1\".rjust(3))\n puts(\"Chapter 2\".ljust(15) + \"Numbers\".ljust(20) + \"page \".ljust(1) + \"9\".rjust(3))\n puts(\"Chapter 3\".ljust(15) + \"Letters\".ljust(2... | [
"0.75025827",
"0.721961",
"0.678244",
"0.6566309",
"0.633035",
"0.633035",
"0.6299628",
"0.6262416",
"0.62353283",
"0.62247926",
"0.6187457",
"0.61871845",
"0.6183919",
"0.61698544",
"0.61524606",
"0.61438",
"0.6131542",
"0.6130732",
"0.6089386",
"0.60757464",
"0.60741955",
... | 0.0 | -1 |
Connects to the Stomp middleware TODO: write to use logic from super class | def connect(connector = ::Stomp::Connection)
if @connection
Log.debug("Already connection, not re-initializing connection")
return
end
begin
host = nil
port = nil
user = nil
password = nil
@@base64 = false
@@base64 = get_bool_option("stomp.base64", false)
@@msgpriority = get_option("stomp.priority", 0).to_i
# Maintain backward compat for older stomps
host = get_env_or_option("STOMP_SERVER", "stomp.host")
port = get_env_or_option("STOMP_PORT", "stomp.port", 6163).to_i
user = get_env_or_option("STOMP_USER", "stomp.user")
password = get_env_or_option("STOMP_PASSWORD", "stomp.password")
#TODO: assume reactor is running already
@connection = EM.connect host, port, StompClient, :login => user, :passcode => password
Log.debug("Connecting to #{host}:#{port}")
rescue Exception => e
pp e.backtrace[0..5]
raise("Could not connect to Stomp Server: #{e}")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect\n if @connection\n Log.debug(\"Already connection, not re-initializing connection\")\n return\n end\n\n begin\n host = nil\n port = nil\n user = nil\n ... | [
"0.62556803",
"0.620251",
"0.61694086",
"0.5979476",
"0.5979476",
"0.5977518",
"0.5883973",
"0.58221793",
"0.5811948",
"0.5789673",
"0.5780501",
"0.57481563",
"0.5724082",
"0.5723438",
"0.5721184",
"0.57173914",
"0.5714341",
"0.5689558",
"0.5686748",
"0.5668475",
"0.5652576",... | 0.60536295 | 3 |
TODO: make automic subscribe_and_send because need subscribe to happen before send does Subscribe to a topic or queue | def subscribe(source)
unless @subscriptions.include?(source)
EM::defer do
Log.debug("Subscribing to #{source}")
wait_until_connected?
@connection.subscribe(source)
@subscriptions << source
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe_to_channel; end",
"def subscribe\n @conn.send_data :opcode => SUBSCRIBE, :channel => @name\n @subscribe_sent = true\n end",
"def subscribe\n @broker.subscribe(*self.class.subscriptions) do |channel, data|\n begin\n perform(channel, data)\n rescue => e\n ... | [
"0.6843848",
"0.6802487",
"0.67838216",
"0.6758646",
"0.6711873",
"0.6419873",
"0.6419273",
"0.6394999",
"0.63465226",
"0.63434416",
"0.6327666",
"0.63045335",
"0.62975055",
"0.6293828",
"0.6293258",
"0.620208",
"0.6188301",
"0.61713296",
"0.61614805",
"0.6138595",
"0.6132861... | 0.0 | -1 |
Subscribe to a topic or queue | def unsubscribe(source)
#TODO
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subscribe(_topic, **)\n raise 'not implemented'\n end",
"def subscribe(connection)\n channel = connection.create_channel\n q = channel.queue DESTINATION_QUEUE, durable: true\n q.subscribe do |delivery, headers, body|\n puts \"#{Time.now}: Got the message\"\n end\nend",
"def subscribe\n ... | [
"0.8279137",
"0.7770299",
"0.76997524",
"0.75924224",
"0.75877917",
"0.7525232",
"0.75030375",
"0.74784464",
"0.7423347",
"0.73976284",
"0.73969394",
"0.73961616",
"0.7369467",
"0.7362734",
"0.73212713",
"0.7195823",
"0.71849406",
"0.71793324",
"0.7140507",
"0.7122031",
"0.70... | 0.0 | -1 |
looks for a config option, accepts an optional default raises an exception when it cant find a value anywhere | def get_option(opt, default=nil)
return @config.pluginconf[opt] if @config.pluginconf.include?(opt)
return default if default
raise("No plugin.#{opt} configuration option given")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conf name, args = {}\n required = args[:required] ||= false\n default = args[:default] ||= nil\n if CONFIG[name]\n CONFIG[name]\n else\n if required && !default\n $stderr.puts \"#{name} not found - exiting\"\n exit\n else\n default\n end\n end\nend",
"def find_option(name)\n ... | [
"0.72180235",
"0.7143899",
"0.70763266",
"0.7036564",
"0.6899398",
"0.6899398",
"0.68198174",
"0.67460746",
"0.6729968",
"0.6623835",
"0.6613081",
"0.660622",
"0.6602791",
"0.6581234",
"0.64198565",
"0.63926655",
"0.63518363",
"0.6329506",
"0.62800413",
"0.6279581",
"0.627181... | 0.67625976 | 7 |
gets a boolean option from the config, supports y/n/true/false/1/0 | def get_bool_option(opt, default)
return default unless @config.pluginconf.include?(opt)
val = @config.pluginconf[opt]
if val =~ /^1|yes|true/
return true
elsif val =~ /^0|no|false/
return false
else
return default
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bool_option(opt, default)\n return default unless @config.pluginconf.include?(opt)\n\n val = @config.pluginconf[opt]\n\n if val =~ /^1|yes|true/\n return true\n elsif val =~ /^0|no|false/\n return false\n ... | [
"0.8172083",
"0.8158482",
"0.74252176",
"0.7221383",
"0.7102384",
"0.7072118",
"0.6993416",
"0.6939167",
"0.684158",
"0.6835384",
"0.6732325",
"0.67090964",
"0.66438526",
"0.6631929",
"0.66208476",
"0.6613772",
"0.66091496",
"0.6604708",
"0.6571556",
"0.6539367",
"0.6489771",... | 0.8155399 | 3 |
MES Mark that this user/planner viewed the indicated plan | def viewed_plan(pln)
#MES- Is the plan on the planner?
if plans.include?(pln)
plans.update_attributes(pln, :viewed_at => Time.now_utc)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plan=(new_plan)\n reset\n @plan = new_plan\n end",
"def has_contributor_plan?\n (current_user.plan.id == 5)\n end",
"def set_plan\n\t\t@plan = Plan.find(params[:id])\n\tend",
"def show\n set_client_profile(@plan)\n @goals = @plan.goals\n @tasks = @plan.tasks\n e... | [
"0.61313593",
"0.604793",
"0.6032117",
"0.6024883",
"0.60174525",
"0.6013894",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"0.60137343",
"... | 0.73103297 | 0 |
MES Of the plans associated with this planner, which are visible to the indicated user? NOTE: This does NOT check the visiblity of the PLANNER, only of the PLANS | def visible_plans(viewing_user_id)
#MES- If the viewing user is the owner of this planner, then
# they can see all the plans
return plans if !viewing_user_id.nil? && viewing_user_id == self.user_id
#MES- Other users can see all plans that are public
return plans.find_all { |pln| pln.security_level == Plan::SECURITY_LEVEL_PUBLIC }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plans\n return @plans\n end",
"def all_plans\n if current_user.typeofuser == \"admin\" then\n @tenant = current_user.tenant\n @current_plan = @tenant.pricing_plan\n @selected_plan = PricingPlan.find(@tenant.selected_plan_id)\n @pricing_plans = PricingPlan.wher... | [
"0.6818674",
"0.658455",
"0.64472157",
"0.6380544",
"0.6378029",
"0.6353371",
"0.62980527",
"0.62788904",
"0.62707305",
"0.625661",
"0.62412214",
"0.6212541",
"0.61753654",
"0.610983",
"0.6104827",
"0.609371",
"0.60398334",
"0.6039682",
"0.5999258",
"0.5998156",
"0.59873533",... | 0.83265644 | 0 |
MES Returns a hash where the keys are the IDs of plans on this planner that have unviewed changes (e.g. plans that have a new comment since the user last viewed the plan.) Viewing time is controlled by the viewed_plan function. | def plan_ids_with_unviewed
#MES- Select plan IDs for plans that are on our calendar,
# that are taking place in the future, that we've accepted,
# and that have relevant changes that took place AFTER we
# viewed the plan
sql = <<-END_OF_STRING
SELECT
plans.id AS id, count(*) as count
FROM
plans, planners_plans, plan_changes
WHERE
plans.id = planners_plans.plan_id AND
planners_plans.planner_id = ? AND
planners_plans.cal_pln_status IN (?) AND
plans.fuzzy_start > UTC_TIMESTAMP() AND
plan_changes.plan_id = planners_plans.plan_id AND
(
plan_changes.change_type IN (?) OR
(plan_changes.change_type = ? AND plan_changes.comment IS NOT NULL)
) AND
((plan_changes.updated_at > planners_plans.viewed_at) OR planners_plans.viewed_at IS NULL) AND
plan_changes.owner_id != ?
GROUP BY plans.id
END_OF_STRING
res = {}
rows = perform_select_all_sql([sql, self.id, Plan::STATUSES_ACCEPTED, PlanChange::CHANGE_TYPES_COMMENTS_AND_CHANGES, PlanChange::CHANGE_TYPE_RSVP, self.user_id])
rows.each do | row |
res[row['id'].to_i] = row['count'].to_i
end
return res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def viewed_plan(pln)\r\n #MES- Is the plan on the planner?\r\n if plans.include?(pln)\r\n plans.update_attributes(pln, :viewed_at => Time.now_utc)\r\n end\r\n end",
"def visible_plans(viewing_user_id)\r\n #MES- If the viewing user is the owner of this planner, then\r\n # they can see all the... | [
"0.68991256",
"0.6014877",
"0.59783185",
"0.58419055",
"0.573575",
"0.5673647",
"0.5646351",
"0.5623643",
"0.56008315",
"0.5585867",
"0.5571968",
"0.55279857",
"0.54809815",
"0.5456194",
"0.5420065",
"0.54191834",
"0.5374252",
"0.5368421",
"0.53627574",
"0.53460735",
"0.53381... | 0.7733827 | 0 |
MES A helper to get the current plan status for the indicated plan for this planner. | def plan_status(plan)
cur_stat = Plan::STATUS_NO_RELATION
existing_plan = self.plans.detect { | item | item.id == plan.id }
cur_stat = existing_plan.cal_pln_status if !existing_plan.nil?
return cur_stat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n if (!plan_results || plan_results == [])\n return 'no_tests'\n end\n if (plan_results['state'] == \"Successful\")\n return 'pass'\n end\n if (plan_results['state'] != \"Successful\")\n return 'fail'\n end\n return 'no_tests'\n end",
"def plan\n ... | [
"0.67702335",
"0.6701635",
"0.65720326",
"0.65377736",
"0.65377736",
"0.64744776",
"0.6295177",
"0.62819177",
"0.6191641",
"0.61736345",
"0.61341655",
"0.6117844",
"0.60947067",
"0.6046385",
"0.6028999",
"0.6019969",
"0.6000083",
"0.5995394",
"0.5987751",
"0.5960768",
"0.5947... | 0.84197336 | 0 |
MES A helper that creates a PlanChange object for a change in RSVP status | def create_plan_change_helper(user, plan, initial_status, final_status, comment = nil)
#MES- Record a PlanChange object
pc = PlanChange.new
#MGS- set the comment on the plan change, unless the comment is blank
pc.comment = comment unless comment.blank?
pc.rsvp_changed(user, initial_status, final_status)
pc.save
plan.plan_changes << pc
return pc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_plan(plan)\n PsegRecurring::Plan.new(@credentials).send_plan(plan)\n end",
"def plan_object\n Plan.new plan\n end",
"def test_change_plan\n response=@root_key_api.change_plan(\"test-rb@precog.com\",\"password\",@account_id, \"Bronze\")\n \n response=@root_key_api.describe_plan(\... | [
"0.60182947",
"0.59660757",
"0.5834655",
"0.5811939",
"0.574948",
"0.5744434",
"0.5569099",
"0.5558198",
"0.5556602",
"0.55485564",
"0.5498216",
"0.5460444",
"0.5443325",
"0.54411876",
"0.5435703",
"0.5424753",
"0.54196864",
"0.5415485",
"0.5403401",
"0.53931385",
"0.5382359"... | 0.75026447 | 0 |
loads SEO templates and format strings for SEO tags | def set_seo_data(hash)
tt = Setting::get('Title for location page')
unless tt.blank?
hash[:title] = self.process_seo_str tt
end
dt = Setting::get('Description for location page')
unless dt.blank?
hash[:description] = self.process_seo_str dt
end
kt = Setting::get('Keywords for location page')
unless kt.blank?
hash[:keywords] = self.process_seo_str kt
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seo_tags\n seo_title + seo_meta_author + seo_meta_description\n end",
"def seo_for_page\n PAGE_SEO_META.each do |meta|\n send(\"set_#{meta}_key\", \"#{seo_condition[:prefix]}#{meta}\")\n end\n\n set_title_variables(seo_variables)\n end",
"def show_seo\n end",
"def cama... | [
"0.6205917",
"0.60901994",
"0.60728276",
"0.60494053",
"0.599405",
"0.58108777",
"0.5797078",
"0.5694372",
"0.569129",
"0.5674238",
"0.5668645",
"0.5616299",
"0.5606037",
"0.558438",
"0.55697536",
"0.55638504",
"0.5536742",
"0.5536026",
"0.55350375",
"0.5528014",
"0.55126846"... | 0.55816007 | 14 |
Gets the current type attribute's value | def type
self['type']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type\n self.attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def type\n @attributes[:type]\n end",
"def value_type\n @type.value_type\n end",
"def type\n attr_... | [
"0.78003544",
"0.77100164",
"0.7668282",
"0.7668282",
"0.7668282",
"0.75117207",
"0.7466865",
"0.7422981",
"0.7300822",
"0.7290232",
"0.71729934",
"0.7155426",
"0.71400565",
"0.71258974",
"0.70320106",
"0.70320106",
"0.70320106",
"0.70320106",
"0.70320106",
"0.70320106",
"0.7... | 0.704443 | 14 |
Sets the type attribute's value | def type=(type)
self['type'] = type
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type=(type)\n write_attr :type, type\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = val... | [
"0.86953473",
"0.8539794",
"0.8539794",
"0.8539794",
"0.8539794",
"0.8539794",
"0.8539794",
"0.8539794",
"0.8466387",
"0.8302757",
"0.8230761",
"0.8181526",
"0.817837",
"0.8114125",
"0.80668706",
"0.80517",
"0.805084",
"0.80491745",
"0.8015288",
"0.7978776",
"0.7974479",
"0... | 0.8063848 | 15 |
Gets the current value attribute's value | def value
self['value']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value\n @attributes[:value]\n end",
"def value\n attributes.fetch(:value)\n end",
"def current_value\n @value\n end",
"def get_value\n @value\n end",
"def value\n @value\n end",
"def value\n @value\n end",
"def value\n return @v... | [
"0.8574868",
"0.85322654",
"0.8309908",
"0.80959237",
"0.80002624",
"0.80002624",
"0.79958004",
"0.79958004",
"0.79958004",
"0.7941724",
"0.7914703",
"0.79025954",
"0.79025954",
"0.7884767",
"0.7882802",
"0.7803875",
"0.7803875",
"0.7803875",
"0.7803875",
"0.7803875",
"0.7803... | 0.80789804 | 4 |
Sets the value attribute's value | def value=(value)
self['value'] = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value=(value)\n @value = value\n @value_set = true\n end",
"def value=(value)\n @value = value\n end",
"def set_value(value)\n @value = value\n end",
"def value=(value)\n @value = value\n end",
"def value=(value)\n @value = val... | [
"0.8652245",
"0.8651793",
"0.86175907",
"0.8599462",
"0.8599462",
"0.8599462",
"0.8485731",
"0.8447393",
"0.84305567",
"0.83629733",
"0.8352488",
"0.8293621",
"0.82422143",
"0.82364106",
"0.8217837",
"0.81796056",
"0.81599414",
"0.81295973",
"0.8120572",
"0.8077543",
"0.80702... | 0.85437864 | 6 |
List all mailing lists | def list(options={})
response = Mailgun.submit(:get, list_url, options)["items"] || []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @client.call(method: :get, path: 'recipient-lists')\n end",
"def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end",
"def index\n @mail_lists = MailList.all\n end",
"def mailboxes_list\n get \"mailboxes\"\n end",
"def mailing\n gb = Gib... | [
"0.75645286",
"0.7324172",
"0.7314068",
"0.7245025",
"0.71619785",
"0.68899566",
"0.6879543",
"0.6777096",
"0.6742243",
"0.6729593",
"0.66930526",
"0.6678078",
"0.65925694",
"0.65269196",
"0.6502744",
"0.6491451",
"0.64658934",
"0.6405798",
"0.6405798",
"0.6403956",
"0.638259... | 0.64232117 | 17 |
List a single mailing list by a given address | def find(address)
Mailgun.submit :get, list_url(address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end",
"def list_url(address=nil)\n \"#{@mailgun.base_url}/lists#{'/' + address if address}\"\n end",
"def address_list_fetch(field_name)\n if values = fetch_all(field_name, nil)\n list = nil\n values.e... | [
"0.71387213",
"0.7038603",
"0.6412147",
"0.62788033",
"0.61784786",
"0.61186785",
"0.6102625",
"0.6073309",
"0.6044168",
"0.6014143",
"0.5952885",
"0.59479433",
"0.59216946",
"0.5901179",
"0.5895365",
"0.58914",
"0.58729684",
"0.58612025",
"0.58373404",
"0.5769141",
"0.573067... | 0.74962294 | 0 |
Create a mailing list with a given address | def create(address, options={})
params = {:address => address}
Mailgun.submit :post, list_url, params.merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_address\n if @ok\n @mailing_list_address = MailingListAddress.new\n @mailing_list_address.group_id = @mailing_list_group.id\n @mailing_list_address.heading = params[:heading]\n @mailing_list_address.email = params[:email]\n @ok = @mailing_list_address.save\n end\n rende... | [
"0.71838236",
"0.7044075",
"0.6479478",
"0.6473532",
"0.63066816",
"0.6094493",
"0.607733",
"0.6019209",
"0.60179317",
"0.6014871",
"0.5962647",
"0.5930004",
"0.5929772",
"0.5924748",
"0.59244263",
"0.5890285",
"0.588425",
"0.58803403",
"0.5858954",
"0.5850831",
"0.5850385",
... | 0.7912631 | 0 |
Update a mailing list with a given address with an optional new address, name or description | def update(address, new_address, options={})
params = {:address => new_address}
Mailgun.submit :put, list_url(address), params.merge(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n end",
"def update!(**args)\n @address = args[:address] if args.key?(:address)\n @business_name = args[:business_name] if args.key?(:business_name)\n end",
"def update_contact(list_id, email, attrib... | [
"0.6679444",
"0.6426836",
"0.64000386",
"0.6370609",
"0.62479097",
"0.62142956",
"0.62118226",
"0.6187356",
"0.6164377",
"0.6160676",
"0.6160676",
"0.6142797",
"0.6135446",
"0.61072063",
"0.60949093",
"0.60574806",
"0.60353005",
"0.6027851",
"0.6025905",
"0.599905",
"0.598734... | 0.821938 | 0 |
Deletes a mailing list with a given address | def delete(address)
Mailgun.submit :delete, list_url(address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_address\n @mailing_list_address.destroy if @ok\n render 'update_addresses'\n end",
"def delete_address_list(id)\n delete(\"addressGroups/#{id}\")\n end",
"def delete_address(address)\n address.delete!\n end",
"def delete(email, list_id = nil)\n query = \"email=#{CGI.esc... | [
"0.75958645",
"0.74267596",
"0.70941395",
"0.6842968",
"0.681401",
"0.67526555",
"0.66959757",
"0.66598684",
"0.65694076",
"0.6516752",
"0.6470642",
"0.64618486",
"0.6448635",
"0.6431369",
"0.64174503",
"0.6406945",
"0.6396984",
"0.6389896",
"0.63549894",
"0.6335586",
"0.6334... | 0.75007063 | 1 |
Helper method to generate the proper url for Mailgun mailbox API calls | def list_url(address=nil)
"#{@mailgun.base_url}/lists#{'/' + address if address}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_url\n \"#{Mailgun.protocol}://api:#{Mailgun.api_key}@#{Mailgun.mailgun_host}/#{Mailgun.api_version}\"\n end",
"def make_url(dav_uri, mailbox)\n \"#{dav_uri}/#{mailbox}/\"\n end",
"def build_url(base_url, queue_name)\n return \"#{base_url}/#{queue_name}\"\n end",
"def ... | [
"0.7624175",
"0.66184914",
"0.6617954",
"0.661051",
"0.64382964",
"0.6246601",
"0.6235379",
"0.6214893",
"0.619302",
"0.61212283",
"0.60938257",
"0.60920215",
"0.60911274",
"0.6088733",
"0.6088733",
"0.605631",
"0.604059",
"0.6031597",
"0.6018392",
"0.6011611",
"0.6011569",
... | 0.580421 | 44 |
2 is obviously not helpful | def find_good_set(numbers,i)
return [] if i==0
while not numbers.empty?
x = numbers.shift
test = find_good_set(numbers.find_all{|y| good_pair?(x,y)},i-1)
return [x]+test unless test == nil
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_or_more\n -3\n end",
"def anchored; end",
"def one_or_more\n -2\n end",
"def m3; 3 end",
"def arity; 2; end",
"def bad_smell_by_nfunctions\n end",
"def mystery(n)\n 0\nend",
"def low_two_of_a_kind\n values.reverse.each do |i|\n if values.reverse.cou... | [
"0.61581075",
"0.6010702",
"0.5963642",
"0.5943594",
"0.5872732",
"0.58667123",
"0.5824876",
"0.581235",
"0.57657164",
"0.57438016",
"0.5736968",
"0.5723011",
"0.57149154",
"0.57115537",
"0.57045156",
"0.5700724",
"0.5675906",
"0.566252",
"0.5647478",
"0.5647478",
"0.5639143"... | 0.0 | -1 |
human readable description of modeling approach | def modeler_description
return ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def modeler_description\n return \"Example use case is adding special loads like an elevator to a model as part of an analysis workflow\"\n end",
"def m... | [
"0.7710149",
"0.76145315",
"0.75934714",
"0.74018747",
"0.7299891",
"0.7296635",
"0.727943",
"0.71912926",
"0.71912926",
"0.7191264",
"0.7100944",
"0.70977926",
"0.70629936",
"0.7045383",
"0.7044268",
"0.70413125",
"0.7040473",
"0.7032938",
"0.70267737",
"0.70182866",
"0.6987... | 0.6852012 | 38 |
define the arguments that the user will input | def arguments(model)
args = OpenStudio::Ruleset::OSArgumentVector.new
return args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments\n \"\"\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end... | [
"0.73748195",
"0.73748195",
"0.73748195",
"0.7087363",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
"0.7008232",
... | 0.0 | -1 |
define what happens when the measure is run | def run(model, runner, user_arguments)
super(model, runner, user_arguments)
# use the built-in error checking
if !runner.validateUserArguments(arguments(model), user_arguments)
return false
end
model.getSurfaces.each do |surface|
# vertices are in space coordinates
vertices = surface.vertices
# site vertices are the vertices in site coordinates
site_transformation = surface.space.get.siteTransformation
site_vertices = site_transformation*vertices
# face vertices are the vertices in face coordinates
face_transformation = OpenStudio::Transformation.alignFace(vertices)
face_vertices = face_transformation.inverse*vertices
# put the point 0,0,0 in face coordiantes back into space coordinates
face_origin = face_transformation*OpenStudio::Point3d.new(0,0,0)
runner.registerInfo("Surface #{surface.name}<br/><span style='font-family:courier new;'> vertices = #{print_vertices(vertices)}<br/> site_vertices = #{print_vertices(site_vertices)}<br/> face_vertices = #{print_vertices(face_vertices)}<br/> face_origin = [#{print_vertex(face_origin)}]</span>")
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure; end",
"def measure=(_arg0); end",
"def measure\n\t\t1\n\tend",
"def measure(*args, &b)\n end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def called\n self.measurement.called\n end",
"def measure\n ... | [
"0.7983946",
"0.76391083",
"0.7635224",
"0.7169362",
"0.66924226",
"0.66924226",
"0.6672431",
"0.6630611",
"0.65984803",
"0.6585971",
"0.65319055",
"0.6481404",
"0.6405025",
"0.64017195",
"0.6333557",
"0.62834954",
"0.62834954",
"0.62834954",
"0.6281307",
"0.6270175",
"0.6241... | 0.0 | -1 |
When we want to reference a Position object's coordinates, we must use ship.positions[i].x and ship.positions[i].y | def initialize(x, y)
@x = x
@y = y
@hit = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ship_coordinates\n @ship_squares.map do |squares|\n squares.map { |square| [square.x, square.y] }\n end\n end",
"def get_ship_coords_from_player\n @fleet.each do |ship|\n until ship.valid_coords == true #ship knows if its coords are valid\n orientation = @board.get_... | [
"0.76592076",
"0.6969124",
"0.6720254",
"0.6709193",
"0.6685841",
"0.6643278",
"0.66182053",
"0.6608212",
"0.654357",
"0.6446469",
"0.6413517",
"0.6408827",
"0.6398969",
"0.6392892",
"0.6328625",
"0.6318411",
"0.62878954",
"0.62839276",
"0.626582",
"0.6235921",
"0.62311447",
... | 0.0 | -1 |
Test submitting form with two fields of the same name | def test_post_multival
page = @agent.get("http://localhost/form_multival.html")
form = page.form_with(:name => 'post_form')
assert_not_nil(form)
assert_equal(2, form.fields_with(:name => 'first').length)
form.fields_with(:name => 'first')[0].value = 'Aaron'
form.fields_with(:name => 'first')[1].value = 'Patterson'
page = @agent.submit(form)
assert_not_nil(page)
assert_equal(2, page.links.length)
assert_not_nil(page.link_with(:text => 'first:Aaron'))
assert_not_nil(page.link_with(:text => 'first:Patterson'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_submit_on_form\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:na... | [
"0.69689614",
"0.67568964",
"0.6102426",
"0.6010265",
"0.59461796",
"0.5911001",
"0.5732697",
"0.5601203",
"0.55539143",
"0.5479292",
"0.54697484",
"0.5452993",
"0.54526776",
"0.5413721",
"0.5413721",
"0.54122156",
"0.5398371",
"0.5380142",
"0.5380108",
"0.53337073",
"0.53269... | 0.6770113 | 1 |
Test calling submit on the form object | def test_submit_on_form
page = @agent.get("http://localhost/form_multival.html")
form = page.form_with(:name => 'post_form')
assert_not_nil(form)
assert_equal(2, form.fields_with(:name => 'first').length)
form.fields_with(:name => 'first')[0].value = 'Aaron'
form.fields_with(:name => 'first')[1].value = 'Patterson'
page = form.submit
assert_not_nil(page)
assert_equal(2, page.links.length)
assert_not_nil(page.link_with(:text => 'first:Aaron'))
assert_not_nil(page.link_with(:text => 'first:Patterson'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_submit\r\n form.submit\r\n @form = nil\r\nend",
"def submit\r\n assert_exists\r\n submit_form \r\n @o.wait\r\n end",
"def submit_form\n @page = @form.submit\n end",
"def submit_form\n click_button 'submit'\n end",
"def click_submit\n end",
"def submit; end",
... | [
"0.77359384",
"0.77248186",
"0.7687927",
"0.74157035",
"0.73261464",
"0.7246452",
"0.71802634",
"0.71379143",
"0.70889956",
"0.70889956",
"0.6980076",
"0.69614476",
"0.68712854",
"0.68674284",
"0.6802274",
"0.6802274",
"0.6778336",
"0.6757847",
"0.6732922",
"0.6732922",
"0.67... | 0.7216442 | 6 |
Test submitting form with two fields of the same name | def test_get_multival
page = @agent.get("http://localhost/form_multival.html")
form = page.form_with(:name => 'get_form')
assert_not_nil(form)
assert_equal(2, form.fields_with(:name => 'first').length)
form.fields_with(:name => 'first')[0].value = 'Aaron'
form.fields_with(:name => 'first')[1].value = 'Patterson'
page = @agent.submit(form)
assert_not_nil(page)
assert_equal(2, page.links.length)
assert_not_nil(page.link_with(:text => 'first:Aaron'))
assert_not_nil(page.link_with(:text => 'first:Patterson'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_submit_on_form\n page = @agent.get(\"http://localhost/form_multival.html\")\n form = page.form_with(:name => 'post_form')\n\n assert_not_nil(form)\n assert_equal(2, form.fields_with(:name => 'first').length)\n\n form.fields_with(:name => 'first')[0].value = 'Aaron'\n form.fields_with(:na... | [
"0.69689614",
"0.6770113",
"0.6102426",
"0.6010265",
"0.59461796",
"0.5911001",
"0.5732697",
"0.5601203",
"0.55539143",
"0.5479292",
"0.54697484",
"0.5452993",
"0.54526776",
"0.5413721",
"0.5413721",
"0.54122156",
"0.5398371",
"0.5380142",
"0.5380108",
"0.53337073",
"0.532692... | 0.67568964 | 2 |
revert if is resolved | def hash
@__set.to_a.hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revert\n end",
"def unresolve\n change_state(:unresolve)\n end",
"def revert\n self.class.revert [self]\n end",
"def revert_to!(version)\n revert version, :hard\n self\n end",
"def revert\n\t\tself.clear_caches\n\t\t@dirty = false\n\n\t\treturn true\n\tend",
"def rever... | [
"0.7244867",
"0.7137545",
"0.6626651",
"0.64322037",
"0.6375228",
"0.6312392",
"0.63080513",
"0.61527157",
"0.607998",
"0.6076882",
"0.607032",
"0.60539263",
"0.6034204",
"0.602577",
"0.60107523",
"0.597025",
"0.59442115",
"0.5926339",
"0.5906725",
"0.59026825",
"0.58871853",... | 0.0 | -1 |
def package(&block) instance_eval(&block) end def create_method(name, &block) self.send(:define_method, name, &block) end allows appending of configure flags for the current package (default) gd.configure do |c| c << 'withwhatever=prefix' end or alternatively append configure flags for other packages: gd.configure :php do |c| c << 'withgd=prefix' end | def configure(*args)
conf_target = self
if args[0].is_a?(String) or args[0].is_a?(Symbol)
conf_target = FACTORY.send(args[0].to_sym)
end
yield conf_target.instance_variable_get("@configure") if block_given?
conf_target.instance_variable_get("@configure").join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install!\n @method_name ||= self.name.split('::').last.downcase.to_sym\n _cls = self # for self is obscured in define_method block's body\n ( class << Vendorificator::Config ; self ; end ).\n send(:define_method, @method_name ) do |name, *args, &block|\n mod = _cls.new(... | [
"0.6358286",
"0.59426403",
"0.5877358",
"0.5869282",
"0.5863037",
"0.5859998",
"0.5667525",
"0.56672543",
"0.5645333",
"0.5634808",
"0.5634808",
"0.56293875",
"0.56216025",
"0.56216025",
"0.5618099",
"0.55913615",
"0.55913615",
"0.5585487",
"0.5579566",
"0.55751896",
"0.55684... | 0.0 | -1 |
def package_dependencies(force=false) return [] if is_installed unless force return package_depends_on end | def package_depends_on
depends_on
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dependencies\n []\n end",
"def dependencies\n []\n end",
"def build_local_dependency_list(force=true)\n install_root = self.internal_package_root\n\n unless File.exists?(install_root)\n return nil unless force\n rebuild_dependency_list\n end\n\n Dir[Fil... | [
"0.77388394",
"0.7629285",
"0.7601581",
"0.7553305",
"0.7541763",
"0.74454284",
"0.7425449",
"0.7376971",
"0.7376971",
"0.7376971",
"0.7376971",
"0.736357",
"0.7360789",
"0.7349574",
"0.7341946",
"0.73008835",
"0.73008835",
"0.7253065",
"0.72396785",
"0.7235444",
"0.7216514",... | 0.79597485 | 0 |
def compile_cmd 'make j2' end def install_cmd 'make install' end def clean_cmd 'make clean' end | def is_gotten
File.exist?(package_path) && is_md5_verified
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install\n\tsystem \"make\"\n end",
"def build\n cd_and_sh( pkg_dir, build_commands )\n end",
"def install\n# Dependency tracking only, uncomment this section only if you know what you\n# are doing!\n#\n# mkdir 'build'\n# cd 'build' do\n# system \"cmake .. #{std_cmake_parameters}\"\n... | [
"0.6734177",
"0.64734024",
"0.64705765",
"0.64264864",
"0.6146586",
"0.61381656",
"0.6082572",
"0.60784847",
"0.6038011",
"0.6033691",
"0.6030359",
"0.60287786",
"0.6020638",
"0.60128796",
"0.6006925",
"0.6002507",
"0.6000753",
"0.59836894",
"0.5939882",
"0.59396726",
"0.5926... | 0.0 | -1 |
Write code here DRY Attempt Returns hash of player given a name, so that other methods can return specific player info | def lookup_by_player (player_name)
game_hash.each_pair { |h_or_a, team_info|
team_info[:players].map { |player|
if player[:player_name] === player_name
# player[:location] = h_or_a;
# player[:team_name] = game_hash[h_or_a][:team_name];
# player[:team_colors] = game_hash[h_or_a][:colors];
return player;
end
}
}
#Could add error message here if player could not be found. N/A for lab.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_name(hash)\n return hash[:name]\nend",
"def player_stats(name)\n players = players_stats(game_hash)\n \n players.each_pair do |player, stats|\n if player == name\n \n # Fix code to pass the LEARN test\n stats.delete(:player_name)\n \n return stats\n end\n end\n nil... | [
"0.76280874",
"0.7153431",
"0.6844092",
"0.6835698",
"0.6759702",
"0.67098314",
"0.6689651",
"0.6685675",
"0.66820216",
"0.6650911",
"0.6641411",
"0.656579",
"0.65472305",
"0.6546737",
"0.6545603",
"0.6516204",
"0.6513769",
"0.64928865",
"0.6455089",
"0.6454938",
"0.6454854",... | 0.685125 | 2 |
DRY Attempt Returns hash of team info when looking for a specific team | def lookup_by_team (team_name)
game_hash.map { |home_or_away, team_info|
if team_name === team_info[:team_name]
team_info[:location] = home_or_away;
return team_info;
end
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_team_info(team_name)\n team_info = game_hash.find do |color, team_data|\n team_data[:team_name] == team_name\n end\n team_info[1]\nend",
"def team_info(team_id)\n team_info_hash(team_id)\n end",
"def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[... | [
"0.8209577",
"0.80243915",
"0.73967505",
"0.7355486",
"0.7327",
"0.7322008",
"0.73188317",
"0.7280859",
"0.72722125",
"0.72686076",
"0.71976966",
"0.7189932",
"0.7189932",
"0.7179784",
"0.71696717",
"0.71151376",
"0.7111152",
"0.70994854",
"0.70809335",
"0.7073181",
"0.706868... | 0.7068622 | 21 |
DRY Attempt Returns a AoH of all players | def player_collection
all_players = [];
game_hash.each_pair { |h_or_a, team_info|
team_info[:players].map { |player|
player[:location] = h_or_a;
player[:team_name] = game_hash[h_or_a][:team_name];
player[:team_colors] = game_hash[h_or_a][:colors];
all_players << player;
}
}
all_players;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_players\n home_players = game_hash[:home][:players] # Array of player Hashes\n away_players = game_hash[:away][:players] # Array of player Hashes\n home_players + away_players # Array of player Hashes\nend",
"def all_players\n home_players = game_hash[:home][:players] # Array of player Hashes\n away... | [
"0.7240488",
"0.7240488",
"0.71385586",
"0.70466274",
"0.69507426",
"0.6912053",
"0.6904409",
"0.68284094",
"0.68257874",
"0.68008536",
"0.6763472",
"0.6755358",
"0.6740059",
"0.6724501",
"0.6724501",
"0.67176425",
"0.6696304",
"0.66931415",
"0.6682255",
"0.6650541",
"0.66329... | 0.6823564 | 9 |
Returns the points scored by player | def num_points_scored (player_name)
lookup_by_player(player_name)[:points];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def points_scored_for_player(name,game)\n game[:home_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\n game[:away_team][:players].each do |player_hash|\n return player_hash[:stats][:points] if player_hash[:player_name] == name\n end\n... | [
"0.76588863",
"0.7641648",
"0.75937146",
"0.7571153",
"0.75394684",
"0.7532965",
"0.7525876",
"0.7478467",
"0.74774414",
"0.74760145",
"0.74378204",
"0.74357593",
"0.74313986",
"0.74286175",
"0.7425263",
"0.74205977",
"0.74188447",
"0.740702",
"0.73789775",
"0.73740506",
"0.7... | 0.73430866 | 25 |
Returns the shoe size of player | def shoe_size (player_name)
lookup_by_player(player_name)[:shoe];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shoe_size(playerName)\n player_stats(playerName)[:shoe]\nend",
"def shoe_size(player_name)\n # get list of players\n players = get_players\n # find player with matching name\n found_player = find_player(players, player_name)\n # return player's shoe size\n found_player[:shoe]\nend",
"def shoe_size(n... | [
"0.8393058",
"0.82261133",
"0.81985044",
"0.8004811",
"0.79156977",
"0.78123903",
"0.7766805",
"0.77561945",
"0.7749386",
"0.7732825",
"0.7732825",
"0.76933897",
"0.7691095",
"0.7686871",
"0.7661001",
"0.762997",
"0.7612224",
"0.7545879",
"0.75455153",
"0.7531072",
"0.7513135... | 0.8005754 | 3 |
Returns the colors of team | def team_colors (team_name)
lookup_by_team(team_name)[:colors];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_colors(team)\n game_hash.each do |side, value|\n if value[:team_name] == team\n return value[:colors]\n end\n end\n end",
"def team_colors(team_name)\n\tright_team = nil\n\tgame_hash.each do |home_or_away, data|\n\t\tdata.each do |attribute, value|\n\t\t\tif attribute == :team_name && value == tea... | [
"0.8617856",
"0.8287963",
"0.82117283",
"0.8207186",
"0.8194202",
"0.81297433",
"0.81168866",
"0.8067711",
"0.7919048",
"0.7795626",
"0.77830756",
"0.7726006",
"0.7672502",
"0.7670836",
"0.76211226",
"0.76201755",
"0.7611461",
"0.76041406",
"0.7576709",
"0.7531364",
"0.751405... | 0.7780917 | 11 |
Returns both team names. Not dynamic, but does it need to be? Teams are always home and away, could be adapted into another method for tournaments | def team_names
[
game_hash.dig(:home, :team_name),
game_hash.dig(:away, :team_name)
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_names\n game = Game.find(self.game_id)\n type = self.bet_type\n if over_under?\n return \"#{game.away_team} vs #{game.home_team}\"\n elsif type == \"lay\"\n if game.spread <= 0\n return game.home_team\n else\n return game.away_team\n end\n else\n if ga... | [
"0.8469943",
"0.76590705",
"0.7613365",
"0.7595783",
"0.7552728",
"0.75323176",
"0.75323176",
"0.75323176",
"0.75323176",
"0.7456411",
"0.74353874",
"0.73893493",
"0.73689276",
"0.7319529",
"0.73154485",
"0.7300384",
"0.7291165",
"0.7198319",
"0.7198089",
"0.70930916",
"0.705... | 0.79633147 | 1 |
Returns array of jersey numbers for team | def player_numbers (team_name)
all_jersies = [];
lookup_by_team(team_name)[:players].map { |player|
all_jersies << player[:number];
}
all_jersies;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_numbers(team_name)\n team = all_team_info(team_name)\n team[:players].map do |player|\n player[:number]\n end\nend",
"def player_numbers(team_name)\n array_of_jerseys = []\n one_team_stats(team_name)[:players].each do |player, stats|\n array_of_jerseys << stats[:number]\n end\n array_of_j... | [
"0.74998224",
"0.7365563",
"0.7351597",
"0.72578573",
"0.7154844",
"0.7068934",
"0.7041595",
"0.6991162",
"0.6980928",
"0.6969954",
"0.6894792",
"0.68932664",
"0.68220276",
"0.6816457",
"0.67398953",
"0.6732363",
"0.6732256",
"0.6720778",
"0.6692669",
"0.656047",
"0.65594035"... | 0.7542146 | 0 |
Returns a players stats. Basically is my lookup_by_player method. | def player_stats (player_name)
lookup_by_player(player_name);
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_stats(player)\n game_hash.each do |location, team_data|\n team_data[:players].each do |name, stats|\n if name.to_s == player\n return stats\n end\n end\n end\nend",
"def player_stats(playerName)\n players[playerName]\nend",
"def player_stats(player_name)\n game_hash.each d... | [
"0.7854962",
"0.7849181",
"0.78485507",
"0.77261955",
"0.7615381",
"0.76011974",
"0.7578505",
"0.75376475",
"0.75055635",
"0.7481486",
"0.74378526",
"0.7402045",
"0.73494565",
"0.7302118",
"0.72688746",
"0.72614264",
"0.72552264",
"0.72197175",
"0.7125658",
"0.7123158",
"0.71... | 0.8242873 | 0 |
Returns the rebounds of player with the biggest shoe | def big_shoe_rebounds
big_shoe_player = player_collection.reduce { |memo, next_player|
memo[:shoe] > next_player[:shoe] ? memo : next_player;
}
big_shoe_player[:rebounds];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def big_shoe_rebounds\n players[player_with_most(:shoe)][:rebounds]\nend",
"def big_shoe_rebounds\n all_players = game_hash[:home][:players].merge(game_hash[:home][:players])\n big_object = all_players.max_by do |key,value|\n value[:shoe]\n end \n big_object[1][:rebounds]\nend",
"def big_shoe_rebounds\... | [
"0.83024466",
"0.8195294",
"0.8145576",
"0.81283486",
"0.8090692",
"0.80538493",
"0.7980708",
"0.79363906",
"0.7789502",
"0.7734409",
"0.7699467",
"0.7688509",
"0.765567",
"0.76496804",
"0.7562456",
"0.7560956",
"0.7472922",
"0.74616796",
"0.7433744",
"0.7408723",
"0.7404332"... | 0.76904076 | 11 |
3. Which player has the longest name? Call the method `player_with_longest_name`. Super Bonus: 1. Write a method that returns true if the player with the longest name had the most steals. Call the method `long_name_steals_a_ton?`. Returns player with the most points scored | def most_points_scored
big_score_player = player_collection.reduce { |memo, next_player|
memo[:points] > next_player[:points] ? memo : next_player;
}
big_score_player[:player_name];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def long_name_steals_a_ton?\n player_with_most(:steals) == player_with_longest_name\nend",
"def player_with_longest_name_also_had_most_steals?(game)\n player_longest_name(game) == most_steals(game)\nend",
"def player_with_longest_name\n longestName.max_by(&:length)\nend",
"def long_name_steals_a_ton?\n l... | [
"0.8404898",
"0.8081119",
"0.8045302",
"0.79781646",
"0.79124814",
"0.77866083",
"0.77182883",
"0.76244104",
"0.75691086",
"0.754592",
"0.75295967",
"0.75148463",
"0.7497775",
"0.74806464",
"0.74708986",
"0.7452582",
"0.7443772",
"0.74157697",
"0.74079156",
"0.7401228",
"0.73... | 0.66086143 | 41 |
=> "Ben Gordon" Returns team name which scored the most cumulative points | def winning_team
final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|
case
when next_player[:location] === :away
teams_points[:away] += next_player[:points];
when next_player[:location] === :home
teams_points[:home] += next_player[:points];
end
teams_points;
}
winner = final_scores.reduce { |highest_points, team_points|
highest_points[1] > team_points[1] ? highest_points : team_points;
}
game_hash[winner[0]][:team_name];
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_points_scored\n points = 0\n result = \"\"\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if points < stats[:points]\n points = stats[:points]\n result = name\n end\n end\n end\n result\nend",
"def most_points_scored()\n points = 0\n res... | [
"0.7706059",
"0.7685398",
"0.7620051",
"0.76162976",
"0.76155096",
"0.758842",
"0.7455333",
"0.74161637",
"0.73677474",
"0.7350155",
"0.7310132",
"0.7277706",
"0.72298926",
"0.72163904",
"0.718598",
"0.7174886",
"0.71062326",
"0.7043164",
"0.7004782",
"0.6985479",
"0.6944278"... | 0.6311421 | 60 |
Returns name of player with the most characters | def player_with_longest_name
player_collection.reduce { |longest_name, next_player|
longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player;
}[:player_name];
#probably easier to read to declare variable, however, good to know this works.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_with_longest_name\n players.keys.sort_by { |name| name.length }[-1]\nend",
"def player_with_longest_name\n longestName.max_by(&:length)\nend",
"def player_with_longest_name\n max_name = 0\n player_name = ''\n game_hash.keys.each do |location|\n game_hash[location][:players].keys.each do |nam... | [
"0.7885582",
"0.7850679",
"0.7775609",
"0.74523056",
"0.7401727",
"0.73853225",
"0.7381373",
"0.73366386",
"0.72873074",
"0.7276021",
"0.7271516",
"0.72666633",
"0.7263492",
"0.7138735",
"0.7015085",
"0.6884869",
"0.67687607",
"0.6742015",
"0.65812135",
"0.6554715",
"0.653303... | 0.6557617 | 19 |
Returns true if the player with the longest name, steals a lot. | def long_name_steals_a_ton
long_name_player = player_collection.reduce { |longest_name, next_player|
longest_name[:player_name].length > next_player[:player_name].length ? longest_name : next_player;
}
most_steals_player = player_collection.reduce { |most_steals, next_player|
most_steals[:steals] > next_player[:steals] ? most_steals : next_player;
}
long_name_player === most_steals_player;
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def long_name_steals_a_ton?\n longest_name = player_with_longest_name()\n player_name_with_most_steals = player_with_most_steals()\n\n if longest_name == player_name_with_most_steals\n return true\n end\n false\nend",
"def long_name_steals_a_ton?\n if player_with_longest_name == mostSteals[0]\n true... | [
"0.838977",
"0.81737137",
"0.8119735",
"0.8091636",
"0.8068787",
"0.7639363",
"0.76026756",
"0.7258259",
"0.7220508",
"0.7209721",
"0.7173911",
"0.7050161",
"0.7033831",
"0.6816754",
"0.68075556",
"0.6780254",
"0.6764679",
"0.675441",
"0.6709574",
"0.6663305",
"0.6660415",
... | 0.6467735 | 26 |
From the page 651 Range.new(start, end, exclusive=false) > rng Constructs a range using the given start and end. If the third parameter is omitted or is false, the range will include the end object; otherwise, it will be excluded. | def test_Range_ClassMethods_new
a = Range.new(-1, -5); assert_equal('Range', a.class.name)
b = Range.new(-5, -1); assert_equal('Range', b.class.name)
c = Range.new('a', 'e'); assert_equal('Range', c.class.name)
d = Range.new('a', 'e', false); assert_equal('Range', d.class.name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclusive\n if exclude_end?\n self\n else\n Range.new(self.begin, self.end + 1, true)\n end\n end",
"def initialize(first, last, exclude_end = false)\n raise NameError, \"`initialize' called twice\" if @begin\n \n unless first.kind_of?(Fixnum) && last.kind_of?(Fixnum)\n begi... | [
"0.7046357",
"0.69521165",
"0.6402998",
"0.63936335",
"0.63243616",
"0.621054",
"0.6176177",
"0.61249894",
"0.59327364",
"0.59201485",
"0.5901909",
"0.5821596",
"0.5810652",
"0.5774134",
"0.5770379",
"0.57551026",
"0.5750545",
"0.57398516",
"0.5734298",
"0.57305247",
"0.57213... | 0.5543395 | 26 |
From the page 651 rng obj > true or false Returns true if obj is a range whose beginning and end the same as those in rng (compared using ==) and whose exclusive flg is the same as rng. | def test_Range_InstanceMethods_compare
assert_equal(true, (1..3) == Range.new(1,3))
assert_equal(false, (1..3) == (2..4))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin == self.end\n end",
"def touching?(range)\n range.end == self.start || self.end == range.start\n end",
"def is_winner_on_range?(range)\n return false unless range.uniq.size == 1 && !range.first.nil?... | [
"0.6977244",
"0.6929778",
"0.67731416",
"0.674858",
"0.67211276",
"0.67209524",
"0.66546834",
"0.6573191",
"0.6429114",
"0.6391341",
"0.6363969",
"0.6352874",
"0.6332498",
"0.6322249",
"0.62675065",
"0.6162777",
"0.6158347",
"0.6155119",
"0.61278677",
"0.6119522",
"0.607159",... | 0.63622123 | 11 |
From the page 651 rng === val > true or false If rng excludes its end, returns rng.start <= val <rng.end. If rng is inclusive, returns rng.start <= val <= rng.end. Note that this implies that val need not be a member of the range itself (for example, a float fall between the start and end values of a range of integers). Implemented by calling include? Conveniently, the === operator is used by case statements. | def test_Range_InstanceMethods_excludes
assert_equal(true, (1..10) === 5)
assert_equal(false, (1..10) === 15)
assert_equal(true, (1..10) === 3.14159)
assert_equal(true, ('a'..'j') === 'c')
assert_equal(false, ('a'..'j') === 'z')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < @below) and\n (@valid_range.nil? or @valid_range.include?(val))\n end",
"def in_range?( val )\n val = val.to_i\n (@above.nil? or val > @above) and\n (@below.nil? or val < ... | [
"0.7339574",
"0.7339574",
"0.72782993",
"0.7275126",
"0.709013",
"0.7085354",
"0.6924308",
"0.6886121",
"0.68578357",
"0.6772248",
"0.6740891",
"0.6678802",
"0.66721594",
"0.6670432",
"0.6660282",
"0.663764",
"0.6587948",
"0.65817",
"0.655895",
"0.6540969",
"0.6527654",
"0.... | 0.0 | -1 |
From the page 651 rng.begin > obj Returns the first object of rng. | def test_Range_InstanceMethods_begin
assert_equal('a', ('a'..'b').begin)
assert_equal('a', ('a'...'b').begin)
assert_equal(1, (1..100).begin)
assert_equal(1, (1...100).begin)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first\n @range.first\n end",
"def begin\n @ranges.size == 1 ? @ranges[0].begin : nil\n end",
"def range_start; range.first; end",
"def get_next_object\n unless( @next_object )\n @next_object = reserve\n get_more\n end\n get_head\n end",
"def first() end"... | [
"0.6471917",
"0.64614993",
"0.63639176",
"0.60616535",
"0.60181355",
"0.5943039",
"0.59360266",
"0.580613",
"0.57939255",
"0.5789423",
"0.5752141",
"0.5746536",
"0.57435054",
"0.57434285",
"0.5620421",
"0.5593492",
"0.559294",
"0.5541309",
"0.5541309",
"0.5528023",
"0.5501722... | 0.536386 | 32 |
From the page 652 rng.end > obj Returns the object that defines the end of rng. | def test_Range_InstanceMethods_end
assert_equal(10, (1..10).end)
assert_equal(10, (1...10).end)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end; self.begin + self.size - 1; end",
"def end\n @range.end\n end",
"def end\n @ranges.size == 1 ? @ranges[0].end : nil\n end",
"def last\n @range.last\n end",
"def range_end\n @character_range[1]\n end",
"def end_pos; end",
"def end_pos; end",
"def end(end_ke... | [
"0.7237669",
"0.69368935",
"0.67486405",
"0.6460771",
"0.6437915",
"0.6182963",
"0.6182963",
"0.61781067",
"0.6131008",
"0.61212075",
"0.6050402",
"0.5983753",
"0.5875641",
"0.5874183",
"0.5869698",
"0.5856579",
"0.58346933",
"0.5810682",
"0.58041155",
"0.57766855",
"0.576066... | 0.6355115 | 5 |
From the page 653 rng.eql?(obj) > true or false Returns true if obj is a range whose beginning and end are the the same as those in rng (compared using eql?) and whose exclusive flag is the same as rng. | def test_Range_InstanceMethods_eql?
assert_equal(true , (1..10).eql?(Range.new(1,10)))
assert_equal(false, (1..10).eql?([1..10]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n return true if equal? other\n\n other.kind_of?(Range) and\n self.first == other.first and\n self.last == other.last and\n self.exclude_end? == other.exclude_end?\n \n end",
"def meets?(*args)\n other = coerce_range(*args)\n self.begin == other.end or other.begin ... | [
"0.73438793",
"0.7283759",
"0.710202",
"0.6937217",
"0.69319475",
"0.6856036",
"0.6800224",
"0.6717256",
"0.6631819",
"0.6568318",
"0.6553385",
"0.6368419",
"0.6334689",
"0.6302752",
"0.6270239",
"0.6229716",
"0.62163496",
"0.61921597",
"0.6173244",
"0.6151612",
"0.61438686",... | 0.73148656 | 1 |
From the page 653 rng.exclude_end? > true or false Returns true if rng excludes its and value. | def test_Range_InstanceMethods_exclude_end?
# TODO, need add some testcases.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclude_end?\n @ranges.size == 1 ? @ranges[0].exclude_end? : nil\n end",
"def exclude_end?\n @exclude_end\n end",
"def exclude_end?\n false\n end",
"def exclude_end?() end",
"def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend",
"def exclude_begin?\n @ranges.s... | [
"0.78446496",
"0.7428057",
"0.7289669",
"0.68370533",
"0.67327553",
"0.67320293",
"0.6677454",
"0.6375281",
"0.6320449",
"0.6171066",
"0.61512977",
"0.6137421",
"0.61352247",
"0.6039115",
"0.6019044",
"0.60181",
"0.6007065",
"0.5970629",
"0.5908297",
"0.5882339",
"0.5864835",... | 0.6669949 | 7 |
From the page 653 rng.first(n=1) > obj or array Returns the first (or first n) elements of rng. | def test_Range_InstanceMethods_first
assert_equal('aa', ('aa'..'bb').first)
assert_equal(['aa','ab','ac','ad','ae'], ('aa'..'bb').first(5))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first(*n) end",
"def first(n = 1)\n return self.clone if n >= self.size\n return self[0] if n == 1\n return self[0...n]\n end",
"def first(n = nil)\n if n\n self[0,n]\n else\n self[0]\n end\n end",
"def first(n = 1)\n if n > 1\n (ds = Array(min)).empt... | [
"0.76450205",
"0.7486319",
"0.7150061",
"0.70670307",
"0.7042806",
"0.69239825",
"0.6910762",
"0.6910762",
"0.6880357",
"0.68759686",
"0.6862687",
"0.6862687",
"0.6862687",
"0.6862687",
"0.68303907",
"0.6780862",
"0.67580646",
"0.6724696",
"0.6692148",
"0.6692148",
"0.6670999... | 0.0 | -1 |
From the page 653 rng.include?(val) > true or false Returns true if val is one of the values in rng (that is, is Rangeeach would return val at some point). If the range is defined to span numbers, this method returns true if value lies between the start and end of the range, even if it is not actually a member ( that is, it has the same behavior as Rangecover?). Otherwise, the parameter must be a member of the range. | def test_Range_InstanceMethods_include?
r = 1..10
assert_equal(true, r.include?(5))
assert_equal(true, r.include?(5.5))
assert_equal(true, r.include?(10))
r = 1...10
assert_equal(false, r.include?(10))
r = 'a'..'z'
assert_equal(true, r.include?('b'))
assert_equal(false, r.include?('ruby'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ranges_include?(value)\n any? { |range| Array(range).include?(value) }\n end",
"def in_range?(val, range)\n return true unless range\n\n if range.is_a?(Hash)\n result = true\n result &= ( val < range[:before] ) if range[:before]\n result &= ( val > range[:after] )... | [
"0.7557789",
"0.7422679",
"0.7395845",
"0.73809433",
"0.7292925",
"0.7292925",
"0.72008795",
"0.71961576",
"0.7136108",
"0.7100964",
"0.7053803",
"0.70510894",
"0.70145833",
"0.69458646",
"0.6921536",
"0.6864503",
"0.6855867",
"0.67644507",
"0.6739863",
"0.6738579",
"0.666177... | 0.65081936 | 28 |
From the page 653 rng.last(n=1) > obj or array Returns the last (or last n) elements of rng. | def test_Range_InstanceMethods_last
assert_equal('bb', ('aa'..'bb').last)
assert_equal(['ax','ay','az','ba','bb'], ('aa'..'bb').last(5))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last(*n) end",
"def last(n=nil)\n return self[-1] if n.nil?\n \n start = length-n\n start = 0 if start < 0\n self[start, n]\n end",
"def last(n = 1)\n return self.clone if n >= self.size\n return self[-1] if n == 1\n return self.reverse[0...n].reverse\n end",
"def last\n all[al... | [
"0.76323164",
"0.7443199",
"0.74066764",
"0.7318788",
"0.73128283",
"0.72899467",
"0.71919453",
"0.7143601",
"0.71191245",
"0.7098221",
"0.7098221",
"0.70971173",
"0.70961624",
"0.70566154",
"0.70369387",
"0.7035263",
"0.70233727",
"0.7019156",
"0.7001647",
"0.6987939",
"0.69... | 0.0 | -1 |
From the page 653 rng.member?(val) > true or false Synonym for Rangeinclude?. | def test_Range_InstanceMethods_member?
r = 1..10
assert_equal(true, r.member?(5))
assert_equal(true, r.member?(5.5))
assert_equal(true, r.member?(10))
r = 1...10
assert_equal(false, r.member?(10))
r = 'a'..'z'
assert_equal(true, r.member?('b'))
assert_equal(false, r.member?('ruby'))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include?(i)\n @range.include?(i)\n end",
"def ranges_include?(value)\n any? { |range| Array(range).include?(value) }\n end",
"def range_include?(ranges, addr)\n\t\t\tranges.each do |range|\n\t\t\t\treturn true if range.include? addr\n\t\t\tend\n\t\t\tfalse\n\t\tend",
"def check_include(value)\n ... | [
"0.67694825",
"0.6643983",
"0.64987695",
"0.64606565",
"0.63851225",
"0.63162804",
"0.6306146",
"0.6281779",
"0.6269659",
"0.61950886",
"0.61744666",
"0.6146276",
"0.6143199",
"0.6096666",
"0.6062473",
"0.60531837",
"0.6021256",
"0.60050917",
"0.5996035",
"0.5964964",
"0.5946... | 0.6109425 | 13 |
From the page 653 rng.size > int or nil Returns the number of elements in rng. In ruby 2.0 only works for ranges of integers | def test_Range_InstanceMethods_size
# New in 2.0!
# assert_equal(26, (1..26).size)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_between(list_of_integers,lower_bound,upper_bound)\nr = Range.new(lower_bound,upper_bound)\nnew_array=[]\nlist_of_integers.each do |x|\n if r.include?(x)\n new_array.push(x)\n end\n\nend\n\nreturn new_array.length\nend",
"def count_between(list_of_integers, lower_bound, upper_bound)\nnew_array=Arra... | [
"0.66657025",
"0.65354204",
"0.6525089",
"0.6522534",
"0.6476154",
"0.64604956",
"0.63427526",
"0.63277805",
"0.6322742",
"0.63173044",
"0.6316268",
"0.6289644",
"0.62690246",
"0.62558174",
"0.6239591",
"0.61385345",
"0.61141354",
"0.609874",
"0.60566884",
"0.6044494",
"0.595... | 0.61979157 | 15 |
gray Boom City tiles available in supply, plus how many will be made available by resolving pending upgrades to gray Double Boom City tiles | def gray_boomcity_tile_potential_count
gray_boomcity_tile_count +
[gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tiles_remaining\n # still not sure why or how this is working. TODO: may take out later\n total_num_tiles = @default_set.inject(0) { |letter, letter_quantity| letter += letter_quantity[1] }\n p \"++++TEST++++\"\n p total_num_tiles\n return total_num_tiles\n end",
"def tiles_remain... | [
"0.6707476",
"0.6505464",
"0.6171981",
"0.6090379",
"0.5993909",
"0.59258765",
"0.5882051",
"0.58278006",
"0.5783641",
"0.57422876",
"0.57153195",
"0.57030356",
"0.56827545",
"0.56681496",
"0.56669766",
"0.5665383",
"0.5653407",
"0.56423277",
"0.55822384",
"0.5565164",
"0.556... | 0.7152191 | 0 |
because gray tiles are limited, their counts could affect pending tile lays, so track them separately | def pending_boom_tile_lays
@pending_boom_tile_lays.merge(
@pending_gray_boom_tile_lays[:boom].to_h { |h| [h, boomcity_tiles(h.tile.name)] }
).merge(
@pending_gray_boom_tile_lays[:double_boom].to_h { |h| [h, [double_boomcity_tile(h.tile.name)]] }
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gray_boomcity_tile_potential_count\n gray_boomcity_tile_count +\n [gray_double_boomcity_tile_count, @pending_gray_boom_tile_lays[:double_boom].size].min\n end",
"def count_black_tiles_around(in_tiles, tile_x, tile_y)\n black_tile_count = 0\n MOVE.each do |dir, deltas|\n other_t... | [
"0.7308935",
"0.69810325",
"0.68227607",
"0.67577446",
"0.67008567",
"0.65787137",
"0.6547141",
"0.641404",
"0.6386406",
"0.6383767",
"0.6361345",
"0.63573515",
"0.63160497",
"0.6299499",
"0.62970245",
"0.6273948",
"0.62636185",
"0.6249431",
"0.62161463",
"0.6198146",
"0.6154... | 0.5664489 | 69 |
automatically lay gray Boom upgrades if enough tiles remain if no such tiles remain, remove the pending gray lays from the list of pending lays if some such tiles remain, but not enough for all of the Booming hexes, then they will be manually resolved by the BoomTrack step | def handle_gray_booms!
return if @pending_gray_boom_tile_lays.values.flatten.empty?
# clear gray double boom city actions, no tiles remain
if (num_double_boom_tiles = gray_double_boomcity_tile_count).zero?
@pending_gray_boom_tile_lays[:double_boom].clear
# there are enough gray double boom city tiles, automatically lay them
elsif num_double_boom_tiles >= @pending_gray_boom_tile_lays[:double_boom].size
@pending_gray_boom_tile_lays[:double_boom].each do |hex|
boomcity_to_double_boomcity!(hex, gray_checked: true)
end
end
# clear pending gray boom city tile lays, no tiles remain
if gray_boomcity_tile_potential_count.zero?
@pending_gray_boom_tile_lays[:boom].clear
# there are enough gray boom city tiles, automatically lay them
elsif gray_boomcity_tile_count >= @pending_gray_boom_tile_lays[:boom].size
@pending_gray_boom_tile_lays[:boom].each do |hex|
boomtown_to_boomcity!(hex, gray_checked: true)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending_boom_tile_lays\n @pending_boom_tile_lays.merge(\n @pending_gray_boom_tile_lays[:boom].to_h { |h| [h, boomcity_tiles(h.tile.name)] }\n ).merge(\n @pending_gray_boom_tile_lays[:double_boom].to_h { |h| [h, [double_boomcity_tile(h.tile.name)]] }\n )\n ... | [
"0.68826956",
"0.6176632",
"0.60074663",
"0.5950315",
"0.59274405",
"0.56083107",
"0.5607654",
"0.5589487",
"0.55878806",
"0.5583212",
"0.557387",
"0.5555022",
"0.5516676",
"0.54984146",
"0.5469843",
"0.5462013",
"0.5425392",
"0.5418034",
"0.54143566",
"0.5407485",
"0.5401977... | 0.72770035 | 0 |
add_suffix "somefile.xml", "_1234" => somefile_1234.xml"" | def add_suffix filename, suffix
parts = filename.split("\.")
base = parts[0..-2]
parts2 = base << suffix << parts[-1]
fn = parts2.join(".")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_suffix\n file_name.split('.').last \n end",
"def suffix(num)\n namespace + '_suffix_' + num.to_s\n end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def formatted_filename(name, version, suffix, extension)\n name.gsub(\"#{vers... | [
"0.70290285",
"0.69593513",
"0.690518",
"0.690518",
"0.690518",
"0.690518",
"0.690518",
"0.6796579",
"0.6610421",
"0.6555351",
"0.65308225",
"0.6454237",
"0.6397575",
"0.63385963",
"0.63100404",
"0.61908066",
"0.61215705",
"0.6119859",
"0.60992366",
"0.5972121",
"0.5951897",
... | 0.76750684 | 1 |
hash defines key => value for updating template | def replace_strings(str, rhash)
s = str.to_s
return s if ! (s && rhash)
rhash.each do |k,v|
s.gsub!(k.to_s, v.to_s)
end
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_replace template, myhash\n #tmpltext=File::read(template);\n\n t = template.dup\n t.gsub!( /##(.*?)##/ ) {\n #raise \"Key '#{$1}' found in template but the value has not been set\" unless ( myhash.has_key?( $1 ) )\n myhash[ $1 ].to_s\n }\n t\n end",
"def hash_template\n ... | [
"0.69471455",
"0.6941039",
"0.6740843",
"0.6571374",
"0.6505845",
"0.63546234",
"0.6279233",
"0.6157564",
"0.61505085",
"0.6125955",
"0.61016256",
"0.6077773",
"0.60672235",
"0.60131186",
"0.5999108",
"0.5999108",
"0.594819",
"0.59454894",
"0.594437",
"0.59335303",
"0.5919469... | 0.0 | -1 |
deberia haber seguido convencion REST (create x los 2) | def like
choosed = User.find(params[:choosed])
Interaction.create(user_id: current_user.id, choosed: choosed.id, like: true)
choosed.interactions.each do |interaction|
if interaction.choosed == current_user.id
Match.create(user_one_id: current_user.id, user_two_id: choosed.id)
redirect_to match_path
return
end
end
redirect_to search_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend",
"def create\n\t\turi = URI.parse(Counter::Application.config.simplyurl)\n\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\n\t\trequest = Net::HTTP::Post.new('/offsets.json')\n\t\tputs params\n\t\tputs params.slice(... | [
"0.6045054",
"0.6023724",
"0.5995838",
"0.5969186",
"0.59575576",
"0.5883928",
"0.58799845",
"0.5864586",
"0.58577114",
"0.5837107",
"0.58341557",
"0.57930857",
"0.57382125",
"0.57330865",
"0.5716331",
"0.5695235",
"0.56858706",
"0.56694305",
"0.5667942",
"0.5661307",
"0.5656... | 0.0 | -1 |
Convert list interests to hash | def convert_interests_to_hash
interests = Interest.all.map do |interest|
[interest.id, interest.name.gsub(/'/, "''")]
end
interests.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash() end",
"def to_hash\n @list\n end",
"def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\... | [
"0.66141266",
"0.6383351",
"0.6350658",
"0.6096092",
"0.6096092",
"0.6096092",
"0.6096092",
"0.6096092",
"0.6096092",
"0.6096092",
"0.60880315",
"0.60880315",
"0.604204",
"0.604204",
"0.6016482",
"0.60121477",
"0.5893053",
"0.5859914",
"0.5859914",
"0.58557",
"0.5849732",
"... | 0.74384373 | 0 |
Convert list regions to hash | def convert_regions_to_hash
regions = Region.all.map do |region|
[region.id, region.name.gsub(/'/, "''")]
end
regions.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def hash\n lists.inject({}){ |hash, p| hash[p[0]] ||= []; hash[p[0]] << p[1]; hash }\n end",
... | [
"0.64165616",
"0.64165616",
"0.6298657",
"0.603345",
"0.5978496",
"0.58786464",
"0.58479685",
"0.5813349",
"0.5813349",
"0.5813349",
"0.5813349",
"0.5813349",
"0.5813349",
"0.5813349",
"0.57483333",
"0.5743186",
"0.5722402",
"0.5689771",
"0.56876785",
"0.5683516",
"0.5655535"... | 0.72250307 | 0 |
Convert list industries to hash | def convert_industries_to_hash
industries = Cluster.all.map do |cluster|
[cluster.id, cluster.name.gsub(/'/, "''")]
end
industries.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [company_id, company_type, compnay_name, company_name_en, company_address, company_address_en, company_zip_code, company_tax_id, company_branch, company_branch_en, company_branch_code, company_phone, company_mobile, company_fax, company_website].hash\n end",
"def hash\n [ticker, company_n... | [
"0.6187148",
"0.6172327",
"0.6170666",
"0.59252983",
"0.58345586",
"0.58128846",
"0.57879925",
"0.5776287",
"0.576923",
"0.57294047",
"0.57084894",
"0.56902504",
"0.5689507",
"0.56777465",
"0.56734854",
"0.56700295",
"0.56560326",
"0.56513476",
"0.5634995",
"0.5628242",
"0.56... | 0.76263624 | 0 |
Convert list skills to hash | def convert_skills_to_hash
skills = Skill.all.map do |skill|
[skill.id, skill.name.gsub(/'/, "''")]
end
skills.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [list_id, email, phone, gender, first_name, last_name, is_unsubscribed, is_blacklisted, _custom_attribute_].hash\n end",
"def to_hash\n @list\n end",
"def computed_skills\n skills_hash = Hash[skills_count] # {\"générosité\"=>1, \"passion\"=>2}\n wanted_skills_hash = Hash[wanted... | [
"0.6141389",
"0.60800886",
"0.6002242",
"0.58697593",
"0.5759202",
"0.57475084",
"0.5733835",
"0.57204074",
"0.56981117",
"0.56916",
"0.56436944",
"0.5584743",
"0.5561509",
"0.55539453",
"0.55539453",
"0.553916",
"0.5510622",
"0.5501273",
"0.5482035",
"0.54812753",
"0.5480096... | 0.7976907 | 0 |
Convert list educations to hash | def convert_educations_to_hash
educations = Education.all.map do |education|
[education.id, education.name.gsub(/'/, "''")]
end
educations.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end",
"def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % su... | [
"0.60028434",
"0.60028434",
"0.60028434",
"0.60028434",
"0.60028434",
"0.60028434",
"0.60028434",
"0.5958399",
"0.5958399",
"0.59075385",
"0.58492905",
"0.5841919",
"0.58287346",
"0.5819951",
"0.57707435",
"0.5703422",
"0.5609427",
"0.5605253",
"0.5591435",
"0.5576852",
"0.55... | 0.66849023 | 0 |
Get industries query string | def industries_query_str(industry_ids)
industry_ids = industry_ids.split(',')
list_of_clusters = convert_industries_to_hash
industries_q = ['(']
industry_ids.each_with_index do |id, index|
if index.zero?
industries_q.push "industries like '%#{list_of_clusters[id.to_i]}%'"
else
industries_q.push " OR industries like '%#{list_of_clusters[id.to_i]}%'"
end
end
industries_q.push ')'
industries_q.join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_string\n end",
"def query_string\n return nil if @request.query_string.nil?\n ignore_query_params = [\"no-cachely\", \"refresh-cachely\", Rack::Cachely.config.ignore_query_params].flatten\n query = @request.query_string.split(/[&;] */n).map { |p| unescape(p).split('=', 2) }.sort... | [
"0.67935437",
"0.65269196",
"0.6448713",
"0.64261854",
"0.6323839",
"0.6293369",
"0.62864363",
"0.62228286",
"0.6221806",
"0.62193173",
"0.6199676",
"0.6172756",
"0.61655116",
"0.6156877",
"0.61501676",
"0.6129463",
"0.611977",
"0.6110325",
"0.6098706",
"0.60915345",
"0.60711... | 0.59295756 | 30 |
Get educations query string | def educations_query_str(education_ids)
education_ids = education_ids.split(',')
list_of_educations = convert_educations_to_hash
edu_query = ['(']
education_ids.each_with_index do |id, index|
if index.zero?
edu_query.push "education like '%#{list_of_educations[id.to_i]}%'"
else
edu_query.push " OR education like '%#{list_of_educations[id.to_i]}%'"
end
end
edu_query.push ')'
edu_query.join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_string\n end",
"def query_string\n return @query_string\n end",
"def query_string\n \"#{base_url}dmQuery/#{collection_alias}/#{searchstrings}/#{fields}/\" +\n \"#{sortby}/#{max_recs}/#{start}/#{suppress_pages}/#{docptr}/#{suggest}/\" +\n \"#{f... | [
"0.7206758",
"0.7026792",
"0.6618598",
"0.6618598",
"0.65273887",
"0.6515375",
"0.6489365",
"0.6470043",
"0.64572954",
"0.6367679",
"0.6365427",
"0.6332162",
"0.632026",
"0.6225295",
"0.6145192",
"0.6122958",
"0.6101451",
"0.6101064",
"0.6064199",
"0.5996661",
"0.5965971",
... | 0.5705435 | 38 |
scrape the front end of CLUTCH for company name and url | def company_name(position)
"#block-system-main > div > div > div > section > div > div.row > div > div.service-page-rows > ul > li:nth-child(#{position}) > div > div.col-xs-12.col-md-10.bordered-right.provider-base-info > div.row.provider-row-header > div > h3 > a"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCompanyInfo(url)\n\tdoc = Nokogiri::HTML(open(url))\n\tarticle = doc.css('article.company_detail')\n\n\t# top details\n\n\ttopDiv = article.css('div.top_company_detail')\n\n\tnameDiv = topDiv.css('div.com_name')\n\tname = nameDiv.css('h2').text\n\tsubName = nameDiv.css('p').text\n\tlogo = nameDiv.css('a im... | [
"0.7220884",
"0.71377754",
"0.6646778",
"0.6604847",
"0.6593254",
"0.64999235",
"0.64590096",
"0.64050984",
"0.64050984",
"0.62870485",
"0.628092",
"0.624683",
"0.624683",
"0.62284976",
"0.60694",
"0.6059287",
"0.6037628",
"0.6007892",
"0.6000365",
"0.6000208",
"0.5956205",
... | 0.54608136 | 97 |
Process a raw line and return the synthesized symbol of the truth record Sample: "5352 Recv 15:03:55.362.0 0x000001ae DataFrame StdFrame 0x08 1a3a000000000000" "9983\tRecv\t15:04:10.061.0\t0x1824f401\tDataFrame\t ExtFrame\t0x08\t004a004b004a0000 \r\n" | def preprocess_truth_line(text)
matches = text.match(/^\d+[\t|\s]+Recv[\t|\s]+.{14}[\t|\s]+0x([\d|a-f]+)[\t|\s]+\w+[\t|\s]+\w+[\t|\s]+0x[\d|a-f]+[\t|\s]+([\d|a-f]+)/)
return nil if matches.nil?
frame_id, frame_data = matches[1], matches[2]
frame_id.upcase.sub(/^[0:]*/,"") + '#' + frame_data.upcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_raw(raw, line_number)\n raw\n end",
"def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n ... | [
"0.62167466",
"0.61395377",
"0.61065084",
"0.6039564",
"0.5759533",
"0.570317",
"0.5541976",
"0.55359715",
"0.55344516",
"0.5494722",
"0.5493833",
"0.5490411",
"0.5458892",
"0.54140705",
"0.5411361",
"0.53648347",
"0.5346582",
"0.5342015",
"0.53378135",
"0.53374296",
"0.53299... | 0.68291134 | 0 |
Process a raw line and return the synthesized symbol of the observation record Sample: "(20171226 15:04:10.818578) can0 18A003A000000000000" "(20171226 15:04:05.204456) can0 28A0284004900110000\n" | def preprocess_obvervation_line(text)
matches = text.match(/can\d\s+([\d|A-F]+\#[\d|A-F]+)\n?$/)
return nil if matches.nil?
matches[1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_line(line)\n begin\n @loggie.write(\"#{line}\\n\")\n line = line.split(\" \")\n if line[9] == 'voice'\n return Message.new(line[12],line[15],'started.',line[0].to_f,GROUP,line[8])\n elsif line[9] == 'end'\n return Message.new(line[14],line[17].gsub(',',''),'ended.',li... | [
"0.587391",
"0.58448356",
"0.56759423",
"0.56545967",
"0.56508857",
"0.56350976",
"0.5508815",
"0.55046046",
"0.54666936",
"0.5457123",
"0.5401766",
"0.53997487",
"0.53987557",
"0.539206",
"0.535403",
"0.5327109",
"0.5318762",
"0.5295599",
"0.5263337",
"0.5259635",
"0.5243567... | 0.4841357 | 89 |
Compute the smallest edit distance (Levenshtein Distance) of the two token streams | def compute_smallest_edit_distance(eval_stream, ref_stream)
m_sz, n_sz = eval_stream.size, ref_stream.size
arr = Matrix.build(n_sz+1, m_sz+1) do |row, col|
if row == 0
col
elsif col == 0
row
else
0
end
end.to_a
puts "[INFO] DP Matrix generated: #{arr.size} x #{arr.first.size}"
progress_dots = 0
puts "[INFO] Start computing"
for j in 1..m_sz
for i in 1..n_sz
replace_cost = arr[i-1][j-1] + (eval_stream[j] == ref_stream[i] ? 0 : 1)
insert_cost = arr[i][j-1] + 1
delete_cost = arr[i-1][j] + 1
arr[i][j] = [replace_cost, insert_cost, delete_cost].min
end
print "."
progress_dots += 1
print " #{(progress_dots.to_f/m_sz * 100).round(3)}%\n" if (0 == progress_dots % ProgressDotsPerLine)
end
print "\n"
arr[n_sz][m_sz]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def levenshtein_distance(str1, str2)\n s = str1\n t = str2\n n = s.length\n m = t.length\n\n return m if n.zero?\n return n if m.zero?\n\n d = (0..m).to_a\n x = nil\n\n str1.each_char.with_index do |char1, i|\n e = i + 1\n\n str2.each_char.with_index do |char2, j|\n cost... | [
"0.7502699",
"0.74843526",
"0.74593514",
"0.74559355",
"0.73908305",
"0.73652923",
"0.7277934",
"0.708751",
"0.7015121",
"0.69886535",
"0.6924769",
"0.68887687",
"0.6854668",
"0.68144125",
"0.67570454",
"0.66988224",
"0.6660383",
"0.6645816",
"0.6638259",
"0.66046107",
"0.657... | 0.6015106 | 54 |
Open the two input files, read in by line, and compute their similiarity | def perform(truth_fn, observation_fn)
# Preprocess Truth file
line_num = 0
File.readlines(truth_fn).each do |text|
line_num += 1
if generate_symTable_and_tokens(text, :preprocess_truth_line, $truthTokens).nil?
puts "[INFO] Ignore #{truth_fn}:#{line_num} => #{text}"
end
end
# Preprocess Obversation file
line_num = 0
File.readlines(observation_fn).each do |text|
line_num += 1
if generate_symTable_and_tokens(text, :preprocess_obvervation_line, $observationTokens).nil?
puts "[INFO] Ignore #{observation_fn}:#{line_num} => #{text}"
end
end
puts "[INFO] >>> Number of Symbols: #{$symTable.size}"
puts "[INFO] >>> Number of Turth Stream Tokens: #{$truthTokens.size}"
puts "[INFO] >>> Number of Obversation Stream Tokens: #{$observationTokens.size}"
# Compute similarity of the obversation stream against to truth stream
if 0 == $truthTokens.size
puts "[ERROR] Can not compute similarity. Empty truth values."
exit 1
end
distance = compute_smallest_edit_distance($observationTokens, $truthTokens)
puts "[INFO] >>> Minimal Edit Distance = #{distance}"
($truthTokens.size - distance).to_f / $truthTokens.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sameFile( fileA, fileB )\n\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $o... | [
"0.6356287",
"0.6303709",
"0.61563057",
"0.6117033",
"0.60641253",
"0.6007488",
"0.5987714",
"0.59845835",
"0.59647256",
"0.5955391",
"0.5955391",
"0.5928021",
"0.59131616",
"0.59022915",
"0.58573145",
"0.5672314",
"0.56437457",
"0.5585771",
"0.55559933",
"0.54960656",
"0.548... | 0.5833666 | 15 |
Wait for page to be displayed. Url matcher from above is used to verify that page is displayed. | def initialize
# Wait for the page to be displayed with 30 seconds timeout
raise 'The page was not loaded' unless self.displayed?(30)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_until_page_loads(path)\n @wait.until { @driver.current_url == path}\n @wait.until { @driver.execute_script('return PAGE_RENDERED;') == true }\n $verbose ? puts(\"#{path} successfully loaded\") : nil\n end",
"def wait_to_load\n activity_div.wait_until(&:exists?)\n @page = @bank_page.load_... | [
"0.7413323",
"0.72536707",
"0.7201008",
"0.71494627",
"0.69868624",
"0.69339645",
"0.6843561",
"0.6831059",
"0.68261796",
"0.67356426",
"0.6705139",
"0.670131",
"0.6653075",
"0.6639472",
"0.6639472",
"0.6614516",
"0.6610064",
"0.6609883",
"0.650811",
"0.6390504",
"0.6334343",... | 0.66586405 | 18 |
Creates a new course with the following hash of params | def create_course(param = {})
course_name.set param['name']
course_oid.set param['oid']
description.set param['description']
passing_score.set param['passing_score']
prerequisite.select(param['prereq']) unless create_course_params['prereq'] == 'N/A'
course_locale.select(param['locale'])
course_duration.set param['duration']
upload_file('Course File', param['course_file'])
submit_button.click
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(params)\n response = self.class.post(\n '/webservice/rest/server.php',\n {\n :query => query_hash('core_course_create_courses', token),\n :body => {\n :courses => {\n '0' => {\n :fullname => params[:full_name],\n ... | [
"0.786746",
"0.7648681",
"0.76388013",
"0.7608392",
"0.7579288",
"0.7557643",
"0.75401956",
"0.7527627",
"0.7508889",
"0.7508591",
"0.7502794",
"0.74793756",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
"0.7472013",
... | 0.8029758 | 0 |
group_owner_id defaults to the current owner_id | def authorize_ec2_security_group(group_name, group_owner_id=owner_id)
key = group_name.match(/^sg-/) ? 'EC2SecurityGroupId' : 'EC2SecurityGroupName'
authorize_ingress({
key => group_name,
'EC2SecurityGroupOwnerId' => group_owner_id
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_owner\n User.find_by(id: self.user_id)\n end",
"def owner_of(group)\n current_user.is_owner?(group)\n end",
"def with_group_owner\n self\n end",
"def set_owner(id)\n self.owner_id = id\n end",
"def owner_user_id\n return @owner_user_id\n end",
"def owner_user_i... | [
"0.8172053",
"0.77662015",
"0.7726203",
"0.71466225",
"0.70898277",
"0.70898277",
"0.6991115",
"0.6990758",
"0.69636214",
"0.69533837",
"0.69533837",
"0.6952436",
"0.6907562",
"0.6907562",
"0.68503493",
"0.6818043",
"0.6802009",
"0.67520535",
"0.6716727",
"0.66990435",
"0.666... | 0.0 | -1 |
Add the current machine to the RDS security group. | def authorize_me
authorize_ip_address(Fog::CurrentMachine.ip_address)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n ec2 = self.class.new_ec2(@resource.value(:user), @resource.value(:password))\n group = @resource.value(:name)\n begin\n ec2.describe_security_groups({:group_name => group})\n rescue Exception => e\n ec2.create_security_group({ \n :group_name => group,\n :group_descr... | [
"0.57602894",
"0.5734369",
"0.5555561",
"0.5528507",
"0.5337871",
"0.53162956",
"0.5296002",
"0.5228811",
"0.52073044",
"0.51378554",
"0.5137595",
"0.512515",
"0.50814545",
"0.5078808",
"0.50601643",
"0.50600517",
"0.50364786",
"0.5032829",
"0.50321704",
"0.5020412",
"0.50073... | 0.0 | -1 |
Add the ip address to the RDS security group. | def authorize_ip_address(ip)
authorize_cidrip("#{ip}/32")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def security_group=(new_cidr_block)\n new_cidr_block = new_cidr_block + '/32' unless new_cidr_block.include? \"/\"\n @environment.vpc.security_groups.each do |sg|\n @security_group = sg if sg.group_name == 'SshSecurityGroup' + new_cidr_block\n end\n\n # only create security group if it does not ex... | [
"0.6491142",
"0.614331",
"0.6031237",
"0.60004073",
"0.5926284",
"0.5926284",
"0.58699954",
"0.58220404",
"0.5800351",
"0.5796592",
"0.5758454",
"0.5721502",
"0.57127887",
"0.56476074",
"0.5643926",
"0.5621095",
"0.561757",
"0.5600346",
"0.5598551",
"0.55921835",
"0.55314344"... | 0.0 | -1 |
group_owner_id defaults to the current owner_id | def revoke_ec2_security_group(group_name, group_owner_id=owner_id)
key = group_name.match(/^sg-/) ? 'EC2SecurityGroupId' : 'EC2SecurityGroupName'
revoke_ingress({
key => group_name,
'EC2SecurityGroupOwnerId' => group_owner_id
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_owner\n User.find_by(id: self.user_id)\n end",
"def owner_of(group)\n current_user.is_owner?(group)\n end",
"def with_group_owner\n self\n end",
"def set_owner(id)\n self.owner_id = id\n end",
"def owner_user_id\n return @owner_user_id\n end",
"def owner_user_i... | [
"0.81719637",
"0.77667946",
"0.7725763",
"0.7146375",
"0.7089867",
"0.7089867",
"0.6990967",
"0.69906116",
"0.69637877",
"0.6953418",
"0.6953418",
"0.6952131",
"0.6907714",
"0.6907714",
"0.68497586",
"0.6817341",
"0.68021923",
"0.6752042",
"0.6716601",
"0.66992486",
"0.666032... | 0.0 | -1 |
Returns error message if there is an error | def error?
task_result_field if States::Error.include?(task_state)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message\n @errormsg\n end",
"def error\n valid? ? nil : @error_message\n end",
"def error_message; end",
"def error_message\n error.message\n end",
"def error message\n message = \"ERROR: \" + process_message(message)\n output_message message, @error_color if valid_con... | [
"0.7982122",
"0.79227185",
"0.7870464",
"0.76630884",
"0.76078886",
"0.7585859",
"0.75676686",
"0.75119203",
"0.74794",
"0.7406865",
"0.7352388",
"0.73436135",
"0.7312576",
"0.7307238",
"0.7293063",
"0.7285613",
"0.72824585",
"0.7279738",
"0.7275888",
"0.7269337",
"0.72584414... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.