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
This is customized because GENCAT
def participatory_processes @participatory_processes ||= filtered_processes.includes(attachments: :file_attachment) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def formation; end", "def probers; end", "def guct\n end", "def suivre; end", "def terpene; end", "def blg; end", "def schubert; end", "def custom; end", "def custom; end", "def verdi; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end",...
[ "0.7225691", "0.66720587", "0.64770335", "0.6476829", "0.64121234", "0.6375613", "0.63514936", "0.634799", "0.62883306", "0.62883306", "0.6268521", "0.6214126", "0.6214126", "0.6214126", "0.6214126", "0.6209637", "0.61696506", "0.6142058", "0.60313547", "0.6003933", "0.595940...
0.0
-1
This is customized because GENCAT
def participatory_process_groups @participatory_process_groups ||= Decidim::ParticipatoryProcesses::OrganizationParticipatoryProcessGroups.new(current_organization).query .where(id: filtered_processes.grouped.group_ids) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def formation; end", "def probers; end", "def guct\n end", "def suivre; end", "def terpene; end", "def blg; end", "def schubert; end", "def custom; end", "def custom; end", "def verdi; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end",...
[ "0.7225691", "0.66720587", "0.64770335", "0.6476829", "0.64121234", "0.6375613", "0.63514936", "0.634799", "0.62883306", "0.62883306", "0.6268521", "0.6214126", "0.6214126", "0.6214126", "0.6214126", "0.6209637", "0.61696506", "0.6142058", "0.60313547", "0.6003933", "0.595940...
0.0
-1
as a string. If there is no missing letter, the method should return nil. bonus: returns a string of all missing letters as a string. ex: find_missing_letter("ace") would return "bd", write your own test. split the string into an array each through and check the next char against the current if next char not in order then append to result array
def find_missing_letter(range) # result = [] # prev_char = "" # array = range.split("") # array.each do |char| # if prev_char.next != char # result << prev_char.next # end # prev_char = char # end # result first_letter = range[0] last_letter = range[-1] test_range = (first_letter..last_letter).to_a result = "" test_range.each do |letter| result += letter unless range.include?(letter) end result != "" ? result : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_missing_letter(string)\n if string.empty?\n missing_letters = (\"a\"..\"z\").to_a\n else\n alphabet = (\"a\"..\"z\").to_a\n missing_letters = alphabet[alphabet.index(string.split(\"\").first)..alphabet.index(string.split(\"\").last)]- string.split(\"\")\n end\n missing_letters.empty? ? nil : ...
[ "0.8343222", "0.819091", "0.77769184", "0.7709831", "0.76052773", "0.7605015", "0.7584002", "0.75720584", "0.7566565", "0.75613004", "0.74952155", "0.7481679", "0.746577", "0.7425209", "0.738644", "0.7382518", "0.73818976", "0.7340042", "0.7254415", "0.7247441", "0.7239824", ...
0.75941455
6
GET /advertisements GET /advertisements.json
def index @advertisements = Advertisement.all respond_to do |format| format.html # index.html.erb format.json { render json: @advertisements } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_to do |format|\n format.html\n format.json { render json: { advertisements: @advertisements } }\n end\n end", "def index\n @advertisements = Advertisement.where(merchant_id: params[:merchant_id])\n\n render json: @advertisements\n end", "def index\n @ad...
[ "0.7671461", "0.7202624", "0.7116933", "0.7116933", "0.682151", "0.68149704", "0.67937994", "0.6704052", "0.6591452", "0.64982456", "0.6447812", "0.63391554", "0.6260698", "0.6211911", "0.61962545", "0.61804163", "0.6179664", "0.61773366", "0.61773366", "0.61765516", "0.61475...
0.7539251
2
GET /advertisements/1 GET /advertisements/1.json
def show advertisement = nil consumer_page_view = @consumer.crumbs.map{ |crumb| crumb.beacon_id }.uniq.sample if consumer_page_view @sem3.products_field( "upc", Beacon.find(consumer_page_view).first_party_data.sample ) advertisement = @sem3.get_products end logger.debug "Advertisement : #{advertisement}" respond_to do |format| if advertisement format.html # show.html.erb format.json { render json: advertisement['results'].first } else format.html # show.html.erb format.json { render json: {"status" => "error"}, status: :not_found } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_to do |format|\n format.html\n format.json { render json: { advertisements: @advertisements } }\n end\n end", "def index\n @advertisements = Advertisement.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advertisements...
[ "0.7674561", "0.73763406", "0.73763406", "0.70393205", "0.6935458", "0.6935458", "0.6715051", "0.66931844", "0.661896", "0.65987253", "0.6579459", "0.6576351", "0.6520924", "0.64730126", "0.6456537", "0.6437107", "0.6414039", "0.63672954", "0.6350185", "0.6329816", "0.6291070...
0.60796714
33
GET /advertisements/new GET /advertisements/new.json
def new @advertisement = Advertisement.new respond_to do |format| format.html # new.html.erb format.json { render json: @advertisement } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @advertise = Advertise.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advertise }\n end\n end", "def new\n @advert = Advert.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advert }...
[ "0.76206595", "0.7297989", "0.72325534", "0.71533144", "0.7111669", "0.7000442", "0.69535595", "0.6822083", "0.6812474", "0.6812474", "0.6793023", "0.6746201", "0.6719198", "0.67072266", "0.6700006", "0.6695936", "0.66890997", "0.6650996", "0.6650996", "0.66219807", "0.660461...
0.72619087
4
POST /advertisements POST /advertisements.json
def create @advertisement = Advertisement.new(params[:advertisement]) respond_to do |format| if @advertisement.save format.html { redirect_to @advertisement, notice: 'Advertisement was successfully created.' } format.json { render json: @advertisement, status: :created, location: @advertisement } else format.html { render action: "new" } format.json { render json: @advertisement.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @advertise = Advertise.new(advertise_params)\n\n respond_to do |format|\n if @advertise.save\n format.html { redirect_to @advertise, notice: 'Advertise was successfully created.' }\n format.json { render :show, status: :created, location: @advertise }\n else\n form...
[ "0.68848366", "0.6881313", "0.64537203", "0.6451686", "0.64215386", "0.64215386", "0.63332886", "0.6313317", "0.62875354", "0.6259814", "0.6251439", "0.62460595", "0.62224966", "0.62224966", "0.6218263", "0.6211225", "0.6134877", "0.60934216", "0.6089346", "0.60785955", "0.60...
0.6430163
4
PUT /advertisements/1 PUT /advertisements/1.json
def update @advertisement = Advertisement.find(params[:id]) respond_to do |format| if @advertisement.update_attributes(params[:advertisement]) format.html { redirect_to @advertisement, notice: 'Advertisement was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @advertisement.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @advertise.update(advertise_params)\n format.html { redirect_to @advertise, notice: \"Advertise was successfully updated.\" }\n format.json { render :show, status: :ok, location: @advertise }\n else\n format.html { render :edit, status: :un...
[ "0.6978973", "0.692015", "0.6558807", "0.64093983", "0.6406906", "0.618249", "0.61492044", "0.6126311", "0.6126311", "0.6126311", "0.6111755", "0.6104872", "0.6038145", "0.6035168", "0.6035168", "0.6035168", "0.60293984", "0.5999683", "0.59949195", "0.599381", "0.5955715", ...
0.59350944
21
DELETE /advertisements/1 DELETE /advertisements/1.json
def destroy @advertisement = Advertisement.find(params[:id]) @advertisement.destroy respond_to do |format| format.html { redirect_to advertisements_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @advertise.destroy\n respond_to do |format|\n format.html { redirect_to advertises_url, notice: 'Advertise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @advertise.destroy\n respond_to do |format|\n format.html { redire...
[ "0.7651922", "0.7646948", "0.741282", "0.73541045", "0.73157495", "0.7311145", "0.71902347", "0.71623296", "0.7154859", "0.71490514", "0.7144615", "0.71437955", "0.71437955", "0.71137816", "0.7093831", "0.7093461", "0.7093461", "0.7093461", "0.7075143", "0.7047947", "0.703174...
0.736775
3
Run distances against datasets listed in metadata's +:dist_req+
def distances_by_request(metric) return unless dataset.metadata[:dist_req] $stderr.puts 'Running distances by request' dataset.metadata[:dist_req].each do |target| ds = ref_project.dataset(target) and send(metric, ds) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_dist(cli)\n p = cli.load_project\n %i[ani aai].each do |dist|\n res = p.result(\"#{dist}_distances\")\n next if res.nil?\n\n cli.say \"Checking #{dist} table for consistent datasets\"\n notok, fix = check_dist_eval(cli, p, res)\n check_dist_fix(cli, p, fix)\n check_dis...
[ "0.6014446", "0.59729105", "0.579879", "0.579879", "0.57411486", "0.5702526", "0.5352509", "0.53382516", "0.5336454", "0.5332691", "0.53043216", "0.52376676", "0.52144223", "0.5210712", "0.5202379", "0.5180323", "0.51697487", "0.51528037", "0.51419413", "0.5140173", "0.513841...
0.8088296
0
Builds a tree with all visited medoids from any classification level
def build_medoids_tree(metric) $stderr.puts "Building medoids tree (metric = #{metric})" db = query_db(metric) return unless File.size? db out_base = File.expand_path(dataset.name, home) ds_matrix = "#{out_base}.txt" ds_matrix_fh = File.open(ds_matrix, 'w') ds_matrix_fh.puts %w[a b value].join("\t") # Find all values in the database seq2 = [] foreach_in_db(db, metric) do |r| seq2 << r[0] ds_matrix_fh.puts r[0, 3].join("\t") end # Find all values among visited datasets in ref_project ref_r = ref_project.result("#{metric}_distances") or return Zlib::GzipReader.open(ref_r.file_path(:matrix)) do |fh| fh.each_line do |ln| r = ln.chomp.split("\t") next unless seq2.include?(r[1]) or seq2.include?(r[2]) ds_matrix_fh.puts r[1, 3].join("\t") end end ds_matrix_fh.close ref_tree = File.expand_path('utils/ref-tree.R', MiGA::MiGA.root_path) `"#{ref_tree}" "#{ds_matrix}" "#{out_base}" "#{dataset.name}"` File.unlink ds_matrix end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tree\n index = 0\n @ignore_list.each do |attribute|\n #puts \"Attribute: #{attribute}\"\n #puts \"Result: #{@max_result_array[index]}\"\n #puts \"Count: #{@max_class_count_array[index]}\"\n\n @max_class_count_array[index].each do |label, count|\n isLeaf = false\n r...
[ "0.686628", "0.63870203", "0.6285585", "0.6238042", "0.62215614", "0.6221035", "0.6182034", "0.61539394", "0.6019765", "0.5963613", "0.58705133", "0.5854121", "0.5821261", "0.58090204", "0.57919925", "0.578722", "0.5785339", "0.57389534", "0.5731139", "0.57135504", "0.5676343...
0.6260847
3
Transfer the taxonomy to the current dataset
def transfer_taxonomy(tax) $stderr.puts 'Transferring taxonomy' return if tax.nil? pval = (project.metadata[:tax_pvalue] || 0.05).to_f tax_a = tax .select { |i| i[1] != '?' && i[2] <= pval } .map { |i| i[0, 2].join(':') } dataset.metadata[:tax] = MiGA::Taxonomy.new(tax_a) dataset.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_indicate_taxonomy\n @indicate_taxonomy = Indicate::Taxonomy.find(params[:id])\n end", "def taxonomy(context)\n taxonomy_drop(context).taxonomy\n end", "def set_taxonomy\n c = case self.class.base_class.name\n when 'CollectionObject'\n a = current_taxon_name\n\n ...
[ "0.6211107", "0.61210275", "0.60703415", "0.5641416", "0.5640258", "0.5640258", "0.5596159", "0.5530919", "0.5463734", "0.5462066", "0.54161364", "0.53748494", "0.5367793", "0.53317016", "0.5306021", "0.52899534", "0.52686036", "0.5265831", "0.5253677", "0.52399653", "0.52148...
0.6942107
0
tablas de CRUDig funciones comunes
def ordenar_create( tabla, params ) order = '' if (params[:g_g] && (params[:g_g]==tabla)) (params[:g_o] && params[:g_o]!='') ? order = params[:g_o] : order = 'asc' (params[:g_f] && params[:g_f]!='') ? order = params[:g_f]+' '+order : order = '' else (params[:order] && params[:order]!='') ? order = params[:order] : order = 'asc' (params[:field] && params[:field]!='') ? order = params[:field]+' '+order : order = '' end #(order=='asc') ? order='desc' : order='asc' return ' ORDER BY '+order if (order != '') return '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def editar\n end", "def index\n self.validar_admin\n @inventarios = Inventario.all\n end", "def set_tabla\n @objeto = Tabla.find(params[:id])\n end", "def index\n @crud_municipios = CrudMunicipio.all\n end", "def index\n @tipo_funcionarios = TipoFuncionario.all\n end", "def _crud(...
[ "0.6436675", "0.6322331", "0.6315084", "0.6300498", "0.6237227", "0.62296414", "0.6210463", "0.6210463", "0.61749816", "0.615349", "0.61149585", "0.6107555", "0.6072892", "0.6063122", "0.6059731", "0.6029649", "0.6021682", "0.60033965", "0.59989977", "0.59905064", "0.59726995...
0.0
-1
=> buscamos la Key entre las FKs que apuntan a la tabla => return la columna de la tabla
def getCol_from_fk(tabla, claveFK) @aplicacion[:tablas][tabla]['columnas'].each {|key, value| if (value[:column_rel] && value[:column_rel].eql?(claveFK)) return key end } return '' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def essential_columns(model_class)\n model_class.reflect_on_all_associations.inject([@primary_key]) do |arr, assoc|\n if assoc.options[:dependent] && assoc.macro == :belongs_to\n arr << assoc.association_foreign_key\n end\n arr\n end\n end", "def key_columns\n ...
[ "0.70305985", "0.6934662", "0.6860085", "0.6801162", "0.67920816", "0.6746138", "0.67425704", "0.66787606", "0.6655856", "0.66209376", "0.66142535", "0.6610513", "0.6610513", "0.6595162", "0.658286", "0.6569761", "0.65458333", "0.6541611", "0.651242", "0.64937085", "0.6485629...
0.76632375
0
Si en :order viene en los parametros lo invertimos sino devolvemos siempre ASC
def set_order( params ) return 'desc' if (params[:order]=='asc') return 'asc' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort_direction\n # karakter kontrol yapiliyor security icin \n %w[asc desc].include?(params[:direction]) ? params[:direction] : \"asc\" \n end", "def sort_direction\n # karakter kontrol yapiliyor security icin \n %w[asc desc].include?(params[:direction]) ? params[:direction] : \"asc\" ...
[ "0.7538117", "0.7538117", "0.7538117", "0.7538117", "0.7538117", "0.7538117", "0.73701024", "0.729054", "0.724826", "0.71240824", "0.70787895", "0.70771384", "0.7031609", "0.70219976", "0.69541156", "0.68781275", "0.6877097", "0.6868974", "0.68656623", "0.6857382", "0.6857382...
0.7752323
0
Si en :order viene en los parametros lo invertimos sino devolvemos siempre ASC
def set_sub_grid_order( params ) return 'desc' if (params[:g_o]=='asc') return 'asc' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_order( params )\n return 'desc' if (params[:order]=='asc')\n return 'asc'\n end", "def sort_direction\n # karakter kontrol yapiliyor security icin \n %w[asc desc].include?(params[:direction]) ? params[:direction] : \"asc\" \n end", "def sort_direction\n # karakter kontrol yapiliyo...
[ "0.77514964", "0.75367886", "0.75367886", "0.75367886", "0.75367886", "0.75367886", "0.75367886", "0.7369766", "0.7290562", "0.7246361", "0.71222764", "0.70779127", "0.70770496", "0.70284855", "0.70206004", "0.6953256", "0.68783253", "0.68757725", "0.6869807", "0.68636024", "...
0.6593067
65
funciones de los CHARTS select salary, first_name from employees as emp inner join salaries as sala on emp.emp_no=sala.emp_no group by salary, first_name select count(title) as cantidades, titles.title as elementos from employees as emp inner join titles on emp.emp_no=titles.emp_no group by title SELECT departments.dept_name as elementos, count(employees.first_name) as cantidades FROM departments inner join dept_emp on departments.dept_no = dept_emp.dept_no inner join employees on employees.emp_no=dept_emp.emp_no GROUP BY departments.dept_name ORDER BY departments.dept_name
def testingCircle( params ) result = {} cantidad = params[:cantidades].split('.') elemento = params[:elementos].split('.') select = params[:elementos]+' as elementos, count('+params[:cantidades]+') as cantidades ' group_by = ' GROUP BY '+params[:elementos] ordenar_sql = ' ORDER BY '+params[:elementos] from = 'FROM '+make_form( elemento[0], cantidad[0], '' ) type_col_cantidades = @aplicacion[:tablas][cantidad[0]]['columnas'][cantidad[1]][:data_type] #if ('varchar'.eql?(type_col_cantidades) || 'char'.eql?(type_col_cantidades)) if ('int'.eql?(type_col_cantidades)) select = params[:elementos]+' as elementos, sum('+params[:cantidades]+') as cantidades ' end if (from != 'FROM ' && @conexion) #puts 'SELECT '+select+' '+from+' '+group_by+' '+ordenar_sql #result = @conexion.query('SELECT '+select+' '+from+' '+group_by+' '+ordenar_sql) #puts 'SELECT '+select+' '+from+' '+group_by+' '+ordenar_sql result = @conexion['SELECT '+select+' '+from+' '+group_by+' '+ordenar_sql] end return result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_character_names_and_number_of_books_they_are_in\n \"SELECT characters.name, COUNT(books.title)\n FROM characters\n JOIN character_books\n ON characters.id = character_books.character_id\n JOIN books\n ON books.id = character_books.book_id\n GROUP BY characters.name\n ORDER BY COU...
[ "0.59568244", "0.5948838", "0.5763102", "0.5753427", "0.5696337", "0.56681186", "0.56150657", "0.5605416", "0.5572776", "0.55337006", "0.54528964", "0.5427158", "0.5397447", "0.5387074", "0.53855616", "0.53821063", "0.5377702", "0.5370028", "0.5366083", "0.5349785", "0.534508...
0.55489564
9
We don't compare the sizes, because RSpec will add some classes that we don't care about...
def check_descendent_array clazz, expected actual = TypeUtils.descendents(clazz) expected.each {|c| actual.should include(c)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size\n specs.size\n end", "def test_size\n assert_equal(1, @root.size, \"Root's size should be 1\")\n setup_test_tree\n\n assert_equal(5, @root.size, \"Root's size should be 5\")\n assert_equal(2, @child3.size, \"Child 3's size should be 2\")\n end", "def test_file_size_diffe...
[ "0.6665844", "0.6473106", "0.6378862", "0.63026774", "0.62916136", "0.6287386", "0.6208231", "0.6196033", "0.61894614", "0.61816835", "0.6136922", "0.61112225", "0.6109822", "0.60631025", "0.6062682", "0.6062652", "0.60292006", "0.59741724", "0.59741724", "0.5971382", "0.5966...
0.0
-1
Make record an orphan by deleting its parent member. Since we use delete rather than destroy, member's child records should not be deleted.
def make_orphan(record) m = Member.find_by_id(record.member_id) m.delete if m record.reload end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orphan\n parent.disown self if parent\n @parent = nil\n end", "def orphan\n self[foreign_key_column] = 0\n self.save\n end", "def orphan_self_and_children\n self.class.transaction do\n orphan_children\n orphan\n end\n end", "def orphan_self_a...
[ "0.74852765", "0.66529375", "0.6562246", "0.6269693", "0.62692726", "0.6183468", "0.61821836", "0.61697876", "0.6165588", "0.61017454", "0.60970914", "0.6079622", "0.6068483", "0.60582846", "0.60120195", "0.5941644", "0.590946", "0.5889548", "0.5856497", "0.5709339", "0.56976...
0.7578648
0
Sets payment method as default on Stripe
def make_default! result = gateway.customer.update(customer.processor_id, default_payment_method_token: processor_id) raise Pay::Braintree::Error, result unless result.success? result.success? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_default!\n ::Stripe::Customer.update(customer.processor_id, {invoice_settings: {default_payment_method: processor_id}}, stripe_options)\n end", "def default_payment_method\n payment_methods.find { |payment_instrument| payment_instrument.default? }\n end", "def payment_method\n ...
[ "0.7564746", "0.7424524", "0.73193496", "0.73193496", "0.6966798", "0.69363505", "0.6818548", "0.67787534", "0.67312056", "0.6719104", "0.6668703", "0.6649052", "0.6620557", "0.6507257", "0.645748", "0.6454149", "0.6454149", "0.64396995", "0.63896215", "0.636981", "0.6295887"...
0.64011097
19
Utility methods Gets a given URL's response (following any redirects) Code tweaked from: AND: Parameters: url = URL to connect to max_redirects = Max number of redirects to follow (default = 6) timeout = Response timeout in seconds Returns the following: 1. Final URL (after following any redirects) 2. Response object 3. Parsed HTML response (from Nokogiri)
def url_response(url, max_redirects=6, timeout=7) response = nil parsed_page = nil seen = Set.new loop do url = URI.parse(url) break if seen.include? url.to_s break if seen.size > max_redirects seen.add(url.to_s) # initialize our http connection http = Net::HTTP.new(url.host, url.port) http.open_timeout = timeout http.read_timeout = timeout # Determine path to access # Treat an empty path as "/" path = (url.path.nil? or url.path.empty?) ? "/" : url.path # Append querystring to path if found path = path + "?" + url.query if !url.query.nil? # Initialize our HTTP request req = Net::HTTP::Get.new(path) # Handle HTTPS as needed if url.instance_of? URI::HTTPS http.use_ssl=true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end # Get back the response (i.e. actually perform request) response = http.request(req) if response.kind_of?(Net::HTTPRedirection) url = response['location'] parsed_page = nil elsif response.kind_of?(Net::HTTPSuccess) # Parse the HTML using Nokogiri parsed_page = Nokogiri::HTML(response.body) # Check for a <meta http-equiv="refresh"> type of redirect # If found, we will parse out the redirect URL and load it # NOTE: The following is a case insensitive XPATH search for <meta http-equiv="refresh"> # returning the value of the "content" attribute. meta_refresh = parsed_page.xpath("//meta[translate( @http-equiv, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz' ) = 'refresh' ]/@content").to_s # Attempt to parse out a URL="" from @content attribute if meta_refresh and result = meta_refresh.match(/URL=(.+)/i) # Found a redirect URL, we'll load that one next in our loop url = result.captures[0].gsub(/['"]/, '') parsed_page = nil else # Otherwise, we have a valid response & parsed page break end else # Else, response was an error (4xx or 5xx) break end end # return final URL response (after redirects) # AND the parsed page (from Nokogiri) return url, response, parsed_page end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response(uri, limit = 5)\n response = Net::HTTP.get_response(URI(uri))\n case response\n when Net::HTTPSuccess then\n response\n when Net::HTTPRedirection then\n location = response['location']\n get_response(location, limit - 1)\n else\n response.value\n end\nend", "def get_final_url(u...
[ "0.7163484", "0.70454776", "0.7043237", "0.7037283", "0.6894828", "0.6820514", "0.6820514", "0.6786093", "0.67844546", "0.67166764", "0.67166764", "0.6669712", "0.6669712", "0.6665687", "0.66245437", "0.66215193", "0.66007584", "0.6472299", "0.64491177", "0.6439345", "0.64368...
0.86533403
0
Get DSpace information (version, uitype, etc) from a given URL / parsed HTML page. This method takes in the output of url_response() and attempts to determine if this is a DSpace site or not. Parameters: url = URL of the (supposed) DSpace site parsed_page = HTML Response parsed by Nokogiri Returns the following: 1. DSpace Version info (or "UNKNOWN") 2. DSpace UI type (or "UNKNOWN")
def dspace_info(url, parsed_page) #------------------------- # Get DSpace Version Info #------------------------- # Check the parsed page's <meta name="Generator"> tag value) # This is the DSpace Version info # NOTE: The following is a case insensitive XPATH search for <meta name="generator"> # returning the value of the "content" attribute. generator = parsed_page.xpath("//meta[translate( @name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz' ) = 'generator' ]/@content").to_s # If generator with @content found, then this is the DSpace Version. # Otherwise, version is "UNKNOWN" (or possibly < 1.6.0 when this <meta> tag was added) version = (generator and !generator.empty?) ? generator : "UNKNOWN (possibly < 1.6.0)" #------------------------- # Get DSpace UI Type #------------------------- # Quick check. Does this URL include either "jspui" or "xmlui". # If so, let's trust the URL path is accurate if url.to_s.match(/\bjspui\b/i) ui_type = "JSPUI" elsif url.to_s.match(/\bxmlui\b/i) ui_type = "XMLUI" end # If URL match didn't work, we'll have to parse to determine UI type if ui_type.nil? or ui_type.empty? # To determine XML vs JSPUI we need to send a second request # Append "?XML" or "&XML" on original URL path to check if this is XMLUI xml_url = url.to_s.include?("?") ? url.to_s + "&XML" : url.to_s + "?XML" begin xml_url,response,parsed_xml_page = url_response(xml_url) rescue => e response = nil response_error = e end # If second response was successful if !response.nil? if response.kind_of?(Net::HTTPSuccess) # Try to parse this result as XML xml = Nokogiri::XML(response.body) # If the result is an XML document with a <document> root node, # Then this is definitely the XMLUI. if xml.root and xml.root.name == "document" ui_type = "XMLUI" # If our parsed version said this was DSpace, and it is NOT XMLUI, then it must be JSPUI elsif(version.include?("DSpace")) ui_type = "JSPUI" # Else if the response body includes the word "mydspace", this is definitely JSPUI elsif(response.body.match(/\bmydspace\b/i)) ui_type = "JSPUI" # Else if the response body includes the word "htmlmap", this is definitely JSPUI elsif(response.body.match(/\bhtmlmap\b/i)) ui_type = "JSPUI" # Else if none of the above match, but the response body includes the word "dspace" # it's *possibly* JSPUI (but no guarantees) elsif(response.body.match(/\bdspace\b/i)) ui_type = "JSPUI (possibly)" else # Otherwise, this really may not be a DSpace UI ui_type = "UNKNOWN (may not be DSpace)" end else # Else if response returned but not a "SUCCESS" ui_type = "RESPONSE FAILED: (#{response.code} #{response.message})" end else # Else if response was nil ui_type = "RESPONSE ERROR: (#{response_error})" end # End if ?XML response end # End if ui_type empty # Return parsed DSpace info return version, ui_type end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetchPage(url)\n Nokogiri::HTML(open(url, 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.152 Safari/535.19').read, nil, 'utf-8')\n end", "def visit_url(url)\n url_link = url\n begin\n linked_page = url_link.click\n rescue Excepti...
[ "0.58358526", "0.5818859", "0.5473012", "0.52615213", "0.5257803", "0.524651", "0.5232744", "0.52214617", "0.5165066", "0.51450235", "0.5086591", "0.50853395", "0.50853395", "0.50771624", "0.5074556", "0.5057889", "0.5052093", "0.50478536", "0.50478536", "0.504465", "0.501097...
0.78208727
0
Execute a specific command to acquire the exit code stderr, and raw data
def execute(cmd) captured_stdout = '' captured_stderr = '' exit_status = Open3.popen3(ENV, cmd) do |stdin, stdout, stderr, wait_thr| stdin.close captured_stdout = stdout.read captured_stderr = stderr.read wait_thr.value end [exit_status, captured_stdout, captured_stderr] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call(command)\n $log.debug(\"exec #{command}\")\n\n stdout, stderr, exit_status = Open3::capture3(ENV, command)\n $log.debug(\"stderr = #{stderr}\") if stderr\n $log.debug(\"stdout = #{stdout}\")\n $log.debug(\"exit status = #{exit_status}\")\n\n status = Status.from_plowshare(exit_status.exi...
[ "0.70583147", "0.69758534", "0.69353664", "0.680935", "0.6742753", "0.67330915", "0.6726129", "0.66874856", "0.66874856", "0.66532004", "0.66139555", "0.65990394", "0.65990394", "0.65990394", "0.65990394", "0.6590954", "0.6590257", "0.6580369", "0.6576773", "0.6569997", "0.65...
0.6723059
7
Use callbacks to share common setup or constraints between actions.
def set_order_item @order_item = OrderItem.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
take a number: gives "name" a "number" in line
def take_a_number(the_deli, name) the_deli << "#{name}" #names to be added into the_deli array puts "Welcome, #{name}. You are number #{the_deli.length} in line." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num\n name\n end", "def take_a_number(katz_deli, name)\n # add person to end of line\n katz_deli << name\n # call out (`puts`) the person's name along with their position in line\n puts \"Welcome, #{name}. You are number #{katz_deli.size} in line.\"\nend", "def take_a_number(deli, name)\n de...
[ "0.65389943", "0.64754903", "0.6464459", "0.64454347", "0.6438557", "0.63748974", "0.63555187", "0.6334456", "0.6275784", "0.6238477", "0.6220943", "0.61808383", "0.61358494", "0.61358494", "0.6130072", "0.6125467", "0.6120338", "0.6069747", "0.6038459", "0.6002342", "0.59359...
0.5986978
20
TODO: filter by resource type if system uses different resource types later
def index if params[:fromDate] == '' || params[:toDate] == '' flash[:alert] = 'Please choose the date range' return redirect_to upcoming_bookings_url end build_date_params @bookings = Booking.all( coworker_id: nil, resource_ids: [], options: { from_time: @from_time, to_time: @to_time } ).sort_by(&:from_time) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_type_filter\n return filter_for(:resource_type_id, \n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], _(\"Resource Type\"))\n end", "def resource_type_filter\n return filter_for(:resource_type_id,\n ...
[ "0.75654453", "0.74132526", "0.7187222", "0.6966026", "0.685138", "0.68013346", "0.67923766", "0.67795813", "0.6766436", "0.6766436", "0.6766436", "0.6766436", "0.6668854", "0.6653556", "0.663171", "0.6625173", "0.6625173", "0.6618369", "0.6604739", "0.6571398", "0.6552887", ...
0.0
-1
constantly alternates between these two loops
def buy_in_loop @entry_time = Time.now set_amount_and_check_balance loop do log_time_and_price set_and_log_indicator_ivars if lagging_indicators_green && leading_indicators_green set_buy_in break else @dc.prepend 'position_logs', "NOT BUYING IN YET ------------------------------------ <br /><br />" set_sleep_time #varies depending on state of indicators. end end manage_position_loop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def performs_sequential!()\n\n @m.times do |y|\n @n.times do |x|\n\n turn!(x, y)\n end\n end\n\n self\n end", "def loop!\n f, l = first, last\n first.prv = l\n last.nxt = f\n end", "def check_for_implication_loops\n # actually this is tricky\n end", "def...
[ "0.6231678", "0.59329766", "0.5930323", "0.58379114", "0.5811057", "0.5698566", "0.5648129", "0.5646934", "0.56390053", "0.5620709", "0.5593258", "0.55929995", "0.55867755", "0.5558013", "0.55525696", "0.55356276", "0.5533881", "0.55211794", "0.5496905", "0.5481098", "0.54757...
0.0
-1
widths 25, 50, 100 formats webp, original
def test_picture_files tested('auto rms.jpg') files = Dir.glob(temp_dir('generated' + '/*')) assert_equal(6, files.length) assert_includes stdout, 'Generating' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uml(picture_name, contents, width_slide, width_plain)\n new_width = calculate_width(width_plain)\n formats = %w(pdf eps)\n img_path = super(picture_name, contents, width_slide, width_plain, 'pdf')\n image(img_path, formats, '', '', new_width, new_width)\n end", "def uml(picture_name, c...
[ "0.56965244", "0.56241006", "0.56122464", "0.54735243", "0.5460694", "0.5460694", "0.5447592", "0.53227234", "0.5310752", "0.5271013", "0.52313244", "0.52006453", "0.519558", "0.4993038", "0.4976429", "0.4974337", "0.4974337", "0.4974337", "0.4974337", "0.4974337", "0.4974337...
0.0
-1
widths 25, 50, 100 formats webp, original
def test_picture_markup output = tested('auto rms.jpg') assert errors_ok? output sources = output.css('source') ss1 = '/generated/rms-25-c87b11253.webp 25w,' \ ' /generated/rms-50-c87b11253.webp 50w,' \ ' /generated/rms-100-c87b11253.webp 100w' assert_equal ss1, sources[0]['srcset'] assert_equal std_rms_ss, sources[1]['srcset'] assert_equal 'image/webp', sources[0]['type'] assert_equal 'image/jpeg', sources[1]['type'] assert_equal rms_url, output.at_css('img')['src'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uml(picture_name, contents, width_slide, width_plain)\n new_width = calculate_width(width_plain)\n formats = %w(pdf eps)\n img_path = super(picture_name, contents, width_slide, width_plain, 'pdf')\n image(img_path, formats, '', '', new_width, new_width)\n end", "def uml(picture_name, c...
[ "0.56964666", "0.56240404", "0.56118727", "0.54733765", "0.5460478", "0.5460478", "0.54472125", "0.53225136", "0.53105706", "0.5270903", "0.5231124", "0.52005523", "0.51955914", "0.49930593", "0.49762097", "0.49741358", "0.49741358", "0.49741358", "0.49741358", "0.49741358", ...
0.45380226
97
img with sizes attribute
def test_sizes output = tested('sizes rms.jpg') assert errors_ok? output assert_equal '(max-width: 600px) 80vw, 50%', output.at_css('img')['sizes'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def image_size(style = default_style)\n return nil if instance_read(:meta).nil? || instance_read(:meta).empty?\n \"#{width(style)}x#{height(style)}\"\n end", "def image_sizes\n { :small => 'x110',\n :medium => 'x208',\n :large => 'x413',\n :big => 'x654',\n ...
[ "0.7520836", "0.7360362", "0.724988", "0.7172528", "0.70751977", "0.7008975", "0.6905201", "0.6890874", "0.6789753", "0.6772769", "0.67674047", "0.67609435", "0.6746429", "0.67457914", "0.67315453", "0.67028576", "0.66869587", "0.6682386", "0.663354", "0.66269255", "0.6616964...
0.7231818
3
data_ output with sizes attr, yes datasizes
def test_data_img_yes_size output = tested('data_img_yes_size rms.jpg') assert errors_ok? output assert_equal '(max-width: 600px) 80vw, 50%', output.at_css('img')['data-sizes'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size ; data['size'] ; end", "def get_size(data)\n @horizontal_length = data[0].length\n @vertical_length = data.length\n end", "def size\n stats[:dataSize]\n end", "def size\n stats[:dataSize]\n end", "def size\n @data.size\n end", "def size\n @data.size\n end", "de...
[ "0.76078606", "0.7328655", "0.7306415", "0.7306415", "0.71286786", "0.71286786", "0.6887701", "0.6887701", "0.6887701", "0.6842166", "0.6828724", "0.68108106", "0.6805772", "0.6795957", "0.67811364", "0.673414", "0.6719803", "0.6694658", "0.6692248", "0.6686813", "0.66781837"...
0.0
-1
data_ output with sizes attr, no datasizes
def test_data_img_no_size output = tested('data_img_no_size rms.jpg') assert errors_ok? output assert_equal '(max-width: 600px) 80vw, 50%', output.at_css('img')['sizes'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size ; data['size'] ; end", "def get_size(data)\n @horizontal_length = data[0].length\n @vertical_length = data.length\n end", "def size\n stats[:dataSize]\n end", "def size\n stats[:dataSize]\n end", "def size\n @data.size\n end", "def size\n @data.size\n end", "de...
[ "0.73123187", "0.7034131", "0.69246083", "0.69246083", "0.68477607", "0.68477607", "0.6803036", "0.6740246", "0.66061413", "0.66039586", "0.66039586", "0.66039586", "0.6559971", "0.65096176", "0.6483793", "0.6466329", "0.6456414", "0.64278555", "0.641152", "0.639167", "0.6383...
0.0
-1
Ensure that attributes passed into the tag do not persist to other tags.
def test_attribute_persistence tested 'attributes rms.jpg --img class="goaway"' test_attributes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_attributes\n @attribute_changes = {}\n end", "def sanitized_allowed_attributes=(attributes); end", "def sanitized_allowed_attributes=(attributes); end", "def safe_attributes=(attrs, user=User.current)\n return unless attrs.is_a?(Hash)\n\n attrs = attrs.dup\n attrs = delete_unsafe_a...
[ "0.6329165", "0.6232465", "0.6232465", "0.62250835", "0.6173405", "0.6173405", "0.6170182", "0.61473346", "0.6085685", "0.6062724", "0.60559154", "0.60468197", "0.6035718", "0.6017482", "0.6011926", "0.5983391", "0.598302", "0.59792477", "0.59545505", "0.5952442", "0.5934745"...
0.0
-1
Ensure that when attributes are passed from both the argument and the preset, they all make it into the final output.
def test_combined_attributes output = tested 'attributes rms.jpg --img class="arg classes"' attrs = output.at_css('img')['class'].split assert_includes attrs, 'arg' assert_includes attrs, 'classes' assert_includes attrs, 'img' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_attributes_definitions_or_croak(attrArgs, &attrBlok)\n eye = :'m_attrs_defs'\n\n # Work with attribute as strings\n \n $DEBUG && logger_me(eye, logger_fmt_kls(:attrArgs => attrArgs, :attrBlok => attrBlok))\n\n mustbe_attributes_specification_or_croak(attrArgs, eye, \"attrArgs not attributes...
[ "0.58576226", "0.52793735", "0.52575773", "0.5203818", "0.51870185", "0.5125669", "0.5117332", "0.5110013", "0.5103362", "0.5088816", "0.50814444", "0.5061189", "0.5060868", "0.5054867", "0.5051679", "0.5051679", "0.5000203", "0.4977076", "0.49484178", "0.49476695", "0.493731...
0.49564713
18
fallback width and format
def test_fallback output = tested 'fallback rms.jpg' assert_match url_matcher(format: 'webp', width: 35), output.at_css('img')['src'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def width=(_); end", "def width=(_); end", "def fit_width; end", "def width=(_arg0); end", "def width; end", "def width; end", "def width; end", "def width; end", "def width; end", "def width; end", "def width; end", "def width; end", "def width; end", "def fw; self.fixed_width = true; ...
[ "0.6885236", "0.6885236", "0.6850314", "0.6584504", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6580705", "0.6513701", "0.6423407", "0.6402112", "0.6402112", "0.6366919", "0.6365824", "0.63242286", "0.62605226", ...
0.0
-1
Fallback is actually generated
def test_fallback_exists File.unstub :exist? tested 'fallback rms.jpg' files = Dir.glob(temp_dir('generated') + '/rms-35-?????????.webp') assert_equal 1, files.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fallbacks; end", "def fallbacks; end", "def fallback_data; end", "def fallback_data; end", "def fallbacks=(_arg0); end", "def generate\n throw \"override me before innocent kittens are hurt!\"\n end", "def fallback\n @@fallback\n end", "def fallbacks=(fallbacks); end", "def ...
[ "0.74256533", "0.74256533", "0.6943717", "0.6943717", "0.6911517", "0.66755295", "0.6485262", "0.6407383", "0.6286948", "0.6112707", "0.606089", "0.606089", "0.5886607", "0.5824552", "0.57680345", "0.5754977", "0.57537025", "0.5742189", "0.5737953", "0.5714434", "0.56846344",...
0.0
-1
Ensure fallback images aren't enlarged when cropped.
def test_cropped_fallback output = tested 'fallback rms.jpg 1:3' assert_includes stderr, 'rms.jpg' assert_match url_matcher(format: 'webp', width: 30), output.at_css('img')['src'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_that_grids_do_not_work_for_small_imgs\n end", "def default_preset(img)\n img.crop_resized(128, 128, params[:gravity]).quality(75)\n end", "def square_image_crop\n if (self.crops)\n if !(self.crop_x.nil? || self.crop_y.nil? || self.crop_w.nil? || self.crop_h.nil?)\n @image = Min...
[ "0.5822013", "0.5747133", "0.56986934", "0.567421", "0.5615147", "0.56128144", "0.5590237", "0.5526051", "0.5507453", "0.54916936", "0.54382104", "0.543451", "0.5424528", "0.5408385", "0.53995377", "0.53995377", "0.53948313", "0.5390894", "0.53841573", "0.53549534", "0.532784...
0.6703654
0
convert from each to each, make sure nothing breaks.
def test_conversions File.unstub(:exist?) formats = supported_formats presets['formats']['formats'] = formats formats.each do |input_format| output = tested "formats rms.#{input_format}" sources = output.css('source') formats.each do |output_format| mime = MIME::Types.type_for(output_format).first.to_s assert(sources.any? { |source| source['type'] == mime }, "Failed to generate a source with type #{mime}") end end files = Dir.entries(temp_dir('generated')) formats.each do |format| assert_equal( formats.length, files.count { |f| File.extname(f) == '.' + format } ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def loop_through\n self.map! do |element| \n if !element.is_a?(Array)\n element\n elsif element.is_a?(Array)\n element = element.dup\n element = element.loop_thr...
[ "0.56226206", "0.56226206", "0.56226206", "0.5456607", "0.54258895", "0.54258895", "0.54258895", "0.54258895", "0.54258895", "0.54258895", "0.5334028", "0.5311052", "0.52786386", "0.5277227", "0.5263029", "0.52068317", "0.51996076", "0.51908195", "0.51908195", "0.51908195", "...
0.0
-1
If width and height are set in the preset, they should be overridden rather than appended.
def test_dimension_attributes_replace_values output = tested 'dimension_attributes_replace_values rms.jpg' assert_equal '100', output.at_css('img')['width'] assert_equal '89', output.at_css('img')['height'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_defaults\n self.width ||= 0.20\n self.height ||= 0.20\n end", "def size=(width, height)\n end", "def set_size(w=nil, h=nil)\n @window_width = w if w.is_a?(Numeric) && w > 0 # TODO: > min_width\n @window_height = h if h.is_a?(Numeric) && h > 0 # TODO: > min_height\n super(@window_width,...
[ "0.6931197", "0.6772534", "0.6566193", "0.6498647", "0.6341938", "0.6263508", "0.617338", "0.6144427", "0.6101942", "0.6101942", "0.6101942", "0.6070874", "0.6058934", "0.60096854", "0.6008641", "0.6001165", "0.5948111", "0.59463125", "0.5933111", "0.59201443", "0.58210623", ...
0.0
-1
We don't have an easy way to verify output image quality; the best we can do is make sure you don't get any errors when running it.
def test_calculated_quality assert_silent do tested 'calculated_quality rms.jpg' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def img_resize( dat, w, h, options = {} )\n quality = options[:quality]\n format = options[:format]\n\n begin\n img = GD2::Image.load(dat)\n if h == 0\n h = ( w / img.aspect ).to_i\n end\n\n puts \"resizing image… width: #{w}, height: #{h}, quality: #{quality}\" if $debug\n\n # make sure it ...
[ "0.64244705", "0.6380331", "0.63627076", "0.63494796", "0.6327457", "0.6321721", "0.63078254", "0.62726974", "0.6209394", "0.6186229", "0.61421037", "0.6132888", "0.6129049", "0.6117874", "0.60891587", "0.60744673", "0.60596305", "0.60316795", "0.6023955", "0.60224074", "0.60...
0.6312013
6
Metodo para la indexacion
def [](i) @m_Matrix[i] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def construct_index\n end", "def ta_index\n end", "def add_index_field(*) super end", "def index ; @index ; end", "def index; @index; end", "def index\n set_index\n end", "def index_signature; end", "def index elemento\n end", "def setting_index\n end", "def index\r\n build_index u...
[ "0.81736577", "0.7801928", "0.77983326", "0.77701855", "0.75958234", "0.75148547", "0.74871033", "0.74796593", "0.7478186", "0.746287", "0.74186707", "0.7293735", "0.7249419", "0.7233055", "0.7229382", "0.71772736", "0.71559036", "0.71418726", "0.71418726", "0.7043069", "0.70...
0.0
-1
Metodo que retorna un SparseVector con los valores de una columna.
def cols(j) c = {} for r in @m_Matrix.keys do c[r] = @m_Matrix[r].vector[j] if @m_Matrix[r].vector.keys.include? j end SparseVector.new c end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def covector\n SparseMatrix.row_vector(self)\n end", "def column_vectors\n # (0 .. column_size - 1).collect { |i| column(i) }\n my_rows = @rows\n r_size = my_rows.size\n col_size = my_rows[0].size\n vector_cls = Vector\n array_cls = Array\n res = array_cls.new(col_size)\n for j in 0.....
[ "0.6700544", "0.6443182", "0.5867511", "0.58196855", "0.57611173", "0.55526966", "0.554979", "0.55270654", "0.54024434", "0.5329452", "0.5295366", "0.5284604", "0.5232551", "0.51945686", "0.5126178", "0.51055133", "0.5076098", "0.50242144", "0.50167465", "0.4987222", "0.49630...
0.68450993
0
Metodo para la operacion aritmetica de la suma.
def +(matrizb) #sumita={} #for r in @m_Matrix.keys do # sum = {} # if matrizb.m_Matrix.keys.include? r # for j in @m_Matrix[r].vector.keys do # sum[j] = @m_Matrix[r].vector[j]+matrizb[r].vector[j] # sumita[r] = {j=>sum[j]} # end # else # sum[r]=@m_Matrix[r] # end #end #SparseMatrix.new(sumita) for r in @m_Matrix.keys do for j in @m_Matrix[r].vector.keys do matrizb[r][j]= @m_Matrix[r][j]+matrizb[r][j] end end matrizb end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum; end", "def sum\n\t\treturn self.reduce(:+)\n\tend", "def sum(x, op, y)\n x.send(op, y)\nend", "def sum (operator, a, b)\n if operator == \"add\"\n a + b\n elsif operator == \"subtract\"\n a - b\n elsif operator == \"multiply\"\n a * b\n elsif operator == \"divide\"\n a / b\n end\ne...
[ "0.76462483", "0.69342417", "0.69295937", "0.6904479", "0.6823284", "0.68148553", "0.6810283", "0.68043506", "0.6761971", "0.67081374", "0.6699157", "0.6697887", "0.6693527", "0.6657674", "0.6647919", "0.6622925", "0.6612619", "0.6612072", "0.6599355", "0.6588482", "0.6578472...
0.0
-1
Metodo para la operacion aritmetica de la resta.
def -(matrizb) restita={} for r in @m_Matrix.keys do res = {} if matrizb.m_Matrix.keys.include? r for j in @m_Matrix[r].vector.keys do res[j] = @m_Matrix[r].vector[j]-matrizb[r].vector[j] restita[r] = {j=>res[j]} end else res[r]=@m_Matrix[r] end end SparseMatrix.new(restita) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oper\n return @oper\n end", "def op; end", "def operation; end", "def operations; end", "def operations; end", "def operator; end", "def oper=(value)\n ...
[ "0.73056257", "0.7152441", "0.7005722", "0.68248516", "0.68248516", "0.67099226", "0.64829224", "0.62090945", "0.6032426", "0.6032426", "0.6032426", "0.60213053", "0.60083264", "0.59783834", "0.5942082", "0.5846438", "0.58102375", "0.5806722", "0.57830805", "0.57605016", "0.5...
0.0
-1
The algorithm does not provide a guarantee when the data does not have a majority, returning a random value, then we need a step to check the result
def majority_vote(votes) count = 0 most_voted = 0 votes.each do |vote| most_voted = vote if count.zero? count += vote == most_voted ? 1 : -1 end majority?(votes, most_voted) ? most_voted : -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mc\n rnd = rand(total_count)\n @possibility_distribution.detect{ |pos| (rnd -= pos.last) <= 0 }.first\n end", "def find_by_bayer_moore(array)\n candidate = 0\n count = 0\n # Pass 1 - Find the candidate maintaing a count \n for i in 0..array.size-1\n # binding.pry\n candidate = array[i] if co...
[ "0.6645303", "0.63677937", "0.6246012", "0.6203457", "0.6181281", "0.61715794", "0.6151797", "0.61277753", "0.6095637", "0.6087085", "0.60553885", "0.6046146", "0.60302943", "0.6003618", "0.59460115", "0.5924459", "0.5901495", "0.5895271", "0.5895271", "0.5889197", "0.5881356...
0.56161517
48
Cria atributos de apenas leitura Cria o inicializador da classe, passando os valores dos parametros para os atributos da classe
def initialize(titulo, preco, ano_lancamento, possui_reimpressao) @titulo = titulo @ano_lancamento = ano_lancamento @possui_reimpressao = possui_reimpressao @preco = calcula_preco(preco) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(nombre,edad) #--> se crean los metodos, y se inicializan para darles un valor al crear el objeto \n @nombre = nombre #-->la variable local nombre es asignada a la var. de instancia @nombre, al realizar esto cada instancia tendra un valor propio.\n @edad = edad #--> lo mismo para edad\...
[ "0.7060042", "0.68208", "0.6819683", "0.67807245", "0.6780606", "0.6765753", "0.671401", "0.6693817", "0.66931564", "0.6686258", "0.6677564", "0.6639425", "0.6638173", "0.6633336", "0.6627243", "0.66172147", "0.66078943", "0.66000974", "0.66000706", "0.6566535", "0.6566535", ...
0.0
-1
Metodos apenas chamados na classe mesmo
def calcula_preco(base) if @ano_lancamento <2006 if @possui_reimpressao base * 0.9 else base * 0.5 end elsif @ano_lancamento <= 2010 if @possui_reimpressao base * 0.96 else base end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def mi_carrera\n\n\tend", "def checks; end", "def informational?; end", "def suivre; end", "def usable?; end", "def probers; end", "def marquer!\n fail \"Doit etre defini dans la sous-classe\"\n end", "def cumple_requisitos?\n propietario.hangar.nivel >= 4 && propietario....
[ "0.59491336", "0.58105725", "0.56839466", "0.5679155", "0.56448257", "0.5592401", "0.55302614", "0.5513648", "0.55124253", "0.5512297", "0.5510457", "0.5481711", "0.54707146", "0.54707146", "0.54556906", "0.5429441", "0.54177994", "0.54177994", "0.54177994", "0.53667456", "0....
0.0
-1
ensure that there are no line items referencing this product
def ensure_not_referenced_by_any_line_item if line_items.empty? return true else errors.add(:base, 'Line Items present') return false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_not_referenced_by_any_line_item\n\t\t\tunless line_items.empty?\n\t\t\t\terrors.add(:base, 'Line items reference this product')\n\t\t\t\tthrow :abort\n\t\t\tend\n\t\tend", "def ensure_not_referenced_by_any_line_item_product\n unless line_item_products.empty?\n errors.add(:base, 'Line Items Pro...
[ "0.8736616", "0.853958", "0.8289557", "0.8246923", "0.82232034", "0.82068616", "0.8206619", "0.81594956", "0.81327915", "0.8104883", "0.81018025", "0.80855167", "0.8076766", "0.8076766", "0.80568", "0.8037973", "0.8020351", "0.8020351", "0.8020351", "0.80173016", "0.8011286",...
0.0
-1
=begin The method returns the list of hotel items using the city and token parameters passed in the url. =end
def index hotels_list = get_hotels(params[:city_id].downcase,params[:token]) render_with_protection hotels_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hotels(city,token)\n results = []\n lat,lng = get_coordinates(city)\n if lat.nil? or lng.nil?\n return [].append({:results=>[],:token=>nil}).to_json\n end\n if(token.nil?)\n if((results = $redis.get(lat.to_s+':'+lng.to_s+':hotel')).nil?)\n hotel = get_hotels_list(city,lat...
[ "0.7186517", "0.6746002", "0.6483955", "0.6184442", "0.6137089", "0.6105003", "0.6084849", "0.605834", "0.60118616", "0.59888697", "0.5953563", "0.59356654", "0.5895931", "0.5889715", "0.587097", "0.58280563", "0.58265257", "0.58216214", "0.5820304", "0.5662635", "0.56516993"...
0.7102496
1
=begin The method returns the details of the object identified by the id passed in the url. =end
def show details = hotel_details(params[:id]) render_with_protection details end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retrieve(id)\n instance = self.new(id)\n url = instance.url\n requestor = Requestor.new\n response = requestor.request(:get, url)\n instance.load_from(response)\n instance\n end", "def id\n self.url\n end", "def get_info(id)\n url = \"...
[ "0.7056304", "0.70362073", "0.69295615", "0.668905", "0.6654831", "0.66308546", "0.66008276", "0.65544236", "0.64788526", "0.64471495", "0.64265245", "0.6424871", "0.64235514", "0.63908786", "0.6351275", "0.6345247", "0.6254293", "0.6239257", "0.6238694", "0.6236622", "0.6229...
0.0
-1
This action is called from the redbox in the offer forms. It responds only to POST and xhr.
def create_for_offer @customer = @current_account.customers.build(params[:customer]) @customer.build_address(params[:address]) if @customer.save # Create dummy objects to be able to rebuild the customer selector. @offer = @current_account.offers.build @offer.customer = @customer end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def POST; end", "def post; end", "def xhr?; end", "def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend", "def post_data; end", "def perform(request, options); end", "def post\r\n end", "def perform(request, response); end", "def post_request\n\t\turl = request.fullpath....
[ "0.6717174", "0.6370963", "0.63504535", "0.63321084", "0.6293219", "0.6177772", "0.6172585", "0.61117923", "0.60632414", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "0.60466045", "...
0.0
-1
Configuration changes to be done. Nothing needed here either.
def configure(root_config) super(root_config) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure\n end", "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def configuration; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end", "def config; end",...
[ "0.76876414", "0.76450205", "0.76450205", "0.76450205", "0.76450205", "0.76450205", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882", "0.7620882...
0.61693287
98
Nothing needs to be done on cleanup.
def cleanup super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup; end", "def cleanup; end", "def cleanup; end", "def cleanup; end", "def cleanup!; end", "def cleanup!; end", "def cleanup\r\n end", "def cleanup!\n # This method may be left unimplemented if that is applicable\n end", "def cleanup\n end", "def cleanup\n end", ...
[ "0.9077426", "0.9077426", "0.9077426", "0.9077426", "0.8927613", "0.8927613", "0.8764102", "0.87586147", "0.8717561", "0.8717561", "0.8717561", "0.8717561", "0.87075377", "0.87075377", "0.87075377", "0.86842954", "0.86842954", "0.8348282", "0.8348282", "0.82635987", "0.810750...
0.78892756
24
POST /enrollments POST /enrollments.json
def create @enrollment = @membership.build_enrollment(params[:enrollment]) respond_to do |format| if @enrollment.save format.html { redirect_to business_membership_enrollment_path(@business, @membership, @enrollment), notice: 'Enrollment was successfully created.' } else format.html { render action: "new" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @enrollments = Enrollment.new(enrollment_params)\n\n respond_to do |format|\n if @enrollments.save\n format.html { redirect_to current_user }\n format.json { render :show, status: :created, location: @enrollments }\n else\n format.html { render :new }\n form...
[ "0.7454781", "0.7336914", "0.7142115", "0.6823971", "0.6823971", "0.68186426", "0.67857486", "0.67269367", "0.66352534", "0.65869594", "0.6410974", "0.639911", "0.6384636", "0.6376349", "0.63298506", "0.6321295", "0.6297824", "0.6297824", "0.6297824", "0.6297824", "0.62677735...
0.5670478
77
PUT /enrollments/1 PUT /enrollments/1.json
def update respond_to do |format| if @enrollment.update_attributes(params[:enrollment]) format.html { redirect_to business_membership_enrollment_path(@business, @membership, @enrollment), notice: 'Enrollment was successfully updated.' } else format.html { render action: "edit" } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @enroll = Enroll.find(params[:id])\n if @enroll.update_attributes(params[:enroll])\n render json: JSON.parse(@enroll.to_json)\n else\n render json: JSON.parse(@enroll.errors.to_json)\n end\n end", "def update\n respond_to do |format|\n if @enroll.update(enroll_params)\...
[ "0.7461845", "0.7149237", "0.7149237", "0.6986249", "0.6958556", "0.6883756", "0.6880892", "0.6805591", "0.6805591", "0.6805591", "0.6805591", "0.6759934", "0.6695068", "0.6677743", "0.6677743", "0.6677743", "0.6677743", "0.6677743", "0.6648709", "0.65927005", "0.6553545", ...
0.5955725
69
DELETE /enrollments/1 DELETE /enrollments/1.json
def destroy @enrollment.destroy respond_to do |format| format.html { redirect_to business_membership_url(@business, @membership) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n\n respond_to do |format|\n format.html { redirect_to enrolls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @enroll = Enroll.find(params[:id])\n @enroll.destroy\n render json: JSON.parse({m...
[ "0.7878989", "0.7807575", "0.7752044", "0.7749885", "0.75889903", "0.7575885", "0.7510936", "0.7510936", "0.7510936", "0.7510936", "0.7510936", "0.74598867", "0.7427407", "0.7404994", "0.73979115", "0.73262525", "0.72354174", "0.71959776", "0.71811384", "0.7150566", "0.711881...
0.672684
46
Function created to help break down multiplication of the roman numeral and divided number(from dividing the key and number being tested)
def mult(x,y) x * y end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convertToRoman(n)\n #divide by roman num taken out\n #num is remainder \n #repeat\n roman = { 1000 => \"M\", 900 => \"CM\", 500 => \"D\", 400 => \"CD\", 100 => \"C\", 90 => \"XC\", 50 => \"L\", 40 => \"XL\", 10 => \"X\", 9 => \"IX\", 5 => \"V\", 4 => \"IV\", 1 => \"I\" }\n\n ans = \"\"\n roman.keys.each ...
[ "0.7349924", "0.72723097", "0.717049", "0.7079716", "0.70752275", "0.7042755", "0.7030761", "0.70078313", "0.70029527", "0.69749993", "0.69377095", "0.6910887", "0.6896755", "0.68681806", "0.68323076", "0.6802452", "0.6795064", "0.6783195", "0.678287", "0.6765192", "0.6760622...
0.0
-1
Function created to help break down the divisibility of the number to be converted and the keys in the roman hash
def num_converter_update(num_to_convert,key) num_to_convert % key end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_num(input)\n result = 0\n #iterate on roman number hash\n MAPPING.each do |k,v|\n while input.index(k) == 0 #if \"CL\".index(\"C\") == 0\n result += v #assign value of current hash key\n input.slice!(0) #remove string \"C\" from input and so on\n end\n end\n result\n ...
[ "0.7081349", "0.6980615", "0.68603635", "0.66427726", "0.6542843", "0.65317106", "0.65279365", "0.64967775", "0.6461748", "0.64551085", "0.64265347", "0.64248174", "0.6414048", "0.64095867", "0.6342532", "0.6299481", "0.62900305", "0.628542", "0.62599796", "0.62340164", "0.62...
0.0
-1
put beer name and id together into one variable
def connect_deleted_beer "#{beer_name} [id: #{id}]" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def by_id\n get_beer\n end", "def id\n\t\tputs \"Hi! My name is #{name} and my gene_gene is #{gene}.\"\n\tend", "def entire_name_with_id\r\n self.entire_full_name + \" (#{self.id})\"\r\n end", "def make_id_to_name\n build_hash('id', 'name')\n end", "def name\n id.to_s\n end", "def...
[ "0.6558066", "0.6024858", "0.58939886", "0.5850488", "0.58489627", "0.5783383", "0.576869", "0.5756782", "0.5751613", "0.5729647", "0.5729647", "0.56936455", "0.56769747", "0.5646166", "0.5646166", "0.56071717", "0.56040776", "0.55874234", "0.5560389", "0.554319", "0.5533847"...
0.5159198
79
join long maker and drink name together
def join_drink_name if brewery.short_brewery_name.nil? "#{brewery.brewery_name} #{beer_name}" else "#{brewery.short_brewery_name} #{beer_name}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def artist_name_and_genre\n \"#{artist_name} - #{genre.name}\"\n end", "def long_name\n [number, title].join(' ')\n end", "def long_name\n [number, title].join(' ')\n end", "def full_name\n \"#{bike_brand.name} #{model}\"\n end", "def build_name\n \"#{manufacturer} #{weight} #{style} #{n...
[ "0.5533941", "0.5518208", "0.5518208", "0.54684293", "0.5456652", "0.54524815", "0.539281", "0.5366308", "0.533506", "0.53204626", "0.5264557", "0.52471876", "0.5244372", "0.52410257", "0.52200073", "0.52200073", "0.5195274", "0.51899457", "0.516247", "0.514659", "0.51452863"...
0.6993197
0
get unique beer descriptors
def top_drink_descriptors(how_many) # create empty array to hold top descriptors list for beer being rated @this_beer_descriptors = Array.new # find all descriptors for this drink @this_beer_all_descriptors = self.descriptors # Rails.logger.debug("this beer's descriptors: #{@this_beer_all_descriptors.inspect}") @this_beer_all_descriptors.each do |descriptor| @descriptor = descriptor["name"] @this_beer_descriptors << @descriptor end # attach count to each descriptor type to find the drink's most common descriptors @this_beer_descriptor_count = @this_beer_descriptors.each_with_object(Hash.new(0)) { |word,counts| counts[word] += 1 } # put descriptors in descending order of importance @this_beer_descriptor_count = Hash[@this_beer_descriptor_count.sort_by{ |_, v| -v }] # grab top 5 of most common descriptors for this drink @this_beer_descriptor_count.first(how_many) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drink_type_descriptors\n # get related drinks\n @associated_drinks = Beer.where(beer_type_id: self.id)\n # create array to hold descriptors\n @descriptors_holder = Array.new\n # find all descriptors for this drink type\n @associated_drinks.each do |drink|\n @this_drink_type_all_descripto...
[ "0.5957836", "0.5727464", "0.543534", "0.53549594", "0.52713406", "0.526261", "0.5239569", "0.5232444", "0.5219096", "0.5171344", "0.51576805", "0.51488894", "0.5147665", "0.513588", "0.51348037", "0.51212865", "0.510564", "0.5104553", "0.5081027", "0.50544775", "0.502555", ...
0.5609657
2
save actual tags without quotes
def descriptor_list_tokens=(tokens) self.descriptor_list = tokens.gsub("'", "") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_tag(tag_vals)\n # strip first line\n # strip last line\n # save to file tag_vals[0]\nend", "def tags_text\n\t\tself.tags.join(', ') #convertir el arreglo en una cadena de texto separado por ,\n\tend", "def after_save\n save_tags\n end", "def tags_raw=(values)\n self.tags = []\n self.tag...
[ "0.72315115", "0.64633924", "0.64312917", "0.6400584", "0.6329529", "0.6313223", "0.6284215", "0.62534887", "0.6241067", "0.6107823", "0.6064638", "0.59806883", "0.59617513", "0.591178", "0.5908289", "0.5862886", "0.5861477", "0.584789", "0.5844181", "0.5834414", "0.5821497",...
0.0
-1
aggregate total number of beer ratings
def number_ratings if number_ratings_one.nil? && number_ratings_two.nil? && number_ratings_three.nil? 0 # else, combine the public ratings according to algorithm below else if number_ratings_one && number_ratings_two && number_ratings_three (number_ratings_one + number_ratings_two + number_ratings_three) elsif number_ratings_one && number_ratings_two (number_ratings_one + number_ratings_two) elsif number_ratings_one && number_ratings_three (number_ratings_one + number_ratings_three) elsif number_ratings_two && number_ratings_three (number_ratings_two + number_ratings_three) elsif number_ratings_one number_ratings_one elsif number_ratings_two number_ratings_two else number_ratings_three end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ratings_count\n ratings.count\n end", "def num_ratings\n ratings.count\nend", "def ratings\n if self.reviews.any?\n avg_rating = 0\n self.reviews.each do |review|\n avg_rating += review.rating\n end\n avg_rating = (avg_rating/self.reviews.length).ceil\n return avg_...
[ "0.7571546", "0.7411842", "0.7285324", "0.7215017", "0.7129826", "0.7057436", "0.704326", "0.7041887", "0.70111257", "0.6943283", "0.6941667", "0.69359475", "0.6933854", "0.6933302", "0.6933089", "0.6908444", "0.689924", "0.6891107", "0.688944", "0.6888895", "0.6866801", "0...
0.0
-1
create beer rating algorithm
def beer_rating # if all three public rating sources are nil, provide a "zero" rating for this beer if beer_rating_one.blank? && beer_rating_two.blank? && beer_rating_three.blank? (3.25*2).round(2) # else, combine the public ratings according to algorithm below else # determine if a large number of people have provided ratings on this beer if number_ratings_one first_ratings = number_ratings_one else first_ratings = 0 end if number_ratings_two second_ratings = number_ratings_two else second_ratings = 0 end if number_ratings_three third_ratings = number_ratings_three else third_ratings = 0 end # calculate total number of ratings number_of_ratings = (first_ratings + second_ratings + third_ratings) # if a significant number (>500) have rated this beer, don't discount the rating if number_of_ratings >= 500 if beer_rating_one && beer_rating_two && beer_rating_three (((((beer_rating_one * number_ratings_one) + (beer_rating_two * number_ratings_two) + (beer_rating_three * number_ratings_three)) / (number_of_ratings))*1)*2).round(2) elsif beer_rating_one && beer_rating_two (((((beer_rating_one * number_ratings_one) + (beer_rating_two * number_ratings_two)) / (number_ratings_one + number_ratings_two))*1)*2).round(2) elsif beer_rating_one && beer_rating_three (((((beer_rating_one * number_ratings_one) + (beer_rating_three * number_ratings_three)) / (number_ratings_one + number_ratings_three))*1)*2).round(2) elsif beer_rating_two && beer_rating_three (((((beer_rating_two * number_ratings_two) + (beer_rating_three * number_ratings_three)) / (number_ratings_two + number_ratings_three))*1)*2).round(2) elsif beer_rating_one ((((beer_rating_one * number_ratings_one) / (number_ratings_one))*1)*2).round(2) elsif beer_rating_two ((((beer_rating_two * number_ratings_two) / (number_ratings_two))*1)*2).round(2) else ((((beer_rating_three * number_ratings_three) / (number_ratings_three))*1)*2).round(2) end else # if a non-significant number (<500) have rated this beer, discount the rating by 10% if beer_rating_one && beer_rating_two && beer_rating_three (((((beer_rating_one * number_ratings_one) + (beer_rating_two * number_ratings_two) + (beer_rating_three * number_ratings_three)) / (number_of_ratings))*0.9)*2).round(2) elsif beer_rating_one && beer_rating_two (((((beer_rating_one * number_ratings_one) + (beer_rating_two * number_ratings_two)) / (number_ratings_one + number_ratings_two))*0.9)*2).round(2) elsif beer_rating_one && beer_rating_three (((((beer_rating_one * number_ratings_one) + (beer_rating_three * number_ratings_three)) / (number_ratings_one + number_ratings_three))*0.9)*2).round(2) elsif beer_rating_two && beer_rating_three (((((beer_rating_two * number_ratings_two) + (beer_rating_three * number_ratings_three)) / (number_ratings_two + number_ratings_three))*0.9)*2).round(2) elsif beer_rating_one ((((beer_rating_one * number_ratings_one) / (number_ratings_one))*0.9)*2).round(2) elsif beer_rating_two ((((beer_rating_two * number_ratings_two) / (number_ratings_two))*0.9)*2).round(2) else ((((beer_rating_three * number_ratings_three) / (number_ratings_three))*0.9)*2).round(2) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rating\n rating_calculator.rate(raters)\n end", "def rating_of(category, item)\n ratings_of = ratings.select{ |r| r.beer.send(category) == item }\n ratings_of.map(&:score).inject(&:+) / ratings_of.count.to_f\n end", "def bayesian_rating(options = { })\n entity = Rating.find(:firs...
[ "0.67777103", "0.6221486", "0.6170849", "0.6123548", "0.60644686", "0.60255337", "0.5953071", "0.5950244", "0.59494865", "0.5943388", "0.5940363", "0.5918166", "0.5913563", "0.5862407", "0.5851387", "0.5818734", "0.5811374", "0.58102465", "0.58041066", "0.5795505", "0.5789432...
0.76755834
0
GET /fish GET /fish.json
def index @fish = Fish.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @fishing_method = FishingMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fishing_method }\n end\n end", "def show\n @fish_type = FishType.find(params[:id])\n\n respond_to do |format|\n format.html # show.htm...
[ "0.7247589", "0.6956957", "0.6747203", "0.66758305", "0.6594654", "0.65888816", "0.65587527", "0.65428066", "0.6526046", "0.6475164", "0.6471221", "0.6466248", "0.64371705", "0.6397099", "0.6332353", "0.6330123", "0.63223624", "0.63073725", "0.6291055", "0.62750745", "0.62678...
0.64805937
11
GET /fish/1 GET /fish/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @fishing_method = FishingMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fishing_method }\n end\n end", "def show\n @fish_type = FishType.find(params[:id])\n\n respond_to do |format|\n format.html # show.htm...
[ "0.72222954", "0.70915884", "0.679114", "0.6745848", "0.6732362", "0.6686373", "0.66577846", "0.6630204", "0.66273814", "0.6578545", "0.6541784", "0.6512644", "0.6469412", "0.64474076", "0.6445051", "0.64307207", "0.64307207", "0.64307207", "0.64307207", "0.6417912", "0.64058...
0.0
-1
POST /fish POST /fish.json
def create @fish = Fish.new(fish_params) respond_to do |format| if @fish.save format.html { redirect_to @fish, notice: 'Fish was successfully created.' } format.json { render :show, status: :created, location: @fish } else format.html { render :new } format.json { render json: @fish.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: \"Fish was successfully created.\" }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new, status: :u...
[ "0.75316876", "0.72104937", "0.6981267", "0.69333696", "0.6887857", "0.68178904", "0.6796484", "0.674556", "0.67100996", "0.6703341", "0.6666068", "0.6626096", "0.6478269", "0.6465013", "0.63797915", "0.63763463", "0.63742584", "0.62729216", "0.6198163", "0.6152941", "0.61394...
0.7525397
1
PATCH/PUT /fish/1 PATCH/PUT /fish/1.json
def update respond_to do |format| if @fish.update(fish_params) format.html { redirect_to @fish, notice: 'Fish was successfully updated.' } format.json { render :show, status: :ok, location: @fish } else format.html { render :edit } format.json { render json: @fish.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fish.errors, stat...
[ "0.7068595", "0.6915725", "0.68295753", "0.6707333", "0.6575412", "0.6520344", "0.64568204", "0.64408624", "0.642989", "0.64050674", "0.6347398", "0.63256425", "0.63119215", "0.63097984", "0.6238832", "0.62318236", "0.6227714", "0.6219472", "0.62190235", "0.6204084", "0.61915...
0.6933296
2
DELETE /fish/1 DELETE /fish/1.json
def destroy @fish.destroy respond_to do |format| format.html { redirect_to fish_index_url, notice: 'Fish was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @fish.destroy\n respond_to do |format|\n format.html { redirect_to fish_index_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @fish.destroy\n respond_to do |format|\n format.html { redirec...
[ "0.7452039", "0.72269714", "0.72077584", "0.7131434", "0.7102592", "0.7047345", "0.7047036", "0.7023634", "0.69605815", "0.6874034", "0.6853095", "0.68523306", "0.68523306", "0.68480194", "0.684692", "0.684692", "0.684555", "0.6819591", "0.68119234", "0.6796409", "0.67907494"...
0.72058713
4
Use callbacks to share common setup or constraints between actions.
def set_fish @fish = Fish.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 fish_params params.require(:fish).permit(:name, :description, :sex, :is_neuter) 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
DELETE /locations/1 locations are only destroyed when a user destroys their account
def destroy @location.destroy end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @user_location.destroy\n\n respond_to do |format|\n format.html { redirect_to user_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = current_user.locations.find(params[:id])\n @location.destroy\n\n respond_to do |for...
[ "0.79904115", "0.79009205", "0.78712076", "0.7864998", "0.779462", "0.7759236", "0.77300984", "0.7724419", "0.7718348", "0.7697779", "0.76676565", "0.7649388", "0.7642275", "0.76372886", "0.7634565", "0.75894624", "0.7577347", "0.756857", "0.75489223", "0.7539702", "0.7509996...
0.76102585
15
Only allow a trusted parameter "white list" through.
def location_params params.require(:location).permit(:longitude, :latitude, :altitude, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.71217275", "0.7052942", "0.6947555", "0.6903013", "0.6735074", "0.67167085", "0.6687677", "0.66765445", "0.66602796", "0.65548825", "0.6524274", "0.6455697", "0.6451343", "0.645123", "0.64465624", "0.6433475", "0.64118403", "0.64118403", "0.6390524", "0.6378871", "0.637887...
0.0
-1
Returns the user's fullname and its username in brackets.
def full_user_link(user) link_to edit_user_path(user) do html = content_tag :strong, "#{user.prename} #{user.name}" html << " (#{user.username})" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_full_name\n if user\n user.first_name + ' ' + user.last_name\n else\n 'Anonymous'\n end\n end", "def full_name(user)\n user.first_name + ' ' + user.last_name\n end", "def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty?...
[ "0.8158177", "0.7872309", "0.783311", "0.7799578", "0.7790509", "0.77893984", "0.77218884", "0.7696811", "0.7643659", "0.7622009", "0.7613974", "0.7597232", "0.75905824", "0.75795305", "0.7576303", "0.75638163", "0.7555768", "0.75332564", "0.752702", "0.75214", "0.75159127", ...
0.0
-1
def self.prepended 1/ new method RM 4.0.3 OK Smile specicfic 784714 V4.0.0 : My page Time Entry queries
def name_and_project return name unless project "#{::ERB::Util.h name}&nbsp;&nbsp;|&nbsp;&nbsp;#{::ERB::Util.h project.name}".html_safe end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def internal\n if params[:col].blank? && params[:dir].blank?\n params.merge!(:col => 'created_at', :dir => 'up')\n end\n sort_column_order\n\t\tset_page_number(192,193,71,params[:status])\n\t\tsession[:referer] = nil\n\t\tdata=params\n\t\tapproved_or_billed_time_and_expense_entry(data)\n\t\tsession[:...
[ "0.5826976", "0.57364345", "0.5629898", "0.5559913", "0.5502287", "0.54747945", "0.54685026", "0.54685026", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", "0.54628676", ...
0.0
-1
GET /gatos GET /gatos.json
def index @gatos = Gato.all respond_to do |f| f.html f.pdf{ render template: 'gatos/ficha', pdf:'Ficha Gato' } f.csv{ send_data @gatos.to_csv} f.xls # { send_data @gatos.to_csv(col_sep: "\t") } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @gatos = Gato.all\n end", "def show\n @gasto = Gasto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gasto }\n end\n end", "def index\n @ginasios = Ginasio.all\n\n respond_to do |format|\n format.html # inde...
[ "0.7011776", "0.65732145", "0.6563739", "0.63083196", "0.6190325", "0.6133004", "0.61266977", "0.6121094", "0.61160743", "0.60831946", "0.60776997", "0.6041592", "0.60226625", "0.59611094", "0.5936822", "0.5931319", "0.5910226", "0.58962333", "0.58932954", "0.5893085", "0.585...
0.0
-1
GET /gatos/1 GET /gatos/1.json
def show respond_to do |f| f.js f.pdf{ render template: 'gatos/ficha', pdf:'Ficha Gato' } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @gatos = Gato.all\n end", "def show\n @gasto = Gasto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gasto }\n end\n end", "def index\n @ginasios = Ginasio.all\n\n respond_to do |format|\n format.html # inde...
[ "0.6885853", "0.6746555", "0.6587885", "0.6397008", "0.6312808", "0.6303259", "0.6300389", "0.6160753", "0.6085799", "0.608402", "0.6079833", "0.60390484", "0.6019983", "0.60183126", "0.6017463", "0.60060394", "0.6004982", "0.5993295", "0.5985673", "0.5971384", "0.5970874", ...
0.0
-1
POST /gatos POST /gatos.json
def create @gato = Gato.new(gato_params) respond_to do |format| if @gato.save format.html { redirect_to gatos_url, notice: 'Gato Creado.' } format.json { render :show, status: :created, location: @gato } else format.html { render :new } format.json { render json: @gato.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @gato = Gato.new(gato_params)\n @gato.user_id = current_user.id\n\n respond_to do |format|\n if @gato.save\n format.html { redirect_to @gato, notice: 'Gato was successfully created.' }\n format.json { render :show, status: :created, location: @gato }\n else\n fo...
[ "0.62240034", "0.6188656", "0.6131201", "0.5958368", "0.5938348", "0.59288913", "0.5917163", "0.59059304", "0.5882015", "0.58559597", "0.5823399", "0.5804692", "0.58017516", "0.58016104", "0.57912993", "0.56942344", "0.56591713", "0.5654604", "0.5634455", "0.56294835", "0.561...
0.65635693
0
PATCH/PUT /gatos/1 PATCH/PUT /gatos/1.json
def update respond_to do |format| if @gato.update(gato_params) format.html { redirect_to gatos_url, notice: 'Gato actualizado.' } format.json { render :show, status: :ok, location: @gato } else format.html { render :edit } format.json { render json: @gato.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @gato.update(gato_params)\n format.html { redirect_to @gato, notice: 'Gato was successfully updated.' }\n format.js...
[ "0.67134315", "0.663127", "0.6481839", "0.63991874", "0.63627356", "0.6356359", "0.62897944", "0.6287018", "0.62193406", "0.6199958", "0.6199958", "0.619835", "0.6140744", "0.6104011", "0.6093891", "0.6093891", "0.6053616", "0.60272473", "0.60092235", "0.6000355", "0.59866273...
0.6308932
6
DELETE /gatos/1 DELETE /gatos/1.json
def destroy @gato.destroy respond_to do |format| format.html { redirect_to gatos_url, notice: 'Gato eliminado.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @gato.destroy\n respond_to do |format|\n format.html { redirect_to gatos_url, notice: 'Gato was successfully destroyed.' }\n ...
[ "0.7076654", "0.70082253", "0.6974017", "0.69264495", "0.6873137", "0.685613", "0.68513274", "0.68319887", "0.6825646", "0.6816378", "0.68099326", "0.6740092", "0.6740092", "0.6740092", "0.6740092", "0.66871685", "0.6687002", "0.66235137", "0.66104037", "0.66040975", "0.66040...
0.68643546
5
Use callbacks to share common setup or constraints between actions.
def set_gato @gato = Gato.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.6163927", "0.6046165", "0.59465253", "0.59167755", "0.58904207", "0.58346355", "0.577713", "0.5703502", "0.5703502", "0.56531286", "0.56215113", "0.54224145", "0.5410795", "0.5410795", "0.5410795", "0.53924775", "0.5379919", "0.53580743", "0.53401667", "0.53397506", "0.533...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def gato_params params.require(:gato).permit(:nombre, :edad, :formato_edad, :sexo, :raza, :tipo, :peso, :porte, :chip, :numero_chip, :agresividad, :color, :senas, :fecha_operacion, :comentario, :ficha_id, :propietario_es, :veterinario_id, :apto_cirujia, :apto_cirujia_text, :medico_tratante, :hora_ingreso, :tipo_cirujia, :hallazgos, :hora_alta, :complicaciones,vacunas_attributes:[:id,:nombre,:_destroy], enfermedades_attributes:[:id,:nombre,:_destroy],veterinario_atributes:[:id,:nombre,:_destroy],medicamentos_attributes:[:id,:nombre,:cantidad,:unidad,:cada,:durante,:durante_unidad,:_destroy]) 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
Use callbacks to share common setup or constraints between actions.
def set_freight @freight = Freight.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 freight_params params.require(:freight).permit(:airport_id, :inspectedon, :carrier, :brmtype_id, :ctnpresented, :ctnreleased, :start_time, :finish_time, :importer, :exporter, :permit, :noncompliance, :avatar, :comment) 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
Here our task is to convert string to number
def string_to_number(string) string.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_string_to_number(str); end", "def string_to_number(string)\n string.to_f\nend", "def str_to_number(s)\r\n\t\tval_str = s.to_s()\r\n\t\tif INT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_i()\r\n\t\telsif FLOAT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_f()\r\n\t\telse\r\n\t\t\traise Argume...
[ "0.9173285", "0.80351496", "0.79944414", "0.79724705", "0.7946466", "0.7946466", "0.79224306", "0.7891063", "0.7818706", "0.7808193", "0.76191306", "0.7596244", "0.755788", "0.7302884", "0.72686845", "0.71819144", "0.7033213", "0.70211655", "0.7014203", "0.7008867", "0.700345...
0.7849734
8
O(n + m) O(1)
def exists_in_matrix(matrix, k) return false if matrix.length == 0 || matrix[0].length == 0 r, c = 0, matrix[0].length - 1 while(r >= 0 && c >= 0 && r < matrix.length && c < matrix[0].length) if matrix[r][c] == k return true elsif matrix[r][c] > k c -= 1 else r += 1 end end false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_...
[ "0.6496528", "0.63134277", "0.60639024", "0.60598534", "0.60155207", "0.5987571", "0.5979741", "0.5973184", "0.5908554", "0.5899429", "0.58580816", "0.5830351", "0.58284014", "0.58173484", "0.5794095", "0.577454", "0.5767894", "0.5758229", "0.57176214", "0.569795", "0.5692872...
0.0
-1
gather performance data for a single PID
def record(pid, data = nil) pid_stats_map[pid] = Stat.new(pid, data) unless pid_stats_map[pid] pid_stats_map[pid].record end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_perf_info\n @perf_end_timestamp = Time.now\n @hosts.map { |h| get_perf_data(h, @perf_timestamp, @perf_end_timestamp) }\n end", "def get_perf_data(host, perf_start, perf_end)\n @logger.perf_output(\"Getting perf data for host: \" + host)\n if PERF_SUPPORTED_PLATFORMS.match?(host['...
[ "0.6122074", "0.5885567", "0.58374125", "0.5763835", "0.56918347", "0.5570379", "0.5553219", "0.5532301", "0.55108595", "0.5493562", "0.53463674", "0.53402525", "0.5289529", "0.52815604", "0.52645046", "0.5239986", "0.5237518", "0.52252936", "0.5220956", "0.5208771", "0.52079...
0.47154638
97
Roll up the stats from individual PIDs into a summary
def report(process_pids) ret = {} return ret if pid_stats_map.size == 0 age_sec = 0 cpu_pct = 0 resident_set_bytes = 0 threads = 0 virtual_mem_bytes = 0 pid_stats_map.each do |pid, stat| unless process_pids.include? pid pid_stats_map.delete(pid) next end age_sec += stat.perf_detail[:age_seconds] threads += stat.perf_detail[:threads] resident_set_bytes += stat.perf_detail[:mem][:resident_set_bytes] virtual_mem_bytes += stat.perf_detail[:mem][:virtual_mem_bytes] cpu_pct += process_cpu_pct stat.perf_detail[:cpu] end ret[:age_seconds] = age_sec ret[:threads] = threads ret[:mem] = {} ret[:mem][:resident_set_bytes] = resident_set_bytes ret[:mem][:virtual_mem_bytes] = virtual_mem_bytes ret[:cpu_pct] = cpu_pct ret end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stats_summary\n html = \"\"\n %w(inhale exhale cycle).each do |phase|\n %w(min max avg).each do |stat|\n time = format_time(self.meditations.map {|med| med.send(phase + \"_\" + stat)}.max)\n html += \"record #{phase} #{stat}: #{time}<br>\"\n end\n end\n html\n end", "def ...
[ "0.61231524", "0.6025786", "0.6012312", "0.5933369", "0.5794421", "0.5773226", "0.57561785", "0.5745157", "0.5728771", "0.5668581", "0.5663509", "0.5642775", "0.56234944", "0.56234944", "0.55735254", "0.5525645", "0.5514889", "0.54742026", "0.5460928", "0.545071", "0.54444134...
0.52312607
44
Perform the monitoring checks.
def run( nodes ) super do |host, snmp| self.check_battery( host, snmp ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_monitoring\n @servers.each do |server|\n obj_behavior(server, :settings)\n response = nil\n count = 0\n until response || count > 20 do\n begin\n response = obj_behavior(server, :monitoring)\n rescue\n response = nil\n co...
[ "0.76253325", "0.7601913", "0.69044155", "0.68843925", "0.66576385", "0.6642668", "0.65737313", "0.6556669", "0.65349877", "0.6534936", "0.6504919", "0.6417568", "0.6373893", "0.6370729", "0.63407713", "0.63247293", "0.631746", "0.62872535", "0.6251566", "0.62446713", "0.6213...
0.6410466
12
Query SNMP and format information into a hash.
def format_battery( snmp ) info = {} # basic info that's always available info[ :status ] = snmp.get( oid: OIDS[:battery_status] ) info[ :capacity ] = snmp.get( oid: OIDS[:est_charge_remaining] ) rescue nil info[ :temperature ] = snmp.get( oid: OIDS[:battery_temperature] ) rescue nil info[ :minutes_remaining ] = snmp.get( oid: OIDS[:est_minutes_remaining] ) rescue nil # don't report voltage if the UPS doesn't voltage = snmp.get( oid: OIDS[:battery_voltage] ) rescue nil info[ :voltage ] = voltage / 10 if voltage # don't report current if the UPS doesn't current = snmp.get( oid: OIDS[:battery_current] ) rescue nil info[ :current ] = current/10 if current # see if we are on battery info[ :seconds_on_battery ] = snmp.get( oid: OIDS[:seconds_on_battery] ) rescue 0 info[ :in_use ] = ( info[ :seconds_on_battery ] != 0 ) return { battery: info.compact } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ethernet_oids(host)\n ifTable_columns = [\"ifDescr\", \"ifOutOctets\",\"ifIndex\"]\n eth_name = nil\n eth_octets = nil\n eth_index = nil\n SNMP::Manager.open(:Host => host) do |manager|\n manager.walk(ifTable_columns) do |row|\n next if row[0].value.to_s.match('^lo')\n if eth_name.nil? th...
[ "0.6157912", "0.6037412", "0.57262534", "0.57256126", "0.57255334", "0.56743914", "0.5659326", "0.56244016", "0.5604151", "0.5479429", "0.5462078", "0.52830315", "0.5229554", "0.52291936", "0.5213674", "0.52029276", "0.51975584", "0.5140825", "0.511271", "0.50678647", "0.5051...
0.0
-1
Parse SNMPprovided information and alert based on thresholds.
def check_battery( host, snmp ) info = self.format_battery( snmp ) config = self.identifiers[ host ].last['config'] || {} cap_warn = config[ 'capacity_warn_at' ] || self.class.capacity_warn_at temp_warn = config[ 'temperature_warn_at' ] || self.class.temperature_warn_at in_use = info.dig( :battery, :in_use ) status = info.dig( :battery, :status ) capacity = info.dig( :battery, :capacity ) temperature = info.dig( :battery, :temperature ) warnings = [] if in_use mins = info.dig( :battery, :minutes_remaining ) || "(unknown)" warnings << "UPS on battery - %s minute(s) remaning." % [ mins ] end warnings << BATTERY_STATUS[ status ] if status != 2 warnings << "Battery remaining capacity %0.1f%% less than %0.1f percent" % [ capacity, cap_warn ] if capacity && capacity <= cap_warn warnings << "Battery temperature %dC greater than %dC" % [ temperature, temp_warn ] if temperature && temperature >= temp_warn info[ :warning ] = warnings.join( "\n" ) unless warnings.empty? self.results[ host ] = info end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_snmp_hosts(text)\n re = /host: ([^\\s]+)\\s+.*?port: (\\d+)\\s+type: (\\w+)\\s*user: (.*?)\\s+security model: (.*?)\\n/m # rubocop:disable Metrics/LineLength\n text.scan(re).map do |(host, port, type, username, auth)|\n resource_hash = { name: host, ensure: :present, port: port.to_...
[ "0.60059613", "0.5842377", "0.56512755", "0.5472736", "0.5254893", "0.5221036", "0.5188501", "0.51767224", "0.5044552", "0.50299484", "0.49437246", "0.49314392", "0.48781294", "0.48282015", "0.48275483", "0.4772863", "0.47685096", "0.47587496", "0.47324726", "0.47140944", "0....
0.42953137
81
edit GET /:locale/admin_session/edit (named path: edit_admin_session)
def test_edit_admin_session # FIXME route exists but no action in controller, remove route? #get :edit, :locale => 'en' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @admin_session.update(session_params)\n format.html { redirect_to @admin_session, notice: 'Session was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_session }\n else\n format.html { render :edit }\n ...
[ "0.7054085", "0.68064123", "0.6672927", "0.6614801", "0.6589939", "0.6582252", "0.6557362", "0.6557362", "0.6557362", "0.64800197", "0.6323263", "0.62463754", "0.6240032", "0.62319636", "0.6223811", "0.62187576", "0.6200787", "0.61983234", "0.6183785", "0.61829305", "0.617700...
0.70252484
1
new GET /:locale/admin/session/new (named path: new_admin_session)
def test_new_admin_session get :new, :locale => 'en' assert_response :success end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @user = Admin.new\n\n respond_to do |format|\n format.html { render :template => \"admin/session/new\"}\n format.xml { render :xml => @user }\n end\n end", "def new\n @usuario = Usuario.new\n if current_user\n session[:admin_new] = true\n else\n session[:admin_ne...
[ "0.70117503", "0.69180125", "0.67954737", "0.67679363", "0.6726583", "0.6636874", "0.65391636", "0.65348166", "0.651468", "0.6492233", "0.64741516", "0.6468671", "0.6448151", "0.6441115", "0.6433127", "0.6397004", "0.63933915", "0.6367016", "0.6330643", "0.6290651", "0.627463...
0.6498683
9
show GET /:locale/admin_session (named path: admin_session)
def test_admin_session # FIXME route exists but no action in controller, remove route? # get :show, :locale => 'en' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @admin = Admin.find_by(id: session[:admin_id])\n end", "def show\n @admin_level = Admin.find(session[:admin_id]).admin_level\n end", "def admin_login\n self.current_admin = Admin.find_by_id(session[:admin]) if session[:admin]\n end", "def show\n if !session[:is_admin]\n redir...
[ "0.75633323", "0.7145599", "0.686751", "0.6754945", "0.66622984", "0.6648095", "0.6573709", "0.65021276", "0.6501548", "0.6491134", "0.6487545", "0.6471359", "0.64673877", "0.64360416", "0.64173067", "0.6382344", "0.63659334", "0.6352974", "0.6333428", "0.6330037", "0.6301639...
0.7106847
2
code for 7 dwarves goes here (best practice)
def index if session[:count] == nil session[:count] = 0 end session[:count] += 1 @visit_count = session[:count] @products = Product.all if params[:category] @products = Category.find_by(name: params[:category]).products end if params[:sort] @products = Product.all.order(params[:sort] => params[:sort_order]) end if params[:discount] @products = Product.where("price < ?", 2) end render "index.html.erb" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def schubert; end", "def unusual_sport; end", "def winter_paralympics_sport; end", "def winter_olympics_sport; end", "def who_we_are\r\n end", "def jack_handey; end", "def scientist; end", "def villian; end", "def weber; end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end",...
[ "0.5916293", "0.58770216", "0.5860818", "0.5778818", "0.57446796", "0.57159746", "0.5678462", "0.56354403", "0.56335133", "0.5614869", "0.5607277", "0.5589076", "0.5551287", "0.55388665", "0.55299103", "0.5498585", "0.5498585", "0.5438088", "0.5436617", "0.54210484", "0.54203...
0.0
-1
rubocop:enable Metrics/AbcSize Reads current default serialization arguments.
def config @default_args || Surrealist::HashUtils::EMPTY_HASH end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def args\n @args_serializer.perform_deserialization! if @args_serializer.args.nil?\n @args_serializer.args\n end", "def serialize_default(object); object; end", "def serialization_options\n @serialization_options || self.class.serialization_options || self.class.superclass.serialization_optio...
[ "0.6585234", "0.6388964", "0.6302947", "0.6088047", "0.6003908", "0.59347486", "0.58784777", "0.58057946", "0.5769517", "0.5755509", "0.5747322", "0.5747322", "0.57458204", "0.5738589", "0.5664444", "0.5648463", "0.5648463", "0.5633757", "0.563268", "0.563268", "0.563268", ...
0.58779716
7
Sets default serialization arguments with a block
def configure(hash = nil, &_block) if block_given? carrier = Surrealist::Carrier.new yield(carrier) @default_args = carrier.parameters else @default_args = hash.nil? ? Surrealist::HashUtils::EMPTY_HASH : hash end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize(*args, &block); end", "def serialize(*args, &block); end", "def initialize(&block)\n load_defaults!\n\n instance_eval(&block) if block_given?\n\n set_defaults!\n end", "def default_params_encoder=(_arg0); end", "def initialize\n @block_args = []\n end", ...
[ "0.65434855", "0.65434855", "0.6362944", "0.6152541", "0.61254287", "0.6075222", "0.6064395", "0.60465366", "0.6043293", "0.6023695", "0.5982058", "0.5915093", "0.5883889", "0.5882861", "0.57608163", "0.57608163", "0.57576203", "0.57487386", "0.5737648", "0.5722403", "0.57075...
0.59752697
11
Checks if there is a serializer (< Surrealist::Serializer) defined for the object and delegates surrealization to it.
def __build_schema(object, **args) return args[:serializer].new(object, **args[:context].to_h).build_schema(**args) if args[:serializer] if (serializer = Surrealist::VarsHelper.find_serializer(object.class, tag: args[:for])) serializer.new(object, **args[:context].to_h).build_schema(**args) else build_schema(instance: object, **args) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serializer(name)\n @_serializer = name <= Malba::Serializer ? name : nil\n end", "def use_serializer(serializer)\n @serializer = serializer\n end", "def serialize!(object, serializer_instance)\n serializer = serializer(object, serializer_instance)\n return unless serialize...
[ "0.6800968", "0.6706143", "0.669719", "0.6663395", "0.6325869", "0.62911326", "0.6170903", "0.61556405", "0.60922986", "0.60850024", "0.6050007", "0.60145956", "0.5971927", "0.5890221", "0.5873433", "0.5850773", "0.58401513", "0.5838806", "0.57777303", "0.56955296", "0.561995...
0.0
-1
Auxiliary Recursive function for fibs2
def fibs_rec2(n, i = 0, j = 1) n == 0 ? i : fibs_rec2(n-1, j, i+j) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fib2(n)\n if n < 2\n n\n else\n fib2(n - 1) + fib2(n - 2)\n end\nend", "def fib2(n)\n check = @@saved_fibs[n]\n if(check != nil)\n return check\n elsif n <= 2\n @@saved_fibs[n] = n\n return n\n else\n val = fib2(n-1) + fib2(n-2)\n @@saved_fibs[n] = val\n return val\n end\nend"...
[ "0.81149924", "0.7963547", "0.7920036", "0.78132284", "0.77975935", "0.7752685", "0.773212", "0.7729712", "0.7691897", "0.7683077", "0.7678424", "0.76573914", "0.76124716", "0.7605746", "0.7602062", "0.7600958", "0.7598341", "0.759583", "0.7595043", "0.75934285", "0.7582799",...
0.77920103
5
Rersive function using fibs_rec2
def fibs2(n) (0..n).map { |i| fibs_rec2(i) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fibs_rec(num, fib = [0,1])\n if num == 1\n 0\n elsif num == fib.length\n fib\n else\n result = fib[fib.length - 2] + fib[fib.length - 1]\n fib.push(result)\n fibs_rec(num, fib)\n end\nend", "def fibs_rec(n)\n if n <= 2 then return n == 2 ? [0,1] : [0] end\n a = fibs_rec(n-1)\n return a...
[ "0.72103864", "0.7167818", "0.715184", "0.7124236", "0.71067625", "0.70858645", "0.7085737", "0.7062453", "0.70487046", "0.7035652", "0.6992201", "0.69885856", "0.69871384", "0.6986774", "0.69794714", "0.69622415", "0.69403446", "0.6925711", "0.6919367", "0.69018126", "0.6889...
0.712185
4