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 |
|---|---|---|---|---|---|---|
We need to know the column count before opening tabular context. | def table_open(opts)
@table = []
@table_multirow = {}
@table_multirow_next = {}
return ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_count\n @stkw_config[:max_col]\n end",
"def column_count\n is_container? ? get_content_param_by_key( :model_count_in_row ) : 0\n end",
"def column_count\n @stmt_api.column_count\n end",
"def number_of_columns\n return rows.first.length unless rows.empty?\n ra... | [
"0.7049613",
"0.6909892",
"0.68005216",
"0.67777175",
"0.67762566",
"0.6773424",
"0.676802",
"0.6696059",
"0.6693213",
"0.6677995",
"0.6551139",
"0.6538027",
"0.6506348",
"0.6441231",
"0.6289866",
"0.61741036",
"0.617348",
"0.6153409",
"0.61289954",
"0.61023325",
"0.60996467"... | 0.0 | -1 |
FIXME: need caption and label elements similar to image > figure | def table_close(opts)
output = "\\begin{table}\n"
output << " \\centering\n"
output << " \\begin{tabular}{ #{"l " * @table[0].size }}\n"
@table.each do |row|
output << " #{row.join(" & ")} \\\\\n"
end
output << " \\end{tabular}\n"
output << "\\end{table}\n"
output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def caption; end",
"def example(node)\n figure_attributes = {\n anchor: node.id,\n align: node.attr(\"align\"),\n alt: node.alt,\n title: node.title,\n 'suppress-title': node.attr(\"suppress-title\"),\n # TODO: is 'suppress-title' the correct attribute... | [
"0.70286727",
"0.6273495",
"0.6195517",
"0.60519785",
"0.59836686",
"0.5896454",
"0.5829528",
"0.5829528",
"0.5798733",
"0.5781889",
"0.5730286",
"0.5721611",
"0.57113063",
"0.5702275",
"0.5692435",
"0.5659796",
"0.56546277",
"0.5636285",
"0.55746865",
"0.55532104",
"0.552770... | 0.0 | -1 |
TODO: what do we do with (unknown) unicode entities ? | def entity(opts)
text = opts[:text][0..0] == '#' ? opts[:text][1..-1] : opts[:text]
ENTITIES[text]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entities(str)\n\t\tbegin\n\t\t\treturn str.unpack(\"U*\").collect do |s| \n\t\t\t\tstr = (s > 127 ? \"&##{s};\" : s.chr) \n\t\t\t\t# there are tons of these and they do nothing\n\t\t\t\tstr = \"\" if s == 160\n\t\t\t\tstr\n\t\t\tend.join(\"\")\n\t\trescue\n\t\t\tputs \"UTF-8 encoding failed on file\"\n\t\t\tre... | [
"0.72770315",
"0.70849603",
"0.69893247",
"0.67386657",
"0.6699765",
"0.66884524",
"0.6659015",
"0.6565358",
"0.6497426",
"0.6455232",
"0.64187795",
"0.6402388",
"0.6402388",
"0.63602144",
"0.635535",
"0.6340014",
"0.6296339",
"0.6252849",
"0.61957514",
"0.61953115",
"0.61834... | 0.5788654 | 45 |
TODO: what do we do with HTML? | def inline_html(opts)
opts[:text] || ""
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def html?; end",
"def html?; end",
"def html?; end",
"def html_markup_html(text); end",
"def to_html; end",
"def html=(b); end",
"def html_open; \"<html>\"; end",
"def inner_html(*args); end",
"def inner_html(*args); end",
"def html_markup_text(text); end",
"def html_markup_org(text); end",
... | [
"0.7814639",
"0.7814639",
"0.7814639",
"0.75425345",
"0.7362692",
"0.730858",
"0.72680545",
"0.7262803",
"0.7262803",
"0.7044644",
"0.7039862",
"0.7035748",
"0.69931936",
"0.6985139",
"0.6871205",
"0.6871205",
"0.6871205",
"0.6871205",
"0.6753466",
"0.67380095",
"0.6731718",
... | 0.0 | -1 |
Use this for block level commands that use \begin | def begin_chunk(type)
chunk_counter[type] += 1
return "\\begin{#{type}}" if 1 == chunk_counter[type]
''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pre_block\n end",
"def pre_block\n end",
"def begin() end",
"def begin; end",
"def begin_block(name, opts)\n @block_name_stack << name\n @block_opts_stack << opts\n @block_break_type_stack << \"entry-break\"\n end",
"def k_begin!\n # -> uncomment the next line to manually enable ... | [
"0.6832067",
"0.6832067",
"0.6695719",
"0.6401926",
"0.61936456",
"0.61648566",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
"0.60618323",
... | 0.6029531 | 29 |
Use this for block level commands that use \end | def end_chunk(type)
chunk_counter[type] -= 1
raise RuntimeError, "Bad latex #{type} nesting detected" if chunk_counter[type] < 0 # This should never need to happen
return "\\end{#{type}}" if 0 == chunk_counter[type]
''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _end!; end",
"def end_commands\n abstract!\n end",
"def end() end",
"def _close_open_block_commands\n return unless @stack.size > 1\n until @stack.size == 1\n sub = @stack.pop\n @stack.last << sub\n end\n end",
"def after_block_boundary?; end",
"def end... | [
"0.68269855",
"0.6681319",
"0.6657931",
"0.6423036",
"0.6390094",
"0.63747513",
"0.63747513",
"0.63747513",
"0.6371019",
"0.63505703",
"0.62689286",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122",
"0.6239122... | 0.0 | -1 |
Invoked after rollbacks to ensure versions records are not created for changes that never actually took place. Optimization: Use lazy `reset` instead of eager `reload` because, in many use cases, the association will not be used. | def clear_rolled_back_versions
versions.reset
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rollback\n objects.clear\n load\n finish_transaction\n end",
"def restore\r\n self.update(deleted: false)\r\n end",
"def reset_version_association_cache(record)\n association(:first_version).reset\n association(:last_version).reset\n end",
"def restore\n self.deleted_at_will... | [
"0.68587697",
"0.67080104",
"0.66804457",
"0.66732454",
"0.6664062",
"0.6546559",
"0.642199",
"0.6360955",
"0.634769",
"0.63160306",
"0.6305918",
"0.62969273",
"0.62710315",
"0.61806834",
"0.61359924",
"0.6105813",
"0.6071707",
"0.60432196",
"0.60406405",
"0.60373974",
"0.603... | 0.6488634 | 7 |
Invoked via`after_update` callback for when a previous version is reified and then saved. | def clear_version_instance
@record.send("#{@record.class.version_association_name}=", nil)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_update; end",
"def after_update; end",
"def save_version?\n\t\t\t \t\tchanged?\n\t\t\t \tend",
"def after_update\n end",
"def after_update\n end",
"def after_update(updated)\n # not required\n end",
"def save\n if self.changed? || self.relationships_changed?\n self._ve... | [
"0.7064584",
"0.7064584",
"0.6995887",
"0.6969663",
"0.6969663",
"0.6936537",
"0.6874516",
"0.6867572",
"0.6791612",
"0.66768384",
"0.6581367",
"0.6462485",
"0.6420276",
"0.63562995",
"0.635086",
"0.6332594",
"0.6305527",
"0.6303522",
"0.6271895",
"0.62384003",
"0.6233988",
... | 0.0 | -1 |
Returns true if this instance is the current, live one; returns false if this instance came from a previous version. | def live?
source_version.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def live?\n return @live\n end",
"def live?\n !!self[:live]\n end",
"def current?\n return self.tournament.live?\n end",
"def live?\n\t\tfalse\n\tend",
"def is_active?\n @@instance ? true : false\n end",
"def active?\n @@instance ? true : false\n end",
"def is... | [
"0.8029109",
"0.7996529",
"0.7488013",
"0.73778594",
"0.7218228",
"0.71708083",
"0.7164916",
"0.7158529",
"0.71326095",
"0.71115667",
"0.71115667",
"0.71115667",
"0.70779413",
"0.70632964",
"0.70355517",
"0.6975737",
"0.6962946",
"0.6940223",
"0.6924538",
"0.685686",
"0.68461... | 0.72945535 | 5 |
Returns the object (not a Version) as it became next. NOTE: if self (the item) was not reified from a version, i.e. it is the "live" item, we return nil. Perhaps we should return self instead? | def next_version
subsequent_version = source_version.next
subsequent_version ? subsequent_version.reify : @record.class.find(@record.id)
rescue StandardError # TODO: Rescue something more specific
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_version \n # NOTE: if self (the item) was not reified from a version, i.e. it is the\n # \"live\" item, we return nil. Perhaps we should return self instead?\n subsequent_version = trail_version ? next_trail_version : nil\n subsequent_version.reify if subsequent_version\n ... | [
"0.7434892",
"0.62816995",
"0.6225269",
"0.6225269",
"0.60895556",
"0.5996482",
"0.5970773",
"0.596392",
"0.596392",
"0.59614366",
"0.5856563",
"0.57928056",
"0.57708454",
"0.57452685",
"0.57292694",
"0.56984425",
"0.569605",
"0.56655747",
"0.5657479",
"0.56490105",
"0.560834... | 0.5516035 | 30 |
Returns the object (not a Version) as it was most recently. | def previous_version
(source_version ? source_version.previous : versions.last).try(:reify)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest\n self\n end",
"def most_recent\n self.stats.first\n end",
"def last_retrieved\n unless self.cache_object.nil?\n @last_retrieved = self.cache_object.last_retrieved\n end\n return @last_retrieved\n end",
"def latest\n first_one(&:latest)\n end",
"def last\... | [
"0.69080657",
"0.688553",
"0.6502014",
"0.64533544",
"0.64327466",
"0.6405051",
"0.62279284",
"0.6214403",
"0.61928153",
"0.6181023",
"0.6177548",
"0.6160452",
"0.61320424",
"0.6114755",
"0.6082766",
"0.6071734",
"0.60712016",
"0.60709447",
"0.60580814",
"0.6050851",
"0.60508... | 0.0 | -1 |
`recording_order` is "after" or "before". See ModelConfigon_destroy. | def record_destroy(recording_order)
return unless enabled? && !@record.new_record?
in_after_callback = recording_order == "after"
event = Events::Destroy.new(@record, in_after_callback)
# Merge data from `Event` with data from PT-AT. We no longer use
# `data_for_destroy` but PT-AT still does.
data = event.data.merge(data_for_destroy)
version = @record.class.paper_trail.version_class.create(data)
if version.errors.any?
log_version_errors(version, :destroy)
else
assign_and_reset_version_association(version)
version
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_destroy(recording_order)\n @in_after_callback = recording_order == \"after\"\n if enabled? && !@record.new_record?\n version = @record.class.paper_trail.version_class.create(data_for_destroy)\n if version.errors.any?\n log_version_errors(version, :destroy)\n else\... | [
"0.7764093",
"0.7262259",
"0.6072749",
"0.6072684",
"0.5874992",
"0.56880695",
"0.56730855",
"0.55762744",
"0.55464196",
"0.55233353",
"0.5462787",
"0.54593116",
"0.5405394",
"0.5399842",
"0.53864574",
"0.5326504",
"0.5318231",
"0.52783805",
"0.5268671",
"0.5230486",
"0.52133... | 0.720027 | 2 |
Invoked via callback when a user attempts to persist a reified `Version`. | def reset_timestamp_attrs_for_update_if_needed
return if live?
@record.send(:timestamp_attributes_for_update_in_model).each do |column|
@record.send("restore_#{column}!")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_version\n if @saving_version\n @saving_version = nil\n rev = self.class.versioned_class.new\n clone_versioned_model(self, rev)\n rev.send(\"#{self.class.version_column}=\", send(self.class.version_column))\n rev.send(\"#{self.class.versioned_... | [
"0.6767819",
"0.6356407",
"0.63177186",
"0.624026",
"0.61787057",
"0.61785525",
"0.6162293",
"0.6134631",
"0.61163294",
"0.610486",
"0.60628444",
"0.6050775",
"0.60319966",
"0.6008665",
"0.5993039",
"0.5974415",
"0.5964341",
"0.5944025",
"0.5917223",
"0.5885919",
"0.5820393",... | 0.0 | -1 |
Save, and create a version record regardless of options such as `:on`, `:if`, or `:unless`. `in_after_callback`: Indicates if this method is being called within an `after` callback. Defaults to `false`. `options`: Optional arguments passed to `save`. This is an "update" event. That is, we record the same data we would in the case of a normal AR `update`. | def save_with_version(in_after_callback: false, **options)
::PaperTrail.request(enabled: false) do
@record.save(**options)
end
record_update(force: true, in_after_callback: in_after_callback, is_touch: false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_if_changed(options = {})\n save if changed?\n end",
"def save(options = {})\n options.assert_valid_keys\n if new_record? then create\n else update\n end\n @new_record = false\n true\n end",
"def save_without_transaction(options = {})\n re... | [
"0.55681676",
"0.546597",
"0.5424957",
"0.5261846",
"0.5205442",
"0.5185259",
"0.51203305",
"0.5096601",
"0.508088",
"0.5063638",
"0.5022155",
"0.4992403",
"0.49849766",
"0.49799106",
"0.49785915",
"0.49731565",
"0.49558645",
"0.49551806",
"0.4948411",
"0.48551416",
"0.485419... | 0.8048526 | 0 |
Like the `update_column` method from `ActiveRecord::Persistence`, but also creates a version to record those changes. | def update_column(name, value)
update_columns(name => value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_table_column(column)\n changes_to_commit << ColumnChange::Update.from_column(column)\n end",
"def touch_with_version(name = nil)\n unless @record.persisted?\n raise ::ActiveRecord::ActiveRecordError, \"can not touch on a new record object\"\n end\n attributes = @record.se... | [
"0.7039554",
"0.632113",
"0.6237305",
"0.60738635",
"0.59229565",
"0.58881056",
"0.58367413",
"0.58325815",
"0.57899874",
"0.5747011",
"0.5673642",
"0.5666944",
"0.56628436",
"0.56628436",
"0.56628436",
"0.56628436",
"0.56628436",
"0.56628436",
"0.56628436",
"0.56628436",
"0.... | 0.66757715 | 3 |
Like the `update_columns` method from `ActiveRecord::Persistence`, but also creates a version to record those changes. | def update_columns(attributes)
# `@record.update_columns` skips dirty-tracking, so we can't just use
# `@record.changes` or @record.saved_changes` from `ActiveModel::Dirty`.
# We need to build our own hash with the changes that will be made
# directly to the database.
changes = {}
attributes.each do |k, v|
changes[k] = [@record[k], v]
end
@record.update_columns(attributes)
record_update_columns(changes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_columns(attributes)\n # `@record.update_columns` skips dirty tracking, so we can't just use `@record.changes` or\n # @record.saved_changes` from `ActiveModel::Dirty`. We need to build our own hash with the\n # changes that will be made directly to the database.\n changes = {}\n ... | [
"0.6892118",
"0.6512092",
"0.645296",
"0.6367316",
"0.6367316",
"0.6239952",
"0.6223718",
"0.61987233",
"0.61936164",
"0.6169181",
"0.6166549",
"0.6117445",
"0.6087442",
"0.6019071",
"0.59866524",
"0.5948828",
"0.5941088",
"0.5935084",
"0.59326",
"0.5932556",
"0.5928722",
"... | 0.6872302 | 1 |
Returns the object (not a Version) as it was at the given timestamp. | def version_at(timestamp, reify_options = {})
# Because a version stores how its object looked *before* the change,
# we need to look for the first version created *after* the timestamp.
v = versions.subsequent(timestamp, true).first
return v.reify(reify_options) if v
@record unless @record.destroyed?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamp\n self[:timestamp]\n end",
"def timestamp\n first(:timestamp)\n end",
"def timestamp\n TimeStamp.new\n end",
"def timestamp\n _timestamp.as_time\n end",
"def timestamp\n @timestamp ||= Time.parse(self['timestamp'])\n end",
"def timestamp\n _t... | [
"0.6742115",
"0.6620841",
"0.6573856",
"0.65109605",
"0.64427716",
"0.6441582",
"0.63332516",
"0.6287034",
"0.6264239",
"0.6238899",
"0.62141323",
"0.62141323",
"0.6133868",
"0.59872115",
"0.59775907",
"0.59217656",
"0.5907451",
"0.5880321",
"0.5872435",
"0.5872435",
"0.58724... | 0.6677518 | 2 |
Returns the objects (not Versions) as they were between the given times. | def versions_between(start_time, end_time)
versions = send(@record.class.versions_association_name).between(start_time, end_time)
versions.collect { |version| version_at(version.created_at) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def within_range\n @site.loads.desc(:time).where(:time.gt => @timeframe.from, :time.lt => @timeframe.to)\n end",
"def sensor_readings_between(start_time, end_time, kind)\n start_time.change usec: 0\n end_time.change usec: 0\n\n time_series = []\n value = sensor_at start_time, kind\n\n edges = ... | [
"0.609356",
"0.6038365",
"0.59471",
"0.58981794",
"0.5897811",
"0.58473265",
"0.5808229",
"0.58017653",
"0.5774026",
"0.5755324",
"0.5754886",
"0.57115996",
"0.56883025",
"0.5662758",
"0.565742",
"0.56564546",
"0.5629121",
"0.55332357",
"0.55139136",
"0.5443632",
"0.5436151",... | 0.65474784 | 1 |
PTAT extends this method to add its transaction id. | def data_for_create
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_transaction_id\n begin\n self.transaction_id = SecureRandom.random_number(FIXNUM_MAX)\n end while self.class.exists?(transaction_id: transaction_id)\n logger.info(\"transaction id: #{self.transaction_id}\")\n end",
"def add_parent_transaction_id xml, id\n xml.tag!(:'parent-transacti... | [
"0.67579395",
"0.6756487",
"0.6674309",
"0.6612841",
"0.64687634",
"0.63546777",
"0.62346244",
"0.62334496",
"0.62160057",
"0.61904716",
"0.6158412",
"0.61004186",
"0.60848534",
"0.59938097",
"0.5987529",
"0.5987529",
"0.5987529",
"0.5987275",
"0.5987237",
"0.5909745",
"0.589... | 0.0 | -1 |
PTAT extends this method to add its transaction id. | def data_for_destroy
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_transaction_id\n begin\n self.transaction_id = SecureRandom.random_number(FIXNUM_MAX)\n end while self.class.exists?(transaction_id: transaction_id)\n logger.info(\"transaction id: #{self.transaction_id}\")\n end",
"def add_parent_transaction_id xml, id\n xml.tag!(:'parent-transacti... | [
"0.6759873",
"0.6758094",
"0.66765094",
"0.66149646",
"0.64706314",
"0.63541204",
"0.6236645",
"0.62328666",
"0.62155277",
"0.61920756",
"0.6160318",
"0.61041033",
"0.60842246",
"0.5993662",
"0.5990274",
"0.5990274",
"0.5990274",
"0.599017",
"0.59901357",
"0.59096503",
"0.589... | 0.0 | -1 |
PTAT extends this method to add its transaction id. | def data_for_update
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_transaction_id\n begin\n self.transaction_id = SecureRandom.random_number(FIXNUM_MAX)\n end while self.class.exists?(transaction_id: transaction_id)\n logger.info(\"transaction id: #{self.transaction_id}\")\n end",
"def add_parent_transaction_id xml, id\n xml.tag!(:'parent-transacti... | [
"0.67579395",
"0.6756487",
"0.6674309",
"0.6612841",
"0.64687634",
"0.63546777",
"0.62346244",
"0.62334496",
"0.62160057",
"0.61904716",
"0.6158412",
"0.61004186",
"0.60848534",
"0.59938097",
"0.5987529",
"0.5987529",
"0.5987529",
"0.5987275",
"0.5987237",
"0.5909745",
"0.589... | 0.0 | -1 |
PTAT extends this method to add its transaction id. | def data_for_update_columns
{}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_transaction_id\n begin\n self.transaction_id = SecureRandom.random_number(FIXNUM_MAX)\n end while self.class.exists?(transaction_id: transaction_id)\n logger.info(\"transaction id: #{self.transaction_id}\")\n end",
"def add_parent_transaction_id xml, id\n xml.tag!(:'parent-transacti... | [
"0.67579573",
"0.67579025",
"0.66744643",
"0.6614034",
"0.6469101",
"0.63557094",
"0.62361425",
"0.6235558",
"0.6218457",
"0.6190395",
"0.61594576",
"0.6102762",
"0.6085417",
"0.5993829",
"0.59896016",
"0.59896016",
"0.59896016",
"0.5989326",
"0.5989288",
"0.5912693",
"0.5890... | 0.0 | -1 |
Is PT enabled for this particular record? | def enabled?
PaperTrail.enabled? &&
PaperTrail.request.enabled? &&
PaperTrail.request.enabled_for_model?(@record.class)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled?\n PaperTrail.enabled? &&\n PaperTrail.request.enabled_for_controller? &&\n PaperTrail.request.enabled_for_model?(@record.class)\n end",
"def service_pt?()\n return true if (@service == TAC_PLUS_AUTHEN_SVC_PT)\n return false\n end",
"def enabled?()\n ... | [
"0.6744152",
"0.67093927",
"0.66768336",
"0.66733325",
"0.667173",
"0.65645254",
"0.6560633",
"0.6503642",
"0.649047",
"0.6402444",
"0.6402444",
"0.6382808",
"0.6382808",
"0.6382808",
"0.6382808",
"0.63772213",
"0.636693",
"0.6354606",
"0.6354606",
"0.6324001",
"0.62564224",
... | 0.6855143 | 0 |
GET /test_attempts GET /test_attempts.json | def index
@test_attempts = TestAttempt.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_exam_attempts(user_id, course_id, exam_id)\r\n get(Path::USERS_COURSES_EXAMS_ATTEMPTS % [user_id, course_id, exam_id])\r\n end",
"def index\n @attempts = Attempt.all\n end",
"def index\n @attempts = Attempt.all\n end",
"def index\n @attempts = Attempt.all\n end",
"def attempts\n... | [
"0.7020565",
"0.7015215",
"0.7015215",
"0.7015215",
"0.63162",
"0.62854147",
"0.62022185",
"0.6186667",
"0.6124291",
"0.61129874",
"0.6060357",
"0.60376835",
"0.60282123",
"0.5984391",
"0.59541935",
"0.58617055",
"0.58617055",
"0.58617055",
"0.58552915",
"0.5854688",
"0.58198... | 0.74733645 | 0 |
GET /test_attempts/1 GET /test_attempts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @test_attempts = TestAttempt.all\n end",
"def index\n @attempts = Attempt.all\n end",
"def index\n @attempts = Attempt.all\n end",
"def index\n @attempts = Attempt.all\n end",
"def get_exam_attempts(user_id, course_id, exam_id)\r\n get(Path::USERS_COURSES_EXAMS_ATTEMPTS % [... | [
"0.71028286",
"0.6848326",
"0.6848326",
"0.6848326",
"0.6759416",
"0.6370069",
"0.61662966",
"0.6079555",
"0.60743475",
"0.60399514",
"0.60137314",
"0.59130067",
"0.5886458",
"0.58822364",
"0.58124816",
"0.57899743",
"0.57635653",
"0.57532656",
"0.57520497",
"0.57520497",
"0.... | 0.0 | -1 |
POST /test_attempts POST /test_attempts.json | def create
@concept = CustomizedConcept.find(params[:test_attempt][:customized_concept_id])
@tests = @concept.tests
@test_attempt = @concept.test_attempts.new(test_attempt_params)
@course = @concept.course
@answer_records = @test_attempt.answer_records
@error_test = check_answer(params[:select_answers])
respond_to do |format|
if (@error_test.length == 0)
@test_attempt.test_time_sec = Time.now.to_i - @test_attempt.test_time_sec
if @test_attempt.save
format.html { redirect_to course_customized_concept_path(@course, @concept), notice: 'Successfully pass' }
format.json { render :show, status: :created, location: @test_attempt }
end
else
@test_attempt.retry_time += 1
binding.pry
@error_test.each do |e|
@answer_records.each do |a|
a.error_times += 1 if a.test == e
end
end
format.html { render :new }
format.json { render json: @test_attempt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @test_attempts = TestAttempt.all\n end",
"def test_attempt_params\n params.require(:test_attempt).permit(:customized_concept_id, :user, :retry_time, :test_time_sec,\n answer_records_attributes: [:id, :test, :error_times])\n end",
"def attempt_par... | [
"0.64922994",
"0.6301416",
"0.6272404",
"0.6265595",
"0.6096744",
"0.60820657",
"0.6060679",
"0.60411525",
"0.5949924",
"0.5920747",
"0.5888943",
"0.5827398",
"0.5815964",
"0.5808387",
"0.5780827",
"0.5769073",
"0.5769073",
"0.5769073",
"0.5760686",
"0.5748226",
"0.5723192",
... | 0.67356116 | 0 |
PATCH/PUT /test_attempts/1 PATCH/PUT /test_attempts/1.json | def update
respond_to do |format|
if @test_attempt.update(test_attempt_params)
format.html { redirect_to @test_attempt, notice: 'Test attempt was successfully updated.' }
format.json { render :show, status: :ok, location: @test_attempt }
else
format.html { render :edit }
format.json { render json: @test_attempt.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthd... | [
"0.6290403",
"0.62838197",
"0.6269295",
"0.6269295",
"0.61428195",
"0.61423916",
"0.6140218",
"0.61187696",
"0.61187696",
"0.61187696",
"0.60879266",
"0.6079368",
"0.5982612",
"0.59760875",
"0.59760404",
"0.59466",
"0.59357774",
"0.5934108",
"0.592115",
"0.58336705",
"0.58206... | 0.67448276 | 0 |
DELETE /test_attempts/1 DELETE /test_attempts/1.json | def destroy
@test_attempt.destroy
respond_to do |format|
format.html { redirect_to test_attempts_url, notice: 'Test attempt was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @attempt.destroy\n respond_to do |format|\n format.html { redirect_to attempts_url, notice: \"Attempt was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @attempt.destroy\n respond_to do |format|\n format.html { redirect_to ... | [
"0.7025353",
"0.7024115",
"0.7024115",
"0.7024115",
"0.6991073",
"0.6974722",
"0.6862093",
"0.68037313",
"0.6664713",
"0.6640213",
"0.6583524",
"0.65667784",
"0.65618783",
"0.6504407",
"0.6500759",
"0.64974695",
"0.6476051",
"0.6441583",
"0.64395326",
"0.6425904",
"0.64183784... | 0.7457809 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_test_attempt
@test_attempt = TestAttempt.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def test_attempt_params
params.require(:test_attempt).permit(:customized_concept_id, :user, :retry_time, :test_time_sec,
answer_records_attributes: [:id, :test, :error_times])
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 |
Teardown and setup for quick recycling of env. within a single test | def recycle; teardown; setup; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown\n reset_test_env\n end",
"def teardown\n reset_test_env\n end",
"def setup_environment; end",
"def teardown; end",
"def teardown; end",
"def teardown\n # if necessary\n end",
"def teardown\n puts \"tear down\"\n end",
"def with_test_env\n in_separate_environment do\n ... | [
"0.78927827",
"0.78927827",
"0.7304628",
"0.6832387",
"0.6832387",
"0.67588377",
"0.6746976",
"0.67307633",
"0.67306453",
"0.672041",
"0.672041",
"0.672041",
"0.672041",
"0.672041",
"0.672041",
"0.672041",
"0.672041",
"0.671861",
"0.67112774",
"0.67093205",
"0.6701068",
"0.... | 0.78115684 | 2 |
Add more helper methods to be used by all tests here... | def login_using_basic_auth
@request.env['HTTP_AUTHENTICATION'] = ActionController::HttpAuthentication::Basic.encode_credntials("", "")
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.73305196",
"0.70179296",
"0.70179296",
"0.70179296",
"0.67745805",
"0.66819173",
"0.66819173",
"0.65844315",
"0.65526474",
"0.63783103",
"0.6375409",
"0.6330069",
"0.62822294",
"0.62822294",
"0.6251325",
"0.6144103",
"0.6138683",
"0.6123141",
"0.61083466",
"0.6097728",
"0.... | 0.0 | -1 |
def parse_csv_file separated purely to allow stubbing in testing I can't seem to find a way to stub 'birth_data.count' | def screening_data_count
screening_data.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_people_raw\n @@people_raw = CsvMapper.import('test_ward.csv') do\n read_attributes_from_file\n end\nend",
"def parse_all(filename, vio, rac, sex, age)\n count = 0\n CSV.foreach(filename, headers: true, converters: %i[numeric date]) do |row|\n vio[row[\"violation\"]] += 1\n rac... | [
"0.6710014",
"0.60771066",
"0.57027805",
"0.5647552",
"0.5643096",
"0.56399906",
"0.56284237",
"0.56060624",
"0.5597815",
"0.5587393",
"0.5566803",
"0.5562365",
"0.555864",
"0.5537152",
"0.55307895",
"0.5491575",
"0.5487364",
"0.5482249",
"0.54817575",
"0.5475846",
"0.5442933... | 0.0 | -1 |
for gebnerating setter method attr_accessor will create both getter and setter Like Constructor | def initialize
#instance variables uses @
@gadget_type="Electronics"
@production_no=rand(1..1000)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_accessor(*args)\n attr_reader(*args)\n attr_writer(*args)\n end",
"def initialize\n @attribute = 'truite'\n @accessor = 'pouet'\n end",
"def define_attr_accessor(attr)\n attr_accessor(attr)\n end",
"def attr_accessor(*fields)\n attr_reader *fields\n attr_write... | [
"0.754305",
"0.7355564",
"0.7097333",
"0.7034848",
"0.69340396",
"0.6880017",
"0.6791772",
"0.6750188",
"0.67476565",
"0.67332685",
"0.67332685",
"0.67332685",
"0.6718221",
"0.6715299",
"0.6656928",
"0.6642113",
"0.66419506",
"0.6635315",
"0.66347235",
"0.6616324",
"0.6604475... | 0.0 | -1 |
GET /rubrics GET /rubrics.json def index | def show
@articles = @rubric.articles.order('published_at desc').paginate(:page => params[:page], :per_page => 18)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @rubrics = Rubric.all\n end",
"def index\n @rubrics = Rubric.all\n end",
"def index\n @rubrics = Rubric.all\n end",
"def index\n @recipies = Recipy.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipies }\n end\n end",
... | [
"0.74826354",
"0.74826354",
"0.74826354",
"0.6474487",
"0.6399329",
"0.6282117",
"0.62336266",
"0.6200526",
"0.6187744",
"0.6171451",
"0.60933053",
"0.60553885",
"0.6046043",
"0.6030307",
"0.60105973",
"0.59881395",
"0.5978426",
"0.5973546",
"0.5963514",
"0.5949516",
"0.59470... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_rubric
@rubric = Rubric.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def rubric_params
params.require(:rubric).permit(:name)
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
Class instance variable for paginating Subsplash API | def initialize
@page = 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callSubsplashAPI\n raw_response = HTTParty.get(\"#{ENDPOINT}?page[size]=50&fields=title,youtube_url,reach&page[num]=#{@page}\", \n format: :json, \n :headers => HEADERS)\n case raw_response.code \n when 200\n compileSubsplashResponse(raw_response) if raw_response.success?\n i... | [
"0.72569895",
"0.6734847",
"0.67252344",
"0.67119455",
"0.6697824",
"0.6611013",
"0.6609346",
"0.6601883",
"0.65448755",
"0.650519",
"0.6497489",
"0.6436202",
"0.64159554",
"0.6393097",
"0.6392828",
"0.63905334",
"0.6370722",
"0.6311784",
"0.6309917",
"0.6306833",
"0.6300152"... | 0.67327225 | 2 |
Call Subsplash API recursively. Can adjust number of pages, or base recursion on number of results. If number of results < 50, do not call end of data. Response is sent to compile for every 50 results this limiter is due to the YouTube API which will only take a batch request of 50 videos. | def callSubsplashAPI
raw_response = HTTParty.get("#{ENDPOINT}?page[size]=50&fields=title,youtube_url,reach&page[num]=#{@page}",
format: :json,
:headers => HEADERS)
case raw_response.code
when 200
compileSubsplashResponse(raw_response) if raw_response.success?
if @page < 5
@page += 1
callSubsplashAPI
end
when 404
puts "Page not found. Code: #{raw_response.code}"
when 500...600
puts "An error occured. Code: #{raw_response.code}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_with_limit\n start_result = 10\n start_result.step(RESULTS_LIMIT, 10) do |number|\n response = get_subdomains!(number)\n break unless response.items_present?\n end\n end",
"def make_recursive_call\n offset = 0\n p_args = set_pagination(offset, page_size, ar... | [
"0.6706481",
"0.66142845",
"0.6148446",
"0.58866423",
"0.57100856",
"0.5677769",
"0.56404835",
"0.552191",
"0.5510358",
"0.54698825",
"0.53907806",
"0.53449345",
"0.5322345",
"0.53222734",
"0.5284838",
"0.52718073",
"0.52617306",
"0.5242977",
"0.5237955",
"0.52278554",
"0.521... | 0.80470526 | 0 |
Batch is created as a string. Some videos do not contain a valid YouTube ID and will not be sent to the YouTube API. Each video received from the Subsplash API will be entered into the database. Duration and views will be updated when the YouTube API is called. | def compileSubsplashResponse(response)
batch = ''
response["_embedded"]["media-items"].each do |r|
youtube_id = extractYouTubeID(r["youtube_url"])
batch << youtube_id + ',' unless youtube_id == ''
video = Video.new.tap do |v|
v.youtube_id = youtube_id
v.youtube_url = r["youtube_url"]
v.title = r["title"]
v.duration = nil
v.views = nil
v.reach = r["reach"]
v.save
end
end
batch.chop!()
callYouTubeAPI(batch)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def callYouTubeAPI(batch_string)\n raw_response = HTTParty.get(\"https://www.googleapis.com/youtube/v3/videos?key=#{YOUTUBE_API_KEY}&part=contentDetails,statistics&id=#{batch_string}\",\n format: :json)\n case raw_response.code \n when 200\n compileYouTubeResponse(raw_response)\n when 4... | [
"0.68079823",
"0.61422765",
"0.6060544",
"0.58525866",
"0.5809023",
"0.559625",
"0.5557311",
"0.55331427",
"0.55310816",
"0.5493384",
"0.5426864",
"0.5419059",
"0.54031295",
"0.5401127",
"0.53936553",
"0.5385374",
"0.5379504",
"0.5367032",
"0.5365027",
"0.5342547",
"0.5325793... | 0.65406114 | 1 |
YouTube API batch request with up to 50 videos in each request. Response is sent to compile. | def callYouTubeAPI(batch_string)
raw_response = HTTParty.get("https://www.googleapis.com/youtube/v3/videos?key=#{YOUTUBE_API_KEY}&part=contentDetails,statistics&id=#{batch_string}",
format: :json)
case raw_response.code
when 200
compileYouTubeResponse(raw_response)
when 404
puts "Page not found. Code: #{raw_response.code}"
when 500...600
puts "An error occured. Code: #{raw_response.code}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compileSubsplashResponse(response)\n batch = ''\n response[\"_embedded\"][\"media-items\"].each do |r|\n youtube_id = extractYouTubeID(r[\"youtube_url\"])\n batch << youtube_id + ',' unless youtube_id == ''\n video = Video.new.tap do |v|\n v.youtube_id = youtube_id\n v.youtub... | [
"0.6731681",
"0.65895545",
"0.63735825",
"0.62353885",
"0.5965035",
"0.59179854",
"0.5858738",
"0.579918",
"0.57695913",
"0.5743935",
"0.5720264",
"0.569859",
"0.5685575",
"0.5636389",
"0.56310767",
"0.56224227",
"0.5596784",
"0.55940855",
"0.5591624",
"0.5478172",
"0.5456952... | 0.73756135 | 0 |
YouTube API response is used to update each video in the datebase with duration and number views. Duration is saved as a ISO 8601 duration integer, per YouTube's response format which is stored as total seconds. | def compileYouTubeResponse(response)
response["items"].each do |video|
update = Video.find_by youtube_id: video["id"]
update.duration = ActiveSupport::Duration.parse(video["contentDetails"]["duration"])
update.views = video["statistics"]["viewCount"]
update.save
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n\n @video = Video.find(params[:id])\n\n\n @url = params[:video][:url]\n\n require 'uri'\n\n\n if(@url.downcase.include? 'youtube.com')\n ##create ways to catch if user is using \n query_string = URI.parse(params[:video][:url]).query\n parameters = Hash[URI.decode_www_form(q... | [
"0.62499845",
"0.6223936",
"0.5929072",
"0.5828676",
"0.5828676",
"0.58258563",
"0.5819271",
"0.57894987",
"0.5717434",
"0.57066864",
"0.56964755",
"0.5614211",
"0.55611986",
"0.55580765",
"0.5518987",
"0.55094063",
"0.54841673",
"0.547447",
"0.5459698",
"0.5440079",
"0.54383... | 0.7652031 | 0 |
Ruby gem used to extract YouTube ID from URL of video. Returns '' if unable to extract ID. ID is used to call YouTube API which requires an ID to find a single video. | def extractYouTubeID(url)
YoutubeVideoId.extract(url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_youtube_video_id(url)\n # find id\n result = url.match /https*\\:\\/\\/.*youtube\\.com\\/watch\\?v=(.*)/\n # return id or nil\n result ? result[1] : nil\n end",
"def parse_youtube_id(url)\n url =~ /[v]=([^&]*)/\n id = $1\n \n if id.nil?\n # when there is ... | [
"0.8268028",
"0.8099546",
"0.79548645",
"0.79049766",
"0.780002",
"0.7729929",
"0.7710642",
"0.7661107",
"0.74572164",
"0.74178547",
"0.7310259",
"0.7209714",
"0.71756095",
"0.7148213",
"0.7142817",
"0.7142817",
"0.7053817",
"0.70231795",
"0.70194304",
"0.6986369",
"0.6963433... | 0.8318692 | 0 |
Create a prompt that asks the user if they would like to display their balance, withdraw or deposit. Write three methods to perform these calculations and output the result to the user. Here is a sample output: Your current balance is 4000 What would you like to do? (deposit, withdraw, check_balance) deposit How much would you like to deposit? 1000 Your current balance is 5000 Are you done? yes Thank you! | def bank_transactions(starting_balance)
balance = starting_balance.to_f
puts "Your starting balance is $#{balance}"
continue = "yes"
while continue == "yes"
puts "What would you like to do? (deposit (d), withdraw (w), check_balance(c))"
transaction = gets.chomp
if transaction == "d"
#deposit
puts "How much would you like to deposit?"
deposit = gets.chomp
balance += deposit.to_f
elsif transaction == "w"
#withdraw
puts "How much would you like to withdraw?"
withdraw = gets.chomp
balance -= withdraw.to_f
end
# check balance
puts "Your current balance is: $#{balance}"
transaction = nil
puts "Do you want to continue? yes/no"
continue = gets.chomp
end
puts "Thank you, and have a nice day!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bank()\n @balance = 4000\n\n def withdraw()\n puts \"How much would you like to withdraw?\"\n @balance -= gets.chomp.to_i\n puts \"Your current balance is %s\" % @balance\n puts \"Are you done?\"\n response = gets.chomp\n if response == 'yes'\n abort('Goodbye')\n elsif response == '... | [
"0.7903301",
"0.75240123",
"0.7393925",
"0.7365348",
"0.72983813",
"0.72426957",
"0.71714187",
"0.71714187",
"0.7143373",
"0.71250814",
"0.7113198",
"0.71019244",
"0.70907474",
"0.70346606",
"0.703245",
"0.70085806",
"0.6998683",
"0.6998683",
"0.69651437",
"0.6927544",
"0.688... | 0.74363446 | 2 |
def name self[self.class.current_locale_column(:name)].to_s.html_safe end | def collection_values
collection.each_line.find_all(&:present?).map(&:strip)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_display\n self.name[I18n.locale]\n end",
"def name\n object.translated_name(scope[:locale] || I18n.default_locale)\n end",
"def formatted_name\n \"#{self.id} - #{self.name}\"\n #This is used to bring value on each page.\n end",
"def to_s\n\t\tself.name.titleize\n\tend",
"def nam... | [
"0.8426713",
"0.7774385",
"0.74248517",
"0.7416438",
"0.7408126",
"0.7321583",
"0.732082",
"0.732082",
"0.7267729",
"0.7211553",
"0.71128327",
"0.71128327",
"0.711139",
"0.71083605",
"0.71083605",
"0.7101371",
"0.7100053",
"0.707831",
"0.7076573",
"0.7070379",
"0.7070379",
... | 0.0 | -1 |
number1 The first Integer to compare. number2 The second Integer to compare. Examples max_of_two(1, 2) => 2 Returns the largest Integer. | def max_of_two(number1, number2)
if number1 > number2
return number1
else
return number2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_number (number_1, number_2)\n \n [number_1, number_2].max\n \nend",
"def max_of_two(num1, num2)\n \n if num1 < num2\n return num2\n else \n return num1\n end\n end",
"def max_of_two(number1,number2)\n if number1 < number2\n output ... | [
"0.8357308",
"0.83250415",
"0.8220368",
"0.8197038",
"0.81938386",
"0.81668156",
"0.81504905",
"0.8143155",
"0.8143152",
"0.8143152",
"0.8131677",
"0.79577345",
"0.7917452",
"0.78898805",
"0.7812748",
"0.7768626",
"0.7747248",
"0.77443016",
"0.76138526",
"0.7565043",
"0.74169... | 0.8364421 | 0 |
def to_param short_uuid end | def short_uuid
uuid[0..7]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_param\n uuid\n end",
"def to_param\n uuid\n end",
"def to_param\n uuid\n end",
"def to_param\n uuid\n end",
"def to_param\n uuid\n end",
"def to_param\n if uuid_changed? and uuid_was and !Vidibus::Uuid.validate(uuid)\n uuid_was\n else\n ... | [
"0.824637",
"0.824637",
"0.824637",
"0.8189266",
"0.8067228",
"0.7290129",
"0.710403",
"0.710403",
"0.70349187",
"0.67765903",
"0.673991",
"0.672727",
"0.672727",
"0.6699266",
"0.66654974",
"0.6664839",
"0.6649234",
"0.66400415",
"0.65912807",
"0.65879613",
"0.65789825",
"0... | 0.7526292 | 5 |
returns javascript text that can be used standalone or injected into a GTM Container Tag | def touchpoints_js_string
ApplicationController.new.render_to_string(partial: "components/widget/fba", formats: :js, locals: { touchpoint: self })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script(text)\n \"<script type=\\\"text/javascript\\\">jQuery(document).ready(function() {#{text};});</script>\"\n end",
"def javascript_tag(content_or_options_with_block = T.unsafe(nil), html_options = T.unsafe(nil), &block); end",
"def script\n @elements.map { |e|\n (e && !e.hidden? && !e.... | [
"0.65439945",
"0.6369463",
"0.63307077",
"0.6213078",
"0.6199185",
"0.6198094",
"0.6175535",
"0.6103509",
"0.6058113",
"0.6058113",
"0.60564387",
"0.60184884",
"0.599967",
"0.59672767",
"0.5965106",
"0.5916988",
"0.5830082",
"0.58249146",
"0.58207226",
"0.580262",
"0.5781365"... | 0.5277302 | 93 |
TODO: Refactor into a Report class Generates 1 of 2 exported files for the A11 This is a one record metadata file | def to_a11_header_csv(start_date:, end_date:)
non_flagged_submissions = self.submissions.non_flagged.where("created_at >= ?", start_date).where("created_at <= ?", end_date)
return nil unless non_flagged_submissions.present?
header_attributes = [
"submission comment",
"survey_instrument_reference",
"agency_poc_name",
"agency_poc_email",
"department",
"bureau",
"service",
"transaction_point",
"mode",
"start_date",
"end_date",
"total_volume",
"survey_opp_volume",
"response_count",
"OMB_control_number",
"federal_register_url"
]
CSV.generate(headers: true) do |csv|
submission = non_flagged_submissions.first
csv << header_attributes
csv << [
submission.form.data_submission_comment,
submission.form.survey_instrument_reference,
submission.form.agency_poc_name,
submission.form.agency_poc_email,
submission.form.department,
submission.form.bureau,
submission.form.service_name,
submission.form.name,
submission.form.medium,
start_date,
end_date,
submission.form.anticipated_delivery_count,
submission.form.survey_form_activations,
non_flagged_submissions.length,
submission.form.omb_approval_number,
submission.form.federal_register_url,
]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateReport\n filePath = \"#{@reportFolder}/report.csv\"\n file = File.open(filePath, 'w')\n file.puts ['Screen', 'Description', 'Automation Message', 'Status'].join(',')\n @report.each do |result|\n file.puts result.join(',')\n end\n file.close\n end",
"def generate_new_report\n ... | [
"0.64811206",
"0.62326384",
"0.6112047",
"0.6112047",
"0.6097704",
"0.5949684",
"0.5890126",
"0.587609",
"0.5813249",
"0.5774118",
"0.5759863",
"0.5755963",
"0.5741709",
"0.5741709",
"0.5741709",
"0.5741709",
"0.5741709",
"0.5717248",
"0.571383",
"0.56603587",
"0.5651898",
... | 0.52994525 | 68 |
Generates the 2nd of 2 exported files for the A11 This is a 7 record detail file; one for each question | def to_a11_submissions_csv(start_date:, end_date:)
non_flagged_submissions = self.submissions.non_flagged.where("created_at >= ?", start_date).where("created_at <= ?", end_date)
return nil unless non_flagged_submissions.present?
header_attributes = [
"standardized_question_number",
"standardized_question_identifier",
"customized_question_text",
"likert_scale_1",
"likert_scale_2",
"likert_scale_3",
"likert_scale_4",
"likert_scale_5",
"response_volume",
"notes",
"start_date",
"end_date"
]
@hash = {
answer_01: Hash.new(0),
answer_02: Hash.new(0),
answer_03: Hash.new(0),
answer_04: Hash.new(0),
answer_05: Hash.new(0),
answer_06: Hash.new(0),
answer_07: Hash.new(0)
}
# Aggregate likert scale responses
non_flagged_submissions.each do |submission|
@hash.keys.each do |field|
response = submission.send(field)
if response.present?
@hash[field][submission.send(field)] += 1
end
end
end
# TODO: Needs work
CSV.generate(headers: true) do |csv|
csv << header_attributes
@hash.each_pair do |key, values|
@question_text = "123"
if key == :answer_01
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 1
elsif key == :answer_02
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 2
elsif key == :answer_03
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 3
elsif key == :answer_04
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 4
elsif key == :answer_05
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 5
elsif key == :answer_06
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 6
elsif key == :answer_07
question = questions.where(answer_field: key).first
response_volume = values.values.collect { |v| v.to_i }.sum
@question_text = question.text
standardized_question_number = 7
end
csv << [
standardized_question_number,
key,
@question_text,
values["1"],
values["2"],
values["3"],
values["4"],
values["5"],
response_volume,
"", # Empty field for the user to enter their own notes
start_date,
end_date
]
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_records_file(format)\n file = Tempfile.new(\"patients-#{Time.now.to_i}\")\n patients = Record.where(\"test_id\" => self.id)\n Cypress::PatientZipper.zip(file, patients, format.to_sym)\n\n file\n end",
"def generate_records_file(format)\n file = Tempfile.new(\"patients-#{Time.now.... | [
"0.6203283",
"0.61166507",
"0.606366",
"0.605115",
"0.58370364",
"0.5822247",
"0.58138186",
"0.5760449",
"0.5756231",
"0.5694883",
"0.5670154",
"0.5668435",
"0.56633455",
"0.5583467",
"0.556145",
"0.5546068",
"0.5532889",
"0.5519694",
"0.55189615",
"0.5517111",
"0.55083233",
... | 0.53948057 | 38 |
TODO: Move to /models/submission.rb | def hashed_fields_for_export
hash = {}
self.ordered_questions.map { |q| hash[q.answer_field] = q.text }
hash.merge!({
location_code: "Location Code",
user_agent: "User Agent",
page: "Page",
referer: "Referrer",
created_at: "Created At"
})
if self.organization.enable_ip_address?
hash.merge!({
ip_address: "IP Address"
})
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submission_params\n params.require(:submission).permit(:title, :url, :text, :user_id)\n end",
"def set_submission\n @submission = Submission.find(params[:id])\n end",
"def set_submission\n @submission = Submission.find(params[:id])\n end",
"def set_submission\n @submission = Submission... | [
"0.7183502",
"0.71730244",
"0.71721596",
"0.71721596",
"0.7028174",
"0.70275825",
"0.69799685",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.697897",
"0.69656813",
"0.69577897",
"0.6942635",
"0.69... | 0.0 | -1 |
reduce country name to their abbr: West Indies => WI, Australia => AUS | def short_country_name(name)
if name.include? ' '
temp = name.split(' ')
temp[0][0] + temp[1][0]
else
name[0..2].upcase
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_country_name\n [state_abbr_name, country.try(:name)].compact.join(', ')\n end",
"def state_country_name\n [state_abbr_name, country.try(:name)].compact.join(', ')\n end",
"def normalize_country\n c = @data_object.add_country.strip\n\n c = c.downcase.gsub(/[\\. ]/, '').sub(/^the/, '')\n... | [
"0.7296578",
"0.7296578",
"0.7267566",
"0.71765447",
"0.7031106",
"0.6935989",
"0.68097353",
"0.68092525",
"0.6786268",
"0.67342526",
"0.67221034",
"0.66712725",
"0.66217405",
"0.6580406",
"0.6575553",
"0.653983",
"0.6538342",
"0.6538342",
"0.6538342",
"0.6526612",
"0.6517560... | 0.76235425 | 0 |
METHOD: Responds to a slack event that is passed to the "/events" endpoint. | def respond_to_slack_event json
# find the team
team_id = json['team_id']
api_app_id = json['api_app_id']
event = json['event']
event_type = event['type']
event_user = event['user']
event_text = event['text']
event_channel = event['channel']
event_ts = event['ts']
team = Team.find_by(team_id: team_id)
# didn't find a match... this is junk!
return if team.nil?
# see if the event user is the bot user
# if so we shoud ignore the event
return if team.bot_user_id == event_user
event = Event.create(team_id: team_id, type_name: event_type, user_id: event_user, text: event_text, channel: event_channel, direction: "incoming", timestamp: Time.at(event_ts.to_f) )
event.team = team
event.save!
client = team.get_client
event_to_action client, event, team
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def events\n # ignore messages from bots!\n\n case params[:type]\n when 'url_verification'\n logger.info \"verifying url\"\n render json: { challenge: params[:challenge] }\n when 'event_callback'\n return unless event_params[:bot_id].nil?\n\n render json: nil\n ProcessSlackMess... | [
"0.7407353",
"0.66214234",
"0.65260667",
"0.64818394",
"0.6465002",
"0.6441457",
"0.63185614",
"0.6259064",
"0.6222443",
"0.6210973",
"0.6187442",
"0.6184775",
"0.61799896",
"0.6152988",
"0.6114041",
"0.607485",
"0.60739154",
"0.6049582",
"0.6048424",
"0.60371375",
"0.6018512... | 0.7455685 | 0 |
METHOD: Responds to a slack button click that is passed to the "/interactivebuttons" endpoint. | def respond_to_slack_button json
if json['token'] != ENV['SLACK_VERIFICATION_TOKEN']
halt 403, 'Incorrect slack token'
end
puts "token valid"
call_back = json['callback_id']
action_name = json['actions'].first["name"]
action_text = json['actions'].first["text"]
action_value = json['actions'].first["value"]
channel = json['channel']['id']
team_id = json['team']['id']
user_id = json['user']['id']
time_stamp = json['message_ts']
team = Team.find_by(user_id: user_id)
puts team
if team.nil?
client.chat_postMessage(channel: channel, text:"You don't have Jude installed. Click the below link to install: http://agile-stream-68169.herokuapp.com/", unfurl_links: true)
return
end
puts "team found!"
client = team.get_client
event = Event.create(team_id: team_id, type_name: "button_click", user_id: user_id, text: call_back, channel: channel, direction: "incoming", timestamp: Time.at(time_stamp.to_f) )
event.team = team
event.save!
case call_back
when 'to-do'
case action_name
when "add assignment"
$assignment = Assignment.create
message = "Great! Let's add an assignment!"
client.chat_postMessage(channel: channel, text: message, attachments: interactive_assignment_course, as_user: true)
add_outgoing_event event, team, "interaction", "add assignment course"
{ text: "You selected 'add an assignment'" , replace_original: true }.to_json
when "show assignments"
message = get_upcoming_assignments team
client.chat_postMessage(channel: channel, text: message, as_user: true)
add_outgoing_event event, team, "message", "upcoming assignments"
{ text: "You selected 'show upcoming assignments'" , replace_original: true }.to_json
when "show next"
message = get_upcoming_events team
client.chat_postMessage(channel: channel, text: message, as_user: true)
add_outgoing_event event, team, "message", "upcoming events"
{ text: "You selected 'show upcoming schedule'" , replace_original: true }.to_json
else
200
end
when "course_assignment"
if action_name == "add course"
client.chat_postMessage(channel: channel, text: "Enter Course Name starting with *course name: *", as_user: true)
add_outgoing_event event, team, "message", "upcoming assignments"
{ text: "You selected 'add a course'" , replace_original: true }.to_json
else
message = "You're adding an assignment for #{action_name}!"
$assignment_record = "Assignment for #{action_name}: "
$assignment.course_name = action_name
$assignment.user_id = user_id
$assignment.team_id = team_id
client.chat_postMessage(channel: channel, text: message, attachments: [{"text": "Please type your assignment details in <= 140 chars", "callback_id": "assignment_text"}].to_json, as_user: true)
add_outgoing_event event, team, "message", "add assignment description"
{ text: "You selected 'add an assignment'" , replace_original: true }.to_json
end
when "add event"
if action_name == "add assignment"
$assignment_record = ""
client.chat_postMessage(channel: channel, text: "Let's add an assignment!", attachments: interactive_assignment_course, as_user: true)
{ text: "You selected 'add an assignment'" , replace_original: true }.to_json
elsif action_name == "add course"
client.chat_postMessage(channel: channel, text: "Enter Course Name starting with *course name: *", as_user: true)
{ text: "You selected 'add a course'" , replace_original: true }.to_json
else
200
end
when "confirm_assignment"
if action_name == "confirm"
$assignment.save!
create_calendar_event team, $assignment
client.chat_postMessage(channel: channel, as_user: true)
{ text: "The assignment has been added to your Google Calendar." , replace_original: true }.to_json
else
client.chat_postMessage(channel: channel, text: "Add assignment", attachments: interactive_assignment_course, as_user: true)
{ text: "Please add the assignment again!" , replace_original: true }.to_json
end
when "confirm_course"
if action_name == "confirm"
create_course $course_object
client.chat_postMessage(channel: channel, text: "The course has been added to your list of courses.", as_user: true)
{ text: "The course has been added to your list of courses." , replace_original: true }.to_json
else
client.chat_postMessage(channel: channel, text: "Enter Course Name starting with *course name: *", as_user: true)
{ text: "Please add the course again!" , replace_original: true }.to_json
end
else
200
# do nothing...
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action\n trigger :click\n end",
"def click_button(button)\n append_to_script \"click_button \\\"#{button}\\\"\"\n end",
"def question_classic_button_click\n MenuControllerContracts.invariant(self)\n @alert_view = @help_view = Views::ConnectInstructionsAlertView.new(@window, self)\... | [
"0.6921636",
"0.68468595",
"0.6600931",
"0.6527548",
"0.6467257",
"0.64633656",
"0.64579743",
"0.6450336",
"0.6342369",
"0.63271105",
"0.63271105",
"0.63271105",
"0.6320848",
"0.631984",
"0.6307707",
"0.62942725",
"0.62651813",
"0.6262837",
"0.6252468",
"0.62407815",
"0.62309... | 0.57640225 | 64 |
initialize for an empty roster | def initialize(name)
@name = name
@roster = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(name) ## when new instance is called, the instance is passed with the name and given an empty roster hash \n @name = name\n @roster = {}\n end",
"def initialize(name)\n @name = name\n #why is the roster here without being passed in as an argument with name?\n @roster = {}\n end",... | [
"0.75521755",
"0.7057276",
"0.7052119",
"0.7052119",
"0.70339954",
"0.6976132",
"0.6725037",
"0.6616796",
"0.6519166",
"0.64938235",
"0.6462552",
"0.6461136",
"0.6459787",
"0.6445426",
"0.6445426",
"0.6394245",
"0.6394245",
"0.6345489",
"0.63144594",
"0.6290142",
"0.62897205"... | 0.6973885 | 6 |
Add a student as a key(grade) value(student name) pair open up a new array and shovel students and grades into it. it won't put students multiple students into grades (or= operator?) | def add_student(student, grade_level)
roster[grade_level] ||= []
roster[grade_level] << student
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_student(student_name, grade)\n # roster[grade] = [] # ...first: create the new key and point it to an empty array\n roster[grade] ||= [] # add multiple students to a grade & add students to different grades using ||=\n roster[grade] << student_name # ...then: push the new value into that array\n ... | [
"0.82732445",
"0.7914259",
"0.78868115",
"0.78043705",
"0.7783535",
"0.7759234",
"0.7739855",
"0.7690558",
"0.76744956",
"0.7591585",
"0.75809",
"0.7550164",
"0.7505855",
"0.74924684",
"0.748259",
"0.7478669",
"0.7432754",
"0.7432754",
"0.74069464",
"0.738235",
"0.7367718",
... | 0.73303396 | 21 |
gather all the students by grade level. .detect enumerable moves through the key value pairs if the key == a given grade level it gives the student name | def grade (grade_level)
roster.detect do |x, y|
if x == grade_level
return y
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grade(grade)\n roster.each do |k|\n if k[:grade] == grade\n puts \"The following students are in Grade #{grade}: #{k[:students]}\"\n return k[:students]\n end\n end\n end",
"def get_grade(school, name)\n school[:students].each do |student|\n if name == student[:name]\n ... | [
"0.75993675",
"0.7400531",
"0.7374229",
"0.7343595",
"0.73338896",
"0.7268785",
"0.7237062",
"0.7177274",
"0.71480834",
"0.7147275",
"0.7102513",
"0.70912117",
"0.7053918",
"0.6976639",
"0.6603851",
"0.65601134",
"0.6520393",
"0.6283475",
"0.6282033",
"0.6279471",
"0.6264464"... | 0.5895192 | 30 |
open a new hash sort each array into alphabetical order don't forget to call! | def sort
new_hash = {}
roster.each do |grade, student|
new_hash[grade] = student.sort
end
new_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_anagrams(words)\r\n big_array = Array.new\r\n hash = Hash.new(0)\r\n words.each do |w| \r\n array = Array.new\r\n array = w.downcase.split(//)\r\n if hash.has_key?(array.sort) \r\n hash[array.sort]=hash[array.sort].push(w)\r\n else\r\n hash[array.sort]=Array.[](w)\r\n ... | [
"0.67810255",
"0.6664068",
"0.6655287",
"0.6651533",
"0.65346867",
"0.65315366",
"0.64102274",
"0.6382791",
"0.6341498",
"0.6330899",
"0.6328973",
"0.63272285",
"0.6321883",
"0.62943053",
"0.62723047",
"0.62489563",
"0.6246878",
"0.6222054",
"0.62158227",
"0.62113124",
"0.620... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_tourney
@tourney = Tourney.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def tourney_params
params.require(:tourney).permit(:title, :desc, :start_date, :end_date, :user_id, :venue_id, :game_type_id, :tourney_type_id, :game_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
... | 0.0 | -1 |
get '/profile/edit/:id' , to: 'profilesedit' , as: 'edit_profile' | def edit
@profile = User.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n redirect_to action: 'edit_profile'\n end",
"def edit\n @user = User.find(params[:user_id])\n @profile = @user.profile\n \n end",
"def edit\n user = User.find(params[:user_id])\n @profile = user.profile\n end",
"def edit_profile\n @user = User.find params[:id]\n end",
... | [
"0.78629565",
"0.7620848",
"0.76161116",
"0.75753564",
"0.7575133",
"0.7463404",
"0.7378464",
"0.72081894",
"0.71664774",
"0.7150149",
"0.7133589",
"0.69994134",
"0.69903344",
"0.69261116",
"0.68859214",
"0.6879549",
"0.6878355",
"0.68729264",
"0.68615943",
"0.68035156",
"0.6... | 0.77003163 | 1 |
patch '/profile/update' , to: 'profilesupdate', as: 'update_profile' | def update
@profile = User.find(params[:id])
respond_to do |format|
if @profile.update(profile_params)
format.html { redirect_to profile_path(@profile) }
else
flash[:alert] = "unable to update. Please check the data."
format.html { render 'edit' }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_profile(params)\n post 'account/update_profile', :post => params\n end",
"def update\n @profile = Profile.find(params[:id])\n logger.debug(\"UPDATE PROFILE @profile = #{@profile.inspect}\")\n logger.debug(\"UPDATE PROFILE params = #{params[:profile].inspect}\")\n logger.debug(\"UPDATE ... | [
"0.7866492",
"0.7533542",
"0.73888963",
"0.73803216",
"0.7331513",
"0.7325189",
"0.7322486",
"0.7321579",
"0.7321579",
"0.7321579",
"0.7313322",
"0.72635365",
"0.72599286",
"0.72599286",
"0.72599286",
"0.72599286",
"0.72391653",
"0.7238916",
"0.72328883",
"0.7208578",
"0.7207... | 0.69389695 | 77 |
GET /active_tours GET /active_tours.json | def index
@active_tours = ActiveTour.order(order_number: :asc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active\n @travels = Travels::Travel.actual\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @tours = Tour.all\n end",
"def index\n @tours = Tour.all\n end",
"def index\n #@tours = Tour.all\n ... | [
"0.7204806",
"0.7182234",
"0.7182234",
"0.7085145",
"0.6844847",
"0.68308365",
"0.662875",
"0.66066885",
"0.6532531",
"0.64981866",
"0.64694136",
"0.63596714",
"0.6253795",
"0.62199926",
"0.6180268",
"0.6152395",
"0.61234486",
"0.61234367",
"0.6098612",
"0.60837173",
"0.60807... | 0.6263412 | 12 |
GET /active_tours/1 GET /active_tours/1.json | def show
@comments = Comment.where(tour_type: "ActiveTour", tour_id: params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active\n @travels = Travels::Travel.actual\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @tours = Tour.all\n end",
"def index\n @tours = Tour.all\n end",
"def index\n #@tours = Tour.all\n ... | [
"0.72490406",
"0.7168245",
"0.7168245",
"0.71109444",
"0.6901423",
"0.68249667",
"0.67261857",
"0.6672885",
"0.6448099",
"0.6439044",
"0.63783056",
"0.63718224",
"0.62951386",
"0.6274639",
"0.6258416",
"0.62121576",
"0.6208836",
"0.6157781",
"0.6152751",
"0.6151271",
"0.61474... | 0.0 | -1 |
POST /active_tours POST /active_tours.json | def create
if logged_in?
@active_tour = ActiveTour.new(active_tour_params)
respond_to do |format|
if @active_tour.save
format.html { redirect_to @active_tour, notice: 'Active tour was successfully created.' }
format.json { render :show, status: :created, location: @active_tour }
else
format.html { render :new }
format.json { render json: @active_tour.errors, status: :unprocessable_entity }
end
end
else
flash[:success] = 'У вас нет доступа!'
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def active\n @travels = Travels::Travel.actual\n\n respond_to do |format|\n format.html { render \"travels/index\" }\n format.json { as_json @travels }\n end\n end",
"def index\n @tours = Tour.all\n end",
"def index\n @tours = Tour.all\n end",
"def create\n @tour = current_user... | [
"0.61127895",
"0.6002867",
"0.6002867",
"0.594233",
"0.5939798",
"0.58981556",
"0.5877904",
"0.5839588",
"0.5833311",
"0.5782581",
"0.5724373",
"0.5711826",
"0.5691565",
"0.56247497",
"0.5610598",
"0.5586351",
"0.5575191",
"0.5574559",
"0.55590415",
"0.55549467",
"0.5550704",... | 0.62852037 | 0 |
PATCH/PUT /active_tours/1 PATCH/PUT /active_tours/1.json | def update
if logged_in?
respond_to do |format|
if @active_tour.update(active_tour_params)
format.html { redirect_to @active_tour, notice: 'Active tour was successfully updated.' }
format.json { render :show, status: :ok, location: @active_tour }
else
format.html { render :edit }
format.json { render json: @active_tour.errors, status: :unprocessable_entity }
end
end
else
flash[:success] = 'У вас нет доступа!'
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
... | [
"0.6672768",
"0.63321555",
"0.6239977",
"0.6226033",
"0.6182283",
"0.6159127",
"0.60583735",
"0.6053855",
"0.6014622",
"0.60063094",
"0.5962429",
"0.5955567",
"0.5944792",
"0.5933108",
"0.59320337",
"0.59231174",
"0.59198624",
"0.5916741",
"0.59080464",
"0.58909506",
"0.58612... | 0.5883223 | 20 |
DELETE /active_tours/1 DELETE /active_tours/1.json | def destroy
if logged_in?
@active_tour.destroy
respond_to do |format|
format.html { redirect_to active_tours_url, notice: 'Active tour was successfully destroyed.' }
format.json { head :no_content }
end
else
flash[:success] = 'У вас нет доступа!'
redirect_to root_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @attraction_tour = AttractionTour.find(params[:id])\n @tour = @attraction_tour.tour\n @attraction_tour.destroy\n\n respond_to do |format|\n format.html { redirect_to @tour }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tour = Tour.find_by_url(params[... | [
"0.7191179",
"0.7157668",
"0.7049863",
"0.70370716",
"0.70370716",
"0.70370716",
"0.70370716",
"0.70370716",
"0.70370716",
"0.7031894",
"0.7031094",
"0.6948699",
"0.6906987",
"0.6903212",
"0.6879949",
"0.6823882",
"0.6811907",
"0.6811907",
"0.6791024",
"0.67902803",
"0.678182... | 0.68731135 | 15 |
Use callbacks to share common setup or constraints between actions. | def set_active_tour
@active_tour = ActiveTour.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def active_tour_params
params.require(:active_tour).permit(:duration, :tour_program, :included, :necessary, :popular, :title, :short_content, :content, :adult_price, :order_number, :child_price, {images: []})
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
Only install the application if the destination file does not exist. Returns `true` if the app was installed; `false` otherwise. | def install_app
return false if File.exists?(app_dest)
install_app!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_app!\n return false unless File.exists?(app_bak)\n\n puts \" application: #{app_dest.inspect}\"\n # FileUtils.cp_r(app_bak, app_dest)\n # the call to `FileUtils` was not copying the application icon, so I'm using\n # a call to `system` to properly copy application directories\n syste... | [
"0.7288054",
"0.7283983",
"0.6930372",
"0.6918287",
"0.68954384",
"0.68407756",
"0.68250155",
"0.68046963",
"0.6689773",
"0.6682309",
"0.66595095",
"0.66115487",
"0.6604094",
"0.6525895",
"0.6520257",
"0.64246184",
"0.625581",
"0.62503654",
"0.6238648",
"0.6232066",
"0.622589... | 0.8597958 | 0 |
Install the application regardless of the existence of the destination file. The srouce file must exist, however. Returns `true` if the app was installed; `false` otherwise. | def install_app!
return false unless File.exists?(app_bak)
puts " application: #{app_dest.inspect}"
# FileUtils.cp_r(app_bak, app_dest)
# the call to `FileUtils` was not copying the application icon, so I'm using
# a call to `system` to properly copy application directories
system(%Q/cp -r "#{app_bak}" "#{app_dest}"/)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_app\n return false if File.exists?(app_dest)\n install_app!\n end",
"def install_file(source, destination)\n overwrite = overwrite? destination\n if overwrite.downcase == \"y\"\n FileUtils.copy_entry(source, destination, :preserve=>true, :remove_destination=>true)\n return true\n else... | [
"0.8650068",
"0.7286133",
"0.67030627",
"0.6630147",
"0.6623431",
"0.6588772",
"0.65443975",
"0.65374285",
"0.6494707",
"0.6429026",
"0.6340845",
"0.6337338",
"0.63329333",
"0.63086784",
"0.6295004",
"0.6290715",
"0.62478447",
"0.6209135",
"0.61942816",
"0.6094291",
"0.608783... | 0.74912095 | 1 |
Only install the application preferences if the destination file does not exist. Returns `true` if the app was installed; `false` otherwise. | def install_prefs
return false if File.exists?(prefs_dest)
install_prefs!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_prefs!\n return false unless File.exists?(prefs_bak)\n\n puts \" preferences: #{prefs_dest.inspect}\"\n FileUtils.cp(prefs_bak, prefs_dest)\n true\n end",
"def install_app\n return false if File.exists?(app_dest)\n install_app!\n end",
"def update_install_preference(preference)... | [
"0.74196476",
"0.736238",
"0.68824184",
"0.68561465",
"0.67665815",
"0.64156836",
"0.6328796",
"0.6327937",
"0.6308007",
"0.6300741",
"0.6290514",
"0.61665726",
"0.6156937",
"0.60419846",
"0.59929734",
"0.59888947",
"0.59848475",
"0.5910716",
"0.5865829",
"0.58565265",
"0.580... | 0.78054965 | 0 |
Install the application preferences regardless of the existence of the destination file. The srouce file must exist, however. Returns `true` if the prefs were installed; `false` otherwise. | def install_prefs!
return false unless File.exists?(prefs_bak)
puts " preferences: #{prefs_dest.inspect}"
FileUtils.cp(prefs_bak, prefs_dest)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_prefs\n return false if File.exists?(prefs_dest)\n install_prefs!\n end",
"def update_install_preference(preference)\n if ALLOWED_INSTALL_PREFERENCES.include?(preference)\n self.install_preference = preference\n save\n else\n false\n end\n end",
"def install_file(sou... | [
"0.8743545",
"0.7318834",
"0.6505949",
"0.6406523",
"0.598112",
"0.58824325",
"0.58017033",
"0.5789054",
"0.5777216",
"0.57694685",
"0.5732148",
"0.55605775",
"0.55589646",
"0.554197",
"0.5485598",
"0.5463208",
"0.5453043",
"0.54484355",
"0.53797174",
"0.5346581",
"0.53193575... | 0.8460579 | 1 |
Backup this Fluid app to iCloud Drive. Returns `true` if the files were copied; `false` otherwise | def backup!
return false unless File.exists?(app_dest) && File.exists?(prefs_dest)
puts " application: #{app_dest.inspect}"
FileUtils.rm_r(app_bak, secure: true) if File.exists?(app_bak)
# FileUtils.cp_r(app_dest, app_bak)
# the call to `FileUtils` was not copying the application icon, so I'm using
# a call to `system` to properly copy application directories
system(%Q/cp -r "#{app_dest}" "#{app_bak}"/)
puts " preferences: #{prefs_dest.inspect}"
FileUtils.rm_r(prefs_bak, secure: true) if File.exists?(prefs_bak)
FileUtils.cp(prefs_dest, prefs_bak)
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup\n return false if !@file || !backup_file\n FileUtils.cp @file, backup_file if File.file? @file\n true\n end",
"def backup\n self.keep_backup && !File.exists?( backup_path ) && FileUtils.cp( self.resource.path, backup_path )\n end",
"def backup?\n @backup || false\n end",
"def... | [
"0.7315167",
"0.6774264",
"0.64493054",
"0.6257439",
"0.61175627",
"0.6093523",
"0.60062355",
"0.5951592",
"0.5855223",
"0.58507705",
"0.57992333",
"0.572426",
"0.5712752",
"0.5711529",
"0.56864476",
"0.56513476",
"0.56327176",
"0.5612802",
"0.56032395",
"0.5582983",
"0.55593... | 0.7150568 | 1 |
Create an Deck instance | def initialize
suits = ["Heart", "Diamond", "Spade", "Club"]
values = [:Two, :Three, :Four, :Five, :Six, :Seven,
:Eight, :Nine, :Ten, :Jack, :Queen, :King, :Ace]
@cards = []
suits.each do |suit|
values.each do |value|
@cards << Card.new(suit, value)
end
end
shuffle!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @deck = Deck.new\n end",
"def init_deck\n @deck = Deck.new\nend",
"def new\n @current_deck = Deck.new\n end",
"def new\n @decklist = Decklist.new\n end",
"def newDeck(name, template = @cur_deck_name)\n\n end",
"def start\n # Since I am not doing Deck.new.build, I am b... | [
"0.79433906",
"0.7129916",
"0.70354223",
"0.67883253",
"0.66120327",
"0.65978026",
"0.64800763",
"0.6409692",
"0.64044434",
"0.63885933",
"0.6276853",
"0.62081885",
"0.6127668",
"0.6100377",
"0.6072063",
"0.5958458",
"0.59423476",
"0.58995825",
"0.58802974",
"0.58534515",
"0.... | 0.0 | -1 |
define a function print_all, it takes a file object as a parameter | def print_all(f)
#print the content of the file object (a string)
puts f.read
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_all(f) # f is a placeholder argument for a file, which is defined when calling the functions with the current_file variable\n\tputs f.read() # take the argument and .read()\nend",
"def print_all(f)\t\t\t\t\t\t\t\t#prints the entire file\r\n puts f.read\r\nend",
"def print_all(f) # defining a new met... | [
"0.83088857",
"0.8247789",
"0.8231558",
"0.8218211",
"0.8147397",
"0.8145543",
"0.81144166",
"0.808073",
"0.8075185",
"0.80644196",
"0.799207",
"0.7983528",
"0.79294825",
"0.79245853",
"0.78761417",
"0.7799004",
"0.7799004",
"0.7799004",
"0.7798872",
"0.77942413",
"0.7751233"... | 0.79304904 | 12 |
define a function rewind, it takes a file object as a parameter | def rewind(f)
# the seek(procurar) method of classIO, moves the file pointer(indicates urrent location in the file)
# to a given integer distance (the first parameter), since the integer distance is 0,
# this method moves the file pointer to the beginning of the file
f.seek(0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rewind(f)\n# takes you to first position in the argument\n f.seek(0)\nend",
"def rewind(f)\n # the seek method tries to find a position (given as an integer)\n # if we send a file to our \"rewind\" method, it will \"seek\" position 0\n # position 0 is the beginning of the File\n f.seek(0)\nend",
"def ... | [
"0.8639903",
"0.86092746",
"0.85942596",
"0.8542193",
"0.8542193",
"0.8542193",
"0.8542193",
"0.8542193",
"0.8542193",
"0.8542193",
"0.85207593",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.84967846",
"0.8... | 0.8130975 | 73 |
define a function print_a_line, it takes an integer parameter, and a file object parameter | def print_a_line(line_count, f)
#print the line number, and then print the next line of the file
#the chomp method removes the new line character at the end of the line
puts "#{line_count}, #{f.gets.chomp}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_a_line(line_count, f)\n\t# prints a line of the file, wherever it left off last\n\tputs \"#{line_count} #{f.readline()}\"\n# ends the print_a_line function definition\nend",
"def print_a_line(line_count, f)\n # prints the line count variable value and then prints the line of the file\n puts \"#{line_... | [
"0.76142186",
"0.75062597",
"0.74381626",
"0.74328405",
"0.7421211",
"0.74046195",
"0.7395919",
"0.7337737",
"0.7336251",
"0.7336171",
"0.7336171",
"0.7336171",
"0.7324269",
"0.73159933",
"0.7305439",
"0.7300833",
"0.7267567",
"0.7267567",
"0.72458047",
"0.7239355",
"0.720173... | 0.7165219 | 48 |
Convert integer to SinoJapanese kana equivalent | def to_jtext
Bangou.integer_to_japanese_text(self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kan2n(s)\n '〇一二三四五六七八九'.index(s)\n end",
"def to_kanji(dd)\n d1, d2 = dd.length == 1 ? ['0', dd[0]-48] : [dd[0]-48, dd[1]-48]\n case d1 when 0 then ''\n when 1 then 'JUU'\n else to_kanji_single(d1.to_i) ;end \\\n + to_kanji_single(d2.to_s)\nend",
... | [
"0.70784223",
"0.69438046",
"0.6819599",
"0.65460265",
"0.65327644",
"0.6383176",
"0.60966295",
"0.6039863",
"0.5875036",
"0.5818686",
"0.5810936",
"0.5774968",
"0.57685375",
"0.57653457",
"0.57503",
"0.57247704",
"0.5626599",
"0.56264776",
"0.56203073",
"0.5610849",
"0.56083... | 0.6993138 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_send_type
@send_type = SendType.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def send_type_params
params.require(:send_type).permit(:info)
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.69480115",
"0.6813417",
"0.68023044",
"0.67950493",
"0.67457634",
"0.6741017",
"0.65274155",
"0.6519536",
"0.6491671",
"0.64317423",
"0.64317423",
"0.64317423",
"0.63975054",
"0.6354703",
"0.63543284",
"0.6346128",
"0.63437325",
"0.63382536",
"0.6327421",
"0.6327421",
"0.6... | 0.0 | -1 |
puts nth_fibonacci(5) puts nth_fibonacci(7) Double counted, not correct | def make_change(total, denominations)
ways = {}
start_point = 1
while start_point <= total
sub_answer = 0
denominations.each do |coin|
if coin == start_point
sub_answer += 1
elsif coin < start_point
next if (denominations.include?(start_point - coin) && coin < (start_point - coin))
sub_answer += ways[start_point - coin]
end
end
ways[start_point] = sub_answer
start_point += 1
end
puts ways
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def q9_fibonacci(num)\n f1 = 0\n f2 = 1\n (num-1).times {|_|\n tmp = f2\n f2 += f1 \n f1 = tmp\n }\n f2\nend",
"def nth_fibonacci(n) \n if n == 1\n return 0\n elsif n == 2\n return 1\n end\n return nth_fibonacci(n-1) + nth_fibonacci(n-2)\nend",
"def nthFibonacci(n)\r\n if n == 1\r\n ... | [
"0.8197875",
"0.81867546",
"0.81254417",
"0.8109659",
"0.8105636",
"0.80825984",
"0.80825984",
"0.80825984",
"0.80825984",
"0.80810255",
"0.8070567",
"0.8055018",
"0.80418",
"0.8036262",
"0.7998099",
"0.798059",
"0.7978495",
"0.7969896",
"0.79644424",
"0.7953206",
"0.7935093"... | 0.0 | -1 |
puts make_change2(4,[1,2,3]) return max monetary value possible cakes looks like [[weight, value], [weight, value]] | def max_duffel_bag_value(cakes, capacity)
maxes = {0 => 0}
(1..capacity).each do |constraint|
current_max = 0
cakes.each do |cake|
next if cake[1] == 0
if (constraint - cake[0] >= 0)
test_value = cake[1] + maxes[constraint - cake[0]]
current_max = test_value > current_max ? test_value : current_max
end
end
maxes[constraint] = current_max
end
maxes[capacity]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_change(amount, coins = [25, 10 ,5, 1])\n biggest_fit_coin = coins.detect { |val| amount >= val }\n\n if biggest_fit_coin == amount\n [biggest_fit_coin]\n else\n [biggest_fit_coin] + make_change(amount - biggest_fit_coin)\n end\nend",
"def make_change(value,coins)\n return nil if value < coins... | [
"0.68569505",
"0.6833275",
"0.6828743",
"0.6788839",
"0.65516907",
"0.6547967",
"0.6531686",
"0.64643323",
"0.6415708",
"0.6413621",
"0.64043796",
"0.63774174",
"0.6369555",
"0.6337708",
"0.6337708",
"0.63371325",
"0.6334728",
"0.6328974",
"0.6327683",
"0.6311955",
"0.6262853... | 0.62261313 | 22 |
Rank oligomers within some constraints. | def possible_oligos_ordered_by_temperature_difference(nucleotide_string, min_temperature, best_temperature, max_temperature, gc_clamp)
default_distance = lambda do |seq, tm|
# fails constraints if not enough GC clamp
if seq[seq.length-gc_clamp..seq.length-1].gsub(/[gc]/i,'').length > 0
false
else
# the sequence is within contraints. The melting temperature closest to the best wins.
tm_diff = (best_temperature-tm).abs
tm_diff
end
end
# initial conditions
guess = 0
guess_temp = 0
# arrays to fill with possible possibles
oligos = []
# loop around, until max temperature is reached
while guess_temp < max_temperature
guess += 1
seq = nucleotide_string[0..guess-1]
guess_temp = melting_temperature seq
# Add it to the list if there is enough temperature
if guess_temp > min_temperature and guess_temp < max_temperature
o = Oligo.new
o.sequence = seq
o.tm = guess_temp
oligos.push o
end
# break if there's we've reached the end of the line
break if guess > nucleotide_string.length-1
end
# Convert sequences into distances
oligos.each do |oligo|
oligo.distance = default_distance.call(oligo.sequence, oligo.tm)
end
# remove sequences that don't meet the constraints, and sort the rest with
# smallest distance first
return oligos.reject{|o| o.distance == false}.sort{|a,b|
a.distance<=>b.distance
}.collect{|o| o.sequence}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def army_rank; end",
"def navy_rank; end",
"def rank; end",
"def rank; end",
"def coast_guard_rank; end",
"def rank\n\t\trr = self.clone\n\t\trr.row_reduce_below\n\t\trr.rank_rr\n\tend",
"def rank\n case @owner\n # Prefer volumes from Princeton most strongly\n when 'njp'\n @rank = 4\n ... | [
"0.64386904",
"0.6392135",
"0.6297644",
"0.6297644",
"0.6167016",
"0.6080318",
"0.6042223",
"0.6021526",
"0.59731555",
"0.59504586",
"0.5936681",
"0.58973527",
"0.58969444",
"0.5845316",
"0.5776895",
"0.57362586",
"0.57276434",
"0.5708236",
"0.568094",
"0.56720537",
"0.566337... | 0.0 | -1 |
A simple method to return the melting temperature of a particular nucleotide string. Uses oligotm on the command line. | def melting_temperature(nucleotide_string)
#`oligotm -tp 1 -sc 1 -n 0.8 -d 500 -mv 0 -dv 50 '#{nucleotide_string}'`.to_f
`oligotm -tp 1 -sc 1 -n 0.2 -d 2 -mv 1 '#{nucleotide_string}'`.to_f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_temperature_unit\n\t\t@tempUnit\n\tend",
"def fromString\n\t\t\tinput = gets\n\t\t\ttemp = input.split(' ', 2)\n\t\t\treturn Temperature.new(temp[0].chomp.to_f, temp[1].chomp)\n\t\tend",
"def readTemp()\n print \"(Enter the temperature in the format --- degrees, scale): \"\n inputStr = gets... | [
"0.5532336",
"0.5465866",
"0.5355978",
"0.5311209",
"0.5294026",
"0.526486",
"0.52642745",
"0.52060866",
"0.5193607",
"0.5191234",
"0.51831114",
"0.5139729",
"0.5137355",
"0.5122024",
"0.50674456",
"0.50539196",
"0.50420356",
"0.5030534",
"0.5015428",
"0.50137573",
"0.5010049... | 0.85150766 | 0 |
typed a number and not a letter | def check_if_letter(number)
while number =~ /[a-z]/
puts "numbers only please"
number = gets.chomp
end
number = number.to_i
return number
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def valid_number?(num)\n\n integer?(num) || float?(num)\n\n #num.match(/\\d/) # this asks is input num has any letters in it.\nend",
"def is_a_number?(word)\n Integer(w... | [
"0.7215244",
"0.7215244",
"0.70119095",
"0.70051926",
"0.6910227",
"0.6754479",
"0.67310244",
"0.6651406",
"0.66108894",
"0.6604403",
"0.6587591",
"0.65642464",
"0.6499063",
"0.6499063",
"0.6470755",
"0.6458453",
"0.6444437",
"0.64334404",
"0.63939875",
"0.63825345",
"0.63657... | 0.60532975 | 71 |
GET /chiropractic_compliances/1 GET /chiropractic_compliances/1.json | def show
@chiropractic_compliance = ChiropracticCompliance.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @chiropractic_compliance }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @chiropractic_compliance = ChiropracticCompliance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chiropractic_compliance }\n end\n end",
"def index\n @compliances = Compliance.all\n end",
"def index\n @compliances = Compliance.find... | [
"0.6811593",
"0.67728806",
"0.641175",
"0.6376448",
"0.6347363",
"0.63158286",
"0.61299616",
"0.6129793",
"0.61107355",
"0.61100775",
"0.609204",
"0.60556215",
"0.6030139",
"0.60246146",
"0.60025966",
"0.59940815",
"0.598027",
"0.5977583",
"0.5977583",
"0.59619963",
"0.595959... | 0.7713304 | 0 |
GET /chiropractic_compliances/new GET /chiropractic_compliances/new.json | def new
@chiropractic_compliance = ChiropracticCompliance.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @chiropractic_compliance }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @appliance_type = ApplianceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @appliance_type }\n end\n end",
"def create\n @chiropractic_compliance = ChiropracticCompliance.new(params[:chiropractic_compliance])\n\n respond_to do |for... | [
"0.72965777",
"0.72609943",
"0.691419",
"0.6905257",
"0.690346",
"0.6893505",
"0.6847896",
"0.6839095",
"0.683588",
"0.6814316",
"0.67943925",
"0.6790414",
"0.6786493",
"0.6786493",
"0.6786493",
"0.67773265",
"0.6768785",
"0.67556286",
"0.67438465",
"0.6743106",
"0.6743106",
... | 0.7858804 | 0 |
POST /chiropractic_compliances POST /chiropractic_compliances.json | def create
@chiropractic_compliance = ChiropracticCompliance.new(params[:chiropractic_compliance])
respond_to do |format|
if @chiropractic_compliance.save
format.html { redirect_to @chiropractic_compliance, notice: 'Chiropractic compliance was successfully created.' }
format.json { render json: @chiropractic_compliance, status: :created, location: @chiropractic_compliance }
else
format.html { render action: "new" }
format.json { render json: @chiropractic_compliance.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @compliance = Compliance.new(compliance_params)\n\n respond_to do |format|\n if @compliance.save\n format.html { redirect_to @compliance, notice: 'Compliance was successfully created.' }\n format.json { render :show, status: :created, location: @compliance }\n else\n ... | [
"0.7287039",
"0.6507846",
"0.64655584",
"0.628364",
"0.61952776",
"0.6022172",
"0.59928876",
"0.59390604",
"0.58907557",
"0.5850793",
"0.5807121",
"0.5805183",
"0.5794477",
"0.570333",
"0.5617513",
"0.56000787",
"0.5598201",
"0.5584937",
"0.5535902",
"0.5520934",
"0.55130297"... | 0.7352764 | 0 |
PUT /chiropractic_compliances/1 PUT /chiropractic_compliances/1.json | def update
@chiropractic_compliance = ChiropracticCompliance.find(params[:id])
respond_to do |format|
if @chiropractic_compliance.update_attributes(params[:chiropractic_compliance])
format.html { redirect_to @chiropractic_compliance, notice: 'Chiropractic compliance was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @chiropractic_compliance.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @compliance.update(compliance_params)\n format.html { redirect_to @compliance, notice: 'Compliance was successfully updated.' }\n format.json { render :show, status: :ok, location: @compliance }\n else\n format.html { render :edit }\n ... | [
"0.67792267",
"0.6546376",
"0.6427315",
"0.6357584",
"0.6356043",
"0.62587595",
"0.6190158",
"0.60860425",
"0.6067144",
"0.6066049",
"0.6042575",
"0.6001",
"0.59587526",
"0.59099907",
"0.5882994",
"0.58702993",
"0.58676517",
"0.58511895",
"0.5810964",
"0.5800086",
"0.5786652"... | 0.718265 | 0 |
DELETE /chiropractic_compliances/1 DELETE /chiropractic_compliances/1.json | def destroy
@chiropractic_compliance = ChiropracticCompliance.find(params[:id])
@chiropractic_compliance.destroy
respond_to do |format|
format.html { redirect_to chiropractic_compliances_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @compliance.destroy\n respond_to do |format|\n format.html { redirect_to compliances_url, notice: 'Compliance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @appliance.destroy\n respond_to do |format|\n format.html { red... | [
"0.7046134",
"0.7002751",
"0.692222",
"0.6865582",
"0.67826533",
"0.6738198",
"0.67234087",
"0.669051",
"0.6688727",
"0.66832",
"0.6673031",
"0.6666458",
"0.6659181",
"0.665505",
"0.66427636",
"0.6632965",
"0.660826",
"0.6606954",
"0.65980583",
"0.6583445",
"0.6576747",
"0.... | 0.76515293 | 0 |
DEPRECATED: Please use find instead. | def retrieve(id)
instance = self.new(id)
url = instance.url
requestor = Requestor.new
response = requestor.request(:get, url)
instance.load_from(response)
instance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(path); end",
"def find(path); end",
"def find; end",
"def find(name); end",
"def find\n fail NotImplementedError\n end",
"def find\n raise \"Method not implemented\"\n end",
"def find(path, type, setting); end",
"def find(args, mode); end",
"def find(object, parent = @b... | [
"0.70903206",
"0.70903206",
"0.70147693",
"0.691699",
"0.6882063",
"0.67785126",
"0.6335041",
"0.6328692",
"0.6324696",
"0.62689793",
"0.6250707",
"0.6222226",
"0.6097645",
"0.60139537",
"0.5977887",
"0.5977117",
"0.5951964",
"0.5906444",
"0.58097553",
"0.5807863",
"0.5792673... | 0.0 | -1 |
finds all walks associated with dog walker | def walks
Walk.all.select {|walk_instance| walk_instance.dog_walker == self}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def walks\n Walk.all.select { |walk_instance| walk_instance.dog == self }\n end",
"def dog_walkers # ex: dog_instance.dog_walkers\n dog_walkers_array = self.walks.map { |walk_instance| walk_instance.dog_walker }\n dog_walkers_array.uniq\n end",
"def dogs \n dogs = self.walks.map {|walk| walk.dog}... | [
"0.795295",
"0.7501949",
"0.73330885",
"0.6677817",
"0.63465476",
"0.6301396",
"0.6230297",
"0.6215427",
"0.62003875",
"0.610984",
"0.60921925",
"0.60588163",
"0.60555327",
"0.6052747",
"0.6004184",
"0.5965259",
"0.5933898",
"0.58995",
"0.5822421",
"0.5785218",
"0.5785218",
... | 0.8236184 | 0 |
finds each unique dog that the walker walked | def dogs
dogs = self.walks.map {|walk| walk.dog}
dogs.uniq
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dog_walkers # ex: dog_instance.dog_walkers\n dog_walkers_array = self.walks.map { |walk_instance| walk_instance.dog_walker }\n dog_walkers_array.uniq\n end",
"def walks\n Walk.all.select { |walk_instance| walk_instance.dog == self }\n end",
"def walks\n Walk.all.select {|walk_instance| walk_i... | [
"0.7397084",
"0.7124577",
"0.6962085",
"0.6618277",
"0.6610712",
"0.6503407",
"0.6353665",
"0.6229849",
"0.6148217",
"0.6137677",
"0.61162525",
"0.60591424",
"0.60433996",
"0.59735656",
"0.59537935",
"0.59459496",
"0.59209996",
"0.5914655",
"0.58799213",
"0.58694667",
"0.5866... | 0.8053894 | 0 |
creates a new walk given a length of time and dog instance for the walker | def give_walk(length_in_minutes, dog)
Walk.new(length_in_minutes, dog, self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_walk(length_in_minutes, dog_walker)\n Walk.new(length_in_minutes, self, dog_walker)\n end",
"def walk\n if @legs > 0\n @speed = @speed + (0.2 * @legs)\n else\n raise TypeError, \"This dog don't exist.\"\n end\n end",
"def walk\n @speed = @speed + (0.2 * @legs)\n end",... | [
"0.8406667",
"0.6212975",
"0.5992634",
"0.59058464",
"0.5869149",
"0.55021065",
"0.5361269",
"0.5319975",
"0.5309914",
"0.5295538",
"0.52784854",
"0.52784854",
"0.5256408",
"0.525182",
"0.525182",
"0.51320285",
"0.5037695",
"0.50373185",
"0.5006747",
"0.5004618",
"0.50019467"... | 0.8334157 | 1 |
totals length of time the walker has spent walking dogs | def length_of_all_walks
self.walks.sum {|walk| walk.length_in_minutes}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def totalDistance\n\t\ti = 0\n\t\tsum = 0\n\t\twhile i < @@walks\n\t\t\tsum += @@distance[i].to_i\n\t\t\ti += 1\n\t\tend\n\t\tputs \"Bark\"\n\t\tif @@walks == 0\n\t\t\tputs \"#{@name}'s owners don't love them. They haven't been on a walk yet :(\"\n\t\telsif @@walks == 1\n\t\t\tputs \"#{@name} has walked #{sum}kms ... | [
"0.71997774",
"0.6173129",
"0.6147595",
"0.61392164",
"0.6078002",
"0.60699093",
"0.606177",
"0.6047934",
"0.5981787",
"0.59813875",
"0.5917267",
"0.5913028",
"0.59045637",
"0.5878136",
"0.586704",
"0.58522284",
"0.58469176",
"0.58459425",
"0.58234274",
"0.5819311",
"0.581870... | 0.7494386 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_records_product
@records_product = Product.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def records_product_params
params.require(:product).permit(:name, :product_category_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 |
FIXME: hard coded in core, not exposed via api | def mime_type
"text/plain"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def internal; end",
"def operation... | [
"0.79308814",
"0.6890208",
"0.6890208",
"0.6890208",
"0.6890208",
"0.6732465",
"0.655153",
"0.64599395",
"0.64599395",
"0.6415525",
"0.6405161",
"0.6405161",
"0.6314445",
"0.6281288",
"0.6281288",
"0.6177237",
"0.61566406",
"0.6133077",
"0.6109108",
"0.6094129",
"0.60459065",... | 0.0 | -1 |
There isn't a public DNS entry like 'example.com' with an A rrset | def test_a_pair
pend('FIXME: this test is broken on Windows') if windows?
EM.run {
d = EM::DNS::Resolver.resolve "yahoo.com"
d.errback { |err| assert false, "failed to resolve yahoo.com: #{err}" }
d.callback { |r|
assert_kind_of(Array, r)
assert r.size > 1, "returned #{r.size} results: #{r.inspect}"
EM.stop
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def required_dns_records\n all_ingress_hostnames + SPECIAL_A_RECORD_NAMES\nend",
"def dns_a_record\n @_dns_a_record = \"0.0.0.0\" if @config[:dns_lookup] == :off\n @_dns_a_record ||= Socket.gethostbyname(dns_name)\n rescue SocketError # not found, but could also mean network not work\n @_dns_a... | [
"0.684725",
"0.68455136",
"0.6389935",
"0.62669086",
"0.62307674",
"0.6162587",
"0.607667",
"0.606992",
"0.6035384",
"0.5962784",
"0.59308064",
"0.59153926",
"0.58982927",
"0.5881765",
"0.58483696",
"0.5828942",
"0.58273566",
"0.58137095",
"0.57965624",
"0.57783496",
"0.57737... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.