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 |
|---|---|---|---|---|---|---|
PATCH/PUT /tecnicas_de_impresion/1 PATCH/PUT /tecnicas_de_impresion/1.json | def update
respond_to do |format|
if @tecnica_de_impresion.update(tecnica_de_impresion_params)
format.html { redirect_to @tecnica_de_impresion, notice: 'Tecnica de impresion was successfully updated.' }
format.json { render :show, status: :ok, location: @tecnica_de_impresion }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @impuesto = Impuesto.find(params[:id])\n\n respond_to do |format|\n if @impuesto.update_attributes(params[:impuesto])\n format.html { redirect_to @impuesto, :notice => 'Impuesto was successfully updated.' }\n format.json { render json: @impuesto }\n else\n format.h... | [
"0.68302006",
"0.68055195",
"0.6590267",
"0.65820646",
"0.6576079",
"0.6528667",
"0.65276986",
"0.6427517",
"0.6392006",
"0.63906705",
"0.6381589",
"0.6371047",
"0.63374215",
"0.6334863",
"0.6330993",
"0.63254154",
"0.6317289",
"0.631638",
"0.63098824",
"0.6305287",
"0.629815... | 0.7128373 | 0 |
DELETE /tecnicas_de_impresion/1 DELETE /tecnicas_de_impresion/1.json | def destroy
@tecnica_de_impresion.destroy
respond_to do |format|
format.html { redirect_to tecnicas_de_impresion_url, notice: 'Tecnica de impresion was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { he... | [
"0.72402686",
"0.707065",
"0.7049887",
"0.70170003",
"0.70139796",
"0.70100605",
"0.69872594",
"0.69872594",
"0.6979386",
"0.6976891",
"0.69512254",
"0.69273645",
"0.6878749",
"0.68744767",
"0.6871848",
"0.6859419",
"0.6859419",
"0.6859419",
"0.6856008",
"0.684868",
"0.684824... | 0.7413745 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_tecnica_de_impresion
@tecnica_de_impresion = TecnicaDeImpresion.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def tecnica_de_impresion_params
params.require(:tecnica_de_impresion).permit(:tecnica, :descripcion, :estado)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_toy_category
@toy_category = ToyCategory.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.6165094",
"0.60450804",
"0.5944413",
"0.5915806",
"0.58885634",
"0.5835225",
"0.5775847",
"0.5700531",
"0.5700531",
"0.56543404",
"0.56209993",
"0.54238355",
"0.5410386",
"0.5410386",
"0.5410386",
"0.5394892",
"0.5377769",
"0.53559244",
"0.5339896",
"0.53388095",
"0.533008... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def toy_category_params
params.require(:toy_category).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.71207976",
"0.705222",
"0.69488335",
"0.69021654",
"0.67362636",
"0.6717561",
"0.6689192",
"0.6678948",
"0.66622657",
"0.6555007",
"0.6527569",
"0.64588845",
"0.64522904",
"0.6450812",
"0.6448551",
"0.6434285",
"0.6412147",
"0.6412147",
"0.6393719",
"0.6381976",
"0.6381976... | 0.0 | -1 |
GET /batches GET /batches.xml | def index
@own_batches = [Batch.all(:conditions => ["user_id = ?", current_user.id],
:order => "brewed_on DESC")].flatten.compact
@others_batches = [Batch.all(:conditions => ["user_id != ?", current_user.id],
:order => "brewed_on DESC")].flatten.comp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @batches = Batch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @batches }\n end\n end",
"def index\n @batches = Batch.all\n end",
"def index\n @batches = Batch.page(params[:page]).per(15)\n @page = params[:page] || 1\n\n ... | [
"0.75787103",
"0.71581537",
"0.70026606",
"0.6914053",
"0.676929",
"0.67224777",
"0.6607838",
"0.6549317",
"0.643094",
"0.6205997",
"0.6112463",
"0.6106596",
"0.6105769",
"0.6105769",
"0.60921174",
"0.6089149",
"0.6083226",
"0.60737914",
"0.6071445",
"0.5946221",
"0.5936407",... | 0.5950188 | 19 |
GET /batches/1 GET /batches/1.xml | def show
@batch = Batch.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @batch }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @batches = Batch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @batches }\n end\n end",
"def index\n @batches = Batch.all\n end",
"def index\n @batches = Batch.all\n respond_to do |format|\n format.html {}\n form... | [
"0.7357227",
"0.68783665",
"0.6574755",
"0.6540133",
"0.65092796",
"0.63362634",
"0.62235224",
"0.6212221",
"0.61690235",
"0.61662316",
"0.6039626",
"0.6022464",
"0.5986156",
"0.5964942",
"0.59444594",
"0.58974975",
"0.586904",
"0.5864089",
"0.5856767",
"0.5758288",
"0.574262... | 0.6487741 | 6 |
GET /batches/new GET /batches/new.xml | def new
@batch = Batch.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @batch }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @batch = Batch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @batch }\n end\n end",
"def index\n @batches = Batch.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @batches }\n e... | [
"0.6634136",
"0.65760076",
"0.6543075",
"0.62951535",
"0.6201103",
"0.6161949",
"0.6125936",
"0.61006045",
"0.602846",
"0.6027767",
"0.5999857",
"0.5985789",
"0.5982841",
"0.5981439",
"0.59546226",
"0.5920884",
"0.58279216",
"0.5809517",
"0.5795397",
"0.57201684",
"0.57168525... | 0.70569456 | 1 |
POST /batches POST /batches.xml | def create
@batch = Batch.new(params[:batch])
@batch.user = current_user
respond_to do |format|
if @batch.save
flash[:notice] = 'Batch was successfully created.'
format.html { redirect_to(@batch) }
format.xml { render :xml => @batch, :status => :created, :location => @batch }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def batch_xml(xml) \r\n xml.batch(:ID => 1) do\r\n xml.tag!(:bat_date, date)\r\n xml.tag!(:bat_id, batchid)\r\n xml.tag!(:site_num, facility.sitecode.rjust(5, '0'))\r\n xml.tag!(:bat_time, (batch_time.strftime(\"%H:%M:%S\") unless batch_time.blank?))\r\n xml.tag!(:chk_vol, (correspon... | [
"0.6390154",
"0.62985516",
"0.62725264",
"0.626065",
"0.623785",
"0.6175283",
"0.6165487",
"0.60862374",
"0.6075594",
"0.6037535",
"0.60276073",
"0.60094064",
"0.59984887",
"0.5996277",
"0.59601283",
"0.5956547",
"0.59449476",
"0.59314156",
"0.59160125",
"0.5912522",
"0.59111... | 0.5725483 | 29 |
PUT /batches/1 PUT /batches/1.xml | def update
@batch = Batch.find(params[:id])
@batch.user = current_user
respond_to do |format|
if @batch.update_attributes(params[:batch])
flash[:notice] = 'Batch was successfully updated.'
format.html { redirect_to(@batch) }
format.xml { head :ok }
else
format.ht... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @batch.update(batch_params)\n render json: @batch, status: :ok\n else\n render json: @batch.errors, status: :unprocessable_entity\n end\n end",
"def update\n @batch = Batch.find(params[:id])\n\n respond_to do |format|\n if @batch.update_attributes(params[:batch])\n ... | [
"0.62564594",
"0.620208",
"0.60742575",
"0.60740477",
"0.6048246",
"0.59922814",
"0.59824777",
"0.59744066",
"0.59744066",
"0.59744066",
"0.59744066",
"0.59744066",
"0.5959533",
"0.59541285",
"0.59502304",
"0.5924828",
"0.5907865",
"0.5899297",
"0.5898639",
"0.5896433",
"0.58... | 0.583356 | 24 |
DELETE /batches/1 DELETE /batches/1.xml | def destroy
@batch = Batch.find(params[:id])
@batch.destroy
respond_to do |format|
format.html { redirect_to(batches_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @batch.destroy\n head :no_content\n end",
"def destroy\n @batch = Batch.find(params[:id])\n @batch.destroy\n redirect_to batches_path\n end",
"def destroy\n @batch.destroy\n\n respond_to do |format|\n format.html { redirect_to batches_url }\n format.json { head :n... | [
"0.69745255",
"0.6939801",
"0.6923459",
"0.6901111",
"0.6901111",
"0.6894814",
"0.68251014",
"0.6688921",
"0.66840583",
"0.66563916",
"0.66341084",
"0.6620243",
"0.661648",
"0.6587278",
"0.6587278",
"0.6587278",
"0.6573865",
"0.657035",
"0.6540011",
"0.6507362",
"0.63968706",... | 0.7438581 | 1 |
mapping do indexes :image_url indexes :initiator_name indexes :assigned_user_name indexes :taskable_title indexes :taskable_name indexes :taskable_id end | def to_indexed_json
to_json(
#:only => [ :id, :name, :normalized_name, :url ],
:methods => [:image_url, :initiator_name, :assigned_user_name, :taskable_title, :taskable_name, :taskable_id]
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def atributos_index\n [ :id,\n :nusuario,\n :nombre,\n :email,\n :grupo_ids,\n :foto,\n :habilitado,\n ]\n end",
"def to_indexed_json\n to_json( \n #:only => [ :id, :name, :normalized_name, :url ],\n :methods => [:image_url, :initiator_name, :assigned_user_na... | [
"0.58455753",
"0.57307136",
"0.54222214",
"0.5402449",
"0.5402449",
"0.5396289",
"0.5396133",
"0.53632784",
"0.53632784",
"0.5361502",
"0.52906317",
"0.5279867",
"0.52546644",
"0.52494633",
"0.52433485",
"0.522576",
"0.52098423",
"0.52069056",
"0.5183003",
"0.5148922",
"0.509... | 0.6328012 | 0 |
cookbooks on github but not on the opscode supermarket. | def company_cookbook(name, version = '>= 0.0.0', options = {})
cookbook(name, version, { git: "https://github.com/EagleGenomics-cookbooks/#{name}.git" }.merge(options))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_cookbooks\n @cookbooks.each do |name, git_address|\n if ssh.exec? \"ls #{COOKBOOKS_PATH}/#{name}\"\n ssh.exec! \"cd #{COOKBOOKS_PATH}/#{name}; git pull origin master\", sudo: true\n else\n ssh.exec! \"git clone #{git_address} #{COOKBOOKS_PATH}/#{name}\", sudo: true... | [
"0.71856135",
"0.6674255",
"0.65168214",
"0.6466382",
"0.61688125",
"0.6144863",
"0.61344296",
"0.59632206",
"0.5909693",
"0.5906553",
"0.58792806",
"0.5859416",
"0.58260614",
"0.5821281",
"0.58024216",
"0.57874966",
"0.57540566",
"0.5752297",
"0.57183605",
"0.5709855",
"0.56... | 0.68002146 | 1 |
Initialize a Session. A session can be explicit or implicit. Lifetime of explicit sessions is managed by the application applications explicitry create such sessions and explicitly end them. Implicit sessions are created automatically by the driver when sending operations to servers that support sessions (3.6+), and th... | def initialize(server_session, client, options = {})
if options[:causal_consistency] && options[:snapshot]
raise ArgumentError, ':causal_consistency and :snapshot options cannot be both set on a session'
end
if options[:implicit]
unless server_session.nil?
raise ArgumentErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_session\n if session\n if session.updated_at < Time.now - ::Gricer.config.max_session_duration\n self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n else\n self.session.... | [
"0.6826761",
"0.66717184",
"0.6652943",
"0.6652481",
"0.6430142",
"0.6430142",
"0.63964325",
"0.63408905",
"0.6337353",
"0.6253362",
"0.6201662",
"0.6195405",
"0.614092",
"0.61339974",
"0.60382587",
"0.6034247",
"0.6018331",
"0.6008687",
"0.6002115",
"0.5950722",
"0.59445727"... | 0.62768394 | 9 |
Is this session an implicit one (not usercreated). | def implicit?
@implicit ||= !!(@options.key?(:implicit) && @options[:implicit] == true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def implicit?\n !!@implicit\n end",
"def session?\n !@session.nil?\n end",
"def valid_session?\n self.active?\n end",
"def patient_implicit?\n @authorized_user.patients.size == 1 \n end",
"def has_session?\n session\n end",
"def session?\n !expires_at || discar... | [
"0.71857107",
"0.6739051",
"0.66644317",
"0.66611046",
"0.6641482",
"0.6589992",
"0.652076",
"0.651917",
"0.651917",
"0.651333",
"0.65052265",
"0.6499565",
"0.6491228",
"0.6482779",
"0.64822906",
"0.644491",
"0.6433861",
"0.63980657",
"0.638257",
"0.6381274",
"0.63691497",
... | 0.6653607 | 4 |
Is this session an explicit one (i.e. usercreated). | def explicit?
!implicit?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def temporary_session?\n session[:user_id]\n end",
"def session?\n !@session.nil?\n end",
"def new_session?\n new_session != false\n end",
"def new_session?\n new_session != false\n end",
"def cas_authed?\n !session[:cas_user].blank?\n end",
"def cu... | [
"0.7077725",
"0.69114137",
"0.6893108",
"0.68922013",
"0.6868262",
"0.6840528",
"0.68223846",
"0.68103606",
"0.68094605",
"0.68003887",
"0.67783815",
"0.67305243",
"0.6728257",
"0.67260695",
"0.6704692",
"0.6704141",
"0.6654133",
"0.66436",
"0.66436",
"0.6584772",
"0.65828824... | 0.0 | -1 |
Whether reads executed with this session can be retried according to the modern retryable reads specification. If this method returns true, the modern retryable reads have been requested by the application. If the server selected for a read operation supports modern retryable reads, they will be used for that particula... | def retry_reads?
client.options[:retry_reads] != false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_with_retry(session = nil, server_selector = nil, &block)\n if session.nil? && server_selector.nil?\n deprecated_legacy_read_with_retry(&block)\n elsif session&.retry_reads?\n modern_read_with_retry(session, server_selector, &block)\n elsif client.max_read_retries > 0... | [
"0.71263725",
"0.70623285",
"0.6630252",
"0.66182506",
"0.6466018",
"0.64119613",
"0.6394917",
"0.63517874",
"0.60898924",
"0.59999996",
"0.58229244",
"0.57511216",
"0.57300866",
"0.5706145",
"0.5704998",
"0.567525",
"0.56335956",
"0.56287175",
"0.5589956",
"0.5587834",
"0.55... | 0.7948218 | 0 |
Will writes executed with this session be retried. | def retry_writes?
!!client.options[:retry_writes] && (cluster.replica_set? || cluster.sharded? || cluster.load_balanced?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retry!\n queue.repush(trx_id)\n rcache.lrem(queue.retries_cache_key, 0, trx_id)\n end",
"def retried\n tryouts.size\n end",
"def retry_later\n @meta[Cworked_at] = nil\n @meta[Crt_count] += 1\n @meta[Crt_at] = Time.now.utc + (queue.rt_at_interval * @meta[C... | [
"0.647833",
"0.64137137",
"0.6401617",
"0.62112135",
"0.6110285",
"0.6043755",
"0.58829945",
"0.5861372",
"0.5831798",
"0.5813091",
"0.5804334",
"0.5801108",
"0.57944155",
"0.5739615",
"0.5731129",
"0.57165205",
"0.56617326",
"0.5660423",
"0.5649293",
"0.56458867",
"0.5614766... | 0.6655871 | 0 |
Get the read preference the session will use in the currently active transaction. This is a driver style hash with underscore keys. | def txn_read_preference
rp = txn_options[:read] ||
@client.read_preference
Mongo::Lint.validate_underscore_read_preference(rp)
rp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_preference\n @read_preference ||= options[:read] || database.read_preference\n end",
"def read_preference\n @read_preference ||= options[:read]\n end",
"def txn_read_concern\n # Read concern is inherited from client but not db or collection.\n txn_options[:read_concern] || @c... | [
"0.75487614",
"0.7249995",
"0.59919995",
"0.572168",
"0.5624034",
"0.5583799",
"0.5335359",
"0.5334067",
"0.53017235",
"0.5276015",
"0.5261898",
"0.5235389",
"0.5234672",
"0.5148157",
"0.511184",
"0.50920504",
"0.5089182",
"0.50744",
"0.50600505",
"0.50600505",
"0.49812937",
... | 0.8092673 | 0 |
Whether this session has ended. | def ended?
!!@ended
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ended?\n @ended\n end",
"def ended?\n\t\t\tstate == 'ended'\n\t\tend",
"def ended?\n end_time < Time.now.utc\n end",
"def end?\n @status == :end\n end",
"def ended?\n return(self.ends_at < Time.now)\n end",
"def finished?\n @end_time != nil\n end",
"def end_sessi... | [
"0.82073945",
"0.8097605",
"0.79468244",
"0.7933156",
"0.7733763",
"0.77181727",
"0.7696096",
"0.7667667",
"0.76476353",
"0.7523028",
"0.74619186",
"0.74191386",
"0.7277199",
"0.7256805",
"0.7144905",
"0.7119376",
"0.70824796",
"0.706447",
"0.70320916",
"0.70223033",
"0.70223... | 0.80698144 | 2 |
Get a formatted string for use in inspection. | def inspect
"#<Mongo::Session:0x#{object_id} session_id=#{session_id} options=#{@options}>"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n @source_string || format\n end",
"def to_s ; format ; end",
"def to_s\n format\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n Formatter::ToString.format(self)\n end",
"def to_s()\n p... | [
"0.7265646",
"0.7025372",
"0.7022326",
"0.68324786",
"0.6695813",
"0.6695216",
"0.66513515",
"0.6634724",
"0.66005236",
"0.6515484",
"0.6506862",
"0.6484359",
"0.6462425",
"0.6441558",
"0.64156044",
"0.63934547",
"0.63866264",
"0.6349399",
"0.63457274",
"0.63249403",
"0.63125... | 0.0 | -1 |
End this session. If there is an inprogress transaction on this session, the transaction is aborted. The server session associated with this session is returned to the server session pool. Finally, this session is marked ended and is no longer usable. If this session is already ended, this method does nothing. Note tha... | def end_session
if !ended? && @client
if within_states?(TRANSACTION_IN_PROGRESS_STATE)
begin
abort_transaction
rescue Mongo::Error, Error::AuthError
end
end
if @server_session
@client.cluster.session_pool.checkin(@server_session)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end\n # todo: catch when there is no valid session?\n do_request(:post, path: @config[:end_session_url], payload: {:SessionToken => @session_token})\n connection.headers['x-sessionToken'] = ''\n @session_token = ''\n end",
"def end_session\n if !@session.nil?\n ... | [
"0.744619",
"0.74401784",
"0.69952077",
"0.6843908",
"0.66219074",
"0.64548737",
"0.63604355",
"0.6333382",
"0.6326159",
"0.6310521",
"0.6293404",
"0.62652016",
"0.6162541",
"0.6122899",
"0.6083666",
"0.5992631",
"0.595942",
"0.5895309",
"0.58928853",
"0.58430994",
"0.5839883... | 0.7780685 | 0 |
Whether or not the session is currently in a transaction. | def in_transaction?
within_states?(STARTING_TRANSACTION_STATE, TRANSACTION_IN_PROGRESS_STATE)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_transaction?\n _session&.in_transaction? || false\n end",
"def within_transaction?\n !current_transaction.nil?\n end",
"def within_transaction?\n !current_transaction.nil?\n end",
"def in_transaction?\n !@transaction_stack.empty?\n end",
"def outsi... | [
"0.9189826",
"0.86319625",
"0.8605586",
"0.8533281",
"0.8010713",
"0.7999643",
"0.77458787",
"0.7639261",
"0.76080984",
"0.75818175",
"0.75403214",
"0.72109866",
"0.7153173",
"0.71007055",
"0.70732176",
"0.70564514",
"0.70434755",
"0.70434755",
"0.69218373",
"0.6856194",
"0.6... | 0.85312706 | 4 |
Pins this session to the specified server, which should be a mongos. | def pin_to_server(server)
if server.nil?
raise ArgumentError, 'Cannot pin to a nil server'
end
if Lint.enabled?
unless server.mongos?
raise Error::LintError, "Attempted to pin the session to server #{server.summary} which is not a mongos"
end
end
@pinned_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_server\n @server = current_user.servers.find(params[:id])\n end",
"def set_server\n @server = Server.includes(:user).includes(:votes).find(params[:id])\n end",
"def set_server\n @server = Server.find(params[:id])\n if params.has_key?(:server) and params[:server].has_key?(:need... | [
"0.61215687",
"0.58594906",
"0.5743057",
"0.5546483",
"0.5546483",
"0.5546483",
"0.5546483",
"0.5546483",
"0.5495398",
"0.5465419",
"0.5436875",
"0.54323256",
"0.54162866",
"0.53771085",
"0.5371034",
"0.5364362",
"0.5346386",
"0.5345742",
"0.5345742",
"0.52610785",
"0.5203360... | 0.72250384 | 0 |
Pins this session to the specified connection. | def pin_to_connection(connection_global_id)
if connection_global_id.nil?
raise ArgumentError, 'Cannot pin to a nil connection id'
end
@pinned_connection_global_id = connection_global_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_tunnel_connection(connection)\n @tunnel_connections[connection.connection_id] = connection\n control_connection = connection.control_connection\n @tunnel_connections_by_control[control_connection] ||= Set.new\n @tunnel_connections_by_control[control_connection] << connection\n end",
"de... | [
"0.54717636",
"0.5291078",
"0.51851434",
"0.5100299",
"0.50523937",
"0.50452274",
"0.49989706",
"0.4959195",
"0.49340752",
"0.49340752",
"0.49340752",
"0.49261814",
"0.48800045",
"0.4868649",
"0.48364875",
"0.48243463",
"0.48187426",
"0.4801213",
"0.47516826",
"0.47116768",
"... | 0.48870963 | 12 |
Unpins this session from the pinned server or connection, if the session was pinned. | def unpin(connection = nil)
@pinned_server = nil
@pinned_connection_global_id = nil
connection.unpin unless connection.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpin_maybe(session)\n yield\n rescue Mongo::Error => e\n if session\n session.unpin_maybe(e)\n end\n raise\n end",
"def disconnect\n @pins.each { |n, p| p.close } if @pins\n @pins = {}\n super\n end",
"def unpin(space_id, id, opts = ... | [
"0.62758726",
"0.57582635",
"0.54889274",
"0.5398944",
"0.53932804",
"0.5315527",
"0.5290123",
"0.52600396",
"0.52201074",
"0.5181319",
"0.51782703",
"0.517144",
"0.5144685",
"0.5120452",
"0.5108248",
"0.5104583",
"0.5104583",
"0.50975585",
"0.50854516",
"0.5069253",
"0.50445... | 0.74959475 | 0 |
Add the autocommit field to a command document if applicable. | def add_autocommit!(command)
command.tap do |c|
c[:autocommit] = false if in_transaction?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autocommit(flag)\n query \"set autocommit=#{flag ? 1 : 0}\"\n self\n end",
"def autocommit=(p1)\n #This is a stub, used for indexing\n end",
"def autocommit=(value)\n raise NoMethodError, \"Not implemented for this raw driver\"\n end",
"def initial_commit?; end",
"def initial_c... | [
"0.68756294",
"0.6681053",
"0.6414353",
"0.6267186",
"0.6267186",
"0.6224249",
"0.6163878",
"0.591485",
"0.583517",
"0.5835153",
"0.5835153",
"0.5825909",
"0.5785601",
"0.5672924",
"0.56428945",
"0.5639265",
"0.56193864",
"0.56150883",
"0.55445486",
"0.54677373",
"0.5465825",... | 0.77702206 | 0 |
Add the startTransaction field to a command document if applicable. | def add_start_transaction!(command)
command.tap do |c|
if starting_transaction?
c[:startTransaction] = true
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end",
"def start_transaction\n NewRelic::Agent.instance.events.notify(:start_transaction)\n end",
"def start(&block)\n res = database.execute_... | [
"0.61995417",
"0.6055715",
"0.56439495",
"0.56032264",
"0.54841435",
"0.54218704",
"0.5372974",
"0.5261148",
"0.5176781",
"0.51366",
"0.5073107",
"0.5069461",
"0.50111675",
"0.4980159",
"0.49468744",
"0.49468744",
"0.49455872",
"0.4927345",
"0.49196663",
"0.48886558",
"0.4882... | 0.8142215 | 0 |
Add the transaction number to a command document if applicable. | def add_txn_num!(command)
command.tap do |c|
c[:txnNumber] = BSON::Int64.new(@server_session.txn_num) if in_transaction?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_add_on_nr(key, to_add)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'add_on_nr' => {key => to_add}}\n self\n end",
"def add_number\n return unless %w[techreport manual].include? @bib.type\n\n d... | [
"0.59055364",
"0.5786797",
"0.56618667",
"0.54574686",
"0.5424963",
"0.5330703",
"0.53276724",
"0.52305037",
"0.52284306",
"0.52270913",
"0.5190183",
"0.5165298",
"0.51572764",
"0.5129801",
"0.5079075",
"0.5061447",
"0.5041135",
"0.5033301",
"0.4979372",
"0.4973829",
"0.49735... | 0.7810937 | 0 |
Add the transactions options if applicable. | def add_txn_opts!(command, read)
command.tap do |c|
# The read concern should be added to any command that starts a transaction.
if starting_transaction?
# https://jira.mongodb.org/browse/SPEC-1161: transaction's
# read concern overrides collection/database/client read concerns... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transactions(options = {})\n raise MethodNotImplemented\n end",
"def transactions(options = {})\n []\n end",
"def transactions(options)\n options[:type] ||= :all\n\n unless %i[all all_deal deposit withdrawal].include? options[:type]\n raise ArgumentError, \"in... | [
"0.7055103",
"0.69169605",
"0.66014344",
"0.65497303",
"0.65497303",
"0.6395857",
"0.6359373",
"0.6351337",
"0.62908334",
"0.6203462",
"0.61862946",
"0.61862946",
"0.6091206",
"0.6072444",
"0.6072444",
"0.6072444",
"0.60476035",
"0.59910524",
"0.5964763",
"0.5957976",
"0.5819... | 0.55048317 | 37 |
Remove the read concern and/or write concern from the command if not applicable. | def suppress_read_write_concern!(command)
command.tap do |c|
next unless in_transaction?
c.delete(:readConcern) unless starting_transaction?
c.delete(:writeConcern) unless c[:commitTransaction] || c[:abortTransaction]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_concern\n @write_concern ||= WriteConcern::Mode.get(options[:write])\n end",
"def read_concern\n options[:read_concern] || database.read_concern\n end",
"def write_concern\n @write_concern ||= WriteConcern.get(options[:write_concern] || options[:write])\n end",
"def require_... | [
"0.5511157",
"0.54856974",
"0.54471004",
"0.53442645",
"0.5333504",
"0.5304505",
"0.52903724",
"0.5232246",
"0.5092679",
"0.50723255",
"0.50168216",
"0.49132794",
"0.49009657",
"0.48390377",
"0.4755652",
"0.4715307",
"0.47074786",
"0.47068384",
"0.46897364",
"0.46897364",
"0.... | 0.79551595 | 0 |
Update the state of the session due to a (noncommit and nonabort) operation being run. | def update_state!
case @state
when STARTING_TRANSACTION_STATE
@state = TRANSACTION_IN_PROGRESS_STATE
when TRANSACTION_COMMITTED_STATE, TRANSACTION_ABORTED_STATE
@state = NO_TRANSACTION_STATE
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_state\n raise \"Nothing to do\"\n end",
"def commit_if_dirty\n # no op\n end",
"def confirm\n DB.session do |db|\n self.executed = true\n save\n end\n end",
"def commit!\n _commit( false )\n end",
"def perform_atomic_update(&block)\n Edition.connection... | [
"0.60286033",
"0.57189333",
"0.5705997",
"0.55150294",
"0.5465165",
"0.5410075",
"0.53549844",
"0.53462285",
"0.5344829",
"0.5298678",
"0.52927494",
"0.52898437",
"0.5288572",
"0.5281893",
"0.5281378",
"0.5278055",
"0.52750516",
"0.52577853",
"0.52513015",
"0.5241831",
"0.523... | 0.604065 | 0 |
Process a response from the server that used this session. | def process(result)
unless implicit?
set_operation_time(result)
if cluster_time_doc = result.cluster_time
advance_cluster_time(cluster_time_doc)
end
end
@server_session.set_last_use!
if doc = result.reply && result.reply.documents.first
if doc[:recovery... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_response!(response)\n\t\t\t\tfinish_request!\n\t\t\t\t\n\t\t\t\tif Exception === response\n\t\t\t\t\t@logger.warn \"[#{@message.id}] Failure while processing response #{response}!\" if @logger\n\t\t\t\t\tRubyDNS.log_exception(@logger, response) if @logger\n\t\t\t\t\t\n\t\t\t\t\ttry_next_server!\n\t\t\t... | [
"0.7008381",
"0.68888766",
"0.6875339",
"0.6875339",
"0.6735087",
"0.66736865",
"0.66698396",
"0.66681296",
"0.6640876",
"0.6622838",
"0.66214436",
"0.66164446",
"0.65444565",
"0.6521868",
"0.63940877",
"0.6342237",
"0.63304263",
"0.6313282",
"0.6302881",
"0.62992495",
"0.629... | 0.0 | -1 |
Advance the cached operation time for this session. | def advance_operation_time(new_operation_time)
if @operation_time
@operation_time = [ @operation_time, new_operation_time ].max
else
@operation_time = new_operation_time
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance ( delta=0 ) \n @actual += delta\n @current = @actual + offset\n @current_offset = @current.to_i/60 - @actual.to_i/60\n @updated = Time.new\n @update_count += 1\n self\n end",
"def advance()\n @time = @time + 1\n end",
"def execute_time\n @next_time\n end",
"def upda... | [
"0.6213749",
"0.6105846",
"0.6057444",
"0.60359585",
"0.6002576",
"0.5976153",
"0.5922597",
"0.5899459",
"0.58758664",
"0.5865277",
"0.5858318",
"0.5854123",
"0.58510983",
"0.5810227",
"0.5790225",
"0.57138747",
"0.56800866",
"0.5570207",
"0.55701023",
"0.55691147",
"0.556584... | 0.6425299 | 0 |
If not already set, populate a session objects's server_session by checking out a session from the session pool. | def materialize_if_needed
if ended?
raise Error::SessionEnded
end
return unless implicit? && !@server_session
@server_session = cluster.session_pool.checkout
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_session\n if session\n if session.updated_at < Time.now - ::Gricer.config.max_session_duration\n self.session = Session.create previous_session: session, ip_address: @ip_address, agent: agent, requested_locale: @request_locale\n else\n self.session.... | [
"0.6318363",
"0.6186886",
"0.59901744",
"0.56484807",
"0.5633784",
"0.561242",
"0.5550783",
"0.553081",
"0.55306745",
"0.5526627",
"0.5513509",
"0.54782397",
"0.5474269",
"0.54685783",
"0.54485106",
"0.5441319",
"0.54353553",
"0.5418251",
"0.5413428",
"0.54124445",
"0.5400829... | 0.6881658 | 0 |
Increment and return the next transaction number. | def next_txn_num
if ended?
raise Error::SessionEnded
end
@server_session.next_txn_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_txn_num\n @txn_num += 1\n end",
"def next_number(number)\n return number += 1\nend",
"def next_number(number)\n number.to_i\n return number+=1\nend",
"def next_number(num)\n return num += 1\nend",
"def next_number\n Sequence.next_val\n end",
"def next_id\n ... | [
"0.7995656",
"0.7173126",
"0.7131651",
"0.7022402",
"0.698528",
"0.697392",
"0.69705683",
"0.69684905",
"0.6928131",
"0.6919153",
"0.68712884",
"0.68442327",
"0.6843622",
"0.67627627",
"0.6720851",
"0.6686768",
"0.66837186",
"0.66837156",
"0.6654979",
"0.6631892",
"0.6618722"... | 0.6720714 | 15 |
Get the current transaction number. | def txn_num
if ended?
raise Error::SessionEnded
end
@server_session.txn_num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_id\n ret = @transaction_id ||= 0\n @transaction_id = @transaction_id.succ\n ret\n end",
"def last_trx_number\n @trx_number\n end",
"def transaction_id\n read('transaction_id')\n end",
"def gettransactionid()\r\n return getvalue(SVTags::TRANSACT... | [
"0.7618531",
"0.7261809",
"0.7192076",
"0.70725507",
"0.7057324",
"0.6926264",
"0.6885128",
"0.688322",
"0.6875995",
"0.67836994",
"0.677764",
"0.6638427",
"0.6522042",
"0.6458585",
"0.6447784",
"0.6439447",
"0.6409002",
"0.63020283",
"0.62886584",
"0.6282409",
"0.6265234",
... | 0.61138856 | 28 |
Get the read concern the session will use when starting a transaction. This is a driver style hash with underscore keys. | def txn_read_concern
# Read concern is inherited from client but not db or collection.
txn_options[:read_concern] || @client.read_concern
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_concern\n options[:read_concern] || database.read_concern\n end",
"def txn_read_preference\n rp = txn_options[:read] ||\n @client.read_preference\n Mongo::Lint.validate_underscore_read_preference(rp)\n rp\n end",
"def read_concern\n options[:read_concern]\n end... | [
"0.69444764",
"0.6797174",
"0.6649898",
"0.58897996",
"0.5657166",
"0.5632186",
"0.5573482",
"0.5554453",
"0.53901315",
"0.5252398",
"0.49701583",
"0.4930122",
"0.4921574",
"0.49074987",
"0.4891467",
"0.48892057",
"0.48645636",
"0.48136455",
"0.47962373",
"0.47842982",
"0.475... | 0.78394794 | 0 |
Returns causal consistency document if the last operation time is known and causal consistency is enabled, otherwise returns nil. | def causal_consistency_doc
if operation_time && causal_consistency?
{:afterClusterTime => operation_time}
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_causal_consistency_if_possible(selector, connection)\n if !connection.description.standalone?\n cc_doc = session.send(:causal_consistency_doc)\n if cc_doc\n rc_doc = (selector[:readConcern] || read_concern || {}).merge(cc_doc)\n selector[:readConcern] = Opti... | [
"0.53652483",
"0.52495265",
"0.52319294",
"0.52018934",
"0.5021014",
"0.50115883",
"0.4914938",
"0.48918858",
"0.48728105",
"0.48696464",
"0.47638002",
"0.4747719",
"0.47215372",
"0.47152287",
"0.47051",
"0.46586743",
"0.4656725",
"0.46537474",
"0.4625193",
"0.46139282",
"0.4... | 0.78131884 | 0 |
Initialize the new pullAll operation. | def initialize(document, field, value, options = {})
@document, @field, @value = document, field, value
@options = { :safe => safe_mode?(options) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull_all(pulls)\n view.update_many(\"$pullAll\" => collect_operations(pulls))\n end",
"def initialize\n super\n select @all\n end",
"def pull_all!(args)\n collection_modifier_update('$pullAll', args)\n end",
"def pull_all(pulls)\n prepare_atomic_opera... | [
"0.65336317",
"0.65269214",
"0.6413637",
"0.6150209",
"0.597825",
"0.5962242",
"0.5943055",
"0.5914618",
"0.5681118",
"0.56261575",
"0.5600337",
"0.5576164",
"0.5492014",
"0.5475469",
"0.5468357",
"0.54648304",
"0.5426144",
"0.5423466",
"0.5395576",
"0.5390652",
"0.53807956",... | 0.0 | -1 |
Get the atomic operation to perform. | def operation(modifier)
{ modifier => { field => value } }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operation\n return @operation\n end",
"def operation(name)\n @operations.fetch(name)\n end",
"def operation(name)\n @operations.fetch(name)\n end",
"def get_operation token\n OPERATOR_MAP[token]\n end",
"def get_operator\n OPERATORS[get_token]\n end... | [
"0.6974664",
"0.6537092",
"0.6537092",
"0.6391606",
"0.62851477",
"0.6204928",
"0.6166573",
"0.61135",
"0.6095621",
"0.601442",
"0.59768337",
"0.5902297",
"0.5901001",
"0.58969295",
"0.5854671",
"0.58113676",
"0.5805961",
"0.5770444",
"0.5728005",
"0.5728005",
"0.5728005",
... | 0.0 | -1 |
============================================ Actions ============================================================================ ======================================================================================================================= Objective: To set the default values for fields of Qualification Grade... | def default_values
self.status = QUALIFICATION_GRADE_STATUS_UNCONFIRMED if !self.status.present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_values\n\t\tself.max_student ||= 0\n\t\tself.backup_student ||= 0\n\tend",
"def default_values!\n self.name ||= 'DEFAULT ACHIEVEMENT'\n self.description ||= 'This is a default achievement.'\n end",
"def default_fields\n @enrollment.default_fields_with_name if @enrollment\n end",
"def s... | [
"0.6061326",
"0.5940502",
"0.5633615",
"0.5618045",
"0.56120145",
"0.5592394",
"0.5567712",
"0.554917",
"0.55447197",
"0.5530026",
"0.5530026",
"0.54936814",
"0.5465835",
"0.5444785",
"0.544025",
"0.5435537",
"0.5403124",
"0.54030764",
"0.5387773",
"0.53288066",
"0.5321183",
... | 0.62310404 | 0 |
Further Exploration Write a transpose! method that transposes a matrix in place. The obvious solution is to reuse transpose from above, then copy the results back into the array specified by the argument. For this method, don't use this approach; write a method from scratch that does the inplace transpose. | def transpose!(matrix)
copy_matrix = []
matrix.each_with_index { |row, ind| copy_matrix[ind] = row }
matrix[0].length.times { matrix.unshift([]) }
copy_matrix.length.times { matrix.pop }
matrix.each_with_index do |_, n_ind|
copy_matrix.each_with_index do |_, ind|
matrix[ind] << copy_matrix[n_ind][in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transpose(matrix)\n size = matrix.first.size\n matrix.each_with_index.with_object(Array.new(size) {[]}) do |(arr, idx), trans_arr|\n arr.each_with_index do |el, i|\n trans_arr[i] << el\n end\n end\nend",
"def transpose!(matrix)\n (0...matrix.size).each do |i|\n (i...matrix.size).each do |j|... | [
"0.81416273",
"0.8116325",
"0.8113068",
"0.8053015",
"0.79318166",
"0.7924386",
"0.78850913",
"0.7876198",
"0.78547037",
"0.78474796",
"0.78244096",
"0.77866596",
"0.7729929",
"0.7724046",
"0.7717034",
"0.77147305",
"0.7713556",
"0.76826537",
"0.7648765",
"0.7644218",
"0.7629... | 0.8278036 | 0 |
valid: letters, spaces, and a period 1 or more words separated by 1+ spaces words: 120 letters terminated by 0+ spaces and period output: words separated by a single space, ending w/ a period after last word odd indexed words are reversed, even are kept the same rules: characters must be read and printed one at a time ... | def odd(str)
result = ''
is_odd_idx = false
space_just_added = false
last_letter_idx = nil
last_space_idx = nil
str.each_char do |char|
if char == ' '
next if space_just_added
result << ' '
space_just_added = true
last_space_idx = result.size
is_odd_idx = !is_odd_idx
el... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def odd_words(string)\n return 'invalid input' if invalid_input?(string)\n\n results = []\n temp_string = ''\n string = string.squeeze(' ').sub(/\\s*\\./, '.')\n string.chars.each do |char|\n if char.match(/[A-Za-z]/)\n temp_string << char\n elsif char.match(/(\\.| )/)\n temp_string = temp_str... | [
"0.72784215",
"0.6962317",
"0.69469607",
"0.6773737",
"0.6748486",
"0.6675819",
"0.6559164",
"0.6548285",
"0.6514206",
"0.65067977",
"0.6494062",
"0.6471243",
"0.6424372",
"0.6423459",
"0.63654983",
"0.63177747",
"0.6298985",
"0.62886953",
"0.62667185",
"0.62579155",
"0.62390... | 0.71445364 | 1 |
convert url to key NOTE: This is actually necessary since other wiki pages (such as oscar and other lists) have slightly different links, some contain film or year+film some don't. So we need something other than URL to check. This is defective since it does not remove the year in film. We need to remove _(1925_film), ... | def converturl url
return nil unless url
newurl = url.sub('/wiki/','').downcase().sub('_(film)','').sub(/([12][8901].._film)/,'')
newurl = URI.decode(newurl)
# accept only alphanum and %
newurl.gsub!(/[^0-9a-z%]/i,'')
return newurl
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for(url)\n url.to_s.downcase.gsub(\"https\",'http').gsub(/\\s+/,' ')\n end",
"def key_for(url)\n url.to_s.downcase.gsub(\"https\",'http').gsub(/\\s+/,' ')\n end",
"def parse_gdoc_url_for_key(url)\n u = URI.parse(url)\n \n key = CGI.parse(u.query)['key'][0]\n end",
... | [
"0.7320936",
"0.7320936",
"0.69649506",
"0.599091",
"0.594897",
"0.5941554",
"0.5899248",
"0.58934885",
"0.5857091",
"0.584379",
"0.5750223",
"0.57220775",
"0.56746626",
"0.56337243",
"0.56069",
"0.55562913",
"0.5505668",
"0.5504673",
"0.5498057",
"0.5470613",
"0.5459943",
... | 0.7272555 | 2 |
parturl is "/wiki/film_name" without the part _file is path to save to (optional, if not given will be determined and written to a file) | def fetchfilm parturl, _file=nil
return nil unless parturl
table = "movie"
if parturl.index("&")
#$log.warn "Cannot handle ampersand in URL. please correct #{parturl}"
$stderr.puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
$stderr.puts "Cannot handle ampersand in URL. please correct #{parturl}"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_wiki_media( filename, url )\n path =\n if @media_dir.nil?\n filename\n else\n \"#{@media_dir}/#{filename}\"\n end\n save_wiki_body( path, url )\n end",
"def save_wiki_path( wikipath )\n filename = wikipath.split( ':' ).last\n extension = file... | [
"0.6338837",
"0.58899647",
"0.58490884",
"0.5745464",
"0.56739825",
"0.5639433",
"0.5523551",
"0.5519502",
"0.5376674",
"0.53636736",
"0.5315702",
"0.5308096",
"0.5277985",
"0.5277065",
"0.52752936",
"0.5263278",
"0.52556884",
"0.5250324",
"0.5199795",
"0.5197651",
"0.5195781... | 0.6603925 | 0 |
All words must have their first letter capitalized. If the final result is longer than 140 chars it must return false. If the input or the result is an empty string it must return false. Examples " Hello there thanks for trying my Kata" => "HelloThereThanksForTryingMyKata" " Hello World " => "HelloWorld" "" => false p ... | def generateHashtag(string)
return false if string.gsub(/ /, "").empty?
capitalized_string = string.split(" ").map do |word|
word.capitalize
end
hash_tag_str = capitalized_string.join("").prepend("#")
if hash_tag_str.size <= 140
return hash_tag_str
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateHashtag(string)\r\n return false if string.empty?\r\n words = string.split(\" \")\r\n capitals = words.map do |element|\r\n element.capitalize\r\n end\r\n joined = capitals.join\r\n hashed = joined.prepend(\"#\")\r\n \r\n if hashed.length > 140\r\n return false\r\n end\r\n return false ... | [
"0.7310608",
"0.7130881",
"0.698981",
"0.6791103",
"0.6754028",
"0.6637155",
"0.6135526",
"0.5959236",
"0.5797691",
"0.57809156",
"0.56838995",
"0.56784815",
"0.56149065",
"0.5589976",
"0.55755496",
"0.5559497",
"0.5547764",
"0.5538655",
"0.5530566",
"0.552751",
"0.54935855",... | 0.716136 | 1 |
GET /beer/cBLTUw GET /beers/1.json | def show
@beer = BreweryDB.beer(params[:id])
render json: @beer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_beer\n beer_id = params['id'];\n response = HTTP.get('http://api.brewerydb.com/v2/beer/' + beer_id,\n :params=> {\n :key => ENV[\"BREWERYDB_BEERRATER_KEY\"],\n :withBreweries => \"y\"\n }\n )\n\n body = response.parse\n\n # check for success\n i... | [
"0.7754738",
"0.7627747",
"0.74879485",
"0.72991407",
"0.71286124",
"0.71008426",
"0.69856155",
"0.6803981",
"0.6791996",
"0.67296135",
"0.6644262",
"0.66208786",
"0.65915847",
"0.65607315",
"0.6537092",
"0.6497845",
"0.6490301",
"0.6453182",
"0.6394819",
"0.6390688",
"0.6339... | 0.7661986 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def post_params
params.require(:post).permit(:title, :body, :image, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
GET /donees GET /donees.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @to_dos = ToDo.all\n\n render json: @to_dos\n end",
"def index\n @task_doers = TaskDoer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @task_doers }\n end\n end",
"def index\n @departamentos = Departamento.all\n\n render j... | [
"0.6463405",
"0.6172791",
"0.61008775",
"0.60967517",
"0.6068657",
"0.6067882",
"0.60667306",
"0.6053499",
"0.60400176",
"0.60331196",
"0.60110235",
"0.5964939",
"0.5922689",
"0.58988655",
"0.58849907",
"0.5881288",
"0.58730483",
"0.5842002",
"0.58310384",
"0.5818661",
"0.581... | 0.0 | -1 |
GET /donees/1 GET /donees/1.json | def show
# Date.strptime('03-02-2001', '%d-%m-%Y')
# @donee = Donee.first
# @donee_names = []
#
# donees = Donee.all
# donees.each do |n|
# @donee_names << n.name
# end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @to_dos = ToDo.all\n\n render json: @to_dos\n end",
"def set_donee\n @donee = Donee.find(params[:id])\n end",
"def destroy\n @donee.destroy\n respond_to do |format|\n format.html { redirect_to donees_url, notice: 'Donee was successfully destroyed.' }\n format.json { h... | [
"0.62583584",
"0.60610557",
"0.5984346",
"0.5948712",
"0.59423405",
"0.59041643",
"0.58695966",
"0.58659023",
"0.5832346",
"0.582402",
"0.5821973",
"0.5782034",
"0.5771655",
"0.57648844",
"0.5755583",
"0.5738947",
"0.5731873",
"0.5719817",
"0.5696216",
"0.5693852",
"0.5664053... | 0.0 | -1 |
POST /donees POST /donees.json | def create
@donee = Donee.new(donee_params)
respond_to do |format|
if @donee.save
format.html { redirect_to @donee, notice: 'Donee was successfully created.' }
format.json { render :show, status: :created, location: @donee }
else
format.html { render :new }
format.js... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n# @done = Done.new(done_params)\n\n @post = Post.find(params[:post_id])\n @done = @post.dones.new(done_params)\n @done.user_id = current_user.id\n\n\n respond_to do |format|\n if @done.save\n format.html { redirect_to posts_path, notice: 'Done was successfully created.' }\n ... | [
"0.6368177",
"0.6215301",
"0.5959685",
"0.5940304",
"0.5764649",
"0.5729818",
"0.5721839",
"0.5669568",
"0.5599997",
"0.55538124",
"0.5545116",
"0.553388",
"0.54506445",
"0.5449535",
"0.5407654",
"0.5389707",
"0.53404117",
"0.53182375",
"0.52874565",
"0.5287048",
"0.52795315"... | 0.68349856 | 0 |
PATCH/PUT /donees/1 PATCH/PUT /donees/1.json | def update
respond_to do |format|
if @donee.update(donee_params)
format.html { redirect_to @donee, notice: 'Donee was successfully updated.' }
format.json { render :show, status: :ok, location: @donee }
else
format.html { render :edit }
format.json { render json: @donee.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @api_v1_todo.update(api_v1_todo_params)\n format.json { render json: @api_v1_todo, status: :ok }\n else\n format.json { render json: @api_v1_todo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do... | [
"0.64618134",
"0.6408097",
"0.63804674",
"0.6371403",
"0.63557965",
"0.6265587",
"0.6203826",
"0.6152558",
"0.61506444",
"0.6117603",
"0.6073044",
"0.60711056",
"0.60544413",
"0.6034909",
"0.60259163",
"0.6019092",
"0.6018569",
"0.5997066",
"0.59880114",
"0.5956873",
"0.59485... | 0.6399549 | 2 |
DELETE /donees/1 DELETE /donees/1.json | def destroy
@donee.destroy
respond_to do |format|
format.html { redirect_to donees_url, notice: 'Donee was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy1\n @todo = Todo.find(params[:id])\n @todo.destroy\n\n respond_to do |format|\n format.html { redirect_to(todos_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend... | [
"0.6807342",
"0.6752741",
"0.67200166",
"0.6698951",
"0.6698896",
"0.66622174",
"0.664555",
"0.66266084",
"0.6626386",
"0.66260356",
"0.66081125",
"0.66073656",
"0.6604701",
"0.6588041",
"0.65833795",
"0.6556959",
"0.6552667",
"0.6542285",
"0.65412533",
"0.6515899",
"0.651589... | 0.69950575 | 0 |
Never trust parameters from the scary internet, only allow the white list through. | def donee_params
params.require(:donee).permit(:name, :blurb, :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 |
Use callbacks to share common setup or constraints between actions. | def set_donee
@donee = Donee.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
def serializer Client::ProfileSerializer end | def obj_params
params.require(:data).require(:attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializer_class\n AccountSerializer\n end",
"def serializer; end",
"def serializer_class\n UserSerializer\n end",
"def to_json\r\n @profile.to_json\r\n end",
"def profile\n render_json 0,\"ok\",current_member.as_profile\n end",
"def profile\n render jso... | [
"0.707104",
"0.6976395",
"0.6910577",
"0.6908832",
"0.68323326",
"0.6702154",
"0.6689409",
"0.6689409",
"0.66135454",
"0.6595338",
"0.6530614",
"0.65118307",
"0.64069897",
"0.6401974",
"0.63848996",
"0.6359871",
"0.6348998",
"0.6336353",
"0.6336353",
"0.6336353",
"0.6336353",... | 0.0 | -1 |
This method generates an array of all moves that can be made after the current move. | def children
new_board = board.dup
kids = []
@board.rows.each_with_index do |row, idx1|
row.each_with_index do |spot, idx2|
if spot.nil?
next_mover_mark = (next_mover_mark = :x ? :o : :x)
node = TicTacToeNode.new(board.dup, next_mover_mark, [idx1,idx2])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_possible_moves\n positions_array = []\n x = @position[0]\n y = @position[1]\n next_position = [x+1,y+2]\n positions_array << next_position if position_check(next_position)\n next_position = [x+1,y-2]\n positions_array << next_position if position_check(next_position)\n next_positio... | [
"0.74549186",
"0.74482554",
"0.74063426",
"0.737531",
"0.72386026",
"0.7236256",
"0.72157466",
"0.72128487",
"0.7204562",
"0.7180846",
"0.7139838",
"0.71160436",
"0.70885247",
"0.70808315",
"0.7072801",
"0.7061625",
"0.7034458",
"0.7026592",
"0.69839364",
"0.69761074",
"0.695... | 0.0 | -1 |
get every test to pass before coding runner below | def runner
welcome
total = initial_round
until total > 21
total = hit?(total)
display_card_total(total)
end
end_game(total)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_tests\n puts \"Running exactly #{@spec.size} tests.\"\n @spec.each do |test_case|\n sleep test_case.wait_before_request\n response = send_request_for(test_case)\n Checker.available_plugins.each do |plugin|\n result = @expectation.check(plugin, response, test_case)\n if no... | [
"0.7274132",
"0.7200911",
"0.71905994",
"0.7134598",
"0.7127439",
"0.70358455",
"0.6860759",
"0.68229115",
"0.68049264",
"0.6790065",
"0.6790065",
"0.6768047",
"0.65728307",
"0.65551996",
"0.65487796",
"0.65460235",
"0.65293026",
"0.64595217",
"0.6447049",
"0.6447049",
"0.644... | 0.0 | -1 |
Search for a user by invitee email and check if it exists in the database and set it as user. | def find_user_from_invitee_email
return if invitee_email.nil?
self.user = ::User.find_by(email: invitee_email)
errors.add(:invitee_email, 'is not a registered user') if user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_user_byemail(email, name)\n users = db[:users]\n usr = users.first(:email => email)\n\n if usr.nil?\n\n u = retrieve_user_byemail(email, name)\n\n if u.nil? or u['login'].nil?\n warn \"Could not retrieve user #{email} through search API query\"\n login = (0... | [
"0.70235425",
"0.7015569",
"0.68371695",
"0.6813584",
"0.6776161",
"0.6768435",
"0.67257917",
"0.6720371",
"0.670291",
"0.66934264",
"0.66686183",
"0.6651658",
"0.6641781",
"0.6633563",
"0.6595569",
"0.6589429",
"0.65857303",
"0.6574355",
"0.65354645",
"0.6519255",
"0.6496975... | 0.8416475 | 0 |
Uses googles tokeninfo endpoint to get an email address from the google access_token | def get_email_from_access_token(google_access_token)
data= {
:access_token => google_access_token,
:fields => 'email' # specify we only want the email
}
r = RestClient.post GOOGLE_OAUTH_TOKEN_VALIDATION_URL, data
json = JSON.parse(r.body)
puts "\n#{json['email']}\n"
json['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_email(access_token)\n callback = Proc.new { |r| r.headers['Authorization'] = \"Bearer #{access_token}\"}\n\n graph = MicrosoftGraph.new(base_url: 'https://graph.microsoft.com/v1.0',\n cached_metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY, 'metadata_v1.... | [
"0.710528",
"0.68023866",
"0.6704101",
"0.66410035",
"0.6637329",
"0.65964234",
"0.65655583",
"0.65655583",
"0.6557444",
"0.65545434",
"0.6512269",
"0.6477013",
"0.64744395",
"0.64744395",
"0.64744395",
"0.64744395",
"0.6457409",
"0.6447656",
"0.6399571",
"0.6399571",
"0.6399... | 0.8042009 | 0 |
First POST to /connect/authorize to get an authorization code from Nylas Then post to /connect/token to get an access_token that can be used to access account data | def connect_to_nylas(data)
code = nylas_code(data)
data = {
:client_id => NYLAS_CLIENT_ID,
:client_secret => NYLAS_CLIENT_SECRET,
:code => code
}
nylas_access_token = nylas_token(data)
session[:nylas_access_token] = nylas_access_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def auth\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"params=#{params}\",\n \"\" ] if browse_everything_controlle... | [
"0.72624415",
"0.7230645",
"0.71952486",
"0.71725875",
"0.7137556",
"0.7077505",
"0.7062492",
"0.7056827",
"0.70510006",
"0.6968806",
"0.6937291",
"0.6877333",
"0.68456054",
"0.6810999",
"0.6806704",
"0.67880017",
"0.6782348",
"0.6764795",
"0.67646086",
"0.6761982",
"0.676198... | 0.66567063 | 32 |
As an administrator, I can access the list of all of the rooms in the hotel | def initialize(room_file = 'support/rooms.csv', reservations_file = 'support/reservations.csv', blocks_file = 'support/blocks.csv')
@rooms = load_rooms(room_file)
@reservations = load_reservations(reservations_file)
@blocks = load_blocks(blocks_file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @rooms = current_user.rooms.all\n end",
"def room_list\n\t\t@room = Accommodation.find_all_by_host_id(@current_user.id)\n\t\t@date = RoomBooking.find_all_by_room_id(@room)\n \tend",
"def room_list\n @roomtype = DetailRoom.all_types\n @time = Room.all_times\n @day_list = Room.all_days\n... | [
"0.74852496",
"0.73973393",
"0.71839",
"0.71793145",
"0.7169243",
"0.71610993",
"0.71486694",
"0.70516187",
"0.698442",
"0.6981503",
"0.6969448",
"0.69612294",
"0.69489056",
"0.691579",
"0.6896379",
"0.6890746",
"0.68892586",
"0.68819296",
"0.68819296",
"0.68819296",
"0.68819... | 0.0 | -1 |
As an administrator, I can reserve an available room for a given date range As an administrator, I can reserve a room from within a block | def make_reservation(start_date: Date.today, end_date: Date.today + 2, group_name: "", num_of_rooms: 1)
if group_name != ""
found_block = Block.find_block(blocks, group_name, start_date: start_date, end_date: end_date)
if found_block == nil
new_block = create_a_block(group_name, start_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reserve_room(start_date, end_date) \n \n current_room = ()\n if @reservation_list.empty? == true\n current_room = rooms.shift\n elsif @reservation_list.empty? == false\n @reservation_list.include?(start_date)\n count = @reservation_list.count(start_date)\n c... | [
"0.79430896",
"0.78415716",
"0.7600206",
"0.75615066",
"0.736294",
"0.7265062",
"0.7235886",
"0.72112006",
"0.71817195",
"0.70016396",
"0.6952507",
"0.69495267",
"0.6948527",
"0.6914141",
"0.6908276",
"0.6899546",
"0.6894756",
"0.68527126",
"0.6848436",
"0.68452126",
"0.68356... | 0.70888895 | 9 |
As an administrator, I can create a block of rooms | def create_a_block(group_name, num_of_rooms: 5, start_date: Date.today, end_date: Date.today + 2, room_rate: 175)
if num_of_rooms > 5
raise ArgumentError.new("Only 5 rooms per block.")
end
list = Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)
if list.length... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n filteredParams = params.require(:room).permit(:name, :owner_id, :privacy, :password)\n\n if filteredParams[\"privacy\"] && filteredParams[\"privacy\"] == \"on\"\n filteredParams[\"privacy\"] = \"private\"\n else\n filteredParams[\"privacy\"] = \"public\"\n end \n\n if fi... | [
"0.693106",
"0.67344487",
"0.66236943",
"0.6591751",
"0.6462527",
"0.6459644",
"0.6424162",
"0.6346768",
"0.633667",
"0.6284537",
"0.62812614",
"0.62696147",
"0.62604463",
"0.6247351",
"0.6226696",
"0.61603326",
"0.61317974",
"0.611346",
"0.6102216",
"0.6101918",
"0.6101918",... | 0.58285147 | 44 |
As an administrator, I can access the list of reservations for a specific date | def find_reservations(date: Date.today)
found_reservations = []
if date.class != Date
date = Date.parse(date)
end
reservations.each do |reservation|
all_dates = DateRange.create_date_array(start_date: reservation.start_date, end_date: reservation.end_date)
if all_dates.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_reservations\n user = User.find(current_user.id)\n @reservations = user.reservations\n end",
"def index\n @reservations = Reservation.all.paginate(:page => params[:page]).per_page(10)\n authorize! :index, :Reservations\n end",
"def list_reservations(date)\n res_on_date = @reservatio... | [
"0.73762614",
"0.7365575",
"0.73042095",
"0.72225356",
"0.72077215",
"0.71958464",
"0.7177841",
"0.71753603",
"0.7130236",
"0.71139574",
"0.70995647",
"0.69245934",
"0.6906378",
"0.6825093",
"0.67735434",
"0.67682695",
"0.675079",
"0.67491305",
"0.67491305",
"0.67491305",
"0.... | 0.6662723 | 35 |
As an administrator, I can view a list of rooms that are not reserved for a given date range | def find_available_rooms(rooms, start_date: Date.today, end_date: Date.today + 2)
return Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unreserved_rooms_by_date(start_date, end_date)\n dates = date_range(start_date, end_date)\n dates << Date.parse(end_date)\n unreserved_rooms = []\n @rooms.each do |room|\n if is_available?(room, dates) && is_not_blocked?(room, dates)\n unreserved_rooms << room\n end\n end\n r... | [
"0.80312866",
"0.8021399",
"0.7997565",
"0.7774477",
"0.76432896",
"0.7572688",
"0.7559248",
"0.75459963",
"0.75328237",
"0.74155045",
"0.7182441",
"0.70447415",
"0.70402145",
"0.70017654",
"0.6975295",
"0.6958855",
"0.69202226",
"0.6906689",
"0.688763",
"0.6831559",
"0.68250... | 0.6947593 | 16 |
As an administrator, I can check whether a given block has any rooms available and view a list of these rooms | def find_available_rooms_in_block(blocks, group_name, start_date: Date.today, end_date: Date.today + 2)
return Block.all_available_rooms_in_block(blocks, group_name, start_date: start_date, end_date: end_date)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_rooms_in_block(block_name:)\n available = reservations.find_all do |reservation|\n reservation.block_name == block_name && reservation.booking_name == nil\n end\n\n return available\n end",
"def rooms_available\n avail_block_reservations = []\n \n reservation... | [
"0.7543029",
"0.71390253",
"0.7020946",
"0.6975275",
"0.68901706",
"0.67006785",
"0.6576037",
"0.65246403",
"0.6451157",
"0.6387117",
"0.6386919",
"0.6358869",
"0.63572425",
"0.6327068",
"0.62708783",
"0.62096894",
"0.6206484",
"0.62007195",
"0.61949897",
"0.6191824",
"0.6151... | 0.68016624 | 5 |
create_table_like( :sometable, :newtable, :remove_keys => true) | def create_table_like(like_table, table, options = {}, &blk)
options.symbolize_keys!
code = table_schema_code(like_table)
code.gsub!(/create_table\s+"#{like_table}"/, "create_table :#{table}")
if options[:replace_keys] or options[:remove_keys]
code.gsub!(/add_index\s+"#{like_table}"/, "#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tables!\n migrate(:up)\n end",
"def create_table!(*args, &block)\n drop_table(model.table_name)\n create_table(*args, &block)\n end",
"def tnTableCreation(tableName)\n pk_list = @pkList.join(',')\n pk_list = \"#{pk_list},branch_name,node_name\"\n q = QueryBuilder.create... | [
"0.6575832",
"0.650357",
"0.64961874",
"0.6459509",
"0.6357394",
"0.63541585",
"0.6335444",
"0.6333733",
"0.6318558",
"0.631556",
"0.6293069",
"0.6249256",
"0.6181985",
"0.6175112",
"0.61671805",
"0.61654323",
"0.61263263",
"0.6099077",
"0.6088456",
"0.60824215",
"0.6081483",... | 0.7066579 | 0 |
copy_table_data( :sometable, :newtable, [[:old_column, :new_column]]) | def copy_table_data(from, to, remaps = [])
old = columns(from).collect(&:name)
current = columns(to).collect(&:name)
remapped_columns = remaps.collect {|c| c.first.to_s}.compact
common = (current & old).sort - remapped_columns
from_columns = common.collect {|c| "`#{c}`"}
to_columns =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_table(old_table_name, new_table_name)\r\n execute add_select_into_table(new_table_name, \"SELECT * FROM #{old_table_name}\")\r\n end",
"def copy_table(old_table_name, new_table_name)\n execute add_select_into_table(new_table_name, \"SELECT * FROM #{old_table_name}\")\n end",
"d... | [
"0.71277267",
"0.70293593",
"0.69157106",
"0.6910602",
"0.6837608",
"0.6511523",
"0.6480268",
"0.6466001",
"0.6390649",
"0.63520324",
"0.6078091",
"0.5984563",
"0.59447193",
"0.58846813",
"0.5861879",
"0.5852372",
"0.5843485",
"0.5803659",
"0.5803481",
"0.5754729",
"0.5754729... | 0.75281143 | 0 |
removes all the indexes | def disable_indexes(table)
list = indexes(table)
change_table_with_remaps table do |t|
list.each do |i|
t.remove_index :name => i.name
end
end
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_index_information\n @indexes = nil\n end",
"def delete_indexes\n self.class.indexes.each do |name, index|\n index.delete(self)\n end\n end",
"def deregister_all_indexes\n @indexes.clear\n $LUCENE_LOGGER.debug{\"Deregistered all index, #{@indexes.inspect}\... | [
"0.79736143",
"0.7935358",
"0.77306616",
"0.7723996",
"0.7683794",
"0.76807785",
"0.76742744",
"0.76606107",
"0.7629888",
"0.75919926",
"0.74693227",
"0.7408753",
"0.7408531",
"0.73250586",
"0.730263",
"0.72727716",
"0.72090036",
"0.7123538",
"0.7105879",
"0.70663124",
"0.703... | 0.68176967 | 28 |
GET /articles GET /articles.xml | def index
@channel, @articles = find_articles(params[:channel_id])
respond_to do |format|
format.html { render :layout => 'admin' } # index.html.erb
format.xml { render :xml => @articles }
format.js { render(:update) { |page| page.replace_html 'channel-form', :partial => 'list' } }
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @articles = Article.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @articles }\n end\n end",
"def index\n @articles = Article.published\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { re... | [
"0.7521566",
"0.73842925",
"0.73075944",
"0.7159722",
"0.7159722",
"0.7159722",
"0.7159722",
"0.7159722",
"0.7159722",
"0.7159722",
"0.7159722",
"0.71472275",
"0.71425074",
"0.7112847",
"0.7068216",
"0.6978829",
"0.6947218",
"0.6909853",
"0.6844263",
"0.68124366",
"0.67681164... | 0.0 | -1 |
GET /articles/1 GET /articles/1.xml | def show
@article = Article.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @article }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @articles = Article.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @articles }\n end\n end",
"def show\n @article = Article.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml ... | [
"0.7446893",
"0.738177",
"0.7374569",
"0.724454",
"0.7055296",
"0.70232207",
"0.701292",
"0.6995432",
"0.69788206",
"0.6860953",
"0.68546844",
"0.68211466",
"0.6727519",
"0.6677121",
"0.66770333",
"0.66738933",
"0.66449267",
"0.6644454",
"0.66257924",
"0.66229665",
"0.6549625... | 0.7242173 | 8 |
GET /articles/new GET /articles/new.xml | def new
@standalone = params[:standalone]
if @standalone && @standalone.length > 0
@channel = Channel.find(1)
@article = Article.new
else
@channel = Channel.find(params[:channel_id])
@article = Article.new(:channel_id => @channel.id)
end
respond_to do |format|
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @article = Article.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article }\n end\n end",
"def new\n @article = Article.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @article }\... | [
"0.78804785",
"0.78804785",
"0.78804785",
"0.78804785",
"0.78804785",
"0.78804785",
"0.78804785",
"0.78804785",
"0.76756096",
"0.75748205",
"0.75093895",
"0.75093895",
"0.75093895",
"0.74744266",
"0.7393164",
"0.7303267",
"0.726955",
"0.72494406",
"0.72494406",
"0.72428685",
... | 0.0 | -1 |
POST /articles POST /articles.xml | def create
@article = Article.new(params[:article])
@article.user_id = current_user.id
respond_to do |format|
if @article.save
#@article.contents.create(:body => params[:body])
Content.create(:title => @article.title, :body => params[:body], :article_id => @article.id)
flash[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @article = Article.new(params[:article])\n \n respond_to do |format|\n if @article.save\n flash[:notice] = 'Article was successfully created.'\n \n format.html { redirect_to article_url(@article) }\n format.xml do\n headers[\"Location\"] = article_url... | [
"0.67597526",
"0.65964556",
"0.6577468",
"0.6577468",
"0.6577468",
"0.65076905",
"0.63619834",
"0.62928456",
"0.6286046",
"0.62419593",
"0.6227294",
"0.6215315",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662",
"0.6213662... | 0.0 | -1 |
PUT /articles/1 PUT /articles/1.xml | def update
@article = Article.find(params[:id])
content = @article.contents[0]
# @article.contents.create(:title => @article.title, :body => params[:body]) unless content
# content.update_attributes(:title => @article.title, :body => params[:body]) if content
Content.create(:title => @article.title, :... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(uri, xml)\r\n req = Net::HTTP::Put.new(uri)\r\n req[\"content-type\"] = \"application/xml\"\r\n req.body = xml\r\n request(req)\r\n end",
"def update\n @article = Article.find(params[:id])\n \n respond_to do |format|\n if @article.update_attributes(params[:article])\n... | [
"0.68915385",
"0.6718309",
"0.6661881",
"0.65886074",
"0.6569046",
"0.65310055",
"0.648138",
"0.6479946",
"0.6479946",
"0.6479946",
"0.64545494",
"0.64324313",
"0.63550544",
"0.6338919",
"0.62794197",
"0.6229289",
"0.62172234",
"0.6180424",
"0.6176849",
"0.6176849",
"0.617684... | 0.0 | -1 |
DELETE /articles/1 DELETE /articles/1.xml | def destroy
params[:id].each{|id|
Content.delete_all("article_id = #{id}")
Article.find(id.to_i).destroy
} if params[:id]
respond_to do |format|
format.html { redirect_to(articles_url) }
format.xml { head :ok }
format.js {
@channel, @articles = find_articles(params[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @article = Article.find_by_sysname(params[:id])\n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to(articles_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @article = Article.find(params[:id])\n @article.destroy\n\n respond_to do... | [
"0.749537",
"0.7440755",
"0.7440755",
"0.7440755",
"0.7440755",
"0.7440755",
"0.7421442",
"0.739566",
"0.739566",
"0.7387888",
"0.72310495",
"0.7155709",
"0.7146168",
"0.7144743",
"0.7049671",
"0.7016849",
"0.69805413",
"0.6971348",
"0.69401735",
"0.6921887",
"0.6919229",
"... | 0.0 | -1 |
Find and return the category in the current row from the csv file | def find_category(row, start, finish)
idx = (start..finish).to_a.filter { |i| row[i] }.first
row[idx]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_category(file)\n file.match(Regexp.new(Regexp.escape(csv_root))) or \n raise AMEEM::Exceptions::Location.new(\"#{file} is not in CSV tree\")\n file.sub(Regexp.new(Regexp.escape(csv_root)),\"\");\n end",
"def get_categories(row)\n categories = []\n cat = at_in(:category1 , row) # should... | [
"0.74801314",
"0.6453353",
"0.64435565",
"0.6150726",
"0.6064087",
"0.60306656",
"0.5939777",
"0.59292287",
"0.57306725",
"0.56499374",
"0.55948186",
"0.5560919",
"0.55508685",
"0.55247885",
"0.5489577",
"0.5489265",
"0.54536885",
"0.54429805",
"0.54271144",
"0.5426627",
"0.5... | 0.63962 | 3 |
Get all will retrieve all todos from the storage. | def get_all
Rutodo::Database::Todo.map(&:as_entity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all\n storage\n end",
"def all\n @all ||= data.collect do |item|\n todo = Todo.new(item.merge(user: user))\n end\n end",
"def index\n @todos = @list.todos.all\n end",
"def all\n api_get(path)\n end",
"def all_todos\n (global_todos.where(language: I... | [
"0.68890536",
"0.6657874",
"0.65052336",
"0.64595646",
"0.6355627",
"0.6348337",
"0.6348337",
"0.6348337",
"0.6348337",
"0.6348337",
"0.6348337",
"0.6246821",
"0.6227349",
"0.61992437",
"0.61480683",
"0.6141433",
"0.6104199",
"0.6093661",
"0.6093272",
"0.601962",
"0.60181755"... | 0.69502157 | 0 |
Get pending will retrieve all pending todos from the storage. | def get_pending
Rutodo::Database::Todo.where(done: false).map(&:as_entity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status\n TodoStatus::PENDING\n end",
"def get_completed_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => true})\n end",
"def pending\r\n\t\t\t# Author\r\n\t\t\tauthorize! :manage, Project\r\n\r\n\t\t\t@projects = Project.pending_search_with_params interact: 'desc'\r\n\r\n\t\t\tre... | [
"0.5814593",
"0.57646",
"0.5761569",
"0.57317364",
"0.5680982",
"0.56554574",
"0.5609464",
"0.5572155",
"0.5555084",
"0.554804",
"0.55394024",
"0.5485255",
"0.54261005",
"0.5423436",
"0.53721136",
"0.5369424",
"0.53673214",
"0.5364665",
"0.5331469",
"0.5316743",
"0.5307562",
... | 0.7058404 | 0 |
Get all will retrieve all finished todos from the storage. | def get_finished
Rutodo::Database::Todo.where(done: true).map(&:as_entity)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed_todos\n if @completed_todos.empty? && @completed_count > 0\n refresh\n end\n \n return @completed_todos\n end",
"def all\n storage\n end",
"def get_all\n Rutodo::Database::Todo.map(&:as_entity)\n end",
"def todos\n remaining_todos + complet... | [
"0.6609674",
"0.65785336",
"0.655256",
"0.6484078",
"0.64625454",
"0.6263009",
"0.62069297",
"0.6189128",
"0.6142066",
"0.6029412",
"0.5997413",
"0.5997413",
"0.5997413",
"0.5997413",
"0.5997413",
"0.5997413",
"0.5975037",
"0.596113",
"0.59547675",
"0.5947648",
"0.59311473",
... | 0.56697804 | 45 |
Insert will insert a new todo to the storage. | def insert(todo)
todo = Rutodo::Database::Todo.new(
title: todo.title,
description: todo.description,
done: todo.status == :finished
)
todo.save
todo.as_entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert task\n now = Time.now.to_i\n tasks = @db[:tasks]\n tasks.insert :title => task.title,\n :status => task.getStatus,\n :created => now,\n :wake => now,\n :changed => 0,\n :path => task.getPath,\n :data... | [
"0.69900006",
"0.6769621",
"0.6562503",
"0.64362013",
"0.6251474",
"0.61850756",
"0.60824394",
"0.6025825",
"0.590449",
"0.58825225",
"0.5834113",
"0.58253413",
"0.580955",
"0.58057314",
"0.5782336",
"0.57745624",
"0.5761529",
"0.5711856",
"0.5710602",
"0.5710126",
"0.5707353... | 0.7308 | 0 |
Update will update a todo in the storage. | def update(todo)
todo = Rutodo::Database::Todo[todo.id].set(
title: todo.title,
description: todo.description,
done: todo.status == :finished
)
todo.save_changes
todo.as_entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @todo.update(todo_params)\n head :no_content\n end",
"def update\n @todo.update(todo_params)\n respond_with(@user, @todo)\n end",
"def update\n @todo = @list.todos.find(params[:id])\n\n if @todo.update_attributes(params[:todo])\n flash[:notice] = 'To do was succe... | [
"0.74574673",
"0.6868982",
"0.68505585",
"0.68407863",
"0.6807895",
"0.6724905",
"0.66860473",
"0.66340023",
"0.65627944",
"0.6554246",
"0.6552655",
"0.6547167",
"0.6488379",
"0.64814824",
"0.6475541",
"0.6461797",
"0.6425606",
"0.6411207",
"0.640347",
"0.64017725",
"0.639266... | 0.69932497 | 1 |
Delete will delete a todo. | def delete(todo)
Rutodo::Database::Todo[todo.id].destroy.as_entity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_todo(todo)\n response = Logan::Client.delete \"/projects/#{@project_id}/todos/#{todo.id}.json\"\n end",
"def destroy\n @todo.destroy\n head :no_content\n end",
"def destroy\n @todo = Todoo.find(params[:id])\n @todo.destroy\n \n redirect_to todoo_index_pat... | [
"0.78907937",
"0.77379066",
"0.77284724",
"0.7658772",
"0.76345795",
"0.75409585",
"0.7537518",
"0.7492626",
"0.74409676",
"0.7429703",
"0.7424949",
"0.73925024",
"0.732475",
"0.7309192",
"0.7296406",
"0.729235",
"0.7287415",
"0.7281031",
"0.7249211",
"0.72407746",
"0.7220539... | 0.82587105 | 0 |
Delete finished will delete all finished todos. | def delete_finished
Rutodo::Database::Todo.where(done: true).delete
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all_completed!\n @todos = @todos.reject { |todo| todo.completed == true }\n end",
"def done!\n @todos.each {|todo| todo.done! }\n end",
"def destroy\n @todo.destroy\n head :no_content\n end",
"def delete\n newTodos = []\n\n @@allTodos.each { |item|\n if item['id'] !... | [
"0.7211703",
"0.68463326",
"0.63647157",
"0.6318015",
"0.6176891",
"0.61645496",
"0.60707474",
"0.6064646",
"0.6059137",
"0.60561436",
"0.60423464",
"0.6006104",
"0.5979228",
"0.5950897",
"0.59291536",
"0.5897564",
"0.5885479",
"0.58851975",
"0.5872813",
"0.58606887",
"0.5858... | 0.8363232 | 0 |
Let the projct object at least raise exceptions. | def raise(*args)
::Object.send(:raise, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raise(exception); end",
"def exceptions; end",
"def catch_exceptions; end",
"def expects_exception?; self.class.expects_exception; end",
"def is_exception?; end",
"def propagate\n @propagate_exceptions = true\n end",
"def exception; end",
"def exception; end",
"def exception; end",
"d... | [
"0.68677676",
"0.6847129",
"0.6682763",
"0.6631456",
"0.6574435",
"0.6572312",
"0.6498573",
"0.6498573",
"0.6498573",
"0.6498573",
"0.6498573",
"0.64845103",
"0.6460485",
"0.6314652",
"0.63035256",
"0.62866044",
"0.62543726",
"0.6244052",
"0.6215",
"0.61669993",
"0.61594075",... | 0.0 | -1 |
The current preview branch is the alphabetically last preview branch | def derive_branch_name
@config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_branch\n repo.branches.find(&:head?)\n end",
"def current_branch\n repo.branches.find(&:head?)\n end",
"def current_branch; end",
"def current_branch; end",
"def branch_name\n $repo.current_branch\n end",
"def current_branch\n hg('branch').to_s.strip\n ... | [
"0.7132076",
"0.69722915",
"0.69348985",
"0.69348985",
"0.6899001",
"0.68023574",
"0.6778202",
"0.67422575",
"0.6734611",
"0.6660328",
"0.6639899",
"0.6615331",
"0.6615331",
"0.6575923",
"0.65658313",
"0.65194666",
"0.6489488",
"0.6471747",
"0.6468118",
"0.6436184",
"0.643294... | 0.81659114 | 0 |
would be more advanced, but for the purposes of this, I'll stringify, then get each numbers ASCII key, then concat those keys together | def hash(key)
ascii_keys = []
key.to_s.each_byte { |el| ascii_keys << el }
ascii_keys.map { |el| el.to_s }.join('')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stringified_keys; end",
"def stringify_keys; end",
"def stringify_keys; end",
"def stringify_keys; end",
"def kv_encode(h); h.map {|k,v| k.to_s + \":\" + v.to_s + 10.chr }.join end",
"def stringify_keys\n reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n r... | [
"0.7265383",
"0.71342665",
"0.71342665",
"0.71342665",
"0.69689995",
"0.6911233",
"0.678544",
"0.678544",
"0.678544",
"0.66945225",
"0.6620249",
"0.66101766",
"0.66071206",
"0.6601913",
"0.65091455",
"0.6468331",
"0.6468331",
"0.6468331",
"0.6438948",
"0.6343887",
"0.6338717"... | 0.64007986 | 19 |
can't pick your opponent's piece | def picked_wrong_color(picked_color)
color != picked_color
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick_piece(test = false, pick = nil) # test, pick parameters for unit testing\n begin\n # TODO: Need to show only rooms not taken yet.\n puts \"Choose your playing piece.\"\n puts Suspects.list\n print \"> \"\n \n if test == false\n pick = gets.chomp\n else\n ... | [
"0.7183322",
"0.6910036",
"0.68939495",
"0.688727",
"0.68671954",
"0.6754144",
"0.67210466",
"0.6700011",
"0.66770566",
"0.6665463",
"0.6605182",
"0.6535708",
"0.6519613",
"0.650721",
"0.64365536",
"0.63894683",
"0.63607705",
"0.63547033",
"0.6321484",
"0.6255378",
"0.6245612... | 0.0 | -1 |
picking a nonjumping piece when you must jump | def not_jumping_when_obligated(gameboard, piece)
gameboard.must_jump?(piece.color) && piece.possible_jumps.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop_piece\n return unless @falling_piece\n\n loop do\n # piece_down takes care of finishing on hit\n break if piece_down\n end\n end",
"def select_piece\n piece_pos = get_piece_locations.sample\n return select_piece if @board[piece_pos].valid_moves.empty?\n piece_pos\n end",
... | [
"0.67122525",
"0.670047",
"0.65402097",
"0.6522776",
"0.6445344",
"0.63636875",
"0.63295084",
"0.6294951",
"0.6291475",
"0.628652",
"0.6285642",
"0.62849283",
"0.62569094",
"0.6224944",
"0.6215041",
"0.620617",
"0.61999285",
"0.6176394",
"0.6159135",
"0.6156761",
"0.6154919",... | 0.68028706 | 0 |
debug print line for printdebugging debug print default dp_line __LINE__ yy = call line no => |filename=|line=yy| debug print with filename dp_line __LINE__, filename: __FILE__ xx = filename, yy = call line no => |filename=xx|line=yy| debug print with no filename, specific char | def dp_line(line, options = { filename: '', char: '-' })
filename = options[:filename].nil? ? '' : options[:filename]
char = options[:char].nil? ? '-' : options[:char]
puts "#{char * 20}|filename=#{filename}|line=#{line}|#{char * 20}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def at_line(context, _file, _line)\n resume_pry(context)\n end",
"def print_line(msg='')\n end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end",
"def line; end"... | [
"0.6519024",
"0.6498243",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6496478",
"0.6400849",
"0.6360263",
"0.6258514",
"0.62584454",
... | 0.7277153 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_doctor_category
@doctor_category = DoctorCategory.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def doctor_category_params
params.require(:doctor_category).permit(:name, :avatar)
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 |
Logout of KFS (Not all versions support this) | def logout
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logout\n send_command( KonoEppLogout.new, 1500 )\n end",
"def logout\n BrickFTP::API::Authentication.logout\n end",
"def logout\n BrickFTP::API::Authentication.logout\n end",
"def logout\n session.context.logout(name)\n end",
"def logout\n if @logged_in\n cmd... | [
"0.78206146",
"0.7505195",
"0.7505195",
"0.7468499",
"0.7467534",
"0.741663",
"0.7403548",
"0.7397089",
"0.73841417",
"0.7373244",
"0.73689806",
"0.73650885",
"0.7336697",
"0.73278224",
"0.7312935",
"0.73082316",
"0.72827876",
"0.72669303",
"0.72651064",
"0.7223085",
"0.72166... | 0.72146297 | 22 |
Original from rubygnome gem | def original_exit_application(exception, status)
msg = exception.message || exception.to_s
msg = exception.class.to_s if msg == ''
backtrace = exception.backtrace
STDERR.puts "#{backtrace.shift}: #{msg}"
backtrace.each do |v|
STDERR.puts "\t from #{v}"
end
exit(status)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main\n # force close gedit process if open\n system('killall', 'gedit')\n \n # ***** uncomment the line below to install soothing fonts *****\n # system('sudo apt-get install ttf-bitstream-vera ttf-dejavu ttf-dejavu ttf-dejavu-core ttf-dejavu-extra ttf-liberation')\n \n # copy mime files\n FileUtils.cp... | [
"0.5899653",
"0.5570458",
"0.5524945",
"0.55060214",
"0.5500063",
"0.5486391",
"0.5419175",
"0.5410946",
"0.53806996",
"0.53768253",
"0.5342214",
"0.5331308",
"0.5320606",
"0.5320606",
"0.5320606",
"0.5320265",
"0.530021",
"0.5277027",
"0.52760476",
"0.5245931",
"0.5245931",
... | 0.0 | -1 |
DELETE /projects/1 DELETE /projects/1.json | def destroy
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url, notice: 'Successfully deleted project.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pr... | [
"0.78951",
"0.78593713",
"0.7778056",
"0.7771693",
"0.77585995",
"0.7730887",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77305084",
"0.77244985",
"0.7718401",
"0.7718401",
"0.7718401",
"0.7718401",
"0.7704753",
"0.7704753",
"0.7704753",
"0.7704753",
"0.7704753... | 0.75986093 | 53 |
Use callbacks to share common setup or constraints between actions. | def set_project
@project = Project.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def project_params
params.require(:project).permit(:name, :category, :tag_list, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.