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 |
|---|---|---|---|---|---|---|
Remove an element of current folder given the name Params: +name+:: item name to be removed | def remove_element(name)
@element_list.delete_if{|e|
e.name == name
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeNamedItem(name)\n getNamedItem(name).remove\n end",
"def remove_by_name(name)\n p = get_by_name(name)\n if (p != nil)\n return remove(p)\n end \n end",
"def remove_by_name(name)\n fw = get_by_name(name)\n if (fw != nil)\n return remove(fw)\n en... | [
"0.8024502",
"0.7679463",
"0.765818",
"0.7332817",
"0.7259456",
"0.72351766",
"0.71850127",
"0.7126715",
"0.69702256",
"0.6885262",
"0.68367624",
"0.68367624",
"0.68367624",
"0.6830028",
"0.67952293",
"0.6789976",
"0.678763",
"0.6686446",
"0.6646198",
"0.6644099",
"0.6632055"... | 0.764056 | 3 |
Return the list of elements: folders and images Params: +path+:: folders path | def list_elements(path)
return @element_list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def folders\n xpath './folder'\n end",
"def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.coun... | [
"0.68734086",
"0.67162555",
"0.6700611",
"0.6609244",
"0.65742",
"0.64641976",
"0.64496046",
"0.63831675",
"0.6383112",
"0.6341366",
"0.63192004",
"0.625608",
"0.6250279",
"0.6238051",
"0.61524254",
"0.6149613",
"0.61456925",
"0.6120569",
"0.61133146",
"0.6077465",
"0.6063345... | 0.5875153 | 26 |
Create a new element image Params: +name+:: image name file +data+:: raw data encoded in base64 format | def initialize(name, data = nil)
super(name)
# Create a fake ElemImage
if not data.nil?
@data = data
set_preview()
end
@tags = Array.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_image(name, data)\n elem = ElemImage.new(name, data)\n add_element(elem)\n end",
"def create\n data = image_params[:data]\n\n if data\n @image = Image.new.tap do |t|\n t.data = data.read\n t.description = data.original_filename\n end\n end\n\n respond_to do |for... | [
"0.8038413",
"0.69392025",
"0.67863214",
"0.6761201",
"0.6750616",
"0.65513587",
"0.65075296",
"0.64962435",
"0.64941376",
"0.6423913",
"0.62506497",
"0.6248157",
"0.6239548",
"0.62000585",
"0.61777496",
"0.6170078",
"0.6150181",
"0.61439335",
"0.6143416",
"0.6119093",
"0.611... | 0.67227453 | 5 |
Set a thumbnail for the current image | def set_preview()
temporal = get_random_dir()
FileUtils::mkdir_p "./temp/#{temporal}"
File.open("./temp/#{temporal}/#{@name}", 'wb') do |f|
f.write(Base64.decode64(@data))
f.close
end
img = ImageList.new("./temp/#{temporal}/#{@name}")
width, height = 150, 150
thumb = img.resize_to_fit(width, height)
thumb.write("./temp/#{temporal}/thumb_#{@name}")
img.destroy!
thumb.destroy!
GC.start
f_thumb = File.open("./temp/#{temporal}/thumb_#{@name}", 'rb')
thumb_s = f_thumb.read
encoded_string = Base64.strict_encode64(thumb_s)
f_thumb.close
@preview = encoded_string
FileUtils.rm_rf(Dir.glob('./temp/#{temporal}/*'))
FileUtils.rm_rf('./temp/#{temporal}/')
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_thumbnail\n @thumbnail = Thumbnail.find(params[:id])\n end",
"def thumbnail!\n image.recreate_versions! if thumbnail_coordinates_changed?\n end",
"def set_thumbnail\n dir_name = File.dirname(@path)\n\n if File.exists?(dir_name + '/thumbnails/' + @file_name)\n @thumbnail = dir_na... | [
"0.7652176",
"0.7312374",
"0.7274713",
"0.6766907",
"0.6632878",
"0.6627596",
"0.6619362",
"0.6521404",
"0.6501132",
"0.64227283",
"0.64157206",
"0.6358383",
"0.6350575",
"0.62945926",
"0.6282541",
"0.62528425",
"0.6245",
"0.62286675",
"0.61763215",
"0.6172776",
"0.6159089",
... | 0.60111403 | 31 |
Add a tag element to tags list Params: +tag+:: String tag element to be added | def add_tag(tag)
if not tag.kind_of?(String)
raise "tag '#{tag.inspect}' is not a String"
end
if not @tags.include?(tag)
@tags.push(tag)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(tag)\n return nil if tag.nil?\n get_list(tag) << tag\n end",
"def add_tag(tag)\n @api.post(\"#{@api.path}/List/#{@id}/Tag\", body: tag)\n end",
"def add_tag(tag)\n @added_tags ||= Set.new\n @added_tags << tag\n end",
"def add_tag(tag)\r\n s... | [
"0.84965324",
"0.8365562",
"0.8192638",
"0.81339",
"0.8084619",
"0.78674704",
"0.78641444",
"0.7806318",
"0.7590903",
"0.756516",
"0.735697",
"0.727346",
"0.727346",
"0.7213086",
"0.7196795",
"0.715527",
"0.71396285",
"0.7108268",
"0.70784944",
"0.6962239",
"0.6949853",
"0.... | 0.8440724 | 1 |
Remove an existing tag Params: +tag+:: String tag to be removed | def delete_tag(tag)
if not tag.kind_of?(String)
raise "tag '#{tag.inspect}' is not a String"
end
if @tags.include?(tag)
@tags.delete(tag)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_tag (tag)\n `rs_tag --remove \"#{tag}\"`\n end",
"def remove_tag(tag)\r\n self.tags.all(:name => tag.name).destroy\r\n end",
"def delete_tag tag\n delete \"tag/#{tag}\"\n end",
"def remove_tag(tag)\n\n # it's a bit convoluted... trying to cope with potential inconsiste... | [
"0.89350694",
"0.84345907",
"0.8310276",
"0.81095326",
"0.80983466",
"0.8006342",
"0.78906214",
"0.7881145",
"0.7820389",
"0.7651982",
"0.7602269",
"0.7576496",
"0.753511",
"0.7526821",
"0.7299816",
"0.72779053",
"0.7263261",
"0.72136724",
"0.7202351",
"0.71180326",
"0.710811... | 0.85822165 | 1 |
Generate a random dir name | def get_random_dir()
return (0...50).map { ('a'..'z').to_a[rand(26)] }.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dir(name = :test)\n @dirs[name.to_sym] ||= Pathname.new(\n File.expand_path(\"#{Dir.tmpdir}/#{Time.now.to_i}#{rand(1000)}/\"))\n end",
"def generate_name\n @seed ||= 0\n @seed += 1\n \"_anon_#{@seed}\"\n end",
"def random_name\n SecureRandom.hex(20)\n end",
"def rfold... | [
"0.7344269",
"0.7196336",
"0.70977837",
"0.7017638",
"0.6981843",
"0.6962934",
"0.6884985",
"0.687063",
"0.68673164",
"0.67774785",
"0.6729956",
"0.6729956",
"0.6696002",
"0.66544217",
"0.65930045",
"0.65914667",
"0.6566541",
"0.6561699",
"0.654645",
"0.6533214",
"0.65134084"... | 0.8263759 | 0 |
GET /Unit/1 GET /unit/1.xml | def show
@unit = Unit.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @unit }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @unit = Unit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @unit }\n end\n end",
"def show\n @unit_type = UnitType.find(params[:id])\n respond_to do |format|\n format.json { render json: @unit_type }\n form... | [
"0.7254404",
"0.68162423",
"0.6680625",
"0.66078967",
"0.6590373",
"0.65897095",
"0.65603596",
"0.65185696",
"0.65185696",
"0.65185696",
"0.6458335",
"0.6441875",
"0.6406214",
"0.63294095",
"0.62453425",
"0.6231326",
"0.6226446",
"0.61949766",
"0.61941874",
"0.6159124",
"0.61... | 0.6516072 | 10 |
P for paragraph instead of puts | def p(*args)
method_missing(:p, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paragraphize(input)\n \"#{input.lstrip.rstrip.gsub(/\\n\\n/, '</p><p>').gsub(/\\n/, '')}\"\n end",
"def paragraph; end",
"def paragraph(text)\n \"<p>#{text}</p>\"\n end",
"def paragraph(text)\n add_custom_tags(\"<p>#{text.strip}</p>\\n\")\n end",
"def body_paragraph(num)\n puts \"#{num... | [
"0.7772114",
"0.74232733",
"0.73539823",
"0.7273219",
"0.71446747",
"0.7113146",
"0.7113146",
"0.70543635",
"0.7047311",
"0.7047072",
"0.6982673",
"0.69415873",
"0.6940919",
"0.68824476",
"0.68329626",
"0.67988896",
"0.67270917",
"0.671181",
"0.6707464",
"0.66985977",
"0.6690... | 0.0 | -1 |
Optional arguments (given as hash optional) +filter+ > Booleanreturning [ReQL]( expression, which allows you to filter items to be listed. Only the items for which the expression is true will be returned. | def initialize(optional = {})
@filter = optional['filter']
@optional = optional
@timeout = 30000
@ensure_https = false
@optional.each do |par, _|
fail UnknownOptionalParameter.new(par) unless ["filter"].include? par
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter(filter)\n @query[:q] << \"filter:#{filter}\"\n self\n end",
"def list_filter(**opt)\n # May be overridden by the subclass.\n end",
"def filter\n @filter = params[:q]\n end",
"def searchUsing(filter)\n @zqlQuery = filter\n end",
"def list(filter)\n List.new(optio... | [
"0.6807616",
"0.6354888",
"0.6255562",
"0.6211298",
"0.6206977",
"0.6206977",
"0.61642516",
"0.6134432",
"0.6130225",
"0.6092029",
"0.6034763",
"0.6034763",
"0.60178596",
"0.59703505",
"0.59592605",
"0.5954552",
"0.59532106",
"0.5946451",
"0.59352493",
"0.5907176",
"0.5905844... | 0.0 | -1 |
Values of body parameters as a Hash | def body_parameters
p = Hash.new
p
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body_params(request)\n body = request.body.read\n return {} if body.empty?\n\n JSON\n .parse(body)\n .each_with_object({}) { |(key, value), res| res[key] = filtered_value(key, value) }\n end",
"def request_body\n MAPPING.keys.inject({}) do |mem, e|\n next mem unles... | [
"0.71729606",
"0.7139374",
"0.69017446",
"0.68907666",
"0.6833561",
"0.6789942",
"0.6779669",
"0.67790276",
"0.6769272",
"0.67527705",
"0.6706808",
"0.6706808",
"0.6706808",
"0.6706808",
"0.6677066",
"0.6609662",
"0.6577909",
"0.6555701",
"0.6535505",
"0.6508655",
"0.6508655"... | 0.82885647 | 0 |
Values of query parameters as a Hash. name of parameter => value of the parameter | def query_parameters
params = {}
params['filter'] = @optional['filter'] if @optional['filter']
params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_values\n CGI.parse(parsed_url.query || \"\").inject({}) do |hash, (key, values)|\n hash.merge!(key.to_sym => values.first)\n end\n end",
"def params\n params = {}\n @options[:params].each{|key, value| params[key.to_s] = escape((value.class == Array ? value.join(\",\") : va... | [
"0.8128486",
"0.7268927",
"0.712609",
"0.70504725",
"0.7048077",
"0.6898153",
"0.6874682",
"0.6858629",
"0.6851548",
"0.68484086",
"0.68353003",
"0.6789605",
"0.67849034",
"0.6780333",
"0.6777408",
"0.67714834",
"0.6769854",
"0.6768476",
"0.676557",
"0.676557",
"0.676557",
... | 0.6651196 | 34 |
Relative path to the endpoint | def path
"/{databaseId}/items/list/"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def web_endpoint\n File.join(@web_endpoint, \"\")\n end",
"def relative_path; end",
"def re... | [
"0.7422241",
"0.7344933",
"0.7344933",
"0.7344933",
"0.73063546",
"0.73063546",
"0.73063546",
"0.73063546",
"0.73063546",
"0.7226793",
"0.7141356",
"0.7135636",
"0.7099657",
"0.709893",
"0.7030732",
"0.70250756",
"0.7023122",
"0.70048136",
"0.6993529",
"0.6992715",
"0.6975351... | 0.0 | -1 |
Defines when the token is able to match. This provides context that cannot be expressed otherwise, such as feature flags. | def acceptable_when(block)
@acceptable_when = block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_token(token)\n return true\n end",
"def soft_accept(token=current_token)\n (token == current_token).tap do |result|\n accept if result\n end\n end",
"def token_valid?\n raise 'To be implemented in child classes'\n end",
"def accept_limitable_token?(token_or_object)\n ... | [
"0.6201978",
"0.6012208",
"0.58029675",
"0.5782884",
"0.5765047",
"0.5685254",
"0.56549525",
"0.55465615",
"0.55271244",
"0.5469669",
"0.53765655",
"0.53444433",
"0.533253",
"0.533253",
"0.5324759",
"0.5316067",
"0.53139627",
"0.5286869",
"0.52672106",
"0.5264739",
"0.5264739... | 0.0 | -1 |
Creates an empty token list | def initialize
@tokens = {}
@regex_tokens = []
@string_tokens = []
@tokens_by_string = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokens\n @tokens ||= []\n end",
"def constructor\n\t\t\tarray_of_arrays = []\n\t\t\t6.times do |i|\n\t\t\t\tarray_of_arrays[i] = []\n\t\t\t\t7.times do \n\t\t\t\t\tarray_of_arrays[i] << Token.new \n\t\t\t\tend\n\t\t\tend\n\t\t\tarray_of_arrays\n\t\tend",
"def todos_tokens\n le_tokens(0..)\n ... | [
"0.7212405",
"0.67418134",
"0.6418341",
"0.64168227",
"0.6366059",
"0.6366059",
"0.6366059",
"0.6366059",
"0.6366059",
"0.6366059",
"0.6366059",
"0.6366059",
"0.63309187",
"0.63142216",
"0.631095",
"0.6215272",
"0.6205885",
"0.61788154",
"0.6089436",
"0.6089436",
"0.6089436",... | 0.58071613 | 45 |
Sort literal (string) tokens by length, so we know once we match, we're done. This helps avoid the O(n^2) nature of token matching. The tokens are sorted in place. | def sort_tokens
@string_tokens.sort! { |a, b| b.string.length <=> a.string.length }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_length(my_sentence)\n words = my_sentence.split(/\\W+/)\n\n words.size.times do |first_index| \n min_index = first_index\n\n (words.size-first_index).times do |subarray_index|\n if words[first_index+subarray_index].length < words[min_index].length \n min_index = first_index + subarr... | [
"0.6338004",
"0.6294598",
"0.62299085",
"0.5982418",
"0.5951991",
"0.5889627",
"0.58869135",
"0.58865076",
"0.58631873",
"0.58592385",
"0.5780963",
"0.57716954",
"0.57574606",
"0.57416046",
"0.57396775",
"0.5730002",
"0.5714128",
"0.57055867",
"0.57017666",
"0.56982297",
"0.5... | 0.80472547 | 0 |
Yield each token name and value in turn. | def each
@tokens.each {|name, value| yield name, value }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n while (token = next_token)\n yield token\n end\n end",
"def each &block\n @tokens.each &block\n end",
"def each # yields: name, value\n @fields.each { |i|\n yield [i.name, i.value]\n }\n end",
"def each()\n fields.each... | [
"0.703246",
"0.67316145",
"0.6254835",
"0.61529815",
"0.6114309",
"0.60947883",
"0.60749733",
"0.602065",
"0.602065",
"0.60162055",
"0.60162055",
"0.60162055",
"0.60162055",
"0.60162055",
"0.60162055",
"0.60162055",
"0.60162055",
"0.6010253",
"0.5939956",
"0.59244245",
"0.592... | 0.8332228 | 0 |
scan the whole file basically just used for testing | def fullscan
array = []
self.scan { |token, str|
# Ignore any definition nesting problems
@indefine = false
array.push([token,str])
}
array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_file (file_name)\n #for each line\n File.open(file_name).each do |line|\n parsed_line = parse_line line\n raise \"Invalid spec format:\\n\" + line if parsed_line.class == InvalidLine\n update_on_new_line parsed_line\n end \n @test_suite.add_test_case current_test_case if cur... | [
"0.69331056",
"0.6609932",
"0.6574925",
"0.64443153",
"0.6281207",
"0.62577933",
"0.6233339",
"0.6221442",
"0.62154996",
"0.6203702",
"0.6190686",
"0.6189677",
"0.6166364",
"0.6149693",
"0.6120718",
"0.6110258",
"0.6100901",
"0.6084658",
"0.6083488",
"0.6080131",
"0.60746694"... | 0.0 | -1 |
Find the next token that matches a regex. We look for these first. | def find_regex_token
best_token = nil
best_length = 0
# I tried optimizing based on the first char, but it had
# a slightly negative affect and was a good bit more complicated.
TOKENS.regex_tokens.each do |token|
if length = @scanner.match?(token.regex) and token.acceptable?(lexing_context)
# We've found a longer match
if length > best_length
best_length = length
best_token = token
end
end
end
return best_token, @scanner.scan(best_token.regex) if best_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_regex regex\n if regex.is_a? Symbol\n regex = @text_patterns[regex]\n raise \"Pattern specified #{regex} does not exist in text_patterns \" unless regex\n end\n @last_regex = regex\n find_more\n end",
"def regex_token\n return if @chunk[0] != '/'\n length = her... | [
"0.7275594",
"0.7032459",
"0.6990419",
"0.68577456",
"0.6670748",
"0.6610332",
"0.6524977",
"0.6509122",
"0.6494141",
"0.6417967",
"0.6313416",
"0.6290375",
"0.6275873",
"0.6273385",
"0.62148386",
"0.6169835",
"0.6117423",
"0.6111705",
"0.6081944",
"0.60802066",
"0.6061838",
... | 0.7889047 | 0 |
Find the next token, returning the string and the token. | def find_token
shift_token || find_regex_token || find_string_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_token\n tokens.shift\n end",
"def next\n\t\tif @next_token\n\t\t\ttoken = @next_token\n\t\t\t@next_token = nil\n\t\t\treturn token\n\t\telse\n\t\t\ttoken = read_token\n\t\t\treturn token\n\t\tend\n\tend",
"def next_token\n @tokens.shift\n end",
"def next()\n if @ss.scan_until(token_re)\... | [
"0.77912265",
"0.7597295",
"0.75661474",
"0.7513609",
"0.7505228",
"0.74702686",
"0.74235845",
"0.739657",
"0.73887914",
"0.7347198",
"0.72881716",
"0.71980375",
"0.7127303",
"0.70877445",
"0.7085526",
"0.7058631",
"0.6999692",
"0.69971216",
"0.69786435",
"0.6968315",
"0.6945... | 0.79630405 | 0 |
Returns true if ruby version >= 1.9.3 since regexp supports multibyte matches and expanded character categories like [[:blank:]]. This implementation will fail if there are more than 255 minor or micro versions of ruby | def init_multibyte
numver = RUBY_VERSION.split(".").collect {|s| s.to_i }
return true if (numver[0] << 16 | numver[1] << 8 | numver[2]) >= (1 << 16 | 9 << 8 | 3)
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ruby_m17n?\n return true if \"\".respond_to? :encoding\nend",
"def supports_regexp?\n true\n end",
"def supports_regexp?\n true\n end",
"def is_1_9_or_later?\n \"1.9\".respond_to?(:encoding)\n end",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def mul... | [
"0.67353904",
"0.6420967",
"0.64198494",
"0.61302364",
"0.60355073",
"0.59897786",
"0.5898182",
"0.5811034",
"0.57272613",
"0.56797385",
"0.56797385",
"0.5643132",
"0.56373304",
"0.5624298",
"0.5612669",
"0.5589698",
"0.5580018",
"0.5573218",
"0.5550607",
"0.5503736",
"0.5489... | 0.7060692 | 0 |
Make any necessary changes to the token and/or value. | def munge_token(token, value)
# A token may already have been munged (converted and positioned)
#
return token, value if value.is_a? Hash
skip if token.skip_text
return if token.skip
token, value = token.convert(self, value) if token.respond_to?(:convert)
return unless token
return if token.skip
# If the conversion performed the munging/positioning
return token, value if value.is_a? Hash
pos_hash = position_in_source
pos_hash[:value] = value
# Add one to pos, first char on line is 1
return token, pos_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_Token(value)\n set_input(\"Token\", value)\n end",
"def set_Token(value)\n set_input(\"Token\", value)\n end",
"def set_Token(value)\n set_input(\"Token\", value)\n end",
"def set_Token(value)\n set_input(\"Token\", value)\n end",
"def set_Token(value... | [
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.65299976",
"0.648497",
"0.6439002",
"0.62790334",
"0.61950505",
"0.61369854",
"0.606439",
"0.60390604",
"0.60387737",
"0.60027367",
"0.6001009",
"0.5969704",
"0.... | 0.5522207 | 85 |
Returns a hash with the current position in source based on the current lexing context | def position_in_source
pos = @locator.pos_on_line(lexing_context[:offset])
offset = @locator.char_offset(lexing_context[:offset])
length = @locator.char_length(lexing_context[:offset], lexing_context[:end_offset])
start_line = @locator.line_for_offset(lexing_context[:offset])
return { :line => start_line, :pos => pos, :offset => offset, :length => length}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n source_position.hash\n end",
"def lex_state; end",
"def hash\n offset.hash\n end",
"def hash_char_positions\n hash_positions= []\n @lines.each_with_index do |line, line_index|\n line.enum_for(:scan, /#/).each do\n hash_positions << [line_index, Regexp.last_mat... | [
"0.6972583",
"0.6220081",
"0.60452026",
"0.5902621",
"0.5892592",
"0.58650255",
"0.5742433",
"0.5713725",
"0.5698491",
"0.5698491",
"0.5698491",
"0.5698491",
"0.5610938",
"0.55897266",
"0.55897266",
"0.55897266",
"0.55897266",
"0.5546867",
"0.5544935",
"0.5542613",
"0.5469671... | 0.67900187 | 1 |
Collect the current namespace. | def namespace
@namestack.join("::")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_namespace\n @current_namespace\n end",
"def collect_namespaces(object); end",
"def namespaces\n root ? root.collect_namespaces : {}\n end",
"def collect_namespaces\n # TODO: print warning message if a prefix refers to more than one URI in the document?\n ns = {}\... | [
"0.74915904",
"0.747886",
"0.74407864",
"0.7214919",
"0.7165817",
"0.7165817",
"0.7165817",
"0.7165817",
"0.69004107",
"0.68653",
"0.68653",
"0.68653",
"0.68653",
"0.68653",
"0.68653",
"0.68653",
"0.68653",
"0.6848573",
"0.6717477",
"0.6708551",
"0.6672187",
"0.65588754",
... | 0.6753942 | 18 |
this is the heart of the lexer | def scan
#Puppet.debug("entering scan")
lex_error "Internal Error: No string or file given to lexer to process." unless @scanner
# Skip any initial whitespace.
skip
until token_queue.empty? and @scanner.eos? do
offset = @scanner.pos
matched_token, value = find_token
end_offset = @scanner.pos
# error out if we didn't match anything at all
lex_error "Could not match #{@scanner.rest[/^(\S+|\s+|.*)/]}" unless matched_token
newline = matched_token.name == :RETURN
lexing_context[:start_of_line] = newline
lexing_context[:offset] = offset
lexing_context[:end_offset] = end_offset
final_token, token_value = munge_token(matched_token, value)
# update end position since munging may have moved the end offset
lexing_context[:end_offset] = @scanner.pos
unless final_token
skip
next
end
lexing_context[:after] = final_token.name unless newline
if final_token.name == :DQPRE
lexing_context[:interpolation_stack] << lexing_context[:brace_count]
elsif final_token.name == :DQPOST
lexing_context[:interpolation_stack].pop
end
value = token_value[:value]
if match = @@pairs[value] and final_token.name != :DQUOTE and final_token.name != :SQUOTE
@expected << match
elsif exp = @expected[-1] and exp == value and final_token.name != :DQUOTE and final_token.name != :SQUOTE
@expected.pop
end
yield [final_token.name, token_value]
if @previous_token
namestack(value) if @previous_token.name == :CLASS and value != '{'
if @previous_token.name == :DEFINE
if indefine?
msg = "Cannot nest definition #{value} inside #{@indefine}"
self.indefine = false
raise Puppet::ParseError, msg
end
@indefine = value
end
end
@previous_token = final_token
skip
end
# Cannot reset @scanner to nil here - it is needed to answer questions about context after
# completed parsing.
# Seems meaningless to do this. Everything will be gc anyway.
#@scanner = nil
# This indicates that we're done parsing.
yield [false,false]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lex_start; end",
"def lex_start; end",
"def lex_start; end",
"def lex_start; end",
"def lex_state; end",
"def lex_start=(_arg0); end",
"def lex_start=(_arg0); end",
"def lex_start=(_arg0); end",
"def lex_start=(_arg0); end",
"def lex_en_expr_beg; end",
"def lex_en_expr_beg; end",
"def lex... | [
"0.7861751",
"0.7861751",
"0.7861751",
"0.7861751",
"0.7465163",
"0.73807234",
"0.73807234",
"0.73807234",
"0.73807234",
"0.7330933",
"0.7330933",
"0.7330933",
"0.73222506",
"0.73222506",
"0.73222506",
"0.73222506",
"0.72994894",
"0.72994894",
"0.72773147",
"0.7236444",
"0.72... | 0.0 | -1 |
Skip any skipchars in our remaining string. | def skip
@scanner.skip(@skip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def skip\n @str.slice! @last_re if peek_next_type != :eos\n end",
"def skipChars(pos, code)\n max = @src.length\n while pos < max\n break if (charCodeAt(@src, pos) != code)\n pos += 1\n end\n return pos\n end",
"def skip_space\n @str.slice!(/\\A[ \\t]+/... | [
"0.7593563",
"0.6560959",
"0.64228886",
"0.6250866",
"0.6080288",
"0.6057893",
"0.60271347",
"0.6011382",
"0.59288347",
"0.5927362",
"0.5920899",
"0.5882763",
"0.5882763",
"0.5863297",
"0.58393115",
"0.58328104",
"0.5825309",
"0.5823364",
"0.5793063",
"0.578884",
"0.57712454"... | 0.62386554 | 4 |
we've encountered the start of a string... slurp in the rest of the string and return it | def slurpstring(terminators,escapes=%w{ \\ $ ' " r n t s }+["\n"],ignore_invalid_escapes=false)
# we search for the next quote that isn't preceded by a
# backslash; the caret is there to match empty strings
last = @scanner.matched
str = @scanner.scan_until(/([^\\]|^|[^\\])([\\]{2})*[#{terminators}]/) || lex_error(positioned_message("Unclosed quote after #{format_quote(last)} followed by '#{followed_by}'"))
str.gsub!(/\\(.)/m) {
ch = $1
if escapes.include? ch
case ch
when 'r'; "\r"
when 'n'; "\n"
when 't'; "\t"
when 's'; " "
when "\n"; ''
else ch
end
else
Puppet.warning(positioned_message("Unrecognized escape sequence '\\#{ch}'")) unless ignore_invalid_escapes
"\\#{ch}"
end
}
[ str[0..-2],str[-1,1] ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_string; end",
"def read_string\n string = unpack_byteslice('Z*', @content.bytesize)\n @cursor += string.size + 1\n string\n end",
"def first(string)\n return string[0]\nend",
"def next\n ret = peek_next\n @str.slice! @last_re if ret.type != :eos\n\n ... | [
"0.6176881",
"0.6128913",
"0.60640377",
"0.6026781",
"0.5982277",
"0.59781826",
"0.59376895",
"0.5935463",
"0.5928668",
"0.589478",
"0.58827424",
"0.58492637",
"0.58472764",
"0.5839778",
"0.58222055",
"0.58030653",
"0.5792281",
"0.5787966",
"0.57857794",
"0.5779795",
"0.57774... | 0.0 | -1 |
Formats given message by appending file, line and position if available. | def positioned_message msg
result = [msg]
result << "in file #{file}" if file
result << "at line #{line}:#{pos}" if line
result.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_log_message file, lineno, line, parameters\n message = insert_parameters(line, parameters)\n return \"#{file[:file_name]}@#{lineno}: #{message}\"\nend",
"def make_message message\n prefix = \"#{@file_name}:\".dup\n\n tk = peek_tk\n prefix << \"#{tk[:line_no]}:#{tk[:char_no]}:\" if tk\n\n ... | [
"0.6325112",
"0.57906216",
"0.57024133",
"0.56086946",
"0.55307496",
"0.53906",
"0.52830887",
"0.5237303",
"0.5237303",
"0.5237303",
"0.52306247",
"0.5200783",
"0.5166942",
"0.51590085",
"0.5153617",
"0.51021403",
"0.508848",
"0.50732267",
"0.50667214",
"0.5057646",
"0.505147... | 0.61481863 | 1 |
Returns "" if at end of input, else the following 5 characters with \n \r \t escaped | def followed_by
return "<eof>" if @scanner.eos?
result = @scanner.rest[0,5] + "..."
result.gsub!("\t", '\t')
result.gsub!("\n", '\n')
result.gsub!("\r", '\r')
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalizeInput(s)\r\n if s == nil\r\n return \"\"\r\n else\r\n return s.gsub(/\\\\n/, \"\\n\")\r\n end\r\n end",
"def clean_input(text)\n text.gsub(/\\r/, '') rescue text\n end",
"def chomp(string)\n if string[-1] == \"\\n\"\n string[-1] = \"\"\n end\n return string\... | [
"0.59777504",
"0.5912957",
"0.5883413",
"0.5857106",
"0.5857106",
"0.58563113",
"0.58449715",
"0.5844214",
"0.5780054",
"0.5722688",
"0.5715861",
"0.56986547",
"0.56899863",
"0.56716335",
"0.56474435",
"0.56270957",
"0.5599359",
"0.557436",
"0.5526852",
"0.54410356",
"0.54378... | 0.5299482 | 42 |
just parse a string, not a whole file | def string=(string)
@scanner = StringScanner.new(string)
@locator = Locator.new(string, multibyte?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(str); end",
"def get_parse(s);end",
"def parse(text); end",
"def parse(str)\n read_items(tokenize(str))\n end",
"def parse(string, options = {}, &block)\n file = StringIO.new(string)\n _read file, options, &block\n end",
"def subparse( str )\n parse( str )\n end",
... | [
"0.8104021",
"0.752533",
"0.7259129",
"0.71722394",
"0.7151232",
"0.713021",
"0.6953557",
"0.69075686",
"0.6779146",
"0.675563",
"0.67448336",
"0.66370416",
"0.66321576",
"0.66321576",
"0.6573742",
"0.6554972",
"0.6554972",
"0.6554972",
"0.6554972",
"0.6505069",
"0.6505069",
... | 0.0 | -1 |
Returns the line number (starting from 1) for the current position in the scanned text (at the end of the last produced, but not necessarily consumed. | def line
return 1 unless lexing_context && locator
locator.line_for_offset(lexing_context[:end_offset])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_line_number\n # Not using string[@previous_pos..best_pos].count('\\n') because it is slower\n strscan = ::StringScanner.new(string)\n strscan.pos = @previous_pos\n old_pos = pos + 1\n @previous_line_number += 1 while strscan.skip_until(/\\n/) && strscan.pos <= old_pos... | [
"0.8203528",
"0.81517696",
"0.8078261",
"0.7939834",
"0.7843478",
"0.7717781",
"0.7700215",
"0.7615812",
"0.7554427",
"0.74743915",
"0.735489",
"0.7350172",
"0.7344981",
"0.7305915",
"0.720809",
"0.7163476",
"0.71075845",
"0.710176",
"0.70817566",
"0.7077125",
"0.70636266",
... | 0.76708955 | 7 |
Create a locator based on a content string, and a boolean indicating if ruby version support multibyte strings or not. | def initialize(string, multibyte)
@string = string
@multibyte = multibyte
compute_line_index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains(str)\r\n ContainsText.new(str)\r\n end",
"def string=(string)\n @scanner = StringScanner.new(string)\n @locator = Locator.new(string, multibyte?)\n end",
"def init_multibyte\n numver = RUBY_VERSION.split(\".\").collect {|s| s.to_i }\n return true if (numver[0] << 16 | numver[1... | [
"0.5540213",
"0.5494152",
"0.5236414",
"0.49922538",
"0.49922538",
"0.49574855",
"0.48208997",
"0.4784041",
"0.4784041",
"0.47807616",
"0.4776724",
"0.4771744",
"0.47249988",
"0.47247946",
"0.46709627",
"0.4656158",
"0.46241507",
"0.46165243",
"0.46054173",
"0.45940083",
"0.4... | 0.521534 | 3 |
Returns whether this a ruby version that supports multibyte strings or not | def multibyte?
@multibyte
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_multibyte\n numver = RUBY_VERSION.split(\".\").collect {|s| s.to_i }\n return true if (numver[0] << 16 | numver[1] << 8 | numver[2]) >= (1 << 16 | 9 << 8 | 3)\n false\n end",
"def is_multibyte(charset)\n charset == 0x31\n end",
"def ruby_m17n?\n return true if \"\".respond_to? :... | [
"0.7441177",
"0.7085027",
"0.7035886",
"0.69056624",
"0.681283",
"0.6787667",
"0.67764807",
"0.6705927",
"0.6631445",
"0.66089034",
"0.6608508",
"0.6392585",
"0.6302911",
"0.62906176",
"0.62824094",
"0.62824094",
"0.6041165",
"0.60100174",
"0.60079634",
"0.5996027",
"0.598322... | 0.82434446 | 0 |
Computes the start offset for each line. | def compute_line_index
scanner = StringScanner.new(@string)
result = [0] # first line starts at 0
while scanner.scan_until(/\n/)
result << scanner.pos
end
@line_index = result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lines_offset\n @starting_line - 1\n end",
"def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend",
"def each_line_with_offset\n return to_enum(:each_line_with_offset) unless block_given?\n\n offset = 0\n\n each_line do |line|\n yield line, offset\n offset = tell\n end\... | [
"0.79640824",
"0.7821471",
"0.70385724",
"0.6971291",
"0.68710536",
"0.6869533",
"0.6768879",
"0.67488086",
"0.6730402",
"0.66793084",
"0.66793084",
"0.65517306",
"0.6551379",
"0.652046",
"0.64716256",
"0.64448",
"0.64448",
"0.63392437",
"0.63392437",
"0.6336762",
"0.6336762"... | 0.61733234 | 26 |
Returns the line number (first line is 1) for the given offset | def line_for_offset(offset)
if line_nbr = line_index.index {|x| x > offset}
return line_nbr
end
# If not found it is after last
return line_index.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_for_offset(offset)\n @locator.line_for_offset(offset) + @leading_line_count\n end",
"def pos_on_line(offset)\n offset_on_line(offset) +1\n end",
"def pos_on_line(offset)\n offset_on_line(offset) +1\n end",
"def line_for_offset(offset)\n if @prev_offset == offset\n ... | [
"0.87250704",
"0.8619968",
"0.8619968",
"0.84161466",
"0.8403525",
"0.8132346",
"0.81258845",
"0.80890095",
"0.80588526",
"0.7950124",
"0.788008",
"0.7779174",
"0.7757431",
"0.7717758",
"0.76832455",
"0.7666131",
"0.75950503",
"0.75102305",
"0.7462738",
"0.7434836",
"0.738651... | 0.88626176 | 0 |
Returns the offset on line (first offset on a line is 0). | def offset_on_line(offset)
line_offset = line_index[line_for_offset(offset)-1]
if multibyte?
@string.byteslice(line_offset, offset-line_offset).length
else
offset - line_offset
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend",
"def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end",
"def line_offset(pos=pos)\n p = 0\n string.eac... | [
"0.83182013",
"0.81490743",
"0.8065296",
"0.79671144",
"0.79157156",
"0.7685793",
"0.7685793",
"0.76200676",
"0.74972904",
"0.7400435",
"0.7351982",
"0.7331497",
"0.7301205",
"0.7275301",
"0.7272048",
"0.72710425",
"0.72558475",
"0.7236635",
"0.72209555",
"0.7216413",
"0.7210... | 0.7261781 | 16 |
Returns the position on line (first position on a line is 1) | def pos_on_line(offset)
offset_on_line(offset) +1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end",
"def line_number(pos=pos())\n line_index(pos) + 1\n end",
"def line_number(pos=pos)\n line_index(pos) + 1\n end",
"def line_index(pos=pos())\n p = n = 0\n ... | [
"0.8150782",
"0.8144542",
"0.8144046",
"0.8066001",
"0.80050844",
"0.79975295",
"0.7866907",
"0.7832629",
"0.77999073",
"0.77836305",
"0.7690088",
"0.76855123",
"0.76503426",
"0.76503426",
"0.76503426",
"0.76413673",
"0.76374876",
"0.7551129",
"0.7545681",
"0.7531284",
"0.752... | 0.75326097 | 20 |
Returns the character offset for a given byte offset | def char_offset(byte_offset)
if multibyte?
@string.byteslice(0, byte_offset).length
else
byte_offset
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_offset(byte_offset)\n string.byteslice(0, byte_offset).length\n end",
"def char_offset(byte_offset)\n end",
"def char_offset(offset)\n effective_line = @locator.line_for_offset(offset)\n locator.char_offset(offset) + (effective_line * @leading_line_offset) + @leading_offset\n end... | [
"0.8801407",
"0.872878",
"0.78818357",
"0.77217644",
"0.73726964",
"0.7368709",
"0.7140324",
"0.70197535",
"0.6985971",
"0.69540256",
"0.6908945",
"0.6824348",
"0.6644967",
"0.6630207",
"0.66291195",
"0.6610807",
"0.6590889",
"0.6587622",
"0.6558443",
"0.6551033",
"0.6549941"... | 0.88935417 | 0 |
Returns the length measured in number of characters from the given start and end byte offseta | def char_length(offset, end_offset)
if multibyte?
@string.byteslice(offset, end_offset - offset).length
else
end_offset - offset
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def char_length(offset, end_offset)\n end",
"def char_length(offset, end_offset)\n string.byteslice(offset, end_offset - offset).length\n end",
"def char_length(offset, end_offset)\n raise \"Should not be called\"\n end",
"def char_length(offset, end_offset)\n effective_line = @locator.... | [
"0.85210264",
"0.83728707",
"0.79796195",
"0.79774165",
"0.71530443",
"0.69355303",
"0.69024414",
"0.6639218",
"0.65726554",
"0.64903563",
"0.64903563",
"0.6251936",
"0.6207447",
"0.61984646",
"0.6185773",
"0.6183793",
"0.6183793",
"0.6183793",
"0.6183793",
"0.60129935",
"0.5... | 0.795123 | 4 |
vv test text files for loading vv | def load_english_a
File.open("test/test_files/english_a.txt", "r").read
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_file\n assert_pattern_match [ \"/directory\", \"component.vwf\", nil, nil ], \"/directory/component.vwf/\"\n end",
"def load_test(tc)\n data = Hash.new\n File.open(tc, \"r\") do |infile|\n while (line = infile.gets)\n #test = /^.*\\/(.*\\.rb)/.match(tc)[1]\n ... | [
"0.6377764",
"0.61243576",
"0.5966196",
"0.589349",
"0.5864657",
"0.5863206",
"0.585949",
"0.58372384",
"0.5807989",
"0.58074725",
"0.57558095",
"0.57558095",
"0.574495",
"0.572627",
"0.57151824",
"0.5714111",
"0.5704153",
"0.5697015",
"0.5694747",
"0.56898683",
"0.56863856",... | 0.59070235 | 3 |
Display the result as a floating point (decimal) number to two decimal places (for example, 17.23) =begin doctest: calculate_age converts an age from seconds into years >> calculate_age(315360000) => 10 doctest: format_age displays age as a floating point number >> format_age(10) => 10.00 =end | def calculate_age( age )
age = age/60/60/24/365
#format_age( age )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_age(num)\n return (num / 60 / 60 / 24 / 365.25).round()\nend",
"def format_balance\n format(\"%.2f\", balance.to_f)\n end",
"def number_with_precision\n\t\t\"%.2f\" % number\n\tend",
"def ageCalculator(age)\n age = age.to_i\n puts \"Your age in 10 years\"\n puts \"#{age + 10}\"\n put... | [
"0.66137207",
"0.65809983",
"0.65681094",
"0.6535336",
"0.64479893",
"0.64404684",
"0.6424021",
"0.6371828",
"0.6357857",
"0.6354521",
"0.63211083",
"0.6230109",
"0.62047315",
"0.6186564",
"0.6176963",
"0.61679757",
"0.61623067",
"0.612729",
"0.61189383",
"0.60915536",
"0.609... | 0.72431946 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def employer_params
params.require(:employer).permit(:name, :location, :city, :contact_point)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
Uses the buy method to find what index number needs to be removed so that you do not sell before you buy. | def selling_array(stonks)
index_to_remove = stonks.find_index(buy(stonks))
return index_to_remove + 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stock(ticker, number_of_shares)\n @stocks.each do |item|\n if item.ticker == ticker\n item.shares -= number_of_shares\n end\n end\n end",
"def single_sell_in_day_remover(item)\r\n item.sell_in -= 1\r\n end",
"def purchase\n \t@stock -= 1\n end",
"def removeShelf(index... | [
"0.65881187",
"0.6474389",
"0.6419027",
"0.63498473",
"0.6326811",
"0.62346584",
"0.6183282",
"0.6183282",
"0.6138554",
"0.6135981",
"0.6128264",
"0.6112484",
"0.6099646",
"0.6096267",
"0.6083681",
"0.6024815",
"0.59987104",
"0.59807765",
"0.5958098",
"0.59514534",
"0.5924126... | 0.76555413 | 0 |
reverses the initial array of stocks and then slices off all the stocks before and including the buy variable(I know I can probably do this without the reverse but my brain tried this first). you then find the biggest stock left and return it. | def sell(stonks)
reversed = stonks.reverse
stocks_you_can_sell = stonks.slice(selling_array(stonks),100)
biggest = stocks_you_can_sell.max
sell_day = stocks_you_can_sell.find {|stock| stock <= biggest}
return sell_day
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_picker(stock_array)\n buy_sell_output = []\n real_output = []\n largest_difference = 0\n \n for i in 0...stock_array.length() \n for j in 0...stock_array.length()\n if j > i and stock_array[j] - stock_array[i] > largest_difference\n largest_difference = stock_... | [
"0.7316463",
"0.71369934",
"0.71050143",
"0.70406646",
"0.70335674",
"0.6885281",
"0.6754171",
"0.6743664",
"0.67429775",
"0.6730248",
"0.67223406",
"0.67187077",
"0.66781616",
"0.66434616",
"0.6640035",
"0.6633278",
"0.6606161",
"0.65817827",
"0.65583134",
"0.6544509",
"0.65... | 0.7223032 | 1 |
takes the selling price and subtracts it from the buying price to get profit. Creates a statement with when to buy/sell and a statement telling you your profit. | def final_choice (stonks)
profit = sell(stonks) - buy(stonks)
earnings_statement = "Congratulations, you made #{profit} dollars!"
final_array = ["Buy at this price:",buy(stonks),"Sell at this price:",sell(stonks)]
return final_array, earnings_statement
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profit\n \tself.bid - self.payout\n end",
"def profit\n (self.price - self.product.cost) * self.quantity\n end",
"def profit_statement(drink, profit)\r\n # Only thing of interest here is using the %.2f % profit method (is this a method? A reassignment?) to force two decimal places as this is a... | [
"0.7306166",
"0.70697653",
"0.7033874",
"0.6985192",
"0.68237936",
"0.68237936",
"0.67705065",
"0.6741352",
"0.6655424",
"0.66192406",
"0.6609433",
"0.6604633",
"0.65943974",
"0.6574221",
"0.6564993",
"0.6512685",
"0.6493633",
"0.64706665",
"0.6451675",
"0.64364463",
"0.63967... | 0.65165323 | 15 |
action create DELETE /admin/blog | def destroy
if 0 == Blog.count
flash[:notice] = I18n.t('admin.blog.failure.blog_does_not_exist', :action => t('admin.blog.delete.action'))
else
flash[:alert] = I18n.t('admin.blog.delete.success')
@blog.destroy
end # if
redirect_to admin_blog_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @blog.destroy\n respond_to do |format|\n format.html { redirect_to admin_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @blog.destroy\n flash[:success] = t('blog.post_supprimer')\n redirect_to blogs_url\n end",
"def destroy\n @blog.destroy\n... | [
"0.77188295",
"0.76531",
"0.7627966",
"0.75379664",
"0.75112534",
"0.74729806",
"0.7470636",
"0.74382466",
"0.74140024",
"0.7393942",
"0.7392632",
"0.7391348",
"0.73806727",
"0.73666936",
"0.73335713",
"0.7328543",
"0.7313199",
"0.7279826",
"0.7279826",
"0.72698957",
"0.72293... | 0.7611767 | 3 |
action destroy GET /admin/blog/edit | def edit
if 0 == Blog.count
flash[:notice] = I18n.t('admin.blog.failure.blog_does_not_exist', :action => t('admin.blog.edit.action'))
redirect_to admin_blog_path
else
breadcrumbs_for :edit
render :edit
end # if-else
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @post = Post.find(params[:id], :include => :blog)\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_blog_posts_url(@post.blog)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @admin_blog = Admin::Blog.find(params[:id])\n\n respond_t... | [
"0.77764964",
"0.7608572",
"0.7597182",
"0.75306356",
"0.75023943",
"0.7458738",
"0.7421284",
"0.7414327",
"0.7382238",
"0.73004645",
"0.73004645",
"0.7288826",
"0.7272133",
"0.7271481",
"0.72330946",
"0.72252125",
"0.72073895",
"0.72038823",
"0.71955436",
"0.7172826",
"0.712... | 0.0 | -1 |
action edit GET /admin/blog/new | def new
if 0 < Blog.count
flash[:notice] = I18n.t('admin.blog.failure.blog_already_exists', :action => t('admin.blog.new.action'))
redirect_to admin_blog_path and return
end # if
breadcrumbs_for :new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\r\n @blog_post = BlogPost.find(params[:id])\r\n end",
"def edit\n\t\t\tauthorize! :manage, Blog\n\n\t\t\t@blog = Blog.find params[:id]\n\n\t\t\tif request.post?\n\t\t\t\tif @blog.save_with_params params[:blog]\n\t\t\t\t\trender json: { status: 0, result: { redirect: _route_helpers.blogs_path } }\n\t... | [
"0.7491793",
"0.7413666",
"0.7403861",
"0.7403861",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.72724164",
"0.7242632",
"0.72130656",
"... | 0.65794253 | 36 |
action new GET /admin/blog | def show
breadcrumbs_for :show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n if 0 < Blog.count\n flash[:notice] = I18n.t('admin.blog.failure.blog_already_exists', :action => t('admin.blog.new.action'))\n redirect_to admin_blog_path and return\n end # if\n\n breadcrumbs_for :new \n end",
"def new\n\t\t@blog = Blog.new\n\tend",
"def new\n @blog = Admin... | [
"0.76742625",
"0.76605403",
"0.7521036",
"0.7478313",
"0.7478313",
"0.7433433",
"0.7365707",
"0.7355463",
"0.7323803",
"0.7316507",
"0.72585833",
"0.72585833",
"0.7101684",
"0.7004261",
"0.6956471",
"0.6862607",
"0.6862378",
"0.6852846",
"0.68093294",
"0.68010455",
"0.6773577... | 0.0 | -1 |
action show PATCH /admin/blog | def update
if 0 == Blog.count
flash[:notice] = I18n.t('admin.blog.failure.blog_does_not_exist', :action => t('admin.blog.edit.title').downcase)
redirect_to admin_blog_path
elsif @blog.update_attributes blog_params
flash[:notice] = I18n.t('admin.blog.edit.success')
redirect_to admin_blog_path
else
breadcrumbs_for :edit
render :edit
end # if-elsif-else
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @admin_blog = Admin::Blog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_blog }\n end\n end",
"def edit\n @blog = Blog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n end\n e... | [
"0.77078134",
"0.7389392",
"0.738353",
"0.7358751",
"0.72599065",
"0.72599065",
"0.7209983",
"0.7152205",
"0.7152205",
"0.7130827",
"0.7120095",
"0.7113677",
"0.71050775",
"0.70810467",
"0.70810467",
"0.70810467",
"0.70810467",
"0.70810467",
"0.70810467",
"0.70810467",
"0.708... | 0.0 | -1 |
scan nodes by dfs; shallower to deeper; O(nodes) | def dfs_tree_preorder(start, edges)
require 'set'
queue = [[start,nil]]
visited = Set[start]
while queue.size > 0
f,ff = *(queue.pop)
ts = edges[f].keys.reject{ |t| visited.member?(t) }
yield(f, ff)
ts.each{ |t| visited << t; queue << [t,f] }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dfs(start_node)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n... | [
"0.68521607",
"0.68476075",
"0.6827877",
"0.67946625",
"0.6767304",
"0.6749029",
"0.6657059",
"0.65363556",
"0.6492219",
"0.64699835",
"0.6430719",
"0.64167",
"0.64145714",
"0.64106095",
"0.6359685",
"0.63483435",
"0.6323377",
"0.63126373",
"0.6306834",
"0.62695426",
"0.62657... | 0.55062044 | 99 |
scan nodes by dfs; deeper to shallower; O(nodes) | def dfs_tree_postorder(start, edges)
require 'set'
queue = [[start,nil]]
visited = Set[start]
bq = []
while queue.size > 0
f = queue.pop
bq << f
ts = edges[f[0]].keys.reject{ |t| visited.member?(t) }
ts.each{ |t| visited << t; queue << [t,f[0]] }
end
bq.reverse_each{ |f| yield(*f) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n prefer... | [
"0.68317086",
"0.6824252",
"0.6811683",
"0.672235",
"0.66894144",
"0.6686052",
"0.66003716",
"0.64707446",
"0.6410268",
"0.64076275",
"0.640533",
"0.639591",
"0.6369034",
"0.63461167",
"0.6322226",
"0.6307453",
"0.62810516",
"0.6275009",
"0.6247051",
"0.623363",
"0.61983454",... | 0.0 | -1 |
Gets various options for Haml. See README for details. | def options
@@options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html_options\n @options\n end",
"def options() end",
"def get_options; end",
"def html_options; @html_opts end",
"def view_language\n options[:haml] ? 'haml' : 'erb'\n end",
"def options; @opts end",
"def options\n @options\n end",
"def options\n @options\n end",
"def pa... | [
"0.6432099",
"0.62973994",
"0.6212406",
"0.6200326",
"0.61081797",
"0.6087107",
"0.60832924",
"0.60832924",
"0.6083143",
"0.60586035",
"0.6057801",
"0.603176",
"0.5989146",
"0.5955021",
"0.59323716",
"0.59323716",
"0.5913807",
"0.5913621",
"0.5910032",
"0.58743984",
"0.587147... | 0.5788454 | 86 |
Sets various options for Haml. See README for details. | def options=(value)
@@options = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))\n if File.file?(config_path)\n ... | [
"0.58618706",
"0.584582",
"0.5833211",
"0.57775587",
"0.5763215",
"0.5761587",
"0.57536966",
"0.57401097",
"0.5730917",
"0.57194227",
"0.57175314",
"0.5650286",
"0.5533821",
"0.55186784",
"0.5507866",
"0.54747224",
"0.54729927",
"0.5467407",
"0.5440525",
"0.54282826",
"0.5422... | 0.0 | -1 |
Creates a new Haml::Template object that uses view to render its templates. | def initialize(view)
@view = view
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def view\n return @view unless @view.nil?\n file = File.join VIEWS, self.template\n @view = Haml::Engine.new File.read(file), HAML_CONFIG\n end",
"def render(template)\n template = File.read(\"./views/#{template}\")\n engine = Haml::Engine.new(template)\n @response = engine.render\ne... | [
"0.77719593",
"0.718972",
"0.7086994",
"0.6821626",
"0.6821626",
"0.655148",
"0.6546762",
"0.65188533",
"0.6348487",
"0.6313155",
"0.63104403",
"0.63048977",
"0.6274309",
"0.61900914",
"0.6166262",
"0.61083335",
"0.61048305",
"0.6066804",
"0.60581696",
"0.60403967",
"0.603004... | 0.0 | -1 |
Renders the file at the location template, with local_assigns available as local variables within the template. Returns the result as a string. | def render(template, local_assigns={})
@view.instance_eval do
evaluate_assigns
end
options = @@options.dup
locals = options[:locals] || {}
locals.merge! local_assigns
options[:locals] = locals
if @view.haml_inline
engine = Haml::Engine.new(template, options)
else
options[:filename] ||= template
engine = Haml::Engine.new(File.read(template), options)
end
yield_proc = @view.instance_eval do
proc { |*name| instance_variable_get("@content_for_#{name.first || 'layout'}") }
end
engine.to_html(@view) { |*args| yield_proc.call(*args) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(file_path, local_variables = {})\n absolute_path = File.expand_path file_path, base_path\n absolute_path += FILE_EXTENSION unless absolute_path.end_with?(FILE_EXTENSION)\n file_content = File.read absolute_path\n erb = ERB.new file_content\n erb.result create_binding(base_path, local_vari... | [
"0.7340644",
"0.7107698",
"0.6991029",
"0.68809855",
"0.68085635",
"0.6748164",
"0.6691094",
"0.6604724",
"0.6563183",
"0.65574867",
"0.6507146",
"0.65011615",
"0.6475485",
"0.64268434",
"0.6418069",
"0.64096904",
"0.63983715",
"0.62962705",
"0.6267613",
"0.6248985",
"0.62170... | 0.6382596 | 17 |
your code goes here | def begins_with_r(collection)
collection.each do |names|
if names.start_with?("r") == false
return false
end
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply\n\t\t\t\t\n\t\t\tend",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run\n end",
"def run\n \n end",
"def run\n \n end",
"def run\n end",
"def custom; end"... | [
"0.6193367",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.61824477",
"0.6169166",
"0.6124124",
"0.6124124",
"0.6094903",
"0.60627353",
"0.60627353",
"0.5983734",
"0.5979919",
"0.5979919",
"0.5897549",
"0.58... | 0.0 | -1 |
Pila de tablas. Manejo de la estructura general del programa Manejador del programa principal. | def program_Handler(ast, printSymbolTable)
return scope_Handler(ast.scope, printSymbolTable)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tabla\n @nombre_tabla\n end",
"def getTable\r\n return @pila_t.last #puedes hacer getTable sucesivos sin modificar nada en lo absoluto.\r\n end",
"def tabla_pasos(contador,array_anterior)\n aux=0\n tabla = Terminal::Table.new do |a|\n a.title= \"ELEMENTOS A ORDENAR: #{array_anterior... | [
"0.6991516",
"0.68199944",
"0.67875695",
"0.6693382",
"0.6660544",
"0.6660544",
"0.6660544",
"0.6660544",
"0.6552947",
"0.6493791",
"0.6467145",
"0.6436237",
"0.6422821",
"0.63467824",
"0.6321304",
"0.63093454",
"0.62579703",
"0.6254343",
"0.6214203",
"0.62125015",
"0.6194379... | 0.0 | -1 |
Manejador de lista de identificadores | def listI_Handler(type, listI)
if !($symTable.contains(listI.id.term))
$symTable.insert(listI.id.term, [type, nil])
if (listI.listI != nil)
return listI_Handler(type, listI.listI)
end
return 0
else
puts "ERROR: variable '#{listI.id.term}' was declared before" \
" at the same scope."
if (listI.listI != nil)
return listI_Handler(type, listI.listI) + 1
end
return 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n whe... | [
"0.71384054",
"0.68553966",
"0.6706147",
"0.66565055",
"0.6627752",
"0.6603254",
"0.6592369",
"0.6533876",
"0.65081877",
"0.64918125",
"0.647743",
"0.64288306",
"0.64259285",
"0.6387752",
"0.63680035",
"0.63546544",
"0.63445646",
"0.632627",
"0.628526",
"0.6270883",
"0.626100... | 0.0 | -1 |
Manejo de las instrucciones del programa Manejador de la instruccion ASSIGN. | def assign_Handler(assign, iterVar=nil)
idVar = assign.branches[0].term
if (idVar == iterVar)
puts "ASSIGN ERROR: iterator '#{idVar}' cannot be modified."
return 1
end
if ($symTable.lookup(idVar) == nil)
puts "ASSIGN ERROR: variable '#{idVar}' has not been declared."
return 1
end
typeVar = $symTable.lookup(idVar)[0]
typeExpr = expression_Handler(assign.branches[1])
if (typeVar != typeExpr)
puts "ASSIGN ERROR: #{typeExpr} expression assigned to #{typeVar} "\
"variable '#{idVar}'."
return 1
end
return 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activation_instructions\n end",
"def asignacion!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 14 )\n\n\n\n type = ASIGNACION\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - ... | [
"0.55986637",
"0.5427459",
"0.5290781",
"0.5264261",
"0.52573866",
"0.5241061",
"0.52232945",
"0.51919717",
"0.5091107",
"0.50503916",
"0.4991324",
"0.4923115",
"0.48957592",
"0.4876856",
"0.485368",
"0.48401937",
"0.48314705",
"0.4824454",
"0.482401",
"0.47705486",
"0.475960... | 0.0 | -1 |
Manejador de la instruccion READ. | def read_Handler(read)
idVar = read.branches[0].term
if ($symTable.lookup(idVar) == nil)
puts "READ ERROR: variable '#{idVar}' has not been declared."
return 1
end
typeVar = $symTable.lookup(idVar)[0]
if (typeVar != :NUMBER) and (typeVar != :BOOLEAN)
puts "READ ERROR: variable '#{idVar}' must be an int or a boolean."
return 1
end
return 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read() end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read; end",
"def read\n end",
"def read\n end",
"def read\n end",
"def read\n end",
"def read\n end",
"def read\nend",
"def read\n \n end",
"def rea... | [
"0.7693163",
"0.75159746",
"0.75159746",
"0.75159746",
"0.75159746",
"0.75159746",
"0.75159746",
"0.75159746",
"0.7450575",
"0.7376642",
"0.7376642",
"0.7376642",
"0.7376642",
"0.73650736",
"0.7092368",
"0.704689",
"0.6963158",
"0.69459665",
"0.6936747",
"0.684094",
"0.679193... | 0.0 | -1 |
Manejador de la instruccion WRITE. | def write_Handler(write)
expr = write.branches[0]
typeExpr = expression_Handler(expr)
if (typeExpr != :CANVAS)
puts "WRITE ERROR: the expression given must be a canvas."
return 1
end
return 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write; end",
"def write; end",
"def write\n end",
"def write\n command :write\n self\n end",
"def write(p0) end",
"def write(p0) end",
"def write(p0) end",
"def syswrite(p0) end",
"def syswrite(p0) end",
"def syswrite(p0) end",
"def write(data); end",
"def write(data); end... | [
"0.7816408",
"0.7816408",
"0.76631165",
"0.7210597",
"0.7177618",
"0.7177618",
"0.7176767",
"0.71299714",
"0.7129066",
"0.7129066",
"0.7046499",
"0.7046499",
"0.7046499",
"0.7046499",
"0.7000703",
"0.6999579",
"0.69573146",
"0.69038165",
"0.68366194",
"0.68366194",
"0.6836619... | 0.0 | -1 |
Manejador de la instruccion CONDITIONAL STATEMENT. | def conditional_statement_Handler(cs)
expr = cs.elems[0]
instr1 = cs.elems[1]
result = instr_Handler(instr1)
if (cs.elems[2] != nil)
instr2 = cs.elems[2]
result += instr_Handler(instr2)
end
if (expression_Handler(expr) != :BOOLEAN)
puts "CONDITIONAL STATEMENT ERROR: expression must be boolean."
result += 1
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cond; end",
"def cond; end",
"def cond; end",
"def complex_condition?(condition); end",
"def condition; end",
"def conditionally(*) end",
"def conditionally(*) end",
"def non_complex_expression?(condition); end",
"def parse_condition; end",
"def parse_condition; end",
"def parse_condition(e... | [
"0.7240936",
"0.7240936",
"0.7240936",
"0.71459717",
"0.71164876",
"0.7107119",
"0.7107119",
"0.70525056",
"0.6785731",
"0.6785731",
"0.66943944",
"0.6685927",
"0.66114837",
"0.65002155",
"0.65002155",
"0.65002155",
"0.64488006",
"0.64488006",
"0.6435098",
"0.64197236",
"0.62... | 0.6134134 | 23 |
Manejador de la instruccion IND LOOP. | def iLoop_Handler(iLoop)
result = 0
expr = iLoop.elems[0]
if (expression_Handler(expr) != :BOOLEAN)
puts "IND LOOP ERROR: expression must be boolean."
result += 1
end
instr = iLoop.elems[1]
result += instr_Handler(instr)
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_loop; end",
"def loop; end",
"def looper \r\n for i in 1..10\r\n puts i\r\n end\r\nend",
"def looper(stop_point)\n numbers = []\n # i = 0\n (0 ... stop_point).each do |i|\n puts \"at the top of i is #{i}\"\n numbers << i\n\n # i+= incrementer\n\n puts \"numbers is now: \", numbers\n... | [
"0.59637314",
"0.5837868",
"0.5750518",
"0.5660681",
"0.5657127",
"0.56270397",
"0.56270397",
"0.55978066",
"0.5588867",
"0.5582357",
"0.5546302",
"0.5545444",
"0.5524933",
"0.5509653",
"0.5435013",
"0.5433649",
"0.54239035",
"0.5420469",
"0.5417283",
"0.53871",
"0.53651106",... | 0.51023877 | 50 |
Manejador de la instruccion DET LOOP. | def dLoop_Handler(dLoop)
result = 0
if (dLoop.types[0] == :VARIABLE)
iterVar = dLoop.elems[0].term
# Busca la variable, si la encuentra, la actualiza, si no, la inserta.
if ($symTable.lookup(iterVar) == nil)
$symTable.insert(iterVar, [:NUMBER, nil])
else
$symTable.update(iterVar, [:NUMBER, nil])
end
expr1 = dLoop.elems[1]
typeExpr1 = expression_Handler(expr1)
expr2 = dLoop.elems[2]
typeExpr2 = expression_Handler(expr2)
if (typeExpr1 != :NUMBER) or (typeExpr2 != :NUMBER)
puts "DET LOOP ERROR: expressions must be arithmetic."
result += 1
end
instr = dLoop.elems[3]
result += instr_Handler(instr, iterVar)
return result
else
expr1 = dLoop.elems[0]
typeExpr1 = expression_Handler(expr1)
expr2 = dLoop.elems[1]
typeExpr2 = expression_Handler(expr2)
if (typeExpr1 != :NUMBER) or (typeExpr2 != :NUMBER)
puts "DET LOOP ERROR: expressions must be arithmetic."
result += 1
end
instr = dLoop.elems[2]
result += instr_Handler(instr)
return result
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processa_de\n puts(format(\"%<n>4i TRADES\\tBITCOINDE\\tINSERIDAS det\", n: apide.trades.empty? ? 0 : dml(det_ins)))\n puts(format(\"%<n>4i LEDGER\\tBITCOINDE\\tINSERIDAS del\", n: apide.ledger.empty? ? 0 : dml(del_ins)))\n end",
"def run\n sleep INTERVAL\n loop do\n start = Tim... | [
"0.53038603",
"0.5189994",
"0.51566046",
"0.51399547",
"0.5136086",
"0.5071034",
"0.49988896",
"0.49910718",
"0.4981069",
"0.49723718",
"0.49610803",
"0.49443093",
"0.48349676",
"0.48240927",
"0.47922722",
"0.47734648",
"0.47680405",
"0.47295243",
"0.47235462",
"0.46712807",
... | 0.4849949 | 13 |
Manejador de expresiones binarias: Devuelve el tipo de las expresiones binarias => si hay un error de tipo, devuelve nil. | def binExp_Handler(expr)
typeExpr1 = expression_Handler(expr.elems[0])
typeExpr2 = expression_Handler(expr.elems[1])
if (typeExpr1 != typeExpr2)
return nil
end
case expr.op
when /^\/\\/
if typeExpr1 == :BOOLEAN
return :BOOLEAN
else
return nil
end
when /^\\\//
if typeExpr1 == :BOOLEAN
return :BOOLEAN
else
return nil
end
when /^(=|\/=)/
return :BOOLEAN
when /^[\+\-\*\/%]/
if typeExpr1 == :NUMBER
return :NUMBER
else
return nil
end
when /^[~&]/
if typeExpr1 == :CANVAS
return :CANVAS
else
return nil
end
when /^(<|>|<=|>=)/
if (typeExpr1 == :NUMBER) and (typeExpr2 == :NUMBER)
return :BOOLEAN
else
return nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evalExpression(expr)\n\texprs = expr.get_expr\n\tif expr.class == EXPR_VALUE\n\t\tsymbol = exprs.get_symbol\n\t\tidentif = exprs.get_value\n\t\tif symbol == :IDENTIFIER\n\t\t\tsymbol = $tables.lookup(identif)\n\t\t\tif symbol[1] != nil\n\t\t\t\treturn symbol\n\t\t\telse\n\t\t\t\tputs \"ERROR: variable `#{ident... | [
"0.4974279",
"0.48580658",
"0.4834702",
"0.47746885",
"0.47701406",
"0.47009465",
"0.46919444",
"0.46607322",
"0.45943224",
"0.4585477",
"0.45459998",
"0.45431176",
"0.45197222",
"0.45124716",
"0.45035613",
"0.44943735",
"0.44899225",
"0.44756415",
"0.44441873",
"0.44126937",
... | 0.511311 | 1 |
Manejador de expresiones parentizadas. | def parExp_Handler(expr)
return expression_Handler(expr.expr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def parent; end",
"def semplice\r\n puts \"senza parentesi\... | [
"0.6917464",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.6667378",
"0.65657705",
"0.64119434",
"0.63710964",
"0.63710964",
"0.63710964",
"0.63710964",
"0.6362404",
"0.6242371... | 0.0 | -1 |
Manejador de expresiones unarias. Devuelve el tipo de las expresiones unarias => si hay un error de tipo, devuelve nil. | def unaExp_Handler(expr)
typeExpr = expression_Handler(expr.elem)
case expr.op
when /^[$']/
if typeExpr == :CANVAS
return :CANVAS
else
return nil
end
when /\^/
if typeExpr == :BOOLEAN
return :BOOLEAN
else
return nil
end
when /-/
if typeExpr == :NUMBER
return :NUMBER
else
return nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def empieza_evaluacion\r\n begin\r\n alumnos1 = administrador.empezar_evaluaciones\r\n rescue RuntimeError => e\r\n error_handler(e)\r\n end\r\n menu_principal\r\n end",
"def exp_type\n return data.exp_type\n end",
"def acciones\n # -> uncomment the next line to manually enabl... | [
"0.56537473",
"0.5388245",
"0.5318948",
"0.51339185",
"0.5082011",
"0.49253663",
"0.49248526",
"0.492373",
"0.49035835",
"0.4875143",
"0.4862434",
"0.4840597",
"0.48384959",
"0.4730276",
"0.4730276",
"0.46895784",
"0.46834165",
"0.46706024",
"0.46696827",
"0.4658853",
"0.4657... | 0.0 | -1 |
GET /visitas GET /visitas.xml | def index
@paciente = Paciente.find(params[:paciente_id])
@visitas = @paciente.visitas
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @visitas }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @visit_stats = VisitStat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @visit_stats }\n end\n end",
"def show\n @visit_stat = VisitStat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n forma... | [
"0.6470733",
"0.6285716",
"0.628488",
"0.6173321",
"0.6141649",
"0.61204946",
"0.6058852",
"0.60119545",
"0.5979308",
"0.5979308",
"0.5979308",
"0.594474",
"0.5935703",
"0.5857834",
"0.5834348",
"0.58237976",
"0.58206743",
"0.58202493",
"0.58009976",
"0.5795578",
"0.5779536",... | 0.70957536 | 0 |
GET /visitas/new GET /visitas/new.xml | def new
@paciente = Paciente.find(params[:paciente_id])
@visita = Visita.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @visita }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @visit_stat = VisitStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @visit_stat }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"d... | [
"0.71203405",
"0.7033105",
"0.7003776",
"0.69301426",
"0.688343",
"0.68470883",
"0.682249",
"0.67607236",
"0.6700201",
"0.66869193",
"0.66736907",
"0.6659861",
"0.6659861",
"0.6659861",
"0.6659861",
"0.6659861",
"0.6659861",
"0.6659861",
"0.6659861",
"0.661827",
"0.65938216",... | 0.7053187 | 1 |
POST /visitas POST /visitas.xml | def create
@paciente = Paciente.find(params[:paciente_id])
@visita = Visita.new(params[:visita])
@visita.paciente = @paciente
respond_to do |format|
if @visita.save
format.html { redirect_to(paciente_visitas_url, :notice => 'La Visita se creo exitosamente.') }
format.xml { render :xml => @visita, :status => :created, :location => @visita }
else
format.html { render :action => "new" }
format.xml { render :xml => @visita.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @visit = Visit.new(params[:visit])\n\n respond_to do |format|\n if @visit.save\n flash[:notice] = 'visit was successfully created.'\n format.html { redirect_to(@visit) }\n format.xml { render :xml => @visit, :status => :created, :location => @visit }\n else\n ... | [
"0.6055787",
"0.5897053",
"0.5853344",
"0.58181536",
"0.57236993",
"0.56594145",
"0.5611767",
"0.5584431",
"0.5568132",
"0.5563245",
"0.5563245",
"0.55627036",
"0.55316854",
"0.54914224",
"0.54465455",
"0.54092723",
"0.53391033",
"0.5304929",
"0.5291616",
"0.52794164",
"0.527... | 0.6367066 | 0 |
PUT /visitas/1 PUT /visitas/1.xml | def update
@paciente = Paciente.find(params[:paciente_id])
@visita = Visita.find(params[:id])
respond_to do |format|
if @visita.update_attributes(params[:visita])
format.html { redirect_to(paciente_visitas_url, :notice => 'La Visita se modifico exitosamente.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @visita.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def upd... | [
"0.5910079",
"0.58351886",
"0.5716238",
"0.5641251",
"0.5617313",
"0.55971235",
"0.5565322",
"0.55049795",
"0.54812926",
"0.5389472",
"0.5389472",
"0.5367714",
"0.5367714",
"0.5338952",
"0.53336865",
"0.5333045",
"0.5332819",
"0.53323746",
"0.53214455",
"0.5301496",
"0.529675... | 0.57602763 | 2 |
DELETE /visitas/1 DELETE /visitas/1.xml | def destroy
@visita = Visita.find(params[:id])
@visita.destroy
respond_to do |format|
format.html { redirect_to(paciente_visitas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @visit = Visit.find(params[:id])\n @visit.destroy\n\n respond_to do |format|\n format.html { redirect_to(visits_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @visit.destroy\n\n head :no_content\n end",
"def destroy\n @visit_stat = VisitStat.find(p... | [
"0.71239424",
"0.70111334",
"0.67547613",
"0.6717794",
"0.6703657",
"0.66631025",
"0.6625145",
"0.6609466",
"0.6586951",
"0.6571506",
"0.6502698",
"0.64755756",
"0.6451933",
"0.6441314",
"0.6439824",
"0.6416585",
"0.6391441",
"0.63731956",
"0.63578343",
"0.63414866",
"0.63403... | 0.7217611 | 0 |
removes unnecessary field options | def sanitize_field_options(options={})
options.stringify_keys.reject {|k, v| %w(vertical_align label edit req lock auto popup url position help).include?(k)}.symbolize_keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_form_field_options(options={})\n options.symbolize_keys.reject {|k,v| [:disabled, :object, :help, :edit, :label, :req, :lock].include?(k)} \n end",
"def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end",
... | [
"0.7152702",
"0.70674604",
"0.70674604",
"0.706571",
"0.7012314",
"0.6703961",
"0.6507369",
"0.6450818",
"0.64127314",
"0.63915575",
"0.63469243",
"0.63464206",
"0.6326708",
"0.6257015",
"0.6245541",
"0.62359387",
"0.62082714",
"0.61662227",
"0.61516786",
"0.6151402",
"0.6149... | 0.71283245 | 1 |
form element form_element wraps a label and input tag with ... | def form_element(*args, &block)
content, options = filter_tag_args(*args)
options[:class] = if dom_class = options.delete(:class)
"fieldRow #{dom_class}"
else
"fieldRow"
end
if block_given? && !content
concat content_tag(:dl, capture(&block), options)
else
content_tag(:dl, content, options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_field_wrapper(attr, options = {}, html_options = nil, &block)\n label_text = options.delete :label\n @label_html = label_html_for attr, label_text, class: 'text-right middle'\n @input_html = input_html_for attr, options, html_options, &block\n @help_html = help_html_for attr, options\n @er... | [
"0.7005657",
"0.6958107",
"0.6735915",
"0.6708983",
"0.67078245",
"0.654526",
"0.6472453",
"0.64456165",
"0.6442146",
"0.64310604",
"0.6409941",
"0.6387987",
"0.6377107",
"0.63454914",
"0.63425386",
"0.63231695",
"0.6320345",
"0.62934023",
"0.62907827",
"0.6283335",
"0.628267... | 0.6224218 | 25 |
form element with condition | def form_element_if(condition, *args, &block)
form_element(*args, &block) if condition
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_field_tag_if(condition, name, options={}, &block)\n form_field_tag(name, options, &block) if condition\n end",
"def element_form(context={}, aspect_model)\n \n app = context[:app]\n\n if resource.can_write?(app.user) and (not app.user.belongs_to?(Users::Group.get('anonymous')))\n ... | [
"0.68513155",
"0.62790114",
"0.6228893",
"0.6220391",
"0.6032024",
"0.5905588",
"0.58428806",
"0.5841703",
"0.5799177",
"0.56713086",
"0.56109655",
"0.5609957",
"0.5602968",
"0.5602968",
"0.5602189",
"0.560009",
"0.55874723",
"0.558183",
"0.5527897",
"0.5518164",
"0.5470504",... | 0.7325086 | 0 |
form element with unless condition | def form_element_unless(condition, *args, &block)
form_element(*args, &block) unless condition
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_element_if(condition, *args, &block)\n form_element(*args, &block) if condition\n end",
"def unless_condition; end",
"def form_field_tag_if(condition, name, options={}, &block)\n form_field_tag(name, options, &block) if condition\n end",
"def hide_unless(condition)\n hide(:unless => condi... | [
"0.67857665",
"0.66668105",
"0.6372581",
"0.6244477",
"0.6146979",
"0.61204994",
"0.5902677",
"0.5894449",
"0.5860579",
"0.5829911",
"0.5811225",
"0.57508785",
"0.57419",
"0.564376",
"0.56341755",
"0.5570474",
"0.5565243",
"0.55609125",
"0.55511147",
"0.5541836",
"0.55315936"... | 0.8435725 | 0 |
wraps fields in a before wrapping in tags | def form_table_element(*args, &block)
content, options = filter_tag_args(*args)
options[:class] = (dom_class = options.delete(:class) ? "fieldRow #{dom_class}" : 'fieldRow')
if block_given? && !content
concat tag("td",
{:class => cycle('formBoxTwoColumnsLeftColumn', 'formBoxTwoColumnsRightColumn', :name => 'form_box_two_columns'),
:style => "vertical-align:top;"}, true)
concat content_tag("dl", capture(&block), options)
concat "</td>"
else
content_tag("td", content_tag("dl", content, options),
{:class => cycle('formBoxTwoColumnsLeftColumn', 'formBoxTwoColumnsRightColumn', :name => 'form_box_two_columns')})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_field(field, options = {})\n required_flag = options.delete(:required) ? true : false\n text = \"\"\n\n field_text = content_tag(\"span\", field,{:class => \"form-field\"}, false)\n\n required_text = content_tag(\"span\",\"\",{:class => \"form-field-required-flag\"}, false)\n\n info_imag... | [
"0.65692616",
"0.60607636",
"0.5959434",
"0.5915851",
"0.5886435",
"0.5823551",
"0.58014125",
"0.5756252",
"0.57223356",
"0.567222",
"0.5631674",
"0.56219935",
"0.56203365",
"0.5606508",
"0.55915666",
"0.55769116",
"0.55665886",
"0.5562742",
"0.5562742",
"0.55596316",
"0.5551... | 0.0 | -1 |
behaves like a normal label, except it uses the same parameter as form_label omits label wrapping e.g. ... | def form_label_without_wrapping(object_name, method_name, *args)
options = args.extract_options!
options = normalize_form_label_options(options)
text = args.first || options.delete(:text)
label(object_name, method_name, text, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label(*args)\n current_form_context.label(*args)\n end",
"def form_label(model, label_text, options={})\n\t\tfield_name = options[:field_name]\n\t\tfield_name ||= label_text.gsub(' ', '_')\n\t\tlabel_for = (model.to_s + '_' + field_name).downcase\n\t\tlabel_tag = content_tag('label', label_text, label_fo... | [
"0.79747874",
"0.78619874",
"0.7637113",
"0.7604215",
"0.750032",
"0.7407079",
"0.73812115",
"0.738087",
"0.7380789",
"0.7332394",
"0.72707474",
"0.726871",
"0.7219486",
"0.721126",
"0.7197181",
"0.7168917",
"0.71438634",
"0.7120233",
"0.7116078",
"0.70983976",
"0.7070198",
... | 0.7636594 | 3 |
form field helpers form_field to wrap a form field between tags | def form_field(object_name, method, options={}, &block)
raise "No block given for from_field" unless block_given?
if defined?(:capture)
form_field_with_capture(object_name, method, options, &block)
else
form_field_without_capture(object_name, method, options, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_field(field, options = {})\n required_flag = options.delete(:required) ? true : false\n text = \"\"\n\n field_text = content_tag(\"span\", field,{:class => \"form-field\"}, false)\n\n required_text = content_tag(\"span\",\"\",{:class => \"form-field-required-flag\"}, false)\n\n info_imag... | [
"0.7333756",
"0.71423554",
"0.6764207",
"0.6689143",
"0.65735406",
"0.65675336",
"0.6554551",
"0.65443325",
"0.6541998",
"0.6492958",
"0.6491278",
"0.6489537",
"0.64847416",
"0.64714026",
"0.6466776",
"0.6424548",
"0.64204955",
"0.638739",
"0.63730884",
"0.62801147",
"0.62396... | 0.0 | -1 |
this is used as alias for form_field in a rails view context | def form_field_with_capture(object_name, method, options={}, &block)
rendered, help_options = extract_form_field_help_options(options)
options = sanitize_form_field_options(options)
html_options = options.delete(:html_options) || {}
html_options[:class] = "#{html_options[:class]} clearfix"
concat tag(:dd, html_options, true)
concat capture(&block)
concat "</dd>"
#concat probono_clear_class
# add help caption
if !help_options.blank? && rendered
concat help_text(object_name, method, help_options)
elsif !help_options.blank?
concat help(object_name, method, help_options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_field\n case self.column_type\n when \"text\"\n %{<%= :#{self.model_name}.text_area :#{self.column_name}, :label => true %>}\n when \"date\"\n %{<%= :#{self.model_name}.date_select :#{self.column_name}, :label => true %>}\n when \"date_time\"\n ... | [
"0.72871584",
"0.6811545",
"0.6705842",
"0.6648298",
"0.65270203",
"0.6524946",
"0.650468",
"0.6503915",
"0.64910793",
"0.64748764",
"0.6455452",
"0.641725",
"0.64154464",
"0.63678616",
"0.63264567",
"0.6319227",
"0.6305269",
"0.62973267",
"0.62913364",
"0.62780476",
"0.62591... | 0.5799618 | 68 |
this is used as alias for form_field where there is no concat available | def form_field_without_capture(object_name, method, options={}, &block)
rendered, help_options = extract_form_field_help_options(options)
options = sanitize_form_field_options(options)
html_options = options.delete(:html_options) || {}
html_options[:class] = "#{html_options[:class]} clearfix"
html = tag(:dd, html_options, true)
html += String(yield)
html += "</dd>"
unless help_options.blank?
html += rendered ? help_text(object_name, method, help_options) : help(object_name, method, help_options)
end
html
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_field\n case self.column_type\n when \"text\"\n %{<%= :#{self.model_name}.text_area :#{self.column_name}, :label => true %>}\n when \"date\"\n %{<%= :#{self.model_name}.date_select :#{self.column_name}, :label => true %>}\n when \"date_time\"\n ... | [
"0.6123963",
"0.6113853",
"0.61060697",
"0.6054052",
"0.60276973",
"0.6025411",
"0.6016318",
"0.6009662",
"0.59655565",
"0.59569305",
"0.5948732",
"0.59381694",
"0.5907778",
"0.58869904",
"0.58681244",
"0.58561736",
"0.5852921",
"0.5809841",
"0.5792921",
"0.57920694",
"0.5789... | 0.0 | -1 |
form_field_tag with if condition | def form_field_tag_if(condition, name, options={}, &block)
form_field_tag(name, options, &block) if condition
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def form_input?(tag)\n FORM_INPUTS.include?(tag)\n end",
"def form_element_if(condition, *args, &block)\n form_element(*args, &block) if condition\n end",
"def value_for_tag?(tag)\n @set_fields[tag] || false\n end",
"def hidden_field?(field_name); end",
"def form_tag(url_for_opt... | [
"0.6625311",
"0.6539874",
"0.62312657",
"0.6140676",
"0.60652685",
"0.58785516",
"0.586094",
"0.58605224",
"0.56875193",
"0.5686554",
"0.5686444",
"0.56824905",
"0.56750125",
"0.5599845",
"0.55712956",
"0.5566806",
"0.55601174",
"0.55480665",
"0.5541232",
"0.55140305",
"0.550... | 0.8525367 | 0 |
clean form field options of unnecessary stuff | def sanitize_form_field_options(options={})
options.symbolize_keys.reject {|k,v| [:disabled, :object, :help, :edit, :label, :req, :lock].include?(k)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_field_options(options={})\n options.stringify_keys.reject {|k, v| %w(vertical_align label edit req lock auto popup url position help).include?(k)}.symbolize_keys\n end",
"def strip_formtastic_options(options) #:nodoc:\n options.except(:value_method, :label_method, :collection, :re... | [
"0.74034667",
"0.6613715",
"0.65059566",
"0.6459138",
"0.6455472",
"0.6221802",
"0.6164604",
"0.60950804",
"0.60727376",
"0.60503006",
"0.6037716",
"0.60021865",
"0.5981846",
"0.5978974",
"0.5976046",
"0.59561086",
"0.5952735",
"0.59468645",
"0.5927496",
"0.5889467",
"0.58883... | 0.7560706 | 0 |
GET /patients GET /patients.json | def index
@human = current_user.humen.find(params[:human_id])
@patients = @human.patients
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patients\n patients = User.patients\n render json: { status: 200, data: patients }\n end",
"def index\n @patients = Patient.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @patients }\n end\n end",
"def index\n @patients = Patient.all... | [
"0.8516118",
"0.7569042",
"0.756106",
"0.7403918",
"0.73298424",
"0.73298424",
"0.73298424",
"0.7266375",
"0.7243043",
"0.7211859",
"0.7060163",
"0.69869906",
"0.69869906",
"0.69869906",
"0.69869906",
"0.69869906",
"0.6982621",
"0.6905368",
"0.6856045",
"0.6836014",
"0.682363... | 0.6388063 | 56 |
GET /patients/1 GET /patients/1.json | def show
@human = current_user.humen.find(params[:human_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patients\n patients = User.patients\n render json: { status: 200, data: patients }\n end",
"def show\n @patient = Patient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @patient }\n end\n end",
"def show\n @patient = Pat... | [
"0.8068742",
"0.77322924",
"0.77322924",
"0.77322924",
"0.74470353",
"0.74359375",
"0.7393628",
"0.7371118",
"0.7279583",
"0.72444344",
"0.7220066",
"0.7197602",
"0.7136716",
"0.7091374",
"0.70721817",
"0.7024261",
"0.7024261",
"0.7008515",
"0.70075595",
"0.69602466",
"0.6901... | 0.0 | -1 |
POST /patients POST /patients.json | def create
human = current_user.humen.find(params[:human_id])
@patient = human.patients.new(patient_params)
@patient.nombre = human.nombre
@patient.ocupacion = human.ocupacion
@patient.sexo = human.sexo
@patient.edad = human.edad
@patient.estado_civil = human.estado_civil
respond_to do |format|
if @patient.save
format.html { redirect_to ([@patient.human, @patient]), notice: 'La Ficha de Atencion ha sido creada.' }
format.json { render :show, status: :created, location: @patient }
else
format.html { render :new }
format.json { render json: @patient.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patients\n patients = User.patients\n render json: { status: 200, data: patients }\n end",
"def create\n @patient = @client.patients.build(params[:patient])\n \n respond_to do |format|\n if @patient.save\n format.html { redirect_to @patient, notice: 'Patient was successfully creat... | [
"0.7592191",
"0.73099726",
"0.7224586",
"0.7215889",
"0.7204241",
"0.71554035",
"0.7154567",
"0.7154567",
"0.7154567",
"0.7145153",
"0.71400976",
"0.71327364",
"0.7114515",
"0.7087543",
"0.7064427",
"0.7018494",
"0.6986667",
"0.69537294",
"0.68936956",
"0.6878548",
"0.6838345... | 0.6333656 | 54 |
PATCH/PUT /patients/1 PATCH/PUT /patients/1.json | def update
human = current_user.humen.find(params[:human_id])
@patient = human.patients.find(params[:id])
@patient.nombre = human.nombre
@patient.ocupacion = human.ocupacion
@patient.sexo = human.sexo
@patient.edad = human.edad
@patient.estado_civil = human.estado_civil
respond_to do |format|
if @patient.update(patient_params)
format.html { redirect_to [@patient.human,@patient], notice: 'La Ficha de Atencion ha sido actualizada.' }
format.json { render :show, status: :ok, location: @patient }
else
format.html { render :edit }
format.json { render json: @patient.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @patient = @client.patients.find(params[:id])\n\n respond_to do |format|\n if @patient.update_attributes(params[:patient])\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render a... | [
"0.75512815",
"0.72636867",
"0.7239252",
"0.7219267",
"0.7213453",
"0.71881855",
"0.7145686",
"0.7145356",
"0.7129984",
"0.7129984",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.7030897",
"0.70294386",
"0.7007923",... | 0.6240864 | 57 |
DELETE /patients/1 DELETE /patients/1.json | def destroy
human = current_user.humen.find(params[:human_id])
@patient = human.patient.new(patient_params)
@patient.destroy
respond_to do |format|
format.html { redirect_to patients_url, notice: 'La Ficha de Atencion ha sido eliminada.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @patient.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @patient = Patient.find(params[:id])\n @patient.destroy\n\n respond_to do |format|\n format.html { redirect_to patients_url }\n format.json { head :ok }\n e... | [
"0.79443026",
"0.7818962",
"0.78076196",
"0.78076196",
"0.78076196",
"0.78076196",
"0.778471",
"0.7758137",
"0.7758137",
"0.7758137",
"0.7758137",
"0.77568585",
"0.7693971",
"0.7637775",
"0.7611082",
"0.75585014",
"0.7551793",
"0.7544347",
"0.75142616",
"0.75102514",
"0.75100... | 0.7194422 | 59 |
Use callbacks to share common setup or constraints between actions. | def set_patient
human = current_user.humen.find(params[:human_id])
@patient = human.patients.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def patient_params
params.require(:patient).permit(:fecha, :nombre, :sexo, :edad, :ocupacion, :estado_civil, :descripcion_del_paciente, :anamnesis, :hora_de_inicio, :desarrollo_de_la_sesion, :hora_de_termino, :comentarios, :tag_ids => [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
GET /posts GET /posts.json | def index
@posts = Post.where(boardtype: params[:type])
#localhost:3000/posts?type=auction 혹은 /posts?type=rent로 하면 해당 게시글만 보여짐
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n ... | [
"0.7866291",
"0.74953306",
"0.7494917",
"0.7494917",
"0.7489136",
"0.7431804",
"0.7286642",
"0.7286642",
"0.7286642",
"0.725636",
"0.7252535",
"0.7247708",
"0.7246376",
"0.72223",
"0.7204546",
"0.7204476",
"0.7170577",
"0.7169457",
"0.71660894",
"0.7123361",
"0.711584",
"0.... | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
@comments = Comment.all
if user_signed_in?
@like = Like.where(user_id: current_user.id, post_id: @post.id)
else
@like = []
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
... | [
"0.77119195",
"0.73543334",
"0.73437566",
"0.7338182",
"0.7323827",
"0.7293454",
"0.727687",
"0.72568816",
"0.71632427",
"0.7160145",
"0.71564347",
"0.71564347",
"0.712078",
"0.7096915",
"0.7096915",
"0.7096915",
"0.70940864",
"0.7073703",
"0.7062825",
"0.7047479",
"0.7033576... | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @po... | [
"0.74463975",
"0.73221767",
"0.73072433",
"0.7123966",
"0.7015686",
"0.701327",
"0.69841874",
"0.6939327",
"0.69313824",
"0.69053805",
"0.68196476",
"0.6812792",
"0.6793222",
"0.6792862",
"0.6779654",
"0.6779654",
"0.67625546",
"0.67602354",
"0.67515427",
"0.6735786",
"0.6698... | 0.6345706 | 86 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n forma... | [
"0.71862537",
"0.70413613",
"0.6773835",
"0.6766243",
"0.66691214",
"0.66486603",
"0.6578893",
"0.65564305",
"0.6550832",
"0.65507567",
"0.6534898",
"0.653136",
"0.6499514",
"0.64970934",
"0.64680624",
"0.64311296",
"0.6428271",
"0.64268893",
"0.64268476",
"0.64193285",
"0.64... | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
backurl = "/boards/"+ @post.boardtype.to_s
format.html { redirect_to backurl, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: param... | [
"0.8046927",
"0.76904076",
"0.7584888",
"0.7580699",
"0.7568424",
"0.75054324",
"0.7504039",
"0.74757856",
"0.746826",
"0.74662447",
"0.7464773",
"0.7460266",
"0.7460266",
"0.7460266",
"0.7460266",
"0.7458692",
"0.7458692",
"0.7458692",
"0.7458692",
"0.7458692",
"0.7458692",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def post_params
params.require(:post).permit(:boardtype, :title, :content, :postimage, :category, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980244",
"0.6782812",
"0.6745103",
"0.6741142",
"0.6733961",
"0.65925",
"0.6503602",
"0.64967257",
"0.64822173",
"0.64796996",
"0.6456357",
"0.6439594",
"0.63803256",
"0.6376499",
"0.63644457",
"0.6319286",
"0.6299465",
"0.6298051",
"0.62935406",
"0.62923044",
"0.6291212"... | 0.0 | -1 |
attr_accessor : create setter & getter method for the word the class instances are initialized with | def initialize(word)
@word = word
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(word)\n @word = word \nend",
"def initialize(word)\n @word=word\n end",
"def initialize(word)\n @word = word #instanciates a new instance of `word`\n end",
"def initialize(word)\n @word = word\n end",
"def initialize(word)\n\t\t@word = word\n\tend",
"def initialize\n ... | [
"0.72781944",
"0.72556823",
"0.7158256",
"0.6954427",
"0.6945719",
"0.6916038",
"0.6902265",
"0.68275267",
"0.6758189",
"0.66506034",
"0.65995693",
"0.65985376",
"0.6506883",
"0.6506883",
"0.6506883",
"0.6455237",
"0.64529395",
"0.6417945",
"0.63797003",
"0.6275865",
"0.62411... | 0.7146067 | 12 |
This returns true if the tweet is a reply to someone, false if it isn't | def reply?
!self.in_reply_to.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reply?\n !!in_reply_to_status_id\n end",
"def answered_by?(user)\n replies.exists?(:user_id => user)\n end",
"def check_if_reply_and_not_already_read(tweet)\n\n puts tweet.text\n if tweet.text.match(/^@partyprinter.*/) && tweet.user.id != 1678701920 && Tweet.exists?(tweet.id.to_i) == nil\n ... | [
"0.8156376",
"0.78701",
"0.77932274",
"0.7774268",
"0.7501654",
"0.74164146",
"0.74140036",
"0.7360148",
"0.7360148",
"0.7320537",
"0.71854484",
"0.71737576",
"0.709681",
"0.70790815",
"0.7055218",
"0.7051182",
"0.6931537",
"0.6925203",
"0.68984663",
"0.68559647",
"0.68122727... | 0.8033367 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.