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 |
|---|---|---|---|---|---|---|
metodo que crea la tabla con las comparaciones | def tabla(reporte_marca)
data = datos(reporte_marca)
table( [ encabezado ] + data, :header => true) do
row(0).style( :background_color => 'cccccc', :style => :bold, :align => :center, :valign => :center)
cells.style(:size => 8, :inline_format => true)
column(0..5).style(:width => 80)
column(0).style(:width => 120)
column(5).style(:width => 250)
column(5).style(:width => 100)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_table(options={})\n get_table(options).rows\n end",
"def table (b,rain_fall_type,year,ji,compare)\n if rain_fall_type == \"All\"\n hash_data = ji.map do |el|\n {title:el, field:el, sorter:\"string\", editor:true}\n end\n else\n if compare == \... | [
"0.640342",
"0.62216365",
"0.61505413",
"0.6127808",
"0.6092604",
"0.6080967",
"0.60752696",
"0.5945738",
"0.5945738",
"0.5945738",
"0.5945738",
"0.5920275",
"0.5908779",
"0.5869838",
"0.5853422",
"0.57792187",
"0.5744979",
"0.5742229",
"0.5718815",
"0.5712657",
"0.56978565",... | 0.5218145 | 96 |
Prepara los datos para la marca | def datos_marca(reporte_marca = nil)
datos_array = []
datos_array[0] = "#{ reporte_marca.marca_propia.nombre }"
datos_array[1] = "#{ reporte_marca.marca_propia.tipo_signo.sigla if reporte_marca.marca_propia.tipo_signo }"
datos_array[2] = "#{ reporte_marca.marca_propia.clase_id }"
datos_array[3] = "#{ reporte_marca.marca_propia.numero_marca if reporte_marca.marca_propia.numero_marca }"
datos_array[4] = "#{ I18n.l(reporte_marca.marca_propia.fecha_marca.to_date, :format => :short) if reporte_marca.marca_propia.fecha_marca}"
datos_array[5] = "#{ reporte_marca.marca_propia.titulares.collect{|persona| persona.nombre}.join(", ") }"
datos_array[6] = "#{ reporte_marca.comentario }"
datos_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preenche_parcelas_recorrencia\n return unless recorrencia\n \n if recorrencia.tipo == 'por'\n recorrencia.data_inicial = data\n recorrencia.parcelas = recorrencia.descobre_parcelas\n else\n recorrencia.parcelas = nil\n end\n end",
"def modelo_carne_build_data_left(doc, boleto, ... | [
"0.7095181",
"0.60559016",
"0.6031849",
"0.6029318",
"0.5890335",
"0.5811938",
"0.5811938",
"0.5806392",
"0.5758755",
"0.57132375",
"0.5708232",
"0.5603387",
"0.5598211",
"0.55704665",
"0.5549271",
"0.55476916",
"0.5533727",
"0.5434769",
"0.5426965",
"0.5419987",
"0.54155225"... | 0.5169384 | 47 |
get elements from the input file | def read_elems(file_name)
File.foreach(file_name) do |line|
elem = SsumElem.new
line_content = line.split
elem.value=(line_content[0].to_i)
elem.name=(line_content[1])
@elems.push(elem)
end
@done = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def take_input\n pp File.open('input.txt').read.split\n end",
"def parse_input (input_file)\nend",
"def read(files); end",
"def read(files); end",
"def get_elements_from_filename(fileSpec)\n # Split fileSpec into path and file... | [
"0.65794253",
"0.65794253",
"0.65391994",
"0.6539045",
"0.6438291",
"0.6438291",
"0.6429152",
"0.63005126",
"0.62701875",
"0.62701875",
"0.622733",
"0.6159717",
"0.6139828",
"0.6134639",
"0.61054206",
"0.6012727",
"0.5992204",
"0.5985893",
"0.5985668",
"0.59582675",
"0.593623... | 0.7243998 | 0 |
prints the array since unix prints arrays weird | def printarray(array)
print'{'
array.each_index do |i|
print "#{array[i]}"
if i < array.length - 1
print ', '
end
end
print"}\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_array my_array\n\t\tp my_array\n\tend",
"def print_array(array)\n p array\nend",
"def print_array\r\n\t\t\t[@num_files, @total, @blank_lines, @lines]\r\n\t\tend",
"def print_array(array)\n puts '[' + array.join(',') + ']'\nend",
"def printArray\n i = 0\n while (i < (@commandArray.... | [
"0.80811167",
"0.7467618",
"0.74495286",
"0.7235986",
"0.7227587",
"0.72109604",
"0.7146381",
"0.7128479",
"0.6966078",
"0.6957889",
"0.69523394",
"0.69277865",
"0.6926342",
"0.6883094",
"0.68728036",
"0.686041",
"0.685649",
"0.6840872",
"0.68074816",
"0.6707266",
"0.6655553"... | 0.7110713 | 8 |
Fetch the current value | def value(fund, fund_type=nil)
uitf_com_ph_parser(fund)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch\n @value\n end",
"def fetch\n @fetched_value\n end",
"def current_value\n @value\n end",
"def current_value; end",
"def get\n val\n end",
"def get\n val\n end",
"def value\n fetch(0, 0)\n end",
"def get\n @value\n end",... | [
"0.8358098",
"0.8128685",
"0.78576565",
"0.77395225",
"0.74833035",
"0.74833035",
"0.74229467",
"0.739562",
"0.73888826",
"0.7359989",
"0.72878957",
"0.7279641",
"0.7268002",
"0.7263009",
"0.7244565",
"0.72195035",
"0.7190301",
"0.7168009",
"0.7168009",
"0.7168009",
"0.714647... | 0.0 | -1 |
iterate the given matrix and get the correspondent value of the string ascII | def setAscIIMatrix(matrix, max_color = 255)
@ascIIMatrix = matrix.map do |matrix_row|
matrix_row.map do |column|
mapToAsc(column, max_color)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_st( str, matrix )\n matrix.map do |combination|\n detect_single str, combination\n end\n end",
"def experimental_layout(string, matrix)\n matrix.each_with_index do |row, idx|\n if row.include? string\n matrix = matrix[idx..(idx + 8)] \n ... | [
"0.63017124",
"0.62424636",
"0.6066331",
"0.6062223",
"0.5989932",
"0.59141326",
"0.59098536",
"0.5800013",
"0.5776435",
"0.5733184",
"0.56770027",
"0.5666825",
"0.5665908",
"0.5636763",
"0.56365436",
"0.5617619",
"0.5617619",
"0.5617619",
"0.5602507",
"0.5559806",
"0.5512899... | 0.5635286 | 15 |
Define a method `primes(num)` that returns an array of the first "num" primes. You may wish to use an `is_prime?` helper method. | def is_prime?(num)
(2...num).each do |factor|
if num % factor == 0
return false
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend",
"def get_primes num\n primes = []\n for i in 0 ... num do\n ... | [
"0.7646097",
"0.7535501",
"0.74426496",
"0.74036944",
"0.735773",
"0.735544",
"0.73497057",
"0.7346434",
"0.73462665",
"0.73432755",
"0.72876334",
"0.7286933",
"0.7262967",
"0.7202156",
"0.7165513",
"0.7139612",
"0.70907146",
"0.70803976",
"0.70380455",
"0.7034348",
"0.700861... | 0.0 | -1 |
Write a recursive method that returns the first "num" factorial numbers. Note that the 1st factorial number is 0!, which equals 1. The 2nd factorial is 1!, the 3rd factorial is 2!, etc. 0!, 1!, 2!, 3! 0, 1, 21, 321 | def factorials_rec(num)
# p num
# p "num #{num} "
if num <= 0
return [1]
end
if num == 1
return [1]
end
if num == 2
return [1, 1]
end
# p factorial(3)
# factorial = num-1 * factorials_rec(num-2)
# p factorial
return factorials_rec(num-1) + [factorial(num-1)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_factorial(num)\n if num < 2\n return 1\n else\n return num * first_factorial(num - 1)\n end\nend",
"def FirstFactorial(num)\n if num > 1\n return num*(FirstFactorial(num-1)) \n end\n return num \nend",
"def factorialrecursion num\n\tif num < 0\n\t\tnil\n\tend\n\t\n\tif nu... | [
"0.8578709",
"0.8443549",
"0.8218579",
"0.8169257",
"0.80102843",
"0.79322165",
"0.79215854",
"0.792012",
"0.7915208",
"0.79036087",
"0.79018426",
"0.7892543",
"0.78834593",
"0.7875812",
"0.78733236",
"0.7870808",
"0.7822589",
"0.7820595",
"0.7817242",
"0.78039074",
"0.779651... | 0.0 | -1 |
GET /os_groups_principals GET /os_groups_principals.json | def index
@os_groups_principals = OsGroupsPrincipal.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
"def valid_principals; end",
"def all_principals\n (User.all + UserGroup.where_unit(unit).not(self)).sort { |a, b| a.name.downcase <=> b.name.downcase }\n end",
"def set_o... | [
"0.6097689",
"0.60508186",
"0.60463494",
"0.60167515",
"0.5963318",
"0.5945676",
"0.5880693",
"0.58682334",
"0.5852709",
"0.5815911",
"0.57917845",
"0.57739615",
"0.5754028",
"0.57078266",
"0.5663193",
"0.5656794",
"0.5651548",
"0.56480765",
"0.5647834",
"0.5639857",
"0.56241... | 0.73849803 | 0 |
GET /os_groups_principals/1 GET /os_groups_principals/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @os_groups_principals = OsGroupsPrincipal.all\n end",
"def set_os_groups_principal\n @os_groups_principal = OsGroupsPrincipal.find(params[:id])\n end",
"def groups\n \n \n @groups = @current_user.groups\n render 'groups.json.jbuilder', status: :ok\n end",
... | [
"0.73617285",
"0.6323054",
"0.6140531",
"0.60549027",
"0.60502696",
"0.6036909",
"0.6031016",
"0.59600157",
"0.5904643",
"0.585827",
"0.5852412",
"0.58440906",
"0.5812709",
"0.5808064",
"0.58049154",
"0.573848",
"0.5721879",
"0.5717146",
"0.569385",
"0.5689574",
"0.5682774",
... | 0.0 | -1 |
POST /os_groups_principals POST /os_groups_principals.json | def create
@os_groups_principal = OsGroupsPrincipal.new(os_groups_principal_params)
respond_to do |format|
if @os_groups_principal.save
format.html { redirect_to @os_groups_principal, notice: 'Os groups principal was successfully created.' }
format.json { render :show, status: :created, location: @os_groups_principal }
else
format.html { render :new }
format.json { render json: @os_groups_principal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n #logger.info \"Post parameters: #{params}\"\n @group = Group.new(name: params[:group][:name], expiration: params[:group][:expiration], owner: current_user)\n if @group.save\n @group.memberships.create!(user: current_user, admin: true)\n if params[:group][:users]\n params[:gro... | [
"0.6335019",
"0.63143855",
"0.62710017",
"0.61670905",
"0.6159802",
"0.61406267",
"0.6111444",
"0.5953767",
"0.5915605",
"0.5891893",
"0.58433414",
"0.5841817",
"0.58326596",
"0.57998157",
"0.578946",
"0.5781074",
"0.57583886",
"0.57482994",
"0.56941783",
"0.5680823",
"0.5650... | 0.65073085 | 0 |
PATCH/PUT /os_groups_principals/1 PATCH/PUT /os_groups_principals/1.json | def update
respond_to do |format|
if @os_groups_principal.update(os_groups_principal_params)
format.html { redirect_to @os_groups_principal, notice: 'Os groups principal was successfully updated.' }
format.json { render :show, status: :ok, location: @os_groups_principal }
else
format.html { render :edit }
format.json { render json: @os_groups_principal.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n #logger.info \"Put parameters: #{params.to_json}\"\n\n if @membership.admin \n if @group.update_attributes(params[:group])\n head :no_content\n else\n render json: @group.errors, status: :unprocessable_entity\n end\n else \n render json: {error: \"YOU MUST B... | [
"0.6312263",
"0.62926763",
"0.6251843",
"0.62385625",
"0.61065876",
"0.6094883",
"0.60867923",
"0.596669",
"0.5907262",
"0.5903982",
"0.5899533",
"0.5899143",
"0.5859179",
"0.5849815",
"0.5841814",
"0.5836343",
"0.58053243",
"0.58008516",
"0.5765576",
"0.57338476",
"0.5713981... | 0.6910296 | 0 |
DELETE /os_groups_principals/1 DELETE /os_groups_principals/1.json | def destroy
@os_groups_principal.destroy
respond_to do |format|
format.html { redirect_to os_groups_principals_url, notice: 'Os groups principal was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @os_groups_membership.destroy\n respond_to do |format|\n format.html { redirect_to os_groups_memberships_url, notice: 'Os groups membership was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @agroup.destroy\r\n respond_to do |f... | [
"0.7164885",
"0.7157955",
"0.7079997",
"0.7054249",
"0.7025282",
"0.69949687",
"0.69822466",
"0.6970758",
"0.69643766",
"0.69468206",
"0.69466543",
"0.6946197",
"0.6938851",
"0.6921054",
"0.6901507",
"0.6901365",
"0.68666947",
"0.6856973",
"0.68455476",
"0.68349695",
"0.68316... | 0.7754734 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_os_groups_principal
@os_groups_principal = OsGroupsPrincipal.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 os_groups_principal_params
params.require(:os_groups_principal).permit(:ActiveGroupID)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
Call the method to show the predicted deaths and virus spread speed. | def virus_effects
predicted_deaths
speed_of_spread
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virus_effects\n print predicted_deaths\n puts speed_of_spread\n end",
"def virus_effects\n number_of_deaths = predicted_deaths\n speed = speed_of_spread\n print_results(number_of_deaths, speed)\n\n end",
"def virus_effects\n predicted_deaths\n speed_of_spread\n print\n end",
"def v... | [
"0.7859605",
"0.7702295",
"0.7651795",
"0.7651795",
"0.75596046",
"0.72306985",
"0.72231823",
"0.72183573",
"0.72172034",
"0.72172034",
"0.72172034",
"0.72172034",
"0.72172034",
"0.7185333",
"0.7165502",
"0.7165502",
"0.7120303",
"0.7116353",
"0.71141154",
"0.7105458",
"0.709... | 0.0 | -1 |
Base on the state population demsity, and the population to print out the predicted deaths. | def predicted_deaths
# predicted deaths is solely based on population density
=begin
if @population_density >= 200
number_of_deaths = (@population * 0.4).floor
elsif @population_density >= 150
number_of_deaths = (@population * 0.3).floor
elsif @population_density >= 100
number_of_deaths = (@population * 0.2).floor
elsif @population_density >= 50
number_of_deaths = (@population * 0.1).floor
else
number_of_deaths = (@population * 0.05).floor
end
=end
factor = case @population_density
when 0...50 then 0.05
when 50...100 then 0.1
when 100...150 then 0.2
when 150...200 then 0.3
else 0.4
end
number_of_deaths = (@population * factor).floor
print "#{@state} will lose #{number_of_deaths} people in this outbreak"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predicted_deaths # this is going to print out the deaths for each state on the outbreak which is going to be based on population and population density\n \n death_percent = 0.1 if @population_density >= 50\n death_percent = 0.2 if @population_density >= 100\n death_percent = 0.3 if ... | [
"0.83680385",
"0.82915056",
"0.82544446",
"0.82459253",
"0.82047135",
"0.8179161",
"0.8159926",
"0.81475717",
"0.8139793",
"0.81325537",
"0.8109914",
"0.8107401",
"0.8105526",
"0.8100693",
"0.8100693",
"0.80864614",
"0.8082998",
"0.8081954",
"0.8081605",
"0.80811566",
"0.8074... | 0.0 | -1 |
Base on state population density, print out the predicted virus spread speed of the state. | def speed_of_spread
#in months
# We are still perfecting our formula here. The speed is also affected
# by additional factors we haven't added into this functionality.
speed = 0.0
=begin
if @population_density >= 200
speed += 0.5
elsif @population_density >= 150
speed += 1
elsif @population_density >= 100
speed += 1.5
elsif @population_density >= 50
speed += 2
else
speed += 2.5
end
=end
factor = case @population_density
when 0...50 then speed += 2.5
when 50...100 then speed += 2
when 100...150 then speed += 1.5
when 150...200 then speed += 1
else speed += 0.5
end
puts " and will spread across the state in #{speed} months.\n\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virus_effects\n predicted_deaths(@state_density, @population)\n speed_of_spread(@state_density)\n end",
"def virus_effects \n predicted_deaths(@population_density, @population, @state)\n speed_of_spread(@population_density, @state)\n end",
"def virus_effects\n predicted_deaths(@population... | [
"0.7372724",
"0.7336342",
"0.73075587",
"0.72250473",
"0.72250473",
"0.72250473",
"0.72250473",
"0.72250473",
"0.72250473",
"0.721725",
"0.721725",
"0.720011",
"0.720011",
"0.7185972",
"0.7152208",
"0.71435267",
"0.7142469",
"0.7140985",
"0.7140985",
"0.7140985",
"0.7140985",... | 0.0 | -1 |
takes our name and location and performs work to create 2 methods, one for getting and one for setting values attr_reader and attr_writer are two others | def initialize name, location
@name = name
@location = location
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end",
"def method_missing(meth, *args, &blk)\n match = meth.to_s.match(/^([a-zA-Z\\_]+)(=|$)$/)\n if match\n attribute, setter = match[1], !match[2].blank?\n if setter\n write_attribute(attribut... | [
"0.65571475",
"0.6528524",
"0.63773984",
"0.63738316",
"0.6302142",
"0.62688434",
"0.62566525",
"0.6236821",
"0.6235319",
"0.6213773",
"0.61631787",
"0.6114907",
"0.6049062",
"0.6048966",
"0.60329497",
"0.5983087",
"0.5961887",
"0.59423",
"0.59147185",
"0.5898008",
"0.5892614... | 0.56407434 | 41 |
Callable with nitem=nil to create a mock | def initialize(nitem=nil, ident=nil, type=nil, order=nil)
if !nitem.nil?
# path to create a real citem
fail ArgumentError, "invalid CItem contruction" unless ident.nil?
@nitem = nitem
defaults_from_nitem
parse_identifier @nitem.identifier
else
# path to create a mock citem
fail ArgumentError, "invalid CItem contruction" unless nitem.nil?
@nitem = nil
@status = nil
@type = type
@identifier = ident
@order = order
@title = ident
@style = nil
parse_identifier(ident)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Museum_zero_toys\n\td = Minitest::Mock::new \"Driver\"\n\tdef d.location; \"Museum\";\n\tend\n\td.expect :numberOfDinoToys, 0\n\tdef d.numberOfDinoToys=(n); n;\n\tend\n\tassert_equal checkItems(d), 1\nend",
"def test_Museum_one_toy\n\td = Minitest::Mock::new \"Driver\"\n\tdef d.location; \"Museum\";\n\t... | [
"0.5798909",
"0.5771405",
"0.57357544",
"0.5708185",
"0.5700871",
"0.56786513",
"0.56268317",
"0.5606748",
"0.55923647",
"0.55703527",
"0.5556721",
"0.5549778",
"0.5519513",
"0.54963887",
"0.5493598",
"0.5476381",
"0.54665554",
"0.5457811",
"0.5440725",
"0.54403394",
"0.54303... | 0.65746385 | 0 |
Prints out game result | def check_outcome(player)
case @board.status
when 1
puts "*** #{player.name} Won Congratulations! ***"
1
when 0
puts "*** That's a tie ***"
0
else
-1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_game_results(message)\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Display the results of the game\r\n puts \"\\n\\n\\n\"\r\n puts \"\\t\\t\\t Game Over: \" + message + \"\\n\\n\\n\"\r\n puts \"\\t\\t\\t 1 2 3\\n\" \r\n puts \... | [
"0.7640207",
"0.7572283",
"0.75481486",
"0.7542524",
"0.7505903",
"0.7399942",
"0.7372191",
"0.73262334",
"0.7275096",
"0.7242373",
"0.72309",
"0.7224865",
"0.7199096",
"0.7191849",
"0.70517266",
"0.7023484",
"0.7013914",
"0.70130444",
"0.7009906",
"0.6995562",
"0.69873303",
... | 0.0 | -1 |
reset opentox session live status | def stop_session
@office = params[:id] ? Office.find(params[:id]) : Office.new
tok_session = OpentokSession.find(:first, :conditions => {:office_id => @office.id})
if tok_session.is_live
tok_session.is_live = false
tok_session.save
end
render :nothing => true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wipe_state\r\n @modes = nil\r\n @online = false\r\n end",
"def reset_session!\n raw_session.clear\n end",
"def reset_current_session\n\n pop_session_frame\n push_session_frame\n\n end",
"def reset_session_counts\n self.session_count = 0\n end",
"def reset!\n @sess_has... | [
"0.6720009",
"0.6670514",
"0.6604741",
"0.64692205",
"0.645946",
"0.64215964",
"0.6313557",
"0.6295861",
"0.62692076",
"0.62452716",
"0.62167275",
"0.61965734",
"0.6185754",
"0.6167853",
"0.61599034",
"0.61141807",
"0.6069537",
"0.6045733",
"0.6012334",
"0.6011193",
"0.600942... | 0.5728706 | 52 |
cannot validate the created_user. The record is created from the group or patients controller and it is blank until the account information and the iprocedure / idiagnositic information id entered. validates :created_user, :presence => true override the destory method to set the deleted boolean to true. | def destroy
run_callbacks :destroy do
self.update_column(:deleted, true)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_before_create!(user)\n # Calling valid? will reset the error list :( so it has to be done first.\n user.valid?\n\n # NB: These uniqueness constraints have to be enforced by the database\n # also, or else there is a race condition. However, checking for them\n # separ... | [
"0.62461704",
"0.61444396",
"0.60924983",
"0.6048087",
"0.603172",
"0.5896942",
"0.5881733",
"0.58522964",
"0.5837259",
"0.58137447",
"0.57736534",
"0.5770036",
"0.57664156",
"0.5765786",
"0.57248354",
"0.5717002",
"0.5717002",
"0.5716614",
"0.56960285",
"0.56954455",
"0.5695... | 0.0 | -1 |
Doesn't work for anything inside a module (eg, if you try to remove Testify::Framework::RSpec this will totally blow up). | def destroy_class ( klass )
klass = klass.name.to_s if klass.kind_of? Class
Object.class_exec { remove_const klass } if Object.const_defined? klass
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isolate_namespace(mod); end",
"def isolate_namespace(mod); end",
"def ensure_outer_module_declarations(mod); end",
"def ensure_module_defined(module_name)\n module_name.split('::').reduce(Object) do |last_module, next_module|\n last_module.const_set(next_module, Module.new) unless last_module.const_d... | [
"0.6636496",
"0.6636496",
"0.6574651",
"0.622111",
"0.622111",
"0.622111",
"0.6170118",
"0.6154878",
"0.61464465",
"0.6108095",
"0.6062762",
"0.6046401",
"0.6012169",
"0.6002306",
"0.5970949",
"0.59674054",
"0.59674054",
"0.596653",
"0.5955903",
"0.5946241",
"0.5943705",
"0... | 0.0 | -1 |
Constructs an instance of PathRouter::Router. | def initialize
reset!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @router = Router.new(ROUTES)\n end",
"def router\n @router ||= PathRouter.new\n block_given? ? yield(@router) : @router\n end",
"def initialize(router)\n @router = router\n end",
"def initialize(router)\n @router = router\n end",
"def initialize\n... | [
"0.7973749",
"0.7305366",
"0.7236502",
"0.71656704",
"0.68578714",
"0.683714",
"0.6560891",
"0.65367985",
"0.64033943",
"0.6330961",
"0.6306697",
"0.6212239",
"0.61949646",
"0.613634",
"0.613634",
"0.613634",
"0.6105443",
"0.60926133",
"0.6069193",
"0.6061447",
"0.5971413",
... | 0.0 | -1 |
Adds a new route to routes. | def add(verb, path, options = {}, &block)
route = Route.new(path, verb, options, &block)
route.router = self
@routes << route
route
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_route(route)\n @routes << route\n route\n end",
"def add_route(*args, &block)\n route = Route.new(*args, &block)\n @routes << route\n route\n end",
"def add(new)\n @routes << new\n end",
"def add_route(*args)\n custom_routes << args\n end",
"def add_route(*p... | [
"0.8477683",
"0.8319518",
"0.81934136",
"0.7950554",
"0.7822653",
"0.77318794",
"0.76918113",
"0.76151544",
"0.75510204",
"0.75510204",
"0.75510204",
"0.75510204",
"0.75510204",
"0.75510204",
"0.75510204",
"0.74954736",
"0.7467528",
"0.7454288",
"0.7412654",
"0.7412654",
"0.7... | 0.7400999 | 22 |
Returns all routes which are matched with the condition | def call(request, &block)
prepare! unless prepared?
@engine.call_by_request(request, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_routes\n matching_routes\n end",
"def routes(filter = nil)\n Rails.application.reload_routes!\n formatted = formatted_routes\n if filter\n formatted.select!{ |r| r.match(filter) }\n end\n puts formatted\n end",
"def match_with(pattern)\n offset = 0\n conditions = ... | [
"0.69689476",
"0.6567925",
"0.6302781",
"0.6227132",
"0.6227132",
"0.62236345",
"0.61623317",
"0.61459446",
"0.61363983",
"0.60966694",
"0.6081094",
"0.60763067",
"0.60761106",
"0.60761106",
"0.60155773",
"0.60105526",
"0.5975856",
"0.59719414",
"0.5967502",
"0.5833284",
"0.5... | 0.0 | -1 |
Returns all routes which are matched with the condition without block | def recognize(request_or_env)
prepare! unless prepared?
@engine.find_by(request_or_env)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_routes\n matching_routes\n end",
"def show_all_routes\n if @routes.empty?\n routes_void\n else\n routes_list\n end\n end",
"def routes(filter = nil)\n Rails.application.reload_routes!\n formatted = formatted_routes\n if filter\n formatted.select!{ |r| r.match(filte... | [
"0.66447496",
"0.6258296",
"0.62433916",
"0.6156238",
"0.6156238",
"0.6136334",
"0.6074586",
"0.60303664",
"0.6023901",
"0.5981616",
"0.59503853",
"0.59375507",
"0.5907974",
"0.5888199",
"0.5871139",
"0.5849782",
"0.58361006",
"0.58324623",
"0.58324623",
"0.58236015",
"0.5812... | 0.0 | -1 |
Finds a path which is matched with conditions from arguments | def path(name, *args)
params = args.last.is_a?(Hash) ? args.pop : {}
candidates = @routes.select { |route| route.name == name }
fail InvalidRouteException if candidates.empty?
i = 0
route = candidates.sort_by! { |candidate|
# Tries to find the route that matches more, but with fewer names, in stable order
[(params.keys.map(&:to_s) - candidate.matcher.names).length, candidate.matcher.names.size, i += 1] }.shift
matcher = route.matcher
params_for_expand = params.dup
if !args.empty? && matcher.mustermann?
matcher.names.each_with_index do |matcher_name, index|
params_for_expand[matcher_name.to_sym] ||= args[index]
end
end
matcher.mustermann? ? matcher.expand(params_for_expand) : route.path_for_generation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_path(*expected)\n MatchPath.new(*expected)\nend",
"def match(path = '', conditions = {}, &block)\n if path.is_a? Hash\n conditions = path\n else\n conditions[:path] = path\n end\n match_without_path(conditions, &block)\n end",
"def find(path); end",... | [
"0.65873927",
"0.6547209",
"0.65431184",
"0.65431184",
"0.6448081",
"0.63796926",
"0.62855774",
"0.61984944",
"0.60887706",
"0.60732704",
"0.6026135",
"0.6024727",
"0.5934233",
"0.5870842",
"0.58547604",
"0.58470654",
"0.5837413",
"0.5836147",
"0.58238626",
"0.5822486",
"0.58... | 0.5637573 | 30 |
Recognizes route and expanded params from a path. | def recognize_path(path_info)
prepare! unless prepared?
route = @engine.find_by_pattern(path_info).first
[route.name, route.params_for(path_info, {})]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def params_for_path(path)\n routes.each do |route|\n # TODO: Finish nested routes\n if false && route[0].class == Proc\n # puts route[0].call(params).inspect\n\n return false\n elsif route[0] == path\n # Found the matching route\n return route[1]\n end\n end\n\... | [
"0.7280867",
"0.7213237",
"0.7180136",
"0.6988862",
"0.662948",
"0.66172403",
"0.65238047",
"0.6458102",
"0.63789886",
"0.6369277",
"0.6322693",
"0.6229422",
"0.62169653",
"0.61716616",
"0.6166227",
"0.6164699",
"0.6124176",
"0.6110725",
"0.60986584",
"0.6088874",
"0.60877407... | 0.6743341 | 4 |
Resets all routes, current order and preparation. | def reset!
@routes = []
@current_order = 0
@prepared = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset!\n @routes = []\n @current = 0\n @prepared = nil\n end",
"def reset\n @routes.clear\n end",
"def reset_routes!\n router.reset!\n default_routes!\n end",
"def reset!\n ATTRIBUTES.each {|attr| send(\"#{attr.to_s}=\", nil)}\n routes.clear\n end... | [
"0.8502667",
"0.8342837",
"0.8084234",
"0.78610474",
"0.7825249",
"0.76200765",
"0.7598202",
"0.7527421",
"0.75123835",
"0.7503326",
"0.7447917",
"0.72949356",
"0.7233432",
"0.71370775",
"0.713383",
"0.7070246",
"0.68104905",
"0.673515",
"0.673511",
"0.6582808",
"0.64724296",... | 0.8948035 | 0 |
Constructs an instance of PathRouter::Compiler, and sorts all routes by using the order. | def prepare!
@engine = Compiler.new(@routes)
@prepared = true
return if @current_order.zero?
@routes.sort_by!(&:order)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile\n if routes.any?\n eval(compiled_statement, binding, \"Generated Code for Router\", 1)\n else\n reset!\n end\n end",
"def compile!\n return if compiled?\n @routes.each_with_index do |route, index|\n route.index = index\n rout... | [
"0.6722695",
"0.6400436",
"0.6391209",
"0.63828826",
"0.61799264",
"0.59897286",
"0.5970301",
"0.5682375",
"0.5574922",
"0.5313809",
"0.52210253",
"0.5097892",
"0.5096022",
"0.50931543",
"0.5081514",
"0.50616485",
"0.4952214",
"0.4946551",
"0.49374452",
"0.489529",
"0.4882776... | 0.7331069 | 0 |
Returns true if the router has been prepared. | def prepared?
!!@prepared
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepared?\n @prepared\n end",
"def prepared?\n @prepared\n end",
"def check_router\n # checks if the router is ready for us ?\n out_socket.send( \"READY\\n\", 0 )\n result = out_socket.recv( 100 )\n logger.debug( \"RESP TO READY #{result}\" )\n raise \... | [
"0.70103145",
"0.6984132",
"0.6731593",
"0.6039893",
"0.60168797",
"0.6007418",
"0.59772253",
"0.59714454",
"0.59714454",
"0.59087604",
"0.5851214",
"0.5819055",
"0.5819022",
"0.5783502",
"0.5779981",
"0.5757991",
"0.5757963",
"0.57484704",
"0.574119",
"0.57408667",
"0.573772... | 0.6764911 | 3 |
GET /ethans GET /ethans.json | def index
@ethans = Ethan.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def index \n fans = Fan.all \n render json: fans \n ... | [
"0.61438787",
"0.5880642",
"0.5785583",
"0.5766902",
"0.56952447",
"0.5678624",
"0.5668317",
"0.56448",
"0.56446433",
"0.5642055",
"0.5597791",
"0.55810463",
"0.55613166",
"0.55569273",
"0.55017495",
"0.5496808",
"0.5475355",
"0.5455577",
"0.54330426",
"0.54189086",
"0.538566... | 0.6547435 | 0 |
GET /ethans/1 GET /ethans/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end",
"def index\n @ethans = Ethan.all\n end",
"def show\n @ethnic... | [
"0.6066483",
"0.59628034",
"0.5908075",
"0.5722174",
"0.57127494",
"0.5701225",
"0.5652362",
"0.5596546",
"0.55960876",
"0.5590361",
"0.55787706",
"0.55583084",
"0.55578786",
"0.5554576",
"0.55506057",
"0.5521771",
"0.5485512",
"0.5460404",
"0.5460219",
"0.5457282",
"0.545168... | 0.0 | -1 |
POST /ethans POST /ethans.json | def create
@ethan = Ethan.new(ethan_params)
respond_to do |format|
if @ethan.save
format.html { redirect_to @ethan, notice: 'Ethan was successfully created.' }
format.json { render :show, status: :created, location: @ethan }
else
format.html { render :new }
format.json { render json: @ethan.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @etnia = Etnia.new(params[:etnia])\n\n respond_to do |format|\n if @etnia.save\n format.html { redirect_to @etnia, notice: 'Etnia was successfully created.' }\n format.json { render json: @etnia, status: :created, location: @etnia }\n else\n format.html { render ac... | [
"0.53305954",
"0.5286644",
"0.5236006",
"0.5212155",
"0.51399887",
"0.51332456",
"0.51296335",
"0.5124354",
"0.50979507",
"0.50589436",
"0.50586987",
"0.50448734",
"0.50304323",
"0.50243896",
"0.501395",
"0.49914914",
"0.49734533",
"0.4957578",
"0.49536648",
"0.4933228",
"0.4... | 0.5811296 | 0 |
PATCH/PUT /ethans/1 PATCH/PUT /ethans/1.json | def update
respond_to do |format|
if @ethan.update(ethan_params)
format.html { redirect_to @ethan, notice: 'Ethan was successfully updated.' }
format.json { render :show, status: :ok, location: @ethan }
else
format.html { render :edit }
format.json { render json: @ethan.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_a... | [
"0.5855294",
"0.58212775",
"0.57802737",
"0.57800215",
"0.5727435",
"0.5687768",
"0.5680918",
"0.5664223",
"0.566378",
"0.56522346",
"0.5646004",
"0.56335735",
"0.56275564",
"0.5615478",
"0.56134844",
"0.5609227",
"0.56071204",
"0.559153",
"0.5582991",
"0.55725414",
"0.556086... | 0.62819964 | 0 |
DELETE /ethans/1 DELETE /ethans/1.json | def destroy
@ethan.destroy
respond_to do |format|
format.html { redirect_to ethans_url, notice: 'Ethan was successfully destroyed.' }
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 @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n ... | [
"0.67146903",
"0.6661254",
"0.65523934",
"0.6435625",
"0.64042836",
"0.63823205",
"0.63738286",
"0.636189",
"0.6348627",
"0.6344994",
"0.634246",
"0.63373214",
"0.63158107",
"0.62869877",
"0.6267021",
"0.6265753",
"0.6265753",
"0.6265753",
"0.6265753",
"0.6265749",
"0.6263611... | 0.7005887 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_ethan
@ethan = Ethan.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def ethan_params
params.require(:ethan).permit(:login)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
def parse csv_emails.split(/\s,\s/) end | def parse
csv_emails.split(/,?\s/).uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse\n @emails.split(/[,\\s]+/).uniq\n end",
"def parse\n emails.split(/, | /).uniq\n end",
"def parse\n new_emails = emails.delete(\",\")#removes commas\n individual_emails = new_emails.split.uniq #splits emails and deletes repetes\n end",
"def parse\n\t\tparsed = @email.split(\" \")\n\t... | [
"0.8243824",
"0.818082",
"0.8139956",
"0.74992514",
"0.7387046",
"0.72988856",
"0.72714525",
"0.7242116",
"0.7057718",
"0.6876536",
"0.677349",
"0.67328537",
"0.669025",
"0.6671707",
"0.6568704",
"0.6565433",
"0.6435289",
"0.6403737",
"0.63891363",
"0.6374437",
"0.63433534",
... | 0.8912597 | 0 |
TODO: analyze and optimize for n+1 | def set_taxonomy
c = case self.class.base_class.name
when 'CollectionObject'
a = current_taxon_name
# If we have no name, see if there is a Type reference and use it as proxy
# !! Careful/TODO this is an arbitrary choice, technically can be only one primary, but not restricted in DB yet
a ||= type_materials.primary.first&.protonym
when 'Otu'
taxon_name&.valid_taxon_name
when 'AssertedDistribution'
otu.taxon_name&.valid_taxon_name
end
if c
@taxonomy = c.full_name_hash
# Check for required 'Kingdom'
if @taxonomy['kingdom'].blank?
# Det is only to kingdom!
if c.rank == 'kingdom'
@taxonomy['kingdom'] = c.name
else
# Kindom is provided in ancestors
if a = c.ancestor_at_rank(:kingdom)
@taxonomy['kingdom'] = a.name
else
# TODO: re-add when dwc_fields merged
# Very edge case for single kingom nomenclatures (almost none)
# if c.rank_class::KINGDOM.size == 1
# @taxonomy['kingdom'] = c.rank_class::KINGDOM.first
# end
end
end
end
@taxonomy
else
@taxonomy ||= {}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def series_up(n)\n #nlist is the list that will be the ou... | [
"0.6507172",
"0.6356466",
"0.6310508",
"0.6302415",
"0.6146282",
"0.60889304",
"0.6079608",
"0.6067516",
"0.603487",
"0.60213524",
"0.6020552",
"0.60118455",
"0.5997674",
"0.5951143",
"0.59481376",
"0.59479886",
"0.5944809",
"0.5941063",
"0.5940979",
"0.5916744",
"0.5909594",... | 0.0 | -1 |
Use method from previous assignment | def recursive_shuffle(sorted_array, shuffled_array)
if sorted_array == []
puts shuffled_array
else
index = rand(sorted_array.length)
shuffled_array.push sorted_array[index]
sorted_array.delete_at(index)
recursive_shuffle sorted_array, shuffled_array
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method=(_); end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def result=(_); end",
"def method=(_... | [
"0.69294155",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.64181066",
"0.62467575",
"0.62395054",
"0.62395054",
"0.62395054",
"0.61110485",
"0.610435",
"0.610435",
... | 0.0 | -1 |
Parse options into a hash, and values for each option into a hash | def initialize argv
@argv = argv.dup
@options = {}
while @argv[0] =~ /^-/
option, value = @argv.shift.split(/[=:]/, 2)
csv = (value =~ /,/ ? value.split(',') : Array(value))
modes = csv.inject({}){|h,s| k, v = s.split(/=/, 2); h[k] = v || true; h }
@options[option.sub(/^-*/,'')] = modes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n OPTIONS.each_with_object({}) do |option, hash|\n key = option.first\n hash[key] = send(key)\n end\n end",
"def options *options\n if options.size > 0\n @options = {}\n options.each do |a|\n a.is_a?(Hash) ?\n @options.update(a... | [
"0.69800967",
"0.6942315",
"0.68573385",
"0.68573385",
"0.68547577",
"0.67474693",
"0.67459047",
"0.671884",
"0.67061996",
"0.67061996",
"0.67061996",
"0.67061996",
"0.66923374",
"0.66923374",
"0.66923374",
"0.66923374",
"0.66923374",
"0.6682226",
"0.6675947",
"0.6675947",
"0... | 0.0 | -1 |
Load and enumerate all available modules in this path | def enumerate_available path
trace :loading, "Enumerating under #{path.inspect}" do
Loadable.new(path).
enumerate.
map do |filename|
begin
require(pathname = path+"/"+filename)
trace :loading, "Loaded #{pathname}"
filename
rescue LoadError => e
trace :loading, "Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}"
nil
rescue Exception => e
$stderr.puts "Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}"
nil
end
end.compact
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_load_set\n\t\teach_module { |name, mod|\n\t\t}\n\tend",
"def force_load_set\n each_module { |name, mod| }\n end",
"def load_all\n return if defined?(@loaded_all)\n\n load_env\n\n paths = search_path\n unless paths.nil?\n paths.each do |dir|\n # dir is already an absolute p... | [
"0.68327564",
"0.6683814",
"0.66455346",
"0.65846777",
"0.6568229",
"0.6529033",
"0.6516426",
"0.64313036",
"0.64112616",
"0.6368123",
"0.6342436",
"0.63367516",
"0.633323",
"0.63242227",
"0.6317007",
"0.62286586",
"0.6210072",
"0.6202401",
"0.6198187",
"0.6192364",
"0.614857... | 0.7322901 | 0 |
Ensure that the options provided are supported by the action | def check_options action, modes
if modes['help']
display_options(action)
exit
end
options = action.options
unsupported = modes.keys.select{|k| !options.has_key?(k.to_sym)}
return if unsupported.empty?
$stderr.puts "Action --#{action_name action} does not support #{unsupported.size >1 ? 'these options' : 'this option'}: #{unsupported*', '}"
display_options(action, $stderr)
exit 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end",
"def check_options(options, *supported)\n unsupported = options.to_hash.keys - supported.flatten\n raise ArgumentError, \"No such option: #{unsupported.join(' ')}\" unless unsupported.empty?\n ... | [
"0.73340464",
"0.68608904",
"0.68361694",
"0.6826834",
"0.68026775",
"0.6795942",
"0.6761635",
"0.66748357",
"0.66695917",
"0.6657211",
"0.66543394",
"0.6584291",
"0.6558994",
"0.6522699",
"0.6501757",
"0.64617807",
"0.6436773",
"0.6405904",
"0.63658416",
"0.635673",
"0.63331... | 0.71502805 | 1 |
Creates a page description on a perpage basis for analytics purposes. Given the relatively large number of Admin pages, I'll specify which pages I want to track hits for. | def page_desc(desc = '')
base_desc = "Admin"
final_desc = desc.empty? ? base_desc : desc
hit(final_desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_pages_stats\n get_admin_stats \"pages\"\n end",
"def set_admin_page_info\n @page = params[:page] || '1'\n @page_size = (params[:page_size].blank? || params[:page_size] != '1000000' ? '10' : '1000000')\n end",
"def create_pages(page)\n skip_count = 0\n page[:content].spl... | [
"0.65778047",
"0.6254516",
"0.6017957",
"0.59064573",
"0.5742053",
"0.5720931",
"0.57088524",
"0.5708816",
"0.5706068",
"0.56112057",
"0.5556109",
"0.5545617",
"0.55424243",
"0.5529206",
"0.5490053",
"0.54892164",
"0.5455769",
"0.5436854",
"0.53993046",
"0.5389953",
"0.538320... | 0.66922325 | 0 |
Renders markdown text into HTML | def markdown(text)
coderayified = CodeRayify.new(:filter_html => true,
:hard_wrap => true,
:coderay_default_lang => 'ruby'
)
options = {
:fenced_code_blocks => true,
:no_intra_emphasis => true,
:autolink => true,
}
markdown_to_html = Redcarpet::Markdown.new(coderayified, options)
markdown_to_html.render(text).html_safe
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_markdown(text)\n html_renderer.render(text).html_safe if text.present?\n end",
"def html_markup_markdown(text); end",
"def print_markdown(txt)\n Markdown::Processor.instance.render(txt)\n end",
"def markdown( text )\n Kramdown::Document.new( text ).to_html\n end",
"def markdown(text)... | [
"0.8350882",
"0.814961",
"0.7967191",
"0.79536724",
"0.78296083",
"0.7818265",
"0.78106076",
"0.7798053",
"0.7796942",
"0.7789364",
"0.77776814",
"0.7726957",
"0.77250344",
"0.7713604",
"0.7689108",
"0.767614",
"0.7645488",
"0.7614087",
"0.7588479",
"0.75860435",
"0.75860435"... | 0.7581481 | 22 |
Get permission which loging | def get_loging_permission
# Note: we want to use "find_by_id" because it's OK to return a nil.
# If we were to use User.find, it would throw an exception if the user can't be found.
if session[:user_id]
@has_permission = @current_user.role
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end",
"def permission\n return @children['permission'][:value]\n end",
"def permissions\n attribute_prop(5)\n end",
"def get_permissions (user, store_name)\n s = \"\"\n [ :read,... | [
"0.6967123",
"0.68089443",
"0.6729375",
"0.660999",
"0.65850115",
"0.65527326",
"0.6532907",
"0.6532907",
"0.65205395",
"0.6503473",
"0.64594865",
"0.6427388",
"0.64051837",
"0.63688165",
"0.6338135",
"0.6331171",
"0.63069934",
"0.6304725",
"0.6281225",
"0.6281225",
"0.625524... | 0.7362166 | 0 |
Check authentication for Admin / HR / PM | def authenticate_admin_hr_pm
unless current_user && (get_loging_permission ==1 || get_loging_permission ==2 || get_loging_permission ==3)
redirect_to sign_in_path
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_admin_hr\n unless current_user && (get_loging_permission !=1 || get_loging_permission !=2)\n redirect_to sign_in_path\n return \n end\n end",
"def checkauth?\n unless is_admin?\n flash[:privileges]=\"Not enough privileges\"\n redirect_to root_path\n end\n en... | [
"0.7639972",
"0.73113",
"0.72029835",
"0.71848065",
"0.71756196",
"0.71741647",
"0.7083109",
"0.70691967",
"0.70132554",
"0.70035195",
"0.6995198",
"0.6974658",
"0.6920009",
"0.6911564",
"0.68930984",
"0.689263",
"0.68560374",
"0.68508613",
"0.6846871",
"0.6833511",
"0.683213... | 0.8068911 | 0 |
Check authentication for Admin / HR | def authenticate_admin_hr
unless current_user && (get_loging_permission !=1 || get_loging_permission !=2)
redirect_to sign_in_path
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate_admin_hr_pm\n unless current_user && (get_loging_permission ==1 || get_loging_permission ==2 || get_loging_permission ==3)\n redirect_to sign_in_path\n return \n end\n end",
"def admin_authenticate\n authenticate and return if @logged_in.nil?\n unauthorized if !@sso_gr... | [
"0.7762533",
"0.7336168",
"0.7329252",
"0.72544",
"0.7222417",
"0.7196191",
"0.7193631",
"0.7171652",
"0.7162466",
"0.713979",
"0.7128339",
"0.7105525",
"0.7077717",
"0.70741665",
"0.7064603",
"0.70640343",
"0.70622295",
"0.7032432",
"0.70300436",
"0.7019086",
"0.7006027",
... | 0.7799225 | 0 |
Get leave name from leave id | def get_leave_name(id)
#model =LeaveType
arrLeave = LeaveType.find_by_id(id)
if arrLeave
arrLeave.leavename
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def set_leave\n @leave = Leave.find(params[:id])\n end",
"def name(id)\n @id_to_name[id]\n end",
"def name\n return text_get(0, id)\n end",
"def ... | [
"0.5874768",
"0.5874768",
"0.5874768",
"0.57983255",
"0.5777534",
"0.576531",
"0.5738638",
"0.5722997",
"0.57146114",
"0.5711607",
"0.55686426",
"0.55370986",
"0.5536249",
"0.5512361",
"0.5509547",
"0.5509547",
"0.5472566",
"0.5453169",
"0.5424773",
"0.5407437",
"0.53871626",... | 0.80015063 | 0 |
GET /pillars GET /pillars.xml | def index
@pillars = Pillar.all
respond_with(@pillars)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @paragrafs = Paragraf.all\n end",
"def index\n @peeps = Peep.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @peeps }\n end\n end",
"def index\n @pledges = current_user.pledges\n\n respond_to do |format|\n format.html #... | [
"0.60904133",
"0.5983067",
"0.59435505",
"0.5939863",
"0.59358287",
"0.5911341",
"0.59022635",
"0.5899685",
"0.5803042",
"0.5800734",
"0.5800734",
"0.57788014",
"0.57687676",
"0.5751165",
"0.5743559",
"0.57422495",
"0.57391113",
"0.5731747",
"0.5719987",
"0.57091206",
"0.5708... | 0.70026714 | 0 |
GET /pillars/1 GET /pillars/1.xml | def show
@pillar = Pillar.find(params[:id])
@comments = comments
@new_comment = comments.build
@by_year = current_member.people.select{|person| person.chart.year == resource}
@by_hour = current_member.people.select{|person| person.chart.hour == resource}
respond_with(@pillar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pillars = Pillar.all\n respond_with(@pillars)\n end",
"def index\n @parcels = Parcel.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @parcels }\n end\n end",
"def index\n @peeps = Peep.all\n\n respond_to do |format|\n ... | [
"0.65756595",
"0.5939055",
"0.5936313",
"0.59181684",
"0.58274233",
"0.58274233",
"0.58056647",
"0.5783859",
"0.5746578",
"0.5717799",
"0.5706952",
"0.57029986",
"0.5687933",
"0.5664643",
"0.5629887",
"0.5626878",
"0.5616758",
"0.56152654",
"0.55978984",
"0.55813205",
"0.5581... | 0.0 | -1 |
GET /pillars/new GET /pillars/new.xml | def new
@pillar = Pillar.new
respond_with(@pillar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end",
"def new\n @pdig = Pdig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pdig }\n end\n end",
... | [
"0.6814088",
"0.67900634",
"0.67897236",
"0.6548725",
"0.6548725",
"0.6528022",
"0.6451777",
"0.6402526",
"0.63784",
"0.6377339",
"0.6374437",
"0.6370092",
"0.63569546",
"0.63259953",
"0.6315508",
"0.6304606",
"0.63012385",
"0.6280185",
"0.6278536",
"0.6277804",
"0.62717277",... | 0.6725291 | 3 |
POST /pillars POST /pillars.xml | def create
@pillar = Pillar.new(params[:pillar])
flash[:notice] = 'Pillar was successfully created.' if @pillar.save
respond_with(@pillar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pillars = Pillar.all\n respond_with(@pillars)\n end",
"def new\n @pillar = Pillar.new\n respond_with(@pillar)\n end",
"def create\n @pallet = Pallet.new(pallet_params)\n\n respond_to do |format|\n if @pallet.save # SQL\n format.html { redirect_to @pallet, notice: 'P... | [
"0.54550916",
"0.5333818",
"0.52433676",
"0.52264136",
"0.5175935",
"0.5114153",
"0.5056882",
"0.5052415",
"0.5021995",
"0.5008667",
"0.49785462",
"0.49767965",
"0.49709728",
"0.4962728",
"0.49575803",
"0.4952955",
"0.4948321",
"0.49425936",
"0.49371022",
"0.49336588",
"0.492... | 0.6174435 | 0 |
PUT /pillars/1 PUT /pillars/1.xml | def update
@pillar = Pillar.find(params[:id])
flash[:notice] = 'Pillar was successfully updated.' if @pillar.update(params[:pillar])
respond_with(@pillar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @parcel = Parcel.find(params[:id])\n\n respond_to do |format|\n if @parcel.update_attributes(params[:parcel])\n format.html { redirect_to(@parcel, :... | [
"0.545737",
"0.5159021",
"0.51580834",
"0.51319754",
"0.5122104",
"0.51183456",
"0.51051015",
"0.50760704",
"0.5053972",
"0.5031081",
"0.4996789",
"0.49890924",
"0.4987406",
"0.49869016",
"0.49828836",
"0.4976668",
"0.4962958",
"0.4956778",
"0.49220735",
"0.49167752",
"0.4906... | 0.54851407 | 0 |
DELETE /pillars/1 DELETE /pillars/1.xml | def destroy
@pillar = Pillar.find(params[:id])
@pillar.destroy
respond_with(@pillar)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def netdev_resxml_delete( xml )\n top = netdev_resxml_top( xml )\n par = top.instance_variable_get(:@parent)\n par['delete'] = 'delete'\n end",
"def destroy\n @pdig = Pdig.find(params[:id])\n @pdig.destroy\n\n respond_to do |format|\n format.html { redirect_to(pdigs_url) }\n format.x... | [
"0.62863404",
"0.6256719",
"0.61823577",
"0.61384827",
"0.60940725",
"0.6048077",
"0.6048077",
"0.6042027",
"0.60354173",
"0.6023049",
"0.6022815",
"0.6001484",
"0.5996295",
"0.5987557",
"0.59696704",
"0.5963151",
"0.59535944",
"0.5933104",
"0.5917997",
"0.59171236",
"0.59108... | 0.6069365 | 5 |
def parameter_declarations super.merge( ) end def initialize_flavor super end | def default_order
"name"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(**opt)\n super\n end",
"def initialize(*)\n super\n apply_defaults\n end",
"def parameters=(_); end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
"def parameters; end",
... | [
"0.71921074",
"0.71412843",
"0.68893725",
"0.67841244",
"0.67841244",
"0.67841244",
"0.67841244",
"0.67841244",
"0.67841244",
"0.67841244",
"0.67841244",
"0.6766202",
"0.67617404",
"0.6752906",
"0.6739704",
"0.66647464",
"0.6608176",
"0.65617883",
"0.65617883",
"0.65581703",
... | 0.0 | -1 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.order_mailer.new_record_notification.subject | def notify_order_state(order, current_user)
@order = order
receiver = current_user.is_user? ? order.designer : order.user
subject = ""
case order.aasm_state
when "picked"
subject = "[DesignDeck] 您好,您的订单:#{order.title},设计师已接单 "
when "drafts_submitted"
subject = "[DesignDeck] 您好,您的订单:#{order.title},设计师已提交初稿 #{order.title}"
when "versions_submitted"
subject = "[DesignDeck] 您好,您的订单:#{order.title},设计师已提交新稿件 #{order.title}"
when "completed"
if current_user.is_user?
subject = "[DesignDeck] 您好,您的订单:#{order.title},最终版本文件打包已上传 #{order.title}"
else
subject = "[DesignDeck] 您好,您接的订单:#{order.title},用户已确认最终版,请上传打包文件 #{order.title}"
end
when "draft_selected"
subject = "[DesignDeck] 您好,您接的订单:#{order.title},用户已选择初稿 #{order.title}"
when "version_selected"
subject = "[DesignDeck] 您好,您接的订单:#{order.title},用户已对稿件提出修改意见 #{order.title}"
end
mail(to: receiver.email, subject: subject)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate(mapping, key)\n I18n.t(:\"notifications_subject\", :scope => [:eventifier, :notifications, key],\n :default => [:subject, key.to_s.humanize])\n end",
"def subject (recipient)\n subject_variables = alert_variables[:subject].dup\n subject_variables.merge!(recipient_deta... | [
"0.67987466",
"0.6729514",
"0.66022754",
"0.65635526",
"0.64281243",
"0.6425302",
"0.6394938",
"0.63090634",
"0.6285621",
"0.62645745",
"0.6258863",
"0.6156486",
"0.615276",
"0.61037433",
"0.6093246",
"0.60823065",
"0.6055134",
"0.6030548",
"0.6029363",
"0.60247076",
"0.60206... | 0.0 | -1 |
GET /lines GET /lines.json | def index
@lines = Line.where(user_id: current_user.id, diagram_id:@diagram.id, node_id:@node.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @lines = Line.all\n end",
"def index\n @lines = Line.all\n end",
"def show\n @line = Line.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\n end\n end",
"def get_lines_with_http_info(year, opts = {})\n ... | [
"0.6893532",
"0.6893532",
"0.6868059",
"0.67766446",
"0.6743677",
"0.6693905",
"0.6692418",
"0.66735685",
"0.6654958",
"0.6632382",
"0.6632382",
"0.6632382",
"0.6632382",
"0.65953624",
"0.657385",
"0.65404236",
"0.64684856",
"0.6458954",
"0.64464206",
"0.64360505",
"0.6344974... | 0.638006 | 20 |
GET /lines/1 GET /lines/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @line = Line.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\n end\n end",
"def show\n @line = Line.find_by_no(params[:id]) || not_found\n authorize! :index, @line\n respond_to do |format|\n format.html #... | [
"0.7350465",
"0.69085634",
"0.6770396",
"0.676088",
"0.676088",
"0.6709073",
"0.66192645",
"0.66179264",
"0.6616818",
"0.6616818",
"0.6616818",
"0.6616818",
"0.6616818",
"0.6616818",
"0.6616818",
"0.6599095",
"0.65919614",
"0.6590035",
"0.6590035",
"0.6590035",
"0.6590035",
... | 0.0 | -1 |
POST /lines POST /lines.json | def create
@line = Line.new(line_params)
@line.user = current_user
@line.diagram = @diagram
@line.node = @node
respond_to do |format|
if @result = @line.valid?
begin
Line.transaction do
@line.save!
end
format.html { redirect_to @line, notice: 'Line was successfully created.' }
format.json { render :show, status: :created, location: @line }
format.js
rescue => e
render :text => e.message
end
else
format.html { render :new }
format.json { render json: @line.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @line = Line.new(line_params)\n\n respond_to do |format|\n if @line.save\n format.html { redirect_to @line, notice: \"Line was successfully created.\" }\n format.json { render :show, status: :created, location: @line }\n else\n format.html { render :new, status: :u... | [
"0.6890656",
"0.66954935",
"0.65236425",
"0.64464235",
"0.6299703",
"0.6255913",
"0.6188846",
"0.618208",
"0.6169312",
"0.6138691",
"0.60750157",
"0.60553026",
"0.6049836",
"0.6042586",
"0.60384405",
"0.6009484",
"0.5981322",
"0.5977369",
"0.5963573",
"0.5934503",
"0.591805",... | 0.62850916 | 5 |
PATCH/PUT /lines/1 PATCH/PUT /lines/1.json | def update
@line.attributes = line_params
respond_to do |format|
if @result = @line.valid?
begin
Line.transaction do
@line.save!
end
format.html { redirect_to @line, notice: 'Line was successfully updated.' }
format.json { render :show, status: :ok, location: @line }
format.js
rescue => e
render :text => e.message
end
else
format.html { render :edit }
format.json { render json: @line.errors, status: :unprocessable_entity }
format.js
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @line = Line.find(params[:id])\n\n respond_to do |format|\n if @line.update_attributes(line_params)\n format.html { redirect_to new_line_path, notice: 'Line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render verb: \"edit\"... | [
"0.7234065",
"0.7216151",
"0.6894079",
"0.6784709",
"0.67542833",
"0.674736",
"0.66925544",
"0.657046",
"0.65592676",
"0.65592676",
"0.65592676",
"0.65592676",
"0.65592676",
"0.6534173",
"0.6532593",
"0.65191954",
"0.6452219",
"0.6441193",
"0.6441193",
"0.6441193",
"0.6418201... | 0.6505122 | 16 |
DELETE /lines/1 DELETE /lines/1.json | def destroy
Line.transaction do
@line.destroy!
end
respond_to do |format|
format.html { redirect_to node_lines_url(@node), notice: 'Line was successfully destroyed.' }
format.json { head :no_content }
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @line = Line.find_by_no(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n fo... | [
"0.77061015",
"0.7500262",
"0.7346486",
"0.7341652",
"0.71153176",
"0.7102098",
"0.70744765",
"0.70683986",
"0.70683986",
"0.70683986",
"0.70683986",
"0.7057085",
"0.7028231",
"0.7021608",
"0.7021608",
"0.7021102",
"0.6983667",
"0.6962576",
"0.6961447",
"0.69127196",
"0.68979... | 0.6908199 | 20 |
Use callbacks to share common setup or constraints between actions. | def set_line
@line = Line.find(params[:id])
@node = @line.node
@diagram = @node.diagram
head :forbidden unless @line.user_id == current_user.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 line_params
params.require(:line).permit(:next_node_id, :description)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
Video and audio maps | def maps
'-map 0:v:0 -map 1:a:0'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_audio_map\n @audio_map = AudioMap.find(params[:id])\n end",
"def autoplay\n @map.bgm.play if @map.autoplay_bgm\n @map.bgs.play if @map.autoplay_bgs\n end",
"def index\n @audio_maps = AudioMap.all\n end",
"def outputs\n VIDEO_PRESETS.map do |variant, preset_id|\n {\n ... | [
"0.578287",
"0.5758421",
"0.5686713",
"0.5617316",
"0.56066",
"0.5407417",
"0.53611636",
"0.53585345",
"0.5314072",
"0.5300821",
"0.5242607",
"0.52303183",
"0.52303183",
"0.52276653",
"0.52276653",
"0.517548",
"0.516622",
"0.5112323",
"0.5101381",
"0.51004046",
"0.509986",
... | 0.5325946 | 8 |
Complete each step below according to the challenge directions and include it in this file. Also make sure everything that isn't code is commented in the file. I worked on this challenge by myself. 1. Pseudocode 1.) I will define method as get_grade. 2.) get_grade will be passed an array of numbers and an average will be calculated 2.) When get_grade is passed an integer in the value or 90 or greater, it will return the grade of "A" 3.) When get_grade is passed an integer in the value of 80 or greater, it will return the grade of "B" 4.) When get_grade is passed an integer in the value of 70 or greater, it will return the grade of "C" 5.) When get_grade is passed an integer in the value of 60 or greater, it will return the grade of "D" 6.) When get_grade is passed an integer in the value of 50 or greater, it will return the grade of "F" 2. Initial Solution | def get_grade(grades)
sum = 0
total = grades.length
grades.each { |x| sum = (sum + x) }
average = (sum / total)
if average >= 90
return "A"
elsif average >= 80
return "B"
elsif average >= 70
return "C"
elsif average >= 60
return "D"
else
return "F"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_grade(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n avg = sum / array.length\n if (avg >= 90)\n return \"A\"\n elsif (avg >= 80)\n return \"B\"\n elsif (avg >= 70)\n return \"C\"\n elsif (avg >= 60)\n return \"D\"\n else\n return ... | [
"0.81736124",
"0.8147265",
"0.80534446",
"0.79970056",
"0.7962854",
"0.79539114",
"0.7949824",
"0.7904728",
"0.7900539",
"0.7871664",
"0.786638",
"0.7849841",
"0.7846196",
"0.7836579",
"0.78347296",
"0.78345335",
"0.782196",
"0.7819968",
"0.781589",
"0.7802494",
"0.78013605",... | 0.76040834 | 45 |
count the number of strategies in a list of strategy sets | def f(i)
str = i.to_s.reverse
str.gsub!(/([0-9]{3})/,"\\1,")
str.gsub(/,$/,"").reverse
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scenario_count\n scenarios.count\n end",
"def tag_set_count(collection)\n if collection && collection.challenge_type.present?\n if collection.challenge_type == \"GiftExchange\" && !collection.challenge.offer_restriction.owned_tag_sets.empty?\n collection.challenge.offer_restriction.own... | [
"0.6444927",
"0.61465764",
"0.605092",
"0.6015988",
"0.60053885",
"0.5993024",
"0.5990108",
"0.5988807",
"0.59882665",
"0.5980411",
"0.59530693",
"0.5952579",
"0.59278905",
"0.5925762",
"0.59106266",
"0.58890647",
"0.58679193",
"0.5840212",
"0.5816679",
"0.58164126",
"0.58097... | 0.0 | -1 |
GET /status_confirmacao_adotandos/1 GET /status_confirmacao_adotandos/1.json | def show
@status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @status_confirmacao_adotando }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])\n @status_confirmacao_adotando.destroy\n\n respond_to do |format|\n format.html { redirect_to status_confirmacao_adotandos_url }\n format.json { head :no_content }\n end\n end",
"def new\n @status_c... | [
"0.6798881",
"0.67682886",
"0.6415538",
"0.6245207",
"0.6238904",
"0.6133694",
"0.61260235",
"0.58510876",
"0.5803336",
"0.57946557",
"0.57929003",
"0.5729461",
"0.57058895",
"0.5702758",
"0.5637569",
"0.5636913",
"0.55796397",
"0.5526257",
"0.54746646",
"0.5466515",
"0.54617... | 0.73507 | 0 |
GET /status_confirmacao_adotandos/new GET /status_confirmacao_adotandos/new.json | def new
@status_confirmacao_adotando = StatusConfirmacaoAdotando.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @status_confirmacao_adotando }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @status_confirmacao_adotando = StatusConfirmacaoAdotando.new(params[:status_confirmacao_adotando])\n\n respond_to do |format|\n if @status_confirmacao_adotando.save\n format.html { redirect_to @status_confirmacao_adotando, notice: 'Status confirmacao adotando was successfully created... | [
"0.7700577",
"0.7045938",
"0.7006628",
"0.6992576",
"0.67747575",
"0.6761139",
"0.6757918",
"0.673682",
"0.66588956",
"0.66396195",
"0.65574354",
"0.6549481",
"0.64864236",
"0.6475986",
"0.6457381",
"0.6449123",
"0.64276147",
"0.6410709",
"0.6410709",
"0.64024216",
"0.639763"... | 0.80320174 | 0 |
POST /status_confirmacao_adotandos POST /status_confirmacao_adotandos.json | def create
@status_confirmacao_adotando = StatusConfirmacaoAdotando.new(params[:status_confirmacao_adotando])
respond_to do |format|
if @status_confirmacao_adotando.save
format.html { redirect_to @status_confirmacao_adotando, notice: 'Status confirmacao adotando was successfully created.' }
format.json { render json: @status_confirmacao_adotando, status: :created, location: @status_confirmacao_adotando }
else
format.html { render action: "new" }
format.json { render json: @status_confirmacao_adotando.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])\n @status_confirmacao_adotando.destroy\n\n respond_to do |format|\n format.html { redirect_to status_confirmacao_adotandos_url }\n format.json { head :no_content }\n end\n end",
"def new\n @status_c... | [
"0.65187466",
"0.6242381",
"0.6145005",
"0.56811184",
"0.56334877",
"0.56045794",
"0.55966204",
"0.54162717",
"0.5414906",
"0.54070556",
"0.53947556",
"0.5383497",
"0.53804433",
"0.5352823",
"0.5338848",
"0.5292977",
"0.527833",
"0.52715683",
"0.52467144",
"0.52284414",
"0.52... | 0.7212798 | 0 |
PUT /status_confirmacao_adotandos/1 PUT /status_confirmacao_adotandos/1.json | def update
@status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])
respond_to do |format|
if @status_confirmacao_adotando.update_attributes(params[:status_confirmacao_adotando])
format.html { redirect_to @status_confirmacao_adotando, notice: 'Status confirmacao adotando was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @status_confirmacao_adotando.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])\n @status_confirmacao_adotando.destroy\n\n respond_to do |format|\n format.html { redirect_to status_confirmacao_adotandos_url }\n format.json { head :no_content }\n end\n end",
"def create\n @statu... | [
"0.67381394",
"0.660719",
"0.64181006",
"0.612308",
"0.608795",
"0.6044028",
"0.6027289",
"0.60267776",
"0.60168463",
"0.599196",
"0.5917094",
"0.5909084",
"0.58842444",
"0.5867072",
"0.5854817",
"0.58533025",
"0.5853171",
"0.5843091",
"0.5842551",
"0.5825236",
"0.5820652",
... | 0.7507065 | 0 |
DELETE /status_confirmacao_adotandos/1 DELETE /status_confirmacao_adotandos/1.json | def destroy
@status_confirmacao_adotando = StatusConfirmacaoAdotando.find(params[:id])
@status_confirmacao_adotando.destroy
respond_to do |format|
format.html { redirect_to status_confirmacao_adotandos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @core_status_desembaraco = Core::StatusDesembaraco.find(params[:id])\n @core_status_desembaraco.destroy\n\n respond_to do |format|\n format.html { redirect_to core_status_desembaracos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oferta = Oferta.fi... | [
"0.71276647",
"0.70069736",
"0.69541144",
"0.6946211",
"0.69072247",
"0.6871635",
"0.6843806",
"0.6833212",
"0.68183196",
"0.6814677",
"0.6802107",
"0.67788863",
"0.6772625",
"0.6770297",
"0.6770256",
"0.6763505",
"0.6761648",
"0.67196405",
"0.6712868",
"0.66959196",
"0.66951... | 0.7909385 | 0 |
Returns an array specifying the players next move. Returns 1 to forfeit the game | def ask_for_move(map:)
puts "AI deciding its next move, hit <enter> to continue"
gets.chomp
frontier = generate_frontier(map: map)
choose_move_from_frontier(frontier: frontier)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player_no\n\t\twhile @player_order.first && @skip_next_move[@player_order.first - 1] do\n\t\t\t@skip_next_move[@player_order.first - 1] = false\n\t\t\t@player_order.push(@player_order.first)\n\t\t\t@player_order.shift\n\t\tend\n\t\t@player_order.first\n\tend",
"def next_turn\n # Changes the turn to t... | [
"0.7665919",
"0.76012355",
"0.76012355",
"0.75350034",
"0.7404676",
"0.7291928",
"0.72302383",
"0.719722",
"0.7184578",
"0.71559304",
"0.7065957",
"0.70519567",
"0.7049284",
"0.68443775",
"0.6823378",
"0.68066335",
"0.67853427",
"0.6773767",
"0.673398",
"0.6702923",
"0.667518... | 0.0 | -1 |
Custom actions Agree with an identification | def agree
unless @observation = Observation.find_by_id(params[:observation_id])
render_404
return
end
@old_identification = @observation.identifications.by(current_user).current.last
if @old_identification && @old_identification.taxon_id == params[:taxon_id].to_i
@identification = @old_identification
else
@identification = Identification.new(
:user => current_user,
:taxon_id => params[:taxon_id].to_i,
:observation_id => params[:observation_id]
)
end
respond_to do |format|
duplicate_key_violation = false
begin
@identification.save
rescue PG::Error, ActiveRecord::RecordNotUnique => e
raise e unless e =~ /index_identifications_on_current/
duplicate_key_violation = true
end
if @identification.valid? && duplicate_key_violation == false
format.html { agree_respond_to_html }
format.json do
@identification.html = view_context.render_in_format(:html, :partial => "identifications/identification")
render :json => @identification.to_json(:methods => [:html])
end
else
format.html { agree_respond_to_html_failure }
format.json do
render :status => :unprocessable_entity, :json => {:errors => @identification.errors.full_messages }
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invite\n \n end",
"def sell_confirmed\n end",
"def action args = {}\n\t\tend",
"def edit_identity hash = {}\n organise hash.update :action => 'edit_identity'\n end",
"def proceed\n identity = identifier(current_account)\n if @site = current_account.sites.find_by_url(checkid_request.trust... | [
"0.5969674",
"0.582627",
"0.5825941",
"0.58073735",
"0.57787836",
"0.5771823",
"0.5607765",
"0.5594894",
"0.5587383",
"0.55518305",
"0.5545893",
"0.55244374",
"0.5521161",
"0.5521161",
"0.5521161",
"0.5521161",
"0.5521161",
"0.55118185",
"0.5505882",
"0.5497579",
"0.54967964"... | 0.0 | -1 |
The `Patient` class needs an instance method, `appointments`, that iterates through the `Appointment`s array and returns `Appointment`s that belong to the patient. | def appointments
Appointment.all.select do |appointment|
appointment.patient == self
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patients\r\n appointments.map { |s|s.patient }\r\n end",
"def patients\n appointments.collect { |appt| appt.patient }\n end",
"def patients\n appointments.map do |appointment|\n appointment.patient\n end\n end",
"def patients\n @appointments.collect do |appt|\n appt.patient\n ... | [
"0.8559272",
"0.85038257",
"0.8478892",
"0.8369062",
"0.835792",
"0.8265583",
"0.8264936",
"0.82638687",
"0.8191821",
"0.8179461",
"0.810955",
"0.8016381",
"0.78824013",
"0.78185356",
"0.7750108",
"0.7709843",
"0.7688578",
"0.76801044",
"0.7661574",
"0.7623474",
"0.757949",
... | 0.7786111 | 15 |
The `Patient` class needs an instance method, `doctors`, that iterates over that patient's `Appointment`s and collects the doctor that belongs to each `Appointment`. | def doctors
self.appointments.map do |appointment|
appointment.doctor
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doctors\n appointments.map do |appointment|\n appointment.doctor\n end\n end",
"def doctors\n appointments.map do |appointment|\n appointment.doctor\n end\n end",
"def doctors\n @appointments.collect do |appointment|\n appointment.doctor\n end\n end",
"def doctors\n ... | [
"0.8461436",
"0.8461436",
"0.84588975",
"0.8451749",
"0.8450108",
"0.8404329",
"0.8294901",
"0.8160148",
"0.8060073",
"0.80390704",
"0.7999302",
"0.779696",
"0.775942",
"0.7715665",
"0.7707217",
"0.76978815",
"0.7696798",
"0.768852",
"0.7687822",
"0.7677159",
"0.76730007",
... | 0.83500934 | 6 |
Set error on span in Otel without a corresponding exception | def set_error_status(error_message, attributes: {})
current_span = OpenTelemetry::Trace.current_span
current_span.status = OpenTelemetry::Trace::Status.error(error_message)
add_attributes(current_span, attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_error(span, exception)\n raise NotImplementedError\n end",
"def form_error_span\n\t\t@browser.span(id: @form_error)\n\tend",
"def bold_error(*args); end",
"def error_message_field\n { :tag => 'span', :attributes => { :class => 'fielderror' } }\n end",
"def missing_field( err = '... | [
"0.74503285",
"0.6894604",
"0.6349836",
"0.6264364",
"0.62555313",
"0.6253921",
"0.62031865",
"0.61859447",
"0.6132759",
"0.6132759",
"0.61265063",
"0.61221355",
"0.6120461",
"0.610894",
"0.61074376",
"0.61074376",
"0.61074376",
"0.61074376",
"0.61074376",
"0.61074376",
"0.61... | 0.5691294 | 83 |
Set error on span in Otel with a corresponding exception | def record_exception(e = nil, error_message = nil, attributes: {})
current_span = OpenTelemetry::Trace.current_span
current_span.status = OpenTelemetry::Trace::Status.error(error_message || e.message)
current_span.record_exception(e, attributes: format_attributes(attributes))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_error(span, exception)\n raise NotImplementedError\n end",
"def form_error_span\n\t\t@browser.span(id: @form_error)\n\tend",
"def bold_error(*args); end",
"def err(cod)\n @st = :err\n @ie = cod\n end",
"def error_message_field\n { :tag => 'span', :attributes => { :clas... | [
"0.7728452",
"0.6810411",
"0.6540813",
"0.6424159",
"0.6412473",
"0.6366621",
"0.6315627",
"0.6282109",
"0.62765884",
"0.6234137",
"0.6234137",
"0.62067",
"0.6193876",
"0.6191568",
"0.61804026",
"0.6148353",
"0.6132693",
"0.6100118",
"0.60849285",
"0.6079287",
"0.60646886",
... | 0.0 | -1 |
GET /consultors GET /consultors.json | def index
@consultors = Consultor.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @consultant = Consultant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consultant }\n end\n end",
"def show\n @consulta = Consulta.find(params[:id])\n\n render json: @consulta\n end",
"def show\n @consultum = Co... | [
"0.70207036",
"0.67798877",
"0.6774037",
"0.64065063",
"0.6366524",
"0.6291893",
"0.62912387",
"0.62392646",
"0.62392646",
"0.6092597",
"0.6091288",
"0.60668135",
"0.60484004",
"0.60459524",
"0.6000204",
"0.599409",
"0.59913945",
"0.596019",
"0.5929306",
"0.59074026",
"0.5886... | 0.74911803 | 1 |
GET /consultors/1 GET /consultors/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @consultors = Consultor.all\n end",
"def index\n @consultors = Consultor.all\n end",
"def show\n @consultant = Consultant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consultant }\n end\n end",
"def show\n ... | [
"0.72919476",
"0.72919476",
"0.72917616",
"0.71759915",
"0.7097168",
"0.68011004",
"0.655147",
"0.65242237",
"0.65242237",
"0.6463062",
"0.63826764",
"0.6344811",
"0.6282968",
"0.6281735",
"0.6270133",
"0.62612104",
"0.62371314",
"0.6216974",
"0.6131923",
"0.6127547",
"0.6127... | 0.0 | -1 |
POST /consultors POST /consultors.json | def create
@consultor = Consultor.new(consultor_params)
respond_to do |format|
if @consultor.save
format.html { redirect_to @consultor, notice: 'Consultor was successfully created.' }
format.json { render :show, status: :created, location: @consultor }
else
format.html { render :new }
format.json { render json: @consultor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @consultor = Consultor.new(consultor_params)\n\n respond_to do |format|\n if @consultor.save\n format.html { redirect_to @consultor, notice: 'Consultor was successfully created.' }\n format.json { render action: 'show', status: :created, location: @consultor }\n else\n ... | [
"0.725994",
"0.7172065",
"0.6930274",
"0.68663794",
"0.6767447",
"0.6678117",
"0.6558745",
"0.650226",
"0.650226",
"0.6433249",
"0.641408",
"0.62136483",
"0.6197956",
"0.61766666",
"0.6082282",
"0.607946",
"0.59429854",
"0.59429854",
"0.59315324",
"0.5890548",
"0.5869616",
... | 0.731003 | 0 |
PATCH/PUT /consultors/1 PATCH/PUT /consultors/1.json | def update
respond_to do |format|
if @consultor.update(consultor_params)
format.html { redirect_to @consultor, notice: 'Consultor was successfully updated.' }
format.json { render :show, status: :ok, location: @consultor }
else
format.html { render :edit }
format.json { render json: @consultor.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @consultum = Consultum.find(params[:id])\n\n respond_to do |format|\n if @consultum.update_attributes(params[:consultum])\n format.html { redirect_to @consultum, notice: 'Consultum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.6835088",
"0.6810831",
"0.6795562",
"0.6715134",
"0.6497672",
"0.64747185",
"0.64610505",
"0.6442635",
"0.6415019",
"0.6368498",
"0.6368498",
"0.63356215",
"0.63178587",
"0.62513447",
"0.62361777",
"0.6225963",
"0.6111825",
"0.6110636",
"0.60699743",
"0.6069428",
"0.606942... | 0.6893576 | 0 |
DELETE /consultors/1 DELETE /consultors/1.json | def destroy
@consultor.destroy
respond_to do |format|
format.html { redirect_to consultors_url, notice: 'Consultor was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @consultor.destroy\n respond_to do |format|\n format.html { redirect_to consultors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @consultum = Consultum.find(params[:id])\n @consultum.destroy\n\n respond_to do |format|\n format.html { redirec... | [
"0.7684298",
"0.7458699",
"0.73587006",
"0.73587006",
"0.71824473",
"0.7115068",
"0.70885843",
"0.70830476",
"0.70473963",
"0.70361686",
"0.7014428",
"0.7007167",
"0.70061684",
"0.6989662",
"0.6989662",
"0.6868257",
"0.6850494",
"0.68304163",
"0.67870116",
"0.6776639",
"0.669... | 0.74443173 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_consultor
@consultor = Consultor.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def consultor_params
params.require(:consultor).permit(:nome, :telefone, :email)
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.69780594",
"0.678054",
"0.6742781",
"0.67387927",
"0.67346025",
"0.6590683",
"0.6501642",
"0.6495788",
"0.6479752",
"0.64763314",
"0.645457",
"0.6437739",
"0.6377168",
"0.6372484",
"0.6363871",
"0.63179374",
"0.62981373",
"0.6297456",
"0.62916917",
"0.6290227",
"0.628954",... | 0.0 | -1 |
def self.publidados Ariticle.where(state: "published") end custom setter o atributo virtual | def categories=(value)
@categories = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_published_state; end",
"def published!\n self.update_attribute(:status, PUBLISHED)\n end",
"def publish!\n self.update_attribute(:published, true)\n end",
"def publish\n self.published = true\n end",
"def set_published_at\n self.published_at ||= Time.now if status_id == STATUSES.inde... | [
"0.7273453",
"0.6345233",
"0.63156825",
"0.63032097",
"0.62173235",
"0.6205804",
"0.6170852",
"0.6115834",
"0.6115834",
"0.6092728",
"0.60060966",
"0.59345496",
"0.59339774",
"0.5850126",
"0.58336174",
"0.5798399",
"0.5792341",
"0.5774424",
"0.57707417",
"0.57594246",
"0.5759... | 0.0 | -1 |
I worked on this challenge by myself This challenge took me [] hours. Pseudocode =begin Input: a sentence (i.e. a string of words) Output: a string (i.e., the input sentence, but with each word reversed) steps: identify how many words are in the input array by looking for breaks (spaces) between words. iterate over the individual words, reversing the order of characters in each one. =end Initial Solution def reverse_words(input_string) array_string = input_string.split output = array_string.map! do |word| word.reverse end output.join(" ") end input_string = "Hello this is a string" p reverse_words(input_string) Refactored Solution | def reverse_words(sentence)
sentence.split.map! { |word| word.reverse }.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_words(input_string)\n string_array = input_string.split(\" \")\n return_string = \"\"\n string_array.each do |word|\n word_array = word.split(//)\n\n for i in 0...(word_array.length/2)\n temp = word_array[i]\n word_array[i] = word_array[((word_array.... | [
"0.85965437",
"0.84978324",
"0.8484303",
"0.8412838",
"0.8406208",
"0.8403844",
"0.8401595",
"0.8400209",
"0.8371087",
"0.83582145",
"0.8355482",
"0.8346589",
"0.83052254",
"0.83007747",
"0.8291748",
"0.82882375",
"0.8286593",
"0.8285887",
"0.8285046",
"0.8285046",
"0.8273328... | 0.0 | -1 |
Creates an NS record delegating k8s. to its proper name servers. | def str2id(s)
s.id.delete('/hostedzone/')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_domain_record_ns(params)\n post('dns/recordns', params)\n end",
"def create\n name, type = resource[:name].split('/')\n rdata = resource[:rdata]\n ttl = resource[:ttl]\n case type\n when 'MX'\n Array(rdata).each_with_index do |exchange, index|\n preference = Array(resou... | [
"0.6738121",
"0.6572863",
"0.6327784",
"0.5984496",
"0.5951251",
"0.59308404",
"0.58528346",
"0.580543",
"0.5757596",
"0.5692784",
"0.5682873",
"0.56778014",
"0.56566495",
"0.56135154",
"0.55904907",
"0.55648726",
"0.55607706",
"0.55131674",
"0.54372615",
"0.5401427",
"0.5390... | 0.0 | -1 |
defines a function proc with the given name | def define_function(name, &block)
functions[name.to_sym] = block
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_function(name)\n call \"_#{name}\"\n end",
"def define method_name, &block\n machine.named_procs[method_name] = block\n end",
"def fn(name, &block)\n if block_given?\n @fns[name] = block\n else\n @fns[name]\n end\n end",
"def fn(name, &block)\n if bloc... | [
"0.7072815",
"0.700167",
"0.6670196",
"0.6670196",
"0.66388786",
"0.6576613",
"0.64992154",
"0.6460084",
"0.6441716",
"0.64121747",
"0.63856775",
"0.6326809",
"0.6320515",
"0.6305071",
"0.62309486",
"0.6214917",
"0.6206789",
"0.61915183",
"0.61758083",
"0.6148266",
"0.6146622... | 0.65695244 | 6 |
Has this block options? | def options?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def options_ok?\n end",
"def has_options?\n properties.include?(\"has_options\")\n end",
"def called_options?()\n @@called_options\n end",
"def options?\n non_empty?(@config.options)\n end",
"def options?\n options.is_a?(Hash)\n end",
"def has_options?\n bounty_e... | [
"0.7397051",
"0.7273841",
"0.71531844",
"0.7141199",
"0.6987171",
"0.6968128",
"0.6953142",
"0.6884726",
"0.6876823",
"0.675393",
"0.6680509",
"0.66645783",
"0.6626594",
"0.65629834",
"0.6528296",
"0.6505881",
"0.64934367",
"0.64854354",
"0.6480657",
"0.6449",
"0.6440474",
... | 0.67992043 | 9 |
Reads a String or a IO to populate the object | def read(str_or_io)
io = to_io(str_or_io)
return self if io.eof?
self[:type].read io.read(4)
self[:block_len].read io.read(4)
self[:orig_len].read io.read(4)
data_len = compute_data_len
self[:data].read io.read(data_len)
remove_padding(io, data_len)
read_blocklen2_and_check(io)
self.type ||= PcapNG::IDB_TYPE.to_i
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_string; end",
"def read_string\n raise NotImplementedError\n end",
"def read(options={})\n self.open(options) {|f|\n str = f.read\n Meta.init str, f\n str\n }\n end",
"def read(str)\n PacketGen.force_binary(str)\n io = StringIO.new(str)\n ... | [
"0.7006851",
"0.7000546",
"0.6767933",
"0.6687394",
"0.6680261",
"0.66611576",
"0.6655137",
"0.6500439",
"0.6484848",
"0.6475755",
"0.6460343",
"0.6403039",
"0.63955146",
"0.6387911",
"0.626388",
"0.625749",
"0.62298465",
"0.62277585",
"0.62202376",
"0.6213668",
"0.6213668",
... | 0.5930226 | 58 |
Return the object as a String | def to_s
pad_field :data
recalc_block_len
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n object.to_s\n end",
"def to_s\n @object.to_s\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def to_s\n @string || @object.to_s('F')\n end",
"def serialize(object)\n object.to_s\n end",
"def to_s\n \"#<#{self.class.name}:#{object_i... | [
"0.8910257",
"0.8874865",
"0.8379805",
"0.8379805",
"0.8175321",
"0.8057427",
"0.7986625",
"0.798603",
"0.7943571",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
"0.793154",
... | 0.0 | -1 |
Take care of IDB snaplen CAUTION: snaplen == 0 > no capture limit | def compute_data_len
if interface && interface.snaplen.to_i.positive?
[self[:orig_len].to_i, interface.snaplen.to_i].min
else
self[:orig_len].to_i
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dbsize; end",
"def dbsize; end",
"def snap()\n \n end",
"def snap()\n @snap_id += 1\n @snap[@snap_id] = @current.clone\n @snap_id\n end",
"def snapshot_every_n_requests=(_arg0); end",
"def snap_type; self[:snap_type].to_i; end",
"def snap()\n @snaps << @changes.clone\... | [
"0.6142088",
"0.6142088",
"0.5675269",
"0.55753326",
"0.557165",
"0.5569999",
"0.5515771",
"0.5450264",
"0.5449271",
"0.535898",
"0.5345605",
"0.5288072",
"0.52537596",
"0.522714",
"0.51755035",
"0.51570594",
"0.51326585",
"0.51302844",
"0.5122443",
"0.51147103",
"0.5101417",... | 0.48007566 | 52 |
START Pictures Action Tests | def test_show
get :show,
:id => pictures(:by_quentin).id
assert_response :success
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_show_image\n\t\t#get :show, :path => 'photo1.jpg'\n\t\t#assert_response :success \n\tend",
"def test_ID_25836_edit_profile_pic_01\n login_as_user1\n go_to_edit_profile_page\n file_upload \"valid.jpg\"\n verify_valid_profile_pic_uploaded\n end",
"def begin_lights_test\n puts 'Invoker: s... | [
"0.63058025",
"0.6091991",
"0.608692",
"0.60396576",
"0.6008492",
"0.59777373",
"0.59538764",
"0.58958256",
"0.58797854",
"0.5860378",
"0.5858834",
"0.5818659",
"0.58133537",
"0.58013123",
"0.5775154",
"0.57397044",
"0.5731271",
"0.56968987",
"0.56567454",
"0.56457675",
"0.56... | 0.57197577 | 17 |
END Pictures Action Tests START Pictures Defect Tests | def test_show_nonexistent_picture
assert_raise(ActiveRecord::RecordNotFound) {
get :show,
:id => 99
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ID_25836_edit_profile_pic_01\n login_as_user1\n go_to_edit_profile_page\n file_upload \"valid.jpg\"\n verify_valid_profile_pic_uploaded\n end",
"def test_ID_25836_edit_profile_pic\n login_as_user1\n go_to_edit_profile_page\n verify_valid_profile_pic_uploaded \"valid\"\n verify_u... | [
"0.6565921",
"0.6333085",
"0.6311111",
"0.6266393",
"0.62339664",
"0.6232921",
"0.62198585",
"0.6185582",
"0.61564195",
"0.6131533",
"0.61177486",
"0.61144197",
"0.6080509",
"0.6036358",
"0.6022529",
"0.60179996",
"0.60138714",
"0.60082",
"0.59895384",
"0.598428",
"0.5978919"... | 0.0 | -1 |
Generate elements of any type with block | def rand_array(size: rand(1..MAX_LEN))
Array.new(size) {yield}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_registered_block(type, &block); end",
"def new_block_el(*args); end",
"def generators(&blk); end",
"def generators(&blk); end",
"def generate_next\n @block.call(@so_far)\n end",
"def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @bl... | [
"0.68249863",
"0.6732803",
"0.6476451",
"0.6476451",
"0.63125455",
"0.63025975",
"0.6281606",
"0.6220806",
"0.6169639",
"0.6151574",
"0.611384",
"0.61111134",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
"0.6040056",
... | 0.0 | -1 |
doi "10.1093/nar/gkh340", "10.1186/147121055113" tag "bioinformatics" tag origin homebrewscience tag derived | def install
# Fix build per Makefile instructions
inreplace "Makefile", "-static", ""
system "make"
bin.install "muscle"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_doi(doi)\n doi = doi.downcase.gsub('doi:','').gsub('http://','').gsub('dx.doi.org/','').gsub('doi>','').gsub('doi ','').strip\n url = \"http://dx.doi.org/#{doi}\"\n return open(url, \"Accept\" => \"text/bibliography; style=bibtex\").read\nend",
"def citing_doi\n\tif @citing_node.nil?\n\t {}\n\tels... | [
"0.67594737",
"0.6416282",
"0.6071689",
"0.6060078",
"0.5941725",
"0.5941725",
"0.58985317",
"0.5767961",
"0.5727062",
"0.57124996",
"0.5677987",
"0.56681406",
"0.5651267",
"0.5583521",
"0.5567794",
"0.5547246",
"0.55240417",
"0.5515535",
"0.5474985",
"0.5384703",
"0.535762",... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.