query stringlengths 7 6.41k | document stringlengths 12 28.8k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 5 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Submits a PUT request to submit facts for the node to the server. | def put_facts(name, environment:, facts:)
formatter = Puppet::Network::FormatHandler.format_for(Puppet[:preferred_serialization_format])
headers = add_puppet_headers(
'Accept' => get_mime_types(Puppet::Node::Facts).join(', '),
'Content-Type' => formatter.mime
)
response = @client.put(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put!\n request! :put\n end",
"def put(*args)\n request :put, *args\n end",
"def put\n RestClient.put(url, @body, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def put(*args)\n ... | [
"0.6486299",
"0.647389",
"0.6468981",
"0.6419123",
"0.6367229",
"0.6242412",
"0.61906743",
"0.6188967",
"0.61644524",
"0.6155271",
"0.60836464",
"0.6076941",
"0.6062032",
"0.60561156",
"0.60211986",
"0.60090774",
"0.60042167",
"0.6004034",
"0.59919226",
"0.5986781",
"0.598117... | 0.6634443 | 1 |
Submit a HEAD request to check the status of a file stored with filebucket. | def head_filebucket_file(path, environment:, bucket_path: nil)
headers = add_puppet_headers('Accept' => 'application/octet-stream')
response = @client.head(
with_base_url("/file_bucket_file/#{path}"),
headers: headers,
params: {
environment: environment,
bucket_path: bucket_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def HEAD()\n self.class.open @dir, \"HEAD\"\n end",
"def head(path)\n request 'HEAD', path\n end",
"def http_head\n return @head if defined?(@head)\n begin\n @head = conn.request(http_request(:head, resource[:source]))\n fail \"#{resource[:http_verb].to_s.upcase} #{resource[:sou... | [
"0.66754866",
"0.65947723",
"0.6579196",
"0.6409026",
"0.62953323",
"0.62409395",
"0.6024056",
"0.6017825",
"0.5999554",
"0.5883677",
"0.5874071",
"0.58384484",
"0.583672",
"0.5834955",
"0.5771319",
"0.57666385",
"0.5758437",
"0.57139623",
"0.56877404",
"0.56852305",
"0.56756... | 0.7160273 | 1 |
GET /user_scores GET /user_scores.json | def index
@user_scores = UserScore.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @username_scores = UsernameScore.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @username_scores }\n end\n end",
"def score(username)\n user = get(\"/v2/identity.json/twitter\", :screenName => username)\n puts user.inspect\n ... | [
"0.7566785",
"0.7399767",
"0.72119796",
"0.71200496",
"0.70508844",
"0.70148563",
"0.6998617",
"0.6900297",
"0.66787964",
"0.664835",
"0.6568413",
"0.6551169",
"0.65203923",
"0.6488017",
"0.6468205",
"0.64653575",
"0.64544636",
"0.6414613",
"0.6414613",
"0.6414613",
"0.641107... | 0.74754244 | 1 |
PATCH/PUT /user_scores/1 PATCH/PUT /user_scores/1.json | def update
respond_to do |format|
if @user_score.update(user_score_params)
format.html { redirect_to @user_score, notice: 'User score was successfully updated.' }
format.json { render :show, status: :ok, location: @user_score }
else
format.html { render :edit }
format.jso... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @username_score = UsernameScore.find(params[:id])\n\n respond_to do |format|\n if @username_score.update_attributes(params[:username_score])\n format.html { redirect_to @username_score, notice: 'Username score was successfully updated.' }\n format.json { head :no_content }\n ... | [
"0.7103139",
"0.69201654",
"0.6873105",
"0.6873105",
"0.6873105",
"0.67826",
"0.6775637",
"0.6731775",
"0.6731775",
"0.6731775",
"0.6731775",
"0.66351616",
"0.6578503",
"0.6546883",
"0.645763",
"0.6448671",
"0.643871",
"0.6436305",
"0.64356726",
"0.6427505",
"0.64168245",
"... | 0.7313607 | 0 |
DELETE /user_scores/1 DELETE /user_scores/1.json | def destroy
@user_score.destroy
respond_to do |format|
format.html { redirect_to user_scores_url, notice: 'User score was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @username_score = UsernameScore.find(params[:id])\n @username_score.destroy\n\n respond_to do |format|\n format.html { redirect_to username_scores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @score = Score.find(params[:id])\n @score.destroy\n\n... | [
"0.7521304",
"0.71768457",
"0.71768457",
"0.71768457",
"0.71768457",
"0.7176378",
"0.7158487",
"0.69566554",
"0.6947571",
"0.6909006",
"0.6909006",
"0.6909006",
"0.6909006",
"0.6892883",
"0.6866999",
"0.6866999",
"0.68497735",
"0.68414015",
"0.6833266",
"0.68261606",
"0.68046... | 0.7533763 | 0 |
GET /empresa_servicios/1 GET /empresa_servicios/1.json | def show
@empresa_servicio = EmpresaServicio.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @empresa_servicio }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end",
"def show\n @calificacion_servicio = CalificacionServicio.find(params[:id])\n\n respond_to do |f... | [
"0.7232376",
"0.71963567",
"0.7056573",
"0.69814724",
"0.6893948",
"0.66606086",
"0.6650454",
"0.6650454",
"0.6614434",
"0.6529371",
"0.65185034",
"0.65107673",
"0.64949363",
"0.64796895",
"0.64787114",
"0.6477933",
"0.64309007",
"0.63816047",
"0.6370858",
"0.6365033",
"0.635... | 0.75859183 | 0 |
PUT /empresa_servicios/1 PUT /empresa_servicios/1.json | def update
@empresa_servicio = EmpresaServicio.find(params[:id])
respond_to do |format|
if @empresa_servicio.update_attributes(params[:empresa_servicio])
format.html { redirect_to empresa_empresa_servicios_path, notice: "Los datos del servicio fueron actualizados para la empresa #{@empresa_servi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ... | [
"0.6788587",
"0.67126",
"0.66260076",
"0.65767324",
"0.653937",
"0.65163445",
"0.6503712",
"0.64323515",
"0.6420696",
"0.64191544",
"0.6395187",
"0.6348539",
"0.63230324",
"0.628019",
"0.62640035",
"0.624243",
"0.61779153",
"0.61749154",
"0.616928",
"0.61657304",
"0.61592656"... | 0.70942056 | 0 |
Before save, automatically edit URL to remove affiliate codes (we'll insert our own when displayed, rather than saving static codes in the DB). Happens here because validation may change url, and not in url= because validation relies on other fields be set as well. | def filter_url_before_save
return true unless url_changed? && !self['url'].blank?
raw = self['url'].to_s.strip
raw = raw.sub(/tag=.+?(?:&|$)/, '') if raw =~ /amazon.com/i # Remove amazon associate tag
raw = raw.gsub(/&&+/, '&').sub(/[\?&]$/, '') # Trailing ? or &
self.url = raw
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def website_url=(new_url)\n write_attribute(:website_url, Organization.clean_url(new_url))\n end",
"def clean_url\n self.url = self.title.clone if self.url.blank?\n \n self.url.downcase!\n self.url = self.url.gsub(/[^[:alnum:]]/,'-').gsub(/-{2,}/,'-')\n self.url = self.url.gsub(/^[-]... | [
"0.6727485",
"0.62092894",
"0.61731255",
"0.6127247",
"0.6090402",
"0.60522664",
"0.60446507",
"0.60446507",
"0.60446507",
"0.60446507",
"0.60446507",
"0.60446507",
"0.60446507",
"0.5935245",
"0.5930106",
"0.59182924",
"0.59044415",
"0.5903834",
"0.5902385",
"0.58909655",
"0.... | 0.7218981 | 0 |
takes pieces etc and produces a fen string | def export_fen
return false if self.pieces.nil?
fen = export_pieces
#add spacer
fen = fen + " "
#export turn
fen = fen + self.turn + " "
#export castling
castle_fen = ""
if self.K
castle_fen += "K"
end
if self.Q
castle_fen += "Q"
end
if self.k
castle_fen += "k"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assemble_to_string\n #put the strings at the end of the assembled code.\n # adding them will fix their position and make them assemble after\n @string_table.values.each do |data|\n add_block data\n end\n io = StringIO.new\n assemble(io)\n io.string\n end",
"def to... | [
"0.6044938",
"0.600004",
"0.58738554",
"0.5834184",
"0.58218706",
"0.58083767",
"0.574348",
"0.57234615",
"0.5722494",
"0.5665819",
"0.56608874",
"0.5655578",
"0.5641128",
"0.5596495",
"0.55767304",
"0.5575087",
"0.55729365",
"0.557064",
"0.5548656",
"0.5548561",
"0.554408",
... | 0.6397208 | 0 |
POST /commits POST /commits.json | def create
@commit = Commit.new
#walker = Rugged::Walker.new(@repo)
#
#walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE) # optional
#
#walker.push('HEAD')
#walker.each { |c|
# @commit = Commit.new(sha: c.oid, description:c.message,
# author: c.author[:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commits!\n response = @client.get_json(\"#{path}/commits\")\n @commits = response.map do |commit| \n Commit.new(client: @client, user: @user, repo: self, sha: commit['sha']) \n end\n @commits\n end",
"def post_commit(commit_obj)\n return if commit_obj.empty?\n uri = URI.pa... | [
"0.7129438",
"0.692928",
"0.6667282",
"0.661749",
"0.661749",
"0.65267205",
"0.648058",
"0.6459393",
"0.64461845",
"0.6378893",
"0.6360087",
"0.63596094",
"0.6335086",
"0.6262909",
"0.622702",
"0.6204889",
"0.6189343",
"0.6126363",
"0.61192375",
"0.61126983",
"0.6096143",
"... | 0.70275056 | 1 |
PATCH/PUT /commits/1 PATCH/PUT /commits/1.json | def update
respond_to do |format|
if @commit.update(commit_params)
format.html { redirect_to @commit, notice: 'Commit was successfully updated.' }
format.json { render :show, status: :ok, location: @commit }
else
format.html { render :edit }
format.json { render json: @co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @pullRequest = PullRequest.find(params[:id])\n\t\t@git = Git.init()\n\t\tDir.chdir(@pullRequest.source_repo.path)\n\t\trequestor_path = \"#{@pullRequest.repository.path}\"\n\t\t@git.pull(requestor_path, \"master\") # fetch and a merge\n\t\t@pullRequest.status = \"ACCEPTED\"\n if @pullRequest.sav... | [
"0.59423614",
"0.58936435",
"0.5873358",
"0.58318347",
"0.58312976",
"0.5828198",
"0.5780742",
"0.576787",
"0.5766743",
"0.5731027",
"0.5677292",
"0.5670451",
"0.5662608",
"0.56450665",
"0.5629505",
"0.5619782",
"0.5618579",
"0.5608497",
"0.5599193",
"0.55808294",
"0.55618834... | 0.60809225 | 0 |
DELETE /commits/1 DELETE /commits/1.json | def destroy
@commit.destroy
respond_to do |format|
format.html { redirect_to commits_url, notice: 'Commit was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def destroy\n @git_datum = GitDatum.find(params[:i... | [
"0.73538727",
"0.6951826",
"0.6874715",
"0.67548215",
"0.666829",
"0.6578867",
"0.6452734",
"0.6422748",
"0.6384015",
"0.6362599",
"0.63399315",
"0.6336113",
"0.631881",
"0.6296479",
"0.62687254",
"0.6243548",
"0.62385786",
"0.6228795",
"0.6210438",
"0.62074685",
"0.61974144"... | 0.7311827 | 1 |
Sends download conf emails. | def send_download_ext_notice
UserMailer.send_download_ext_notice(self).deliver_now
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perform_download_configuration!\n find_nginx!\n if not @nginx_conf\n error \"Could not find the NginX configuration file in #{y(@nginx_conf)}\"\n exit\n end\n \n local_nginx_dir = File.join(local.gitpusshuten_dir, 'nginx')\n FileUtils.mkdir_p(local_ng... | [
"0.6589146",
"0.6388495",
"0.59134704",
"0.58210474",
"0.58070546",
"0.5748769",
"0.5548778",
"0.5530049",
"0.55266654",
"0.5511346",
"0.55097324",
"0.5498599",
"0.5484351",
"0.5474203",
"0.5469221",
"0.5429748",
"0.5413803",
"0.5395602",
"0.53887796",
"0.53763264",
"0.536682... | 0.68905 | 0 |
GET /people/directors GET /people/directors.xml | def directors
@directors = Person.find(:all, :conditions => {:position => ['Director', 'Co-Director']})
@directors.sort! {|a, b| a.last_name.upcase <=> b.last_name.upcase}
respond_to do |format|
format.html # directors.html.erb
format.xml { render :xml => nil }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@people = Person.all\n\t\t# respond_to do |format|\n\t\t# \tformat.xml { send_data @entries.to_xml, :type => 'text/xml; charset=UTF-8;', :disposition => 'attachment; filename=entries.xml'}\n\t\t# end\n\tend",
"def directors\n parse_crew('Directed by')\n end",
"def show\n @people = Peo... | [
"0.6297891",
"0.62439305",
"0.61748576",
"0.6086512",
"0.6069",
"0.60637957",
"0.60330665",
"0.601716",
"0.6003666",
"0.6003666",
"0.6003666",
"0.5987548",
"0.59682745",
"0.5959596",
"0.5955139",
"0.59440094",
"0.59440094",
"0.59038025",
"0.58719695",
"0.5863148",
"0.5863148"... | 0.664801 | 0 |
Scan all the specified +columns+ (e.g., inputs) in the given +data+ row using the +matchers+ array supplied. | def scan_columns(row:, columns:, matchers:)
columns.each_pair do |col, column|
cell = row[col]
# An empty input cell matches everything, and so never needs to be scanned,
# but it cannot be indexed either.
next column.indexed = false if cell == '' && column.ins?
# If the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_cells(&block)\n scan_all(cells_criteria, &block)\n end",
"def args_match(matchers, candidates, match_data = {})\n matchers.each do |m|\n case m.function\n when :'?'\n return false if candidates.empty?\n match_data[m.literal] = candidates.shift... | [
"0.5850372",
"0.51794404",
"0.51012915",
"0.49124563",
"0.47893378",
"0.47383824",
"0.46947217",
"0.4589764",
"0.45809668",
"0.45254475",
"0.44957072",
"0.4489738",
"0.44817352",
"0.44767383",
"0.446303",
"0.44614983",
"0.44499612",
"0.44480214",
"0.44385898",
"0.44319743",
"... | 0.7386918 | 0 |
Match cells in the input hash against a decision table row. | def match?(row:, scan_cols:, hash:)
# Check any table row cell constants first, and maybe fail fast...
return false if @constants.any? { |col| row[col] != scan_cols[col] }
# These table row cells are Proc objects which need evaluating and
# must all return a truthy value.
@procs.all? { |c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rows_matching(hash_or_hashes = nil, &block)\n do_matching(hash_or_hashes, block, :rows_matching)\n end",
"def keys_match?(my_row, other_row)\n\t\t# Ensure arguments are not nil\n\t\tif not (my_row and other_row)\n\t\t\treturn nil\n\t\tend\n\t\t\n\t\t# If each value at this key doesn't match, retu... | [
"0.6271009",
"0.6108417",
"0.6050767",
"0.60193366",
"0.5846295",
"0.57819474",
"0.5686161",
"0.5623731",
"0.5570982",
"0.5475845",
"0.5462771",
"0.54546887",
"0.54193294",
"0.54000384",
"0.53818697",
"0.53402716",
"0.53012836",
"0.52913755",
"0.5283511",
"0.5246104",
"0.5232... | 0.6589555 | 0 |
GET /drop_locations GET /drop_locations.json | def index
@drop_locations = DropLocation.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @drop_locations }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n get('locations')\n end",
"def index\n @dropoff_locations = DropoffLocation.all\n end",
"def show\n @drop_location = DropLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drop_location }\n end\n end",
"... | [
"0.68739635",
"0.685569",
"0.67338943",
"0.6535025",
"0.6534499",
"0.6321508",
"0.6320161",
"0.61726284",
"0.61649567",
"0.61538523",
"0.6137926",
"0.61234784",
"0.60964024",
"0.60866314",
"0.5973597",
"0.5924806",
"0.5911657",
"0.5905655",
"0.58968025",
"0.58962524",
"0.5891... | 0.7287017 | 0 |
GET /drop_locations/1 GET /drop_locations/1.json | def show
@drop_location = DropLocation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @drop_location }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @drop_locations = DropLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drop_locations }\n end\n end",
"def index\n @dropoff_locations = DropoffLocation.all\n end",
"def locations\n get('locations')\n end",
"def destro... | [
"0.74081534",
"0.67133194",
"0.6678223",
"0.65386677",
"0.6309278",
"0.6232413",
"0.6188998",
"0.61780435",
"0.6151882",
"0.6147868",
"0.6118689",
"0.6105524",
"0.61006075",
"0.60996604",
"0.6041308",
"0.6039154",
"0.6018378",
"0.5983217",
"0.5974732",
"0.5954676",
"0.5950841... | 0.7253602 | 1 |
POST /drop_locations POST /drop_locations.json | def create
@drop_location = DropLocation.new(params[:drop_location])
respond_to do |format|
if @drop_location.save
format.html { redirect_to @drop_location, notice: 'Drop location was successfully created.' }
format.json { render json: @drop_location, status: :created, location: @drop_loc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dropped_pins\n\t\tlocation = Location.new\n\t\tlocation.name = params[:locations][:name]\n\t\tlocation.description = \"\"\n\t\tlocation.user_id = @current_user.id\n\t\tlocation.trip_id = params[:locations][:trip_id]\n\t\tlocation.coordinates = [params[:locations][:pin][1].to_f, params[:locations][:pin][0].to_f... | [
"0.68046373",
"0.6427423",
"0.5968979",
"0.5908477",
"0.58539945",
"0.58506113",
"0.57640374",
"0.57637703",
"0.57398134",
"0.5611941",
"0.5585352",
"0.55653334",
"0.55223846",
"0.54880226",
"0.5485753",
"0.546215",
"0.546215",
"0.546215",
"0.546215",
"0.5455403",
"0.5450264"... | 0.68975717 | 0 |
PUT /drop_locations/1 PUT /drop_locations/1.json | def update
@drop_location = DropLocation.find(params[:id])
respond_to do |format|
if @drop_location.update_attributes(params[:drop_location])
format.html { redirect_to @drop_location, notice: 'Drop location was successfully updated.' }
format.json { head :no_content }
else
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @drop_location = DropLocation.find(params[:id])\n @drop_location.destroy\n\n respond_to do |format|\n format.html { redirect_to drop_locations_url }\n format.json { head :no_content }\n end\n end",
"def create\n @drop_location = DropLocation.new(params[:drop_location])\n\n... | [
"0.6509503",
"0.6457471",
"0.62573683",
"0.62131953",
"0.6132024",
"0.60208064",
"0.59154516",
"0.59154093",
"0.5853837",
"0.5767602",
"0.57631934",
"0.5730557",
"0.57277256",
"0.5727658",
"0.5719491",
"0.57069826",
"0.56898457",
"0.56876576",
"0.5680758",
"0.56769747",
"0.56... | 0.67786264 | 0 |
DELETE /drop_locations/1 DELETE /drop_locations/1.json | def destroy
@drop_location = DropLocation.find(params[:id])
@drop_location.destroy
respond_to do |format|
format.html { redirect_to drop_locations_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Location.delete(params[\"id\"])\n end",
"def destroy\n #@items_location = ItemsLocation.find(params[:id])\n #@items_location.destroy\n\n respond_to do |format|\n format.html { redirect_to items_locations_url }\n format.json { head :no_content }\n end\n end",
... | [
"0.712968",
"0.69119483",
"0.68908155",
"0.6802572",
"0.67821765",
"0.677498",
"0.6771083",
"0.6771083",
"0.6771083",
"0.6771083",
"0.67624605",
"0.6749159",
"0.67345077",
"0.6723086",
"0.6722686",
"0.6715709",
"0.6710105",
"0.6696315",
"0.66714746",
"0.6664702",
"0.6664702",... | 0.7390579 | 0 |
Using the Ruby language, have the function PrimeChecker(num) take num and return 1 if any arrangement of num comes out to be a prime number, otherwise return 0. For example: if num is 910, the output should be 1 because 910 can be arranged into 109 or 019, both of which are primes. | def prime_checker(num)
digits = num.to_s.chars
permutations = digits.permutation(digits.size).map { |n| n.join.to_i }.uniq
# permutations.reject! { |num| num.to_s.size < digits.size }
permutations.each do |permutation|
return 1 if prime?(permutation)
end
0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def PrimeChecker(num)\n num = num.to_s.split('')\n perm = num.permutation(num.size).to_a\n perm.each do |p|\n return 1 if is_prime?(p.join.to_i) \n end\n return 0\nend",
"def check_prime? num\n (2..num-1).none? {|n| num % n == 0}\nend",
"def PrimeNumber?(number)\n return false if number<2 || numb... | [
"0.82442105",
"0.7746656",
"0.7710905",
"0.7654206",
"0.7610895",
"0.76044434",
"0.7600713",
"0.76006764",
"0.75839263",
"0.75839263",
"0.75839263",
"0.75753796",
"0.7563665",
"0.7550432",
"0.75445163",
"0.7533821",
"0.75272715",
"0.7520499",
"0.75157315",
"0.7505811",
"0.750... | 0.7831091 | 1 |
The current, global, instance of serializers that is used by all cache instances. | def serializers
@serializers ||= Readthis::Serializers.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serializers_cache\n @serializers_cache ||= Concurrent::Map.new\n end",
"def _serializer(name)\n type = types[name]\n # flatten and cache all the serializers up the tree\n @_serializers ||= all_ancestors(serializers(nil)).reverse.reduce(&:merge)\n @_serializers[name] ||... | [
"0.758843",
"0.68678796",
"0.68246245",
"0.67308766",
"0.6678354",
"0.6436614",
"0.6411437",
"0.6317708",
"0.6272529",
"0.6246979",
"0.6225726",
"0.6225726",
"0.6189636",
"0.61457694",
"0.6070555",
"0.6070555",
"0.6065646",
"0.6058124",
"0.5972666",
"0.59430486",
"0.5899152",... | 0.7471156 | 1 |
Define [] method to allow a Point to look like an array or a hash with keys :x and :y | def [](index)
case index
when 0, -2 then @x # Index 0 (or -2) is the X coordinate
when 1, -1 then @y # Index 1 (or -1) is the Y coordinate
when :x, "x" then @x # Hash keys as symbol or string for X
when :y, "y" then @y # Hash keys as symbol or string for Y
else nil # Arra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](index)\n case index\n when 0, -2; @x # Index 0 (or -2) is the X coordinate\n when 1, -1; @y # Index 1 (or -1) is the Y coordinate\n when :x, \"x\"; @x # Hash keys as symbol or string for X\n when :y, \"y\"; @y # Hash keys as symbol or string for Y\n else nil # Arrays and h... | [
"0.7060302",
"0.70547646",
"0.6955201",
"0.69214255",
"0.65079594",
"0.64917177",
"0.62981737",
"0.62981737",
"0.62954754",
"0.6249788",
"0.6249788",
"0.61904424",
"0.6185929",
"0.61079603",
"0.61079603",
"0.6101962",
"0.6101962",
"0.60607016",
"0.6040181",
"0.5997742",
"0.59... | 0.7205463 | 0 |
Mix in methods from the Comparable module. Define an ordering for points based on their distance from the origin. This method is required by the Comparable module. Enumerable module defines several methods, such as sort, min, and max, that only work if the objects being enumerated define the operator. | def <=>(other)
return nil unless other.instance_of? Point
@x**2 + @y**2 <=> other.x**2 + other.y**2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def <=>(other)\n# Define the <=> operator\nreturn nil unless other.instance_of? Point\nself.x**2 + self.y**2 <=> other.x**2 + other.y**2\nend",
"def <=>(other)\nreturn nil unless other.instance_of? Point\n@x**2 + @y**2 <=> other.x**2 + other.y**2\nend",
"def <=>(other)\n return nil unless other.instance_of?... | [
"0.64739037",
"0.62438184",
"0.619566",
"0.619566",
"0.619566",
"0.60142386",
"0.59701866",
"0.58635646",
"0.5733524",
"0.57041484",
"0.5669824",
"0.5661582",
"0.562955",
"0.5610167",
"0.555984",
"0.55345136",
"0.5526162",
"0.55164677",
"0.5502765",
"0.54968846",
"0.54888165"... | 0.6258633 | 1 |
GET /pod_reports GET /pod_reports.json | def index
@pod_reports = PodReport.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reports\n @node = resource\n @reports = params[:kind] == \"inspect\" ? @node.reports.inspections : @node.reports.applies\n respond_to do |format|\n format.html { @reports = paginate_scope(@reports); render 'reports/index' }\n end\n end",
"def reports\n collection(\"reports\")\n end"... | [
"0.68017316",
"0.66765726",
"0.6624333",
"0.66117203",
"0.6604601",
"0.6602653",
"0.6599188",
"0.6564866",
"0.64812994",
"0.6390798",
"0.6384582",
"0.6372482",
"0.6353572",
"0.6353572",
"0.63490903",
"0.63490903",
"0.63490903",
"0.63490903",
"0.63490903",
"0.63490903",
"0.634... | 0.7997931 | 0 |
DELETE /pod_reports/1 DELETE /pod_reports/1.json | def destroy
@pod_report.destroy
respond_to do |format|
format.html { redirect_to pod_reports_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @report.destroy!\n render json: {status: :ok}\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n format.html { redirect_to reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy\n respond_to do |format|\n ... | [
"0.7289819",
"0.7136006",
"0.71350765",
"0.71350765",
"0.71350765",
"0.71335536",
"0.70007396",
"0.6997417",
"0.6997417",
"0.6997417",
"0.6997417",
"0.69427496",
"0.6898525",
"0.6887893",
"0.6881274",
"0.6871777",
"0.6853628",
"0.685189",
"0.68394244",
"0.68394244",
"0.683942... | 0.8164491 | 0 |
GET /thread_comments/1 GET /thread_comments/1.json | def show
@my_thread = MyThread.find(params[:id])
@thread_comments = @my_thread.thread_comments
respond_to do |format|
format.html # show.html.erb
format.json { render json: @thread_comment }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def show\n @comments = @news_post.comment_threads.order('created_at desc')\n @new_comment = Comment.build_from(@news_post, current_user.id, \"\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :jso... | [
"0.74854267",
"0.6825249",
"0.68196946",
"0.68196946",
"0.6743535",
"0.6696872",
"0.6695752",
"0.6678742",
"0.6588427",
"0.6576655",
"0.6563461",
"0.6540756",
"0.65204656",
"0.6476824",
"0.6466638",
"0.64448416",
"0.64384687",
"0.643589",
"0.643456",
"0.6429015",
"0.64280975"... | 0.78375185 | 0 |
GET /thread_comments/new GET /thread_comments/new.json | def new
@thread_comment = ThreadComment.new
@thread_comment.user = current_user
@thread_comment.organization = current_user.organization
respond_to do |format|
format.html # new.html.erb
format.json { render json: @thread_comment }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n# @task = Task.find(params[:task_id])\n# @task.comments.new(params[:comment]) \n @comment = Comment.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @comment = @posting.comments.new\n\n res... | [
"0.74629724",
"0.7443438",
"0.74163675",
"0.7385642",
"0.73019385",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.72764266",
"0.7276119",
"0.7251273",
"0.72378284",
... | 0.76045495 | 0 |
POST /thread_comments POST /thread_comments.json | def create
@thread_comment = ThreadComment.new(params[:thread_comment])
@thread_comment.user = current_user
@thread_comment.organization = current_user.organization
@thread_comment.my_thread = @my_thread = MyThread.find(params[:my_thread_id])
respond_to do |format|
if @thread_comme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @comment = @post.comments.new(comment_params)\n if @comment.save\n render json: @comment, status: :created\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n\n end",
"def send_comment(data)\n current_user.comments.create!(content: data['comment'], ... | [
"0.6619746",
"0.6613857",
"0.6540742",
"0.65145093",
"0.65080905",
"0.6416517",
"0.6361741",
"0.6361741",
"0.6361741",
"0.63392216",
"0.6333141",
"0.63207793",
"0.631141",
"0.63021964",
"0.6301321",
"0.62970805",
"0.62958235",
"0.6289556",
"0.62760985",
"0.6265861",
"0.626494... | 0.69272184 | 0 |
PUT /thread_comments/1 PUT /thread_comments/1.json | def update
@thread_comment = ThreadComment.find(params[:id])
respond_to do |format|
if @thread_comment.update_attributes(params[:thread_comment])
format.html { redirect_to @thread_comment, notice: 'Thread comment was successfully updated.' }
format.json { head :no_content }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n user = User.find_by({token: env['HTTP_TOKEN']})\n comment = user.comments.find(params[:id])\n comment.update(comment_params)\n render json: comment\n end",
"def update_thread(opts = {})\n JSON.parse(post('update_thread',\n :forum_api_key => opts[:forum... | [
"0.6873614",
"0.6682786",
"0.6581758",
"0.6456209",
"0.64403725",
"0.6429062",
"0.64236456",
"0.6421052",
"0.6327112",
"0.63079286",
"0.6205499",
"0.61874425",
"0.6173449",
"0.61668545",
"0.61668545",
"0.6139495",
"0.6139076",
"0.61314374",
"0.61247104",
"0.6105436",
"0.61024... | 0.71370476 | 0 |
DELETE /thread_comments/1 DELETE /thread_comments/1.json | def destroy
@thread_comment = ThreadComment.find(params[:id])
@thread_comment.destroy
respond_to do |format|
format.html { redirect_to thread_comments_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_comments\n end",
"def delete_comment(id)\n record \"/msg/delete_comment/#{id}\"\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @comment.destroy\n respond_to do |format|\n format.html { ... | [
"0.7178511",
"0.7034761",
"0.6977883",
"0.6945982",
"0.69205934",
"0.69205934",
"0.6890061",
"0.6873823",
"0.6864634",
"0.6803423",
"0.67875534",
"0.67709845",
"0.6767111",
"0.6763743",
"0.67564",
"0.6740407",
"0.6722968",
"0.67183495",
"0.6707982",
"0.6703433",
"0.6697493",
... | 0.7535171 | 0 |
Revokes token with `:refresh_token` equal to `:previous_refresh_token` and clears `:previous_refresh_token` attribute. | def revoke_previous_refresh_token!
return unless self.class.refresh_token_revoked_on_use?
old_refresh_token&.revoke
update(previous_refresh_token: "")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revoke_previous_refresh_token!\n return if !self.class.refresh_token_revoked_on_use? || previous_refresh_token.blank?\n\n old_refresh_token&.revoke\n update_attribute(:previous_refresh_token, \"\")\n end",
"def revoke_refresh_token(refresh__token)\n if isNullOrWhiteSpace(refresh__token... | [
"0.8511802",
"0.74531",
"0.7279126",
"0.7279126",
"0.7067581",
"0.6916054",
"0.6902987",
"0.6846741",
"0.6747648",
"0.66909033",
"0.6643852",
"0.6643312",
"0.6622768",
"0.6614666",
"0.6613164",
"0.6613164",
"0.6591093",
"0.65192163",
"0.65045226",
"0.64986306",
"0.6492259",
... | 0.847895 | 1 |
GET /hour_bank_employees/1 GET /hour_bank_employees/1.json | def show
@hour_bank_employee = HourBankEmployee.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @handbook_place_employees = HandbookPlaceEmployee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @handbook_place_employees }\n end\n end",
"def index\n if request.xhr?\n branch_id = Branch.find_by_id(params[:branch])\n lastn... | [
"0.6680141",
"0.6671914",
"0.6647796",
"0.6557425",
"0.65051484",
"0.6368474",
"0.6348848",
"0.63247305",
"0.62432575",
"0.62065935",
"0.6187933",
"0.61645865",
"0.6161046",
"0.61537343",
"0.61516225",
"0.6139606",
"0.6133954",
"0.611863",
"0.61120945",
"0.6092605",
"0.609102... | 0.6747601 | 0 |
POST /hour_bank_employees POST /hour_bank_employees.json | def create
@hour_bank_employee = HourBankEmployee.new(params[:hour_bank_employee])
respond_to do |format|
if @hour_bank_employee.save
format.html { redirect_to employees_path, notice: 'Hour bank employee was successfully created.' }
format.json { render json: @hour_bank_employees, status:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @employee = Employee.new(params[:employee])\n\n respond_to do |format|\n if @employee.save\n Cutofftotalsalary.create(cutoff_id: Cutoff.last.id, employee_name: @employee.name, sss: @employee.sss, philhealth: @employee.philhealth, pagibig: @employee.pagibig, withholding_tax: @employee... | [
"0.6750594",
"0.5969452",
"0.5958089",
"0.5927073",
"0.59157884",
"0.5913356",
"0.5907649",
"0.58622247",
"0.5844617",
"0.58418816",
"0.5834733",
"0.58347094",
"0.5818802",
"0.5815407",
"0.58110523",
"0.5807202",
"0.5807202",
"0.57853734",
"0.5779136",
"0.57725847",
"0.576434... | 0.71758026 | 0 |
PUT /hour_bank_employees/1 PUT /hour_bank_employees/1.json | def update
@hour_bank_employee = HourBankEmployee.find(params[:id])
respond_to do |format|
if @hour_bank_employee.update_attributes(params[:hour_bank_employee])
format.html { redirect_to employees_path, notice: 'Hour bank employee was successfully updated.' }
format.json { head :no_conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @employee = Employee.find(params[:id])\n\n respond_to do |format|\n if @employee.update_attributes(params[:employee])\n Cutofftotalsalary.find_by_employee_name(@employee.name).update_attributes(cutoff_id: Cutoff.last.id, employee_name: @employee.name, sss: @employee.sss, philhealth: ... | [
"0.6441037",
"0.64130265",
"0.6410798",
"0.6329757",
"0.6238162",
"0.6216062",
"0.6111545",
"0.6094121",
"0.6080494",
"0.6027956",
"0.6027956",
"0.60145855",
"0.59979296",
"0.5987212",
"0.597697",
"0.59288484",
"0.5920263",
"0.5919687",
"0.58917046",
"0.5886599",
"0.5886599",... | 0.6934553 | 0 |
Total number of answered calls within the timeframe | def num_answered_calls
answered_contacts.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answer_count\n return @answers.length if @answers\n \n Factory.count_answers_at_machine(@location)\n end",
"def incoming_made_calls_stats_in_period(period_start, period_end, calldate_index = 0)\n\n total_calls = 0\n calls_price = 0\n\n # this sql is SLOOOOOWWWW on DB with millions of calls... | [
"0.6588773",
"0.6583706",
"0.6549255",
"0.65270823",
"0.6360038",
"0.6321123",
"0.62681895",
"0.62140495",
"0.6184966",
"0.6178854",
"0.6173722",
"0.61465186",
"0.61379373",
"0.6136274",
"0.6113056",
"0.6103839",
"0.6097367",
"0.60585386",
"0.605726",
"0.60238415",
"0.6003979... | 0.7334832 | 0 |
Average call duration in seconds | def average_call_duration
average_duration(finished_contacts, 'answered', 'call_ended')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_missed_call_duration\n average_duration(missed_contacts, 'arrived', 'call_ended')\n end",
"def average_usage\n\t\treturn 0.0 if @run_count.zero?\n\t\t(@total_utime + @total_stime) / @run_count.to_f\n\tend",
"def average_response_time\n (active_time / requests.to_f) * 1000\n end"... | [
"0.75581735",
"0.7555985",
"0.7548626",
"0.7526071",
"0.7074919",
"0.70698035",
"0.7056018",
"0.69821775",
"0.69468397",
"0.670233",
"0.6589239",
"0.6530525",
"0.6492572",
"0.6462304",
"0.6450812",
"0.6436263",
"0.6426042",
"0.6423431",
"0.64192694",
"0.6403241",
"0.6400413",... | 0.82912415 | 0 |
Average after call duration in seconds | def average_after_call_duration
average_duration(closed_contacts, 'call_ended', 'after_call_ended')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_call_duration\n average_duration(finished_contacts, 'answered', 'call_ended')\n end",
"def average_missed_call_duration\n average_duration(missed_contacts, 'arrived', 'call_ended')\n end",
"def average_response_time\n (active_time / requests.to_f) * 1000\n end",
"def avera... | [
"0.8106363",
"0.74651796",
"0.73918",
"0.7346276",
"0.7174746",
"0.7166771",
"0.7099941",
"0.6994778",
"0.6941244",
"0.6905056",
"0.68260676",
"0.67749834",
"0.6766212",
"0.6724175",
"0.67177856",
"0.6666931",
"0.6535644",
"0.6491442",
"0.64467275",
"0.6441523",
"0.64367396",... | 0.7793699 | 1 |
% of calls answered | def answered_percentage
answered = num_answered_calls
missed = num_missed_calls
return 100.0 if (answered + missed) == 0
(answered.to_f / (answered + missed) * 100).round(1)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percent_passes; end",
"def percent_passes; end",
"def number_returned; 0; end",
"def percent_failed\n if recent_calls.count == 0\n 0\n else\n (recent_calls.select(&:failed?).count / recent_calls.count.to_f)\n end\n end",
"def success\n (correct_answers_count*100.0/answers_count).... | [
"0.66689223",
"0.66689223",
"0.6537657",
"0.6509061",
"0.64638674",
"0.62512654",
"0.6232597",
"0.60983956",
"0.6094108",
"0.6083032",
"0.60755616",
"0.60503924",
"0.60503924",
"0.6035693",
"0.6035693",
"0.59770596",
"0.59424835",
"0.5937683",
"0.5928768",
"0.5928768",
"0.588... | 0.67052454 | 0 |
Total number of missed calls within the timeframe | def num_missed_calls
missed_contacts.count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_missed_call_duration\n average_duration(missed_contacts, 'arrived', 'call_ended')\n end",
"def missing_count\n @missing_count ||= current_patient.records.status(Record::MISSING).count\n end",
"def missed_lines\n return 0.0 if empty?\n\n map { |f| f.missed_lines.count }.inject(... | [
"0.69826645",
"0.64639795",
"0.63469905",
"0.61453164",
"0.60978836",
"0.60871017",
"0.6086205",
"0.605435",
"0.6010274",
"0.59163725",
"0.5906459",
"0.5906459",
"0.588035",
"0.5877234",
"0.5864222",
"0.5864222",
"0.5853958",
"0.58437467",
"0.58304864",
"0.5823169",
"0.581153... | 0.7555177 | 0 |
Average duration missed calls waited in the queue | def average_missed_call_duration
average_duration(missed_contacts, 'arrived', 'call_ended')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_queue_duration\n average_duration(answered_contacts, 'arrived', 'forwarded_to_agent')\n end",
"def average_call_duration\n average_duration(finished_contacts, 'answered', 'call_ended')\n end",
"def waitTime()\n time = Time.now().to_i / 60\n\n # Cleanup once every ten minutes\n ... | [
"0.71899617",
"0.64527303",
"0.63179326",
"0.6251465",
"0.6251465",
"0.6138772",
"0.6129388",
"0.60440457",
"0.60422915",
"0.6012206",
"0.59924",
"0.5964912",
"0.59627175",
"0.59350854",
"0.59235907",
"0.59235907",
"0.5921256",
"0.5921256",
"0.58992714",
"0.5857888",
"0.58505... | 0.6477889 | 1 |
Average duration answered calls waited in the queue, including calls which did not have to wait in queue at all | def average_queue_duration
average_duration(answered_contacts, 'arrived', 'forwarded_to_agent')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_call_duration\n average_duration(finished_contacts, 'answered', 'call_ended')\n end",
"def num_waiting\n @waiting.size + @queue_wait.size\n end",
"def num_waiting\n @waiting.size + @queue_wait.size\n end",
"def average_wait_time\n self.reviews.average(:wait_time).to_i\n end",
"d... | [
"0.6728452",
"0.6521867",
"0.6521867",
"0.61024976",
"0.6060583",
"0.6055224",
"0.605257",
"0.60413784",
"0.6040993",
"0.6034457",
"0.6034457",
"0.5977288",
"0.59410244",
"0.5912961",
"0.58821946",
"0.5864909",
"0.5864909",
"0.58236504",
"0.57797194",
"0.5759588",
"0.5754969"... | 0.7434959 | 0 |
Returns an array of length 24 where each index corresponds to the hour of the day, and value of each index to the average queue duration, in seconds, during that hour | def average_queue_duration_by_hour
gmt_offset = Time.now.getlocal.gmt_offset
select = [
"EXTRACT(HOUR FROM contacts.arrived + '#{gmt_offset} seconds') AS hour",
'AVG(EXTRACT(EPOCH FROM contacts.forwarded_to_agent - contacts.arrived)) AS avg_duration'
].join(',')
data = answered_contacts.sele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hourly_totals(emoji)\n hour_zero = self.last_hour.where(emoji: emoji).pluck(:created_at).size\n hour_one = self.last_hour_plus_one.where(emoji: emoji).pluck(:created_at).size\n hour_two = self.last_hour_plus_two.where(emoji: emoji).pluck(:created_at).size\n hour_three = self.last_hour_plus_... | [
"0.6274891",
"0.62397957",
"0.59632075",
"0.59052026",
"0.58921856",
"0.5867287",
"0.5827379",
"0.5764461",
"0.5729414",
"0.5725073",
"0.56930804",
"0.56824696",
"0.56606287",
"0.5658396",
"0.5597903",
"0.5571507",
"0.55667377",
"0.5528027",
"0.55272853",
"0.55204856",
"0.550... | 0.7834474 | 0 |
Returns an array of length 24 where each index corresponds to the hour of the day, and the values to the number of calls during that hour | def calls_by_hour
gmt_offset = Time.now.getlocal.gmt_offset
select = "EXTRACT(HOUR FROM contacts.arrived + '#{gmt_offset} seconds') AS hour, COUNT(*) AS count"
data = answered_contacts.select(select).group('hour')
result = Array.new(24, 0)
data.each { |d| result[(d['hour'])] = d['count'] }
resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end",
"def hourly_totals(emoji)\n hour... | [
"0.66016304",
"0.64709985",
"0.6353113",
"0.6249751",
"0.6249654",
"0.6248767",
"0.62330693",
"0.61604375",
"0.6141548",
"0.6100363",
"0.60449994",
"0.601262",
"0.59833145",
"0.592039",
"0.5895062",
"0.5829081",
"0.5821465",
"0.57843196",
"0.577205",
"0.57259846",
"0.57236975... | 0.7772784 | 0 |
Returns the percentage of calls that were answered within the specified time limit | def service_level_agreement_percentage(time_limit)
all = num_answered_calls + num_missed_calls
return 100.0 if all == 0
answered_in_time = answered_contacts.select("EXTRACT(EPOCH FROM contacts.answered - contacts.arrived) AS duration")
.select { |c| c if c['duration']... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answered_percentage\n answered = num_answered_calls\n missed = num_missed_calls\n return 100.0 if (answered + missed) == 0\n (answered.to_f / (answered + missed) * 100).round(1)\n end",
"def wait_time\n if rate_limit_remaining < 50\n [rate_limit_reset - Time.zone.now, 0.001].sort.last\n ... | [
"0.64262605",
"0.6220543",
"0.6203604",
"0.6122557",
"0.6027333",
"0.59363323",
"0.5872493",
"0.584182",
"0.57439643",
"0.57439643",
"0.5729087",
"0.57239276",
"0.565824",
"0.56108797",
"0.56061995",
"0.56003356",
"0.5579719",
"0.5575034",
"0.5536187",
"0.5503028",
"0.546958"... | 0.7753194 | 0 |
Contacts waiting in queue to be answered | def queue_contacts
@contacts.where(contact_type: 'PBX', direction: 'I', forwarded_to_agent: nil, call_ended: nil).where.not(service_id: 120)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_queue(conn)\r\n # if there are elements in queue, send first of them\r\n if @queue[conn.user.id] && !@queue[conn.user.id].empty?\r\n send_act(conn, @queue[conn.user.id].first)\r\n else\r\n # else add user to waiting list\r\n @waiting[conn.user.id] = conn\r\n end\r\n end",
"d... | [
"0.64325565",
"0.63352656",
"0.6217203",
"0.6108993",
"0.6108993",
"0.594537",
"0.58729935",
"0.5820963",
"0.5764964",
"0.57553107",
"0.56926715",
"0.56810683",
"0.56810576",
"0.56787753",
"0.56787753",
"0.56726855",
"0.5672463",
"0.56648934",
"0.56500393",
"0.56390697",
"0.5... | 0.71270734 | 0 |
Contacts that have finished, but after call may still be ongoing | def finished_contacts
@contacts.where(contact_type: 'PBX').where.not(answered: nil, call_ended: nil, service_id: 120)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_contacts\n @contacts.where(contact_type: 'PBX', direction: 'I', forwarded_to_agent: nil, call_ended: nil).where.not(service_id: 120)\n end",
"def connection_completed\n end",
"def finished\n @finished = true\n end",
"def finished; end",
"def on_message_complete\n ... | [
"0.6406766",
"0.6190308",
"0.6148203",
"0.60985243",
"0.6009472",
"0.5995321",
"0.5993519",
"0.5982614",
"0.598064",
"0.59694463",
"0.59676814",
"0.5920267",
"0.5890844",
"0.58873475",
"0.5859444",
"0.5846296",
"0.5834664",
"0.5796941",
"0.578079",
"0.5779494",
"0.5778113",
... | 0.767017 | 0 |
Contacts that have been answered(and hence won't be missed contacts for sure), but may still be ongoing | def answered_contacts
@contacts.where(contact_type: 'PBX').where.not(answered: nil, service_id: 120)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished_contacts\n @contacts.where(contact_type: 'PBX').where.not(answered: nil, call_ended: nil, service_id: 120)\n end",
"def missed_contacts\n @contacts.where(contact_type: 'PBX', answered: nil, after_call_ended: nil, direction: 'I').where.not(call_ended: nil, service_id: 120)\n end",
"def queu... | [
"0.7706743",
"0.677557",
"0.6603339",
"0.63920486",
"0.6239981",
"0.6073713",
"0.58688056",
"0.58157396",
"0.57335603",
"0.5717744",
"0.5715859",
"0.57124877",
"0.5690616",
"0.56881356",
"0.5666713",
"0.5659357",
"0.562885",
"0.56261235",
"0.5621278",
"0.56118417",
"0.5609746... | 0.71199477 | 1 |
Contacts that have been missed for certain | def missed_contacts
@contacts.where(contact_type: 'PBX', answered: nil, after_call_ended: nil, direction: 'I').where.not(call_ended: nil, service_id: 120)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished_contacts\n @contacts.where(contact_type: 'PBX').where.not(answered: nil, call_ended: nil, service_id: 120)\n end",
"def num_missed_calls\n missed_contacts.count\n end",
"def failed_email_delivery_contacts\n \n failed_email_delivery_contacts = Array.new \n \n mailout_contacts.each... | [
"0.7121931",
"0.68587637",
"0.6826735",
"0.66599274",
"0.621697",
"0.5949067",
"0.5916735",
"0.5804479",
"0.57103264",
"0.56981635",
"0.5671661",
"0.5660888",
"0.5646338",
"0.563241",
"0.5597064",
"0.5577264",
"0.5567965",
"0.55453074",
"0.55059576",
"0.55059576",
"0.55054444... | 0.81307936 | 0 |
Returns the average duration, in seconds, between the two specified fields in the specified set of contacts Field names should correspond to column names in the Contacts table (ie. start_field could be answered, end_field call_ended to calculate the average duration of when a call is answered to when the call ends) | def average_duration(contacts, period_start_field, period_end_field)
contacts.select("ROUND(AVG(EXTRACT(EPOCH FROM contacts.#{period_end_field}- contacts.#{period_start_field}))) AS avg")[0]['avg'] || 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def average_call_duration\n average_duration(finished_contacts, 'answered', 'call_ended')\n end",
"def average_after_call_duration\n average_duration(closed_contacts, 'call_ended', 'after_call_ended')\n end",
"def average_missed_call_duration\n average_duration(missed_contacts, 'arrived', 'call_ende... | [
"0.74842554",
"0.67890567",
"0.6769005",
"0.6420277",
"0.6184753",
"0.5679092",
"0.5570275",
"0.5210534",
"0.50542146",
"0.49685472",
"0.4846552",
"0.4763005",
"0.47400117",
"0.46972784",
"0.46767804",
"0.4652143",
"0.46510684",
"0.4629451",
"0.46288452",
"0.4623154",
"0.4588... | 0.76788396 | 0 |
This only knows how to output arfs with true/false classes and all numeric attributes. Additionally, every row must have the same attributes. | def output_numeric_arff(io)
keys = features.first.keys
io.puts "@RELATION Data"
keys.each do |key|
io.puts "@ATTRIBUTE #{key} NUMERIC" unless key == :class
end
io.puts "@ATTRIBUTE class {false,true}"
io.puts "@DATA"
features.each do |feature|
io.puts keys.map { ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_format_boolean(object, attr)\n if object.send(attr) then \"Yes\" else \"No\" end\n end",
"def get_attributes(row, given_attrs)\n given_attrs.collect do |x|\n row[x] = serialized_attributes[x].dump(row[x]) if @serialized_attributes_keys.include? x\n row[x]\n ... | [
"0.5416942",
"0.5248495",
"0.51739824",
"0.5154203",
"0.5144566",
"0.5045046",
"0.5030678",
"0.50104845",
"0.4995054",
"0.49916247",
"0.49825874",
"0.4970521",
"0.49651545",
"0.49306208",
"0.48812956",
"0.4863226",
"0.4826243",
"0.4823023",
"0.4814763",
"0.4760833",
"0.476081... | 0.6706417 | 0 |
is a smart method to invoke the effect operation `Async.async` . | def async(th)
@eff.async.perform th
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def async()\n merge(async: 'true')\n end",
"def async(&block)\n @async = block if block_given?\n @async\n end",
"def call_async(method, *args)\n require 'celluloid'\n return Celluloid::Future.new{ send_request(method, args) }\n end",
"def async_call(path, m, *args,... | [
"0.69885004",
"0.6939162",
"0.67586327",
"0.6706935",
"0.668026",
"0.66742027",
"0.6646549",
"0.65954804",
"0.6544478",
"0.6408454",
"0.6403081",
"0.63450485",
"0.6341262",
"0.6337879",
"0.63317555",
"0.6305129",
"0.62958723",
"0.6255014",
"0.625488",
"0.6170659",
"0.6166713"... | 0.73399913 | 0 |
is a smart method to invoke the effect operation `Async.yield` . | def yield
@eff.yield.perform
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yield t = 0\n\n @@_Sleeper ||= Class.new do\n include Dramatis::Actor\n def nap t\n sleep t\n end\n end\n \n if t > 0\n sleeper = @@_Sleeper.new\n ( Dramatis.interface( sleeper ).\n continue :continuation => :rpc,\n :nonblocking => true... | [
"0.6949866",
"0.68601274",
"0.673186",
"0.6643473",
"0.6643473",
"0.66422564",
"0.6630049",
"0.65575814",
"0.65463597",
"0.6517257",
"0.65079755",
"0.65011835",
"0.6474871",
"0.646073",
"0.64491415",
"0.6441003",
"0.64302385",
"0.6428885",
"0.6411741",
"0.6409571",
"0.6409571... | 0.6985539 | 0 |
is a smart method to invoke the effect operation `Async.await` . | def await(p)
@eff.await.perform p
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def async(th)\n @eff.async.perform th\n end",
"def future; end",
"def call_async(method, *args)\n require 'celluloid'\n return Celluloid::Future.new{ send_request(method, args) }\n end",
"def async_result()\n #This is a stub, used for indexing\n end",
"def async... | [
"0.6809594",
"0.6153026",
"0.6105974",
"0.6028155",
"0.60253423",
"0.59929156",
"0.5930864",
"0.59240735",
"0.58829397",
"0.5875321",
"0.5838386",
"0.5731326",
"0.5722273",
"0.57170427",
"0.56896496",
"0.5676019",
"0.56565773",
"0.56454206",
"0.5630444",
"0.56070673",
"0.5556... | 0.7270808 | 0 |
allows rails to use this existing radiant layout by name | def set_radiant_layout
@radiant_layout = "Default Layout"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _layout_for(name = nil)\n name ||= :layout\n view_flow.get(name).html_safe\n end",
"def set_radiant_layout\n @content_for_header_content = header_content_for_page('diagnostics')\n @content_for_body_class = body_class_for_page('diagnostics')\n @content_for_title_tag = title_tag_for... | [
"0.6735514",
"0.67326885",
"0.661426",
"0.65511507",
"0.6490821",
"0.6456864",
"0.6429904",
"0.6426414",
"0.6346706",
"0.63384014",
"0.6322082",
"0.6292875",
"0.627912",
"0.6194076",
"0.6174488",
"0.61690265",
"0.61637396",
"0.61557704",
"0.6131349",
"0.6131349",
"0.60803235"... | 0.719383 | 0 |
Create an inbox replier Create a new inbox rule for reply toing, blocking, and allowing emails when sending and receiving | def create_new_inbox_replier(create_inbox_replier_options, opts = {})
data, _status_code, _headers = create_new_inbox_replier_with_http_info(create_inbox_replier_options, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_inbox_replies\n client.post('/api/sendreplies', id: read_attribute(:name), state: true)\n end",
"def reply\n message = self.class.new(:subject => subject, :body => body)\n message.sender = sender\n message.to(to)\n message\n end",
"def reply\n message = self.message.class... | [
"0.6315891",
"0.589901",
"0.5882185",
"0.5854074",
"0.58081293",
"0.58015287",
"0.57967126",
"0.5791844",
"0.5739557",
"0.56733805",
"0.5669741",
"0.5661322",
"0.5569907",
"0.55316454",
"0.54142165",
"0.5409611",
"0.53881687",
"0.53811306",
"0.5363316",
"0.53499883",
"0.53488... | 0.59454036 | 1 |
Delete an inbox replier Delete inbox replier | def delete_inbox_replier(id, opts = {})
delete_inbox_replier_with_http_info(id, opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @inbox.destroy\n end",
"def delete\n self.class.call('domain.mailbox.delete', @domain.fqdn, @login)\n end",
"def delMail(imap, folder)\n pp \"Emptying #{folder}..\"\n message_ids = imap.uid_search(\"ALL\")\n imap.uid_store(message_ids, \"+FLAGS\", [:Deleted])\n imap.ex... | [
"0.7440216",
"0.69697064",
"0.69115025",
"0.6743412",
"0.6743412",
"0.665895",
"0.6654331",
"0.66389745",
"0.6638676",
"0.6585729",
"0.65072995",
"0.6498291",
"0.6480048",
"0.64766693",
"0.64756143",
"0.6436689",
"0.6413424",
"0.64027244",
"0.63991153",
"0.63881034",
"0.63789... | 0.7167064 | 1 |
Delete inbox repliers Delete inbox repliers. Accepts optional inboxId filter. | def delete_inbox_repliers(opts = {})
delete_inbox_repliers_with_http_info(opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_inbox_replier(id, opts = {})\n delete_inbox_replier_with_http_info(id, opts)\n nil\n end",
"def delete_inbox_repliers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxReplierControllerApi.delete_inbox_repliers ...... | [
"0.66383404",
"0.65294564",
"0.5771031",
"0.55758494",
"0.5427504",
"0.5339469",
"0.5325586",
"0.5285358",
"0.52763665",
"0.52567255",
"0.52551186",
"0.522713",
"0.52220803",
"0.5221166",
"0.51795197",
"0.51758534",
"0.51734924",
"0.51635396",
"0.51263034",
"0.51225036",
"0.5... | 0.79214615 | 0 |
Get an inbox replier event list Get inbox ruleset events | def get_inbox_replier_events(id, opts = {})
data, _status_code, _headers = get_inbox_replier_events_with_http_info(id, opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_list\n events_list\n end",
"def event_list\n @_events\n end",
"def fGetSubscribedEventsFrom(email)\n @users.getSubscribedEventsFrom(email)\n end",
"def get_events\n Resources::Event.parse(request(:get, \"Events\"))\n end",
"def listOfSubscribedEvents (bookieEmail)\r... | [
"0.6024881",
"0.60210675",
"0.598806",
"0.59736395",
"0.5888773",
"0.5888692",
"0.58782476",
"0.58304834",
"0.582835",
"0.5805834",
"0.5766437",
"0.576142",
"0.5744145",
"0.5734585",
"0.57107496",
"0.56941247",
"0.56747353",
"0.5672956",
"0.5627412",
"0.55800766",
"0.55800766... | 0.6184279 | 0 |
List inbox repliers List all repliers attached to an inbox | def get_inbox_repliers(opts = {})
data, _status_code, _headers = get_inbox_repliers_with_http_info(opts)
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @client.call(method: :get, path: 'recipient-lists')\n end",
"def delete_inbox_repliers(opts = {})\n delete_inbox_repliers_with_http_info(opts)\n nil\n end",
"def get_inbox_repliers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.l... | [
"0.5874673",
"0.5731007",
"0.5667305",
"0.54743963",
"0.540082",
"0.5389364",
"0.53811365",
"0.5363898",
"0.53619385",
"0.53444844",
"0.52880526",
"0.5271771",
"0.52622604",
"0.52564824",
"0.525351",
"0.5248221",
"0.52314436",
"0.5209888",
"0.51839423",
"0.5180412",
"0.518041... | 0.72574466 | 0 |
GET /user_attachments GET /user_attachments.json | def index
@user_attachments = UserAttachment.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_email_attachments\n\t\tresp = @resp\n\n\t\tparams[\"email\"] ||= \"\"\n\t\tparams[\"password\"] ||= \"\"\n\n\t\t# Authorize and process attachments in mail account\n\t\tresp = Resume.gmail_attachments(resp, params)\n\n\t\trender :json => resp\n end",
"def attachments(message_id, params = {})\n @a... | [
"0.7167259",
"0.66788316",
"0.6667084",
"0.66433126",
"0.6610999",
"0.6610999",
"0.65874434",
"0.658719",
"0.6544464",
"0.6524932",
"0.6454431",
"0.64295363",
"0.64263964",
"0.6403681",
"0.6390946",
"0.6365857",
"0.63657063",
"0.634736",
"0.634736",
"0.634736",
"0.634736",
... | 0.7556563 | 0 |
PATCH/PUT /user_attachments/1 PATCH/PUT /user_attachments/1.json | def update
respond_to do |format|
if @user_attachment.update(user_attachment_params)
format.html { redirect_to @user_attachment, notice: 'User attachment was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json {... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def update!(**args)\n @attachments = args[:attachments] if args.key?(:attachments)\n end",
"def update\n respond_to do |format|\n if @document.update(document_params)\n if ... | [
"0.674126",
"0.674126",
"0.6719494",
"0.6633693",
"0.6603617",
"0.659649",
"0.654493",
"0.65402746",
"0.65155536",
"0.64894265",
"0.6483923",
"0.6483923",
"0.6465326",
"0.6402814",
"0.6363314",
"0.6323101",
"0.6313152",
"0.6311552",
"0.6310578",
"0.62742203",
"0.6259241",
"... | 0.71855736 | 0 |
DELETE /user_attachments/1 DELETE /user_attachments/1.json | def destroy
@user_attachment.destroy
respond_to do |format|
format.html {
flash[:notice] = 'Your image was successfully deleted.'
redirect_to :back
}
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @attachments = Attachment.find_by_id(params[:id])\n if @attachments.present?\n @attachments.destroy\n render :json=>{:response=>\"success\"}\n\t\tend\n end",
"def destroy\n @attachment = Attachment.find_by_name(params[:id])\n @attachment.destroy\n\n respond_to do |format|\... | [
"0.74116224",
"0.7400218",
"0.7299063",
"0.72894055",
"0.72894055",
"0.72894055",
"0.7167034",
"0.7162645",
"0.7137204",
"0.7136495",
"0.7041996",
"0.70417094",
"0.7032696",
"0.7014603",
"0.7007591",
"0.6994823",
"0.6984737",
"0.69719505",
"0.6958894",
"0.69247717",
"0.692477... | 0.75383335 | 0 |
List all contents allowed for sn | def list_for(sn)
ret = get("/?sn=#{sn}")
return [] if ret.kind_of?(Hash)
ret.lines.map{|i|i.chomp}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_deny_list(src)\n deny_list = Array.new\n text = File.open(src).read\n text.gsub!(/\\r\\n?/, \"\\n\")\n text.each_line do |deny_keyword|\n deny_list.push(deny_keyword.gsub(/\\s+/, ''))\n end\n deny_list\n end",
"def content_type_denylist\n end",... | [
"0.6107427",
"0.6068912",
"0.60687494",
"0.6009014",
"0.5984227",
"0.5942553",
"0.5780876",
"0.57476044",
"0.5736609",
"0.5559866",
"0.5527895",
"0.55124354",
"0.5482874",
"0.5461173",
"0.54462826",
"0.54458034",
"0.5398291",
"0.5398291",
"0.5398291",
"0.53891706",
"0.5375742... | 0.6447539 | 0 |
Create a buildnotes skeleton | def create_note
trap('SIGINT') do
warn "\nCanceled"
exit!
end
# First make sure there isn't already a buildnotes file
filename = find_note_file
if filename
system 'stty cbreak'
fname = "\e[1;33m#{filename}\e[1;37m"
yn = color_single_options(%w[y N])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_notes\n end",
"def construct_all_the_notes\n # All the release note text\n release_notes = process_repos\n\n build_frontmatter\n\n [\n @frontmatter, '---', \"\\n\",\n headfoot(@header), \"\\n\\n\",\n release_notes.join(\"\\n\\n\"),\n headfoot(@footer), \"\\n\",\n @footer_locations.... | [
"0.70904064",
"0.68983334",
"0.6671644",
"0.65966564",
"0.6576176",
"0.6261841",
"0.61820674",
"0.6179286",
"0.6077091",
"0.5981446",
"0.59604514",
"0.59604514",
"0.59604514",
"0.5923967",
"0.5906701",
"0.58263004",
"0.5823351",
"0.5817852",
"0.5816491",
"0.5789082",
"0.57637... | 0.7421023 | 0 |
Output a list of topic titles | def list_topics
output = []
output.push("\e[1;32mTopics:\e[0m\n")
topics.each_key do |title|
output.push("- \e[1;37m#{title}\e[0m")
end
output.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_topic_titles\n topics.keys.join(\"\\n\")\n end",
"def list_topics\n outputter.print_topics(guides.keys)\n 0\n end",
"def topics\n topics = [\"News\", \"A.I.\", \"V.R.\", \"RMIT\", \"Game\", \"Rails\", \"Go\", \"Web\", \"M.L\", \"Joke\", \"React\", \"Vue\", \"Node\", \"iOS\", \"... | [
"0.82453716",
"0.7140254",
"0.68312234",
"0.68298054",
"0.67177683",
"0.65748715",
"0.65650046",
"0.64865094",
"0.6459431",
"0.63934815",
"0.6341335",
"0.63253874",
"0.62566984",
"0.6198361",
"0.61982006",
"0.6163745",
"0.6101705",
"0.6089851",
"0.60857815",
"0.6043803",
"0.6... | 0.8047624 | 1 |
Output a list of topic titles for shell completion | def list_topic_titles
topics.keys.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_topics\n output = []\n output.push(\"\\e[1;32mTopics:\\e[0m\\n\")\n topics.each_key do |title|\n output.push(\"- \\e[1;37m#{title}\\e[0m\")\n end\n output.join(\"\\n\")\n end",
"def list_topics\n\tputs \"1. Social Media\"\n\tputs \"2. Tech\"\n\tputs \"3. Business\"\n\t... | [
"0.7434334",
"0.68344116",
"0.67759764",
"0.6376482",
"0.6254279",
"0.62229896",
"0.6014731",
"0.5992916",
"0.5968363",
"0.591589",
"0.5905288",
"0.5863261",
"0.583281",
"0.58306915",
"0.5813457",
"0.5809981",
"0.57915014",
"0.57762223",
"0.5775547",
"0.5771449",
"0.5766349",... | 0.7223046 | 1 |
Read in the build notes file and output a hash of "Title" => contents | def read_help
filename = find_note_file
help = IO.read(filename)
topics_dict = {}
split = help.split(/^##+/)
split.slice!(0)
split.each do |sect|
next if sect.strip.empty?
lines = sect.split(/\n/)
title = lines.slice!(0).strip
topics_dict[title] = lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_all_the_notes\n # All the release note text\n release_notes = process_repos\n\n build_frontmatter\n\n [\n @frontmatter, '---', \"\\n\",\n headfoot(@header), \"\\n\\n\",\n release_notes.join(\"\\n\\n\"),\n headfoot(@footer), \"\\n\",\n @footer_locations.join(\"\\n\"), \"\\n\\n\",\n ... | [
"0.6404509",
"0.6385553",
"0.6212773",
"0.6141824",
"0.6029667",
"0.5918639",
"0.5835565",
"0.5814812",
"0.57602465",
"0.57045215",
"0.5689383",
"0.5661153",
"0.56503546",
"0.564602",
"0.5607463",
"0.5586213",
"0.5585213",
"0.5564522",
"0.5543646",
"0.554162",
"0.5537586",
... | 0.649643 | 0 |
Same as uses_extension? Checks to see if the provided URL is in the list of service types. Example that checks for support of the simple registratino protocol: service.supports?(' | def supports?(url)
return @service_types.member?(url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_supported?(url)\n @@supported_services.include? URI.parse(url).host.downcase\n end",
"def known_service? url\n !!service_endpoint(url)\n end",
"def supports?(type)\n supported.include? type.to_sym\n end",
"def has_protocol?(url)\n url.start_with?('http://') || url.s... | [
"0.79054433",
"0.73626953",
"0.65499187",
"0.6295217",
"0.62545866",
"0.62204456",
"0.62203187",
"0.61646193",
"0.60759026",
"0.6016665",
"0.596869",
"0.59597063",
"0.59195316",
"0.58983487",
"0.5887999",
"0.5885652",
"0.58775073",
"0.5863821",
"0.5818959",
"0.58080316",
"0.5... | 0.8619127 | 0 |
Returns the OpenID server endpoint URL. | def server_url
@uri
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openid_callback_url\n \"#{request.protocol}://#{request.host}#{Merb::Router.url(:openid)}\"\n end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end",
"def endpoint_url\n # @@api_base + @request.en... | [
"0.7287462",
"0.72060555",
"0.7168388",
"0.7129921",
"0.71148217",
"0.70991886",
"0.7080081",
"0.70476705",
"0.70153975",
"0.7008752",
"0.7006965",
"0.69737065",
"0.69134194",
"0.69085896",
"0.68290377",
"0.6789621",
"0.67788535",
"0.67589134",
"0.671896",
"0.671896",
"0.6718... | 0.7359681 | 0 |
Taking an object, return true if its string representation is the same as that of the current node. | def ==(obj)
self.to_s == obj.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(obj)\n to_s == obj.to_s\n end",
"def ==(obj)\n obj == text\n end",
"def eql?(obj_)\n if obj_.kind_of?(::String)\n obj_ = @_format.parse(obj_) rescue nil\n end\n return false unless obj_.kind_of?(Value)\n index_ = 0\n obj_.each_field_object do |field_, value_|\... | [
"0.73187506",
"0.6938839",
"0.6901013",
"0.68867034",
"0.67221403",
"0.66570705",
"0.66084856",
"0.6589791",
"0.65785646",
"0.656343",
"0.652317",
"0.6520474",
"0.6448585",
"0.6438864",
"0.634995",
"0.63466585",
"0.63334095",
"0.63246614",
"0.6316667",
"0.6291877",
"0.6278418... | 0.72629654 | 1 |
Take a collection of nonterminal (ie functional) node classes, terminal node classes, and an optional depth limit. Until the current node has enough children to be valid, recursively generate random program trees within the depth limit and reference them as children of the current node. This will not overright any exis... | def populate_kids(functions, terminals, depth_limit = nil)
if !depth_limit || depth_limit > 2
programs = functions + terminals
elsif depth_limit == 2
programs = terminals
end
# the index must be one less than ordinality, ie arr[0] is 1st, arr[2] is 3rd
for i in 0..(self.valid_kid_ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_children\n\n return unless @CMAX && @CMAX > 0\n\n num_children = rand(@CMAX)\n num_children.times do\n # Pick a child type, options and preposition\n type = choose(@CTPS.keys)\n options = @CTPS[type]\n options[:prep] = choose(@CPRP[type]... | [
"0.6216413",
"0.59589773",
"0.59161687",
"0.55173415",
"0.55013347",
"0.5476642",
"0.5421474",
"0.53861696",
"0.5352757",
"0.5325903",
"0.530537",
"0.5302936",
"0.52548397",
"0.52192825",
"0.5145614",
"0.5145097",
"0.51450205",
"0.5143505",
"0.5138081",
"0.51375103",
"0.51048... | 0.6359854 | 0 |
Taking all the node descendant from the current one, return a random one. | def random_node
self.to_a.random
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_node\n select_node = nil\n create_random_list(10)\n current_node = head\n # Select a random node from the list to delete just that node.\n (rand(8)+1).times do \n current_node = current_node.next\n break if current_node == nil\n end\n select_node = current_node\n re... | [
"0.6818305",
"0.6581545",
"0.6512868",
"0.63374925",
"0.6182498",
"0.6172278",
"0.60941684",
"0.6092612",
"0.59745723",
"0.59666634",
"0.5935566",
"0.5916916",
"0.59100276",
"0.58806163",
"0.5860548",
"0.5841454",
"0.5841454",
"0.5841454",
"0.5841454",
"0.5809689",
"0.5774898... | 0.7818297 | 0 |
Take a collection of nonterminal (ie functional) node classes, terminal node classes, and an optional depth limit. Clone the current node and remove a single node in its tree, possibly including itself. Recursively generate a random program tree within the depth limit and reference them in replacement of the removed no... | def mutate(functions = Functions, terminals = Terminals, depth = nil)
new_tree = self.clone
node = new_tree.to_a.random
if node.root?
new_tree = Program.generate(functions, terminals, depth)
else
node.parent.kids.delete node
new_tree.populate_kids(functions, terminals, depth)
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune\n # prune trees that aren't duped at all, or are too small\n self.hashes.delete_if { |_,nodes| nodes.size == 1 }\n self.hashes.delete_if { |_,nodes| nodes.all?(&:modified?) }\n\n if option[:liberal] then\n prune_liberally\n else\n prune_conservatively\n end\n end",
"def str... | [
"0.58460385",
"0.54524744",
"0.5341221",
"0.5304798",
"0.52626455",
"0.52570546",
"0.5189912",
"0.5131307",
"0.50980544",
"0.50947005",
"0.5067959",
"0.4821722",
"0.4808763",
"0.4806211",
"0.47877523",
"0.47729623",
"0.4770732",
"0.47680098",
"0.47671428",
"0.476092",
"0.4752... | 0.68397534 | 0 |
Taking two nodes, swap each's parent's reference to it with the other | def swap_parents_references_to_nodes(first_node, second_node)
# store a reference to the second's parent while it is overwritten
temp_parent = second_node.parent
swap_parent_reference_to_node(first_node.parent, first_node, second_node)
swap_parent_reference_to_node(temp_parent, second_node, first_node)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_nodes_references_to_parents(first_node, second_node)\n # no need to worry about nil references, it just works\n first_node.parent, second_node.parent = [second_node.parent, first_node.parent]\n end",
"def swap_parent_reference_to_node(parent, first_node, second_node)\n unless parent.nil?\n ... | [
"0.8880677",
"0.85165757",
"0.7438643",
"0.71823126",
"0.71087927",
"0.71087927",
"0.66594124",
"0.66558135",
"0.6631515",
"0.6593813",
"0.65695405",
"0.65621406",
"0.655074",
"0.655074",
"0.65408695",
"0.65310043",
"0.64378196",
"0.642923",
"0.6383926",
"0.6365766",
"0.63517... | 0.858102 | 1 |
Taking parent and two nodes, swap the parent's reference from the first node to the second node, unless the first node has no parent | def swap_parent_reference_to_node(parent, first_node, second_node)
unless parent.nil?
kids = parent.kids
index = kids.index first_node
kids[index] = second_node
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_nodes_references_to_parents(first_node, second_node)\n # no need to worry about nil references, it just works\n first_node.parent, second_node.parent = [second_node.parent, first_node.parent]\n end",
"def swap_parents_references_to_nodes(first_node, second_node)\n # store a reference to the se... | [
"0.87751985",
"0.84239286",
"0.7055348",
"0.6914278",
"0.6833777",
"0.67778456",
"0.67686313",
"0.6694673",
"0.6694673",
"0.66850483",
"0.65650874",
"0.6562362",
"0.6449583",
"0.6449583",
"0.64192694",
"0.63909817",
"0.6381586",
"0.63407916",
"0.633733",
"0.6325292",
"0.62963... | 0.8594378 | 1 |
Taking two nodes, swap each's reference to its parent with the other's | def swap_nodes_references_to_parents(first_node, second_node)
# no need to worry about nil references, it just works
first_node.parent, second_node.parent = [second_node.parent, first_node.parent]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_parent_reference_to_node(parent, first_node, second_node)\n unless parent.nil?\n kids = parent.kids\n index = kids.index first_node\n kids[index] = second_node\n end\n end",
"def swap_parents_references_to_nodes(first_node, second_node)\n # store a reference to the second's pare... | [
"0.853495",
"0.85175896",
"0.7402738",
"0.7200417",
"0.7094621",
"0.7094621",
"0.67931324",
"0.6744245",
"0.66440165",
"0.6591461",
"0.6579267",
"0.6579267",
"0.6552442",
"0.65465385",
"0.65342426",
"0.6476976",
"0.64698184",
"0.6423482",
"0.64230686",
"0.6412495",
"0.6400671... | 0.8827097 | 0 |
=begin The method returns the details of the item identified by the id. Before checks if the information are already in redis cache, otherwise asks to google places to give them. =end | def get_details(id)
if((results = $redis.get(id)).nil?)
details = get_details_item(id)
$redis.set(id,details.to_json)
return details.to_json
else
return results
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch(id)\n # Pass in a proc that will return true if item with id is looked up\n # (pass in invItem as a param to lambda)\n return lookup(id, Proc.new { |invItem| return invItem } )\n end",
"def fetch_item(item_id)\n fail \"Missing id\" if item_id.nil?\n fail \"No such item... | [
"0.64423573",
"0.63898635",
"0.63001966",
"0.6279467",
"0.61502904",
"0.61502904",
"0.6121647",
"0.61083424",
"0.60720634",
"0.6060753",
"0.60583",
"0.60383666",
"0.60232615",
"0.60232615",
"0.5977987",
"0.5971669",
"0.59676707",
"0.59676707",
"0.5965795",
"0.5965563",
"0.596... | 0.7136467 | 0 |
=begin The method returns the data related to the category culture of the city passed as parameter. Moreover you can specify the token in order to load more items. =end | def get_culture(city,token)
results = []
lat,lng = get_coordinates(city)
if lat.nil? or lng.nil?
return [].append({:results=>[],:token=>nil}).to_json
end
if(token.nil?)
if((results = $redis.get(lat.to_s+':'+lng.to_s+':culture')).nil?)
culture = get_culture_items(city,lat,lng)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n culture_items = get_culture(params[:city_id].downcase,params[:token])\n render_with_protection culture_items\n end",
"def cities\n CS.get :us, :ca\n end",
"def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_key}\n @client.call(... | [
"0.6775501",
"0.6455034",
"0.62882125",
"0.6227307",
"0.6017774",
"0.60081357",
"0.5922589",
"0.5868601",
"0.58455616",
"0.5844394",
"0.5759309",
"0.57562935",
"0.5663921",
"0.5633057",
"0.5623823",
"0.56000966",
"0.55781895",
"0.55595237",
"0.5555425",
"0.55273056",
"0.55266... | 0.6855655 | 0 |
=begin The method returns the data related to the category food of the city passed as parameter. Moreover you can specify the token in order to load more items. =end | def get_food(city,token)
results = []
lat,lng = get_coordinates(city)
if lat.nil? or lng.nil?
return [].append({:results=>[],:token=>nil}).to_json
end
if(token.nil?)
if((results = $redis.get(lat.to_s+':'+lng.to_s+':food')).nil?)
food = get_food_items(city,lat,lng)
puts... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category\n if params[:city] == \"sf\"\n @city = \"San Francisco\"\n elsif params[:city] == \"ny\"\n @city = \"New York\"\n end\n @listings = Listing.find_all_by_city(@city)\n end",
"def do_get_cats_data\n message = {country_id: @client.country_code, webapi_key: @client.webapi_ke... | [
"0.65190214",
"0.6397606",
"0.61949885",
"0.60483325",
"0.5958984",
"0.59314734",
"0.5922743",
"0.5911818",
"0.58592254",
"0.58492106",
"0.5847708",
"0.5821329",
"0.5806238",
"0.57814527",
"0.5775498",
"0.5774703",
"0.5774273",
"0.5728196",
"0.5686806",
"0.56341225",
"0.56335... | 0.710326 | 0 |
=begin The method returns the data related to the category hotel of the city passed as parameter. Moreover you can specify the token in order to load more items. =end | def get_hotels(city,token)
results = []
lat,lng = get_coordinates(city)
if lat.nil? or lng.nil?
return [].append({:results=>[],:token=>nil}).to_json
end
if(token.nil?)
if((results = $redis.get(lat.to_s+':'+lng.to_s+':hotel')).nil?)
hotel = get_hotels_list(city,lat,lng)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n hotels_list = get_hotels(params[:city_id].downcase,params[:token])\n render_with_protection hotels_list\n end",
"def new\n @hotel = Hotel.new\n @hotelCats = Hotel.get_hotel_categories\n\n end",
"def category\n if params[:city] == \"sf\"\n @city = \"San Francisco\"\n elsi... | [
"0.64219105",
"0.6311019",
"0.62498665",
"0.61939096",
"0.618843",
"0.5931736",
"0.5846033",
"0.57949275",
"0.5754828",
"0.5674925",
"0.56697524",
"0.56672555",
"0.5654262",
"0.56534624",
"0.56450033",
"0.5637223",
"0.56235373",
"0.55959195",
"0.55518836",
"0.55279225",
"0.55... | 0.679435 | 0 |
=begin The method returns the details of the hotel identified by the id. Before checks if the information are already in redis cache, otherwise asks to expedia to give them. =end | def hotel_details(id)
results = []
if((results = $redis.get(id)).nil?)
details = get_hotel_details(id)
$redis.set(id,details.to_json)
return details.to_json
else
return results
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_details(id)\n if((results = $redis.get(id)).nil?)\n details = get_details_item(id)\n $redis.set(id,details.to_json)\n return details.to_json\n else\n return results\n end\n end",
"def hotel\n return @hotel if @hotel\n @hotel = context.hotel if context.hotel.is_a? Hotel... | [
"0.63431925",
"0.63279337",
"0.60364497",
"0.5991496",
"0.5924526",
"0.5897568",
"0.58612657",
"0.58610994",
"0.58494556",
"0.57501835",
"0.57501835",
"0.57501835",
"0.5741032",
"0.5737573",
"0.5737573",
"0.5737573",
"0.5737573",
"0.5737573",
"0.5737573",
"0.57316786",
"0.563... | 0.8202833 | 0 |
The +options+ must be a hash of any of the following options: [:cell_size] The number of pixels on a side that each cell should occupy. Different maze types will use that space differently. Also, the cell padding is applied inside the cell, and so consumes some of the area. The default is 10. [:wall_width] How thick th... | def initialize(maze, options)
@options = DEFAULTS.merge(options)
[:background, :wall_color, :cell_color, :solution_color].each do |c|
@options[c] = ChunkyPNG::Color.from_hex(@options[c]) if String === @options[c]
end
@paths = @options[:paths] || []
if @options[:solut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_path(options={})\n path = @maze.new_path(options)\n prev = @maze.entrance\n\n (@solution || current_solution).each do |pt|\n how = path.link(prev, pt)\n path.set(pt, how)\n prev = pt\n end\n\n how = path.link(prev, @maze.exit)\n path.set(@... | [
"0.5579152",
"0.55675614",
"0.55650175",
"0.53642046",
"0.5338557",
"0.53356093",
"0.5271308",
"0.5268398",
"0.5261624",
"0.5033192",
"0.5020067",
"0.5010005",
"0.500933",
"0.49660718",
"0.49070862",
"0.48946014",
"0.4886064",
"0.48725846",
"0.48411402",
"0.48239866",
"0.4792... | 0.7041615 | 0 |
Returns the color at the given point by considering all provided paths. The +:color: metadata from the first path that is set at the given point is returned. If no path describes the given point, then the value of the +:cell_color+ option is returned. | def color_at(pt, direction=nil)
@paths.each do |path|
return path[:color] if direction ? path.path?(pt, direction) : path.set?(pt)
end
return @options[:cell_color]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_color(points, x, y)\n if points.key?(x.to_s.to_sym) && points[x.to_s.to_sym].key?(y.to_s.to_sym)\n points[x.to_s.to_sym][y.to_s.to_sym]\n else\n BLACK\n end\nend",
"def color(point, screen)\n screen[point[0]][point[1]]\nend",
"def get_color\n if @thread\n return CYCLING\n ... | [
"0.58900344",
"0.57645226",
"0.56961703",
"0.5649624",
"0.5332176",
"0.5255872",
"0.5010879",
"0.49766243",
"0.4932518",
"0.49314472",
"0.48868588",
"0.48791838",
"0.4860092",
"0.481093",
"0.47837004",
"0.47810236",
"0.4777897",
"0.47736526",
"0.47435075",
"0.47387832",
"0.47... | 0.7869839 | 0 |
Clamps the value +x+ so that it lies between +low+ and +hi+. In other words, returns +low+ if +x+ is less than +low+, and +high+ if +x+ is greater than +high+, and returns +x+ otherwise. | def clamp(x, low, hi)
x = low if x < low
x = hi if x > hi
return x
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clamp(value, minimum_inclusive, maximum_inclusive)\n\n if minimum_inclusive > maximum_inclusive\n\n swap = minimum_inclusive\n\n minimum_inclusive = maximum_inclusive\n maximum_inclusive = swap\n end\n\n value < minimum_inclusive ? minimum_inclusive : value < max... | [
"0.63418204",
"0.63383096",
"0.61270213",
"0.60302293",
"0.5999137",
"0.5802823",
"0.5730184",
"0.5607849",
"0.55975604",
"0.55432457",
"0.54886407",
"0.5393262",
"0.53752214",
"0.5311812",
"0.5293043",
"0.5264907",
"0.5260671",
"0.5245291",
"0.52112186",
"0.51480216",
"0.514... | 0.8366899 | 0 |
Draws a line from +p1+ to +p2+ on the given canvas object, in the given color. The coordinates of the given points are clamped (naively) to lie within the canvas' bounds. | def line(canvas, p1, p2, color)
canvas.line(
clamp(p1[0].round, 0, canvas.width-1),
clamp(p1[1].round, 0, canvas.height-1),
clamp(p2[0].round, 0, canvas.width-1),
clamp(p2[1].round, 0, canvas.height-1),
color)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_line(x1, y1, x2, y2, color)\n validate_coordinates!(x1, y1, x2, y2)\n validate_color!(color)\n\n area.draw_line(x1: x1, y1: y1, x2: x2, y2: y2, color: color)\n end",
"def draw_line(x1:, y1:, x2:, y2:, stroke_width: 1, color: nil, colour: nil)\n clr = color || colour\n clr = Color.new... | [
"0.75190896",
"0.7340886",
"0.7099494",
"0.70397407",
"0.69004035",
"0.6888946",
"0.6542574",
"0.65017074",
"0.6352124",
"0.6208106",
"0.61725426",
"0.6164968",
"0.6031069",
"0.6017214",
"0.60144967",
"0.6014365",
"0.60066456",
"0.5995002",
"0.5950163",
"0.59023666",
"0.58940... | 0.80848545 | 0 |
Fills the rectangle defined by the given coordinates with the given color. The coordinates are clamped to lie within the canvas' bounds. | def fill_rect(canvas, x0, y0, x1, y1, color)
x0 = clamp(x0, 0, canvas.width-1)
y0 = clamp(y0, 0, canvas.height-1)
x1 = clamp(x1, 0, canvas.width-1)
y1 = clamp(y1, 0, canvas.height-1)
[x0, x1].min.ceil.upto([x0, x1].max.floor) do |x|
[y0, y1].min.ceil.upto([y0, y1].max.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_rectangle(x:, y:, width:, height:, color: nil, colour: nil)\n clr = color || colour\n clr = Color.new(clr) unless clr.is_a? Color\n ext_fill_rectangle([\n x, y, width, height,\n clr.r, clr.g, clr.b, clr.a\n ])\n ... | [
"0.7121431",
"0.709534",
"0.6589137",
"0.65086013",
"0.6474075",
"0.6390988",
"0.6390911",
"0.6332036",
"0.63202345",
"0.62816745",
"0.6107122",
"0.6081478",
"0.60058796",
"0.5988081",
"0.5983963",
"0.5973139",
"0.5907259",
"0.588326",
"0.57940245",
"0.5793011",
"0.5788561",
... | 0.77763695 | 0 |
Fills the polygon defined by the +points+ array, with the given +color+. Each element of +points+ must be a 2tuple describing a vertex of the polygon. It is assumed that the polygon is closed. All points are clamped (naively) to lie within the canvas' bounds. | def fill_poly(canvas, points, color)
min_y = 1_000_000
max_y = -1_000_000
points.each do |x,y|
min_y = y if y < min_y
max_y = y if y > max_y
end
min_y = clamp(min_y, 0, canvas.height-1)
max_y = clamp(max_y, 0, canvas.height-1)
min_y.floor.upt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_polygon(coordinates:, color: nil, colour: nil)\n return if coordinates.nil? || coordinates.count < 6 || (color.nil? && colour.nil?)\n\n colors = colors_to_a(color || colour)\n ext_fill_polygon(coordinates, colors)\n update_texture if @update\n end",
"def polygon *points, color\n ... | [
"0.729775",
"0.6542282",
"0.62495387",
"0.6223149",
"0.62056625",
"0.61456215",
"0.5993672",
"0.5697314",
"0.54212576",
"0.5277981",
"0.5158219",
"0.5157109",
"0.5130532",
"0.49981874",
"0.49837562",
"0.48490575",
"0.48337382",
"0.48260283",
"0.47989127",
"0.47850564",
"0.475... | 0.7170604 | 1 |
We must require variable definitions to create valid prometheus queries. | def validate_variable_definitions!
return unless grafana_dashboard[:dashboard][:templating]
return if grafana_dashboard[:dashboard][:templating][:list].all? do |variable|
query_params[:"var-#{variable[:name]}"].present?
end
raise_error 'All Grafana variables must be defined in the quer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_global_variables!\n return unless panel_contains_unsupported_vars?\n\n raise_error \"Prometheus must not include #{UNSUPPORTED_GRAFANA_GLOBAL_VARS}\"\n end",
"def validate!\n bind_vars = operand(0).map(&:first).map(&:name)\n query_vars = operand(1).variables.keys\n ... | [
"0.6612635",
"0.6378841",
"0.5910635",
"0.57462984",
"0.5690208",
"0.5683649",
"0.5549672",
"0.5549672",
"0.55433613",
"0.55403817",
"0.5535319",
"0.5513412",
"0.54917926",
"0.5480631",
"0.54613",
"0.54093003",
"0.53860414",
"0.53831816",
"0.5360053",
"0.535631",
"0.53410816"... | 0.7279325 | 0 |
Make a copy of this object _Examples_ c = CData.new( "Some text" ) d = c.clone d.to_s > "Some text" | def clone
CData.new self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone() end",
"def clone\n copy(false)\n end",
"def clone; end",
"def clone; end",
"def clone; end",
"def clone\n end",
"def clone_with(data)\n clone = self.clone\n clone.instance_variable_set(:@data, data)\n clone\n end",
"def clone\n end",
"def clone\n end",... | [
"0.66992563",
"0.65524197",
"0.6546719",
"0.6546719",
"0.6546719",
"0.6533299",
"0.65073013",
"0.64716154",
"0.64716154",
"0.64716154",
"0.64650434",
"0.64650434",
"0.6462321",
"0.6462321",
"0.6432859",
"0.6366308",
"0.63413155",
"0.63293093",
"0.6302491",
"0.6225605",
"0.622... | 0.7382289 | 0 |
Generates XML output of this object output:: Where to write the string. Defaults to $stdout indent:: An integer. If 1, no indenting will be used; otherwise, the indentation will be this number of spaces, and children will be indented an additional amount. Defaults to 1. transitive:: If transitive is true and indent is ... | def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
#indent( output, indent ) unless transitive
output << START
output << @string
output << STOP
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(output, indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(nil)); end",
"def write(output = T.unsafe(nil), indent = T.unsafe(nil), transitive = T.unsafe(nil), ie_hack = T.unsafe(... | [
"0.7568185",
"0.7568185",
"0.7280415",
"0.7280415",
"0.6657205",
"0.6657205",
"0.6657205",
"0.6568612",
"0.6353267",
"0.62732005",
"0.59528744",
"0.59528744",
"0.59258246",
"0.57256794",
"0.5472478",
"0.5372227",
"0.5324999",
"0.5235042",
"0.52331513",
"0.51361626",
"0.511437... | 0.7625532 | 0 |
Optimizes the expression and materializes it into bitmap 'dest'. | def evaluate(dest_bitmap)
if @dest
@dest.copy_to(dest_bitmap)
else
do_evaluate(dest_bitmap)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def materialize(dest)\n # Resolve lhs and rhs operand, using 'dest' to store intermediate result so\n # a maximum of one temporary Bitmap has to be created.\n # Then apply the bitwise operator storing the final result in 'dest'.\n\n intermediate = dest\n\n lhs, *other_a... | [
"0.72795343",
"0.5811651",
"0.5811651",
"0.5810064",
"0.576544",
"0.57325697",
"0.56983197",
"0.56609553",
"0.56082356",
"0.55274755",
"0.55158687",
"0.54427516",
"0.54161406",
"0.530393",
"0.5289554",
"0.5285561",
"0.52284664",
"0.51845825",
"0.51710373",
"0.51263565",
"0.51... | 0.67954236 | 1 |
border_radius('5px') => all corners = 5px border_radius('5px', '1px') => top corners = 5px, bottom corners = 1px border_radius('5px', '1px', '5px') => top left = 5px, top right = 1px, bottom corners = 5px border_radius('5px', '1px', '5px', '1px') => top left = 5px, top right = 1px, bottom right = 5px, bottom left = 1px | def border_radius(topleft, topright=nil, bottomright=nil, bottomleft=nil)
bottomleft ||= bottomright || topright || topleft
topright = topleft if bottomright.blank? || topright.blank?
bottomright ||= bottomleft
"border-top-left-radius: #{topleft}; -moz-border-radius-topleft: #{topleft}; -webkit-border-t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rounded_corner(horizontal, vertical)\n css = [] << \"border\"\n attrs = {\n top: \"bottom\", bottom: \"top\",\n left: \"right\", right: \"left\" }\n css << attrs.fetch(vertical)\n css << attrs.fetch(horizontal)\n css << \"radius\"\n css.join(\"-\")\n end",
"def ... | [
"0.7577653",
"0.6856196",
"0.6353185",
"0.62425727",
"0.59274435",
"0.5771738",
"0.5745908",
"0.5740156",
"0.5592208",
"0.5592208",
"0.55738056",
"0.55445206",
"0.55341643",
"0.5518367",
"0.54617953",
"0.5449507",
"0.5422703",
"0.5395897",
"0.5386552",
"0.5297457",
"0.529658"... | 0.80288756 | 0 |
Sets the gain, in dB for the specified channel. | def []=(channel, gain)
set_float(channel.clamp(0, 31) + 1, gain.clamp(-80.0, 10.0))
gain
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gain=(new_gain)\n ptr = ::FFI::MemoryPointer.new(:int)\n Klass.setGain(@handle, @index, Phidgets::FFI::BridgeGains[new_gain])\n new_gain\n end",
"def update(channel, mute, deaf, self_mute, self_deaf)\n @voice_channel = channel\n @mute = mute\n @deaf = deaf\n @self_mute =... | [
"0.647357",
"0.59016347",
"0.5441973",
"0.52854943",
"0.52612376",
"0.5239406",
"0.51957816",
"0.5074396",
"0.5072223",
"0.50440973",
"0.5013539",
"0.50026065",
"0.50003886",
"0.49740273",
"0.49673223",
"0.4954275",
"0.4954275",
"0.49530602",
"0.49436203",
"0.49436203",
"0.49... | 0.79486656 | 0 |
new_string = [] string.chars.each do |char| new_string << char + char end new_string.join end p repeater('Hello') p repeater("Good job!") p repeater('') My solution unnecessarily converts the string to an array with .chars and then reconnects with .join on line 6 still the same amount of lines of code but a lot of extr... | def repeater2(string)
result = ''
string.each_char do |char|
result << char << char
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend",
"def repeater(string)\n new_string = ''\n string.chars.each do |char|\n new_string << char << char\n end\n new_string\nend",
"def repeater(string)\n string.chars.map { |char| char + char }.join\nend",
"def repeater... | [
"0.80695975",
"0.80561537",
"0.7937408",
"0.7928198",
"0.7928198",
"0.7876088",
"0.7778796",
"0.7732985",
"0.77086747",
"0.7627547",
"0.76186275",
"0.7607244",
"0.7537054",
"0.75227624",
"0.7492089",
"0.74672675",
"0.7454308",
"0.74293685",
"0.73836416",
"0.7367617",
"0.73452... | 0.8114022 | 0 |
Request an interactive operation. | def request_interaction(job_id, interaction_id, type, data)
check_interactive_operation_manager
# run the request
case type
when :browser
# page rendering mode
return Global.interactive_operation_manager.request_page(job_id, interaction_id, data)
when :dialog... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remote_interactive\n @calls << [:remote_interactive]\n end",
"def interactive\n rstream.interactive\n end",
"def interact\n end",
"def interactive\n Thread.new { EM.run }.abort_on_exception = true\n end",
"def interactive?\n @interactive\n end",
"def interacti... | [
"0.6792447",
"0.6550415",
"0.63616014",
"0.6222127",
"0.6156106",
"0.61517876",
"0.60638034",
"0.6047408",
"0.59537834",
"0.5943862",
"0.59331876",
"0.5928841",
"0.58876497",
"0.5838247",
"0.5804939",
"0.57616466",
"0.5733079",
"0.57159525",
"0.57033783",
"0.5693865",
"0.5679... | 0.66642016 | 1 |
Check avaiability of interactive opration manager. | def check_interactive_operation_manager
unless Global.interactive_operation_manager
raise Webclient::InteractiveOperationFailure.new("Interactive operation manager not found.")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interactive?\n\t\ttrue\n\tend",
"def interactive?\n\t\tfalse\n\tend",
"def interactive?\n\t\tfalse\n\tend",
"def interactive?\n @interactive\n end",
"def interactive?\n val = @gapi.configuration.query.priority\n return true if val.nil?\n val == \"INTERACTIVE\"\n ... | [
"0.64532363",
"0.6422974",
"0.6422974",
"0.63759065",
"0.6328265",
"0.6241102",
"0.605069",
"0.605069",
"0.6044951",
"0.5953489",
"0.5945068",
"0.59391284",
"0.5932513",
"0.5932513",
"0.58906186",
"0.5881811",
"0.5847464",
"0.5847464",
"0.5829452",
"0.58092725",
"0.5808783",
... | 0.7081548 | 0 |
ask whether to submit a package or not, submit if requested | def ask_submit(package, from, to, question)
if ask question
create_sr(package, from, to)
return true
else
puts "Skipping package #{package}"
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit; end",
"def submit?\n self.type == :submit\n end",
"def submit!\n\tend",
"def submit\n end",
"def submit\n\t\tif save\n\t\t\tsubmit_request\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def submits; end",
"def submit_request\n #TBD add a request to the database\n redir... | [
"0.6359921",
"0.6283683",
"0.6228542",
"0.621321",
"0.6209008",
"0.61669827",
"0.61415946",
"0.6060146",
"0.6025291",
"0.6025291",
"0.59822196",
"0.59438837",
"0.589018",
"0.5859428",
"0.5830596",
"0.5822923",
"0.58076537",
"0.57974356",
"0.57743853",
"0.5763713",
"0.57555515... | 0.7986828 | 0 |
invoice for the post | def invoice
@post = Post.find(params[:id])
@request= Request.find_by(post_id:@post.id)
@payment = Payment.find_by("user_id = ? AND post_id = ? AND status = ?",@post.user_id,@post.id,"success")
@payment1 = Payment.find_by("user_id = ? AND post_id = ? AND status = ?",@post.user_id,@post.id,"refund")
respond_to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoice\n\tparams['invoice']\n end",
"def invoice\n params['invoice']\n end",
"def invoice\n params['invoice']\n end",
"def invoice\n @ipn['invoice']\n end",
"def invoice\n NotificationsMailer.invoice\n end",
"def invoice\n \t\t\tZapi::Models:... | [
"0.7396639",
"0.7265095",
"0.7265095",
"0.72255635",
"0.7191154",
"0.7047565",
"0.6925598",
"0.68619514",
"0.685789",
"0.6833752",
"0.6830268",
"0.6769557",
"0.674438",
"0.6686724",
"0.6675918",
"0.6622802",
"0.66177833",
"0.6613677",
"0.6596032",
"0.6592973",
"0.658477",
"... | 0.79240525 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.