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 |
|---|---|---|---|---|---|---|
Merge links based on the provided attribue to one link by combining the values. The first link will be updated and the obsolete links are deleted and will be returned | def merge_links_on(attribute, concat_string = ',')
links_group_by(attribute)
.select { |key, link_list| links.size > 1 }
.map do |key, link_list|
merge_attributes = Link::ATTRS - [attribute]
link_list.first
.update(Hash[extract_columns(link_list, merge_attributes)
.map { |c| c.uniq.join(concat_string) }
.collect { |v| [merge_attributes.shift, v] }])
link_list.shift
link_list.each { |link| links.delete(link) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def links_duplicate_on(attribute, separator)\n links.map do |link|\n link.send(attribute).split(separator).collect do |value|\n link.dup.update(Hash[attribute, value])\n end\n end.flatten\n end",
"def links_group_by(attribute, linkz = links)\n linkz.map { |link| { k... | [
"0.67300624",
"0.5892039",
"0.57265204",
"0.57170516",
"0.56841004",
"0.5675346",
"0.5667954",
"0.552701",
"0.55245966",
"0.54597044",
"0.5459626",
"0.5449457",
"0.5447379",
"0.5322642",
"0.52903587",
"0.5281846",
"0.52752876",
"0.5264464",
"0.5255046",
"0.52191734",
"0.51897... | 0.7790461 | 0 |
Groups the links on the provided attribute. If no links array is provided the links from self are used | def links_group_by(attribute, linkz = links)
linkz.map { |link| { key: link.send(attribute), link: link } }
.group_by { |entry| entry[:key] }
.each { |key, link| link.map! { |l| l[:link] }}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_links_on(attribute, concat_string = ',')\n links_group_by(attribute)\n .select { |key, link_list| links.size > 1 }\n .map do |key, link_list| \n merge_attributes = Link::ATTRS - [attribute]\n link_list.first\n .update(Hash[extract_colum... | [
"0.7047207",
"0.7033148",
"0.6494589",
"0.6442318",
"0.6316675",
"0.6301108",
"0.6301108",
"0.62618494",
"0.6206597",
"0.6140449",
"0.6079296",
"0.60771763",
"0.60771763",
"0.60771763",
"0.5947005",
"0.5944945",
"0.5903296",
"0.58844495",
"0.58785987",
"0.5834544",
"0.5829364... | 0.78843886 | 0 |
Groups the links on the provided attribute. If the attribute's value contains the provided separator, the value is split up and each of the values is used as group key | def links_group_by_separated(attribute, separator)
links_group_by(attribute, links_duplicate_on(attribute, separator))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def links_duplicate_on(attribute, separator)\n links.map do |link|\n link.send(attribute).split(separator).collect do |value|\n link.dup.update(Hash[attribute, value])\n end\n end.flatten\n end",
"def links_group_by(attribute, linkz = links)\n linkz.map { |link| { k... | [
"0.7209345",
"0.70819247",
"0.69402635",
"0.6790765",
"0.6052833",
"0.6040942",
"0.56788397",
"0.5547922",
"0.5515898",
"0.55039525",
"0.53730845",
"0.5370734",
"0.5358011",
"0.52397287",
"0.523127",
"0.5194748",
"0.51419896",
"0.51263756",
"0.511681",
"0.51120263",
"0.510387... | 0.8568337 | 0 |
Create multiple Links based on the attribute provided. The specified spearator will splitt the attribute value in distinct values and for each different value a Link will be created | def links_duplicate_on(attribute, separator)
links.map do |link|
link.send(attribute).split(separator).collect do |value|
link.dup.update(Hash[attribute, value])
end
end.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_attribute_list(attribute, separator = nil)\n links.map {|link| link.send(attribute).split(separator)}.flatten.uniq.sort\n end",
"def merge_links_on(attribute, concat_string = ',')\n links_group_by(attribute)\n .select { |key, link_list| links.size > 1 }\n .map do |key, l... | [
"0.64542395",
"0.63775426",
"0.636507",
"0.6291467",
"0.6144503",
"0.59896106",
"0.596741",
"0.5905394",
"0.580128",
"0.5676942",
"0.56404126",
"0.56242275",
"0.5576618",
"0.5538052",
"0.55129176",
"0.55090517",
"0.5487199",
"0.54685205",
"0.54665613",
"0.54513675",
"0.538629... | 0.7174124 | 0 |
Return an array of all link values as rows | def rows
links.map { |link| link.row }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def links\n @links.values\n end",
"def get_values\n data = []\n rows = text_range.to_s.split(/\\<\\/tr>/)\n rows.each_with_index do |row, row_i|\n cells = row.split(/\\<\\/td>/)\n row_data = []\n cells.each_with_index do |cell, cell_i|\n datum = cell.sub('</a>... | [
"0.6483877",
"0.6429069",
"0.603671",
"0.6009847",
"0.6004347",
"0.6001252",
"0.59963286",
"0.59733826",
"0.5964714",
"0.5961859",
"0.59537923",
"0.59466726",
"0.5942035",
"0.58889484",
"0.58887583",
"0.5839805",
"0.5821074",
"0.58192897",
"0.57346374",
"0.57065535",
"0.56957... | 0.8204305 | 0 |
List all attributes of the links | def link_attribute_list(attribute, separator = nil)
links.map {|link| link.send(attribute).split(separator)}.flatten.uniq.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_all_links_attributes\n # Interface method\n end",
"def link_attributes\n [:accesskey, :charset, :coords, :hreflang, :id, :lang, :name, :onblur,\n :onclick, :ondblclick, :onfocus, :onkeydown, :onkeypress, :onkeyup,\n :onmousedown, :onmousemove, :onmouseout, :onmouseover, :onmous... | [
"0.8158241",
"0.7704157",
"0.7388222",
"0.71210676",
"0.68836266",
"0.6841157",
"0.68146527",
"0.679153",
"0.6788709",
"0.6759208",
"0.6759208",
"0.66857105",
"0.66715634",
"0.66553456",
"0.6626134",
"0.6572911",
"0.65511525",
"0.65402806",
"0.65314376",
"0.65250146",
"0.6515... | 0.634019 | 29 |
start this worker using: ImportldWorker.perform_async() | def machine_hash(headers,rows)
# This is just to give a nice data structure (a hash of )
rows.each_with_index.map do |row, index|
# todo - rearrange the hash so it is sorted - do we need the row index?
Hash[headers.each_with_index.map { |header, pos|
[header, row[pos] ]}
].merge('row' => index+2)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import!\n # start_async provided by Asyncable module\n return start_async if run_async?\n process_now\n end",
"def async_operation\n run_importer\n end",
"def import!\n t = Thread.new do\n begin\n do_import\n rescue Exception => ex\n Rails.logger.err... | [
"0.72841895",
"0.70909524",
"0.66533697",
"0.65030366",
"0.6470002",
"0.6420829",
"0.625338",
"0.62069803",
"0.60654736",
"0.5964911",
"0.59526515",
"0.5946448",
"0.592457",
"0.5907163",
"0.59027636",
"0.5890287",
"0.5881132",
"0.5847451",
"0.5827813",
"0.5822368",
"0.5813345... | 0.0 | -1 |
Subclasses can override this method to parse additional options beyond the standard set. | def parse_additional_options(opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_options; end",
"def parse_options; end",
"def parse!() options.parse!(self) end",
"def parse_options=(_arg0); end",
"def parse_options=(_arg0); end",
"def parse_options(opts, args); end",
"def _process_options(options); end",
"def _process_options(options); end",
"def options(opt); end",
... | [
"0.8383494",
"0.8383494",
"0.7835524",
"0.7276684",
"0.7276684",
"0.7192962",
"0.7148976",
"0.7148976",
"0.7046408",
"0.70437264",
"0.69123644",
"0.69123644",
"0.69123644",
"0.6870893",
"0.6820842",
"0.6789092",
"0.6783841",
"0.67599016",
"0.67589116",
"0.6747416",
"0.6690396... | 0.769735 | 4 |
Subclasses should return the action name for the help banner | def action_name
"<encrypt|decrypt|read|edit>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apphelp_heading( ctrl = controller, action = nil, default = nil )\n action ||= ctrl.action_name\n\n t(\n \"uk.org.pond.canvass.controllers.#{ ctrl.controller_name }.action_title_#{ action }\",\n :default => default\n )\n end",
"def apphelp_action_name( action, use_default = false )\n o... | [
"0.78540176",
"0.73928285",
"0.7391516",
"0.7158857",
"0.7018628",
"0.6993531",
"0.698538",
"0.6965358",
"0.6960322",
"0.6944226",
"0.69115204",
"0.69115204",
"0.6891898",
"0.68663424",
"0.68642086",
"0.6852588",
"0.6852588",
"0.6852588",
"0.6852588",
"0.6852588",
"0.6852588"... | 0.0 | -1 |
Subclasses must implement this method to execute the logic. | def run!
raise NotImplementedError
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n raise NotImplementedError.new('Must override')\n end",
"def execute\n end",
"def execute\n end",
"def perform\n \n end",
"def execute\n self.started\n self.execute_internal\n self.finished\n end",
"def execute; end",
"def execute; en... | [
"0.7671873",
"0.765174",
"0.765174",
"0.7214063",
"0.7191833",
"0.71316636",
"0.71316636",
"0.71261",
"0.7091385",
"0.7091385",
"0.7039809",
"0.7034491",
"0.70275974",
"0.7026976",
"0.7015942",
"0.70113605",
"0.6964066",
"0.69613653",
"0.6894135",
"0.68529737",
"0.6852916",
... | 0.6432178 | 53 |
Return the output format. | def format
return @format if [:json, :yaml].include?(@format)
secrets.input_format
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_format\n settings[:output_format]\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def format\n return @format\n end",
"def format\n @format\n end",
"def form... | [
"0.86571485",
"0.78989714",
"0.78989714",
"0.78989714",
"0.7647354",
"0.75676167",
"0.7480415",
"0.73922396",
"0.7338724",
"0.7338724",
"0.7248929",
"0.7248929",
"0.7248929",
"0.7248929",
"0.7248929",
"0.7248929",
"0.7248929",
"0.7248929",
"0.72083896",
"0.72061604",
"0.71553... | 0.6329716 | 62 |
Mark that you want to use stdin and raise an exception if it's already been used. | def can_i_haz_stdin!
raise ArgumentError, "stdin (-) cannot be specified multiple times" if @stdin_used
@stdin_used = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stdin!(stdin)\n @stdin = stdin\n self\n end",
"def exit_pretend_user_input\n $stdin = STDIN\nend",
"def with_stdin\n stdin = $stdin\n $stdin, write = IO.pipe\n yield write\nensure\n write.close\n $stdin = stdin\nend",
"def feed_stdin(str)\n old_stdin = $stdin\n $stdin = Stri... | [
"0.7156818",
"0.71262616",
"0.6788906",
"0.66727614",
"0.66703266",
"0.6551462",
"0.6295386",
"0.61591655",
"0.6125575",
"0.6125575",
"0.6098941",
"0.60499394",
"0.60273015",
"0.6015149",
"0.58483684",
"0.58328414",
"0.5831816",
"0.5798967",
"0.5795052",
"0.57116383",
"0.5674... | 0.79393625 | 0 |
Determines if the ledger can be conciliated or nulled | def can_conciliate_or_null?
!(nuller_id.present? || approver_id.present?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_consumable?\n true\n end",
"def null_config?\n actual_config.base_currency.nil? || actual_config.currency_rates.nil?\n end",
"def valid?\n acyclic? and connected?\n end",
"def minimal_charge_enabled?\n minimal_charge != 0\n end",
"def has_bridge?\r\n not @bridges.empty?\r\... | [
"0.6465277",
"0.63448155",
"0.6259447",
"0.6233344",
"0.6162302",
"0.6091201",
"0.6048049",
"0.60303116",
"0.59993446",
"0.5997734",
"0.59807295",
"0.59759563",
"0.59466183",
"0.5941523",
"0.5926792",
"0.585824",
"0.5828116",
"0.58205736",
"0.5797997",
"0.5786325",
"0.5783781... | 0.6623659 | 1 |
Verifico si el Medidor al que pertenece el estado, es de energia reactiva | def es_medidor_de_energia_reactiva
medidor_id = MedidorEstadoMedidor.where(estado_medidor_id: self.id).take.medidor_id
medidor = Medidor.find(medidor_id)
return medidor.tipo_medidor.codigo == 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energized?\n @cur_energy > 0\n end",
"def revolution_per_meter? = unit == 'revolution-per-meter'",
"def past_step_2?\n !spectator? && status_is_active?(\"events\")\n end",
"def set_is_recorded\n write_attribute(:is_recorded, !exercise_minutes.to_i.zero? || !exercise_steps.to_i.zero? || self.en... | [
"0.6492438",
"0.5864758",
"0.5692867",
"0.55882525",
"0.55780554",
"0.55420303",
"0.5530164",
"0.55298436",
"0.55294484",
"0.55100954",
"0.5505155",
"0.55001956",
"0.549322",
"0.54898816",
"0.54870045",
"0.5481236",
"0.5476788",
"0.54651594",
"0.54651594",
"0.54544574",
"0.54... | 0.7939472 | 0 |
Seteo el periodo "mes/anio" | def set_periodo
self.periodo = "#{self.fecha_medicion.month}/#{self.fecha_medicion.year}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def period=(value)\n @period = value\n end",
"def frecuencia_pago_intermediario_w\n case self.frecuencia_pago_intermediario\n when 1\n I18n.t('Sistema.Body.General.Periodos.mensual')\n when 3\n I18n.t('Sistema.Body.Gener... | [
"0.62965125",
"0.6242815",
"0.62229675",
"0.61014354",
"0.6084683",
"0.6084683",
"0.6084683",
"0.60129595",
"0.58583754",
"0.57750285",
"0.5763601",
"0.57557017",
"0.572984",
"0.57110614",
"0.56708086",
"0.5622959",
"0.558434",
"0.55741805",
"0.55708677",
"0.55609673",
"0.554... | 0.77822435 | 0 |
Seteo el consumo promedio | def set_consumo_promedio
self.promedio = self.consumo_promedio
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_consumo\n @consumo = Consumo.find(params[:id])\n end",
"def set_copropietario\n @copropietario = Copropietario.find(params[:id])\n end",
"def set_procon\n @procon = Procon.find(params[:id])\n end",
"def asignar_titulo_propiedad()\n \n end",
"def set_propostum\n... | [
"0.67202896",
"0.66108555",
"0.6603203",
"0.6508413",
"0.63148475",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6289735",
"0.6271108",
"0.6250806",
"0.6218165",
"0.62097245",
"0.6181791",
"0.6176842",
"0.6155868",
"0.61521876"... | 0.8240537 | 0 |
Calculo el consumo para esa toma de estado | def consumo
estado_actual - estado_anterior
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consumo_promedio\n medidor_id = MedidorEstadoMedidor.where(estado_medidor_id: self.id).take.medidor_id\n estado_medidor_id = MedidorEstadoMedidor.where(medidor_id: medidor_id).map(&:estado_medidor_id)\n periodo = \"#{self.fecha_medicion.month}/#{self.fecha_medicion.year}\"\n estados = EstadoMedidor... | [
"0.71257466",
"0.6902688",
"0.6443456",
"0.6379449",
"0.62647855",
"0.621782",
"0.6212504",
"0.6212504",
"0.6209098",
"0.6190779",
"0.6144927",
"0.6131498",
"0.61176854",
"0.61128134",
"0.6092782",
"0.6073375",
"0.60526043",
"0.6038242",
"0.5991762",
"0.59720343",
"0.5953152"... | 0.76880634 | 0 |
Calcular consumo promedio hasta el dia de la fecha | def consumo_promedio
medidor_id = MedidorEstadoMedidor.where(estado_medidor_id: self.id).take.medidor_id
estado_medidor_id = MedidorEstadoMedidor.where(medidor_id: medidor_id).map(&:estado_medidor_id)
periodo = "#{self.fecha_medicion.month}/#{self.fecha_medicion.year}"
estados = EstadoMedidor.where(id: estado_medidor_id).where.not(periodo: periodo)
aux = 0
estados.each do |estado|
aux = aux + estado.consumo
end
aux = aux + self.estado_actual
promedio = aux / (estados.count + 1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculaEstimativaBatimentos(anos)\n estimativaBatimentos = anos * 365 * 24 * 60 * 80\n return estimativaBatimentos\nend",
"def calcular_salario_diario(fecha_ejecucion)\n ultimo_dia_del_mes = -1\n fact_salario = @salario / (Date.new(fecha_ejecucion.year, fecha_ejecucion.month, ultimo_dia_del_mes))... | [
"0.66409856",
"0.6606647",
"0.6523676",
"0.6466985",
"0.64531916",
"0.6383245",
"0.62125564",
"0.61075294",
"0.6046272",
"0.60438526",
"0.60438526",
"0.5951609",
"0.59483176",
"0.5905511",
"0.5885642",
"0.5851328",
"0.5841348",
"0.58235127",
"0.5812338",
"0.57327414",
"0.5642... | 0.63992125 | 5 |
GET /first_semester_library_book_outlines/1 GET /first_semester_library_book_outlines/1.json | def show
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @first_semester_library_book_outline }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @second_semester_library_book_outline }\n end\n end",
"def new\n @first_semester_library_book_outline ... | [
"0.73043036",
"0.70101863",
"0.6979276",
"0.65504867",
"0.6531357",
"0.63347316",
"0.62700015",
"0.6269688",
"0.5727571",
"0.57268167",
"0.5457231",
"0.54255074",
"0.54200023",
"0.53816247",
"0.5374278",
"0.53681225",
"0.53279835",
"0.5322215",
"0.530522",
"0.5296461",
"0.522... | 0.71769243 | 1 |
GET /first_semester_library_book_outlines/new GET /first_semester_library_book_outlines/new.json | def new
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @first_semester_library_book_outline }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @second_semester_library_book_outline }\n end\n end",
"def create\n @second_semester_library_book_outline = SecondSeme... | [
"0.7727355",
"0.67513174",
"0.6704959",
"0.6649451",
"0.6621744",
"0.6582856",
"0.6450111",
"0.6446456",
"0.6445895",
"0.6412568",
"0.6359923",
"0.63554245",
"0.6343102",
"0.6305554",
"0.6282859",
"0.6271041",
"0.6257088",
"0.6256571",
"0.62559855",
"0.6241202",
"0.6241202",
... | 0.7762794 | 0 |
POST /first_semester_library_book_outlines POST /first_semester_library_book_outlines.json | def create
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.new(params[:first_semester_library_book_outline])
respond_to do |format|
if @first_semester_library_book_outline.save
format.html { redirect_to ([:administrator, @first_semester_library_book_outline]), notice: 'First semester library book outline was successfully created.' }
format.json { render json: @first_semester_library_book_outline, status: :created, location: @first_semester_library_book_outline }
else
format.html { render action: "new" }
format.json { render json: @first_semester_library_book_outline.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.new(params[:second_semester_library_book_outline])\n\n respond_to do |format|\n if @second_semester_library_book_outline.save\n format.html { redirect_to ([:administrator, @second_semester_library_book_outline])... | [
"0.7216646",
"0.6680735",
"0.66055524",
"0.64832455",
"0.63993776",
"0.5941207",
"0.58848184",
"0.58844554",
"0.578455",
"0.5350378",
"0.5201201",
"0.5192987",
"0.51917803",
"0.51750815",
"0.51332396",
"0.5128681",
"0.51053727",
"0.5101283",
"0.50947386",
"0.50909024",
"0.508... | 0.72161144 | 1 |
PUT /first_semester_library_book_outlines/1 PUT /first_semester_library_book_outlines/1.json | def update
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
respond_to do |format|
if @first_semester_library_book_outline.update_attributes(params[:first_semester_library_book_outline])
format.html { redirect_to ([:administrator, @first_semester_library_book_outline]), notice: 'First semester library book outline was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @first_semester_library_book_outline.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n\n respond_to do |format|\n if @second_semester_library_book_outline.update_attributes(params[:second_semester_library_book_outline])\n format.html { redirect_to ([:administrator, @second_seme... | [
"0.7037561",
"0.67367375",
"0.6688401",
"0.6677294",
"0.6631812",
"0.61064166",
"0.60777324",
"0.57979673",
"0.5693921",
"0.54442817",
"0.5413638",
"0.5331234",
"0.5320914",
"0.52447987",
"0.5231045",
"0.5222837",
"0.52115697",
"0.5159946",
"0.51523453",
"0.51322454",
"0.5111... | 0.7112624 | 0 |
DELETE /first_semester_library_book_outlines/1 DELETE /first_semester_library_book_outlines/1.json | def destroy
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
@first_semester_library_book_outline.destroy
respond_to do |format|
format.html { redirect_to administrator_first_semester_library_book_outlines_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n @second_semester_library_book_outline.destroy\n\n respond_to do |format|\n format.html { redirect_to administrator_second_semester_library_book_outlines_url }\n format.json { head :no_conte... | [
"0.77728635",
"0.7117115",
"0.6694376",
"0.6642634",
"0.6609743",
"0.6608732",
"0.6608732",
"0.65992564",
"0.6593193",
"0.6569368",
"0.6552684",
"0.6484056",
"0.6484056",
"0.64831024",
"0.64758855",
"0.6433199",
"0.64313555",
"0.64302516",
"0.64287686",
"0.6427422",
"0.642344... | 0.7930115 | 0 |
ASCII sequence for green | def green(string)
"\033[0;32m#{string}\033[0m"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def green\n colorize(32)\n end",
"def green(string)\n \"\\033[0;32m#{string}\\e[0m\"\nend",
"def green(string)\n \"\\033[0;32m#{string}\\e[0m\"\nend",
"def code\n index = 16 +\n RGB.to_ansi_domain(@red) * 36 +\n RGB.to_ansi_domain(@green) * 6 +\n RGB.... | [
"0.79157627",
"0.7517061",
"0.7517061",
"0.7384934",
"0.73222953",
"0.7316391",
"0.72420233",
"0.7199386",
"0.71176684",
"0.71132183",
"0.71132183",
"0.70975363",
"0.70975363",
"0.70975363",
"0.70975363",
"0.70975363",
"0.7041318",
"0.7007957",
"0.7007957",
"0.7007801",
"0.70... | 0.74441147 | 4 |
ASCII sequence for red | def red(string)
"\033[0;33m#{string}\033[0m"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def red\n colorize(31)\n end",
"def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend",
"def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend",
"def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend",
"def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend",
"def red(str)\n \"\\e[31m#{str}\\e[0m\"\nend",
"def red(string)\n \"\\033[... | [
"0.8057685",
"0.7818962",
"0.7818962",
"0.7818962",
"0.7818962",
"0.7818962",
"0.77034116",
"0.77034116",
"0.7540547",
"0.7540547",
"0.75281304",
"0.75258195",
"0.7502985",
"0.7477787",
"0.7469527",
"0.74668884",
"0.74469197",
"0.73723876",
"0.73422134",
"0.7280848",
"0.72718... | 0.74396324 | 18 |
Checks whether +file+ is compliant with our cstyle guidelines using the `indent` utility. | def c_compliant?(file)
corrected = "#{file}_corrected"
status = system("indent #{file} -o #{corrected}")
return nil if status.nil?
return false unless FileUtils.compare_file(file, corrected)
return true
ensure
FileUtils.rm_f(corrected)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkstyle(filename)\n cmd = [Dependency.find_by(name: 'cs-checkstyle').path, File.basename(filename)].join(' ')\n capture = Open3.capture3(cmd, chdir: File.dirname(filename))\n\n Capture.new(cmd, capture)\n end",
"def chk_format(config)\n skip = false\n config.each_line do |l... | [
"0.6002013",
"0.5896103",
"0.5845411",
"0.5822154",
"0.57406276",
"0.5688194",
"0.5501497",
"0.5483768",
"0.5449653",
"0.54476815",
"0.54147255",
"0.5181427",
"0.5060326",
"0.5017108",
"0.498734",
"0.49308065",
"0.49082625",
"0.4897584",
"0.48770759",
"0.48579293",
"0.4854259... | 0.75560665 | 0 |
permet de trouver toute les villes | def get_townhall_city(html)
city =[]
html.search("p/a").each do |element|
city << element.text.downcase.tr(" ", "-")
end
return city
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def villain; end",
"def villain; end",
"def villain; end",
"def veichles\n ['Bil', 'Moped', 'Motorsykkel', 'Tungt kjøretøy', 'ATV', 'Buss', 'Sykkel']\n end",
"def villagers\r\n Villager.all.find_all{ |villager| villager.personality == self}\r\n end",
"def village; end",
"def villains_fo... | [
"0.6999449",
"0.6999449",
"0.6999449",
"0.643453",
"0.63818043",
"0.59164804",
"0.5795519",
"0.5723587",
"0.57159764",
"0.5676427",
"0.56680095",
"0.55987674",
"0.55728596",
"0.554486",
"0.55176204",
"0.5511775",
"0.5465431",
"0.5458499",
"0.5418656",
"0.5412572",
"0.5407199"... | 0.0 | -1 |
permet d'avoir tout les adresse html de chaque ville | def get_townhall_urls(html)
url = []
get_townhall_city(html).each do |x|
url << "http://annuaire-des-mairies.com/95/#{x}.html"
end
return url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def content_from(html, url)\n \n def extract_pre_from(html)\n regex = /<pre.*?>.*?<\\/pre>/m\n pre_list = html.scan regex\n html.gsub! regex, 'DUMMY-STRING'\n [pre_list, html]\n end\n\n def add_domain(html, domain)\n html.gsub! /a href=\\\"(\\/.*?\\\")/, \"a href=\\\"#{domain}\... | [
"0.6583336",
"0.6575045",
"0.63033",
"0.62932074",
"0.62435627",
"0.61815083",
"0.6135724",
"0.61204267",
"0.6117691",
"0.6117691",
"0.61102694",
"0.6101565",
"0.60887885",
"0.60711014",
"0.6019527",
"0.6019009",
"0.6007743",
"0.59937376",
"0.5988689",
"0.59882957",
"0.598679... | 0.5763689 | 42 |
repertoire de mail et leur emplacement | def get_townhall_email(html)
mail = []
get_townhall_urls(html).map do |url|
mail << Nokogiri::HTML(URI.open(url)).search("/html/body/div/main/section[2]/div/table/tbody/tr[4]/td[2]").text
end
return mail
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def envio_email\n @desticoor = @queja.programa.coordinador.id\n @coordinadorp = Coordinador.find(@desticoor)\n \n QuejaMailer.registro_queja_coordinador(@queja, @coordinadorp,\"Notificación de Queja\").deliver\n QuejaMailer.registro_queja_instructor(@queja,current_user.email, \"Notificación de Queja... | [
"0.704954",
"0.6880508",
"0.68678916",
"0.67804664",
"0.67548835",
"0.6664267",
"0.6636308",
"0.65885794",
"0.65845037",
"0.6555886",
"0.6554717",
"0.6549395",
"0.65458894",
"0.6545887",
"0.6521144",
"0.652109",
"0.6516135",
"0.64760035",
"0.64760035",
"0.64760035",
"0.647600... | 0.0 | -1 |
on assemble les 2 morray | def townhall_and_email(html)
contact = get_townhall_city(html).zip(get_townhall_email(html)).map{ |x| [x].to_h}
puts contact
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, &rendering_code); end",
"def transformations; end",
"def pasosLoop(estrategia1,estrategia2)\n if !estrategia1.is_a?(Copiar)\n if (estrategia1.actual.nil? && !estrategia1.is_a?(Manual))\n estrate... | [
"0.58178335",
"0.5675061",
"0.56712776",
"0.55663705",
"0.54715216",
"0.5391161",
"0.53686476",
"0.5307316",
"0.5287353",
"0.5280758",
"0.52531016",
"0.52282125",
"0.52221614",
"0.5214832",
"0.52025855",
"0.5194554",
"0.5185088",
"0.5183531",
"0.51813966",
"0.51723117",
"0.51... | 0.0 | -1 |
Get all the presentation ids from the grid view of the presentations and return an array of ids | def get_presentation_ids(base_url)
ids_arr=[]
get_page(base_url)
grid = @wait.until{@driver.find_element(:id,"presentation_grid")}
presentation_list = @driver.find_elements(:css, ".presentation_wrap")
presentation_list.each do |presentation|
presentation_id = presentation.attribute("id")
presentation_id.slice! "p_"
ids_arr.push(presentation_id)
end
return ids_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sheet_ids\n sheet_ids = []\n sheets = Sheet.find_all_by_survey_id(self.id)\n sheets.each do |sheet|\n sheet_ids << sheet.id\n end\n return sheet_ids\n end",
"def participant_ids\n participants.pluck(:id)\n end",
"def division_ids(season)\n ids = Division.where(:season_id => seas... | [
"0.6413428",
"0.6107001",
"0.6061341",
"0.5998015",
"0.5989683",
"0.59677243",
"0.58413106",
"0.58382535",
"0.57692426",
"0.57543653",
"0.57534105",
"0.57534105",
"0.5748409",
"0.57362914",
"0.57156026",
"0.5657332",
"0.565315",
"0.56286293",
"0.5610111",
"0.55980617",
"0.559... | 0.81500673 | 0 |
Get the presenter name and number of views and send them to write to file | def get_info(i, url)
def displayed?(locator)
locs=[]
locs = @driver.find_elements(:css,locator)
if locs.length>0
return true
else
return false
end
end
puts i
presentation = @driver.title
# presenter name locators are not consistent from page to page so have to check which locator to use to get presenter name
if displayed?("#gallery > div.ad-image-wrapper > div.ad-image > div.ad-image-description > h2 > a")
presenter_locator = @driver.find_element(:css,"#gallery > div.ad-image-wrapper > div.ad-image > div.ad-image-description > h2 > a")
elsif displayed? ("#content_responsive > div.content_grey > div > div:nth-child(1) > div.presenter_col.col-sm-5.col-md-3 > div.presenter_meta > div.member_info > h2 > a")
presenter_locator = @driver.find_element(:css, "#content_responsive > div.content_grey > div > div:nth-child(1) > div.presenter_col.col-sm-5.col-md-3 > div.presenter_meta > div.member_info > h2 > a")
elsif displayed?("#gallery > div.ad-image-wrapper > div.ad-image > div.ad-image-description > h2")
presenter_locator = @driver.find_element(:css,"#gallery > div.ad-image-wrapper > div.ad-image > div.ad-image-description > h2")
else
presenter_locator = @driver.find_element(:css, "#content_responsive > div.content_grey > div > div:nth-child(1) > div.presenter_col.col-sm-5.col-md-3 > div.presenter_meta > div.member_info > h2")
end
presenter = presenter_locator.text
presenter_organization = @driver.find_element(:css,".presenter").text
views_locator = @driver.find_element(:css, "#content_responsive > div.content_grey > div > div:nth-child(2) > div.col-sm-12.col-md-3.hidden-xs.hidden-sm > div.social_panel > div > div:nth-child(1) > h3")
views = views_locator.text
# NSF grans are links while non-NSF grants are not links. The first condition finds all the grants the are links. The second just finds the p element with the list of non-link grants and returns them as one unit.
if displayed? ("#abstract_scroll > p:nth-child(2) > a")
grant_list = @wait.until{@driver.find_elements(css: "#abstract_scroll > p:nth-child(2) > a")}
has_link=true
grant_list_length = grant_list.length
else
grant_list = @wait.until{@driver.find_element(css: "#abstract_scroll > p:nth-child(2)" )}
grant_list_length = 1
end
# puts "grant_list is #{grant_list}. grant_list_length is #{grant_list_length}"
if has_link #checks to see if the grants are links and gets each text individually. Otherwise return the enter p element regardless of how many grants there are
case grant_list_length
when 1
grant_1 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a").text} #abstract_scroll > p:nth-child(2) > a
grant_2 = ""
grant_3 = ""
when 2
grant_1 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a:nth-child(1)").text}
grant_2 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a:nth-child(2)").text}
grant_3 = ""
when 3
grant_1 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a:nth-child(1)").text}
grant_2 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a:nth-child(2)").text}
grant_3 = @wait.until{@driver.find_element(:css, "#abstract_scroll > p:nth-child(2) > a:nth-child(3)").text}
end
else grant_1 = @wait.until{@driver.find_element(css: "#abstract_scroll > p:nth-child(2)" ).text}
end
discussions = @wait.until{@driver.find_element(:css, "#panel-mc-count").text.tr('()','').to_i}
kw_list=@wait.until{@driver.find_elements(:css, ".kw")}
kw_list_length = kw_list.length
kw_first = 2
# puts "ks_list_length is #{kw_list_length}"
case kw_list_length
when 1
keyword_1 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(2)").text}
keyword_2 = ""
keyword_3 = ""
when 2
keyword_1 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(2)").text}
keyword_2 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(3)").text}
keyword_3 = ""
when 3
keyword_1 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(2)").text}
keyword_2 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(3)").text}
keyword_3 = @wait.until{@driver.find_element(:css, "#panel_video > div.presentation_extra > a:nth-child(4)").text}
end
puts "Presentation is #{presentation}, Grant_1 is #{grant_1}, Grant_2 is #{grant_2}, Grant_3 is #{grant_3}, Num Views is #{views}, Discussions is #{discussions}, Keyword_1: #{keyword_1}, Keyword_2: #{keyword_2}, Keyword_3: #{keyword_3}, url is #{url}"
view_num = views.to_i
write_to_file(i,presenter, presenter_organization, presentation, grant_1, grant_2, grant_3, view_num, discussions, keyword_1,keyword_2, keyword_3, url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n #puts \"The password is #{@paldemic_file.pw}\"\n puts \"number views is #{@paldemic_file.num_views}\"\n @paldemic_file.num_views += 1\n @paldemic_file.save!\n end",
"def write_presenter_definitions!\n presenter_definitions = presenters\n .formatted(format)\n ... | [
"0.57676756",
"0.56796205",
"0.55378646",
"0.5537515",
"0.54047054",
"0.5333798",
"0.5244269",
"0.5185905",
"0.51807487",
"0.5171025",
"0.5131862",
"0.49838236",
"0.49838236",
"0.4974482",
"0.49715313",
"0.49685594",
"0.49530482",
"0.49512666",
"0.49315992",
"0.4917018",
"0.4... | 0.0 | -1 |
infra: Template terraform tfvars and tfstate platform: template compose/skaffold templates and service configuration, e.g. fluentd logs service: template compose/skaffold templates and service content | def generate
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster_template(config)\n template = <<~YAML\n '$schema': https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#\n contentVersion: 1.0.0.0\n parameters: {}\n variables: {}\n resources:\n - type: Microsoft.ContainerService/... | [
"0.6377843",
"0.626697",
"0.6258558",
"0.61451566",
"0.60029066",
"0.5953019",
"0.5937783",
"0.59337085",
"0.5931862",
"0.58946085",
"0.58605945",
"0.58370274",
"0.5739947",
"0.57033706",
"0.5664735",
"0.5639949",
"0.5634354",
"0.5627539",
"0.55983686",
"0.5581285",
"0.555503... | 0.0 | -1 |
Insert Elements on List | def insert(value)
self.head.nil? ? insert_empty_list(value) : insert_on_end(value)
print "=> Result insertion: "
print_simple_list(self.last)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def add_to_list(list)\n\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert_in_list_at(position = 1)\n insert_at_position(position)\n end",
"def insert_at(v, list, n)\n... | [
"0.73767644",
"0.73767644",
"0.73767644",
"0.6992129",
"0.6992129",
"0.6767411",
"0.6614927",
"0.65513444",
"0.65053046",
"0.6498203",
"0.63923407",
"0.6352917",
"0.6352682",
"0.63396406",
"0.63295734",
"0.6320552",
"0.63178736",
"0.6286044",
"0.62755257",
"0.6269956",
"0.626... | 0.6206714 | 24 |
Remove def delete(target_cell, value) if target_cell.value == value target_cell = target_cell.next return end while value = .value node = find_before(value) node.next = node.next.next end List Methods Search | def search_cell_by_value(value)
return nil if self.last.nil?
tail = self.last
while true
if tail.value == value
return tail
elsif tail.successor
tail = tail.successor
else
return nil
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(value)\r\n prev = nil\r\n curr = @head \r\n\r\n while curr \r\n if curr.data == value \r\n if prev == nil\r\n @head = curr.next \r\n else \r\n prev.next = curr.next \r\n end\r\n return\r\n\r\n else\r\n prev ... | [
"0.7507487",
"0.7445511",
"0.73831576",
"0.7230802",
"0.7184609",
"0.7109793",
"0.7100229",
"0.70414066",
"0.70044434",
"0.69557816",
"0.69311863",
"0.68400353",
"0.68105865",
"0.6755214",
"0.6738655",
"0.6736432",
"0.67054766",
"0.66994464",
"0.6498103",
"0.64691705",
"0.637... | 0.6102504 | 32 |
Running tests with the ONLY_OS environment variable set limits the tested platforms to the specified values. Example: ONLY_OS=centos7x86_64,ubuntu14x86_64 | def only_test_os
if ENV.key?('ONLY_OS')
ENV['ONLY_OS'].split(',')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exclude_test_os\n if ENV.key?('EXCLUDE_OS')\n ENV['EXCLUDE_OS'].split(',')\n end\nend",
"def on_os_under_test\n on_supported_os.reject do |os, facts|\n (only_test_os() && !only_test_os.include?(os)) ||\n (exclude_test_os() && exclude_test_os.include?(os))\n end\nend",
"def check_platform(a... | [
"0.72467107",
"0.7035191",
"0.6877291",
"0.6828068",
"0.67982554",
"0.67280394",
"0.66957104",
"0.6582198",
"0.65519696",
"0.6548101",
"0.65443254",
"0.65361667",
"0.64682806",
"0.64546293",
"0.6329405",
"0.6321391",
"0.631356",
"0.6301306",
"0.6300785",
"0.62839705",
"0.6223... | 0.78152275 | 0 |
Running tests with the EXCLUDE_OS environment variable set limits the tested platforms to all but the specified values. Example: EXCLUDE_OS=centos7x86_64,ubuntu14x86_64 | def exclude_test_os
if ENV.key?('EXCLUDE_OS')
ENV['EXCLUDE_OS'].split(',')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_os_under_test\n on_supported_os.reject do |os, facts|\n (only_test_os() && !only_test_os.include?(os)) ||\n (exclude_test_os() && exclude_test_os.include?(os))\n end\nend",
"def only_test_os\n if ENV.key?('ONLY_OS')\n ENV['ONLY_OS'].split(',')\n end\nend",
"def exclude_pe_upgrade_platfo... | [
"0.7788235",
"0.747524",
"0.6439767",
"0.6358739",
"0.6235619",
"0.6187325",
"0.6100337",
"0.6095439",
"0.60098463",
"0.6006786",
"0.59239376",
"0.5857372",
"0.583325",
"0.5814551",
"0.57953453",
"0.57785404",
"0.57700527",
"0.5765902",
"0.5762372",
"0.57604283",
"0.5748695",... | 0.8375436 | 0 |
Use the above environment variables to limit the platforms under test | def on_os_under_test
on_supported_os.reject do |os, facts|
(only_test_os() && !only_test_os.include?(os)) ||
(exclude_test_os() && exclude_test_os.include?(os))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_test_os\n if ENV.key?('ONLY_OS')\n ENV['ONLY_OS'].split(',')\n end\nend",
"def exclude_test_os\n if ENV.key?('EXCLUDE_OS')\n ENV['EXCLUDE_OS'].split(',')\n end\nend",
"def platform(name)\n case ENV['PLATFORM']\n when 'windows_10_edge'\n {selenium_version: '3.141.59',\n platf... | [
"0.77483755",
"0.75362223",
"0.7041184",
"0.7038068",
"0.6897069",
"0.6891437",
"0.67669123",
"0.67509305",
"0.66473615",
"0.6643608",
"0.66318834",
"0.6621633",
"0.6606931",
"0.65824383",
"0.6576899",
"0.6562332",
"0.65580904",
"0.6550282",
"0.6543846",
"0.6541644",
"0.65386... | 0.63294464 | 36 |
This depends on the roles being created in the right order, so that e.g. the id for "Writer" is less than that for "Local Admin". | def <=>(other)
id <=> other.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_roles\r\n self.roles.create(:title => \"admin\")\r\n if self.name.eql? \"Grandor Eldoran\"\r\n self.roles.create(:title => \"admin\")\r\n elsif self.name.eql? \"Test2 Test2\"\r\n self.roles.create(:title => \"member\")\r\n end\r\n end",
"def roles_for_select\n Role.all.selec... | [
"0.67753184",
"0.67186546",
"0.66753423",
"0.66425073",
"0.66425073",
"0.6590161",
"0.65740454",
"0.6570927",
"0.65209657",
"0.65164405",
"0.6485773",
"0.6485615",
"0.6481712",
"0.6456935",
"0.6456935",
"0.6456935",
"0.64529026",
"0.64516217",
"0.6421562",
"0.63712543",
"0.63... | 0.0 | -1 |
check if we need password to update user data ie if password or email was changed extend this as needed | def needs_password?(user, params)
# user.email != params[:user][:email] ||
return !params[:user][:password].blank?
logger.info "Password : [#{params[:user][:password]}] is not blank? #{!params[:user][:password].blank?}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def needs_update_password? user, params\n user.email != params[:user][:email] ||\n params[:user][:password].present? ||\n params[:user][:password_confirmation].present?\n end",
"def need_change_password?\n password_change_requested? || password_too_old?\n end",
"def check_password... | [
"0.78474206",
"0.7633188",
"0.7595944",
"0.7529853",
"0.74996895",
"0.74826044",
"0.74752384",
"0.7472026",
"0.74320877",
"0.73250824",
"0.72857994",
"0.7284436",
"0.72496825",
"0.7151641",
"0.714748",
"0.7134663",
"0.7134663",
"0.7133602",
"0.71250427",
"0.711971",
"0.711645... | 0.6761188 | 95 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.friendly.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def post_params
params.require(:post).permit(:title, :text, :user_id, :image_url, :image, :tags)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6978086",
"0.6780264",
"0.6742658",
"0.6738813",
"0.67338693",
"0.65908474",
"0.6501793",
"0.6495506",
"0.64796513",
"0.64755446",
"0.6454826",
"0.6437561",
"0.6377127",
"0.63722163",
"0.6364058",
"0.63178706",
"0.62979764",
"0.62968165",
"0.62913024",
"0.6289789",
"0.6289... | 0.0 | -1 |
Add more helper methods to be used by all tests here... | def log_in_with(email, password)
click_on "Log In"
fill_in :email, with: email
fill_in :password, with: password
click_on "Finish"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end",
"def helpers; end",
"def... | [
"0.7330966",
"0.701972",
"0.701972",
"0.701972",
"0.6772961",
"0.6679903",
"0.6679903",
"0.6583205",
"0.65507036",
"0.6377433",
"0.63762784",
"0.632961",
"0.6280821",
"0.6280821",
"0.6249786",
"0.6142927",
"0.6137607",
"0.6121912",
"0.6108209",
"0.60972595",
"0.60949636",
"... | 0.0 | -1 |
this is the same as the previous one | def process_user_input
command = get_user_input
while command != "quit"
perform_command(command)
command = get_user_input
end
puts "Good bye!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same; end",
"def original; end",
"def private; end",
"def previously_ran?; end",
"def previously_ran?; end",
"def anchored; end",
"def original_order\n end",
"def offences_by; end",
"def prev_line=(_arg0); end",
"def original_result; end",
"def extraer_final()\n @head=head.pre... | [
"0.7406924",
"0.6351001",
"0.6296775",
"0.62820435",
"0.62820435",
"0.6275964",
"0.6264952",
"0.6241501",
"0.6090318",
"0.6059222",
"0.60583985",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.60423434",
"0.6... | 0.0 | -1 |
this prints out a times table Avoid deep nesting | def multiples(i)
ms = []
(1..10).each do |j|
ms << i * j
end
ms
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_table\n\t$table.each do |row|\n\t\trow.each_with_index do |c, index|\n\t\t\tif index != 0\n\t\t\t\tprint ' '\n\t\t\tend\n\t\t\tprint c\n\t\tend\n\t\tprint \"\\n\"\n\tend\nend",
"def print_table table\n\ttable.each do |x|\n\t\tif x != nil\n\t\t\trowLen = x.size\n\t\t\tx.each_with_index { |y, i|\n\t\t\t\... | [
"0.70614403",
"0.6983013",
"0.6848463",
"0.684207",
"0.6823446",
"0.6643791",
"0.6627787",
"0.6525978",
"0.6503731",
"0.6502775",
"0.6477298",
"0.6387253",
"0.6384041",
"0.6338302",
"0.6330474",
"0.633037",
"0.6310579",
"0.6306973",
"0.62966514",
"0.6296414",
"0.62897986",
... | 0.0 | -1 |
We explicitly set the formats and handlers here to avoid the huge number of stat() syscalls that Rails normally triggers when running in dev mode. It would have been nice to call this 'render_partial', but that name is taken by the default controller. | def render_aspace_partial(args)
defaults = {:formats => [:html], :handlers => [:erb]}
return render(defaults.merge(args))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(args={})\n return if @redirect\n @render_nothing = args[:nothing] # TODO hack to block automatic method templates\n json = args[:json]\n action = args[:action]\n html = args[:html]\n content = args[:content_type]\n partial = args[:partial]\n # xxx hack to let me ... | [
"0.69817513",
"0.67564315",
"0.6469044",
"0.6292904",
"0.62860185",
"0.6254606",
"0.61977845",
"0.61204886",
"0.6104197",
"0.6097186",
"0.60801905",
"0.60801905",
"0.60775137",
"0.6077415",
"0.6070317",
"0.6067628",
"0.6066129",
"0.6064863",
"0.6058083",
"0.6033782",
"0.60293... | 0.555685 | 92 |
POST /location_complete POST /location_complete.json | def show
values_container = params['search'] ? params['search'] : params
@find, @near, @coordinates, @page = values_container.values_at('find', 'near', 'coordinates', 'page')
if @near.present?
if @near.include?('Current Location')
values_container['near'] = @near = nil # Monkey patch
elsif ! @near.match(/chicago/i)
values_container['near'] = (@near.to_s << ' Chicago')
end
end
@results = LocationFilter.new(@near).values
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @results }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete!\n load_attributes_from_response(post(:complete))\n end",
"def complete\n sanitized = whitelist(params, :complete)\n travel = Travels::Travel.find(sanitized[:id])\n\n unless travel.taken? && travel.performer == current_user.becomes(Users::Performer)\n fail(:any, :bad_request, \... | [
"0.61893255",
"0.61321986",
"0.61291736",
"0.6111436",
"0.59911543",
"0.5956018",
"0.5952229",
"0.59414667",
"0.59351856",
"0.5931894",
"0.5924253",
"0.5922623",
"0.5917644",
"0.5890898",
"0.58796436",
"0.5875543",
"0.5849817",
"0.58446926",
"0.58262783",
"0.58262783",
"0.582... | 0.0 | -1 |
Get current using Let's Encrypt endpoint | def directory
@endpoint ||= config.use_staging? ? ENDPOINT_STAGING : ENDPOINT
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def letsencrypt\n render plain: ENV[\"LETS_ENCRYPT_KEY\"]\n end",
"def info id\n get(\"ssl/v1/#{id}\")\n end",
"def lets_encrypt\n render plain: ACME_SECRET\n end",
"def lets_encrypt\n render plain: ACME_SECRET\n end",
"def key\n Net::HTTP.get(@uri.host, \"#{@uri.request_uri}key\", @ur... | [
"0.6400273",
"0.62161916",
"0.6101697",
"0.6101697",
"0.6026035",
"0.5792347",
"0.576605",
"0.57019985",
"0.5689617",
"0.56868374",
"0.56747735",
"0.56747735",
"0.56581193",
"0.56508076",
"0.5648403",
"0.5640528",
"0.56332785",
"0.5615711",
"0.56147975",
"0.5602274",
"0.55805... | 0.0 | -1 |
Register a Let's Encrypt account This is required a private key to do this, and Let's Encrypt will use this private key to connect with domain and assign the owner who can renew and revoked. | def register(email)
account = client.new_account(contact: "mailto:#{email}", terms_of_service_agreed: true)
logger.info "Successfully registered private key with address #{email}"
account.kid # TODO: Save KID
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register\n enc_password = Authentication::Encryptor.digest(password)\n account = Authentication::Account.find_or_initialize_by({email: username})\n account.assign_attributes({'encrypted_password' => enc_password, 'gid' => gid})\n account.roles.concat(role.to_a).uniq!\n account.save!\n ... | [
"0.62717634",
"0.6236414",
"0.61966443",
"0.608187",
"0.60175425",
"0.5814123",
"0.56559443",
"0.55758756",
"0.5564925",
"0.5563685",
"0.55515116",
"0.5535045",
"0.5506047",
"0.5502468",
"0.5501809",
"0.54797465",
"0.54707164",
"0.5465139",
"0.5356201",
"0.53537947",
"0.53429... | 0.65624154 | 0 |
Config how to Let's Encrypt works for Rails LetsEncrypt.config do |config| Always use production mode to connect Let's Encrypt API server config.use_staging = false end | def config(&block)
@config ||= Configuration.new
instance_exec(@config, &block) if block_given?
@config
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allow_production; end",
"def ssl_configured?\n !Rails.env.development?\n end",
"def letsencrypt\n render plain: ENV[\"LETS_ENCRYPT_KEY\"]\n end",
"def ssl_required?\n (Rails.env.production? or Rails.env.staging?) and Rails.stage\n end",
"def check_production_account_settings\n raise \"... | [
"0.65388966",
"0.63169533",
"0.62656635",
"0.61576855",
"0.6150957",
"0.60791045",
"0.606316",
"0.6025106",
"0.6011626",
"0.5870942",
"0.5857455",
"0.58531564",
"0.5802018",
"0.5782604",
"0.57567173",
"0.5711788",
"0.56912494",
"0.56574875",
"0.5647095",
"0.5633919",
"0.56132... | 0.0 | -1 |
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 with Benjamin Shpringer. 0. total Pseudocode make sure all pseudocode is commented out! Input: An array of integers Output: Sum of inputs Steps to solve the problem. Sum the objects in the array. 1. total initial solution | def total(num)
sum = num.inject {|x,y| x + y }
return sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solution5(input)\n # Approach\n # Map over the initial array (to return a transformed array)\n # Map over each interal array (to return a transformed array)\n # Creates an enumerable range up to the value in the array\n # Multiple each value in the range using the inject method\n # which iter... | [
"0.67037666",
"0.64605194",
"0.6428263",
"0.6417394",
"0.637501",
"0.63178754",
"0.62595093",
"0.6249261",
"0.6165364",
"0.61109245",
"0.609968",
"0.6067007",
"0.60623837",
"0.6054427",
"0.6047015",
"0.6046068",
"0.6044586",
"0.6036545",
"0.60154575",
"0.60152185",
"0.6008323... | 0.0 | -1 |
3. total refactored solution | def total(num)
num.inject {|x,y| x + y }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchored; end",
"def solution4(input)\n end",
"def suivre; end",
"def private; end",
"def probers; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def stderrs; end",
"def schubert; end",
"def transformations; end... | [
"0.614783",
"0.59552205",
"0.58631617",
"0.5817628",
"0.5803303",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5688251",
"0.5668896",
"0.5657474",
"0.56524754",
"0.562926",
"0.5584554",
"0.5583142",
"0.55335104",
"0.55295557",
"0.55000037",
"0.549499",
"0.5478271",
... | 0.0 | -1 |
4. sentence_maker pseudocode make sure all pseudocode is commented out! Input: An array of strings. Output: A grammatically correct sequence of the strings in the array. Steps to solve the problem. Capitalize the first letter of the first string. Iterate through the array: Convert objects to strings Add string to variable followed by a space Remove last space from variable Add '.' to variable string 5. sentence_maker initial solution 6. sentence_maker refactored solution | def sentence_maker(string)
string[0] = string[0].capitalize
phrase = ''
string.each do |word|
phrase = phrase + word.to_s + ' '
end
phrase = phrase.chop
phrase = phrase + '.'
return phrase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sentence_maker(array)\n\tarray[0].capitalize!\n\tfinalString = array.join(' ')\n\tfinalString = finalString + '.'\nend",
"def sentence_maker(array)\n\tcomplete = \"\"\n\tarray.each do |i|\n\t\tcomplete = complete + i.to_s + \" \"\n\tend\n\tcomplete.insert(-2, \".\")\n\treturn complete.strip.capitalize\nend",... | [
"0.8323096",
"0.8290414",
"0.8241512",
"0.82114214",
"0.81591886",
"0.8155304",
"0.81428975",
"0.8142665",
"0.811588",
"0.8113326",
"0.8112423",
"0.81022674",
"0.80847913",
"0.8071915",
"0.8063879",
"0.80460405",
"0.8040951",
"0.80362636",
"0.8028129",
"0.8025624",
"0.8020612... | 0.75176805 | 72 |
make the filename safe for download by removing any characters that might cause problems | def safe_filename( filename )
ret = filename
# remove commas
ret = ret.gsub( /,/, '' )
# remove colons
ret = ret.gsub( /:/, '' )
# change spaces to underscores
ret = ret.gsub( / /, '_' )
return ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ').strip.gsub(/[ ]+/, '-')\n end",
"def sanitize_filename\n name = self.strip\n #--- get only the filename, not the whole path\n name.gsub! /^.*(\\\\|\\/)/, ''\n\n #--- Finally, replace all no... | [
"0.7860457",
"0.7795738",
"0.7717271",
"0.77045685",
"0.76549053",
"0.7617869",
"0.76148427",
"0.7565396",
"0.75560194",
"0.74698895",
"0.7452285",
"0.74130887",
"0.74130887",
"0.74130887",
"0.74130887",
"0.7410646",
"0.7398637",
"0.7345304",
"0.7280561",
"0.72635967",
"0.725... | 0.74451685 | 11 |
Default actions: index show new edit create update destroy | def initialize(user)
alias_action :new, :edit, :create, :update, :destroy, to: :modify
alias_action :new, :create, to: :touch
alias_action :index, :show, to: :read
user ||= User.new # Если не авторизован, то будет новый пользователь с пустыми полями
#Admin
if user.has_role? :admin
# can :access, :rails_admin # grant access to rails_admin
# can :dashboard # grant access to the dashboard
can :modify, Article
can :read, Article
can :validate, Article
can :read, Menu
can :modify, Menu
can :read, Gallery
can :modify, Gallery
can :del_image, Gallery
can :read, Letter
can :modify, Letter
can :add_director, Letter
# can :read, :all
# Editor
elsif user.has_role? :manager
can :read, :all
can :touch, Article
can :manage, Article do |g|
g.try(:user_id) == user.id
end
can :touch, Gallery
can :manage, Gallery do |g|
g.try(:user_id) == user.id
end
can :del_image, Gallery do |g|
g.try(:user_id) == user.id
end
# Guest
else
can :read, Article
can :read, Gallery
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actions\n ['index', 'show', 'new', 'create', 'edit', 'update', 'destroy']\n end",
"def index\n new\n end",
"def index\r\n end",
"def index\r\n end",
"def index\r\n end",
"def index\r\n\r\n\tend",
"def index\n end",
"def index\n end",
"def index\n end",
"def index\n ... | [
"0.815871",
"0.75112915",
"0.73189867",
"0.73189867",
"0.73189867",
"0.7310435",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7309159",
"0.7303026",
"0.7290191",
"0.7290191",
"0.72701263",
"0.7249213",
"0.7249213",
"0.7249213",... | 0.0 | -1 |
alias_subcommand :details, :get set_default_subcommand :list | def initialize()
#@appliance_name, @appliance_url = Morpheus::Cli::Remote.active_appliance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subcommand() __subcommand__ end",
"def subcommands() __subcommands__ end",
"def __subcommand__!() @__subcommand__ end",
"def __subcommand__() @__subcommand__&.__ident__ end",
"def subcommands!() __subcommands__! end",
"def command(name,aliases,desc,long_desc,arg_name,arg_options)\n abstract!... | [
"0.71278894",
"0.67721564",
"0.65992963",
"0.64372945",
"0.64036524",
"0.63862157",
"0.6264232",
"0.62122387",
"0.62122387",
"0.61734974",
"0.61499405",
"0.61478186",
"0.61291",
"0.60871136",
"0.60538846",
"0.60400736",
"0.60400736",
"0.60249865",
"0.5974858",
"0.5939112",
"0... | 0.0 | -1 |
GET /normas/1 GET /normas/1.xml | def show
@norma = Norma.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @norma }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n end",
"def rest_get(uri)\n \n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start(uri.hos... | [
"0.6173393",
"0.6156843",
"0.60809755",
"0.58903414",
"0.5884842",
"0.5835906",
"0.57748127",
"0.5772957",
"0.575499",
"0.5749537",
"0.57461905",
"0.5742105",
"0.57334083",
"0.57271457",
"0.57139564",
"0.57110673",
"0.5699079",
"0.56712115",
"0.5661917",
"0.5656422",
"0.56521... | 0.6805338 | 0 |
GET /normas/new GET /normas/new.xml | def new
@norma = Norma.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @norma }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def ne... | [
"0.7220552",
"0.7168956",
"0.70436466",
"0.6952536",
"0.6899364",
"0.6887829",
"0.6801287",
"0.6801287",
"0.678975",
"0.6786747",
"0.67562115",
"0.6733357",
"0.6732324",
"0.6721447",
"0.670579",
"0.66994715",
"0.66968226",
"0.6681275",
"0.66792697",
"0.66661775",
"0.66648954"... | 0.7562103 | 0 |
POST /normas POST /normas.xml | def create
@norma = Norma.new(params[:norma])
respond_to do |format|
if @norma.save
format.html { redirect_to(@norma, :notice => 'Norma was successfully created.') }
format.xml { render :xml => @norma, :status => :created, :location => @norma }
else
format.html { render :action => "new" }
format.xml { render :xml => @norma.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(uri, xml)\r\n req = Net::HTTP::Post.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def new\n @norma = Norma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norma }\... | [
"0.5817741",
"0.5744845",
"0.57311445",
"0.5683097",
"0.56655604",
"0.56556445",
"0.5608256",
"0.5589595",
"0.5553461",
"0.55108374",
"0.5456953",
"0.5420579",
"0.5373471",
"0.52988124",
"0.529538",
"0.52333295",
"0.52129006",
"0.5195305",
"0.5185612",
"0.5169016",
"0.5163574... | 0.63164693 | 0 |
PUT /normas/1 PUT /normas/1.xml | def update
@norma = Norma.find(params[:id])
respond_to do |format|
if @norma.update_attributes(params[:norma])
format.html { redirect_to(@norma, :notice => 'Norma was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @norma.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def res... | [
"0.6789023",
"0.66723526",
"0.6665163",
"0.5853039",
"0.58172715",
"0.5785053",
"0.5678803",
"0.5650615",
"0.561669",
"0.559131",
"0.5582461",
"0.5574874",
"0.55725074",
"0.5561283",
"0.5546914",
"0.55468416",
"0.54761153",
"0.5454769",
"0.5439033",
"0.540408",
"0.5367",
"0... | 0.61115265 | 3 |
DELETE /normas/1 DELETE /normas/1.xml | def destroy
@norma = Norma.find(params[:id])
@norma.destroy
respond_to do |format|
format.html { redirect_to(normas_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"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 delete()\n response = send_post_request(@xml_api_del... | [
"0.6808671",
"0.6708888",
"0.66801244",
"0.65826946",
"0.6489992",
"0.6474245",
"0.6465759",
"0.643621",
"0.6430296",
"0.6420173",
"0.64148337",
"0.6396787",
"0.6392645",
"0.6378127",
"0.63672113",
"0.6328987",
"0.6327253",
"0.6316562",
"0.6308252",
"0.630362",
"0.62990457",
... | 0.7091317 | 0 |
For filters use scopes, defined in event.rb | def filter
@events = Event.filter(filter_params).paginate(page: params[:page], per_page: 18)
if @events.blank?
flash.now[:warning] = 'Извините, ничего не найдено по вашему запросу :('
end
render 'index'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_filters(scope)\n scope\n end",
"def acceptable_filter_scopes\n []\n end",
"def uhook_filtered_search filters = {}\n create_scopes(filters) do |filter, value|\n case filter\n when :locale\n {:conditions => {:locale => value}}\n ... | [
"0.74736786",
"0.69640577",
"0.685574",
"0.684137",
"0.6764281",
"0.67611",
"0.6732648",
"0.66711444",
"0.6666964",
"0.6666964",
"0.6663639",
"0.6631192",
"0.6588301",
"0.654416",
"0.65336686",
"0.65336686",
"0.6529236",
"0.6515543",
"0.6498671",
"0.6432729",
"0.6341834",
"... | 0.5713922 | 88 |
Subject can be set in your I18n file at config/locales/en.yml with the following lookup: en.subscription_mailer.quotes.subject | def notify_subscription_created(email)
@email = email
mail to: email, subject: 'Your subscription confirmation'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message_subject=(value)\n @message_subject = value\n end",
"def subject\n self['subject'] || msg['subject']\n end",
"def subject\n @subject ||= Envelope::MessageTools.normalize(message.subject || '')\n end",
"def subject=(subject); @message_impl.setSubject subject; e... | [
"0.682334",
"0.67163616",
"0.6687249",
"0.66175926",
"0.6588627",
"0.6575391",
"0.654069",
"0.6508863",
"0.6311303",
"0.62999105",
"0.62984115",
"0.6296879",
"0.62891567",
"0.6284765",
"0.6284765",
"0.6284765",
"0.6284765",
"0.6252835",
"0.62297297",
"0.6228833",
"0.62268144"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user_memory_score
@user_memory_score = UserMemoryScore.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 |
Only allow a trusted parameter "white list" through. | def user_memory_score_params
params.require(:user_memory_score).permit(:user_id, :memory_id, :up, :down)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.71207976",
"0.705222",
"0.69488335",
"0.69021654",
"0.67362636",
"0.6717561",
"0.6689192",
"0.6678948",
"0.66622657",
"0.6555007",
"0.6527569",
"0.64588845",
"0.64522904",
"0.6450812",
"0.6448551",
"0.6434285",
"0.6412147",
"0.6412147",
"0.6393719",
"0.6381976",
"0.6381976... | 0.0 | -1 |
Implementation of enter that calls transform for the traversed node. | def enter(node, depth)
transform(node)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enter(node, depth)\n method_name = \"enter_#{node.node_type}\"\n if respond_to?(method_name)\n send method_name, *[node, depth][0...method(method_name).arity]\n end\n end",
"def enter!\n @state_machine.current_state = self\n\n @entry_actions.each do |entry_action|\n ... | [
"0.61757076",
"0.6017361",
"0.5895592",
"0.5875677",
"0.5745028",
"0.5711508",
"0.56742907",
"0.5654039",
"0.5636795",
"0.56204844",
"0.56087005",
"0.5576442",
"0.5523049",
"0.5387376",
"0.5378495",
"0.5367927",
"0.5302114",
"0.52514416",
"0.5190156",
"0.5173956",
"0.51664746... | 0.8140209 | 0 |
Called to do the actual transformation of the source node into the target node. Delegates to transform_ if possible. The default implementation does nothing. | def transform(source)
method_name = "transform_#{source.node_type}"
if respond_to?(method_name)
send method_name, source
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform\n # Pass through\n @target.transform\n end",
"def transform!\n raise NotImplementedError, \"You have to implement #transform! in your transformer\"\n end",
"def on_transform(&blk)\n @transform_handler = blk\n self\n end",
"def apply_transform(tree)\n ... | [
"0.7162967",
"0.68824023",
"0.6370784",
"0.62922126",
"0.6219303",
"0.6169243",
"0.61490166",
"0.61447185",
"0.6142655",
"0.6130794",
"0.6084592",
"0.6078942",
"0.5989419",
"0.5890639",
"0.58786696",
"0.5809969",
"0.57800615",
"0.57622427",
"0.5747481",
"0.5732751",
"0.573275... | 0.72962856 | 0 |
Copies the given node into the resulting tree. Includes all attributes and the schema if the given node has one. | def copy_node!(source)
child! source.node_type, source.attributes.merge({ __location: source })
if source.has_schema?
current.instance_variable_set(:@schema, source.instance_variable_get(:@schema))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_node(original_node); end",
"def cloneAll(node,bodyStack = @defaultBodyStack,substp = FALSE)\n newnode = node.clone() ;\n if(node.kind_of?(Element)) then\n node.each { |e|\n\tnewnode.add(cloneAll(e,bodyStack,substp)) ;\n }\n node.attributes.each {|key,attr|\n\tif(substp) then\n\t tr... | [
"0.5966918",
"0.57801753",
"0.5695705",
"0.55888534",
"0.55888534",
"0.5400525",
"0.53995043",
"0.53410506",
"0.53191376",
"0.53113985",
"0.52819824",
"0.5266566",
"0.52406824",
"0.5237756",
"0.5230825",
"0.5198472",
"0.5124338",
"0.507509",
"0.5050429",
"0.50025773",
"0.5002... | 0.73058796 | 0 |
Adds a new child and leaves the current stack pointer on the current node. | def child(node_type, attributes = {}, &block)
raise 'Cannot add a new child without descending, when no parent is available' unless current
current.add_child(node_type, attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(child)\n self.children << child\n end",
"def child_add(child)\n @children.push(child)\n end",
"def add_child child\n @children << child\n self\n end",
"def add_child(new_child)\n if !@children.include?(new_child)\n new_child.parent = self\n end\n \n end",
... | [
"0.7530215",
"0.7398412",
"0.73512244",
"0.7315941",
"0.73148453",
"0.73013276",
"0.7243775",
"0.72014064",
"0.71984154",
"0.71773577",
"0.71363187",
"0.70036024",
"0.6883174",
"0.6877128",
"0.68475926",
"0.68425024",
"0.6841643",
"0.6815889",
"0.6789745",
"0.6783405",
"0.677... | 0.62429786 | 58 |
Adds a new child and sets the current stack pointer onto the newly created child | def child!(node_type, attributes = {})
new_child = if current
child(node_type, attributes)
else
Mahuta::Node.new(nil, nil, node_type, attributes)
end
@result ||= new_child
pin! new_child
new_child
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(child)\n self.children << child\n end",
"def child_add(child)\n @children.push(child)\n end",
"def add_child(child)\n \t\t@children << child\n \tend",
"def add_child child\n @children << child\n end",
"def add_child child\n @children << child\n self\n ... | [
"0.7559921",
"0.75146073",
"0.7445585",
"0.7380994",
"0.73383844",
"0.72831327",
"0.7254705",
"0.7249812",
"0.72417593",
"0.72245",
"0.7172965",
"0.7169923",
"0.7126191",
"0.70330685",
"0.70035267",
"0.6864965",
"0.6833389",
"0.68190885",
"0.6811035",
"0.6811035",
"0.6734329"... | 0.0 | -1 |
Public: Initialize a Grammar. grammar A String grammar structure. | def initialize(grammar)
tokens = grammar.split(/[ \t]+/)
has_comments = tokens.index('#')
if has_comments
# remove all elements after comments position
tokens = tokens.each_with_index.each_with_object([]) do |(value, index), result|
result << value if index < has_comments
result
end
end
# we should have a well formed grammar
self.tree = GrammarTree.new(tokens)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n @parser = Grammar::RootParser.new\n end",
"def initialize(str, debug=false)\n setup_parser(str, debug)\n @g = KPeg::Grammar.new\n end",
"def initialize\n @parser = Grammar::RootParser.new\n end",
"def use_grammar(aGrammar)\n @grammar = aGrammar\n end"... | [
"0.6880689",
"0.679828",
"0.67973316",
"0.6648942",
"0.6560272",
"0.6545935",
"0.6452342",
"0.63491046",
"0.6189848",
"0.616323",
"0.6126192",
"0.61143816",
"0.6090868",
"0.6059614",
"0.6057729",
"0.60098934",
"0.5926562",
"0.59110296",
"0.58983785",
"0.5766961",
"0.5676426",... | 0.6714167 | 3 |
Create a new Crunch::Table headers Array of header names for the table block Block evaluated in the context of the instance, for convenience Examples table = Crunch::Table.new(["a", "b"]) do integer("a") date("b") end table.push(['1', '20110101']) Returns an instance of Crunch::Table | def initialize(headers, &block)
@transforms = []
@filters = []
@table = CSV::Table.new([])
@headers = headers
if block_given?
block.arity == 1 ? yield(self) : instance_eval(&block)
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_headers\n [\"Description\", \"Qty\", \"VAT\", \"Amount\"]\n end",
"def generate_header\n \"<table class='bodyTable'><thead><th>Testing element</th><th>Pass</th><th>Result</th><th>Time</th></thead><tbody>\"\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n ... | [
"0.68610454",
"0.6718063",
"0.66772056",
"0.66583395",
"0.65947783",
"0.6553201",
"0.6531749",
"0.64969134",
"0.64021444",
"0.63978773",
"0.63897514",
"0.63753027",
"0.63412887",
"0.6333678",
"0.62736034",
"0.6238453",
"0.6195734",
"0.61446553",
"0.6142147",
"0.6142147",
"0.6... | 0.59887403 | 32 |
Pushes a new row of data into the table. All data inserted into the table must pass through this method or else transforms and filters won't be applied. rows A hash or array of data Examples table.push(['1','2']) table.push(:a => '1', :b => '2') Returns the table for chaining | def push(*rows)
rows.each { |row| self << row }
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def <<(row)\n @rows << row\n end",
"def add_row(row)\n raise('Cannot add a row. No parameters have been set.') if rows.empty?\n\n # A quick 'deep clone' so that the input isn't modified\n row = Marshal.load(Marshal.dump(row))\n\n values = if row.is_a?(Array) # rubocop:disable Style/Ca... | [
"0.73353535",
"0.7305688",
"0.72963506",
"0.72722286",
"0.7213569",
"0.7167447",
"0.7167348",
"0.7115786",
"0.7082062",
"0.69063884",
"0.68705845",
"0.68298",
"0.6813468",
"0.6791857",
"0.6765364",
"0.673279",
"0.6728729",
"0.66346",
"0.65854436",
"0.6550558",
"0.65197086",
... | 0.7300586 | 2 |
With no args, block will be given the row. With args, block will get called once for each column, and passed the value of the that column. The value of the column will be replaced with the return value of the block | def transform(*cols, &block)
cols.empty? ? transform_row(&block) : transform_cols(*cols, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(&block)\n rows.each(&block)\n end",
"def each(&block)\n @rows.each(&block)\n end",
"def each(&block)\n @rows.each(&block)\n end",
"def each_row\n return rows.each unless block_given?\n\n rows.each { |row| yield(row) }\n end",
"def each(&block)\n @rows.each(&... | [
"0.75967485",
"0.7548146",
"0.7548146",
"0.7468015",
"0.73915565",
"0.73915565",
"0.7265067",
"0.71333325",
"0.7062467",
"0.70321536",
"0.6893565",
"0.6854243",
"0.6850472",
"0.6838657",
"0.6808586",
"0.6713386",
"0.6713127",
"0.6674884",
"0.6642381",
"0.6636305",
"0.6619817"... | 0.6102505 | 80 |
PATCH/PUT /lessons/1 PATCH/PUT /lessons/1.json | def update
respond_to do |format|
if @lesson.update(lesson_params)
format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }
format.json { render :show, status: :ok, location: @lesson }
else
format.html { render :edit }
format.json { render json: @lesson.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n #@lesson = Lesson.find(params[:id])\n @lesson = @course.lessons.find(params[:id])\n\n respond_to do |format|\n if @lesson.update_attributes(params[:lesson])\n format.html { redirect_to [@course,@lesson], :notice => 'Lesson was successfully updated.' }\n format.json { head :... | [
"0.6585176",
"0.6384863",
"0.6311742",
"0.6150693",
"0.6126043",
"0.60705626",
"0.6058295",
"0.60543084",
"0.60299987",
"0.60122746",
"0.6002451",
"0.5999441",
"0.59444463",
"0.5942285",
"0.59401834",
"0.5924028",
"0.59095794",
"0.5904164",
"0.59008974",
"0.5879816",
"0.58731... | 0.60526824 | 10 |
DELETE /lessons/1 DELETE /lessons/1.json | def destroy
@lesson.destroy
respond_to do |format|
format.html { redirect_to lessons_url, notice: 'Lesson was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @lesson = Lesson.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n format.html { redirect_to lessons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lesson = Lesson.find(params[:id])\n @lesson.destroy\n\n respond_to do |format|\n... | [
"0.7557879",
"0.7557879",
"0.7522046",
"0.74908125",
"0.72918993",
"0.7203461",
"0.7174986",
"0.7164306",
"0.71345705",
"0.7104502",
"0.70597553",
"0.70224255",
"0.70013577",
"0.69751513",
"0.69553506",
"0.6906766",
"0.6899398",
"0.6880577",
"0.6877875",
"0.6860072",
"0.68584... | 0.7289318 | 6 |
follower_ids = following_users.pluck(:id) all_ids = follower_ids << user.id Message.where(user_id: all_ids).order("created_at DESC") | def new
@message = Message.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def followed_users_and_me\n followed_users + [id]\n end",
"def user_ids_following_from(users)\n existing_friend_following = Follow.select(\"following_id\").where(:follower_type => 'User', :follower_id => self[:id], :following_type => 'User', :following_id => users)\n existing_friend_following.to_a.inje... | [
"0.75301784",
"0.74349314",
"0.73213476",
"0.7296894",
"0.7284098",
"0.7241594",
"0.72394276",
"0.7218514",
"0.7187114",
"0.71803623",
"0.7179165",
"0.7143974",
"0.7142008",
"0.7125157",
"0.7124665",
"0.7107112",
"0.7104446",
"0.71033055",
"0.707018",
"0.707018",
"0.70301294"... | 0.0 | -1 |
GET /gene_names/1 GET /gene_names/1.json | def show
@gene_name = GeneName.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @gene_name }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @gene_name = GeneName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gene_name }\n end\n end",
"def get_name(somegeneID)\n if self.gene_id.include? somegeneID\n return self.gene_name[self.gene_id.index(somegeneID)]\n end\n end",... | [
"0.6523728",
"0.61929667",
"0.6125455",
"0.60814244",
"0.5992108",
"0.5892785",
"0.5817058",
"0.57419527",
"0.5666294",
"0.56337494",
"0.5576316",
"0.55585",
"0.55035657",
"0.54977834",
"0.549643",
"0.549643",
"0.54895884",
"0.54817843",
"0.5468246",
"0.5441415",
"0.5419633",... | 0.7313697 | 0 |
GET /gene_names/new GET /gene_names/new.json | def new
@gene_name = GeneName.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @gene_name }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @gene_name = GeneName.new(params[:gene_name])\n\n respond_to do |format|\n if @gene_name.save\n format.html { redirect_to @gene_name, notice: 'Gene name was successfully created.' }\n format.json { render json: @gene_name, status: :created, location: @gene_name }\n else\n... | [
"0.7128864",
"0.68376195",
"0.6492006",
"0.63031137",
"0.628574",
"0.61504453",
"0.61068916",
"0.60997087",
"0.59849834",
"0.59618896",
"0.59547",
"0.59159017",
"0.59066784",
"0.5890762",
"0.58803785",
"0.58633363",
"0.58529395",
"0.585156",
"0.5829858",
"0.58291864",
"0.5823... | 0.7757667 | 0 |
POST /gene_names POST /gene_names.json | def create
@gene_name = GeneName.new(params[:gene_name])
respond_to do |format|
if @gene_name.save
format.html { redirect_to @gene_name, notice: 'Gene name was successfully created.' }
format.json { render json: @gene_name, status: :created, location: @gene_name }
else
format.html { render action: "new" }
format.json { render json: @gene_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @gene = Gene.new(gene_params)\n\n respond_to do |format|\n if @gene.save\n format.html { redirect_to @gene, notice: 'Gene was successfully created.' }\n format.json { render :show, status: :created, location: @gene }\n else\n format.html { render :new }\n fo... | [
"0.61724555",
"0.6016811",
"0.5987025",
"0.5412203",
"0.52780473",
"0.52758086",
"0.5190906",
"0.5107133",
"0.51040596",
"0.50974673",
"0.5056585",
"0.5034397",
"0.5033198",
"0.5006084",
"0.500223",
"0.4999419",
"0.49969375",
"0.49883807",
"0.4952977",
"0.49338788",
"0.490672... | 0.6964618 | 0 |
PUT /gene_names/1 PUT /gene_names/1.json | def update
@gene_name = GeneName.find(params[:id])
respond_to do |format|
if @gene_name.update_attributes(params[:gene_name])
format.html { redirect_to @gene_name, notice: 'Gene name was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @gene_name.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @gene.update(gene_params)\n format.html { redirect_to @gene, notice: 'Gene was successfully updated.' }\n format.json { render :show, status: :ok, location: @gene }\n else\n format.html { render :edit }\n format.json { render json: @... | [
"0.62671185",
"0.6239912",
"0.587007",
"0.57803935",
"0.57526296",
"0.56994194",
"0.5681606",
"0.56784767",
"0.56206864",
"0.56084037",
"0.56005967",
"0.55686736",
"0.5527372",
"0.55206954",
"0.55136704",
"0.5508712",
"0.5504186",
"0.54551697",
"0.5424152",
"0.54077333",
"0.5... | 0.7108051 | 0 |
DELETE /gene_names/1 DELETE /gene_names/1.json | def destroy
@gene_name = GeneName.find(params[:id])
@gene_name.destroy
respond_to do |format|
format.html { redirect_to gene_names_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @gene.destroy\n respond_to do |format|\n format.html { redirect_to genes_url, notice: 'Gene was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gid2name = Gid2name.find(params[:id])\n @gid2name.destroy\n\n respond_to do |forma... | [
"0.7046045",
"0.66885334",
"0.6572183",
"0.65706766",
"0.6563253",
"0.65061414",
"0.6476887",
"0.6476887",
"0.6461873",
"0.64480096",
"0.642958",
"0.64083153",
"0.6388026",
"0.62649286",
"0.62568575",
"0.62134457",
"0.6202229",
"0.619262",
"0.6091542",
"0.6087188",
"0.6071824... | 0.7675884 | 0 |
method to build curl object | def build_curl(url)
Curl::Easy.new("#{PDBHOST}#{url}") do |curl|
if CONFIG['ssl']
curl.cacert = CONFIG['cacert'].to_s
curl.cert = CONFIG['cert'].to_s
curl.cert_key = CONFIG['key'].to_s
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_curl\n # NOTE: I consider we should use long options to avoid ambiguity of ones like `-u` etc.\n @curl ||= begin\n ar = [\n \"--request\", self.class.http_method.to_s.upcase,\n \"--url\", \"#{api_url}/#{api_version}/#{self.class.path}\",\n ]\n\n ar += headers... | [
"0.75967425",
"0.75268686",
"0.68380034",
"0.64376676",
"0.64130086",
"0.6344649",
"0.62318945",
"0.6213715",
"0.62026006",
"0.6190994",
"0.6189388",
"0.614611",
"0.614066",
"0.6134958",
"0.6128212",
"0.606757",
"0.6051672",
"0.6029137",
"0.6022612",
"0.60007143",
"0.5988301"... | 0.7199725 | 2 |
method to query puppetdb | def query_pdb(url)
c = build_curl(url)
c.perform
c.body_str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_puppetdb(pql)\n require 'puppet/util/puppetdb'\n return Puppet::Util::Puppetdb.query_puppetdb(pql)\n rescue Puppet::Error\n return nil\n end",
"def query; end",
"def select(db); end",
"def select(db); end",
"def query\n end",
"def query sql\n resul... | [
"0.77725035",
"0.7105746",
"0.6875428",
"0.6875428",
"0.68655235",
"0.6784672",
"0.6593939",
"0.6541534",
"0.6520463",
"0.6460229",
"0.6443138",
"0.6438249",
"0.6418753",
"0.64102805",
"0.64070576",
"0.634114",
"0.6333336",
"0.6331949",
"0.63079125",
"0.6289129",
"0.6240217",... | 0.0 | -1 |
method to rearrange facts returned from puppetdb so that the key for 'value' is the fact name instead of the literal string 'value' and deletes the entry for 'name' | def format_facts(array, factname)
array.each do |h|
h.store(factname, h.delete('value'))
h.delete('name')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(name)\n name = name.to_sym\n if @values.key? name\n delete_name name\n @values.delete name\n end\n end",
"def unstore_fact(object) \n @bot.debug \"Unstoring #{object}\"\n query = config[:dbh].prepare \"DELETE FROM facts WHERE object=?\"\n query.execute object\n\n query ... | [
"0.58825797",
"0.54602957",
"0.54552096",
"0.53699535",
"0.5323647",
"0.5296735",
"0.52723265",
"0.5270282",
"0.52649075",
"0.5258038",
"0.5246185",
"0.5246185",
"0.5234265",
"0.52162075",
"0.5201379",
"0.51188725",
"0.51148087",
"0.51043636",
"0.5086966",
"0.5076144",
"0.507... | 0.6853401 | 0 |
method to merge arrays of hashes on a common field | def merge_hasharray(array1, array2, commonfield)
xref = {}
array2.each { |hash| xref[hash[commonfield]] = hash }
array1.each do |hash|
next if xref[hash[commonfield]].empty?
xref[hash[commonfield]].each_pair do |kk, vv|
next if commonfield == kk
hash[kk] = vv
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_merge original\n {}.tap do |result|\n original.each do |element|\n element.each_pair do |key, value|\n if value.is_a?(Array)\n result[key] ||= []\n result[key].concat value\n merge_if_equals(result[key])\n ... | [
"0.7185269",
"0.71112937",
"0.70626235",
"0.70444024",
"0.6896376",
"0.6871923",
"0.6836876",
"0.6836326",
"0.6812399",
"0.6811324",
"0.67422193",
"0.6689892",
"0.6644896",
"0.65271825",
"0.6498335",
"0.6489018",
"0.64767134",
"0.6463658",
"0.64213955",
"0.63873994",
"0.63410... | 0.7797683 | 0 |
method to make a hacky json inventory for Ansible | def hacky_json(nodes)
meta = {}
hosts = []
nodes.each do |node|
hosts.push(node['fqdn'])
meta[node['fqdn']] = { 'ansible_host' => node['ipaddress'] }
end
meta = { '_meta' => { 'hostvars' => meta } }
hosts = { 'all' => { 'hosts' => hosts } }
JSON.generate(hosts.merge(meta))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_inventory\n inventory = { 'all' => { 'hosts' => {} } }\n jack.each(kind: 'system') do |system|\n if options[:use_ip]\n iface = jack.fetch(kind: 'ipv4_interface',\n all?: { 'net.dns.fqdn' => system['net.dns.fqdn'] })\n ip = { 'ansible_host' => iface['ne... | [
"0.6750007",
"0.64115524",
"0.64115524",
"0.6111257",
"0.6083967",
"0.6029376",
"0.5920944",
"0.5916045",
"0.5763866",
"0.572963",
"0.5635833",
"0.5578304",
"0.55680144",
"0.55456483",
"0.5505147",
"0.5480267",
"0.5477722",
"0.54776424",
"0.5474821",
"0.54711664",
"0.5466885"... | 0.6420255 | 1 |
method that binds everything | def build_rsp
fqdn_query = '/pdb/query/v4/facts/fqdn'
json_hosts_fqdn = JSON.parse(query_pdb(fqdn_query))
format_facts(json_hosts_fqdn, 'fqdn')
ip_query = '/pdb/query/v4/facts/ipaddress'
json_hosts_ip = JSON.parse(query_pdb(ip_query))
format_facts(json_hosts_ip, 'ipaddress')
merged_facts = merge_hasharray(json_hosts_fqdn, json_hosts_ip, 'certname')
hacky_json(merged_facts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind\n \n end",
"def bind(*) end",
"def binding() end",
"def binding() end",
"def bind; binding() end",
"def binding; super end",
"def _binding() binding end",
"def _binding() binding end",
"def bind\n binding\n end",
"def bind\n binding\n end",
"def double_bind; 1; end"... | [
"0.80364126",
"0.7723263",
"0.76977605",
"0.76977605",
"0.7627199",
"0.75077534",
"0.7455632",
"0.7455632",
"0.7350354",
"0.7317509",
"0.7257231",
"0.6825217",
"0.6825217",
"0.6807524",
"0.6807524",
"0.6787254",
"0.6500465",
"0.6459307",
"0.6424632",
"0.621784",
"0.6179624",
... | 0.0 | -1 |
after_action :verify_authorized GET /users | def index
#authorize(User.new)
@users = User.all #policy_scope(User)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_action_on_resource_authorized\n end",
"def after_custom_authentication; end",
"def authorized_user!\n unless user_logged_in?\n redirect_to root_path\n end\n end",
"def authorized\n redirect_to new_user_session_path unless logged_in?\n end",
"def user_authorized\n redirect... | [
"0.7181621",
"0.7091758",
"0.6991131",
"0.69840246",
"0.6899836",
"0.6834795",
"0.68164015",
"0.67598045",
"0.67486525",
"0.67377645",
"0.67313373",
"0.67195946",
"0.6707871",
"0.66952443",
"0.6682875",
"0.66473675",
"0.66436255",
"0.6625738",
"0.66153634",
"0.6611591",
"0.66... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def user_params
params.require(:user).permit(:email, :password, :password_confirmation, :person_id, { :role_ids => [] })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_favoriteanimal
@favoriteanimal = FavoriteAnimal.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 |
Only allow a list of trusted parameters through. | def favoriteanimal_params
params.require(:favorite_animal).permit(:user_id, :animal_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.6948629",
"0.6813401",
"0.68012834",
"0.67958814",
"0.6745398",
"0.67409563",
"0.6526744",
"0.65207636",
"0.6492359",
"0.6433316",
"0.6433316",
"0.6433316",
"0.639903",
"0.6355392",
"0.63544166",
"0.63463736",
"0.6344045",
"0.6337686",
"0.632862",
"0.632862",
"0.632862",
... | 0.0 | -1 |
use the highest value found in our cache of avg_24_hours | def choose_suitable_avg_24_hours
expose_selected_values(:avg_24_hours).max
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max24hr_rec(ints)\n max24help(ints.sort) #O(4log4)=> 2.5 on ave 16 at worst\nend",
"def average(difficulty=1.0, hashrate=1)\n difficulty = current_difficulty\n hashrate = hash_per_second * 1024 * 1024 * 1024\n # Todo: find the current value for foo (seconds?)\n average_foo = eval(\"#{difficulty}... | [
"0.61861575",
"0.6152579",
"0.6047828",
"0.579395",
"0.5773138",
"0.57239884",
"0.5700676",
"0.5681136",
"0.56599873",
"0.5643403",
"0.5555947",
"0.5542025",
"0.55341023",
"0.5533211",
"0.5490417",
"0.5489318",
"0.5487585",
"0.54781145",
"0.54575014",
"0.54535234",
"0.5432349... | 0.715428 | 0 |
GET /brigade_memberships/1 GET /brigade_memberships/1.json | def show
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @membership = Adhocracy::Membership.find(params[:id])\n\n render json: @membership\n end",
"def GetMembership id\n\n APICall(path: \"group_memberships/#{id}.json\")\n\n end",
"def index\n @memberships = @user.memberships\n end",
"def show\n\n respond_to do |fo... | [
"0.6927647",
"0.6885264",
"0.67561066",
"0.6717465",
"0.6666008",
"0.66342163",
"0.6618249",
"0.6583743",
"0.65564793",
"0.6553806",
"0.65480375",
"0.64969146",
"0.64969146",
"0.64969146",
"0.6478067",
"0.6477985",
"0.64609075",
"0.64442027",
"0.6339653",
"0.62985045",
"0.627... | 0.7168519 | 0 |
POST /brigade_memberships POST /brigade_memberships.json | def create
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.create(brigade_membership_params)
respond_to do |format|
if @brigade_membership.save
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully created.' }
else
format.html { render :new }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateMembership params = {}\n \n APICall(path: 'group_memberships.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n #sanity checks, can only modify memberships that you own\n if params[:user_id].to_i != current_user.id then\n render json: {message:'Y... | [
"0.7416727",
"0.73998725",
"0.71063167",
"0.69991755",
"0.6829126",
"0.6822624",
"0.68153",
"0.6797499",
"0.67934155",
"0.6789455",
"0.674693",
"0.6669678",
"0.6652666",
"0.6620921",
"0.6614524",
"0.6540361",
"0.653778",
"0.65145373",
"0.64882565",
"0.6462233",
"0.64237595",
... | 0.7474953 | 0 |
PATCH/PUT /brigade_memberships/1 PATCH/PUT /brigade_memberships/1.json | def update
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
respond_to do |format|
if @brigade_membership.update(brigade_membership_params)
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully updated.' }
else
format.html { render :edit }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n authorize @organization_membership\n\n if @organization_membership.update(organization_membership_update_params)\n head :no_content\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end",
"def UpdateMembership params = {}\n \n ... | [
"0.66806126",
"0.66594344",
"0.6618375",
"0.6562799",
"0.6548472",
"0.65317965",
"0.6528354",
"0.64818823",
"0.64818823",
"0.64818823",
"0.64818823",
"0.64818823",
"0.64496964",
"0.64355224",
"0.642475",
"0.64119613",
"0.62516755",
"0.6248656",
"0.624579",
"0.6229899",
"0.622... | 0.73531294 | 0 |
DELETE /brigade_memberships/1 DELETE /brigade_memberships/1.json | def destroy
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
@brigade_membership.destroy
respond_to do |format|
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully destroyed.' }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @tribal_membership.destroy\n respond_to do |format|\n format.html { redirect_to tribal_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @band_membership = BandMembership.find(params[:id])\n @band_membership.destroy\n\n respond_to do |for... | [
"0.7470196",
"0.7281869",
"0.7260003",
"0.72548515",
"0.72548515",
"0.71653414",
"0.7135157",
"0.7053886",
"0.7029465",
"0.7007146",
"0.69640875",
"0.69522524",
"0.6949805",
"0.69477904",
"0.6911123",
"0.68736047",
"0.68141466",
"0.68113124",
"0.67352253",
"0.67142",
"0.67009... | 0.75529 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def brigade_membership_params
params.require(:brigade_membership).permit(:student_id).merge({brigade_id: params[:brigade_id]})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Defines a table to audit | def table(name, &block)
if block
@config[:tables][name] = Docile.dsl_eval(Watchy::Config::TableConfigBuilder.new, &block).build
else
@config[:tables][name] = {
rules: {
insert: [],
update: [],
delete: [ Watchy::DefaultDeleteRule.new ]
},
versioning_enabled: true
}
end
if @config[:tables][name][:rules][:delete].empty?
@config[:tables][name][:rules][:delete] << Watchy::DefaultDeleteRule.new
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit\n \"#{table.audit}.`#{name}`\"\n end",
"def show_create_table(db, table)\n end",
"def table\n Airmodel.client.table base_config[:base_id], base_config[:table_name]\n end",
"def audit\n identifier(audit_db)\n end",
"def audit_schema(as)\n @config[:audit_schema] ... | [
"0.71703553",
"0.6655187",
"0.6646758",
"0.66335547",
"0.6496281",
"0.649075",
"0.64494103",
"0.64037466",
"0.6395791",
"0.6388281",
"0.63853437",
"0.63444024",
"0.63139474",
"0.6312891",
"0.6312891",
"0.6312891",
"0.6312891",
"0.6283103",
"0.6270992",
"0.62434125",
"0.612916... | 0.58378536 | 47 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.