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
Find a string in text input Finds all occurrences of the input string in the input content, and returns the matches
def edit_text_find_simple_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_find_simple ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_find_simple" end # resource path local_var_path = '/convert/edit/text/find/string' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'FindStringSimpleResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_find_simple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match_text text\n @lookups.each do |rx_curr|\n return true if text =~ rx_curr\n end\n false\n end", "def partial_matches_for(input_string)\n # [\"aardvark\", \"apple\"]\n @word_list.select do |word|\n word.start_with?(input_string)\n end\n end", "def textmatch(text, terms)\n ...
[ "0.68036395", "0.6795913", "0.67817473", "0.67779964", "0.67151433", "0.6652563", "0.6601666", "0.65592533", "0.6536796", "0.6494622", "0.64858484", "0.6435211", "0.6286359", "0.62684727", "0.625438", "0.62385225", "0.62101394", "0.62021774", "0.6197026", "0.6191484", "0.6185...
0.0
-1
Remove whitespace from text string Removes all whitespace from text, leaving behind only nonwhitespace characters. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_remove_all_whitespace(request, opts = {}) data, _status_code, _headers = edit_text_remove_all_whitespace_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def strip_all_spaces(text)\n text&&text.gsub(/ |\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def sanitize text\n [' ',...
[ "0.81326824", "0.80019504", "0.76887697", "0.76572776", "0.75752884", "0.757346", "0.7497051", "0.74809724", "0.7444948", "0.74003035", "0.7357382", "0.7331862", "0.73272204", "0.73223364", "0.73080677", "0.7296706", "0.7286191", "0.72791386", "0.7262048", "0.725166", "0.7229...
0.6582775
84
Remove whitespace from text string Removes all whitespace from text, leaving behind only nonwhitespace characters. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_remove_all_whitespace_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_remove_all_whitespace ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_remove_all_whitespace" end # resource path local_var_path = '/convert/edit/text/remove/whitespace/all' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveWhitespaceFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_remove_all_whitespace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize_whitespace(text)\n text.to_s.gsub(/[[:space:]]+/, ' ').strip\n end", "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def strip_all_spaces(text)\n text&&text.gsub(/ |\\xC2\\xA0|\\xA0/, ' ').strip\n end", "def sanitize text\n [' ',...
[ "0.81326866", "0.8002261", "0.76887006", "0.76567113", "0.7575633", "0.7572814", "0.74958056", "0.74804974", "0.74444455", "0.73995566", "0.7356686", "0.7330323", "0.73262304", "0.7323826", "0.73082674", "0.7296096", "0.72854424", "0.7279162", "0.72619355", "0.7251063", "0.72...
0.0
-1
Remove HTML from text string Removes HTML from text, leaving behind only text. Formatted text will become plain text. Important for protecting against HTML and CrossSiteScripting attacks.
def edit_text_remove_html(request, opts = {}) data, _status_code, _headers = edit_text_remove_html_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n e...
[ "0.7924629", "0.7910312", "0.7887182", "0.7887182", "0.78210896", "0.77246463", "0.7661887", "0.7532948", "0.74416566", "0.7440146", "0.7242279", "0.72368854", "0.7067145", "0.70537746", "0.705334", "0.70479095", "0.7041641", "0.6996081", "0.6968631", "0.6968631", "0.6968631"...
0.69984794
17
Remove HTML from text string Removes HTML from text, leaving behind only text. Formatted text will become plain text. Important for protecting against HTML and CrossSiteScripting attacks.
def edit_text_remove_html_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_remove_html ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_remove_html" end # resource path local_var_path = '/convert/edit/text/remove/html' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveHtmlFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_remove_html\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_html(string=\"\")\n begin\n string = strip_tags(string)\n string = string.gsub(/<\\/?[^>]*>/, \"\")\n string = string.gsub(/\\&+\\w*\\;/, \" \") # replace &nbsp; with a space\n string.html_safe\n rescue\n raw(\"<!-- error stripping html from: #{string} -->\")\n end\n e...
[ "0.7926463", "0.79096335", "0.7888792", "0.7888792", "0.7820859", "0.7726107", "0.76613516", "0.75348973", "0.7444003", "0.74397993", "0.7242551", "0.7237054", "0.706811", "0.7054293", "0.70524216", "0.7047737", "0.7043161", "0.6997918", "0.6995465", "0.6969951", "0.6969951",...
0.0
-1
Replace a string in text with a regex regular expression string Replaces all occurrences of the input regular expression regex string in the input content, and returns the result
def edit_text_replace_regex(request, opts = {}) data, _status_code, _headers = edit_text_replace_regex_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n ...
[ "0.72141683", "0.70457387", "0.6969422", "0.6736167", "0.6681672", "0.6660193", "0.651932", "0.64290744", "0.6422861", "0.6416157", "0.6298413", "0.6285974", "0.6206541", "0.6196962", "0.6154058", "0.61505824", "0.6142467", "0.61248857", "0.61047447", "0.6096712", "0.60720056...
0.6726202
4
Replace a string in text with a regex regular expression string Replaces all occurrences of the input regular expression regex string in the input content, and returns the result
def edit_text_replace_regex_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_replace_regex ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_replace_regex" end # resource path local_var_path = '/convert/edit/text/replace/regex' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ReplaceStringRegexResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_replace_regex\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def regex_replace(string, search, replace)\n return string.gsub(/#{search}/m, replace)\n end", "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n ...
[ "0.7216716", "0.7045514", "0.6968202", "0.67358905", "0.67265934", "0.6683212", "0.66611296", "0.6518081", "0.64273727", "0.64228755", "0.64181393", "0.62994695", "0.6286472", "0.6207523", "0.6197219", "0.6154564", "0.6150717", "0.61427104", "0.6124004", "0.61055475", "0.6095...
0.55705154
59
Replace a string in text with another string value Replaces all occurrences of the input string in the input content, and returns the result
def edit_text_replace_simple(request, opts = {}) data, _status_code, _headers = edit_text_replace_simple_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def replace(range, content); end", "def replace(range, content); end", "...
[ "0.762407", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.68984413", "0.67544174", "0.6717642", "0.66559976", "0.6648128", "0.66168153", "0.661061", "0.6596554", "0.65858436", "0.65445876", "0.64956063", "0.6458525", "0.6...
0.0
-1
Replace a string in text with another string value Replaces all occurrences of the input string in the input content, and returns the result
def edit_text_replace_simple_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_replace_simple ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_replace_simple" end # resource path local_var_path = '/convert/edit/text/replace/string' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ReplaceStringSimpleResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_replace_simple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_text(book_text, string_values)\n string_values.each do |search_string, change_string|\n regex = %r[#{search_string}]\n book_text = book_text.gsub(regex, change_string)\n end\n\n return book_text\nend", "def replace(range, content); end", "def replace(range, content); end", "...
[ "0.7625409", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.6899294", "0.67564654", "0.67163825", "0.66556567", "0.66488314", "0.66175383", "0.6611373", "0.6597033", "0.6585868", "0.6544969", "0.64935786", "0.6457031", "0.6451065...
0.0
-1
Detect text encoding of file Checks text encoding of file
def edit_text_text_encoding_detect(input_file, opts = {}) data, _status_code, _headers = edit_text_text_encoding_detect_with_http_info(input_file, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif ...
[ "0.7468341", "0.7315846", "0.7315846", "0.7143658", "0.7143658", "0.7135522", "0.70065147", "0.6690792", "0.66232216", "0.6559273", "0.6357972", "0.6327798", "0.63072276", "0.6252365", "0.60887176", "0.6066811", "0.60543954", "0.60470784", "0.5998056", "0.5984209", "0.5974880...
0.7079332
6
Detect text encoding of file Checks text encoding of file
def edit_text_text_encoding_detect_with_http_info(input_file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_text_encoding_detect ...' end # verify the required parameter 'input_file' is set if @api_client.config.client_side_validation && input_file.nil? fail ArgumentError, "Missing the required parameter 'input_file' when calling EditTextApi.edit_text_text_encoding_detect" end # resource path local_var_path = '/convert/edit/text/encoding/detect' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data']) # form parameters form_params = {} form_params['inputFile'] = input_file # http body (model) post_body = nil auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'TextEncodingDetectResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_text_encoding_detect\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_encoding\n\tall_encoding = []\n\tfiles = Dir.glob(\"**/*.rb\") + Dir.glob(\"**/*.yml\") + Dir.glob(\"**/*.feature\")\n\tfiles.each do |file|\n\t\tall_encoding.push(File.open(file).map { |line| line.to_s.encoding })\n\tend\n\n\tnb = all_encoding.flatten.count { |encoding| encoding.name != 'UTF-8' }\n\tif ...
[ "0.7467405", "0.7315119", "0.7315119", "0.71428925", "0.71428925", "0.71347225", "0.7080432", "0.7006854", "0.6690197", "0.6623114", "0.65585196", "0.6356964", "0.6327214", "0.63073605", "0.6253385", "0.6087701", "0.6067097", "0.60535413", "0.6048344", "0.5997201", "0.5983960...
0.0
-1
Trim leading and trailing whitespace from text string Trim leading and trailing whitespace from text, leaving behind a trimmed string. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_trim_whitespace(request, opts = {}) data, _status_code, _headers = edit_text_trim_whitespace_with_http_info(request, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def trim_whitespace; end", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def strip_leading_whitespace(text)\n return text if text.empty?\n l...
[ "0.78723127", "0.74349684", "0.7423679", "0.7282651", "0.7208551", "0.7148014", "0.70951265", "0.7042206", "0.7039366", "0.6947847", "0.6894527", "0.6841162", "0.68303525", "0.6811027", "0.6784939", "0.67613214", "0.67364526", "0.67206913", "0.6702575", "0.66930556", "0.66770...
0.6285772
41
Trim leading and trailing whitespace from text string Trim leading and trailing whitespace from text, leaving behind a trimmed string. Whitespace includes newlines, spaces and other whitespace characters.
def edit_text_trim_whitespace_with_http_info(request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: EditTextApi.edit_text_trim_whitespace ...' end # verify the required parameter 'request' is set if @api_client.config.client_side_validation && request.nil? fail ArgumentError, "Missing the required parameter 'request' when calling EditTextApi.edit_text_trim_whitespace" end # resource path local_var_path = '/convert/edit/text/remove/whitespace/trim' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/json', 'application/xml', 'text/xml']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json', 'text/json', 'application/xml', 'text/xml', 'application/x-www-form-urlencoded']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(request) auth_names = ['Apikey'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RemoveWhitespaceFromTextResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: EditTextApi#edit_text_trim_whitespace\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trimmed_whitespace(text)\n text.gsub(/[\\t\\n\\f\\r ]+/ium, ' ')\n end", "def trim_whitespace; end", "def strip_trailing_whitespace(text)\n text.split(\"\\n\").collect(&:strip).join(\"\\n\")\n end", "def strip_leading_whitespace(text)\n return text if text.empty?\n l...
[ "0.78716844", "0.74339074", "0.7422887", "0.7281248", "0.7207586", "0.7147139", "0.70955426", "0.70419943", "0.70376605", "0.69464564", "0.6892956", "0.6840761", "0.68293494", "0.68102765", "0.67847615", "0.6759722", "0.6735669", "0.67207277", "0.67022103", "0.66914845", "0.6...
0.0
-1
create new instance of review for current presentation instance
def create @review = Presentation.find(params[:id]).reviews.build(reviews_params) @review.user_id = current_user.id @review.save redirect_to current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n\t\t@review = Review.new\n\tend", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n end", "def new\n @review = Review.new\n en...
[ "0.7421345", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.7372323", "0.73486525", "0.698937", "0.69290376", "0.68627757", "0.6862681", "0.6855386", "0.6855386", "0.6855386", "0.6855386", "0.6824502", "0.6819315", "0.6772726", ...
0.7245043
10
instantiates tuples for join table of reviews and User model
def index @user = current_user @presentation = Presentation.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def my_reviews\n self.reviews.select do |review|\n review.user.id = self.id \n end \n end", "def create_users_products\n @db.create_join_table(:user_id => :users, :product_id => :products) do\n end\n end", "def user_reviews\n Review.all.select {|review| review.user ...
[ "0.6087441", "0.6030822", "0.575462", "0.5687787", "0.5681288", "0.56111884", "0.55482954", "0.5392939", "0.53920627", "0.53743136", "0.53597075", "0.53304", "0.5269897", "0.52576977", "0.522217", "0.51144004", "0.509312", "0.5079994", "0.5061492", "0.50453436", "0.5027106", ...
0.0
-1
returns attributes for reviews instance from form data of post request
def reviews_params params.permit(:score, :comment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def review_params\n params.fetch(:review, {}).permit(:rating, :body, :restaurant_id, :timestamp)\n end", "def review_params\n params.require(:review).permit( :comment, :attraction_id)\n end", "def review_params\n parm = params.fetch(:review, {}).permit!\n p 'params', parm\n parm\n end...
[ "0.66076064", "0.6541703", "0.65186834", "0.6511674", "0.64998484", "0.648443", "0.6455477", "0.6448019", "0.63681144", "0.6337014", "0.6321367", "0.6294514", "0.6292441", "0.62871933", "0.62807584", "0.62787795", "0.62758386", "0.6268009", "0.6266792", "0.62548", "0.6239934"...
0.6050048
48
GET /catalogs/locations GET /catalogs/locations.json
def index @resources = Catalogs::Location.search(params[:search]).order("#{sort_column} #{sort_direction}").paginate(per_page: 11, page: params[:page]) authorize @resources end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations\n get('locations')\n end", "def index\n @catalog_locations = Catalog::Location.all\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n locations = Location.all\n render json: locations\n end", "def index\n @service_locations = Service...
[ "0.7658977", "0.7414822", "0.7125742", "0.68398523", "0.6815061", "0.6758357", "0.670795", "0.6701871", "0.6701353", "0.66858673", "0.6682732", "0.66826105", "0.6674633", "0.6664289", "0.66210115", "0.65417254", "0.6537305", "0.6520054", "0.649505", "0.6479827", "0.64735633",...
0.0
-1
GET /catalogs/locations/1 GET /catalogs/locations/1.json
def show authorize @resource respond_to do |format| format.html format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @catalog_locations = Catalog::Location.all\n end", "def locations\n get('locations')\n end", "def catalogs\n path = \"#{api_root}/index/catalogs\"\n process_api_request(:get, path)\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n @ap...
[ "0.7068212", "0.6955868", "0.6842533", "0.67034024", "0.6642539", "0.660242", "0.6562066", "0.6539946", "0.6520473", "0.651868", "0.64098555", "0.64075917", "0.6400084", "0.6377357", "0.6361328", "0.6350239", "0.6345115", "0.63340205", "0.63269997", "0.632488", "0.6251556", ...
0.0
-1
POST /catalogs/locations POST /catalogs/locations.json
def create @resource = Catalogs::Location.new(catalogs_location_params) respond_to do |format| if @resource.save index flash[:success] = t('notices.saved_successfully') format.html { redirect_to @resource, notice: 'Location was successfully created.' } format.json { render :show, status: :created, location: @resource } else format.html { render :new } format.json { render json: @resource.errors, status: :unprocessable_entity } end format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @catalogs_location = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @catalogs_location.save\n format.html { redirect_to @catalogs_location, notice: t('.created') }\n format.json { render :show, status: :created, location: @catalogs_location }\...
[ "0.7232983", "0.7151177", "0.6698", "0.65391666", "0.65108997", "0.6459051", "0.6453451", "0.644441", "0.6422136", "0.63830936", "0.63439965", "0.6340161", "0.6299384", "0.6282217", "0.62808484", "0.6267307", "0.6265283", "0.61773825", "0.61661524", "0.61661524", "0.61661524"...
0.69537973
2
PATCH/PUT /catalogs/locations/1 PATCH/PUT /catalogs/locations/1.json
def update respond_to do |format| if @resource.update(catalogs_location_params) # Load records in order to refresh index page index flash[:success] = t('notices.updated_successfully') format.html { redirect_to @resource, warning: 'Location was successfully updated.' } format.json { render :show, status: :ok, location: @resource } format.js else format.html { render :edit } format.json { render json: @resource.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @catalogs_location.update(catalogs_location_params)\n format.html { redirect_to @catalogs_location, notice: t('.updated') }\n format.json { render :show, status: :ok, location: @catalogs_location }\n else\n format.html { render :edit }\n ...
[ "0.6973116", "0.6766193", "0.662001", "0.64670026", "0.6360028", "0.6312289", "0.6268607", "0.62132907", "0.6202481", "0.61735505", "0.6159568", "0.6149059", "0.6100566", "0.60905176", "0.6040952", "0.6022997", "0.60228384", "0.60180384", "0.60162354", "0.59800595", "0.597771...
0.6483199
3
DELETE /catalogs/locations/1z DELETE /catalogs/locations/1.json
def destroy @resource.destroy respond_to do |format| format.html { redirect_to catalogs_locations_url, flash: {warning: t('notices.destroyed') }} format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @catalog_location.destroy\n respond_to do |format|\n format.html { redirect_to catalog_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_location = StorageLocation.find(params[:id])\n @s...
[ "0.70818424", "0.6831045", "0.6726676", "0.66676116", "0.6643871", "0.65990657", "0.654962", "0.65441644", "0.6518476", "0.6516719", "0.6503322", "0.6494045", "0.64939845", "0.6491001", "0.6490741", "0.64897543", "0.64838725", "0.6483559", "0.64463705", "0.64400375", "0.64380...
0.6650272
4
Use callbacks to share common setup or constraints between actions.
def set_catalogs_location @resource = Catalogs::Location.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def catalogs_location_params params.require(:catalogs_location).permit(:abbr, :name_es, :name_en) 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 /users GET /users.json
def index @users = User.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def GetUsers params = {}\n\n para...
[ "0.82109934", "0.7873764", "0.7860689", "0.78108346", "0.78067017", "0.7678852", "0.76586664", "0.76318866", "0.7582366", "0.75291824", "0.7487637", "0.74485743", "0.7439024", "0.7437192", "0.7427442", "0.73978853", "0.73978853", "0.73978853", "0.73978853", "0.7377353", "0.73...
0.0
-1
GET /users/1 GET /users/1.json
def show redirect_to user_articles_path(@user) unless @user == @current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.81046426", "0.7703556", "0.77011716", "0.76262826", "0.7582106", "0.74818", "0.7461394", "0.7446168", "0.730656", "0.7300699", "0.72902125", "0.72781444", "0.72358584", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.72335744", "0.722...
0.0
-1
POST /users POST /users.json
def create @user = User.new(user_params) respond_to do |format| if @user.save format.html { redirect_to login_url, notice: '注册成功,可以登录了!' } format.json { render :show, status: :created, location: @user } else format.html { render :new } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post b...
[ "0.77178615", "0.751936", "0.73831904", "0.72412014", "0.719768", "0.7140784", "0.7103724", "0.70586866", "0.7041747", "0.70236677", "0.7003012", "0.7002012", "0.7002012", "0.7002012", "0.6992873", "0.6990429", "0.6980341", "0.69790155", "0.6978697", "0.6978697", "0.69763535"...
0.0
-1
PATCH/PUT /users/1 PATCH/PUT /users/1.json
def update respond_to do |format| if @user.update(user_params) format.html { redirect_to @user, notice: '所有的信息都已经更新。' } else format.html { render :edit } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "de...
[ "0.72248507", "0.7128768", "0.7003289", "0.6902831", "0.68211025", "0.681476", "0.6707567", "0.6692646", "0.667998", "0.66728854", "0.66717863", "0.666447", "0.666447", "0.66587144", "0.66587144", "0.6653841", "0.6647832", "0.6642772", "0.6640692", "0.6634225", "0.66175383", ...
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user.destroy respond_to do |format| format.html { redirect_to users_url, notice: '用户已删除。' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\...
[ "0.78750724", "0.77518034", "0.7713981", "0.7610077", "0.747295", "0.74073994", "0.74073994", "0.7369968", "0.7346072", "0.7340465", "0.7328618", "0.7309635", "0.73095363", "0.7306841", "0.7297868", "0.72917855", "0.7291585", "0.7289111", "0.7284347", "0.7250935", "0.7250935"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.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
category_id min_price, max_price deadline
def filter page = params[:page] || 1 want_ads = WantAd.active.joins(:user) .joins("LEFT OUTER JOIN addresses a ON a.addressable_id = want_ads.id and a.addressable_type = 'WantAd'") .joins("LEFT OUTER JOIN cities ON cities.id = a.city_id") .select('users.name as user_name, cities.name as city_name, want_ads.*') want_ads = want_ads.where(category_id: params[:category_id]) if params[:category_id].present? want_ads = want_ads.where("cities.id = #{params[:city_id]}") if params[:city_id].present? want_ads = want_ads.where("price >= #{params[:min_price]}") if params[:min_price].present? want_ads = want_ads.where("price <= #{params[:max_price]}") if params[:max_price].present? want_ads = want_ads.where("deadline <= '#{params[:date]}'") if params[:date].present? want_ads = want_ads.where("title ILIKE '%#{params[:search]}%' OR description ILIKE '%#{params[:search]}%'") if params[:search].present? want_ads = want_ads.order("#{params[:sort_by]}") if params[:sort_by].present? want_ads = want_ads.page(page) want_ads.map do |want_ad| { id: want_ad.id, title: want_ad.title, description: want_ad.description, deadline: want_ad.deadline, owner_name: want_ad.user_name, city_name: want_ad.city_name, price: want_ad.price } end render json: { want_ads: want_ads, number_pages: want_ads.total_pages, current_page: page } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_max_price\n if price_min.blank?\n errors.add(:max_price, \"Minimum Price can't be blank \")\n elsif (price_min.present? and price_max.present?) and price_max < price_min\n errors.add(:max_price, \"can't be less than minimum price\")\n end\n end", "def set_min_max_price_values\n pri...
[ "0.6294308", "0.6114247", "0.57694495", "0.57682294", "0.575426", "0.57185185", "0.56026673", "0.5500002", "0.5500002", "0.5496618", "0.54170084", "0.53784925", "0.5342436", "0.5337434", "0.53291327", "0.5317286", "0.529486", "0.5271505", "0.52558035", "0.5243964", "0.5233515...
0.0
-1
File actionpack/lib/action_view/helpers/text_helper.rb, line 215
def word_wrap(text, line_width = 80) text.split("\n").collect do |line| line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line end * "\n" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def text_helper\n gem 'actionpack'\n require 'action_controller' # bringing this in for autolinks\n helper = Object.new\n helper.extend ActionView::Helpers::TextHelper\n helper.extend ActionView::Helpers::TagHelper\n helper\nend", "def text_message_content_from_erb\n # TODO: Remove the following err...
[ "0.7388642", "0.6205606", "0.60055816", "0.5845168", "0.5845168", "0.5845168", "0.5727737", "0.57178885", "0.57178885", "0.5691172", "0.56843746", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853", "0.5681853",...
0.0
-1
Convenience method to test if we're missing any required switches
def missing_switches? !@missing_switches.nil? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def detect_unsupported_switches!(args)\n return unless (unsupported = UNSUPPORTED_SWITCHES & args).any?\n\n $stdout.puts \"Please set the following switches in your vite.json instead: #{ unsupported }.\"\n exit!\n end", "def check_for_missing_enabled_option(hash); end", "def missing_args?(opts)\n ...
[ "0.68960816", "0.64150405", "0.6221129", "0.6208155", "0.61850625", "0.6174304", "0.610002", "0.6052477", "0.60170853", "0.6014367", "0.6007846", "0.5994656", "0.59869766", "0.5974065", "0.5972064", "0.5942299", "0.59315133", "0.5925655", "0.5922561", "0.5915957", "0.5893687"...
0.8438237
0
Wrapper for OptionParser::make_switch to allow for required switches
def make_switch(opts, block = nil) # Test if a switch is required required = opts.delete(:required) return_values = pickled_make_switch(opts, block) # Make sure required switches are given if required short = return_values[1][0].nil? ? nil : "-#{return_values[1][0]}" long = return_values[2][0].nil? ? nil : "--#{return_values[2][0]}" if !(default_argv.include?(short) || default_argv.include?(long)) @missing_switches ||= [] # Should be placed in initialize if incorporated into Ruby proper # Ugly and hard to read, should figure out a prettier way of doing this @missing_switches << "Missing switch: #{short if !short.nil?}#{" or " if !short.nil? && !long.nil?}#{long if !long.nil?}" end end return return_values end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_switch(opts, block = nil)\n short, long, nolong, style, pattern, conv, not_pattern, not_conv, not_style = [], [], []\n ldesc, sdesc, desc, arg = [], [], []\n default_style = Switch::NoArgument\n default_pattern = nil\n klass = nil\n q, a = nil\n has_arg = false\n\n opts.each do |o|...
[ "0.7106335", "0.66314226", "0.63676155", "0.6356591", "0.6319967", "0.6226244", "0.6107747", "0.594925", "0.59243083", "0.59128886", "0.5761938", "0.573902", "0.5707391", "0.5636656", "0.5626769", "0.5619589", "0.5597715", "0.5506363", "0.54627615", "0.5454238", "0.5394043", ...
0.7906773
0
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) array = [] array = name_hash.collect { |key, value| value } array.sort! array = name_hash.collect { |key, value| value == array.first ? key : nil } array.find { |item| item != nil } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.88215435", "0.8777964", "0.8777547", "0.87461567", "0.868959", "0.865596", "0.8652915", "0.8617178", "0.8587992", "0.85718757", "0.8567488", "0.85516495", "0.8529784", "0.8529784", "0.8518652", "0.8493093", "0.8475329", "0.8475329", "0.84659123", "0.8448963", "0.844864", ...
0.0
-1
Returns the Pearson correlation coefficient for p1 and p2
def sim_pearson( prefs, p1, p2) # Get the list of mutually rated items si = {} for item in prefs[p1].keys si[item] = 1 if prefs[p2].include? item end # Find the number of elements n = si.length puts n # If there are no ratings in common, return 0 return 0 if n == 0 # Add up all the preferences sum1 = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] } sum2 = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] } puts "sum1 #{sum1}" puts "sum2 #{sum2}" # Sum up the squares sum1Sq = si.keys.inject(0) { |sum,value| sum += prefs[p1][value] ** 2 } sum2Sq = si.keys.inject(0) { |sum,value| sum += prefs[p2][value] ** 2 } # Sum up the products pSum = si.keys.inject(0) { |sum,value| sum += (prefs[p1][value] * prefs[p2][value])} puts "pSum #{pSum}" # Calculate the Pearson score num = pSum - (sum1*sum2/n) puts "num #{num}" den = Math.sqrt((sum1Sq - (sum1 ** 2)/n) * (sum2Sq - (sum2 ** 2)/n)) puts "den #{den}" return 0 if den == 0 r = num / den end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pearson(v1,v2)\n v1a,v2a=Statsample.only_valid_clone(v1,v2)\n return nil if v1a.size ==0\n if Statsample.has_gsl?\n GSL::Stats::correlation(v1a.to_gsl, v2a.to_gsl)\n else\n pearson_slow(v1a,v2a)\n end\n end", "def pearson x, y\n\txbar, ybar = x.reduce...
[ "0.75894415", "0.7104931", "0.68175733", "0.6656453", "0.6395304", "0.6372642", "0.627266", "0.61372995", "0.59260774", "0.5779789", "0.5698323", "0.568836", "0.5669646", "0.5526602", "0.53528136", "0.5314602", "0.51679915", "0.5163969", "0.512641", "0.5065346", "0.5033453", ...
0.5994895
8
Ranking the critics TODO lacks the scorefunctionasparamter aspect of original.
def topMatches( prefs, person, n=5, scorefunc = :sim_pearson ) scores = [] for other in prefs.keys if scorefunc == :sim_pearson scores << [ sim_pearson(prefs,person,other), other] if other != person else scores << [sim_distance(prefs,person,other), other] if other != person end end return scores.sort.reverse.slice(0,n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def army_rank; end", "def coast_guard_rank; end", "def rank_precedence() = RANKS_SCORES[self.rank]", "def rank; end", "def rank; end", "def calc_rank\n return (self.score * 20001) + self.speaks;\n end", "def navy_rank; end", "def calc_ranking\n ranked = Set.new # Variables to reify (...
[ "0.690859", "0.68162215", "0.6675271", "0.6641978", "0.6641978", "0.6626971", "0.65653944", "0.6545263", "0.6497229", "0.6389432", "0.6332983", "0.6332983", "0.6309176", "0.6299042", "0.6260107", "0.6220353", "0.62186444", "0.6206703", "0.6159537", "0.6133324", "0.61007375", ...
0.58627325
39
Gets recommendations for a person by using a wieghted average of every other user's rankings uses sim_pearson only
def getRecommendations( prefs, person, scorefunc = :sim_pearson ) totals = {} simSums = {} for other in prefs.keys # don't compare me to myself next if other == person if scorefunc == :sim_pearson sim = sim_pearson( prefs, person, other ) else sim = sim_pearson( prefs, person, other ) end puts "rec sim val: #{sim}" #ignore scores of zero or lower next if sim <= 0 for item in prefs[other].keys # only score movies I haven't seen yet if !prefs[person].include? item or prefs[person][item] == 0 # similarity * score totals.default = 0 totals[item] += prefs[other][item] * sim # sum of similarities simSums.default = 0 simSums[item] += sim end end end # create a normalised list rankings = [] totals.each do |item,total| rankings << [total/simSums[item], item] end # Return the sorted list return rankings.sort.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRecommendations(prefs, person, scorefunc = :sim_pearson )\n totals = {}\n simSums = {}\n for other in prefs.keys\n # don't compare me to myself\n next if other == person\n\n if scorefunc == :sim_pearson\n sim = sim_pearson( prefs, person, other)\n else\n sim = sim_...
[ "0.6991422", "0.69263554", "0.6664773", "0.6481484", "0.64040965", "0.62665015", "0.6218784", "0.60484815", "0.6026915", "0.60092866", "0.60069346", "0.59365696", "0.59244215", "0.59199107", "0.5895304", "0.5887364", "0.5802603", "0.5760123", "0.57487303", "0.5742281", "0.567...
0.7043448
0
source: This algorithm was created by Landon Kryger to solve the problem of testing if a set of dice is fair. If you have n players and s sides, the standard approach would require you to test every roll and would run in O(s^n). This algorithm runs in approximately O(snn!). For small s,n, it's not a very noticeable difference, but for large values like n=5;s=30 the benefit is huge. This algorithm also works with dice with different number of sides. The input can be either a string, e.g. state = 'abcddbaccbadcabddacbdbcadcbadcabbcaddacbbacdabcdacbdbcaddbacdabccabddcba' or an array of characters, e.g. state = ['0', '1', '1', '0'] The output, count, will contain how many ways each substring can occur.
def counts(state) counts = {'' => 1} state = state.split("") if state.kind_of?(String) state.each do |char| counts.keys.each do |key| if key.count(char) == 0 key_char = key + char counts[key_char] = (counts[key_char] || 0) + counts[key] end end end counts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def countingValleys(n, s)\n # check constraints\n # do steps match string length\n n_does_not_equal_s_length = n != s.scan(/[UD]/).count\n steps_are_invalid = n < 2 && n > 10**6\n\n returned_to_sea_level_count = 0\n sea_level = 0\n\n if (steps_are_invalid || n_does_not_equal_s_length)\n return 0\n end\n...
[ "0.684635", "0.6608983", "0.6588201", "0.6485433", "0.6435639", "0.64073086", "0.62390244", "0.61810786", "0.61759895", "0.6123667", "0.61217266", "0.6070245", "0.6038976", "0.6020436", "0.598535", "0.59503984", "0.59415495", "0.59283185", "0.59206885", "0.5869518", "0.585534...
0.5794759
31
counts_by_length takes counts hash as input and generates another hash, where the keys are the lengths of substrings (as a string), and the values are arrays containing the number of appearances.
def counts_by_length(counts) counts_by_length = {} counts.each do |key, value| l = key.length.to_s if counts_by_length.has_key?(l) counts_by_length[l] << value else counts_by_length[l] = [value] end end counts_by_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def length_finder(words)\n lengths = {}\n words.each do |word|\n lengths[word] = word.length\n end\n lengths.values\nend", "def word_sizes(words)\n length_arr = []\n hash_words = {}\n words.gsub(/[^[:word:]\\s]/, '').split(' ').each do |word| \n length_arr << word.length\n end\n length_arr.uniq.ea...
[ "0.68282866", "0.6705068", "0.66054076", "0.65641004", "0.6474005", "0.64435613", "0.64107734", "0.6398544", "0.63863635", "0.638351", "0.63834137", "0.637002", "0.6347228", "0.63283277", "0.6306427", "0.6286599", "0.6224484", "0.62089884", "0.620613", "0.6183934", "0.6178028...
0.8085512
0
short_circuit_check is similar to counts_by_length but it does comparison as it builts the hash the comparison is stopped once the check result is clear
def short_circuit_check(counts) counts_by_length = {} counts.each do |key, value| l = key.length.to_s if counts_by_length.has_key?(l) if counts_by_length[l][0] != value return false else counts_by_length[l][1] += 1 end else counts_by_length[l] = [value, 1] end end complete?(counts_by_length) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete?(counts_by_length)\n num_players = counts_by_length['1'][1]\n counts_by_length.each do |key, value|\n l = key.to_i\n if l > 1\n num_perms = 1\n l.times do |index|\n num_perms *= (num_players - index)\n end\n return false if num_perms != counts_by_length[key][1]\n ...
[ "0.60192484", "0.5814405", "0.564393", "0.5636694", "0.5578881", "0.55409706", "0.5539765", "0.54885304", "0.5465793", "0.5460929", "0.54466486", "0.54205924", "0.5405991", "0.5405991", "0.5405991", "0.5374539", "0.5372885", "0.5371269", "0.53646654", "0.5350986", "0.5336949"...
0.820483
0
check if counts_by_length is complete
def complete?(counts_by_length) num_players = counts_by_length['1'][1] counts_by_length.each do |key, value| l = key.to_i if l > 1 num_perms = 1 l.times do |index| num_perms *= (num_players - index) end return false if num_perms != counts_by_length[key][1] end end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def short_circuit_check(counts)\n counts_by_length = {}\n\n counts.each do |key, value|\n l = key.length.to_s\n if counts_by_length.has_key?(l)\n if counts_by_length[l][0] != value\n return false \n else\n counts_by_length[l][1] += 1\n end\n else\n counts_by_length[l] =...
[ "0.7159641", "0.6795858", "0.6679854", "0.6658281", "0.66254085", "0.6604647", "0.64624006", "0.6386218", "0.6386218", "0.6386218", "0.6386218", "0.6374855", "0.6361468", "0.62993425", "0.6291191", "0.62612695", "0.6213323", "0.6195204", "0.6195204", "0.61934996", "0.61859185...
0.7250031
0
Use callbacks to share common setup or constraints between actions.
def set_global_user @global_user = GlobalUser.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def global_user_params params.require(:global_user).permit(:manager, :manager_id, :user_dept, :dept_manager, :dispatch, :holiday_bird_caps, :master_user, :order_input, :pricing, :prospects, :rapid_order, :refusals, :short_term_trucks, :take_in, :temp_hire, :truck_monitoring, :hardware, :campaign_rep1, :campaign_rep2, :campaigns, :campaigns_admin, :cod, :cod_role, :campaign_role, :campaign_manager, :focus_items, :focus_items_rep1, :focus_items_rep2, :focus_items_role, :focus_items_manager, :retail_order_input, :retail_rapid_order, :retail_order_input_rep1, :retail_order_input_rep2, :retail_rapid_order_role, :complaints, :complaints_role, :complaints_dc) 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
Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope) new_admin_session_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_sign_out_path_for(resource_or_scope)\n '/signed_out'\n end", "def after_sign_out_path_for(_resource_or_scope)\n '/'\n end", "def after_sign_out_path_for(resource_or_scope); end", "def signout_url\n {:controller => 'auth', :action => 'signout'}\n end", "def after_sign_out_path_for(reso...
[ "0.8102037", "0.8007481", "0.7984188", "0.79324496", "0.7897868", "0.78892565", "0.7874593", "0.78685254", "0.7857867", "0.78436327", "0.78436327", "0.78436327", "0.78436327", "0.7842701", "0.7821579", "0.77880424", "0.7748489", "0.77373666", "0.7731692", "0.77291566", "0.772...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_flowdef @flowdef = Flowdef.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
note: this quickanddirty parsing leaves us with the data in y/x coordinates rather than x/y. Keep this in mind. :)
def tally_trees( slope ) pos = Coordinates.new( 0, 0 ) tally = 0 pos.x = ( pos.x + slope.x ) % @matrix[0].count pos.y = pos.y + slope.y while pos.y < @matrix.count do tally = tally + 1 if @matrix[pos.y][pos.x] == "\#" pos.x = ( pos.x + slope.x ) % @matrix[0].count pos.y = pos.y + slope.y end return tally end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input_parse(input)\n list_coords = []\n height = 0\n xMin, xMax, yMin = [500, 0, 500]\n input.split(\"\\n\").each do |com_coords|\n if com_coords[0]=='x'\n x_raw, y_raw = com_coords.split(\",\")\n x = x_raw.delete(\"^0-9\").to_i\n xMin, xMax = [[xMin, x].min, [xMax, x].max]\n y_min, ...
[ "0.6731602", "0.65340585", "0.6228304", "0.61461437", "0.61038715", "0.6054457", "0.59944683", "0.5959736", "0.5954485", "0.59362435", "0.58552074", "0.58502394", "0.5849467", "0.58485097", "0.58484674", "0.5834266", "0.58264166", "0.58180034", "0.5801265", "0.5786077", "0.56...
0.0
-1
Escape single quotes, remove newline, split on tabs, wrap each item in quotes, and join with commas
def prepare_for_insert(s) s.gsub(/'/,"\\\\'").chomp.split(/\t/).map {|str| "'#{str}'"}.join(", ") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_csv\n map {|row|\n row.map {|f|\n f =~ /[[:punct:]]/ ? '\"' + f.gsub(/\"/, '\"\"') + '\"' : f }.\n join(\",\")}.\n join(\"\\n\")\n end", "def csv_multi_replacements\n [\n [/\\n\\n/ , \"\\n\"]\n ]\n end", "def escape_for_csv(str)\n str.include?(',') ? add_double_quot...
[ "0.6540647", "0.62299854", "0.62273955", "0.6123004", "0.60439557", "0.6022842", "0.5892201", "0.5805178", "0.57960224", "0.57826674", "0.5633326", "0.56082076", "0.55652905", "0.5546583", "0.5517654", "0.549291", "0.5452453", "0.5424162", "0.5414239", "0.5411293", "0.5365037...
0.55607986
13
Attempts to log the user in, creates a new session If login attempt is successful, set user in session and redirect to user_homeindex If not successful, kick back to /login and display error
def create user = User.find_by_username(user_login_params[:username]) if user and user.authenticate(user_login_params[:password]) session[:current_user_key] = user.key redirect_to '/home' else redirect_to login_url, alert: "Invalid user/password combination" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n user = User.find_by(username: params[:session][:username])\n\n if user && user.authenticate(params[:session][:password])\n # Log the user in\n log_in user\n user.update_attribute(:is_login, true)\n redirect_to index_path\n else\n # Using render in case any error flash...
[ "0.7768877", "0.77146", "0.7703834", "0.75671303", "0.7548197", "0.753731", "0.753731", "0.75142854", "0.74666554", "0.74396724", "0.7395939", "0.7389997", "0.73797965", "0.73612833", "0.7356513", "0.73490715", "0.73417276", "0.7331857", "0.7320191", "0.73147863", "0.7310536"...
0.731647
19
Logs out the user
def destroy session.delete(:current_user_key) redirect_to welcome_index_path, alert: "Logged out." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_out\n\t\t# current_user.delete_auth_token # won't work with curl, but html is good\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_out\n reset_session\n @current_user = nil\n end", "def log_out\n\t\tsession.delete(:user_id)\n\t\t@current_user = nil\n\tend", "def log_ou...
[ "0.86802506", "0.86800635", "0.8676711", "0.8676711", "0.8676711", "0.8676711", "0.867611", "0.86037326", "0.86012846", "0.8592121", "0.8592121", "0.8592121", "0.8592121", "0.8592121", "0.85710555", "0.8560465", "0.85463935", "0.8543438", "0.85410494", "0.85408753", "0.854087...
0.0
-1
Whitelist for user login parameters
def user_login_params params.permit(:username, :password) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :t...
[ "0.70640767", "0.7019153", "0.7005046", "0.67017156", "0.66738164", "0.6460137", "0.64267594", "0.640785", "0.63886124", "0.63816863", "0.6336889", "0.6334745", "0.6329563", "0.63078976", "0.6278103", "0.6277226", "0.62734133", "0.62715596", "0.6265148", "0.6239603", "0.62238...
0.64515394
6
GET /auth_properties GET /auth_properties.json
def index @auth_properties = AuthProperty.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def get_property( propname )...
[ "0.80248255", "0.6984377", "0.6936408", "0.6901678", "0.68921906", "0.6604292", "0.65807223", "0.6557547", "0.655344", "0.64932954", "0.6402689", "0.6352764", "0.6323409", "0.6283516", "0.6257075", "0.6247004", "0.62343067", "0.6204378", "0.61678505", "0.6162262", "0.61421895...
0.75055593
1
GET /auth_properties/1 GET /auth_properties/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_properties()\n resp = conn.get('/users/'+name+'/props/')\n \n case resp.code.to_i\n when 200\n return JSON.parse(resp.body)\n when 404\n raise RestAuthUserNotFound.new( resp )\n else\n raise RestAuthUnknownStatus.new( rest )\n end\n end", "def index\n @auth_propert...
[ "0.7909022", "0.74378896", "0.7308449", "0.704606", "0.6856806", "0.677006", "0.6751695", "0.6745252", "0.66370744", "0.65402", "0.6507988", "0.6502517", "0.6467627", "0.6337173", "0.63112265", "0.6310055", "0.630863", "0.6301934", "0.628738", "0.6256664", "0.6229946", "0.6...
0.0
-1
POST /auth_properties POST /auth_properties.json
def create @auth_property = AuthProperty.new(auth_property_params) @token.authProperties << @auth_property respond_to do |format| if @auth_property.save format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully created.' } format.json { render :show, status: :created, location: @auth_property } else format.html { render :new } format.json { render json: @auth_property.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_property_params\n params.require(:auth_property).permit(:key, :txtValue, :numValue, :token)\n end", "def create_property( propname, value )\n params = { 'prop' => propname, 'value' => value }\n resp = conn.post( '/users/'+name+'/props/', params )\n \n case resp.code.to_i\n when 20...
[ "0.71893424", "0.64241874", "0.6403528", "0.62121916", "0.61966485", "0.6188421", "0.6187812", "0.6144945", "0.610698", "0.6106747", "0.6086319", "0.6076893", "0.60689944", "0.6041595", "0.604103", "0.60404426", "0.59903556", "0.5968608", "0.5943977", "0.5919014", "0.5886966"...
0.71722054
1
PATCH/PUT /auth_properties/1 PATCH/PUT /auth_properties/1.json
def update respond_to do |format| if @auth_property.update(auth_property_params) format.html { redirect_to [@owner, @token, @auth_property], notice: 'Auth property was successfully updated.' } format.json { render :show, status: :ok, location: @auth_property } else format.html { render :edit } format.json { render json: @auth_property.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def set_property( propname, value )\n params = { 'value' => value }\n resp = conn.put('/users/'+name+'...
[ "0.65150845", "0.6458099", "0.640293", "0.6400613", "0.6400613", "0.6400613", "0.6400613", "0.6400613", "0.63936716", "0.63407576", "0.6278915", "0.62030935", "0.6201829", "0.6122758", "0.60915357", "0.6067378", "0.6001033", "0.59925795", "0.5991794", "0.5990218", "0.59744406...
0.7076053
0
DELETE /auth_properties/1 DELETE /auth_properties/1.json
def destroy @auth_property.destroy respond_to do |format| format.html { redirect_to owner_token_auth_properties_path [@owner, @token], notice: 'Auth property was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def del_property( propname )\n resp = conn.delete('/users/'+name+'/props/'+propname+'/')\n \n case resp.code.to_i\n when 204\n return\n when 404\n case resp.header['resource-type']\n when 'user'\n raise RestAuthUserNotFound.new( resp )\n when 'property'\n raise Rest...
[ "0.7440488", "0.7127522", "0.70492405", "0.7034347", "0.69556034", "0.69556034", "0.6921843", "0.6912386", "0.6906535", "0.6901997", "0.6879539", "0.68787664", "0.6842096", "0.6842096", "0.6839829", "0.6839829", "0.68157214", "0.6814176", "0.68130285", "0.6790191", "0.6787141...
0.7467164
0
Use callbacks to share common setup or constraints between actions.
def set_auth_property @auth_property = AuthProperty.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 auth_property_params params.require(:auth_property).permit(:key, :txtValue, :numValue, :token) 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.6980957", "0.6783065", "0.6747844", "0.6741468", "0.67356336", "0.6592548", "0.65036845", "0.64978707", "0.64825076", "0.64795035", "0.64560914", "0.64397955", "0.6379666", "0.6376688", "0.6366702", "0.6319728", "0.6300833", "0.6300629", "0.6294277", "0.6293905", "0.629117...
0.0
-1
Write a program that solicits 6 numbers from the user, then prints a message that describes whether or not the 6th number appears amongs the first 5 numbers.
def compare(num1, num2, num3, num4, num5, num6) num_array = [num1, num2, num3, num4, num5] if num_array.include?(num6) p "The number #{num6} appears in #{num_array}" else p "The number #{num6} does not appear in #{num_array}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_problem()\n\n\tcount = 10\n\twhile count > 0\n\t\tputs \"you have #{count} times you can do this!\"\n\n\t\tputs \"Please enter a number that is a multiple of 3 or 5, 1-100 for a phrase or word back!\"\n\t\tnumber = gets.chomp\n\n\t\tmult_of_three = [\"3\", \"6\", \"9\", \"12\", \"18\", \"21\", \"24\", \...
[ "0.6842517", "0.6824047", "0.67023516", "0.64872897", "0.6443282", "0.64010066", "0.6394573", "0.63698477", "0.63668793", "0.6345415", "0.63336974", "0.63268435", "0.632397", "0.63175577", "0.6305798", "0.6277707", "0.6262173", "0.6256298", "0.62343603", "0.62290215", "0.6206...
0.67892206
2
Writes log_hash to, by default, currently set log file or custom file passed to it
def write_file(filename: @filename) raise 'Filename is not set, you need to initialize RSpecLog before writing' if filename.nil? RSpecLog.write_hash_to_file(RSpecLog.log_hash, filename) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_file\n @hash[\"LogFile\"]\n end", "def log_file\n @_log_file ||= begin\n log_file = ::File.new(log_path, 'a+')\n log_file.sync = true # Dumps the logs to disk immediately\n\n log_file\n end\n end", "def log_to(file)\n @log_file = file\n end", "def log...
[ "0.66926897", "0.6623391", "0.66177714", "0.65326667", "0.64954245", "0.6487172", "0.6454372", "0.63792247", "0.637706", "0.6352852", "0.6351051", "0.6331727", "0.6331727", "0.63139015", "0.63139015", "0.631353", "0.60908157", "0.6055892", "0.6046484", "0.60194176", "0.601470...
0.7050351
0
Its not generating the instances of associated classes from the rows
def test_find_includes # Old style products = Product.includes(:product_tariffs).all assert_equal(3, products.length) assert_equal(3, products.inject(0) {|sum, product| sum + product.product_tariffs.length}) # New style products = Product.includes(:product_tariffs) assert_equal(3, products.length) assert_equal(3, products.inject(0) {|sum, product| sum + product.product_tariffs.length}) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transpose_hbase_row_to_record_attributes_and_raw_data(row) # :nodoc:\n if field = attributes_schema[inheritance_attribute]\n if cell_with_record_sti_class = row.columns[field.unique_name] and cell_with_record_sti_class.present?\n if klass = field.decode(cell_with_record_sti_cla...
[ "0.6723646", "0.63869137", "0.634353", "0.63341016", "0.62597936", "0.62184864", "0.6139677", "0.6086968", "0.6084822", "0.60667866", "0.6006603", "0.5997283", "0.59431756", "0.5942243", "0.581694", "0.5765691", "0.5735786", "0.5722222", "0.5705314", "0.5681461", "0.56772625"...
0.0
-1
This overrides the Objectmethod method to return the mocked method when the mocked method is being requested. For methods that aren't being tested, this method returns a proc that will raise an error when called. This is to assure that only the mocked grpc method is being called.
def method(symbol) return @mock_method if symbol == @expected_symbol # The requested method is not being tested, raise if it called. proc do raise "The method #{symbol} was unexpectedly called during the " \ "test for #{@expected_symbol}." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_grpc_method(grpc_method_object)\n owner = grpc_method_object.owner\n\n return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)\n\n method, = owner.rpc_descs.find do |k, _|\n ::GRPC::GenericService.underscore(k.to_s) == grpc_method_...
[ "0.6446494", "0.6170767", "0.603632", "0.58104575", "0.57906324", "0.57888126", "0.5743578", "0.5743578", "0.5736099", "0.572942", "0.57138884", "0.56847304", "0.56567526", "0.5644068", "0.5631608", "0.5600883", "0.5585982", "0.5581288", "0.5580837", "0.55619633", "0.55441946...
0.613194
37
Since the ProQuest status report has many filters, we apply them all here.
def filter_proquest_status(theses) term_filtered = filter_theses_by_term theses dept_filtered = filter_theses_by_department term_filtered degree_filtered = filter_theses_by_degree_type dept_filtered multi_author_filtered = filter_theses_by_multiple_authors degree_filtered filter_theses_by_published multi_author_filtered end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter\n end", "def get_feed_filters\n filters = self.filters.to_h.reject{ |k, _v| PROHIBITED_FILTERS.include?(k.to_s) }\n filters.merge!({ 'report_status' => ['published'] }) if self.published\n filters\n end", "def postFetchFilter\n @filtered= Filter.new(@detail.waypoints)\n\n # ...
[ "0.62592906", "0.61782485", "0.61355776", "0.61026406", "0.60719156", "0.60378873", "0.59948856", "0.59870553", "0.59870553", "0.58553326", "0.5827876", "0.58108443", "0.5769749", "0.57685274", "0.57639503", "0.5695986", "0.5695155", "0.5632832", "0.5601328", "0.5580405", "0....
0.6502465
0
Determines if there is a conflict between authors' ProQuest optin.
def evaluate_proquest_status(thesis) proquest_status = thesis.authors.map(&:proquest_allowed).uniq return 'conflict' if proquest_status.length > 1 proquest_status.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_conflict?\n prefix == 'U'\n end", "def is_conflict?\n from_json\n (@order && @order.paid?).tap do |x|\n @error = true if x\n end\n end", "def merge_conflict?; end", "def check_version_conflict(other) # :nodoc:\n return if self.version == other.version\n\n ...
[ "0.6441109", "0.5956657", "0.583592", "0.578828", "0.57494783", "0.56846005", "0.55172384", "0.5475199", "0.54699", "0.5443352", "0.54129577", "0.5399809", "0.5393467", "0.5331197", "0.5324871", "0.53027874", "0.5294821", "0.52847314", "0.5275738", "0.52712935", "0.5270399", ...
0.5837913
2
Renders a friendly version of the thesis' ProQuest optin status for reports.
def render_proquest_status(thesis) status = evaluate_proquest_status(thesis) return 'Opt-in status not reconciled' if status == 'conflict' return 'No opt-in status selected' if status.nil? return 'Yes' if status == true return 'No' if status == false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_status(criterion, f, project, is_disabled)\n render(partial: 'status_chooser',\n locals: { f: f, project: project, is_disabled: is_disabled,\n criterion: Criteria[criterion] })\n end", "def pay_status_to_s\n if self.paid?\n %Q|<span style=\"color:green;\">#{se...
[ "0.58567435", "0.5784298", "0.57741016", "0.57447994", "0.56720454", "0.5654737", "0.55385166", "0.5510709", "0.54969966", "0.54466313", "0.5406813", "0.5391828", "0.53888786", "0.5383061", "0.5366101", "0.53650916", "0.5333901", "0.5333901", "0.5322467", "0.53190243", "0.530...
0.76040083
0
GET /partners/1 Shows a particular partner's page
def show @partner = Partner.find(params[:id]) # because you can review either a company or a partner, both company and partner are considered a reviewable. # each review belongs to this phantom reviewable object that is indeed a partner @reviewable = @partner @reviews = @reviewable.reviews @review = Review.new respond_to do |format| format.html # show.html.erb format.json { render json: @partner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n\t\t@partner = Partner.find(params[:id])\n\tend", "def index\n @partners = Partner.order(id: :desc).page(params[:page]).per(25)\n end", "def show\n @partner = Partner.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n end\n end", "def show\n @partne...
[ "0.75801116", "0.7450938", "0.7346493", "0.72480327", "0.72442114", "0.72284573", "0.7019085", "0.699739", "0.69663185", "0.67077", "0.6596621", "0.65813583", "0.6550096", "0.65385556", "0.65384877", "0.6514343", "0.6514343", "0.65006644", "0.64846575", "0.6443035", "0.641934...
0.6604026
10
GET /partners/1/edit Shows the edit page for a partner
def edit @partner = Partner.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n redirect_to edit_partner_url()\n end", "def update\n respond_to do |format|\n if @partner.update(partner_params)\n format.html { redirect_to [:admin, @partner], notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n f...
[ "0.732301", "0.71943516", "0.7008314", "0.69751185", "0.69623435", "0.69623435", "0.67821515", "0.67567277", "0.6735863", "0.67325735", "0.67162997", "0.67162997", "0.67014474", "0.6684075", "0.6663053", "0.66284734", "0.6620979", "0.66140807", "0.6533646", "0.6521306", "0.64...
0.8616317
0
POST /partners Creates a partner that belongs to a company
def create @partner = Partner.new(params[:partner]) @company = Company.find(params[:company_id]) @partner.company = @company @partner.save respond_to do |format| if @partner.save format.html { redirect_to @partner} format.json { render json: @partner, status: :created, location: @partner } else format.html { render action: "new" } format.json { render json: @partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @partner = Partner.new(partner_params)\n\n respond_to do |format|\n if @partner.save\n format.html { redirect_to @partner, notice: 'You are partnered up!' }\n format.json { render :show, status: :created, location: @partner }\n else\n format.html { render :new }\n ...
[ "0.7470335", "0.7422812", "0.7413604", "0.7409306", "0.7409306", "0.7398809", "0.7272806", "0.70434564", "0.70098275", "0.6808376", "0.67809975", "0.67753166", "0.67657083", "0.67507344", "0.66666055", "0.6655175", "0.6648353", "0.66167235", "0.6574595", "0.6573487", "0.65592...
0.8076154
0
PUT /partners/1 Updates a particular partner's information
def update @partner = Partner.find(params[:id]) respond_to do |format| if @partner.update_attributes(params[:partner]) format.html { redirect_to @partner } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @partner.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @partner = Partner.find(params[:id])\n\n respond_to do |format|\n if @partner.update_attributes(params[:partner])\n format.html { redirect_to @partner, notice: 'Partner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render ac...
[ "0.7806584", "0.7806584", "0.7683243", "0.7649199", "0.7616857", "0.7260612", "0.72279847", "0.72279847", "0.72263", "0.7210753", "0.70789826", "0.6987825", "0.69603235", "0.6947241", "0.69467074", "0.6937772", "0.6821978", "0.6802986", "0.67428565", "0.673897", "0.6645223", ...
0.7686307
2
numbers_to_add = Array.new numbers.size.times do |index| numbers_to_add += numbers[0..index] end numbers_to_add.reduce(:+) end alt w/ each_index
def sum_of_sums(numbers) numbers_to_add = Array.new numbers.each_index do |index| numbers_to_add += numbers[0..index] end numbers_to_add.reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_sums(numbers)\n sum = 0\n numbers.size.times do |idx|\n sum += numbers[0..idx].inject(:+)\n end\n \n sum\nend", "def sum_of_sums(numbers)\n (0...numbers.size).reduce(0) { |sum, idx| sum += numbers[0..idx].reduce(:+) }\nend", "def running_total(numbers)\n numbers.each.with_index do |num, i|...
[ "0.81808513", "0.78774333", "0.7760235", "0.7748967", "0.7743926", "0.7690278", "0.76890254", "0.7683565", "0.76275915", "0.7602756", "0.75839686", "0.7567747", "0.75182885", "0.7517349", "0.74515843", "0.74444443", "0.74389607", "0.7426572", "0.7415172", "0.7404755", "0.7395...
0.832987
0
This method is highly questionable, but folks generally refer to a host by its ip address(es), and thus, this makes tasks easier to code.
def name ip_address end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def local_ip_2_host (ip)\n\t\tputs \"Reverse DNS lookup from the local host repository\" if @verbose\n\t\tip=ip.strip unless ip.nil?\n\t\tif @known_hosts.key?(ip)\n\t\t\treturn @known_hosts[ip]\n\t\telse\n\t\t\treturn nil\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\t\treturn n...
[ "0.7512056", "0.7509218", "0.7114507", "0.6956967", "0.69539124", "0.68991584", "0.6895277", "0.6895277", "0.6853046", "0.6761145", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.6748335", "0.67390376", "0.6729594", ...
0.0
-1
Create a new Command Object from a valid XML representation xmlDoc = an xml document (REXML::Document) object
def create_from(xmlDoc) begin # Set the Type @attributes[:CMDTYPE] = xmlDoc.expanded_name.to_sym # Parse the XML object xmlDoc.each_element { |e| # For the OMLCONFIG tag, add the XML value to this Command Object if e.expanded_name.upcase.to_sym == :OMLCONFIG @attributes[e.expanded_name.upcase.to_sym] = e # For the other tags, add the text value to this Command Object else @attributes[e.expanded_name.upcase.to_sym] = e.text end } rescue Exception => ex raise "Failed to create new OmfCommandObject from XML" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_from_xml(xmlDoc)\r\n @type = xmlDoc.expanded_name\r\n xmlDoc.each_element(\"ID\") { |e| @procID = e.text }\r\n xmlDoc.each_element(\"GROUP\") { |e| @group = e.text }\r\n xmlDoc.each_element(\"PATH\") { |e| @path = e.text }\r\n xmlDoc.each_element(\"ARGSLINE\") { |e| @cmdLineArgs = e.text }\...
[ "0.6695541", "0.60271335", "0.60199404", "0.5854265", "0.58124804", "0.56513184", "0.5588628", "0.5556868", "0.55333805", "0.5444194", "0.5420735", "0.5406773", "0.53591406", "0.5357438", "0.53468853", "0.5336927", "0.5336927", "0.5329276", "0.53289604", "0.5321997", "0.52925...
0.8126857
0
Return a String representation of the XML tree describing this Command Object. [Return] a String
def to_s return serialize.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n\t\treturn self.stringify_nodes( @output )\n\tend", "def to_s\n return command\n end", "def to_s\n\t\t\"<Node:#{@e}>\"\n\tend", "def to_s\n msg = ''\n msg += \"Command: #{name}\\n\"\n options.each { |o| msg += \" \" + o.inspect + \"\\n\"}\n msg += \"\\n\"\n com...
[ "0.7047565", "0.7036944", "0.7012967", "0.70049274", "0.6947582", "0.691891", "0.68938714", "0.685215", "0.67929476", "0.67617565", "0.66980183", "0.66948986", "0.6688535", "0.66788656", "0.66088593", "0.65903175", "0.6566926", "0.65399456", "0.65243316", "0.6519443", "0.6516...
0.0
-1
check if user is the same as current_user
def is_current_user(user) if user == current_user return true else return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def current_user?(user)\r\n user == current_user\r\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(user)\n user == current_user\n end", "def current_user?(u...
[ "0.8396463", "0.8244885", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.82260275", "0.8221191", "0.8191692", "0.8173409", "0.81723726", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.8170972", "0.81709...
0.0
-1
get profile foto url
def get_profile_photo_url(photo) if photo != nil return photo.image.url(:thumb) else return 'user.png' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile_pic_url\n result_hash['pic']\n end", "def get_image_url( account_profile ) \n account_profile['profile_image_url']\n end", "def profile_pic_url\n json[\"entry_data\"][\"ProfilePage\"].first[\"graphql\"][\"user\"][\"profile_pic_url\"]\n end", "def image_url\n url_for(...
[ "0.81313115", "0.81181884", "0.8045249", "0.8007603", "0.7930503", "0.7916256", "0.778549", "0.77480817", "0.7669478", "0.76416874", "0.7639152", "0.75990206", "0.7592406", "0.75500304", "0.7539818", "0.748586", "0.7464137", "0.7419884", "0.7419884", "0.74030614", "0.7401696"...
0.7863667
6
def get_possesive_pronoun(gender) if gender == "Male" return "his" elsif gender == "Female" return "her" else return "his/her" end end get permission name
def get_permission_name(permission) case permission when Footprint32::PRIVATE return "Private" when Footprint32::FRIENDS return "Friends" else return "Public" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def possessive_pronoun\n return @gender.possessive\n end", "def genderToObjectivePronoun(gender)\n if gender == nil\n return '(unknown gender)'\n end #TODO: Raise exception if unknown detected\n\n if gender == :male || gender.downcase == 'male'\n return 'him'\n else\n return...
[ "0.7487196", "0.73661214", "0.7308786", "0.71863526", "0.7171797", "0.7058161", "0.7038999", "0.69493514", "0.69390285", "0.69042563", "0.6830248", "0.67770284", "0.67543596", "0.675428", "0.6709431", "0.6706902", "0.6705201", "0.67002004", "0.66957444", "0.66066825", "0.6518...
0.67403656
14
statistics helpers user with most reviews def top_reviewers User.order("reviews_count DESC").includes(:profile, :profile_photo).limit(8) end user with most popular reviews def popular_reviewers User.limit(5).sort_by(&:total_votes).reverse end most reviewed places def most_reviewed_places Place.order("reviews_count DESC").limit(8) end def most_reviewed_places_in_a_week Review.weekly_top_places.limit(8) end def top_reviewers_in_a_week Review.weekly_top_reviewers.limit(8) end most liked places def most_popular_places Place.order("favorite_places_count DESC").limit(8) end most visited places def most_visited_places Place.order("visited_places_count DESC").limit(5) end
def share_with_facebook_url(opts) # Generates an url that will 'share with Facebook', and can includes title, url, summary, images without need of OG data. # # URL generate will be like # http://www.facebook.com/sharer.php?s=100&p[title]=We also do cookies&p[url]=http://www.wealsodocookies.com&p[images][0]=http://www.wealsodocookies.com/images/logo.jpg&p[summary]=Super developer company # # For this you'll need to pass the options as # # { :url => "http://www.wealsodocookies.com", # :title => "We also do cookies", # :images => {0 => "http://imagelink"} # You can have multiple images here # :summary => "My summary here" # } url = "http://www.facebook.com/sharer.php?s=100" parameters = [] opts.each do |k,v| key = "p[#{k}]" if v.is_a? Hash v.each do |sk, sv| parameters << "#{key}[#{sk}]=#{sv}" end else parameters << "#{key}=#{v}" end end url + parameters.join("&") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def most_reviews\n @top_five = Taxi.most_review_answers(current_user, params)\n end", "def most_active\n @users_comments = User.joins(:comment).\n select('user.user_id, user.user_name, user.first_name, user.last_name, count(user.user_id) as count').\n group('user....
[ "0.703726", "0.70285344", "0.69861525", "0.67632675", "0.6682334", "0.653646", "0.65061045", "0.6502863", "0.6465595", "0.6440021", "0.64062035", "0.6382894", "0.6349223", "0.6342745", "0.63236666", "0.6306002", "0.6296857", "0.6264244", "0.6259934", "0.62400794", "0.6237936"...
0.0
-1
GET /projects GET /projects.json
def index @projects = current_user.projects end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def listprojects\n get('listprojects.json')['projects']\n end", "def list\n get 'projects'\n end", "def projects\n request(method: 'getAllProjects')\n end", "def projects\n resource 'projects'\n end", "def projects(params = {})\n make_get_request('/account/projects', params)\n e...
[ "0.8574897", "0.8386689", "0.8355737", "0.8062607", "0.80368364", "0.8002139", "0.78593457", "0.7834634", "0.78324", "0.7799698", "0.77792805", "0.7748103", "0.77139485", "0.7700251", "0.7696023", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", "0.7695487", ...
0.7026879
90
GET /projects/1 GET /projects/1.json
def show @new_page = Page.new({project: @project, name: generate_new_page_name}) @new_data_source = DataSource.new({project: @project}) @pages_list = @project.pages.map {|i| [i.id, i.name]} @data_sources = @project.data_sources.includes(:data_source_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n get 'projects'\n end", "def listprojects\n get('listprojects.json')['projects']\n end", "def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end", "def projects\n...
[ "0.78697544", "0.7698408", "0.7680339", "0.7613705", "0.75337136", "0.7525879", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.7493363", "0.74931365", "0.7483965", "0.74803555", "0.7446126", "0.7429718", "0.74231553", "0.7414986", "0.7385634"...
0.0
-1
POST /projects POST /projects.json
def create @project = current_user.projects.new(project_params) new_page = @project.pages.new({ name: generate_new_page_name}) @project.startpage = new_page @project.date_created = Time.now @project.last_modified = Time.now respond_to do |format| if @project.save format.html { redirect_to @project, notice: 'Project was successfully created.' } format.json { render action: 'show', status: :created, location: @project } else format.html { render action: 'new' } format.json { render json: @project.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new...
[ "0.7338948", "0.73139244", "0.7308003", "0.7299582", "0.7227503", "0.7225945", "0.71982473", "0.71170384", "0.7104803", "0.7095263", "0.7070636", "0.70408624", "0.70358187", "0.7024969", "0.70191896", "0.7009597", "0.698481", "0.697517", "0.6963753", "0.6963096", "0.6948756",...
0.0
-1
PATCH/PUT /projects/1 PATCH/PUT /projects/1.json
def update respond_to do |format| if @project.update(project_params) format.html { redirect_to @project } format.json { respond_with_bip(@project) } else format.html { render action: 'edit' } format.json { respond_with_bip(@project) } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n render json: { errors: @project.errors.messages }, status: 200\n end\n end", "def update\n authorize! :update, @project\n\n if @project.update(project_params)\n head :no_content\n else\...
[ "0.70004326", "0.69119745", "0.6911138", "0.6889052", "0.6888448", "0.6878091", "0.68675476", "0.6857582", "0.685334", "0.685334", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68503886", "0.68...
0.66752994
52
DELETE /projects/1 DELETE /projects/1.json
def destroy @project.destroy respond_to do |format| format.html { redirect_to projects_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pr...
[ "0.78951", "0.78593713", "0.7778056", "0.7771693", "0.77585995", "0.7730887", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77305084", "0.77244985", "0.7718401", "0.7718401", "0.7718401", "0.7718401", "0.7704753", "0.7704753", "0.7704753", "0.7704753", "0.7704753...
0.76495475
44
Use callbacks to share common setup or constraints between actions.
def set_project @project = Project.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.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def project_params params.require(:project).permit(:background_colour, :foreground_colour, :panel_colour, :text_colour, :name, :date_created, :startpage_id, :last_modified, :description, :private, :screensize_x, :screensize_y, :user_id, pages_attributes: [ :id, :name, :_destroy, panels_attributes:[ :id, :_destroy, :x, :y, :properties ] ]) 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
Never trust parameters from the scary internet, only allow the white list through.
def profile_params params.require(:profile).permit(:first_name, :last_name, :graduation_year, :major, :trainer_name, :gpa) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
thanks to Yanis Triandaphilov for the recommendation, sourced from his blog
def should_see(text) expect(page).to have_content(text) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def formation; end", "def terpene; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def anchored; end", "def suivre; end", "def stderrs; end", "def berlioz; end", "def verdi; end", "def intens...
[ "0.72850204", "0.6739374", "0.651189", "0.6334494", "0.6247382", "0.6218363", "0.6218363", "0.6218363", "0.6218363", "0.61617327", "0.61543614", "0.6097425", "0.60290647", "0.60123974", "0.60090643", "0.60081697", "0.6002864", "0.59991914", "0.59991914", "0.5987713", "0.59477...
0.0
-1
Use the Euclidean algorithm, but don't do it recursively because Ruby does not have TCO turned on by default.
def greatest_common_divisor(slice_dimension) width = slice_dimension[0] length = slice_dimension[1] while length != 0 remainder = width % length width = length length = remainder end width end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extended_euclidean_algorithm(a, b)\n s, old_s = 0, 1\n t, old_t = 1, 0\n r, old_r = b, a\n while r != 0\n quotient = old_r / r\n old_r, r = r, old_r - quotient * r\n old_s, s = s, old_s - quotient * s\n old_t, t = t, old_t - quotient * t\n end\n [old_r, old_s, old_t]\nend", "def euclidean_a...
[ "0.7206893", "0.7031616", "0.65744257", "0.6405042", "0.6133944", "0.60679626", "0.59150535", "0.5907035", "0.583164", "0.5831026", "0.58079976", "0.5768717", "0.57666224", "0.57657146", "0.5695695", "0.5643277", "0.5641509", "0.5627073", "0.5592513", "0.5559506", "0.54780376...
0.0
-1
removes any illegal email headers
def scrub_headers(headers) headers.select {|h| UserMailer.legal_headers.include? h} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_headers\n %w(return-receipt-to domainkey-signature dkim-signature)\n end", "def remove_delayed_message_header(headers)\n headers.reject { |k| k == \"x-delay\" }\n end", "def unrecognized_headers\n extra_headers = @transformed_headers - valid_headers\n extra_headers.each do |...
[ "0.72072834", "0.6434472", "0.6386203", "0.62259036", "0.6174803", "0.61696625", "0.6146202", "0.61338484", "0.6133599", "0.60211575", "0.59882176", "0.598217", "0.5978966", "0.59235716", "0.5904892", "0.58889586", "0.5876147", "0.5861512", "0.58470446", "0.58243954", "0.5808...
0.7699297
0
Produces and processes a report for use in the report method It takes the same arguments as report, and returns the same object as process_report
def produce_report(*args) # Check xcov availability, install it if needed `gem install xcov` unless xcov_available? unless xcov_available? puts "xcov is not available on this machine" return end require "xcov" require "fastlane_core" # Init Xcov config = FastlaneCore::Configuration.create(Xcov::Options.available_options, convert_options(args.first)) Xcov.config = config Xcov.ignore_handler = Xcov::IgnoreHandler.new # Init project report_json = nil manager = Xcov::Manager.new(config) if Xcov.config[:html_report] || Xcov.config[:markdown_report] || Xcov.config[:json_report] # Parse .xccoverage and create local report report_json = manager.run else # Parse .xccoverage report_json = manager.parse_xccoverage end # Map and process report process_report(Xcov::Report.map(report_json)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n @report = Report.new\n @report.plugin = self\n build_report\n rescue Exception => e\n @report.error e\n ensure\n return @report\n end", "def run_report(report)\n report.update! status: 'running'\n\n klass = report.name.constantize\n\n r = klass.new(report.para...
[ "0.7349697", "0.6893435", "0.6888932", "0.6838542", "0.6825587", "0.6707957", "0.6694205", "0.6666582", "0.6666582", "0.6665627", "0.6603604", "0.6603604", "0.6603604", "0.6603604", "0.6603604", "0.6582065", "0.6540434", "0.65082556", "0.6411238", "0.63838077", "0.6372985", ...
0.6175298
41
Outputs a processed report with Danger
def output_report(report) # Create markdown report_markdown = report.markdown_value # Send markdown markdown(report_markdown) # Notify failure if minimum coverage hasn't been reached threshold = Xcov.config[:minimum_coverage_percentage].to_i if !threshold.nil? && (report.coverage * 100) < threshold fail("Code coverage under minimum of #{threshold}%") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def report(output)\n end", "def write_report\n\n end", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def output_report\n\t\toutput_start\n\t\toutput_head\n\t\toutput_body_start\n\t\toutput_body\n\t\toutput_body_end\n\t\toutput_end\n\tend", "de...
[ "0.72368264", "0.69831306", "0.6944469", "0.6944469", "0.6944469", "0.6944469", "0.6944469", "0.6942214", "0.6897387", "0.68120337", "0.65397424", "0.6529683", "0.6332955", "0.6303936", "0.6303936", "0.6285366", "0.6285366", "0.61532116", "0.611859", "0.61098444", "0.61035913...
0.6046528
24
Aux methods Checks whether xcov is available
def xcov_available? `which xcov`.split("/").count > 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def requires_cvv?\n @require_cvv_set ||= false\n if @require_cvv_set\n @require_cvv\n else\n self.class.requires_cvv?\n end\n end", "def cv_required?\n true\n end", "def report_coverage?\n config.report || config.no_coverage.nil? && config.coverage && config.te...
[ "0.5605479", "0.54056245", "0.52924585", "0.5273659", "0.51426345", "0.5137662", "0.51306504", "0.50896734", "0.50566614", "0.5024072", "0.501453", "0.50029063", "0.49940974", "0.49840552", "0.49833414", "0.49811834", "0.49790093", "0.49727163", "0.49674454", "0.49608478", "0...
0.7875712
0
Filters the files that haven't been modified in the current PR
def process_report(report) file_names = @dangerfile.git.modified_files.map { |file| File.expand_path(file) } file_names += @dangerfile.git.added_files.map { |file| File.expand_path(file) } report.targets.each do |target| target.files = target.files.select { |file| file_names.include?(file.location) } end report end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_nonexistent(modified_files); end", "def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end", "def filter_directories(modified_files); end", "def filtered(files); end", "def filter_invalid_files\n real_files=[]\n @files.each do |file|\n if @edit_in_...
[ "0.8168486", "0.6880407", "0.6852783", "0.6840195", "0.6751749", "0.67396086", "0.67028654", "0.6681759", "0.6669902", "0.6655551", "0.6636062", "0.64798445", "0.64056295", "0.63902515", "0.63408", "0.6320563", "0.63030326", "0.6299882", "0.62707156", "0.6257452", "0.62491584...
0.0
-1
Processes the parameters passed to the plugin
def convert_options(options) converted_options = options.dup converted_options.delete(:verbose) converted_options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_parameters; end", "def process_params(args = {})\r\n args ||= {}\r\n end", "def process_parameters\n # Build and eval code to get option list. Using this yucky approach\n # because GetoptLong.new expects its parameters given individually;\n # I can't just build an array and pas...
[ "0.68187237", "0.67322344", "0.63737357", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6300978", "0.6266761", "0.6266761", "0.6266761", "0.6208381", "0.62000185", "0.6189266", "0.60950744", "0.60454273", "0.6038895", "0.6002505...
0.0
-1
GET /metodologias GET /metodologias.json
def index @metodologias = Metodologia.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @mesasredondas = Mesasredonda.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mesasredondas }\n end\n end", "def index\n \n if current_user.tipo == 2\n @receita_medicas = ReceitaMedica.where(:medico_id => current_user.id)\n ...
[ "0.6706839", "0.66338074", "0.6615272", "0.6520149", "0.647888", "0.6470972", "0.646249", "0.6455874", "0.6441236", "0.6434453", "0.641009", "0.6399384", "0.6352109", "0.6329938", "0.6324526", "0.63174987", "0.6297443", "0.62691504", "0.62597245", "0.6251404", "0.6240971", ...
0.7024599
0
GET /metodologias/1 GET /metodologias/1.json
def show @metodologia = Metodologia.friendly.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @logjuego = Logjuego.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @logjuego }\n end\n end", "def index\n @metodologias = Metodologia.all\n end", "def show\n @relogio = Relogio.find(params[:id])\n\n respond_to do...
[ "0.7023441", "0.68950266", "0.6876304", "0.68315804", "0.6711144", "0.67087495", "0.6616755", "0.66129297", "0.65941334", "0.647492", "0.64690983", "0.64596504", "0.64440084", "0.6426259", "0.64167756", "0.6416013", "0.6413856", "0.6367413", "0.6336719", "0.6316877", "0.63042...
0.0
-1
POST /metodologias POST /metodologias.json
def create @metodologia = Metodologia.new(metodologia_params) respond_to do |format| if @metodologia.save format.html { redirect_to @metodologia, notice: 'Metodologia was successfully created.' } format.json { render action: 'show', status: :created, location: @metodologia } else format.html { render action: 'new' } format.json { render json: @metodologia.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @metodo = Metodo.new(params[:metodo])\n\n respond_to do |format|\n if @metodo.save\n format.html { redirect_to metodos_url }\n format.json { render json: @metodo, status: :created, location: @metodo }\n else\n format.html { render action: \"new\" }\n format....
[ "0.67429745", "0.6460018", "0.6419304", "0.6323174", "0.6312466", "0.62000996", "0.6176149", "0.61474586", "0.614646", "0.6128271", "0.6125315", "0.6123741", "0.61165315", "0.6114368", "0.6101276", "0.6099468", "0.6087822", "0.6079654", "0.6068045", "0.6054051", "0.60446644",...
0.7096514
0
PATCH/PUT /metodologias/1 PATCH/PUT /metodologias/1.json
def update respond_to do |format| if @metodologia.update(metodologia_params) format.html { redirect_to @metodologia, notice: 'Metodologia was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @metodologia.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @metodo = Metodo.find(params[:id])\n\n respond_to do |format|\n if @metodo.update_attributes(params[:metodo])\n format.html { redirect_to metodos_url }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render...
[ "0.67807484", "0.63534105", "0.62647784", "0.6174062", "0.61529464", "0.6142683", "0.6128223", "0.6101664", "0.6094204", "0.6093889", "0.60876095", "0.6077678", "0.60763264", "0.60653436", "0.6057624", "0.60565454", "0.60504746", "0.60328144", "0.60276836", "0.60161614", "0.6...
0.6838462
0
DELETE /metodologias/1 DELETE /metodologias/1.json
def destroy @metodologia.destroy respond_to do |format| format.html { redirect_to metodologias_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @relogio = Relogio.find(params[:id])\n @relogio.destroy\n\n respond_to do |format|\n format.html { redirect_to relogios_url }\n format.json { head :ok }\n end\n end", "def destroy\n @metodo = Metodo.find(params[:id])\n @metodo.destroy\n\n respond_to do |format|\n ...
[ "0.7326798", "0.72428715", "0.7159269", "0.71088237", "0.69946104", "0.6892742", "0.68869674", "0.68810207", "0.6866423", "0.6851632", "0.68507266", "0.68432856", "0.683257", "0.6828975", "0.68283284", "0.6827685", "0.6827329", "0.68240404", "0.68222696", "0.6814585", "0.6812...
0.73762846
0
Use callbacks to share common setup or constraints between actions.
def set_metodologia @metodologia = Metodologia.friendly.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.5...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def metodologia_params params.require(:metodologia).permit(:name, :descripcion) 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
Use callbacks to share common setup or constraints between actions.
def set_formula_herb_action @formula_herb_action = FormulaHerbAction.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