query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Exercise 2 1) 2 2) nil 3) "Joe" 4) "four" 5) nil Exercise 3 | def multiply(x,y)
x*y
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questionOne(frustration)\n if frustration == \"Yes\"\n return 3\n end \n \n if frustration == \"Not at all\"\n return 1\n end \n \n if frustration == \"I can't tell\"\n return 2\n end\nend",
"def first_not_done_exercise\n i = 0\n while(i < self.use... | [
"0.5799408",
"0.56122524",
"0.5544336",
"0.52911764",
"0.5258592",
"0.5179598",
"0.5178137",
"0.51656234",
"0.5159137",
"0.51502025",
"0.51098025",
"0.5089975",
"0.5089311",
"0.50884056",
"0.5066574",
"0.50569147",
"0.5051238",
"0.5050033",
"0.5040818",
"0.50160843",
"0.49986... | 0.0 | -1 |
Exercise 4 nothing (return statement happens before puts) Exercise 5 | def scream(words)
words = words + "!!!!"
puts words
return
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def what_was_that?\n puts \"-\" * 70\n puts \"***** I didn't catch that *****\"\n puts \"\"\n puts \"Would you please try a different answer?\"\n puts \"-\" * 70\n end",
"def return_statement(num)\n puts \"this is before the explicit return...\"\n if num != 1\n return \"yeah you entered so... | [
"0.6463618",
"0.6425313",
"0.6232855",
"0.6178439",
"0.6160612",
"0.6145456",
"0.6124249",
"0.6078611",
"0.60678726",
"0.60610366",
"0.6058667",
"0.6042817",
"0.5999282",
"0.5969615",
"0.5960293",
"0.5959496",
"0.59490895",
"0.5936979",
"0.59221035",
"0.591469",
"0.591469",
... | 0.0 | -1 |
call to send an actor a job | def delegate(job)
job = job.stringify_keys
job['id'] = generate_job_id(job) unless job_failed?(job)
@jobs[job['id']] = job
job['env_options'][CapistranoMulticonfigParallel::ENV_KEY_JOB_ID] = job['id']
# debug(@jobs)
# start work and send it to the background
@workers.async.work... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_message!\n msg = Message::Request.from_job(self)\n msg.send!\n end",
"def send_job\n new_job.tap do |job|\n yield job\n log_message :C, :job, job\n sendmsg(job.chunked_packed_stream)\n end\n end",
"def queue_job; ... | [
"0.7162265",
"0.6443967",
"0.6383821",
"0.62812716",
"0.6253659",
"0.62121975",
"0.62050664",
"0.61537516",
"0.6130183",
"0.61153984",
"0.6083708",
"0.6051514",
"0.6035013",
"0.6022449",
"0.60025114",
"0.59743583",
"0.59059817",
"0.589867",
"0.58950186",
"0.5892449",
"0.58644... | 0.5719328 | 26 |
call back from actor once it has received it's job actor should do this asap | def register_worker_for_job(job, worker)
job = job.stringify_keys
if job['id'].blank?
debug("job id not found. delegating again the job #{job.inspect}") if self.class.debug_enabled?
delegate(job)
else
start_worker(job, worker)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queue_job; end",
"def on_completion(actor); end",
"def run_job\n end",
"def work( payload, metadata )\n\t\tself.job_counter.mark\n\t\tself.job_timer.time do\n\t\t\tsuper\n\t\tend\n\tend",
"def invoke_job\n payload_object.perform\n end",
"def job \n @job\n end",
"def perform\n ... | [
"0.70943093",
"0.68737835",
"0.6841245",
"0.65333956",
"0.6503637",
"0.64320946",
"0.63727665",
"0.63585836",
"0.62972295",
"0.6294431",
"0.6288443",
"0.6279065",
"0.62272793",
"0.61961114",
"0.6164381",
"0.6139982",
"0.6139982",
"0.6126474",
"0.6110017",
"0.6088696",
"0.6087... | 0.0 | -1 |
lookup status of job by asking actor running it | def get_job_status(job)
status = nil
if job.present?
if job.is_a?(Hash)
job = job.stringify_keys
actor = @registered_jobs[job['id']]
status = actor.status
else
actor = @registered_jobs[job.to_i]
status = actor.status
end
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_status(job)\n (job.status == 'done' and !job.successful) ? 'Failed' : job.status.capitalize\n end",
"def get_status_job(gear, component)\n args = build_base_gear_args(gear)\n job = RemoteJob.new(component.cartridge_name, 'status', args)\n job\n end",
"def get_job_status(job_id)\n ... | [
"0.6813565",
"0.66068596",
"0.6595624",
"0.6533999",
"0.65229654",
"0.6501861",
"0.64503247",
"0.64343446",
"0.63047224",
"0.62552464",
"0.6204144",
"0.61560255",
"0.61560255",
"0.6151745",
"0.61328465",
"0.6110702",
"0.61010116",
"0.60858196",
"0.6080406",
"0.6053864",
"0.60... | 0.6946824 | 0 |
Ininitialize the client You must pass in an api_url and api_key These are available from your ActiveCampaign account For the sandbox accounts these are sent to your Email address by ActiveCampaign | def initialize(api_url:, api_key:, verbose: false)
self.api_url = api_url.is_a?(Addressable::URI) ? api_url : Addressable::URI.parse(api_url)
self.api_key = api_key
self.verbose = verbose
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(api_key, api_secret)\n @api_key = api_key\n @api_secret = api_secret\n @api_base_url = 'https://pepocampaigns.com'\n end",
"def initialize email, api_key\n @email = email\n @api_key = api_key\n end",
"def api_credentials(api_client)\n @api_client = api_client\n retur... | [
"0.6970165",
"0.6919673",
"0.6554132",
"0.65373087",
"0.64869994",
"0.64052314",
"0.6379505",
"0.63730615",
"0.631254",
"0.63085175",
"0.6284486",
"0.6282913",
"0.6267183",
"0.6243744",
"0.62306887",
"0.6214497",
"0.62131584",
"0.6189095",
"0.6189095",
"0.6189095",
"0.6188617... | 0.0 | -1 |
Default headers we send to active campaign Accept/content type json ApiToken for authentication | def default_headers
@default_headers ||= {
'accept': 'json',
'content-type': 'application/json',
'Api-Token': api_key
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def defaultHeaders(token)\n { 'Accept' => '*/*',\n 'Content-Type' => 'application/json',\n 'Authorization' => 'Bearer ' + token }\nend",
"def default_header\n if @access_token.present?\n {\n \"Authorization\" => \"Bearer #{@access_token.token}\",\n \"Accept\" => \"application/json\",... | [
"0.8127259",
"0.7933958",
"0.7718157",
"0.7653109",
"0.7621688",
"0.7616676",
"0.75977206",
"0.75798637",
"0.75456357",
"0.7534027",
"0.75322646",
"0.7492884",
"0.74446607",
"0.7403343",
"0.733573",
"0.7327715",
"0.73112047",
"0.7275964",
"0.7250323",
"0.72470623",
"0.7207899... | 0.796943 | 1 |
Send a GET request | def get(resource_path, headers: {}, prefix: API_PREFIX)
request(method: :get, resource_path: resource_path, headers: headers, prefix: prefix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_get(uri)\n _send_request('GET', uri, nil)\n end",
"def get\n start { |connection| connection.request http :Get }\n end",
"def get\n execute_request('GET') do |uri, headers|\n HTTP.http_client.get(\n uri,\n follow_redirect: true,\n header... | [
"0.8090074",
"0.8086617",
"0.7919836",
"0.78314894",
"0.7725113",
"0.77156067",
"0.77156067",
"0.769808",
"0.76646674",
"0.7653004",
"0.7625794",
"0.75984657",
"0.7544908",
"0.7541812",
"0.7541812",
"0.7541083",
"0.7458797",
"0.74430203",
"0.7413238",
"0.73793817",
"0.7379381... | 0.0 | -1 |
Send a POST request | def post(resource_path, body:, headers: {}, prefix: API_PREFIX)
request(method: :post, resource_path: resource_path, headers: headers, body: body, prefix: prefix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_post_request url, body, headers = []\n make_request url, method: ::Rack::POST, body: body, headers: headers\n end",
"def post(url, post_vars={})\n send_request url, post_vars, 'POST'\n end",
"def post endpoint, data\n do_request :post, endpoint, data\n end",
"def post_request... | [
"0.7967368",
"0.7810881",
"0.7785792",
"0.7714987",
"0.76692915",
"0.7499816",
"0.74733335",
"0.74269605",
"0.74232644",
"0.74210614",
"0.7376196",
"0.7342225",
"0.7288564",
"0.72772527",
"0.7276704",
"0.7257215",
"0.72516686",
"0.7242193",
"0.72285616",
"0.7206875",
"0.72015... | 0.0 | -1 |
Send a PUT request | def put(resource_path, body:, headers: {}, prefix: API_PREFIX)
request(method: :put, resource_path: resource_path, headers: headers, body: body, prefix: prefix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(*args)\n request :put, *args\n end",
"def put!\n request! :put\n end",
"def put(*args)\n request(:put, *args)\n end",
"def put_request(path, params={}, options={})\n request(:put, path, params, options)\n end",
"def put endpoint, data\n do_request :put, endpoint, da... | [
"0.81779695",
"0.8132293",
"0.80464405",
"0.7928155",
"0.77801764",
"0.7735355",
"0.77251774",
"0.76552063",
"0.76366216",
"0.7628022",
"0.76213336",
"0.75720435",
"0.75720435",
"0.7570474",
"0.7567829",
"0.75325865",
"0.7485932",
"0.7470569",
"0.74696434",
"0.74568576",
"0.7... | 0.0 | -1 |
Send a DELETE request | def delete(resource_path, headers: {}, prefix: API_PREFIX)
request(method: :delete, resource_path: resource_path, headers: headers, prefix: prefix)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n request(:delete)\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n u... | [
"0.84990364",
"0.8396772",
"0.83461964",
"0.83461964",
"0.82677025",
"0.82677025",
"0.8261009",
"0.82433265",
"0.81963205",
"0.8109251",
"0.80908537",
"0.8061717",
"0.8061717",
"0.8061717",
"0.8061717",
"0.8059549",
"0.79111004",
"0.7906911",
"0.7902865",
"0.78820944",
"0.786... | 0.0 | -1 |
Send any type of HTTP request | def request(method:, resource_path:, headers: {}, body: nil, prefix: API_PREFIX)
body_json = body.is_a?(String) || body.nil? ? body : body.to_json
url = ((api_url + prefix) + resource_path).to_s
request_headers = default_headers.merge(headers)
if verbose
puts("Executing #{method} reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_request(req); end",
"def send_request; end",
"def send_request\n if payload\n payload_type = payload.is_a?(String) ? :body : :form\n\n @http.public_send(method, url, payload_type => payload, ssl_context: ssl_options)\n else\n @http.public_send(method, url, ssl_... | [
"0.7258315",
"0.71943676",
"0.6980587",
"0.697773",
"0.6949544",
"0.67918146",
"0.655976",
"0.6523057",
"0.65212035",
"0.6504348",
"0.6470678",
"0.6458559",
"0.6436096",
"0.6427744",
"0.638929",
"0.6314951",
"0.63052225",
"0.6300841",
"0.6286664",
"0.6226868",
"0.6225718",
... | 0.0 | -1 |
We cannot mark as archived the section_texts directly, as they may be used by other documents | def archive!
self.update(archived: true)
NotificationMailer.new(self).document_toggle_archive
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_archives_texts(documents)\n\n val = ''\n documents.each do |doc|\n archives = {\n \"RT\" => \"Archives or Manuscripts\",\n \"A1\" => doc['author_display'].present? ? doc['author_display'][0].to_s : doc['author_display'].to_s,\n \"JF\"=> doc['found_in_labels_ss'].to_... | [
"0.548371",
"0.54345596",
"0.539416",
"0.5228337",
"0.5202846",
"0.5202256",
"0.5197544",
"0.51853555",
"0.51423466",
"0.5127201",
"0.5122513",
"0.5122513",
"0.5075254",
"0.50681067",
"0.50642467",
"0.50565386",
"0.5048153",
"0.5024713",
"0.5022597",
"0.50221545",
"0.5006274"... | 0.5097594 | 12 |
Document data we want to report to segment analytics | def reporting_properties
{
title: self.title,
id: self.id,
created_by: self.created_by&.reporting_properties,
project: self.project&.reporting_properties
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(startdate, enddate)\n\t\t\n\t\tdate_range = @analytics::DateRange.new(start_date: startdate, end_date: enddate)\n\t\torder_by = @analytics::OrderBy.new(field_name: 'ga:pageviews', sort_order: 'DESCENDING')\n\t\t# metric = @analytics::Metric.new(expression: 'ga:sessions')\n\t\t# metric = @analytics::Me... | [
"0.6209724",
"0.6081706",
"0.6081706",
"0.60795516",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
"0.5988254",
... | 0.0 | -1 |
used by cancan and paper_trail | def current_user
# authorization initialization if not run yet
# (in the case of paper_trial it might not have run)
authorization_init
@logged_in_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def policy; end",
"def permitted?; end",
"def privacy\n end",
"def privacy\n end",
"def policy(record); end",
"def policies; end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedor... | [
"0.60415083",
"0.6033213",
"0.5940621",
"0.5919646",
"0.5919646",
"0.5888434",
"0.58724374",
"0.58302647",
"0.58047324",
"0.57648396",
"0.57643527",
"0.57518053",
"0.5743139",
"0.5743139",
"0.5743139",
"0.5741305",
"0.5740591",
"0.5723979",
"0.5688626",
"0.56697047",
"0.56681... | 0.0 | -1 |
set course_enroll for destroy action | def index
@course_enrollements = current_user.course_enrollements
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n current_user.enrollments.where(course_id: @course.id).first.destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_url, :flash => { :success => 'Course was successfully deleted.' } }\n format.json { head :no_content }\n end\n end",
"def destr... | [
"0.74290365",
"0.7370804",
"0.72338986",
"0.7157434",
"0.7082216",
"0.70182997",
"0.70140344",
"0.6954295",
"0.69468504",
"0.6939181",
"0.6881087",
"0.68734795",
"0.6836474",
"0.68097466",
"0.6794976",
"0.678588",
"0.6783644",
"0.67827713",
"0.6757214",
"0.6747396",
"0.674300... | 0.0 | -1 |
def is_pass_fail_type? criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL end def is_point_type? criteria_type == Constants::CRITERIA_TYPE_POINT end | def get_status
if criteria_type == Constants::CRITERIA_TYPE_PASS_FAIL
temp_status = status
else
temp_status = point.zero? ? Constants::CRITERIA_STATUS_FAILED : Constants::CRITERIA_STATUS_PASSED
end
temp_status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_criteria_type # :nodoc:\n {\n 'between' => 'between',\n 'not between' => 'notBetween',\n 'equal to' => 'equal',\n '=' => 'equal',\n '==' => 'equal',\n '... | [
"0.6035881",
"0.585241",
"0.5829122",
"0.5829122",
"0.5780756",
"0.5769717",
"0.5678688",
"0.5623546",
"0.5582708",
"0.5572946",
"0.550275",
"0.54975027",
"0.5470265",
"0.54502994",
"0.54390216",
"0.54305667",
"0.5426283",
"0.5387452",
"0.5381422",
"0.5335307",
"0.53101057",
... | 0.7072243 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_career
@career = Career.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def career_params
params.require(:career).permit(:name, :description)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
... | 0.0 | -1 |
This two methods were overwritten for devise compability | def encrypted_password
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capable_login_auth?; end",
"def devise_modules_hook!; end",
"def devise_controller?; end",
"def user_provider; end",
"def devise_parameter_sanitizer; end",
"def fetchable_fields\n super - [:password, :password_confirmation]\n # if (context[:current_user].guest)\n # super - [:email]\n # ... | [
"0.64125067",
"0.6393043",
"0.638745",
"0.6305253",
"0.62551534",
"0.60903037",
"0.60615915",
"0.60024744",
"0.5968084",
"0.5934227",
"0.5887459",
"0.5873767",
"0.5873767",
"0.58577114",
"0.58548737",
"0.5841072",
"0.57956654",
"0.5750887",
"0.5727954",
"0.5701004",
"0.568667... | 0.0 | -1 |
To make things even harder to read, we'll remove spaces too. For example, this string: two drums and a cymbal fall off a cliff can be disemvoweled to get: twdrmsndcymblfllffclff We also want to keep the vowels we removed around (in their original order), which in this case is: ouaaaaoai | def remove_vowels(string)
vowels = ['a', 'e', 'i', 'o', 'u']
final_string = ""
vowels_used = ""
string.gsub!(" ", "")
string.each_char do |letter|
if !(vowels.include?(letter))
final_string << letter
else
vowels_used << letter
end
end
[final_string, vowels_used]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_vowels str\n reggie = /[aAeEiIoOuU]/\n holder_arr = str.split('')\n holder_arr.map! { |letter|\n if reggie.match letter\n letter = ''\n else \n letter\n end\n }\n holder_arr.join('')\nend",
"def disemvowel(str)\n # str.gsub(\"aeiou\", \"\")\n # str.split - ['a'],['e'],['i'],[... | [
"0.75706637",
"0.7558028",
"0.7462536",
"0.73287064",
"0.7279852",
"0.7271789",
"0.72627985",
"0.72091013",
"0.72044814",
"0.7203919",
"0.7198793",
"0.71929234",
"0.719145",
"0.7189943",
"0.7186061",
"0.71720684",
"0.71579576",
"0.71396464",
"0.7137439",
"0.7134888",
"0.70926... | 0.7584386 | 0 |
The MFS API exposes a FileToken creation via several different URLs. However we will never want to create a file token that we do not already have a file to hand, and hence we only use the FileStore URL. | def create(file, properties = {})
path = @file_repository.path_for(file, 'createfiletoken')
@client.post(path, properties).tap do |token|
token.file = file
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(file_token, file)\n create(file, {\n :RedirectWhenExpiredUrl => file_token.redirect_when_expired_url,\n :Unlimited => file.unlimited,\n :MaxDownloadAttempts => file.max_download_attempts,\n :MaxDownloadSuccesses => file.max_download_successes\n ... | [
"0.6421063",
"0.5708221",
"0.55999655",
"0.55879956",
"0.557966",
"0.5577307",
"0.5471286",
"0.5462341",
"0.5447786",
"0.5443468",
"0.5438388",
"0.54278076",
"0.54076326",
"0.5395299",
"0.5373914",
"0.5370456",
"0.53535146",
"0.5275479",
"0.52753377",
"0.5241569",
"0.522696",... | 0.604284 | 1 |
As an alternative a FileToken object can be created and the appropriate values set, then the save method called which creates the token on the server and its details loaded. | def save(file_token, file)
create(file, {
:RedirectWhenExpiredUrl => file_token.redirect_when_expired_url,
:Unlimited => file.unlimited,
:MaxDownloadAttempts => file.max_download_attempts,
:MaxDownloadSuccesses => file.max_download_successes
})
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end",
"def create_token(opts = {})\n self.token = Digest::SHA256.hexdigest(\n Time.now.to_s + Rails.application.secrets.salt + email\n )\n save if ... | [
"0.6669474",
"0.6643992",
"0.65656835",
"0.65253764",
"0.6418239",
"0.6336571",
"0.6302997",
"0.6250146",
"0.62203854",
"0.62145793",
"0.61862487",
"0.6174834",
"0.6094246",
"0.60820854",
"0.60649407",
"0.6040726",
"0.603184",
"0.6012607",
"0.5979807",
"0.5972874",
"0.5964271... | 0.73821336 | 0 |
Returns true if the user is logged in helper methods aren't available in tests! so we can't use the other method, but we will call it a different name to avoid confusion other method: logged_in in helpers/sessions_helper. since helpers/sessions_helper isn't availabled, we also can't use the current_user method defined ... | def is_logged_in?
!session[:user_id].nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_logged_in?\n # Because helper methods are not available in tests,\n # we can’t use the `current_user` method,\n # but the `session` method is available.\n ! session[:user_id].nil?\n end",
"def is_logged_in\n #since these are also marked as helper methods, they are availalble in not j... | [
"0.8104003",
"0.7483097",
"0.7174814",
"0.7174814",
"0.7174814",
"0.7174814",
"0.71568",
"0.7148025",
"0.71366453",
"0.71314925",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.71287936",
"0.712... | 0.0 | -1 |
Logs in a test user This helper method will be used for testing the checkbox | def log_in_as(user, options = {})
password = options[:password] || 'password'
remember_me = options[:remember_me] || '1'
# in integration tests, we can post to the sessions path,
# but in other tests we won't be able to, so we need to check
if integration_test?
# create a user
post login... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_login(user)\n click_log_in\n fill_login_credentials(user)\n end",
"def login_as_testuser\n login 'testuser@test.com', 'TestPass'\n end",
"def sign_in(test_user = :user_1)\n visit new_user_session_path\n fill_in 'Email', with: users(test_user).email\n fill_in 'Password', w... | [
"0.7752128",
"0.772213",
"0.7699351",
"0.76878947",
"0.7575415",
"0.7524393",
"0.7517012",
"0.74389786",
"0.7388671",
"0.7339582",
"0.7323013",
"0.72963667",
"0.7230384",
"0.72084993",
"0.7204875",
"0.71991295",
"0.717661",
"0.7166339",
"0.71626675",
"0.7160628",
"0.71403235"... | 0.6804621 | 71 |
Returns true inside an integration test | def integration_test?
# checks for the existance of a method only found in integration tests
defined?(post_via_redirect)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test?\n true\n end",
"def test?\n false\n end",
"def test?\n self.environment == ENV_TEST\n end",
"def test_truth\n end",
"def integration_test?\n defined?(follow_redirect!)\n end",
"def integration_test()\n return [\"all\"]\n end",
"def test?\n setting... | [
"0.7441766",
"0.72441983",
"0.7133517",
"0.71330607",
"0.7086181",
"0.706544",
"0.7021346",
"0.69783634",
"0.69783634",
"0.69783634",
"0.69783634",
"0.69783634",
"0.69783634",
"0.69783634",
"0.6974975",
"0.6974975",
"0.6974975",
"0.6974975",
"0.6951244",
"0.68909526",
"0.6890... | 0.71672475 | 2 |
UITableView delegate for default contents of UITableView, and UISearchDisplayController's UISearchResultsTableView | def tableView(table_view, numberOfRowsInSection: section)
case
when table_view.instance_of?(UITableView)
if @venues
@venues.length
else
0
end
when table_view.instance_of?(UISearchResultsTableView)
if @user_searched_venues
@user_searched_venues.length
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchControllerForTableView(tableView)\n Cliente.searchController(@searchString, withScope:nil) \n end",
"def index_table(klass, objects)\n # get links from class' helper\n links = send(\"#{klass.table_name}_index_links\", objects).compact\n\n # if there are any batch links, insert the 'select a... | [
"0.5536448",
"0.5417154",
"0.5326385",
"0.5308815",
"0.50853115",
"0.50801945",
"0.49760684",
"0.49630967",
"0.4951682",
"0.49376687",
"0.49332392",
"0.49173078",
"0.49159804",
"0.4900891",
"0.48927355",
"0.48763564",
"0.48569173",
"0.48541132",
"0.4845098",
"0.4835976",
"0.4... | 0.54704094 | 1 |
Checks each way matches the live version and deletes it if it does not. | def refresh_way
@osm.way.each_key do |way|
@log.info('refreshing ' + way)
response = query_server('/way/' + way)
if !response.nil?
xml = StringIO.new(response)
importer = Xml_import_osm.new(@new_osm)
listner = Listener.new(impor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free!\n return false if matches.empty?\n match_preference_indexes = matches.map { | match | preferences.index match }\n max = match_preference_indexes.max # The index of the match with the lowest preference\n candidate_to_reject = preferences[ max ]\n\n # Dele... | [
"0.616391",
"0.6065155",
"0.59841365",
"0.5879119",
"0.58750343",
"0.58690405",
"0.57966816",
"0.5785772",
"0.5773108",
"0.575508",
"0.572038",
"0.572038",
"0.56487286",
"0.5619987",
"0.5585794",
"0.5555359",
"0.55174065",
"0.54747474",
"0.5465739",
"0.54227656",
"0.53936046"... | 0.6493353 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_api_v1_nomination
@api_v1_nomination = Api::V1::Nomination.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def api_v1_nomination_params
params.fetch(:api_v1_nomination, {})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
GET /zoneamentos/1 GET /zoneamentos/1.json | def show
@zoneamento = Zoneamento.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @zoneamento }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @zona = Zona.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @zona }\n end\n end",
"def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end",
"def index\n @zones = Zone.all\n\n render json: @zones... | [
"0.72250354",
"0.71677834",
"0.71508473",
"0.70448995",
"0.70400196",
"0.7023082",
"0.7017232",
"0.6704599",
"0.66656727",
"0.66629034",
"0.6648785",
"0.66203594",
"0.66101664",
"0.659395",
"0.6587109",
"0.6580519",
"0.655609",
"0.65008765",
"0.64913195",
"0.6480973",
"0.6437... | 0.762167 | 0 |
GET /zoneamentos/new GET /zoneamentos/new.json | def new
@zoneamento = Zoneamento.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @zoneamento }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @zone = Zone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone }\n end\n end",
"def new\n @zona = Zona.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zona }\n end\n end",
"d... | [
"0.7623028",
"0.7604283",
"0.7564461",
"0.7119359",
"0.708741",
"0.7068637",
"0.7065412",
"0.705248",
"0.7048611",
"0.7044334",
"0.7004042",
"0.69979227",
"0.69949514",
"0.6982268",
"0.69760436",
"0.6965255",
"0.6962943",
"0.6946886",
"0.6910817",
"0.6907048",
"0.6903603",
... | 0.8057776 | 0 |
POST /zoneamentos POST /zoneamentos.json | def create
@zoneamento = Zoneamento.new(params[:zoneamento])
respond_to do |format|
if @zoneamento.save
format.html { redirect_to @zoneamento, :notice => 'Zoneamento was successfully created.' }
format.json { render :json => @zoneamento, :status => :created, :location => @zoneamento }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @zona = Zona.new(params[:zona])\n\n respond_to do |format|\n if @zona.save\n format.html { redirect_to @zona, notice: 'Zona creata con successo.' }\n format.json { render json: @zona, status: :created, location: @zona }\n else\n format.html { render action: \"new\"... | [
"0.6964226",
"0.6833536",
"0.682575",
"0.6816956",
"0.6778134",
"0.6775695",
"0.6562692",
"0.6562692",
"0.65248847",
"0.6518081",
"0.6441273",
"0.6433194",
"0.6298556",
"0.62896526",
"0.6277612",
"0.6274929",
"0.6269913",
"0.62663525",
"0.62549305",
"0.62502044",
"0.62232614"... | 0.74957556 | 0 |
PUT /zoneamentos/1 PUT /zoneamentos/1.json | def update
@zoneamento = Zoneamento.find(params[:id])
respond_to do |format|
if @zoneamento.update_attributes(params[:zoneamento])
format.html { redirect_to @zoneamento, :notice => 'Zoneamento was successfully updated.' }
format.json { head :no_content }
else
format.html { r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @zona = Zona.find(params[:id])\n\n respond_to do |format|\n if @zona.update_attributes(params[:zona])\n format.html { redirect_to @zona, notice: 'Zona aggiornata con successo.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n ... | [
"0.6687032",
"0.6471863",
"0.6412868",
"0.63772184",
"0.6300222",
"0.623089",
"0.6163724",
"0.61377126",
"0.61177385",
"0.6109353",
"0.61014104",
"0.6077665",
"0.60147405",
"0.5972893",
"0.5904185",
"0.58748996",
"0.5862537",
"0.5862537",
"0.5858848",
"0.5838853",
"0.5830405"... | 0.67096937 | 0 |
DELETE /zoneamentos/1 DELETE /zoneamentos/1.json | def destroy
@zoneamento = Zoneamento.find(params[:id])
@zoneamento.destroy
respond_to do |format|
format.html { redirect_to zoneamentos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @zona = Zona.find(params[:id])\n @zona.destroy\n\n respond_to do |format|\n format.html { redirect_to zone_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end... | [
"0.75745666",
"0.74508953",
"0.7318672",
"0.7273874",
"0.7253935",
"0.72427744",
"0.7231707",
"0.7230406",
"0.72280294",
"0.72023827",
"0.72023827",
"0.7201055",
"0.71909916",
"0.71902084",
"0.71819806",
"0.71762544",
"0.7173782",
"0.7173738",
"0.7171127",
"0.7166722",
"0.716... | 0.77349323 | 0 |
use init_cairo_bind(true) when initializing the screen Texture or you might run into some trouble :x | def init_cairo_bind(dry=false)
args = if self.disposed? || dry
[width, height];
else
dumpdata = dump('bgra');
format = Cairo::Format::ARGB32;
stride = Cairo::Format.stride_for_width(format, width);
[dumpdata, format, width, height, stride];
end
@_cairo_surface = Cairo::... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def begin_canvas\n if @width && @height\n @surface = ::Cairo::ImageSurface.new(::Cairo::FORMAT_ARGB32, @width, @height)\n else\n @surface = ::Cairo::ImageSurface.from_png(@file)\n end\n bind_context\n end",
"def init_screen\n nl\n Curses.noecho # Don't e... | [
"0.64196277",
"0.61500865",
"0.6149609",
"0.60725325",
"0.60695654",
"0.5986396",
"0.59153575",
"0.5892777",
"0.58486634",
"0.5818615",
"0.5808936",
"0.57825184",
"0.57356095",
"0.5685138",
"0.5645222",
"0.5634565",
"0.5628851",
"0.5623956",
"0.5614604",
"0.56089425",
"0.5603... | 0.67981416 | 0 |
we want a name that start with capital | def capitalize_name
self.name = name.sub(/\S/, &:upcase) unless name.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_case(name); end",
"def proper_name(name)\n return name if name =~ /[[:upper:]]/\n\n name.gsub(/\\b[[:alpha:]]+/) { |w| w =~ PARTICLE_REGEX ? w : w.capitalize }\n end",
"def capitalize() end",
"def downcase_name\n name.downcase!\n end",
"def capitalize!() end",
"def snakecase(na... | [
"0.8480844",
"0.79358935",
"0.79127574",
"0.7908961",
"0.7896077",
"0.7847313",
"0.78266174",
"0.78051573",
"0.7730899",
"0.76901996",
"0.76875067",
"0.7671091",
"0.7629492",
"0.7627836",
"0.7615682",
"0.7610093",
"0.7604014",
"0.7603991",
"0.76028335",
"0.7601348",
"0.759605... | 0.75121486 | 27 |
The name of the parser. | def parser
attributes.fetch(:parser)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parser_to_name(parser_name)\n parser_name.split(\"_\").map(&:capitalize).join(\" \")\nend",
"def __name__() @__grammar__.name end",
"def name\n @name ||= (@config[:name] || self.class.name.split(/::/).last.titleize)\n end",
"def name\n self.text =~ /^(.*)$/\n return... | [
"0.7134003",
"0.6830112",
"0.63767326",
"0.6350017",
"0.6295229",
"0.62603974",
"0.6214667",
"0.6205194",
"0.61756384",
"0.6131977",
"0.6127147",
"0.6067495",
"0.606744",
"0.6046374",
"0.60438764",
"0.6021423",
"0.6008149",
"0.6004922",
"0.599922",
"0.5977121",
"0.59762365",
... | 0.5858677 | 37 |
The version of the parser. | def version
attributes.fetch(:version)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_version\n @parser.http_version\n end",
"def version()\r\n return ParseDecision::VERSION\r\n end",
"def version\n @version || 0\n end",
"def version\n @version\n end",
"def version\n @version ||= File.read(file)[version_regex]\n end",
"def version\n ... | [
"0.77527565",
"0.76115483",
"0.7453702",
"0.74077964",
"0.7375093",
"0.7334682",
"0.73187536",
"0.7303047",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.7299586",
"0.72762567",
"0.72730726",
"0.7269243",
"0.7261451... | 0.0 | -1 |
Converts Blockly xml into a Blockly::Code object. | def parse(xml_text)
xml = XmlSimple.xml_in(xml_text, { 'ForceContent' => true })
parse_block(xml['block'][0])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_xml(xml)\n\t\tend",
"def parse_lang_for_codeblock(source); end",
"def compile(xml)\n XML.default_line_numbers = true\n\n doc = nil\n\n if xml.is_a?(String)\n doc = LibXML::XML::Document.string xml\n doc = doc.root\n elsif xml.is_a?(LibXML::XML::Document)\n doc ... | [
"0.5553657",
"0.5515942",
"0.53827",
"0.5287956",
"0.5235847",
"0.5155124",
"0.51472616",
"0.5062968",
"0.5052478",
"0.5052478",
"0.50476193",
"0.5043959",
"0.50289917",
"0.50228316",
"0.49587598",
"0.4934622",
"0.48698857",
"0.4868327",
"0.4866545",
"0.4842544",
"0.48278898"... | 0.50400543 | 12 |
TODO(mtomczak): In all parser statements, will need to clean up to catch syntax failures Blockly allows (such as incomplete blocks) | def parse_arithmetic_op(block)
Blockly::Code::Op.new(
next_block_id,
block['title'][0]['content'],
parse_block(block['value'][0]['block'][0]),
parse_block(block['value'][1]['block'][0]))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_codeblock; end",
"def parse_lang_for_codeblock(source); end",
"def parse_codeblock_fenced; end",
"def parse_block_extensions; end",
"def parse_block(*_arg0); end",
"def blocks_parse(input)\n return nil\nend",
"def parse_block_math; end",
"def invalid_syntax\n mutations.reject do |... | [
"0.754856",
"0.69873405",
"0.6962336",
"0.68896824",
"0.66750926",
"0.66511756",
"0.66362494",
"0.66300225",
"0.65354717",
"0.6476929",
"0.6448425",
"0.64442104",
"0.644317",
"0.6222991",
"0.62110335",
"0.62019753",
"0.6178083",
"0.61281323",
"0.61281323",
"0.61205536",
"0.60... | 0.0 | -1 |
This method is not yet implemented. This method (should) extracts previously stored data for reuse. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. | def extract( options )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ft_options(user_options, default, logger)\n # check version for this feature\n os_version = OpenStudio::VersionString.new(OpenStudio.openStudioVersion)\n\n os300 = OpenStudio::VersionString.new('3.0.0')\n os330 = OpenStudio::VersionString.new('3.3.0')\n known_ft_opt... | [
"0.5364491",
"0.5349642",
"0.5312582",
"0.5285913",
"0.5261508",
"0.52003205",
"0.5170419",
"0.5070996",
"0.5070996",
"0.50575185",
"0.5041466",
"0.50088626",
"0.49867913",
"0.49867913",
"0.49824324",
"0.49823636",
"0.49693188",
"0.4954354",
"0.49489403",
"0.49433717",
"0.493... | 0.56524736 | 0 |
Captures the extract data and converts it to a YML string storing it as a property on this object. Returns an empty array so as not to interupt the process loop. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. data [Hash]:: The extracted data as a hash. | def process( options, data )
@extractData = data.to_yaml
return []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render( options, data )\n @processData = data.to_yaml\n name = options[:store_filename]\n yml = options[:store_hook] == \"extract\" ? @extractData : @processData\n name != nil ? store(yml, name ) : [yml]\n end",
"def extract( options )\n \n end",
"def populate(options = {})\n... | [
"0.56721485",
"0.54680556",
"0.5306932",
"0.52274156",
"0.5174881",
"0.50718737",
"0.50599873",
"0.5008166",
"0.498401",
"0.49657175",
"0.49473906",
"0.49280497",
"0.4847236",
"0.48399734",
"0.48190933",
"0.48167735",
"0.48081338",
"0.47979417",
"0.47940463",
"0.47749463",
"0... | 0.70760983 | 0 |
Captures proess data and converts it to a YML string. This method also handles the actual writing of data to the file system. The options 'store_hook' toggles exract or process targeting. options [Hash]:: A hash that is passed to this extension by the main LEWT program containing rutime options. data [Array]:: The proc... | def render( options, data )
@processData = data.to_yaml
name = options[:store_filename]
yml = options[:store_hook] == "extract" ? @extractData : @processData
name != nil ? store(yml, name ) : [yml]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_polls_data(data)\n save_data('polls.yaml', data)\nend",
"def save_data(data,filename=nil)\n filename=data_file(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n open(filename,\"w\"){|f| f.puts YAML.dump(data)}\n when \".json\"\n open(filename,\"w\"){|f| ... | [
"0.62905395",
"0.59971225",
"0.597189",
"0.5841271",
"0.5786085",
"0.56685495",
"0.56228876",
"0.55521417",
"0.5544924",
"0.55430186",
"0.55080116",
"0.550554",
"0.55055106",
"0.5482314",
"0.5398211",
"0.5398211",
"0.53869045",
"0.53704524",
"0.53398335",
"0.5336009",
"0.5321... | 0.7113031 | 0 |
Writes the given YAML string to a file at path/name.yml, this method will overwrite the file if it already exists. yml [String]:: A YAML string of data. path [String]:: The path to store too. name [String]:: The name of the file to save as. | def store ( yml, name )
storefile = File.new( name, "w")
storefile.puts(yml)
storefile.close
return [yml]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_yaml(path=nil)\n unless path\n # Display file explorer\n path = Qt::FileDialog.getSaveFileName(self, \"Save configuration file\", \"./myconfig.yml\", \"YAML Files (*.yml *.yaml)\")\n end\n\n begin\n config_hash = Hash.new\n @container_hash.e... | [
"0.69372267",
"0.6783027",
"0.6661339",
"0.66281116",
"0.6428165",
"0.63069355",
"0.63029265",
"0.62984097",
"0.6280548",
"0.6252257",
"0.6176577",
"0.6128489",
"0.6072625",
"0.60368526",
"0.60366064",
"0.60152084",
"0.5991822",
"0.5956425",
"0.58868843",
"0.58076626",
"0.578... | 0.7165604 | 0 |
Create a new ProxyList | def initialize(proxy_queue)
@proxy_queue = proxy_queue
@current_proxy_index = 0
self.get_next
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ll_create()\n return Linked_List.new()\nend",
"def new\n @list = List.new\n end",
"def proxies; end",
"def proxylist\r\n\t\t\t`#{BITS::BITSADMIN} /getproxylist {#{@id}}`\r\n\t\tend",
"def new\n @list = List.new\n end",
"def load_proxy_list(*)\n raise NotImplementedError, \"#{__met... | [
"0.68253016",
"0.64611965",
"0.64361465",
"0.64264536",
"0.6358212",
"0.6344006",
"0.6344006",
"0.6149657",
"0.6007837",
"0.5979029",
"0.5931306",
"0.5887181",
"0.5884358",
"0.5880601",
"0.5871942",
"0.5842875",
"0.5838171",
"0.5838171",
"0.5827848",
"0.5788594",
"0.578338",
... | 0.560131 | 42 |
Class to search for resources, defined resources and classes | def search_class(module_name)
file_array = module_name.split('::')
#search module path for the class
$mod_dir.each do |y|
if File.directory?("#{y}/#{file_array[0]}")
@filename = "#{y}/#{file_array[0]}"
break
end
end
#did we find the class?
if defined? @filename
@filename = "#{@file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_resources!\n @resources = @lookups[:_default] = {}\n @resource_arguments = {}\n \n @default_order = []\n Dir[@resource_class.glob].each do |path|\n @default_order << basename = File.basename(path)\n \n @resource_arguments[basename] = resource_a... | [
"0.75339663",
"0.70749015",
"0.6743215",
"0.6685208",
"0.65334034",
"0.64840454",
"0.6455106",
"0.6322176",
"0.62777454",
"0.62701464",
"0.6268375",
"0.62310356",
"0.6178581",
"0.61498725",
"0.6109765",
"0.6104165",
"0.6092178",
"0.60591173",
"0.59949684",
"0.59887385",
"0.59... | 0.58502686 | 30 |
Internal methods (don't use). | def selected(monitor)
if monitor.closed?
@reactor.deregister(@server)
return
end
if monitor.readable?
@klass.new({:reactor => @reactor, :socket => monitor.io.accept_nonblock})
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def internal; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def refutal()\n end",
"def wrapper; end",
"def internal?; end",
"def handl... | [
"0.7993935",
"0.66776866",
"0.651218",
"0.6264087",
"0.62507075",
"0.62507075",
"0.6238261",
"0.6238261",
"0.6238261",
"0.6238261",
"0.60262144",
"0.60127026",
"0.5997253",
"0.59807104",
"0.59413075",
"0.59413075",
"0.5928407",
"0.58937544",
"0.58937544",
"0.5883689",
"0.5861... | 0.0 | -1 |
GET /document_histories GET /document_histories.json | def index
@document_histories = DocumentHistory.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @document_histories }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @document_histories = DocumentHistory.all\n end",
"def show\n @document_history = DocumentHistory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @document_history }\n end\n end",
"def index\n @reading_histories = cu... | [
"0.7655686",
"0.6883783",
"0.6552269",
"0.6547655",
"0.649568",
"0.64467233",
"0.6403964",
"0.6349311",
"0.63123536",
"0.62513787",
"0.62498796",
"0.6219313",
"0.6199762",
"0.6197101",
"0.6186016",
"0.61756635",
"0.6167894",
"0.61586195",
"0.61514014",
"0.6141995",
"0.6105994... | 0.79534477 | 0 |
GET /document_histories/1 GET /document_histories/1.json | def show
@document_history = DocumentHistory.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @document_history }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @document_histories = DocumentHistory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @document_histories }\n end\n end",
"def index\n @document_histories = DocumentHistory.all\n end",
"def new\n @document_history = DocumentHisto... | [
"0.78202945",
"0.7493386",
"0.6679428",
"0.64746624",
"0.6400701",
"0.63793236",
"0.6339385",
"0.62653154",
"0.62411165",
"0.6148458",
"0.6134712",
"0.6134442",
"0.61278677",
"0.61198914",
"0.6089314",
"0.6066219",
"0.6061241",
"0.6056675",
"0.6054338",
"0.60542065",
"0.60334... | 0.7112611 | 2 |
GET /document_histories/new GET /document_histories/new.json | def new
@document_history = DocumentHistory.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @document_history }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n \n end",
"def create\n @document_history = DocumentHistory.new(params[:document_history])\n\n respond_to do |format|\n if @document_histo... | [
"0.71452826",
"0.7141997",
"0.70712",
"0.7040632",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.69915295",
"0.6926776",
"0.69182444",
"0.69072044",
"0.68260354",
"0.6794462",
"0.67733455",
"0.6725073",
"0.6... | 0.79606754 | 0 |
POST /document_histories POST /document_histories.json | def create
@document_history = DocumentHistory.new(params[:document_history])
respond_to do |format|
if @document_history.save
format.html { redirect_to @document_history, notice: 'Document history was successfully created' }
format.json { render json: @document_history, status: :created,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @document_histories = DocumentHistory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @document_histories }\n end\n end",
"def index\n @document_histories = DocumentHistory.all\n end",
"def create\n @document_history = DocumentHi... | [
"0.6826042",
"0.6532865",
"0.6462636",
"0.6339968",
"0.62200975",
"0.61506677",
"0.6149327",
"0.60513204",
"0.6023878",
"0.5999612",
"0.5961733",
"0.58554316",
"0.5849497",
"0.57504565",
"0.57474196",
"0.571343",
"0.57078207",
"0.5681089",
"0.56593907",
"0.5637676",
"0.563416... | 0.6751136 | 1 |
PUT /document_histories/1 PUT /document_histories/1.json | def update
@document_history = DocumentHistory.find(params[:id])
respond_to do |format|
if @document_history.update_attributes(params[:document_history])
format.html { redirect_to @document_history, notice: 'Document history was successfully updated.' }
format.json { head :no_content }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @document_history.update(document_history_params)\n format.html { redirect_to documents_url, notice: 'Document history was successfully updated.' }\n format.json { render :show, status: :ok, location: @document_history }\n else\n format.htm... | [
"0.67855597",
"0.6583278",
"0.631288",
"0.62327373",
"0.60932916",
"0.60357744",
"0.6006562",
"0.59769696",
"0.5914936",
"0.58803964",
"0.5868203",
"0.5868203",
"0.5795932",
"0.57838583",
"0.57754815",
"0.57581544",
"0.5755256",
"0.57471627",
"0.5733513",
"0.57193327",
"0.571... | 0.6824572 | 0 |
DELETE /document_histories/1 DELETE /document_histories/1.json | def destroy
@document_history = DocumentHistory.find(params[:id])
@document_history.destroy
respond_to do |format|
format.html { redirect_to document_histories_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @document_history.destroy\n respond_to do |format|\n format.html { redirect_to document_histories_url, notice: 'Document history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @historial_odt = HistorialOdt.find(params[:id])\n ... | [
"0.75103664",
"0.6973636",
"0.6949144",
"0.6892297",
"0.687828",
"0.6867968",
"0.68034446",
"0.6800372",
"0.67957",
"0.6773752",
"0.6766222",
"0.67589474",
"0.6742232",
"0.67400783",
"0.67357916",
"0.6732897",
"0.6730173",
"0.6724258",
"0.6724258",
"0.6713463",
"0.6713463",
... | 0.7814299 | 0 |
Method to add purchases | def add_transaction(database, user_id)
# Ask user for item name
puts "Enter name of purchase ('q' to quit):"
item = gets.chomp
if item == "q"
return
end
# Ask user for quantity of item
puts "Enter quantity of purchase ('q' to quit):"
# We only want digits stored in these columns
quantity = gets.chomp
if qua... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_purchases(purchase_record)\n @purchases << purchase_record\n end",
"def add_to_pending(purchase)\r\n self.pending_purchases.push(purchase)\r\n end",
"def create\n purchase = @order.purchases.first(:conditions => {\n :purchasable_id => params[:purchase][:purchasable_id],\n ... | [
"0.7992879",
"0.741105",
"0.7236363",
"0.7181183",
"0.71466964",
"0.66805327",
"0.6673908",
"0.65492684",
"0.65337396",
"0.64984447",
"0.64761376",
"0.6428373",
"0.6421839",
"0.64188564",
"0.64108944",
"0.64108944",
"0.63930047",
"0.6314478",
"0.63142496",
"0.627486",
"0.6266... | 0.0 | -1 |
Write method to calculate total spent | def calculate_total(database, user_id)
total = 0
item_costs = database.execute(
"SELECT *
FROM purchases
WHERE login_id='#{user_id}';"
)
item_costs.each do |cost|
total += cost[3]
end
total
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_total_money_spent\n return @trips.inject(0.0) { |sum, trip|\n trip.is_in_progress? ? sum + 0 : sum + trip.cost }\n end",
"def spent\n @spent ||= calculate_spent\n @spent.round(2)\n end",
"def total_spent\n total_cost = 0\n trips.each do |trip|\n total_... | [
"0.8081684",
"0.78729874",
"0.78285927",
"0.75776976",
"0.7370266",
"0.7369869",
"0.7246654",
"0.7238296",
"0.7224928",
"0.7136309",
"0.7129557",
"0.7122343",
"0.71042585",
"0.7098666",
"0.7097408",
"0.7087116",
"0.7065009",
"0.70386064",
"0.70287937",
"0.7027404",
"0.7013621... | 0.0 | -1 |
This method is called with a block to define a provider for some subtree of the MIB. When a request comes in with varbinds in that providers subtree, the provider's handlers will be called to generate the varbind to send back in the response PDU. Arguments oid: The root OID of the MIB subtree this provider is responsib... | def provide(oid = :all, &block)
provider = Provider.new(oid)
provider.instance_eval(&block)
# Providers are pushed onto the end of the provider queue.
# When dispatching, this is searched in order for a match.
# So, like exception handlers, you such specify providers
# in order of m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind(object)\n BlockAdapter.new(@block, object)\n end",
"def register_block_for(type, &blk); end",
"def bind(&block)\n\t\t\t@endpoint.bind(&block)\n\t\tend",
"def stubs_for_provider(target = nil, &block)\n _chefspec_stubs_for_registry[:provider][target] << block\n en... | [
"0.5001778",
"0.48244882",
"0.48094225",
"0.47703215",
"0.4698374",
"0.4698298",
"0.4649873",
"0.46205002",
"0.45914763",
"0.4587741",
"0.4587297",
"0.45735294",
"0.45548",
"0.45420069",
"0.45293686",
"0.4468559",
"0.44195402",
"0.44073898",
"0.4399371",
"0.43583658",
"0.4353... | 0.6432319 | 0 |
The callback given to the Listener object for handling an SNMP message. Calls `dispatch`, then sends the response PDU, if one is returned. | def process_message(message)
# TODO: May want to ignore some messages (say, if the community string is wrong)
message.respond(dispatch(message))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispatch(message)\n response_pdu = message.make_response_pdu\n context = ProviderDsl.new\n context.message = message\n context.response_pdu = response_pdu\n message.pdu.varbinds.each_with_index do |vb, index|\n context.varbind = vb\n provider = providers.find { |p| p.prov... | [
"0.6299982",
"0.58289695",
"0.5644207",
"0.54480875",
"0.5435592",
"0.5406784",
"0.5394403",
"0.53837657",
"0.53768104",
"0.5364736",
"0.5364482",
"0.53307945",
"0.5315853",
"0.5312624",
"0.5271819",
"0.52700657",
"0.5269009",
"0.5252842",
"0.5228024",
"0.52118975",
"0.516678... | 0.4733713 | 64 |
Collects responses for the given message from the available providers | def dispatch(message)
response_pdu = message.make_response_pdu
context = ProviderDsl.new
context.message = message
context.response_pdu = response_pdu
message.pdu.varbinds.each_with_index do |vb, index|
context.varbind = vb
provider = providers.find { |p| p.provides?(vb.oid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond(message)\n RESPONSES.sample\n end",
"def collect_untagged_responses(name, *command)\n untagged_responses = []\n\n send_command(*command).listen do |response|\n if response.is_a?(Net::IMAP::UntaggedResponse) && response.name == name\n untagged_responses << respons... | [
"0.58834857",
"0.5443898",
"0.5429215",
"0.5369184",
"0.52822053",
"0.5265848",
"0.52538484",
"0.51783234",
"0.5154578",
"0.5105787",
"0.50953627",
"0.5094658",
"0.5075465",
"0.50741345",
"0.5041642",
"0.50310385",
"0.502311",
"0.5011243",
"0.49874973",
"0.49836627",
"0.49560... | 0.65969014 | 0 |
Evan Manuella Marsha Fletcher Here, we are creating a system which will allow the user to input an image and a function (e.g: rgbredder). This function will be applied to every pixel in the image (e.g: making the image redder). Outline tile = PixeledTile.new(image_to_intial_tile(image) tile.transform!(fun) tile.export(... | def image_compute(imageID, active_layer, function)
tile = PixeledTile.new(image_to_initial_tile(imageID, active_layer))
while tile
tile.transform!(function)
tile = tile.update()
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_transform(imageID, active_layer, function)\n tile = PixeledTile.new(image_to_initial_tile(imageID, active_layer))\n while tile\n tile.transform!(function)\n tile = tile.export() #send tile to gimp, get new one, and set tile to it\n end #If no tile is next (the end), then image_compute will termi... | [
"0.8024423",
"0.61971647",
"0.603823",
"0.5593634",
"0.5545068",
"0.544241",
"0.5428038",
"0.5422069",
"0.54058564",
"0.53944397",
"0.5392597",
"0.53772104",
"0.5342874",
"0.53412926",
"0.5339355",
"0.53358465",
"0.5324483",
"0.53177506",
"0.5305924",
"0.52995396",
"0.5263042... | 0.7781661 | 1 |
def sum_array(integers) integers.reduce(:+) end | def sum_array(integers)
integers.inject {|sum, n| sum + n}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_array(int_array)\n int_array.reduce(:+)\nend",
"def sum_array(integers)\n integers.sum\nend",
"def sum_array(integers)\n integers.inject(0) { |result, element| result + element }\nend",
"def sum(array_of_integers)\n # TODO\nend",
"def sum_array(array)\n array.reduce(:+)\nend",
"def sum_arr... | [
"0.9350951",
"0.91094023",
"0.9014119",
"0.881848",
"0.8803113",
"0.8761558",
"0.8730734",
"0.8730734",
"0.8712161",
"0.8689692",
"0.86758107",
"0.86166435",
"0.86166435",
"0.86166435",
"0.8608621",
"0.85716164",
"0.8562582",
"0.8512822",
"0.8482392",
"0.8468634",
"0.8426987"... | 0.88204783 | 3 |
Return the number of product attributes that this product has. | def attribute_count
product_family.product_attributes.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_attributes\n\t\treturn self.attributes.size\n\tend",
"def size\n @components.values.inject(0) { |component_count, attribute| component_count + attribute.size }\n end",
"def size\n attribute_prop(3)\n end",
"def count\n @attributes['count']\n end",
"def size\n self... | [
"0.79098463",
"0.73364174",
"0.7141863",
"0.70986485",
"0.7070723",
"0.6916319",
"0.678782",
"0.67702943",
"0.6620325",
"0.65641475",
"0.6558307",
"0.6384833",
"0.6285418",
"0.6226002",
"0.62084836",
"0.6202754",
"0.6170388",
"0.6089106",
"0.60841715",
"0.6077765",
"0.6003365... | 0.8764938 | 0 |
Setter method for the 'internal' price of a product. This is not an attribute, only a field of the product model itself. | def price=(value)
if value.instance_of?(String)
cents = MoneyUtils.parse(value)
else
begin
cents = Integer(value)
rescue
cents = nil
end
end
if cents
self.price_basis = cents
else
errors.add(:price_basis, "price can't be empty")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_price\n\t\tif persisted?\n\t\t\tself[:price]\n\t\telse\n\t\t\tproduct.price\n\t\tend\n\tend",
"def price= price\n if User.current and User.current.currency\n converted_price = (price.to_d / User.current.currency.exchange_rate.to_d).to_d\n else\n converted_price = price\n end\n write... | [
"0.771083",
"0.7291666",
"0.71573824",
"0.70893776",
"0.70893776",
"0.7061236",
"0.69499546",
"0.6853084",
"0.68031144",
"0.6766153",
"0.6752603",
"0.6743855",
"0.67190784",
"0.6675876",
"0.66526353",
"0.65515363",
"0.65492076",
"0.6546677",
"0.6524252",
"0.6497815",
"0.64623... | 0.0 | -1 |
Getter method for the 'internal' price of a product. This is not an attribute, only a field of the product model itself. | def price
MoneyUtils.format(self.price_basis)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def price\n return 0 unless self.persisted?\n\n return product.master.price if with_master_price?\n\n default_price.price\n end",
"def original_price\n self.read_attribute(:price)\n end",
"def unit_price\n return self[:unit_price] if persisted?\n product.price\n end",
"def se... | [
"0.77621764",
"0.76674557",
"0.7461227",
"0.7431277",
"0.73654985",
"0.73654985",
"0.73248166",
"0.7288492",
"0.7202354",
"0.71966803",
"0.71757936",
"0.71757936",
"0.7163685",
"0.71581346",
"0.71107054",
"0.6952827",
"0.6945774",
"0.6925268",
"0.69164795",
"0.6883636",
"0.68... | 0.6669317 | 33 |
Used as pseudoattribute by the products controller. Add this product to the specified leaf categories. The list of leaf categories is assumed to be comprehensive: the product should be assigned to all these leaves and only these leaves. For each leaf, propagate the product all the way up to the root. | def leaf_ids=(lids)
save! if new_record?
# Clear out all mention of the product from the entire tree.
CategoryProduct.delete_all(["product_id = ?", self.id])
lids.each do |lid|
next if lid == "none"
category = Category.find(lid)
category.add_product(self, auto_prop)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_product(prod, propagate = true)\n\n # Can't add products to interior category.\n unless self.leaf?\n errors.add(:base, \"Can't add product to interior category.\")\n return\n end\n \n # Make sure that the category has the product's product family.\n # There is a race condition h... | [
"0.6150408",
"0.5966761",
"0.5800269",
"0.5593024",
"0.55616397",
"0.5540508",
"0.5476254",
"0.5287752",
"0.5285551",
"0.52736497",
"0.5183773",
"0.5157095",
"0.5156824",
"0.5106109",
"0.5102734",
"0.5075878",
"0.50305045",
"0.49920252",
"0.49850667",
"0.49596792",
"0.4956506... | 0.686687 | 0 |
Return an array of the leaf category ids for this product. | def leaf_ids
lids = []
self.categories.leaves.each do |cat|
lids << cat.id
end
lids
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_ids\n self.associated_categories.collect{ |c| c.id }\n end",
"def all_category_ids\n end",
"def ids\n self.is_leaf? ? [@ids].flatten : self.children.inject([]) {|result, item| result += item.ids}\n end",
"def category_ids\n # {{{\n if !@category_ids then\n @catego... | [
"0.7195566",
"0.6842188",
"0.6680551",
"0.6616662",
"0.6568534",
"0.63752604",
"0.6304599",
"0.62496436",
"0.6173014",
"0.6173014",
"0.61586803",
"0.61586803",
"0.61472106",
"0.6140462",
"0.61340463",
"0.6131648",
"0.6117466",
"0.61149436",
"0.6114322",
"0.6081581",
"0.608006... | 0.8255697 | 0 |
Merge an indicator into 'leaf_category_paths' that tells if the current product is visible in that path. | def candidate_paths
# All leaf categories for this product family. This is an array
# of hashes. Each hash has keys :catid and :path.
candidates = self.product_family.leaf_category_paths
# All leaf category ids that were previously selected for this
# product. This will be a subset of the candida... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serachable_leafs\n leafs.select { |leaf| leaf && leaf.searchable && leaf.visible }.compact\n end",
"def category_leaf(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V2/categoryLeaf... | [
"0.51198906",
"0.50693506",
"0.5054103",
"0.5031562",
"0.49735942",
"0.49636924",
"0.49341705",
"0.48935965",
"0.48935965",
"0.4835533",
"0.48277405",
"0.47744712",
"0.47665894",
"0.47470155",
"0.4728564",
"0.47283533",
"0.47126967",
"0.47123095",
"0.47026855",
"0.4667721",
"... | 0.6023198 | 0 |
Save the result of editing the photo set for this product. The corresponding "get" method is just "product.photos". | def photo_set=(photo_set)
photo_set.each_pair do |photo_id, props|
photo = Photo.find(photo_id)
if props[:delete]
self.photos.destroy(photo)
else
if props[:hidden] == "1"
to_set = {:hidden => true}
else
to_set = {:hidden => false}
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_product_photo\n @product_photo = ProductPhoto.find(params[:id])\n end",
"def set_photo\n @photos = Photo.find(params[:id])\n end",
"def set_photo\n @possible_photos = get_possible_photos\n @photo = @possible_photos.find_by_id(params[:id])\n end",
"def update\n if reque... | [
"0.6664469",
"0.66618866",
"0.6463024",
"0.64435536",
"0.64362663",
"0.6307502",
"0.6294206",
"0.6272002",
"0.623259",
"0.6225893",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.61844397",
"0.6... | 0.6087216 | 71 |
Get the value of the the given attribute for this product. | def get_attribute_value(attribute)
values = read_attr_val(attribute.id)
return nil unless values
if attribute.atype == ProductAttribute::Atype_String
return values[0]
elsif attribute.atype == ProductAttribute::Atype_Currency
MoneyUtils.format(values[1])
else
return Integer(values[1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attribute_value(attribute)\n data[attribute]\n end",
"def get attribute\n attributes[attribute]\n end",
"def attribute_value\n @attributes.each { | id, value | return value }\n end",
"def value\n attributes.fetch(:value)\n end",
"def get_value(attribute_i... | [
"0.79997975",
"0.7601683",
"0.7571235",
"0.74166137",
"0.72691464",
"0.725703",
"0.7239424",
"0.70847327",
"0.7031837",
"0.70087326",
"0.70087326",
"0.6965269",
"0.6957848",
"0.6927108",
"0.68974704",
"0.68912816",
"0.6706977",
"0.66794556",
"0.66576356",
"0.6594177",
"0.6592... | 0.81184626 | 0 |
Set the value of this product for a given attribute. | def set_attribute_value(attribute, value)
# This product needs to have an id in order to set
# attribute values on it.
save! if new_record?
if attribute.atype == ProductAttribute::Atype_String
str_val = value
int_val = nil
elsif attribute.atype == ProductAttribute::Atype_Currency
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set attribute, value\n attributes[attribute] = value\n end",
"def set(attribute, value)\n @attributes[attribute.to_s] = value\n nil\n end",
"def set_attribute(attribute, value)\n if MojeID.is_attribute_available?(attribute)\n fetch_request.set_values(attribute, value)\n ... | [
"0.7614049",
"0.7433947",
"0.7421714",
"0.73256314",
"0.73256314",
"0.7287782",
"0.7206394",
"0.7192005",
"0.7136974",
"0.71270645",
"0.70843023",
"0.7008442",
"0.7008442",
"0.6957763",
"0.69515175",
"0.68816537",
"0.6867755",
"0.68602115",
"0.6845434",
"0.68413764",
"0.68246... | 0.8150226 | 0 |
An internal validation function. | def valid_product_family
begin
product_family != nil
rescue
errors.add :product_family, 'does not exist'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate; end",
"def validate; end",
"def validate; end",
"def validate; end",
"def valid?(_) true end",
"def valid?(_) true end",
"def validation; end",
"def validation; end",
"def validate!; end",
"def validate!; end",
"def validate!; end",
"def valid; end",
"def validate\n \n \n e... | [
"0.8178233",
"0.8178233",
"0.8178233",
"0.8178233",
"0.81748724",
"0.81748724",
"0.81284386",
"0.81284386",
"0.80294967",
"0.80294967",
"0.80294967",
"0.80107385",
"0.7980947",
"0.7935828",
"0.7935513",
"0.7928331",
"0.7916492",
"0.78714937",
"0.78237754",
"0.78237754",
"0.78... | 0.0 | -1 |
initialize memache if client is storing results in memcache | def initialize_memcache
require 'memcache'
memcache_options = {
:c_threshold => 10_000,
:compression => true,
:debug => false,
:namespace => 'backgroundrb_result_hash',
:readonly => false,
:urlencode => false
}
@cache = MemCache.new(memcache_option... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare\n namespace = @config[:namespace] || 'merb-cache'\n host = @config[:host] || '127.0.0.1:11211'\n @memcache = MemCache.new(host, {:namespace => namespace})\n @tracking_key = \"_#{namespace}_keys\" unless @config[:no_tracking]\n raise NotReady unless @memcache.active?\n true\n rescue N... | [
"0.71720105",
"0.67617524",
"0.6729403",
"0.6729403",
"0.67230844",
"0.6696267",
"0.66402173",
"0.66231966",
"0.66231966",
"0.66231966",
"0.66231966",
"0.66231966",
"0.66231966",
"0.66231966",
"0.658924",
"0.6551751",
"0.6550356",
"0.6448993",
"0.64371365",
"0.6427174",
"0.64... | 0.7719943 | 0 |
initialize all backend server connections | def establish_connections
klass = Struct.new(:ip,:port)
if t_servers = BackgrounDRb::BDRB_CONFIG[:client]
connections = t_servers.split(',')
connections.each do |conn_string|
ip = conn_string.split(':')[0]
port = conn_string.split(':')[1].to_i
@bdrb_servers << k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_servers\n @protocols.each do |protocol, _|\n server = @servers[protocol.protocol]\n block = server[:start]\n server[:server].start(server[:port], @routes[protocol.protocol], views: @views, channel: @channels[protocol.protocol], debug: @debug, &block)\n end\n end",
... | [
"0.74100477",
"0.6855645",
"0.6611705",
"0.65290457",
"0.6371729",
"0.63163835",
"0.6316341",
"0.63012344",
"0.62954414",
"0.62927186",
"0.62580585",
"0.6250443",
"0.622742",
"0.6225564",
"0.62035614",
"0.61854345",
"0.61762184",
"0.6131116",
"0.6106458",
"0.6096347",
"0.6086... | 0.6667877 | 2 |
end of method establish_connections every 10 request or 10 seconds it will try to reconnect to bdrb servers which were down | def discover_server_periodically
@disconnected_connections.each do |key,connection|
connection.establish_connection
if connection.connection_status
@backend_connections << connection
connection.close_connection
@disconnected_connections[key] = nil
end
en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_reconnect\n delay = @reconnect_manager.get_next_reconnect_delay(@last_status_code)\n\n if delay == -1\n execute_callback(@maxiumum_reconnects_reached_callback)\n terminate_connection\n elsif delay == 0\n execute_callback(@reconnect_callback, 0)\n attempt_reconnect\n else\n... | [
"0.71812356",
"0.6946376",
"0.6926862",
"0.69143933",
"0.6826594",
"0.6811169",
"0.6744435",
"0.67179465",
"0.67179465",
"0.67016524",
"0.6675778",
"0.665093",
"0.6578835",
"0.6561285",
"0.6492736",
"0.6489264",
"0.6468228",
"0.6412572",
"0.6411905",
"0.6411905",
"0.6352755",... | 0.7099165 | 1 |
Find live connections except those mentioned in array, because they are already dead. | def find_next_except_these connections
invalid_connections = @backend_connections.select { |x| connections.include?(x.server_info) }
@backend_connections.delete_if { |x| connections.include?(x.server_info) }
@round_robin = (0...@backend_connections.length).to_a
invalid_connections.each do |x|
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def live_neighbours\n self.neighbours.select do |n|\n n && n.is_alive?\n end\n end",
"def resurrect_dead_connections!\n connections.dead.each { |c| c.resurrect! }\n end",
"def unconnected_probes\n observed_connections = Set.new\n connections.each do |conn|\n observed_conn... | [
"0.67868173",
"0.6353748",
"0.6309217",
"0.62521917",
"0.6147314",
"0.60850143",
"0.6004528",
"0.5976544",
"0.5964049",
"0.5702709",
"0.5679856",
"0.56768495",
"0.56207675",
"0.5598569",
"0.5592869",
"0.54755175",
"0.5466129",
"0.54577994",
"0.5457599",
"0.5452483",
"0.543394... | 0.6228788 | 4 |
Fina a connection by host name and port | def find_connection host_info
conn = @backend_connections.detect { |x| x.server_info == host_info }
raise NoServerAvailable.new("BackgrounDRb server is not found running on #{host_info}") unless conn
return conn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_connect(body)\n host = _pop_token(body)\n port = _pop_token(body).to_i\n if host.length < 1\n begin\n host, port = @var[:last_connection]\n rescue\n raise \"usage: /connect <hostname> [port]\"\n end\n end\n port = 9000 if port == 0\n begin\n connect(host, port)\n @var[:last... | [
"0.6963155",
"0.6958152",
"0.69189584",
"0.66422284",
"0.6608101",
"0.66063154",
"0.65560484",
"0.655131",
"0.6549774",
"0.6537549",
"0.65207833",
"0.6506622",
"0.64691544",
"0.64485484",
"0.64443445",
"0.63930655",
"0.63876575",
"0.6383172",
"0.6346155",
"0.63372755",
"0.631... | 0.0 | -1 |
find the local configured connection | def find_local
find_connection("#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:ip]}:#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:port]}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conn\n\t\treturn @conn ||= self.connect\n\tend",
"def get_db_conn\n mongo = nil\n configure :development do\n mongo = Mongo::MongoClient.new('localhost', 27017).db('ddp')\n end\n configure :production do\n mongo = get_remote_connection\n end\n\n #retun connection\n mongo\n end... | [
"0.6640432",
"0.6539895",
"0.6510178",
"0.64693165",
"0.64692324",
"0.6461957",
"0.64516675",
"0.64343923",
"0.6421453",
"0.63956326",
"0.6379554",
"0.6370063",
"0.6316829",
"0.6306686",
"0.62851006",
"0.62837994",
"0.62813705",
"0.6261312",
"0.62353927",
"0.62281036",
"0.622... | 0.76514256 | 0 |
return the worker proxy | def worker(worker_name,worker_key = nil)
update_stats
RailsWorkerProxy.new(worker_name,worker_key,self)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proxy\n return @proxy\n end",
"def proxy\n @proxy\n end",
"def proxy\n @proxy ||= Proxy.new self\n end",
"def proxy; self end",
"def proxy\n manager_instance(ProxyManager)\n end",
"def __proxy_result__\n @thread.join if @thread && @thread... | [
"0.7579001",
"0.7385312",
"0.7129743",
"0.6647349",
"0.6573572",
"0.6554234",
"0.6554234",
"0.65130967",
"0.64918905",
"0.6397488",
"0.6397488",
"0.6397488",
"0.62850875",
"0.6248578",
"0.6217216",
"0.62137526",
"0.6178733",
"0.6178733",
"0.617546",
"0.6163984",
"0.6163306",
... | 0.61019003 | 23 |
Update the stats and discover new nodes if they came up. | def update_stats
@request_count += 1
discover_server_periodically if(time_to_discover? && !@disconnected_connections.empty?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_node_info_cache()\n @all_stats = []\n @nodes.each { |node|\n ip = node.private_ip\n acc = AppControllerClient.new(ip, @@secret)\n\n begin\n @all_stats << acc.get_stats()\n rescue FailedNodeException\n Djinn.log_warn(\"Failed to get status update from node at #{ip}... | [
"0.7586017",
"0.6404108",
"0.6243333",
"0.6238122",
"0.6201604",
"0.612079",
"0.61026865",
"0.6024497",
"0.60125273",
"0.593072",
"0.5886217",
"0.5877398",
"0.5859355",
"0.5840527",
"0.5827332",
"0.58256435",
"0.579957",
"0.57888585",
"0.5774592",
"0.5723694",
"0.5711678",
... | 0.70602787 | 1 |
Check if, we should try to discover new bdrb servers | def time_to_discover?
if((@request_count%10 == 0) or (Time.now > (@last_polled_time + 10.seconds)))
@last_polled_time = Time.now
return true
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_server\n raise Exception.new(\"Could not reach Apocalypse server please check the address and port and try again.\") unless server_reachable?\n end",
"def unavailable_servers_check\n # Return unless there are servers that are unavailable.\n return unless @unavailable_servers&.... | [
"0.61489105",
"0.60756403",
"0.59978515",
"0.5925955",
"0.58976054",
"0.58961076",
"0.58623147",
"0.58590645",
"0.57456833",
"0.57255125",
"0.57227737",
"0.57113326",
"0.56976765",
"0.5684553",
"0.5661205",
"0.5620546",
"0.5620546",
"0.5620546",
"0.5617895",
"0.5617359",
"0.5... | 0.51928174 | 91 |
Send worker information of all currently running workers from all configured bdrb servers | def all_worker_info
update_stats
info_data = {}
@backend_connections.each do |t_connection|
info_data[t_connection.server_info] = t_connection.all_worker_info rescue nil
end
return info_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def workers\n if known?\n @workers\n else\n know heroku_get_workers\n end\n end",
"def workers\n result = {}\n\n @servers.each do |server|\n\n\n sock=socket server\n if sock.nil?\n result[server] = \"unable to connect to server\" if sock.nil?\n\n ... | [
"0.6800493",
"0.66477734",
"0.6590264",
"0.65490675",
"0.6498326",
"0.6432259",
"0.6413751",
"0.63603693",
"0.6347667",
"0.6346913",
"0.63300866",
"0.6293857",
"0.6290806",
"0.6240705",
"0.6127479",
"0.61128074",
"0.60951334",
"0.6085447",
"0.5925323",
"0.5925323",
"0.5918051... | 0.7126929 | 0 |
one of the backend connections are chosen and worker is started on it | def new_worker(options = {})
update_stats
succeeded = false
result = nil
@backend_connections.each do |connection|
begin
result = connection.new_worker(options)
succeeded = true
rescue BdrbConnError; end
end
raise NoServerAvailable.new("No Backgro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_connection(conn)\n @backends.delete_if { |b| b.dead? }\n logger.debug \"Server:on_connection #{conn} backends #{@backends.count} loads #{@backends.map {|x| x.load}.inspect}\" if logger\n raise ::Heroku::Forward::Errors::BackendFailedToStartError.new if @backends.empty?\n ... | [
"0.67359805",
"0.6388938",
"0.6187251",
"0.6187251",
"0.6096601",
"0.6034333",
"0.6023681",
"0.6002822",
"0.59832776",
"0.5959083",
"0.5882553",
"0.5877238",
"0.586612",
"0.58267134",
"0.5767701",
"0.5729303",
"0.5710896",
"0.57087135",
"0.5704638",
"0.57031626",
"0.57030904"... | 0.5774391 | 14 |
choose a server in round robin manner. | def choose_server
if @round_robin.empty?
@round_robin = (0...@backend_connections.length).to_a
end
if @round_robin.empty? && @backend_connections.empty?
discover_server_periodically
raise NoServerAvailable.new("No BackgrounDRb server is found running") if @round_robin.empty? &&... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_server\n compute.servers.map { |s| [s.name, s.id] }\n end",
"def switch_server\n self.connection = nil\n servers << servers.shift\n end",
"def next\n @server\n end",
"def available(server)\n available_connections(server).pop || make_new(server)\n end",
"def selec... | [
"0.63139117",
"0.62591857",
"0.6240648",
"0.61686677",
"0.616389",
"0.6061973",
"0.6056626",
"0.60068345",
"0.5996559",
"0.5987265",
"0.59482604",
"0.5877202",
"0.58486336",
"0.5829915",
"0.5827921",
"0.5819526",
"0.5724076",
"0.57112455",
"0.5700058",
"0.5666263",
"0.5642221... | 0.71050113 | 0 |
=begin Copyright 20062008 the V8 project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the fol... | def encodeURIComponent(componentString)
::URI::URIEncodeComponent(componentString)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_string_ex; end",
"def url_encode(string) \r\n encoded_string = ''\r\n string.each_char do |char|\r\n char = (\"%%%02X\" % char.ord) if char.match(/[A-Za-z0-9]/) == nil\r\n encoded_string << char\r\n end\r\n return encoded_string\r\n end",
"def url_encode(string) \r\n encoded... | [
"0.55740696",
"0.55436206",
"0.55436206",
"0.5534644",
"0.5534061",
"0.53202385",
"0.5256516",
"0.5218073",
"0.51883304",
"0.5177771",
"0.5161475",
"0.51280713",
"0.51190186",
"0.51151645",
"0.5104644",
"0.5075727",
"0.50694495",
"0.50589395",
"0.5043371",
"0.5043219",
"0.502... | 0.5885299 | 0 |
component must be String | def URIEncodeComponent(componentString)
Encode(componentString, :unescapePredicate);
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def component_present\n if component.nil?\n errors.add(:component, 'is not valid.')\n end\n end",
"def valid?(component)\n true\n end",
"def visitComponent component,args=nil\n name=component.name\n type=component.type\n \"component :#{name} => #{type.capitalize}\"\n end",... | [
"0.66847557",
"0.6398965",
"0.6386892",
"0.62524426",
"0.60941964",
"0.60575044",
"0.59769225",
"0.59567916",
"0.5943029",
"0.5893118",
"0.5840735",
"0.5818399",
"0.5801706",
"0.5775215",
"0.5733513",
"0.56699544",
"0.56215096",
"0.5609815",
"0.5602866",
"0.5584538",
"0.55428... | 0.0 | -1 |
Feel free to google "how to generate a random number in ruby" | def roll
# code goes here
myArray = ['1', '2', '3', '4', '5', '6']
puts myArray
puts myArray[rand(myArray.length)]
Integer(myArray[rand(myArray.length)])
#myArray[rand(myArray.length)]
#rand(1..6)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_number\r\n return randomNumber = 1 + rand(100)\r\n end",
"def get_random_number()\n rand(0x7fffffff).to_s\nend",
"def gen_num\n rand(1..100)\nend",
"def random_number\n t = Time.now.to_f / (Time.now.to_f % Time.now.to_i)\n random_seed = t * 1103515245 + 12345;\n (random_seed / 655... | [
"0.8495249",
"0.83665675",
"0.8312836",
"0.8223235",
"0.8188632",
"0.81023866",
"0.8082494",
"0.80452955",
"0.80336106",
"0.8030636",
"0.8030636",
"0.80123246",
"0.79662156",
"0.7955537",
"0.7934739",
"0.7909762",
"0.78774667",
"0.78719956",
"0.78630906",
"0.78546405",
"0.781... | 0.0 | -1 |
GET /asanas GET /asanas.json | def index
@asanas = Asana.joins(:exercise).merge(Exercise.order(:name)).order(:family_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @sala = Sala.find(params[:id])\n\n render json: @sala, root: \"data\", include: '**', adapter: :json, status: :ok\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n ... | [
"0.64741975",
"0.6450691",
"0.6450691",
"0.6388076",
"0.6292111",
"0.62849617",
"0.6283308",
"0.62745726",
"0.6270093",
"0.6268471",
"0.6265812",
"0.6262482",
"0.6252009",
"0.62378776",
"0.62320215",
"0.6227566",
"0.6225495",
"0.62177074",
"0.6208354",
"0.62015826",
"0.620129... | 0.0 | -1 |
GET /asanas/1 GET /asanas/1.json | def show; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @sala = Sala.find(params[:id])\n\n render json: @sala, root: \"data\", include: '**', adapter: :json, status: :ok\n end",
"def show\n @vachana = Vachana.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vachana }\n end\n ... | [
"0.6466704",
"0.6442568",
"0.6442568",
"0.6386861",
"0.6385092",
"0.6343658",
"0.6339805",
"0.63309896",
"0.63200986",
"0.62970054",
"0.62958264",
"0.6290633",
"0.6276254",
"0.62711215",
"0.6249373",
"0.62302566",
"0.62196493",
"0.6197275",
"0.6194641",
"0.61869025",
"0.61773... | 0.0 | -1 |
POST /asanas POST /asanas.json | def create
@asana = Asana.new(asana_params)
respond_to do |format|
if @asana.save
format.html { redirect_to @asana, notice: 'Asana criado com sucesso.' }
format.json { render :show, status: :created, location: @asana }
else
format.html { render :new }
format.json { r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def post_spoonacular\n # %encode ingredients to url\n encoded_ingr = URI.escape(@translated_recipe[:ingredients_list])\n # post call block :\n... | [
"0.62142646",
"0.6157509",
"0.6144492",
"0.6091369",
"0.6069187",
"0.606698",
"0.60306704",
"0.60192406",
"0.6007616",
"0.5989976",
"0.5989851",
"0.59437853",
"0.5910471",
"0.58869123",
"0.5879283",
"0.5838797",
"0.5837029",
"0.58351773",
"0.58341056",
"0.58308697",
"0.583012... | 0.63904315 | 0 |
PATCH/PUT /asanas/1 PATCH/PUT /asanas/1.json | def update
respond_to do |format|
if @asana.update(asana_params)
format.html { redirect_to @asana, notice: 'Asana atualizado com sucesso.' }
format.json { render :show, status: :ok, location: @asana }
else
format.html { render :edit }
format.json { render json: @asana.err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch!\n request! :patch\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :pat... | [
"0.6854013",
"0.6778955",
"0.64784384",
"0.64591855",
"0.64414656",
"0.64414656",
"0.635757",
"0.63534933",
"0.63525826",
"0.6290294",
"0.62778383",
"0.6274491",
"0.6255972",
"0.6211508",
"0.6211508",
"0.61897767",
"0.61897767",
"0.6109468",
"0.61065614",
"0.6067725",
"0.6067... | 0.576925 | 54 |
DELETE /asanas/1 DELETE /asanas/1.json | def destroy
@asana.destroy
respond_to do |format|
format.html { redirect_to asanas_url, notice: 'Asana excluído com sucesso.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete\n render json: Alien.delete(params[\"id\"])\n end",
"def delet... | [
"0.7326207",
"0.72614926",
"0.7079496",
"0.7014899",
"0.6998341",
"0.69722426",
"0.6907703",
"0.69047415",
"0.6859575",
"0.6857132",
"0.6834509",
"0.6809785",
"0.67948407",
"0.6780148",
"0.67765856",
"0.677561",
"0.67673427",
"0.67673427",
"0.6762091",
"0.67607486",
"0.672361... | 0.6433334 | 86 |
Use callbacks to share common setup or constraints between actions. | def set_asana
exercise = Exercise.find_by(slug: params[:slug])
raise ActiveRecord::RecordNotFound unless exercise
@asana ||= exercise&.content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def asana_params
params.require(:asana).permit(
:translation,
:family_id,
:advanced_actions,
:connections,
:observe,
:benefits,
:caution,
:contraindications,
:content,
:setup,
:entering,
:legs,
:core,
:trunk,
:arms,
:hea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Create a new Chef::DataBagItem | def initialize(chef_server_rest: nil)
@data_bag = nil
@raw_data = Mash.new
@chef_server_rest = chef_server_rest
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_item(data_bag, item_name, data = {}, metadata = {})\n item = ::SecureDataBag::Item.new(metadata)\n item.raw_data = { 'id' => item_name }.merge(data)\n item.data_bag data_bag\n item\n end",
"def create_data_bag_item(bag, item, value)\n unless data_bag_item_ex... | [
"0.8240729",
"0.7829642",
"0.74055153",
"0.6852948",
"0.65775305",
"0.64215535",
"0.6355829",
"0.6277713",
"0.62118",
"0.61099654",
"0.6085725",
"0.60855955",
"0.6055589",
"0.6046265",
"0.6026703",
"0.60262614",
"0.59584713",
"0.59207433",
"0.59207255",
"0.5914139",
"0.589897... | 0.0 | -1 |
Serialize this object as a hash | def to_json(*a)
result = {
"name" => object_name,
"json_class" => self.class.name,
"chef_type" => "data_bag_item",
"data_bag" => data_bag,
"raw_data" => raw_data,
}
Chef::JSONCompat.to_json(result, *a)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize\n JSON.dump(@hash)\n end",
"def to_hash\n @_hash_\n end",
"def to_hash\n @hash\n end",
"def serialize\n self.to_hash.to_json\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def hash\n to_s.hash\n end",
... | [
"0.81276625",
"0.7785287",
"0.7754545",
"0.77381307",
"0.76660955",
"0.76660955",
"0.75481015",
"0.752644",
"0.75174963",
"0.7509108",
"0.75017565",
"0.74726546",
"0.74401784",
"0.74401784",
"0.74401784",
"0.742879",
"0.7408174",
"0.7393062",
"0.73829573",
"0.7357966",
"0.734... | 0.0 | -1 |
Save this Data Bag Item via RESTful API | def save(item_id = @raw_data["id"])
r = chef_server_rest
begin
if Chef::Config[:why_run]
Chef::Log.warn("In why-run mode, so NOT performing data bag item save.")
else
r.put("data/#{data_bag}/#{item_id}", self)
end
rescue Net::HTTPClientException => e
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n method, path = id ? [:post, :update] : [:put, :create]\n self.attributes = Connection.send(method, create_route(path), attributes_without_blanks).body['data']\n self\n end",
"def save\n if new_record?\n overwrite @api.post(\"/meetings/#{meeting.shortcode_url}/items.json\",\n ... | [
"0.6632395",
"0.66288227",
"0.6602629",
"0.65995675",
"0.65512246",
"0.6530977",
"0.64825827",
"0.64817667",
"0.64649725",
"0.6416989",
"0.6403048",
"0.63206935",
"0.63086814",
"0.6300408",
"0.62689567",
"0.62675256",
"0.62606794",
"0.62576306",
"0.6255888",
"0.62490916",
"0.... | 0.76430017 | 0 |
Create this Data Bag Item via RESTful API | def create
chef_server_rest.post("data/#{data_bag}", self)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_item(data_bag, item_name, data = {}, metadata = {})\n item = ::SecureDataBag::Item.new(metadata)\n item.raw_data = { 'id' => item_name }.merge(data)\n item.data_bag data_bag\n item\n end",
"def create\n # defined object to receive strict item_params in... | [
"0.743095",
"0.7268267",
"0.70016277",
"0.6961897",
"0.69579524",
"0.69188625",
"0.68935263",
"0.6889679",
"0.6886641",
"0.6844617",
"0.6842436",
"0.67734605",
"0.6745067",
"0.6712992",
"0.6699835",
"0.66924566",
"0.66805416",
"0.6654137",
"0.66516817",
"0.6630951",
"0.660009... | 0.7417999 | 1 |
Creates this RTSP profile. | def create
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if args.blank?\n error \"Please supply the name for the profile you'd like to create\"\n end\n\n Strongspace::Command.run_internal(\"auth:check\", nil)\n\n if new_profile = ask_for_new_rsync_profile\n add_profile(new_profile)\n\n if args[3] and args[3] == \"sch... | [
"0.68870723",
"0.6695219",
"0.646176",
"0.63764495",
"0.6307138",
"0.62477463",
"0.6162191",
"0.61386937",
"0.61342424",
"0.61294806",
"0.6063301",
"0.6058073",
"0.60542923",
"0.60349345",
"0.59935313",
"0.5991946",
"0.59486794",
"0.59410787",
"0.58827174",
"0.5876568",
"0.58... | 0.0 | -1 |
Deletes all RTSP profile. | def delete_all_profiles
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_all_profiles\n super\n end",
"def destroy\n @profile.destroy\n end",
"def destroy\n @profile.destroy\n @profile.requests.destroy_all\n @profile.member.destroy\n respond_to do |format|\n format.html { redirect_to profiles_url, notice: 'El perfil fue eliminado exitosamente... | [
"0.6601341",
"0.62867165",
"0.6088836",
"0.6055473",
"0.60162616",
"0.6011098",
"0.60039383",
"0.5994199",
"0.5994199",
"0.5991801",
"0.5931767",
"0.5930769",
"0.590397",
"0.58922464",
"0.58868337",
"0.5877435",
"0.5877435",
"0.5877435",
"0.5877435",
"0.5877435",
"0.5876463",... | 0.69172657 | 7 |
Deletes this RTSP profile. | def delete_profile
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @profile.destroy\n end",
"def destroy\n @user_profile = UserProfile.find(params[:id])\n @user_profile.destroy\n\n format.html { redirect_to(user_profiles_url) }\n end",
"def destroy\n @profile = Profile.find(params[:id])\n @profile.destroy\n end",
"def destroy\n\t\t@profile... | [
"0.6971887",
"0.6891237",
"0.68853074",
"0.6787424",
"0.6771902",
"0.6756531",
"0.6684711",
"0.66793215",
"0.66793215",
"0.667683",
"0.6666987",
"0.6666987",
"0.6666987",
"0.6666987",
"0.6666987",
"0.6661079",
"0.66414016",
"0.66301674",
"0.66237247",
"0.65925777",
"0.6560958... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.