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 |
|---|---|---|---|---|---|---|
downloading file to the disk and then reading that file, this will allow us to read large S3 files without exhausting resources/crashing the system | def download_and_process_file?(file_name)
Rails.logger.info "processing file: #{file_name}"
@form_count = 0
@error_count = 0
file_details = parse_file_name(file_name)
return false if file_details.blank?
# downloads S3 file into local file, allows for processing large files this w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_s3_file\n run_callbacks :download_s3_file do\n @s3_local_object = download(@directory, @key)\n end\n end",
"def download_file\n run_callbacks :download_file do\n if attachment.stored_at_s3?\n @s3_file_processor = S3::ProcessFiles.new(attachment)\n s3... | [
"0.76967794",
"0.71969587",
"0.71747994",
"0.7142552",
"0.6963291",
"0.6862504",
"0.68591654",
"0.6842448",
"0.67773116",
"0.674888",
"0.6712193",
"0.66880006",
"0.661093",
"0.65926147",
"0.6532359",
"0.65115345",
"0.6506801",
"0.6496558",
"0.64838916",
"0.6474256",
"0.647066... | 0.5991616 | 63 |
Run registered jobs. ==== Args [current_expire] expire for processing (secs, 0=unexpired) ==== Return self | def run(current_expire = @expire)
if 0 == current_expire
run_once while not empty?
else
@end_time = Time.new.to_f + @expire
run_once while not(empty?) and @end_time >= Time.new.to_f
@end_time = nil
end
if @remain_hook
@remain_received = !empty?
@re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule_recurring_jobs\n EmbargoAutoExpiryJob.perform_later(account)\n LeaseAutoExpiryJob.perform_later(account)\n end",
"def perform_now\n raise(::Mongoid::Errors::Validations, self) unless valid?\n\n worker = RocketJob::Worker.new(inline: true)\n start if may_start?\n ... | [
"0.52272254",
"0.4739352",
"0.4690504",
"0.46370155",
"0.45082107",
"0.4501472",
"0.4485635",
"0.4468313",
"0.4468313",
"0.4468308",
"0.44597876",
"0.44346276",
"0.44338608",
"0.4421992",
"0.4410304",
"0.43888772",
"0.43817842",
"0.43430975",
"0.43101612",
"0.4306353",
"0.428... | 0.65313315 | 0 |
Run a job and forward pointer. ==== Return self | def run_once
if @first_pointer
@busy = true
procedure = forward
procedure = forward while @first_pointer and procedure.canceled?
procedure.run unless procedure.canceled?
end
ensure
@busy = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n case self[:job]\n when Proc\n self[:job].call\n else\n self[:job]\n end\n end",
"def run_job\n end",
"def run!\n TaskServerLogger.instance.error \"Executing job id #{self.id}, #{self.to_s}...\"\n begin\n self.last_run_at = Time.zone.now\n self.nex... | [
"0.70431983",
"0.6526396",
"0.62789714",
"0.62318945",
"0.61395353",
"0.6130733",
"0.61299556",
"0.6091892",
"0.60844254",
"0.6040589",
"0.59648025",
"0.59125257",
"0.5862717",
"0.5832787",
"0.5824651",
"0.5821299",
"0.5800369",
"0.57902586",
"0.57861924",
"0.578216",
"0.5778... | 0.0 | -1 |
Return if some jobs processing now. ==== Args [args] ==== Return true if Delayer processing job | def busy?
@busy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_jobs_hve_been_processed?(queue)\n (job_count(queue) == 0) && (working_job_count(queue) <= 1)\n end",
"def eop?\n @jobs.empty?\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def processing?\n return false if self.batch.blank?\n return false if !self.bat... | [
"0.6854574",
"0.67004204",
"0.6669079",
"0.6595723",
"0.6595723",
"0.65343857",
"0.6525657",
"0.6487264",
"0.64833665",
"0.6463926",
"0.64392865",
"0.6434155",
"0.6428885",
"0.6404588",
"0.64035004",
"0.6400523",
"0.63845074",
"0.6366995",
"0.63599885",
"0.6354189",
"0.634708... | 0.0 | -1 |
Return true if no jobs has. ==== Return true if no jobs has. | def empty?
!@first_pointer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eop?\n @jobs.empty?\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def has_job?(job_name)\n jobs.exists?(job_name)\n end",
"def all_jobs_hve_been_processed?(queue)\n (job_count(queue) == 0) && (working_job_count(queue) <= 1)\n end",
"def has_job_pr... | [
"0.8507919",
"0.778034",
"0.7635272",
"0.7491267",
"0.7461306",
"0.730035",
"0.7146288",
"0.7036515",
"0.69870913",
"0.694431",
"0.6943504",
"0.68761075",
"0.6840493",
"0.68226695",
"0.6787725",
"0.67861354",
"0.6744073",
"0.67409444",
"0.6735555",
"0.6730775",
"0.67303926",
... | 0.0 | -1 |
Return remain jobs quantity. ==== Return Count of remain jobs | def size(node = @first_pointer)
if node
1 + size(node.next)
else
0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending_job_count\n\n @pending_jobs.size\n end",
"def jobs_performed\n Resque.redis.get(jobs_performed_key).to_i\n end",
"def complete_check_count\r\n check_number = []\r\n self.jobs.each do |job|\r\n if job.job_status = JobStatus::COMPLETED\r\n check_number << jo... | [
"0.7782873",
"0.7174962",
"0.70194036",
"0.70018005",
"0.6936034",
"0.6923153",
"0.6765832",
"0.67033696",
"0.67028147",
"0.6607347",
"0.6583595",
"0.6573486",
"0.6573486",
"0.64835614",
"0.6480092",
"0.6480092",
"0.6439144",
"0.6410101",
"0.63951886",
"0.63694125",
"0.634379... | 0.0 | -1 |
register new job. ==== Args [procedure] job(Delayer::Procedure) ==== Return self | def register(procedure)
lock.synchronize do
if @last_pointer
@last_pointer = @last_pointer.break procedure
else
@last_pointer = @first_pointer = procedure
end
if @remain_hook and not @remain_received
@remain_received = true
@remain_hook.call
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_job(job)\n @stream.add_message(job.to_message)\n job\n end",
"def job=(job)\n @job = job\n end",
"def job=(job)\n @job = job\n end",
"def enqueue(job)\n @jobs ||= {}\n @jobs[job.key] = {}\n\n self.save\n end",
"def add_job(job_def)\n\t\t\tjob = JobBuilder.new(... | [
"0.6294539",
"0.6210864",
"0.6163173",
"0.61373377",
"0.60448307",
"0.59881175",
"0.5910839",
"0.5843558",
"0.58221287",
"0.5782402",
"0.5760604",
"0.57446545",
"0.573852",
"0.5684736",
"0.56588286",
"0.5637527",
"0.5607542",
"0.5581098",
"0.556459",
"0.5517109",
"0.54985875"... | 0.6002835 | 5 |
NO CAPITAL LETTER FOR VARIABLES | def initialize(name, x_o)
@name= name
@x_o= x_o
@chosen= Array.new
@reach= Array.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscore_vars\r\n self.gsub(/\\b[a-z][a-z]*(?:[A-Z][a-z]*)(?:[A-Z][a-z]*)*\\b/) {|word|\r\n word.underscore\r\n }\r\n end",
"def unusualCapitalization(*x); field('unusualCapitalization', *x) end",
"def new_var\n ('A'..'Z').to_a.each do |letter|\n if !vars.include?(letter)\n var... | [
"0.6738861",
"0.6530359",
"0.64228284",
"0.63078254",
"0.6243661",
"0.6239441",
"0.61731315",
"0.6168101",
"0.61481297",
"0.6122314",
"0.6108365",
"0.6105782",
"0.6059997",
"0.6058601",
"0.60455394",
"0.5989471",
"0.594478",
"0.5941",
"0.5920999",
"0.5902168",
"0.58866817",
... | 0.0 | -1 |
check if the selected coordinates are inside of reach | def check_bingo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend",
"def include?(pnt)\n pnt.lat >= south && pnt.lng >= west && pnt.lat < north && pnt.lng < east\n end",
"def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..... | [
"0.70325416",
"0.6989404",
"0.6918739",
"0.6804073",
"0.6769021",
"0.6758789",
"0.67091227",
"0.6674856",
"0.6654147",
"0.66429985",
"0.6603973",
"0.6578133",
"0.6547872",
"0.6542676",
"0.6525282",
"0.651598",
"0.6500879",
"0.6447569",
"0.64433056",
"0.64049065",
"0.6391718",... | 0.0 | -1 |
create the array of coordinates (x, y) | def store_in_array(coordinate)
chosen.push(coordinate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coordinates\n arr = []\n (0...@size).each do |row|\n (0...@size).each do |column|\n arr << Coordinate.new(x: row,y: column)\n end\n end\n arr\n end",
"def to_xy\n [x, y]\n end",
"def coordinate_array\n\t\t[latitude,longitude]\n\tend",
"def to_a\n ... | [
"0.8378823",
"0.82199997",
"0.802542",
"0.7833199",
"0.78003895",
"0.7717408",
"0.7712346",
"0.76843995",
"0.76486474",
"0.7491063",
"0.7427675",
"0.7427582",
"0.7363452",
"0.73567325",
"0.729675",
"0.72708887",
"0.7259008",
"0.72423905",
"0.72154963",
"0.71543556",
"0.711136... | 0.0 | -1 |
Add url from object and calls get request on specified url. | def get_custom_url(custom_url, params = {})
params = Params.define_params(params, @config)
Request.get_response("#{@url}/#{custom_url}", @project_id, params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(url); end",
"def get(url)\n call(url: url)\n end",
"def call(url, **options)\n self.class.get url, options\n end",
"def get_request\n# Use our @http_object object's request method to call the\n# Net::HTTP::Get class and return the resulting response object\n @http_object.request(Net::HTT... | [
"0.7186726",
"0.6792118",
"0.677997",
"0.6685166",
"0.66779363",
"0.6450926",
"0.62994295",
"0.6298646",
"0.6282261",
"0.6277992",
"0.62672895",
"0.61857253",
"0.6154108",
"0.61526364",
"0.6137064",
"0.6132324",
"0.61244875",
"0.61123127",
"0.61064374",
"0.6105405",
"0.607720... | 0.0 | -1 |
Return a string with a link to documentation. | def get_help_info
'See the documentation here - https://github.com/blockfrost/blockfrost-ruby'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_documentation; end",
"def documentation_url; end",
"def documentation\n return Addressable::URI.parse(@discovery_document['documentationLink'])\n end",
"def link_markup(descr = nil)\n descr = \"View resource.\" if descr == nil\n\n link = @reference_action_def.doi\n link = ... | [
"0.7857884",
"0.75622004",
"0.72409743",
"0.7212329",
"0.70768553",
"0.67924726",
"0.6751909",
"0.66587406",
"0.6622119",
"0.6590554",
"0.65875274",
"0.6561499",
"0.65330327",
"0.6528061",
"0.6528061",
"0.6510836",
"0.65065944",
"0.65065944",
"0.65065944",
"0.65065944",
"0.64... | 0.0 | -1 |
GET /web/v1/social_media_links GET /web/v1/social_media_links.json | def index
@social_media_links = SocialMediaLink.all
render json: @social_media_links
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render json: @social_media_link\n end",
"def index\n @links = @site.site_social_links\n end",
"def get_links(blob)\n\n #Rails.logger.info(\"[LIB] [SOCIAL_FETCH] [FETCHER] [FACEBOOK] [get_links] Entering\")\n link = []\n\n if !blob[\"link\"].blank?\n\n ... | [
"0.73398477",
"0.65911365",
"0.6394536",
"0.63804704",
"0.6343071",
"0.6333199",
"0.63124585",
"0.62049234",
"0.61928505",
"0.61536324",
"0.61536324",
"0.6147549",
"0.6114166",
"0.60973096",
"0.602091",
"0.59950614",
"0.5990805",
"0.5989481",
"0.5917229",
"0.5903546",
"0.5878... | 0.79115915 | 0 |
GET /web/v1/social_media_links/1 GET /web/v1/social_media_links/1.json | def show
render json: @social_media_link
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @social_media_links = SocialMediaLink.all\n\n render json: @social_media_links\n end",
"def create\n @social_media_link = SocialMediaLink.new(social_media_link_params)\n\n if @social_media_link.save\n render json: @social_media_link, status: :created\n else\n render json: @s... | [
"0.7789854",
"0.64317495",
"0.64153606",
"0.6374051",
"0.6329446",
"0.6279789",
"0.6270436",
"0.6225349",
"0.6202388",
"0.6174492",
"0.6136873",
"0.6134985",
"0.6062893",
"0.605313",
"0.6020355",
"0.601451",
"0.60135466",
"0.600149",
"0.59962684",
"0.59678173",
"0.5967527",
... | 0.7483295 | 1 |
POST /web/v1/social_media_links POST /web/v1/social_media_links.json | def create
@social_media_link = SocialMediaLink.new(social_media_link_params)
if @social_media_link.save
render json: @social_media_link, status: :created
else
render json: @social_media_link.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @social_media_links = SocialMediaLink.all\n\n render json: @social_media_links\n end",
"def social_link_params\n params.require(:social_media_link).permit(:title, :url, :image_url)\n end",
"def create\n @link = current_user.links.new link_params\n create_and_respond(@link)\n end",... | [
"0.68485725",
"0.65721136",
"0.63500565",
"0.63243645",
"0.63008666",
"0.63003147",
"0.6095128",
"0.6095128",
"0.6065061",
"0.6063351",
"0.60328966",
"0.60203314",
"0.6003894",
"0.5997145",
"0.5907603",
"0.59010804",
"0.587946",
"0.5877939",
"0.58765703",
"0.58732164",
"0.584... | 0.7651989 | 0 |
PATCH/PUT /web/v1/social_media_links/1 PATCH/PUT /web/v1/social_media_links/1.json | def update
@social_media_link = SocialMediaLink.find(params[:id])
if @social_media_link.update(social_media_link_params)
head :no_content
else
render json: @social_media_link.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n update_and_respond(@link, link_params)\n end",
"def update\n @link = Link.find(params[:id])\n paginate_all_links\n respond_to do |format|\n if @link.update_attributes(params[:link])\n format.html { redirect_to root_url+\"#show-links\", notice: 'Link was successfully updated.... | [
"0.6750588",
"0.65170574",
"0.643401",
"0.639264",
"0.63316154",
"0.6331006",
"0.6331006",
"0.6295515",
"0.6276486",
"0.6236992",
"0.61880696",
"0.61870164",
"0.61870164",
"0.61870164",
"0.61870164",
"0.61870164",
"0.6184048",
"0.6168081",
"0.61482316",
"0.61446023",
"0.61338... | 0.7439518 | 0 |
DELETE /web/v1/social_media_links/1 DELETE /web/v1/social_media_links/1.json | def destroy
@social_media_link.destroy
head :no_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @socialmediasite.destroy\n respond_to do |format|\n format.html { redirect_to socialmediasites_url }\n format.json { head :no_content }\n end\n end",
"def deleteEntitySocialmedia( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'... | [
"0.73718107",
"0.71441627",
"0.71324843",
"0.7110764",
"0.7102097",
"0.70915425",
"0.7089046",
"0.707747",
"0.707747",
"0.707747",
"0.7061057",
"0.7054068",
"0.70427334",
"0.70143884",
"0.70143884",
"0.6983173",
"0.69804746",
"0.6972959",
"0.6968577",
"0.6955308",
"0.69397485... | 0.77380455 | 0 |
a new Array that contains all elements from both Array arguments, with the elements taken in alternation. You may assume that both input Arrays are nonempty, and that they have the same number of elements. Example: interleave([1, 2, 3], ['a', 'b', 'c']) == [1, 'a', 2, 'b', 3, 'c'] PEDAC: Understand the Problem: > Input... | def interleave(arr1, arr2)
return_array = []
counter = 1
until arr2.empty?
if counter.odd?
return_array << arr1.shift
counter += 1
else
return_array << arr2.shift
counter += 1
end
end
return_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interleave(arr1, arr2)\n new_array = []\n for i in 1..(arr1.size)\n new_array << arr1[(i-1)]\n new_array << arr2[(i-1)]\n end\n new_array\nend",
"def interleave(arr1, arr2)\n return_array = arr1.zip(arr2).flatten\nend",
"def interleave(array1, array2)\n return_array = []\n\n until array2.empty... | [
"0.83356833",
"0.82461077",
"0.82441443",
"0.8215452",
"0.82132375",
"0.8199686",
"0.81798327",
"0.8177549",
"0.81753564",
"0.81345946",
"0.8131501",
"0.8131501",
"0.8131501",
"0.8127481",
"0.81217295",
"0.81110126",
"0.81100816",
"0.8109411",
"0.80852515",
"0.80760807",
"0.8... | 0.80003256 | 40 |
this array uses Enumerableeach_with_index to cycle through the index and shovel the indexed values of each arg arr in sequence | def interleave(arr1, arr2)
return_array = []
arr1.each_with_index do |element, index|
return_array << element << arr2[index]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each_with_index(arr)\n arr.size.times do |i|\n yield(arr[i], i)\n end\n arr\nend",
"def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end",
"def my_each_with_index\n return to_enum unless block_given?\n i = 0\n arra... | [
"0.7264312",
"0.69628876",
"0.68594354",
"0.6714278",
"0.667085",
"0.6637059",
"0.66255176",
"0.66085607",
"0.65933615",
"0.65340585",
"0.6524714",
"0.6521782",
"0.6521782",
"0.65022194",
"0.64909124",
"0.6473688",
"0.64562106",
"0.643974",
"0.6381347",
"0.63633674",
"0.63455... | 0.0 | -1 |
this makes use of the Arrayzip method to combine the two, requires a flatten | def interleave(arr1, arr2)
return_array = arr1.zip(arr2).flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip first, second\n first.zip(second).flatten()\nend",
"def zip_and_flatten(array1,array2)\t\n\t\t(array1.zip(array2)).flatten(1).reject{|x| x.nil?}\n\tend",
"def zip(first, second)\n first.zip(second).flatten\nend",
"def custom_zip(arr1, arr2)\n final=[]\n arr1.each_with_index do |item, index|\n... | [
"0.7900996",
"0.78792024",
"0.77941084",
"0.7689554",
"0.76665264",
"0.7619041",
"0.76187646",
"0.761795",
"0.7597096",
"0.7564523",
"0.7497517",
"0.7484006",
"0.7464832",
"0.74332714",
"0.7426128",
"0.7420991",
"0.74132323",
"0.7383795",
"0.73754126",
"0.73502827",
"0.733195... | 0.691795 | 49 |
Returns a ticket by ticket id ==== Attributes +id+ numerical unique id for record +format+ be sure to include an accept header or add ".xml" or ".json" to the last path element +token+ your API Token for authentication ==== Raises ERROR 403 Forbidden When the token is invalid. ERROR 404 Not found When record to show is... | def show
@ticket = Ticket.find(params[:id].to_i) rescue nil
respond_to do |format|
unless @ticket.blank?
format.xml { render :xml => ticket_presenter }
format.json { render :json => ticket_presenter }
else
format.xml { head :not_found }
format.json { head :not_found... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def get(ticket_id)\r\n\r\n # Validate required parameters\r\n if ticket_id == nil\r\n raise ArgumentError.new \"Required parameter 'ticket_id' cannot be nil.\"\r\n end\r\n\r\n # the base uri for api reque... | [
"0.79411954",
"0.7714045",
"0.76178676",
"0.7395754",
"0.6774969",
"0.6678969",
"0.66049993",
"0.6560623",
"0.6551755",
"0.64916295",
"0.6415602",
"0.640632",
"0.63868004",
"0.63689077",
"0.6347163",
"0.63452417",
"0.63293564",
"0.62909126",
"0.6193635",
"0.61785233",
"0.6178... | 0.6352766 | 14 |
Deletes a ticket ==== Attributes +id+ numerical unique id for record +format+ be sure to include an accept header or add ".xml" or ".json" to the last path element +token+ your API Token for authentication ==== Raises ERROR 403 Forbidden When the token is invalid. ERROR 404 Not found When no records are found. ==== Exa... | def destroy
@ticket = Ticket.find(params[:id].to_i) rescue nil
respond_to do |format|
if @ticket
success = @ticket.destroy rescue false
if success
format.xml { head :accepted }
format.json { head :accepted }
else
format.xml { render :xml => ticket_pres... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteTicket id\n \n APICall(path: \"tickets/#{id}.json\",method: 'DELETE')\n \n end",
"def delete_support_ticket_using_delete_with_http_info(support_ticket_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SupportApi.delete... | [
"0.798416",
"0.70793396",
"0.7019936",
"0.6979481",
"0.69711757",
"0.696552",
"0.696552",
"0.696552",
"0.696552",
"0.696552",
"0.696552",
"0.6903327",
"0.6896321",
"0.6894147",
"0.6894147",
"0.6894147",
"0.6894147",
"0.6883122",
"0.6882252",
"0.6882252",
"0.6882252",
"0.688... | 0.68873286 | 17 |
Private methods below helper for loading the tickets presenter | def tickets_presenter
@tickets_presenter ||= V1::TicketsPresenter.new(@tickets, @template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ticket_presenter\n @ticket_presenter ||= V1::TicketPresenter.new(@ticket, @template)\n end",
"def show_ticket\n end",
"def show_ticket_details(ticket_id)\n url = \"https://alanli1.zendesk.com/api/v2/tickets/#{ticket_id}.json\"\n\n res = ApiHelper.make_req_to_api(url)\n @ticket = find_ticket_d... | [
"0.6766",
"0.6431827",
"0.6115272",
"0.6099503",
"0.6064466",
"0.606041",
"0.6057969",
"0.60260427",
"0.60033655",
"0.5932982",
"0.5915612",
"0.58907574",
"0.5836348",
"0.57882744",
"0.57817584",
"0.5758822",
"0.57571864",
"0.57474613",
"0.57441497",
"0.57253516",
"0.5713772"... | 0.6993174 | 0 |
helper for loading the ticket present | def ticket_presenter
@ticket_presenter ||= V1::TicketPresenter.new(@ticket, @template)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_ticket_details(ticket_id)\n url = \"https://alanli1.zendesk.com/api/v2/tickets/#{ticket_id}.json\"\n\n res = ApiHelper.make_req_to_api(url)\n @ticket = find_ticket_details(res)\n @ticket.requester_name = get_user_name(@ticket.requester_id)\n return @ticket\n end",
"def ticket\n @tic... | [
"0.67572457",
"0.6753084",
"0.670794",
"0.66061914",
"0.6578672",
"0.65642905",
"0.6557784",
"0.6557784",
"0.6557784",
"0.6557784",
"0.6557784",
"0.6557784",
"0.6557784",
"0.6557784",
"0.653213",
"0.6505492",
"0.647389",
"0.6460158",
"0.6460158",
"0.6460158",
"0.6460158",
"... | 0.0 | -1 |
GET /articles GET /articles.json | def index
@articles = Article.find(:all, :order => "created_at DESC" )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def articles\n @articles = Article.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @administration }\n end\n end",
"def index\n @articles = Article.all\n\n respond_to do |format|\n format.json { render json: @articles }\n end\n end",
... | [
"0.7823242",
"0.7757662",
"0.77491444",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7650022",
"0.7612499",
"0.75499934",
"0.744125",
"0.73619306",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
"0.7355765",
... | 0.0 | -1 |
GET /articles/1 GET /articles/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @article = Article.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @articles }\n end\n end",
"def show\n @article = Article.where(id: params[:id]).last\n\n respond_to do |format|\n format.html # show.html.er... | [
"0.7745946",
"0.75169533",
"0.7514653",
"0.7483779",
"0.74794465",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.74741095",
"0.7427753",
... | 0.0 | -1 |
POST /articles POST /articles.json | def create
@article = Article.new(article_params)
respond_to do |format|
if @article.save
Article.get_barcode(@article.id)
format.html { redirect_to action: 'new', notice: 'Article was successfully created.' }
format.json { render action: 'show', status: :created, location: @artic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @article = Article.new(params[:article])\n\n respond_to do |format|\n if @article.save\n format.html { redirect_to @article, :notice => 'Article was successfully created.' }\n format.json { render :json => @article, :status => :created, :location => @article }\n else\n ... | [
"0.7153906",
"0.709067",
"0.709067",
"0.709067",
"0.709067",
"0.709067",
"0.709067",
"0.709067",
"0.709067",
"0.70851403",
"0.70658004",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056407",
"0.7056... | 0.0 | -1 |
PATCH/PUT /articles/1 PATCH/PUT /articles/1.json | def update
respond_to do |format|
if @article.update(article_params)
@article.sent = false
@article.save
format.html { redirect_to @article, notice: 'Article was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @article = article_get(params[:id])\n @article.update(params[:article])\n respond_with(@article)\n end",
"def UpdateArticle id,params = {}\n \n APICall(path: \"help_center/articles/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @... | [
"0.6822808",
"0.67426866",
"0.6710149",
"0.67066306",
"0.66805017",
"0.6678203",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.66669637",
"0.6654977",
"0.6643167",
"0.6633079",
"0.6614886",
"0.... | 0.61277884 | 95 |
DELETE /articles/1 DELETE /articles/1.json | def destroy
respond_to do |format|
if @article.input
format.html { redirect_to articles_url, notice: 'No es posible eliminar un Artículo que ya ha sido vendido, o alquilado.' }
format.json { render json: @article.errors, status: :unprocessable_entity }
else
@article.destroy
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @article = Article.find(params[:id]) \n @article.destroy\n\n respond_to do |format|\n format.html { redirect_to articles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @article = Article.where(id: params[:id]).last\n @article.destroy\n\n res... | [
"0.7844117",
"0.7832465",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
"0.78202105",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_article
@article = Article.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def article_params
params.require(:article).permit(:description, :estimated_price, :entry_date, :commission_per, :commission_cash, :status, :provider_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
Create a new parser initialized with a source file. Refactoring Opportunity: Take data to be parsed and not just a path. | def initialize(path)
@path = path.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(source); end",
"def parse(source, options = {})\n new.parse(source, options)\n end",
"def parse(source, path = T.unsafe(nil)); end",
"def initialize(source)\n self.source = source\n self.fields = []\n self.lines = []\n self.parse!\n end",
"def parse(source, opti... | [
"0.71714497",
"0.70523703",
"0.7030028",
"0.6785629",
"0.6783841",
"0.6763006",
"0.6638045",
"0.6579313",
"0.6564139",
"0.6564139",
"0.6557009",
"0.6549441",
"0.6542895",
"0.65389514",
"0.65389514",
"0.65341866",
"0.65341866",
"0.65341866",
"0.6527015",
"0.6508991",
"0.650899... | 0.0 | -1 |
Parse the current file in to a set of records. Refactoring Opportunity: Create a class method 'parse' that takes path and parsing options. | def parse(options={})
rows = parse_rows(data)
sort_rows(rows, options[:sort])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse\n parse_file\n self\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filename = path\n open path do |f|\n parse f.read\n end\n end",
"def parse_file path\n self.filenam... | [
"0.75361913",
"0.7464579",
"0.7464579",
"0.7464579",
"0.7464579",
"0.7464579",
"0.7464579",
"0.7201121",
"0.70735264",
"0.70595956",
"0.6952022",
"0.6859925",
"0.68220687",
"0.66957206",
"0.6658124",
"0.6536995",
"0.65328467",
"0.6527937",
"0.6475216",
"0.6475216",
"0.6334495... | 0.0 | -1 |
Get the raw data of the file as a string. | def data
return @data unless @data.nil?
if File.exists?(@path)
@data = File.read(@path)
else
raise FileNotFound.new(@path)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_as_string(filename)\n data = ''\n f = File.open(filename, \"r\")\n f.each_line do |line|\n data += line\n end\n return data\n end",
"def get_file_as_string(filename)\n data = ''\n f = File.open(filename, \"r\") \n f.each_line do |line|\n data ... | [
"0.78787535",
"0.7871976",
"0.7768824",
"0.7620733",
"0.7560408",
"0.74693704",
"0.73208654",
"0.72229075",
"0.7220505",
"0.7220505",
"0.7193522",
"0.7186675",
"0.7164912",
"0.7056063",
"0.7014338",
"0.7006306",
"0.6973922",
"0.68200815",
"0.66876906",
"0.66814375",
"0.667487... | 0.0 | -1 |
Infer the separator based on the data (naive but hey). Feature Opportunity: Detect by file extension | def inferred_separator
SUPPORTED_SEPARATORS.each do |sep|
return sep if data.scan(sep).length > 0
end
raise UnknownFormat.new(@path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_delim_filename(delim_type, other_char, suffix = '')\n if delim_type == 'comma'\n filename = params[:model] + params[:id] + suffix + '.csv'\n delimiter = ','\n elsif delim_type == 'space'\n filename = params[:model] + params[:id] + suffix + '.csv'\n delimiter = ' '\n elsif deli... | [
"0.6576335",
"0.6539616",
"0.61765844",
"0.6151087",
"0.6131208",
"0.6056232",
"0.60016304",
"0.5880193",
"0.5879092",
"0.5879092",
"0.5867265",
"0.58501166",
"0.5810048",
"0.57507426",
"0.5730546",
"0.5689163",
"0.56833524",
"0.56779134",
"0.56017107",
"0.5599163",
"0.557724... | 0.72565305 | 0 |
Do the actual parsing of the data. Refactoring Opportunity: Pull this out into its own object like RecordSorter. | def parse_rows(data)
csv_options = DEFAULT_OPTIONS.merge(:col_sep => inferred_separator)
CSV.parse(data, csv_options).map(&:to_hash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(options={})\n rows = parse_rows(data)\n sort_rows(rows, options[:sort])\n end",
"def parse(data); end",
"def parse\n @file_data.each {|line|\n h = {}\n data_elements = line.split('|').collect(&:strip)\n #LastName | FirstName | MiddleInitial | Gender | FavoriteColor | DateOfBi... | [
"0.65955055",
"0.6358661",
"0.6271887",
"0.61964655",
"0.6106517",
"0.5934386",
"0.59171027",
"0.5912882",
"0.5912526",
"0.59096944",
"0.58167225",
"0.5779041",
"0.5741791",
"0.573993",
"0.573993",
"0.573993",
"0.57283115",
"0.5694575",
"0.56515867",
"0.56171006",
"0.5614062"... | 0.0 | -1 |
Do the sorting of the rows | def sort_rows(rows, sorts)
RecordSorter.new(rows).sort(sorts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_data\n sort_cols = @columns.select{ |col| col.sort_order }.sort_by{ |col| col.sort_order }\n if sort_cols.length > 0\n log.fine \"Sorting by #{sort_cols.map(&:header).to_sentence}\"\n @data.sort! do |a, b|\n ord = nil\n ... | [
"0.7778085",
"0.72409344",
"0.71106696",
"0.70163196",
"0.6909443",
"0.68433183",
"0.6793622",
"0.668459",
"0.6682888",
"0.65663344",
"0.6506651",
"0.64522296",
"0.64175683",
"0.63811666",
"0.63563365",
"0.6298603",
"0.62733775",
"0.62725073",
"0.62725073",
"0.62631094",
"0.6... | 0.71003914 | 3 |
def id object.id.to_s end | def fanscnt
object.user_location_favs.size
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n object.id.to_s\n end",
"def id\n object.id\n end",
"def id\n object.id\n end",
"def id\n object_id\n end",
"def id\n object.object_id\n end",
"def object_id() end",
"def id\n model.id.to_s\n end",
"def id\n object.to_param\n end",
"def id\n ... | [
"0.9406557",
"0.90496683",
"0.90496683",
"0.89560145",
"0.8923576",
"0.8763401",
"0.8691035",
"0.86729944",
"0.8651802",
"0.8637324",
"0.8602584",
"0.85727",
"0.8534798",
"0.847595",
"0.84555256",
"0.8450818",
"0.8450818",
"0.8443215",
"0.8417423",
"0.83880836",
"0.8377963",
... | 0.0 | -1 |
def get_games url = " response = HTTParty.get(url).parsed_response.to_xml render xml: response, root: 'objects', children: 'object' end | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_request\n doc_content = open(\"#{@baseurl}#{@path}#{@gamer}#{@gamepath}\", \"User-Agent\" => @user_agent)\n @doc = Nokogiri::HTML( doc_content )\n res = self.reformat_games( self.get_json )\n res\n end",
"def fetch_games\n games, doc = [], get_xml(bungie_net_recent_... | [
"0.6888933",
"0.6799583",
"0.66903627",
"0.668715",
"0.66693574",
"0.6489586",
"0.64611036",
"0.64611036",
"0.63663805",
"0.6355447",
"0.6337306",
"0.629769",
"0.62881064",
"0.62098414",
"0.6203812",
"0.61982876",
"0.61982876",
"0.61908984",
"0.61767155",
"0.6171713",
"0.6155... | 0.0 | -1 |
Some posts have an unwatermarked version of the image. Usually it's lower resolution and lower JPEG quality than the watermarked image. Multiimage posts will have only one unwatermarked URL. | def unwatermarked_url
return nil if api_response["article_image_url"].nil?
Source::URL.parse(api_response["article_image_url"])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_image_uri\n return nil if image.nil?\n return image if image.start_with?('http://')\n return 'http://bookmarket.webhop.org/' + image\n end",
"def latest_image\n attachments.present? ? attachments.last.document.url(:medium) : \"#{APP_URL}/images/missing.png\"\n end",
"def render_small_pos... | [
"0.5773438",
"0.5749078",
"0.5728233",
"0.57170796",
"0.57150257",
"0.5693912",
"0.5677273",
"0.5667931",
"0.565587",
"0.5653029",
"0.5647538",
"0.56018394",
"0.55970937",
"0.55582476",
"0.5556569",
"0.5552411",
"0.5534304",
"0.5519076",
"0.5510771",
"0.5475985",
"0.5463372",... | 0.6870945 | 0 |
For the server to remove a browser cookie we need to set a cookie of the same name with an expires value to now (or in the past) so that the browser will expire it and remove it. The value is also voided. | def remove_session_cookie
headers['Set-Cookie'] = session_cookie "x; expires=#{Time.at(0).httpdate}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_cookie(name)\n cookie = Cookie.new(name, \"\")\n cookie.expires = 1.year.ago \n @context.add_cookie(cookie) \n end",
"def delete_cookie(name)\n set_cookie(name, nil, Merb::Const::COOKIE_EXPIRED_TIME)\n end",
"def delete_cookie(name); end",
"def delete(name, options = {})\n ... | [
"0.7805665",
"0.7571338",
"0.7564561",
"0.7373431",
"0.72466165",
"0.718499",
"0.7161379",
"0.704775",
"0.70309216",
"0.6992143",
"0.6965697",
"0.69307023",
"0.68598115",
"0.6761744",
"0.6723766",
"0.6714807",
"0.6679817",
"0.66047597",
"0.6604622",
"0.65977705",
"0.65928954"... | 0.72842306 | 4 |
Follows the convention of an xcallbackurl action of "addText" matching a class name of "AddText" | def action
self.class.name.split("::").last.tap do |class_name|
class_name[0] = class_name[0].downcase
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_text(text); end",
"def set_add_text\n @add_text = AddText.find(params[:id])\n end",
"def create\n @add_text = AddText.new(add_text_params)\n\n respond_to do |format|\n if @add_text.save\n format.html { redirect_to @add_text, notice: 'Add text was successfully created.' }\n ... | [
"0.7379703",
"0.6640188",
"0.65295076",
"0.6264892",
"0.62057465",
"0.6166358",
"0.6140011",
"0.61306936",
"0.61046857",
"0.60945755",
"0.6069782",
"0.6066314",
"0.58717775",
"0.5803748",
"0.5803748",
"0.5803748",
"0.58003515",
"0.5745676",
"0.57391936",
"0.5720754",
"0.56832... | 0.0 | -1 |
Need to CGI escape strings to allow characters like & through the xcallback URL, but for some reason not spaces | def cgi_escape(string)
CGI.escape(string).gsub("+", " ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uri_escape(input); end",
"def cgi_escape(input); end",
"def safe_escape(uri); end",
"def check_and_escape(url)\n check url\n CGI.escape url\n end",
"def uri_escape\n str = xml_escape.gsub(/\\+/, '+')\n str = str.gsub(/\\s/, '+')\n end",
"def escape_uri(s); Rack::Utils.escape(s... | [
"0.7766201",
"0.7629957",
"0.7440827",
"0.70544904",
"0.70077366",
"0.7001111",
"0.69713885",
"0.6958147",
"0.68568796",
"0.68485373",
"0.6837421",
"0.6821976",
"0.68179744",
"0.6746517",
"0.67192465",
"0.67021126",
"0.669054",
"0.66335946",
"0.66237587",
"0.6602335",
"0.6592... | 0.6133315 | 49 |
GET /boats GET /boats.json | def index
if params[:search].present? and !params[:search].empty?
@search_location = params[:search]
@boats = Boat.complete.near(search_params, 20, unit: :km, order: 'distance').select(&:can_be_published?)
@search_results_count = @boats.size # count doesn't work with near
if @boats.empty?
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n if params[:title]\n @boats = Boat.where title: params[:title]\n else\n if params[:open_seats]\n @boats = Boat.where open_seats: params[:open_seats]\n else\n @boats = Boat.all\n end... | [
"0.7905412",
"0.7756258",
"0.7506124",
"0.72863954",
"0.72863954",
"0.72091883",
"0.6894622",
"0.6795003",
"0.679307",
"0.6743202",
"0.6687222",
"0.66762817",
"0.6672628",
"0.65975404",
"0.6589081",
"0.6501594",
"0.6459849",
"0.6435166",
"0.6421407",
"0.63603795",
"0.633779",... | 0.0 | -1 |
GET /boats/1 GET /boats/1.json | def show
@booking = @boat.bookings.build(user: current_user)
@booking.start_time = Time.zone.tomorrow + 9.hours
@booking.end_time = Time.zone.tomorrow + 18.hours
@booking.people_on_board = 1
#TODO disable also booked(accepted) days
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def show\n @boat = Boat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @boat}... | [
"0.7809086",
"0.7719782",
"0.7498109",
"0.7456902",
"0.7159893",
"0.7159893",
"0.6808315",
"0.6722324",
"0.66718364",
"0.66601306",
"0.6596522",
"0.6591887",
"0.6546317",
"0.65167475",
"0.65091014",
"0.6507481",
"0.64649594",
"0.6461716",
"0.6444277",
"0.6404183",
"0.6393024"... | 0.0 | -1 |
POST /boats POST /boats.json | def create
@boat = current_user.boats.build(boat_params)
@boat.create_boat_features_set
respond_to do |format|
if @boat.save
format.html { redirect_to edit_boat_path(@boat), notice: _("Boat was successfully created") }
format.json { render :edit, status: :created, location: @boat }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tboat = Boat.new(boat_params)\n \tif boat.save\n \t\trender json: boa... | [
"0.7413428",
"0.7193006",
"0.6988092",
"0.6965062",
"0.63574076",
"0.63102376",
"0.6267455",
"0.622307",
"0.6166601",
"0.6127176",
"0.6101744",
"0.60850495",
"0.605931",
"0.6048728",
"0.6020868",
"0.6008816",
"0.6000906",
"0.59235674",
"0.5884312",
"0.5881562",
"0.5802847",
... | 0.63135606 | 5 |
PATCH/PUT /boats/1 PATCH/PUT /boats/1.json | def update
respond_to do |format|
if @boat.update(boat_params)
format.html { redirect_to @boat, notice: _("Boat was successfully updated") }
format.js
format.json { render :show, status: :ok, location: @boat }
else
format.html { render :edit }
format.js
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully upd... | [
"0.75139743",
"0.7205898",
"0.7205898",
"0.7205898",
"0.7149097",
"0.70022035",
"0.67328215",
"0.66688395",
"0.6633111",
"0.65329206",
"0.6529358",
"0.6501237",
"0.6298703",
"0.62954086",
"0.6290583",
"0.62341624",
"0.62328416",
"0.62252235",
"0.621522",
"0.6211749",
"0.62059... | 0.6840953 | 6 |
DELETE /boats/1 DELETE /boats/1.json | def destroy
@boat.destroy
respond_to do |format|
format.html { redirect_to boats_url, notice: _("Boat was successfully destroyed") }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html {redirect_to boats_url}\n format.json {head :no_content}\n end\n end",
"def destroy\n @boat = Boat.find(params[:id])\n @boat.destroy\n\n respond_to do |format|\n format.html ... | [
"0.75705564",
"0.7438568",
"0.74197197",
"0.73656553",
"0.7349286",
"0.7349286",
"0.7349286",
"0.72071075",
"0.71894634",
"0.7050117",
"0.7036506",
"0.697863",
"0.6862241",
"0.68438214",
"0.6821779",
"0.67834526",
"0.67803717",
"0.6767131",
"0.6737287",
"0.6729381",
"0.672593... | 0.7368521 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_boat
@boat = Boat.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def boat_params
create_params = [
:name,
:manufacturer,
:daily_price,
:year,
:model,
:length,
:guest_capacity,
:boat_category_id,
:description,
:fuel_type,
:with_license,
:rental_type,
:address,
:horse_power,
pictures_attribut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /projects/1 GET /projects/1.json | def show
@project = Project.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n get 'projects'\n end",
"def listprojects\n get('listprojects.json')['projects']\n end",
"def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def projects\n... | [
"0.7869151",
"0.76985043",
"0.76807874",
"0.7612022",
"0.75345093",
"0.7527008",
"0.7493986",
"0.7493986",
"0.7493986",
"0.7493986",
"0.7493986",
"0.7493986",
"0.7493986",
"0.74937606",
"0.74849236",
"0.74796486",
"0.7444702",
"0.74304223",
"0.7423762",
"0.74148554",
"0.73853... | 0.73618454 | 34 |
GET /projects/new GET /projects/new.json | def new
@project = Project.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | [
"0.81725097",
"0.81171846",
"0.80850273",
"0.80848",
"0.8061288",
"0.8030936",
"0.79504395",
"0.792672",
"0.79045373",
"0.7865987",
"0.7758509",
"0.7751187",
"0.77291125",
"0.7706384",
"0.7698888",
"0.7685731",
"0.7672869",
"0.7655707",
"0.76342",
"0.7632482",
"0.7619905",
... | 0.8165836 | 23 |
POST /projects POST /projects.json | def create
@project = Project.new(params[:project])
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was successfully created.' }
format.json { render json: @project, status: :created, location: @project }
else
format.html { render... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new... | [
"0.7338948",
"0.73139244",
"0.7308003",
"0.7299582",
"0.7227503",
"0.7225945",
"0.71982473",
"0.71170384",
"0.7104803",
"0.7095263",
"0.7070636",
"0.70408624",
"0.70358187",
"0.7024969",
"0.70191896",
"0.7009597",
"0.698481",
"0.697517",
"0.6963753",
"0.6963096",
"0.6944626",... | 0.6948756 | 26 |
PUT /projects/1 PUT /projects/1.json | def update
@project = Project.find(params[:id])
respond_to do |format|
if @project.update_attributes(params[:project])
format.html { redirect_to @project, notice: 'Project was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end",
"def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n re... | [
"0.7380123",
"0.7308916",
"0.7181629",
"0.7167707",
"0.7132476",
"0.7125153",
"0.7081923",
"0.7008695",
"0.700572",
"0.70002675",
"0.69908255",
"0.6983146",
"0.69805205",
"0.69805205",
"0.6977218",
"0.6970257",
"0.6970257",
"0.6970257",
"0.6970257",
"0.6970257",
"0.6970257",
... | 0.6989358 | 13 |
DELETE /projects/1 DELETE /projects/1.json | def destroy
@project = Project.find(params[:id])
@project.destroy
respond_to do |format|
format.html { redirect_to projects_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @project.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n project.destroy\n\n respond_to do |format|\n format.html { redirect_to projects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pr... | [
"0.78952813",
"0.7859671",
"0.77783555",
"0.7771835",
"0.7758944",
"0.77311707",
"0.7730795",
"0.7730795",
"0.7730795",
"0.7730795",
"0.7730795",
"0.7724859",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
"0.7705122",
... | 0.7718807 | 15 |
=begin Split the sentence Initiate an empty hash with a default value of 0 Iterate over the sentence with each Increment the value of the key =end | def word_sizes(sentence)
hash = Hash.new(0)
sentence.split.each do |word|
hash[word.size] += 1
end
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_hash(sentence)\n letters = Hash.new(0)\n sentence.split.each { |word| letters[word.length] += 1 }\n letters\nend",
"def word_sizes(sentence)\n sentence.split.each_with_object(Hash.new(0)) { |word, obj| obj[word.size] += 1 } \nend",
"def word_count(sentence)\n arr = sentence.split(\" \")\n result... | [
"0.738351",
"0.6912374",
"0.68913656",
"0.6877054",
"0.66581875",
"0.66301024",
"0.65555286",
"0.6554611",
"0.65495664",
"0.65027773",
"0.64794147",
"0.64735574",
"0.64562494",
"0.64534694",
"0.64375323",
"0.6434497",
"0.6421537",
"0.64114994",
"0.6409853",
"0.6404675",
"0.64... | 0.6968999 | 1 |
end m = Parameter.get_float('markup rate') + 1 | def cost(op)
{labor: 4.38, materials: 0}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rate; end",
"def rate; end",
"def rate=(_arg0); end",
"def rate=(_arg0); end",
"def effective_rate; end",
"def base_markup_price\n @base_price + (@base_price * Flat_Markup_Rate)\n end",
"def add_markup_materials\n if Material_Markup_Rate[\"#{@material}\"]\n markup = Material_Markup_Rate... | [
"0.7347682",
"0.7347682",
"0.70341593",
"0.70341593",
"0.693174",
"0.6668449",
"0.6599934",
"0.65176076",
"0.6514493",
"0.64854443",
"0.6388965",
"0.6388965",
"0.63847077",
"0.6339105",
"0.6279815",
"0.6242342",
"0.6225584",
"0.6222308",
"0.62050426",
"0.6187526",
"0.61742777... | 0.0 | -1 |
GET /recommenders/1 GET /recommenders/1.json | def show
@recommender = User.where(username: params[:username]).first.recommender
if @recommender.nil?
render json: "No Recommender of this user found"
else
render json: @recommender.to_json(only: :latest_recommendation)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recommendations\n\t @recommendations = Restaurant.find(params[:id]).recommendations\n\t \n\t respond_to do |format|\n\t\t format.html # recommendations.html.erb\n\t \t format.json { render json: @recommendations.to_json(except: [ :created_at, :updated_at ]) }\n\t end\n end",
"def show\n @recommend ... | [
"0.79008543",
"0.7453154",
"0.7189911",
"0.71554375",
"0.71158415",
"0.7095146",
"0.70482963",
"0.6965189",
"0.68616146",
"0.6840237",
"0.6716086",
"0.6675281",
"0.6574772",
"0.6528001",
"0.65098447",
"0.6474761",
"0.6448644",
"0.6434182",
"0.64237267",
"0.6373494",
"0.637264... | 0.69300073 | 8 |
private if i have no supervisor, return me | def get_tree_top_id(person)
person.direct_supervisors.empty? ? person.id : person.direct_supervisors.first.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def supervisor(options)\n\n end",
"def minimumSupervisorLevel\n \tsupervisions.count + 1\n end",
"def is_supervisor?\n not under_supervision_clinics.empty?\n end",
"def super_user\r\n caller[0] =~ /`(.*)'/ #`\r\n skipping(\"not super user\", $1)\r\n end",
"def validate_supervisor_or_a... | [
"0.6595611",
"0.62592715",
"0.61004466",
"0.6097345",
"0.60226864",
"0.5968137",
"0.59517866",
"0.5927085",
"0.58840185",
"0.5869165",
"0.58434784",
"0.5828282",
"0.5814401",
"0.57701194",
"0.5764326",
"0.5743865",
"0.57429636",
"0.5742461",
"0.5727721",
"0.5727489",
"0.57018... | 0.0 | -1 |
get a reporting tree starting from this person's boss, down to all leaf subordinates. | def get_tree(person)
h = build_adjacency_list
n = h[get_tree_top_id(person)] # start creating the tree at this person's supervisor, if there is one
nodes = to_node(h, n) # recurse through the SQL results to construct a tree (nested hashes)
nodes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tree(employee)\n\n h = Employee.build_adjacency_list\n\n n = h[get_tree_top_id(employee)] # start creating the tree at this employee's supervisor, if there is one\n\n nodes = to_node(h, n) # recurse through the SQL results to construct a tree (nested hashes)\n\n nodes\n end",
"def... | [
"0.6351754",
"0.5512419",
"0.53303957",
"0.5296398",
"0.5267981",
"0.51744694",
"0.5152476",
"0.5144239",
"0.51137257",
"0.510391",
"0.50371367",
"0.5028946",
"0.5019304",
"0.4998947",
"0.49921027",
"0.49740613",
"0.4971543",
"0.49511394",
"0.49429905",
"0.4942447",
"0.492520... | 0.57526386 | 1 |
starting at a top person node, recurse through all subordinate relationships to create a nested reporting structure tree | def to_node(h, n, i=0)
i = i + 1
{
"id" => n[:id],
"name" => n[:name],
"size" => 1,
"children" => n[:children].empty? ? "" : n[:children].map { |c|
c[:children] = get_children(h, c)
to_node h, c, i
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tree(person)\n\n h = build_adjacency_list\n\n n = h[get_tree_top_id(person)] # start creating the tree at this person's supervisor, if there is one\n\n nodes = to_node(h, n) # recurse through the SQL results to construct a tree (nested hashes)\n\n nodes\n end",
"def traverse(perso... | [
"0.63254434",
"0.5934211",
"0.5894449",
"0.56490564",
"0.5612903",
"0.56119716",
"0.5555985",
"0.5541716",
"0.5534209",
"0.5475243",
"0.5440395",
"0.54028016",
"0.5384216",
"0.5324889",
"0.5319483",
"0.5314651",
"0.5312348",
"0.52994525",
"0.5292738",
"0.5286284",
"0.52822423... | 0.0 | -1 |
get children from the hash in memory based on supervisor id | def get_children(h, n)
rr = h[n[:id]]
if !rr.nil?
rr[:children]
else
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n SideJob.redis.hgetall(\"#{redis_key}:children\").each_with_object({}) {|child, hash| hash[child[0]] = SideJob.find(child[1])}\n end",
"def get_children_pids(pid)\n pid = pid.to_i\n unless process_tree.key? pid\n log \"No such pid: #{pid}\"\n return []\n end\n process_... | [
"0.7118726",
"0.6415582",
"0.6358646",
"0.62417567",
"0.6232998",
"0.62155116",
"0.6109614",
"0.6088668",
"0.6017252",
"0.5987482",
"0.5952522",
"0.5938795",
"0.5869971",
"0.5749495",
"0.57375175",
"0.5722531",
"0.5708195",
"0.570273",
"0.5698061",
"0.5686462",
"0.564385",
... | 0.65943426 | 2 |
select the direct reporting relationships and all associated person information needed to construct tree | def join_people_by_relationship_type
sql = <<EOF
select supers.id, supers.name, subs.id, subs.name
from person_associations pa
inner join people as supers
on supers.id = pa.source_id
inner join people as subs
on subs.id = pa.sink_id
and association_type = 'direct_reporting'
order by supers.id
EOF
r = Acti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_father_summary(person_id)\n add_parents!\n couple = parents[0] || ParentsReference.new\n couple.select_parent(person_id,'Male')\n parents[0] = couple \n end",
"def build_adjacency_list\n\n r = join_people_by_relationship_type\n\n h = {}\n r.each {|rr|\n id = rr[0]\... | [
"0.5809124",
"0.57667524",
"0.5698875",
"0.56147885",
"0.5610292",
"0.55432147",
"0.55208224",
"0.54995596",
"0.5482742",
"0.54484296",
"0.5434563",
"0.5381422",
"0.5362427",
"0.53606445",
"0.53301364",
"0.5306149",
"0.5303934",
"0.52873033",
"0.5279822",
"0.526612",
"0.52588... | 0.5244745 | 22 |
place SQL results into a hashkeyed off of supervisor ids, pointing to a list of subordinates for that supervisor | def build_adjacency_list
r = join_people_by_relationship_type
h = {}
r.each {|rr|
id = rr[0]
h[id] = {:id => id, :name => rr[1], :children => []} if h[id].nil? # if there's no hash entry for this person, make one.
h[id][:children] << {:id => rr[2], :name => rr[3], :children => []} # e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterator_heros\n results=[]\n other_results=[]\n Superhero.all.select do |hero| \n # binding.pry\n if self.user.superheros.include?(hero)\n results << {hero.name => hero.id}\n else \n other_results << {hero.name => hero.id}\n end\n ... | [
"0.5744068",
"0.54649127",
"0.5417056",
"0.54154885",
"0.5393021",
"0.5191496",
"0.5142469",
"0.5062413",
"0.500996",
"0.50016695",
"0.4989448",
"0.4906232",
"0.49008897",
"0.48907262",
"0.4860441",
"0.48425025",
"0.4833781",
"0.4808018",
"0.47996476",
"0.47949952",
"0.478469... | 0.0 | -1 |
TODO Don't return all videos, just video for issue | def list
respond_to do |format|
format.html { render partial: 'videos/issues_video_container', locals: {videos: Video.where(issue_id: params[:issue_id]).page(params[:page]).per(params[:per]), issue: Issue.where(id: params[:issue_id])} }
format.json { render json: Video.where(issue_id: params[:issue_id])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos_test\n end",
"def video\n @streams.select { |stream| stream.is_a? VideoStream }\n end",
"def valid_videos\n self.videos.select{ |video|\n video.exist? && video.embed? && video.auto_play?\n }\n end",
"def video_list\n self.video_list = videos.map { |video| video[\"title\"] }\n... | [
"0.7238571",
"0.7144692",
"0.7031928",
"0.68703896",
"0.67784584",
"0.6767138",
"0.6767138",
"0.67403907",
"0.66962653",
"0.6660596",
"0.6583289",
"0.65204346",
"0.6514951",
"0.6503534",
"0.6490964",
"0.6476618",
"0.64699405",
"0.64662665",
"0.64609516",
"0.6453069",
"0.64421... | 0.699107 | 3 |
This might need a bit more complexity in the future, but for now, it works like a charm | def generate_around_site
return Video.order("RAND()").limit(4)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def schubert; end",
"def formation; end",
"def transformations; end",
"def transforms; end",
"def custom; end",
"def custom; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def anchored; end",
"def transform; end",... | [
"0.6775992",
"0.58844966",
"0.57467264",
"0.5697172",
"0.5677934",
"0.5623939",
"0.5602447",
"0.5602447",
"0.5577124",
"0.5577124",
"0.5577124",
"0.5577124",
"0.55260164",
"0.552145",
"0.5502291",
"0.54278207",
"0.542326",
"0.5358239",
"0.53303516",
"0.53284883",
"0.53101146"... | 0.0 | -1 |
that's not the output we see. Why not? | def multiply_by_five(n)
n * 5
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probers; end",
"def out; end",
"def private; end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); end",
"def output=(_arg0); e... | [
"0.6346111",
"0.623553",
"0.60634243",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5997114",
"0.5989041",
"0.5989041",
"0.5989041",
"0.5989041",
"0.5989041",
"0.5989041",
"... | 0.0 | -1 |
We will consider a, e, i, o, and u as vowels for this Kata. The input string will only consist of lower case letters and/or spaces. | def getCount(inputStr)
return inputStr.count("aeiou")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vowels (string)\r\n if string.class == String\r\n vowels(string.split(\"\").concat([ [] ]))\r\n else \r\n if string[0].class == String \r\n case string[0]\r\n when \"A\",\"a\",\"E\",\"e\",\"I\",\"i\",\"O\",\"o\",\"U\",\"u\"\r\n vowels(string.slice(1..-2).concat( [string[-1].concat([s... | [
"0.7775484",
"0.7441667",
"0.7415979",
"0.7412654",
"0.7409381",
"0.7366463",
"0.73115844",
"0.73064893",
"0.7305904",
"0.7298773",
"0.72894734",
"0.72798187",
"0.7273071",
"0.7244948",
"0.7210117",
"0.7205979",
"0.71921057",
"0.7153378",
"0.7142784",
"0.7084901",
"0.7077123"... | 0.0 | -1 |
Binomial, a simple sum of Bernoulli samples. | def rbinomial(mean, prob)
((1..mean).map { rbernoulli(prob) }).sum
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binomial(n,k)\n return 1 if n-k <= 0\n return 1 if k <= 0\n fact(n) / ( fact(k) * fact( n - k ) )\n end",
"def binomial_coefficient(n,k)\n return 1 if (k==0 or k==n)\n k=[k, n-k].min\n permutations(n,k).quo(factorial(k))\n # The factorial way is\n # factorial(n).quo(factori... | [
"0.649787",
"0.6391014",
"0.6376122",
"0.62458915",
"0.6124563",
"0.5773585",
"0.5683067",
"0.561799",
"0.54564595",
"0.5418322",
"0.5331472",
"0.5313237",
"0.52160627",
"0.5199694",
"0.5179689",
"0.51397675",
"0.51350796",
"0.5093536",
"0.50844187",
"0.5055865",
"0.5054107",... | 0.76020145 | 0 |
N(0,1) sampling from the BoxMuller theorem, in two flavours. Note: Feel free to exchange the cos by sin. | def rnormal(mean, sd)
mean + (Math.sqrt(-2 * Math.log(rand)) * Math.cos(2 * Math::PI * rand)) * sd
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_muller\n θ = 2 * Math::PI * rand\n ρ = Math.sqrt(-2 * Math.log(1 - rand))\n scale = σ * ρ\n μ + scale * Math.cos(θ)\n end",
"def box_mueller( mean = 0.0, stddev = 1.0 )\n x1 = 0.0, x2 = 0.0, w = 0.0\n\n until w > 0.0 && w < 1.0\n x1 = 2.0 * rand - 1.0\n x2 = 2.0 * rand - 1.... | [
"0.667646",
"0.6259642",
"0.59863317",
"0.5897662",
"0.586521",
"0.56459343",
"0.5633882",
"0.56110126",
"0.54187095",
"0.5298697",
"0.52863425",
"0.5280851",
"0.5259248",
"0.5241511",
"0.5206297",
"0.51865214",
"0.51795936",
"0.51728475",
"0.51563483",
"0.51393306",
"0.51293... | 0.0 | -1 |
Beta. NOTE: NOT WORKING! | def rbeta(alpha, beta)
alpha = alpha.to_f
beta = beta.to_f
log10 = Math.log(10)
a = alpha + beta
if [alpha, beta].min <= 1
b = [1 / alpha, 1 / beta].max
else
b = Math.sqrt((a - 2) / (2 * alpha * beta - a))
end
c = alpha + 1/b
begin
u1, u2 = rand, rand
v = b * Math.log(u1 / (1 - u1))... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def berlioz; end",
"def blg; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def verdi; end",
"def villian; end",
"def terpene; end",
"def bs; end",
"def refutal()\n end",
"def weber; end"... | [
"0.71760875",
"0.6703603",
"0.65820426",
"0.6547483",
"0.6372093",
"0.63479966",
"0.63479966",
"0.63479966",
"0.63479966",
"0.6304892",
"0.62530065",
"0.6179779",
"0.6164725",
"0.6116117",
"0.610676",
"0.5997255",
"0.5948738",
"0.5914281",
"0.5897416",
"0.589595",
"0.5884841"... | 0.0 | -1 |
Negative binomial. F. Weibull. NOTE: TEST. | def rweibull(alpha, beta)
beta.to_f * (- Math.log(rand))**(1 / alpha.to_f)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def opposite(x)\n x * -1\nend",
"def binary(num)\n if num < 0\n positiveNumBinary = calculate_binary(num.abs, 'negative')\n else\n return calculate_binary(num, 'positive')\n end\n\nend",
"def opposite(number)\r\n return number * (-1)\r\nend",
"def opposite(number)\n number*-1\nend",
"def bitnot(b)... | [
"0.6388879",
"0.62787855",
"0.61814743",
"0.6131015",
"0.60918397",
"0.6057517",
"0.590113",
"0.58922476",
"0.5885237",
"0.5847681",
"0.5780743",
"0.57715017",
"0.577008",
"0.57323104",
"0.57108706",
"0.57078445",
"0.57044077",
"0.5700991",
"0.57001585",
"0.56616527",
"0.5656... | 0.61543226 | 3 |
Hypergeometric. Geometric. Chisquared. Erlang. NOTE: TEST. | def rerlang(k, beta)
-(beta.to_f / k) * Math.log((k.times.collect { rand }).prod)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def power(g,h)\n return g**h\nend",
"def cosh\n math :cosh\n end",
"def rh_factor; end",
"def hyperbolic_cos\n Math.log(Math.tan(Math::PI * random / 2))\n end",
"def geometric(colors)\n colors.reduce(&:*)**(1.0 / colors.count)\n end",
"def gecos(*) end",
"def hypothenus(x, y)... | [
"0.669272",
"0.6281804",
"0.61853135",
"0.6131464",
"0.6098486",
"0.60730606",
"0.5941944",
"0.5903776",
"0.5887678",
"0.5838002",
"0.5777422",
"0.5765179",
"0.5694909",
"0.5656472",
"0.56473446",
"0.56099916",
"0.56043214",
"0.55912673",
"0.5583138",
"0.5554771",
"0.5548989"... | 0.0 | -1 |
GET /control_points GET /control_points.xml GET /user/:user_id/control_points GET /user/:user_id/control_points.xml GET /map/:map_id/control_points GET /map/:map_id/control_points.xml | def index
unless @parent.nil?
@control_points = @parent.control_points.order(:updated_at).page(params[:page]).per(10)
@all_control_points = @parent.control_points
else
@control_points = ControlPoint.order(:updated_at).page(params[:page]).per(10)
@all_control_points = ControlPoint.al... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @map = Map.find(params[:map_id])\n @control_point = @map.control_points.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @control_point }\n end\n end",
"def fetchControlPoints(url, mapID)\n url = URI(url.to_s+'maps/'+mapID.to_s+'/control... | [
"0.6276032",
"0.62197244",
"0.60305244",
"0.58358794",
"0.5720946",
"0.56601816",
"0.56504554",
"0.55939615",
"0.55346173",
"0.5487293",
"0.54569525",
"0.54560316",
"0.54267526",
"0.5425114",
"0.54191685",
"0.5414706",
"0.5412523",
"0.54117185",
"0.5388194",
"0.5382972",
"0.5... | 0.6369145 | 0 |
GET /control_points/1 GET /control_points/1.xml | def show
@control_point = ControlPoint.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @control_point }
format.json { render :json => @control_point }
format.rdf { render :rdf => @control_point,
:httpURI ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n \n unless @parent.nil?\n @control_points = @parent.control_points.order(:updated_at).page(params[:page]).per(10)\n @all_control_points = @parent.control_points\n else\n @control_points = ControlPoint.order(:updated_at).page(params[:page]).per(10)\n @all_control_points = Con... | [
"0.6437103",
"0.6291598",
"0.6111449",
"0.6101844",
"0.60807395",
"0.597764",
"0.5963573",
"0.5938321",
"0.5902689",
"0.59000844",
"0.57983583",
"0.5773126",
"0.57420653",
"0.5701334",
"0.5701086",
"0.56786627",
"0.5678122",
"0.5616808",
"0.5605142",
"0.5601392",
"0.55908585"... | 0.63807595 | 1 |
GET /control_points/new GET /control_points/new.xml GET /maps/:map_id/control_points/new | def new
@map = Map.find(params[:map_id])
@control_point = @map.control_points.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @control_point }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @control_point = ControlPoint.new(params[:control_point])\n @control_point.user = current_user\n @control_point.map = Map.find(params[:map_id])\n @map = @control_point.map # we have to do this so the form is correctly displayed on error\n respond_to do |format|\n if @control_point.... | [
"0.7418747",
"0.69204503",
"0.6777111",
"0.66253453",
"0.6617716",
"0.6550849",
"0.6548895",
"0.65268975",
"0.6509584",
"0.6503684",
"0.64741904",
"0.6437832",
"0.63669163",
"0.63422155",
"0.6339899",
"0.6325702",
"0.62836325",
"0.6260058",
"0.62180346",
"0.6215675",
"0.62126... | 0.8813118 | 0 |
POST /control_points POST /control_points.xml | def create
@control_point = ControlPoint.new(params[:control_point])
@control_point.user = current_user
@control_point.map = Map.find(params[:map_id])
@map = @control_point.map # we have to do this so the form is correctly displayed on error
respond_to do |format|
if @control_point.save
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @map = Map.find(params[:map_id])\n @control_point = @map.control_points.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @control_point }\n end\n end",
"def update\n @control_point = ControlPoint.find(params[:id])\n respond_to do |for... | [
"0.5788798",
"0.552815",
"0.54015684",
"0.53514504",
"0.53513753",
"0.5306971",
"0.5306015",
"0.52876735",
"0.52558243",
"0.52422506",
"0.52386504",
"0.5222931",
"0.5198525",
"0.5162963",
"0.5155648",
"0.51487064",
"0.5138782",
"0.5136373",
"0.51293296",
"0.5118681",
"0.51049... | 0.55718523 | 1 |
PUT /control_points/1 PUT /control_points/1.xml | def update
@control_point = ControlPoint.find(params[:id])
respond_to do |format|
if @control_point.update_attributes(params[:control_point])
format.html { redirect_to(@control_point, :notice => 'Control Point was successfully updated.') }
format.xml { head :ok }
else
format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @point = Point.find(params[:id])\n \n respond_to do |format|\n if @point.update_attributes(params[:point])\n format.html { redirect_to(@point, :notice => 'Point was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"e... | [
"0.60472596",
"0.6014395",
"0.60137856",
"0.60045904",
"0.597827",
"0.59353644",
"0.5787352",
"0.5768037",
"0.57469773",
"0.57033706",
"0.56777453",
"0.5672234",
"0.56524825",
"0.5642758",
"0.5631553",
"0.56256044",
"0.5625326",
"0.5603833",
"0.56034833",
"0.55759764",
"0.555... | 0.6983892 | 0 |
DELETE /control_points/1 DELETE /control_points/1.xml | def destroy
@control_point = ControlPoint.find(params[:id])
@map = @control_point.map
if current_user == @control_point.user
@control_point.destroy
end
respond_to do |format|
format.html { redirect_to(map_url @map) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @page_title = \"Data Points\"\n @data_point = DataPoint.find(params[:id])\n @data_point.destroy\n\n respond_to do |format|\n format.html { redirect_to(data_points_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @checkpoint_removed = CheckpointRemoved.find... | [
"0.6578399",
"0.6508327",
"0.6505394",
"0.6465438",
"0.6465438",
"0.6465438",
"0.64558667",
"0.6416198",
"0.63274354",
"0.63111055",
"0.6264992",
"0.62335855",
"0.6198459",
"0.619169",
"0.61718273",
"0.61651474",
"0.61372656",
"0.61207384",
"0.61103076",
"0.61085796",
"0.6091... | 0.62090063 | 12 |
GET /mini_blogs GET /mini_blogs.xml | def index
@mini_blogs = MiniBlog.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @mini_blogs }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @blogs = Blog.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @blogs }\n end\n end",
"def new\n @mini_blog = MiniBlog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @min... | [
"0.69056165",
"0.6716386",
"0.67085975",
"0.6704603",
"0.6383639",
"0.63157517",
"0.6286475",
"0.6262945",
"0.6251652",
"0.6238403",
"0.6230913",
"0.62203425",
"0.62203425",
"0.62168604",
"0.6158014",
"0.6157484",
"0.614848",
"0.6113",
"0.6108077",
"0.6101627",
"0.6083194",
... | 0.7906309 | 0 |
GET /mini_blogs/1 GET /mini_blogs/1.xml | def show
@mini_blog = MiniBlog.find(params[:id])
@entradas = @mini_blog.entradas
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @mini_blog }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mini_blogs = MiniBlog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mini_blogs }\n end\n end",
"def index\n @blogs = Blog.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :x... | [
"0.7785462",
"0.71288604",
"0.66795796",
"0.657555",
"0.6520972",
"0.6461359",
"0.6442262",
"0.63986194",
"0.63976383",
"0.63478094",
"0.63366735",
"0.63229644",
"0.6256309",
"0.6237625",
"0.6225953",
"0.61977714",
"0.61837614",
"0.61801314",
"0.61801314",
"0.6177376",
"0.617... | 0.6453557 | 6 |
GET /mini_blogs/new GET /mini_blogs/new.xml | def new
@mini_blog = MiniBlog.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @mini_blog }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @blog = Blog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @blog }\n end\n end",
"def new\n @blog = Blog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @blog }\n end\n end",
... | [
"0.72367585",
"0.72367585",
"0.72367585",
"0.71660256",
"0.71568733",
"0.6940847",
"0.6937096",
"0.69343245",
"0.69255906",
"0.6813487",
"0.6761975",
"0.6759992",
"0.6759992",
"0.6759992",
"0.67087287",
"0.67069954",
"0.6705693",
"0.67014277",
"0.67008513",
"0.6681612",
"0.65... | 0.76912254 | 0 |
POST /mini_blogs POST /mini_blogs.xml | def create
@mini_blog = MiniBlog.new(params[:mini_blog])
respond_to do |format|
if @mini_blog.save
flash[:notice] = "Mini-Blog creado exitosamente"
format.html { redirect_to(@mini_blog) }
format.xml { render :xml => @mini_blog, :status => :created, :location => @mini_blog }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @mini_blogs = MiniBlog.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @mini_blogs }\n end\n end",
"def new\n @mini_blog = MiniBlog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml ... | [
"0.64741516",
"0.63926864",
"0.5779235",
"0.57445955",
"0.5705277",
"0.5639441",
"0.5634057",
"0.5502933",
"0.5481555",
"0.5465955",
"0.545359",
"0.54524106",
"0.54491687",
"0.54095256",
"0.5407907",
"0.5390425",
"0.5390367",
"0.53758526",
"0.53669846",
"0.5362362",
"0.533874... | 0.6977585 | 0 |
PUT /mini_blogs/1 PUT /mini_blogs/1.xml | def update
@mini_blog = MiniBlog.find(params[:id])
respond_to do |format|
if @mini_blog.update_attributes(params[:mini_blog])
flash[:notice] = 'Mini-Blog actualizado exitosamente'
format.html { redirect_to(@mini_blog) }
format.xml { head :ok }
else
format.html { ren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @blog = Blog.find_by_url(params[:id])\n\n respond_to do |format|\n if @blog.update_attributes(blogs_params)\n format.html { redirect_to @blog, notic... | [
"0.59715545",
"0.5907054",
"0.5874204",
"0.58332056",
"0.5816163",
"0.5801453",
"0.578742",
"0.5777944",
"0.5777944",
"0.57766056",
"0.5773019",
"0.5724527",
"0.566851",
"0.5627786",
"0.56163806",
"0.56160504",
"0.56120396",
"0.5584735",
"0.55616367",
"0.55095285",
"0.5497805... | 0.67778814 | 0 |
DELETE /mini_blogs/1 DELETE /mini_blogs/1.xml | def destroy
@mini_blog = MiniBlog.find(params[:id])
@mini_blog.destroy
respond_to do |format|
format.html { redirect_to(mini_blogs_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @blogger = Blogger.find(params[:id])\n @blogger.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_bloggers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @blog = Blog.find(params[:id])\r\n @blog.destroy\r\n\r\n respond_to do |form... | [
"0.68957335",
"0.6853874",
"0.684108",
"0.684108",
"0.6751144",
"0.6751144",
"0.66002786",
"0.6552462",
"0.6514873",
"0.64637816",
"0.6446654",
"0.64075494",
"0.6404979",
"0.6397588",
"0.6364859",
"0.63308936",
"0.63308936",
"0.633009",
"0.63214064",
"0.6317189",
"0.6311259",... | 0.75205654 | 0 |
write the getter for us def name | def initialize(name)
@name = name
@accounts = {} # Initialize accounts as an empty hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name # AK as mentioned in `item.rb`, getters and setters are generated by `attr_accessor`. Kind of like in C# with properties.\r\n \"#{self.name}\"\r\n end",
"def name() end",
"def name # getter method (or reader method)\n @name\n end",
"def name; end",
"def name; end",
"def name; end... | [
"0.79177445",
"0.7741643",
"0.7543874",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
"0.7539567",
... | 0.0 | -1 |
, on: :create makes sure password is present, confirmed and 6 to 20 characters | def password=(unencrypted_password) #setter method for password.
unless unencrypted_password.empty? #if there is no password, take the inputed password, salt and hash it. Then set it in the record for that user.
@password = unencrypted_password
self.password_digest = BCrypt::Password.create(unencrypted_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_on_create\n\t\t#puts \"--- ENTRANDO A VALIDATE ON CREATE ----- password, password_confirmation : #{self.password}, #{password_confirmation}\" \n\t\terrors.add('contraseña','no puede estar en blanco') unless !self.password.blank?\n\t\terrors.add('confirmación','no puede estar en blanco')... | [
"0.707499",
"0.7041856",
"0.7013879",
"0.69517136",
"0.68391645",
"0.6764066",
"0.66373885",
"0.6614064",
"0.6549531",
"0.65397495",
"0.65289646",
"0.6524361",
"0.6519417",
"0.6519417",
"0.6519417",
"0.6519417",
"0.6519417",
"0.6519417",
"0.6517804",
"0.64795953",
"0.6470556"... | 0.0 | -1 |
Initialize and run walker | def initialize(root, block)
@root, @block = root, block
dispatch(root)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(folder_walker)\n\t\t@folder_walker = folder_walker\n\tend",
"def walk; end",
"def run\n\t\t\t@walker.run do\n\t\t\t\tself.update\n\t\t\t\t\n\t\t\t\tyield @walker if block_given?\n\t\t\tend\n\t\tend",
"def walk(&block)\n instance_eval(&block)\nend",
"def set_walker\n @walker = Walker.fi... | [
"0.68178755",
"0.6643266",
"0.62453014",
"0.6156959",
"0.6048646",
"0.59823686",
"0.588834",
"0.58429426",
"0.58297706",
"0.582517",
"0.5813887",
"0.5809127",
"0.5749318",
"0.57279736",
"0.5670276",
"0.5598362",
"0.55786276",
"0.5570632",
"0.5545121",
"0.55060863",
"0.5499847... | 0.0 | -1 |
(prices on days 0, 1, ...) and outputs the most profitable pair of days on which to first buy the stock and then sell the stock, | def stock_picker(prices)
min_index, max_index = -1, -1
min_diff = 1.0/0.0 # positive infinity
i, j = 0, 1
while i < prices.length - 1
while j < prices.length
if prices[i] - prices[j] < min_diff
min_diff = prices[i] - prices[j]
min_index, max_index = i, j
end
j += 1
end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_picker(prices) \n min_price = Float::INFINITY\n day_min_cost = 0\n max_price = -Float::INFINITY\n profit = -Float::INFINITY\n best_days = []\n\n prices.each_with_index do |price, day|\n if price < min_price \n min_price = price\n day_min_cost = day\n ... | [
"0.83291537",
"0.8301248",
"0.8255051",
"0.82026064",
"0.81974506",
"0.81904966",
"0.81758815",
"0.8160288",
"0.8076529",
"0.80755687",
"0.8053499",
"0.8033491",
"0.797434",
"0.79628557",
"0.79492766",
"0.7941219",
"0.79200363",
"0.7916135",
"0.790684",
"0.79021865",
"0.78754... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. def set_post | def set_post
@post = Post.find(params[:id])
rescue ActiveRecord::RecordNotFound => e
render json: { error: e.to_s }, status: :not_found
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post\n raise NotImplementedError\n end",
"def post; end",
"def post_task\n end",
"def post\r\n end",
"def _eval_post\n _eval_action('post')\n end",
"def post\n end",
"def post_setup\n end",
"def post\n if phase.has_key?('post')\n execute(\"post\", phase['post'])\n ... | [
"0.65034115",
"0.6446669",
"0.6432541",
"0.64084876",
"0.64011943",
"0.63968515",
"0.6164632",
"0.6105911",
"0.6056664",
"0.6000905",
"0.5967724",
"0.5889567",
"0.5873356",
"0.5849263",
"0.582722",
"0.5787437",
"0.57558125",
"0.57431746",
"0.57355917",
"0.571892",
"0.56864434... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def post_params
params.require(:post).permit(:caption, :user_id, images: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69490993",
"0.6812977",
"0.6801889",
"0.67950445",
"0.6745037",
"0.6740698",
"0.65270424",
"0.6519444",
"0.6492448",
"0.6430671",
"0.6430671",
"0.6430671",
"0.63992614",
"0.6355569",
"0.6354901",
"0.63456345",
"0.63430274",
"0.63376623",
"0.6327184",
"0.6327184",
"0.632718... | 0.0 | -1 |
Replaces 'current_user' to provide account and accounts_user in Context. | def pundit_user
@pundit_user ||= Context.new(
account: current_account,
accounts_user: current_accounts_user,
user: current_user
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_account\n @account = current_user\n end",
"def context; { user: current_user } end",
"def current_user\n current_account\n end",
"def set_current_user\n User.current = current_user\n end",
"def update_current_user(user)\n @current_user = user if user\n end",
... | [
"0.6942678",
"0.6908841",
"0.687852",
"0.6868451",
"0.6853231",
"0.68381894",
"0.683534",
"0.6792495",
"0.6782303",
"0.6777079",
"0.6741104",
"0.6740072",
"0.6732967",
"0.67285234",
"0.66682327",
"0.66582125",
"0.66571486",
"0.66571486",
"0.66571486",
"0.66571486",
"0.6650271... | 0.0 | -1 |
Users are always allowed to manage their session, registration, subscription and account | def access_required?
user_signed_in? &&
!devise_controller? &&
!%w(
subscriptions
accounts
).include?(controller_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def users_only\n deny_access(\"Necesitas crear una cuenta para entrar a esta sección\") unless signed_in?\n end",
"def on_users_account\n true\n end",
"def manage_account\n if @user\n manage_account_menu\n else\n login\n manage_account_menu\n end\n end",
"def manage... | [
"0.7012217",
"0.67214894",
"0.6632757",
"0.6624118",
"0.65385675",
"0.65361595",
"0.65332615",
"0.6531607",
"0.65237486",
"0.65136564",
"0.6470299",
"0.64487445",
"0.64463395",
"0.642896",
"0.64105314",
"0.64040375",
"0.6395701",
"0.6395701",
"0.63791597",
"0.63746303",
"0.63... | 0.644266 | 13 |
Redirect users in accounts in bad standing to billing page | def check_access
redirect_to billing_path, flash: { error: "Your account is inactive. Access will be restored once payment succeeds." } if current_account.try(:inactive?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redirect_if_not_active\n unless current_user.status == :paid\n redirect_to action: \"choose_plan\"\n end\n end",
"def redirect_from_hop\n if session[:pay_post_made]\n if current_user and current_user.orders.order('created_at DESC').first\n order = current_user.orders.order('created... | [
"0.6979145",
"0.6678717",
"0.66289866",
"0.6368841",
"0.634281",
"0.6341985",
"0.63417107",
"0.6301136",
"0.6294412",
"0.62793434",
"0.62494624",
"0.621584",
"0.6197758",
"0.61514485",
"0.61498094",
"0.6146709",
"0.61345613",
"0.60887116",
"0.60686517",
"0.6066532",
"0.604267... | 0.7094632 | 0 |
returns the users for the project. | def users
set_attributes_for(User)
User.find(:all)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsers(projectId)\r\n\t\t\t\turl = getBaseURL+\"projects/\"+String(projectId)+\"/users/\"\t\t\r\n\t\t\t\tresponse = ZohoHTTPClient.get(url, getQueryMap)\t\t\r\n\t\t\t\treturn $userParser.getUsers(response)\r\n\t\t\tend",
"def users\n @users_collection ||= DataStore.users_for_project(self)\n end",
... | [
"0.8190731",
"0.7951698",
"0.7932548",
"0.7911717",
"0.79039216",
"0.78936076",
"0.78936076",
"0.78934443",
"0.7852999",
"0.7758238",
"0.7667056",
"0.7590525",
"0.75703436",
"0.7509743",
"0.7407559",
"0.73978883",
"0.7393979",
"0.73749566",
"0.7363079",
"0.73381823",
"0.73380... | 0.0 | -1 |
returns the wikis for the project. | def wikis
set_attributes_for(Wiki)
Wiki.find(:all)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @wikifiles = Wikifile.all\n end",
"def wikinames\n $_wikinames ||= build_wikinames\n end",
"def index\n @doc_pu_wikis = @doc_pu.doc_pu_wiki_pages\n end",
"def index\n @wikis = Wiki.all\n end",
"def index\n @wikis = @project.wikis\n\n respond_to do |format|\n ... | [
"0.6643206",
"0.6343877",
"0.6255705",
"0.61966074",
"0.61767596",
"0.60621107",
"0.60621107",
"0.5765324",
"0.5747786",
"0.5681829",
"0.55781853",
"0.55375206",
"0.5535804",
"0.54898787",
"0.5461689",
"0.54462326",
"0.5416881",
"0.5352968",
"0.53497803",
"0.53372884",
"0.533... | 0.76151276 | 0 |
returns the property definitions for the project. | def property_definitions
set_attributes_for(PropertyDefinition)
PropertyDefinition.find(:all)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def properties()\n @properties ||= begin\n pom = %w(groupId artifactId version packaging).inject({}) { |hash, key|\n value = project[key] || (parent ? parent.project[key] : nil)\n hash[key] = hash[\"pom.#{key}\"] = hash[\"project.#{key}\"] = value_of(value) if value\n hash\n ... | [
"0.7043262",
"0.69731706",
"0.6845802",
"0.6790796",
"0.6775503",
"0.6716253",
"0.66997534",
"0.66730136",
"0.66397107",
"0.6573263",
"0.65577",
"0.65552264",
"0.6529151",
"0.6494841",
"0.6492099",
"0.6440219",
"0.6425124",
"0.6393894",
"0.6393894",
"0.63913625",
"0.63177973"... | 0.75724435 | 0 |
returns the murmurs for the project. | def murmurs
set_attributes_for(Murmur)
Murmur.find(:all)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:proj, RDF.type, Ruta::Class.project],\n [:proj, RDF::FOAF.member, :mir],\n [:mir, Ruta::Property.has_member, uri]\n )\n projs = []\n query.each_solution { |sol| projs.push(sol.proj.as(Organisation)) }\n projs\n ... | [
"0.5621407",
"0.5550539",
"0.5447138",
"0.5432856",
"0.53935486",
"0.53611296",
"0.53516936",
"0.5330961",
"0.5324999",
"0.5318412",
"0.5310657",
"0.5301935",
"0.5301935",
"0.5291625",
"0.5224376",
"0.520722",
"0.52027243",
"0.5172757",
"0.5167284",
"0.51617825",
"0.51493025"... | 0.5688828 | 0 |
finds a single card | def find_card(number)
set_attributes_for(Card)
Card.find(number)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_card(id)\n found_card = nil\n cards.each { |card| found_card = card if card.id == id.to_i }\n found_card\n end",
"def find_card\n @client.remove_cards\n card = PayuLatam::Card.new(@client) # info de payu\n card.load( PayuCard.find(@selected_card).token )\n @client.add_card(... | [
"0.82328606",
"0.80786943",
"0.8043857",
"0.79800695",
"0.7978989",
"0.7671493",
"0.75866395",
"0.7358201",
"0.7179182",
"0.70867455",
"0.7043636",
"0.70052356",
"0.6984753",
"0.6814153",
"0.6810912",
"0.6753832",
"0.6721989",
"0.6574799",
"0.6550437",
"0.6534133",
"0.6515958... | 0.78482664 | 5 |
returns a filtered list of cards | def filter_cards(filter_str)
set_attributes_for(Card)
Card.apply_filter(filter_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_cards(cards)\n cards = Array(cards) unless cards.respond_to?(:count) \n return cards.select { |card| Card.get(card.id).nil? } #TODO: move this to method\n end",
"def retrieve_cards(category)\n self.unused_cards = Card.where(category: Category.find_by(name: category)).where.not(id: self.used_... | [
"0.8104395",
"0.6942105",
"0.69083244",
"0.68344027",
"0.6712353",
"0.66446733",
"0.66267145",
"0.65148646",
"0.6489907",
"0.6477109",
"0.6446121",
"0.64297193",
"0.6391008",
"0.6357982",
"0.635634",
"0.63313264",
"0.6325586",
"0.63185734",
"0.6300373",
"0.6282775",
"0.626745... | 0.6523171 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.