query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
GET /book_pages GET /book_pages.json | def index
@book_pages = @book.book_pages
respond_to do |format|
format.html # index.html.erb
format.json { render json: @book_pages }
end
end | [
"def show\n @book_page = @book.book_pages.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_page }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /book_pages/1 GET /book_pages/1.json | def show
@book_page = @book.book_pages.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @book_page }
end
end | [
"def index\n @book_pages = @book.book_pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @book_pages }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /book_pages/new GET /book_pages/new.json | def new
@book_page = @book.book_pages.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @book_page }
end
end | [
"def new\n @scrapbook = Scrapbook.new\n @page = @scrapbook.pages.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @scrapbook }\n end\n end",
"def new\n @page = current_site.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /book_pages POST /book_pages.json | def create
@book_page = @book.book_pages.build(params[:book_page])
respond_to do |format|
if @book_page.save
format.html { redirect_to book_series_collection_book_book_pages_url(@book_series, @collection, @book),
notice: 'Book page was successfully created.' }
format.json { r... | [
"def new\n @book_page = @book.book_pages.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @book_page }\n end\n end",
"def create\n @scrapbook = Scrapbook.new(params[:scrapbook])\n @page = @scrapbook.pages.new\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /book_pages/1 PUT /book_pages/1.json | def update
@book_page = @book.book_pages.find(params[:id])
respond_to do |format|
if @book_page.update_attributes(params[:book_page])
format.html { redirect_to book_series_collection_book_book_page_url(@book_series, @collection, @book, @book_page), notice: 'Book page was successfully updated.' }
... | [
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /book_pages/1 DELETE /book_pages/1.json | def destroy
@book_page = @book.book_pages.find(params[:id])
@book_page.destroy
respond_to do |format|
format.html { redirect_to book_series_collection_book_book_pages_url(@book_series, @collection, @book) }
format.json { head :no_content }
end
end | [
"def destroy\n @api_book.destroy\n\n head :no_content\n end",
"def destroy\n @book.book_identifier.delete rescue nil\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove comment from GitHub and then remove from database if successful. comment_id is unique identifier within repo scope. | def remove_comment repo, comment_id
response = @@connection.delete do | request |
request.url "repos/#{repo}/issues/comments/#{comment_id}"
request.headers['Authorization'] = "token #{@@token}"
end
# look for Status: 204 No Content
return if response.env[:status] != 204
# Comment ... | [
"def delete_pull_comment(repo, comment_id, options = T.unsafe(nil)); end",
"def delete_pull_request_comment(repo, comment_id, options = T.unsafe(nil)); end",
"def delete_pull_request_comment(repo, comment_id, options = {})\n boolean_from_response(:delete, \"#{Repository.path repo}/pulls/comments/#{commen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
2. I can find a list of exercises I did on a day | def exercise_on_a_day(date)
#iterate through workouts and find workouts.user_id == self
my_workouts = Workout.all.select do |workout|
workout["user_id"] == self["id"]
end
# find where date == workout date
workouts_for_date = my_workouts.find_all do |workouts|
... | [
"def get_exercises_list\n exercises_list = []\n inst_sections.each do |inst_section|\n exercises_ids = inst_section.inst_book_section_exercises.collect(&:inst_exercise_id).compact\n exercises_objs = InstExercise.where(id: exercises_ids)\n exercises_list.concat exercises_objs.collect(&:short_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
3. I can see what muscle_groups I'm working on, ON a specific day | def muscle_groups_on_given_day(date)
# exercise_name = self.exercise_on_a_day(date)
my_workouts = Workout.all.select do |workout|
workout["user_id"] == self["id"]
end
# find where date == workout date
workouts_for_date = my_workouts.find_all do |workouts|
... | [
"def date_group_items; end",
"def all_scheduled(db)\r\n\t\tall_array=[]\r\n\t\tall_array = db.execute(\"SELECT * FROM playgroups\")\r\n\t\tall_array.each do |i|\r\n\t\t\tputs \"Host:#{i[1]}, Location:#{i[3]}, Kids attending:#{i[2]}\"\r\n\t\tend\t\t\r\n\tend",
"def scsb_edd_patron_groups\n %w[EDD]\nend",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
5. I can log my weight at the end of the week | def log_my_weight(weight)
self.current_weight = weight
self.save
puts "Current weight #{weight}"
end | [
"def log_weight(weight, date, opts={})\n opts[:time] = format_time(opts[:time]) if opts[:time]\n post(\"/user/#{@user_id}/body/log/weight.json\", opts.merge(:weight => weight, :date => format_date(date)))\n end",
"def weight_recently_launched(data, max_weight, equalization_period_data)\n max... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
6. I can also find out how much I lost compared to my starting weight | def weight_lost
weight_fluctuate = current_weight - start_weight
if current_weight < start_weight
return "Down #{weight_fluctuate}. We are making progress!"
else
return "Up #{weight_fluctuate}. We are making gains!"
end
end | [
"def remaining_pints\n ((current_weight-14.25)/0.45).to_i > 0 ? ((current_weight-14.25)/0.45).to_i : 0\n end",
"def weight_until_goal\n if weigh_ins.count > 0 && goal_weight > 0\n weigh_ins.first.current_weight - goal_weight\n elsif goal_weight > 0\n start_weight - goal_weight\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
8. A user can create a new exercise to add to the database | def create_new_exercise(exercise, muscle_group)
Exercise.create(name: exercise, muscle_group: muscle_group)
puts "Thank you for sharing!"
end | [
"def add_exercise(name, description)\n sql = \"INSERT INTO exercises (name, description) VALUES ($1, $2);\"\n query(sql, name, description)\n end",
"def create_exercise()\n\n #Gets all the information from the user\n message(\"Please enter a name for this new exercise: \")\n name = get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
7. a user can log a new workout | def log_new_workout(exercise, date)
exercise_check = Exercise.search_exercise_by_name(exercise)
exercise_instance = Exercise.all.find{|exercises| exercises.name == exercise}
if exercise_check == "Sorry. We don't have any workouts called #{exercise}. Please return to the main menu to create this ... | [
"def create\n @logged_workout = LoggedWorkout.new(logged_workout_params)\n @logged_workout.user = current_user\n\n respond_to do |format|\n if @logged_workout.save\n format.html { redirect_to @logged_workout, notice: \"Logged workout was successfully created.\" }\n format.json { render :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /internships/1 GET /internships/1.json | def show
@internship = Internship.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @internship }
end
end | [
"def index\n @internships = Internship.all\n end",
"def index\n @internships = Internship.all\n @current_user = User.find(current_user.id)\n respond_with(@internships)\n end",
"def show\n @internships_user = InternshipsUser.find(params[:id])\n\n respond_to do |format|\n format.html # sh... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /internships/new GET /internships/new.json | def new
@internship = Internship.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @internship }
end
end | [
"def create\n @internship = current_user.internships.new(internship_params)\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to internships_url, notice: 'Internship was successfully created.' }\n else\n format.html { render action: 'new' }\n format.json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /internships POST /internships.json | def create
@internship = Internship.new(params[:internship])
respond_to do |format|
if @internship.save
format.html { redirect_to @internship, notice: 'Internship was successfully created.' }
format.json { render json: @internship, status: :created, location: @internship }
else
... | [
"def create\n @internship = current_user.internships.new(internship_params)\n\n respond_to do |format|\n if @internship.save\n format.html { redirect_to internships_url, notice: 'Internship was successfully created.' }\n else\n format.html { render action: 'new' }\n format.json ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /internships/1 PUT /internships/1.json | def update
@internship = Internship.find(params[:id])
respond_to do |format|
if @internship.update_attributes(params[:internship])
format.html { redirect_to @internship, notice: 'Internship was successfully updated.' }
format.json { head :no_content }
else
format.html { rend... | [
"def update\n respond_to do |format|\n if @internship.update(internship_params)\n format.html { redirect_to internships_url, notice: 'Internship was successfully updated.' }\n else\n format.html { render action: 'edit' }\n format.json { render json: @internship.errors, status: :unp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns an array with coordinates of the 1's | def find_ones
ones_arr = []
@image.each_index do |row|
@image[row].each_index do |column|
if @image[row][column] == 1
ones_arr << { :x => column, :y => row }
end
end
end
return ones_arr
end | [
"def find_ones\n # @image.each { |row| row.each { |pixel| ... } }\n cords = []\n\n\n @image.each_with_index do |row, row_index|\n # row = [0, 1, 0, 0]\n # puts \"#{row_index} - ROW\"\n row.each_with_index do |pixel, column_index|\n # pixel = 0\n # puts \"#{column_index} - COLU... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
checks if pixel to set within bounds and sets to 1 | def set_to_one(coords)
if (0..@max_x).include?(coords[:x]) && (0..@max_y).include?(coords[:y])
@image[coords[:y]][coords[:x]] = 1
end
end | [
"def set_pixel_if_within_bounds(x, y, color); end",
"def set_pixel_if_within_bounds(x, y, color)\n return unless include_xy?(x, y)\n @pixels[y * width + x] = color\n end",
"def restricted?(x, y)\n out_of_bounds?(x, y) || @image.color(x, y) == 0\n end",
"def outside_curr_image_bounds?(row,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
randomly generates an image from template (random values are normally distributed with mean = characetristic , deviation = sigma) | def create_sample_image_from_template(image_template, sigma)
random_characteristics = image_template.ideal_characteristics.map do |val|
deviated = RandomGaussian.new(val, sigma).rand
deviated = 0.0 if deviated < 0
deviated = 1 if deviated > 1
deviated
end
# values = image_template.id... | [
"def random_header_image\n header_images.sample\n end",
"def random_image_old(horizontal=600,vertical=600)\n image_categories = ['abstract','city','people','transport','animals','food','nature','business', 'nightlife', 'sports','cats','fashion','technics']\n image_category = image_categories[Random.rand... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Restarts the SSH service | def ssh_service_restart
exec(Beaker::Command.new("stopsrc -g ssh"))
exec(Beaker::Command.new("startsrc -g ssh"))
end | [
"def restartIpService\n %x(ssh root@#{nodeRealName} \"echo \\'service networking restart\\' | at now + 1 minute\")\n end",
"def ssh_service_restart\n case self['platform']\n when /debian|ubuntu|cumulus|huaweios/\n exec(Beaker::Command.new(\"service ssh restart\"))\n when /(el|centos|redhat|oracl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The maximum slack_before such that there is no collision with (the slack of) another reservation before the begins_at time This value could be negative, indicating that the begins_at value always collides with (the slack of) another reservation | def max_slack_before(begins_at)
previous_reservation = Reservation.new(entity: self, begins_at: begins_at).previous
(begins_at - previous_reservation.ends_at - previous_reservation.slack_after.minutes) / 1.minute if previous_reservation.present?
end | [
"def max_slack_after(ends_at)\n next_reservation = Reservation.new(entity: self, ends_at: ends_at).next\n (next_reservation.begins_at - next_reservation.slack_before.minutes - ends_at) / 1.minute if next_reservation.present?\n end",
"def slack_before_overlapping?\n previous_reservation = self.previous\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The maximum slack_after such that there is no collision with (the slack of) another reservation after the ends_at time This value could be negative, indicating that the ends_at value always collides with (the slack of) another reservation | def max_slack_after(ends_at)
next_reservation = Reservation.new(entity: self, ends_at: ends_at).next
(next_reservation.begins_at - next_reservation.slack_before.minutes - ends_at) / 1.minute if next_reservation.present?
end | [
"def max_slack_before(begins_at)\n previous_reservation = Reservation.new(entity: self, begins_at: begins_at).previous\n (begins_at - previous_reservation.ends_at - previous_reservation.slack_after.minutes) / 1.minute if previous_reservation.present?\n end",
"def slack_after_overlapping?\n next_reservat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set property values by an list/array (matching array index on property index) or hash (matching hash key on property name or index depending on key type) | def set_properties(*values)
if values.size == 1 && values.first.is_a?(Hash)
# We are dealing with a hash
values.first.each do |key, index|
self.set_property(key, value)
end
else
# We are dealing with a list/array
values.flatten.each_with_index do |value, index|
self... | [
"def set_properties_from_array(properties)\n @property_names_to_types.keys.zip(properties).each do |name, value|\n set_value(name, value)\n end\n end",
"def []=(key, value)\n k = key.to_s\n if value.nil?\n remove_property(k)\n elsif (Array === value)\n case value[0]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array 'board' of rows Each row is an array with randomly assigned values from 'colours' array | def get_board(width, height)
# Create a new 2D array
board = Array.new($board_height) {Array.new($board_width)}
# Each element will be assigned a random value from 'colours'
# That is done by choosing a random index of the 'colours' array
(0...$board_height).each do |row|
(0...$board_width).each do |cel... | [
"def get_board(width, height)\n board = Array.new(height) {Array.new(width)}\n colours = [:red, :blue, :green, :yellow, :cyan, :magenta]\n (0...board.length).each do |i|\n (0...board[i].length).each do |j|\n random = rand colours.length\n board[i][j] = colours[random]\n end\n end\n return board... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update_board method used to update the board after the user choose a new colours First the top left field is updated to the new colour For each neighbour field that has the same colour as the first field had before changing it, recursively update that field as well | def update_board(board,new_colour,old_colour,i,j)
# Update field colour
board[i][j]= new_colour
# Check if there is a neighbour on top and if that neighbour has the same colour as the previous colour
# If yes, then that neighbour is chosen to be updated in turn
if (i-1) >=0 && board[i-1][j] == old_colou... | [
"def update_board(row, column, board, current_colour, new_colour)\n if (current_colour != new_colour) then\n if (board[row][column] == current_colour) then\n board[row][column] = new_colour\n if (row == 0 && column == 0) then\n update_board(row+1, column, board, current_colour, new_colour)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /bingos or /bingos.json | def create
@bingo = Bingo.new(bingo_params)
respond_to do |format|
if @bingo.save
format.html { redirect_to @bingo, notice: "Bingo was successfully created." }
format.json { render :show, status: :created, location: @bingo }
else
format.html { render :new, status: :unprocess... | [
"def create\n @bingo = Bingo.new(params[:bingo])\n\n respond_to do |format|\n if @bingo.save\n format.html { redirect_to @bingo, notice: 'Bingo was successfully created.' }\n format.json { render json: @bingo, status: :created, location: @bingo }\n else\n format.html { render ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /bingos/1 or /bingos/1.json | def update
respond_to do |format|
if @bingo.update(bingo_params)
format.html { redirect_to @bingo, notice: "Bingo was successfully updated." }
format.json { render :show, status: :ok, location: @bingo }
else
format.html { render :edit, status: :unprocessable_entity }
form... | [
"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_aos_version(args = {}) \n put(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def update\n @bof = Bof.find(params[:id])\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return bool indicating if spec file satisfies any file in gem | def has_file_satisfied_by?(spec_file)
file_paths.any? { |gem_file| RPM::Spec.file_satisfies?(spec_file, gem_file) }
end | [
"def has_file_satisfied_by?(spec_file)\n file_paths.any? { |gem_file| RPM::Spec.file_satisfies?(spec_file, gem_file) }\n end",
"def gemspec?\n File.extname(self) == \".gemspec\"\n end",
"def gemspec?\n !gemspecs.empty?\n end",
"def gem?\n #return true if Dir[File.join(location, '*.g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Download the local gem and return it as a string | def download_gem
self.class.download_gem @name, @version
end | [
"def download_gem\n gem_path = \"https://rubygems.org/gems/#{@name}-#{@version}.gem\"\n curl = Curl::Easy.new(gem_path)\n curl.follow_location = true\n curl.http_get\n gemf = curl.body_str\n end",
"def download_gem\n self.class.download_gem @name, @version\n end",
"def get(lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns path to gem, either specified one of downloaded one | def gem_path
@path || downloaded_gem_path
end | [
"def gem_path\n @path || downloaded_gem_path\n end",
"def downloaded_gem_path\n self.class.downloaded_gem_path @name, @version\n end",
"def get_path(gemname, version_req)\n return gemname if gemname =~ /\\.gem$/i\n\n specs = Gem::source_index.find_name gemname, version_req\n\n selected ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return diff of content in this gem against other | def diff(other)
require_cmd! diff_cmd
out = nil
begin
this_dir = unpack
other_dir = other.is_a?(Polisher::Gem) ? other.unpack :
(other.is_a?(Polisher::Git::Repo) ? other.path : other)
result = AwesomeSpawn.run("#{diff_cmd} -r #{this_dir} #{oth... | [
"def diff(other_version, format=:unified)\n Diff.cs_diff(content_html, other_version.content_html, :unified, 0) unless other_version.nil?\n end",
"def display_diff(version1, version2)\n version1_text = render_wiki_content(:content => version1)\n version2_text = render_wiki_content(:content => versio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The plane method is used to retrieve the plane of the arc. Refer to the Geom module for instructions to create a plane. | def plane
end | [
"def plane\n return nil if @vertices.length < 3\n Plane.three_points(*@vertices[0..2])\n end",
"def get_plane\n end",
"def get_plane\n Plane.construct_with_three_points(point_a, point_b, point_c)\n end",
"def project_to_plane(plane)\n end",
"def distance_to_plane(plane)\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The start_angle method is used to retrieve the angle of the start of the arc, measured from the X axis in radians. | def start_angle
end | [
"def start_angle\n MSPhysics::Newton::Hinge.get_start_angle(@address)\n end",
"def start_angle=(angle)\n MSPhysics::Newton::Hinge.set_start_angle(@address, angle)\n end",
"def arc(x, y, radius, start_angle, end_angle)\n start_angle = radians(90 - start_angle)\n end_angle = radians(90... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The xaxis method is used to retrieve the X axis of the coordinate system for the curve. Note that the length of the returned vector is equal to the radius of the underlying curve. | def xaxis
end | [
"def x_axis_coords\n current_x_coord = self.current_pos[0]\n [current_x_coord, (current_x_coord + self.width)]\n end",
"def xaxis\n end",
"def x\n x_value = bounds.x\n x_value -= parent.absolute_x if parent.is_a?(Shape)\n x_value\n end",
"def set_x_axis(para... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The yaxis method is used to retrieve the Y axis of the coordinate system for the curve. Note that the length of the returned vector is equal to the radius of the underlying curve. | def yaxis
end | [
"def y_axis_coords\n current_y_coord = self.current_pos[1]\n [current_y_coord, (current_y_coord + self.height)]\n end",
"def set_y_axis(params = {})\n @y_axis = convert_axis_args(@y_axis, params)\n end",
"def vector_y max_value = 1\n max_value * Math.sin(self.to_radians)\n end",
"def create... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the needed paths. install_dir: The gems will be temporarily installed into this directory. Caution: Before installing the directory will be delete. jar_dir: The directory where the JAR files will be put. | def setup(install_dir, jar_dir)
@install_dir = install_dir
@jar_dir = jar_dir
end | [
"def bundle\n raise \"Paths not given! Call setup first.\" if @install_dir.nil? || @jar_dir.nil?\n gems_jar = File.join(jar_dir, 'gems.jar')\n default_options = { :generate_rdoc => false, \n :generate_ri => false,\n :install_dir => install_dir }\n FileUtils.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Bundles the required gems into a JAR file. Before the gems are packed into the JAR, all JARs inside the gems are moved to the jar_dir. | def bundle
raise "Paths not given! Call setup first." if @install_dir.nil? || @jar_dir.nil?
gems_jar = File.join(jar_dir, 'gems.jar')
default_options = { :generate_rdoc => false,
:generate_ri => false,
:install_dir => install_dir }
FileUtils.rm_rf install... | [
"def add_bundled_gems\n return unless bundle_gems\n\n if bundle_local\n logger.trace 'Adding bundler filer to jar locally...'\n else\n logger.trace 'Adding bundler files to jar...'\n end\n\n require 'bundler'\n begin\n gemfile_path, lockfile_path ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /daties POST /daties.json | def create
@daty = current_user.daties.build(daty_params)
respond_to do |format|
if @daty.save
format.html { redirect_to @daty, notice: 'Daty was successfully created.' }
format.json { render :show, status: :created, location: @daty }
else
format.html { render :new }
... | [
"def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /daties/1 DELETE /daties/1.json | def destroy
@daty.destroy
respond_to do |format|
format.html { redirect_to daties_url, notice: 'Daty was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @json_datum.destroy\n respond_to do |format|\n format.html { redirect_to json_data_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prints out the coin attributes for the Coin object with terminaltable gem | def attributes
table = terminal_table do |t|
t.title = name.upcase
t.add_row ["Price USD:", "$#{price_usd}"]
t.add_row ["Price BTC:", "#{price_btc}"]
t.add_row ["Market Cap USD:", "$#{market_cap_usd}"]
t.add_row ["Change Last 24h:", "#{percent_change_24h}%"]
t.add_row ["Last Upda... | [
"def coin_attributes\n table = terminal_table do |t|\n t.title = name.upcase\n t.add_row [\"Change:\", \"#{change}%\"]\n price.each do |currency, price|\n t.add_row [currency.upcase, price.to_f.round(2)]\n end\n t.style = { all_separators: true, width: 30 }\n end\n puts tabl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Using the options build when the commandline was parsed, instantiate a new Capistrano configuration, initialize it, and execute the requested actions. Returns the Configuration instance used, if successful. | def execute!
config = instantiate_configuration(options)
config.debug = options[:debug]
config.dry_run = options[:dry_run]
config.preserve_roles = options[:preserve_roles]
config.logger.level = options[:verbose]
set_pre_vars(config)
load_recipes(config)
... | [
"def execute!\n config = instantiate_configuration\n config.logger.level = options[:verbose]\n config.load 'deploy'\n\n status = catch(:abort_called_by_capistrano){\n set_webistrano_logger(config)\n \n set_up_config(config)\n \n exchange_real_revision(config) u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The current_user can be found in the JWT payload; eagerly load the user's roles so they can be discriminated against | def current_user
@current_user ||= User.includes(:roles).find_by(id: payload['user_id'])
end | [
"def current_user\n @current_user ||= CurrentUser.includes(:roles).find_by(email: id_token[:email])\n end",
"def current_user\n if decoded_payload\n # Can't use symbol for hash key, JWT parses it as string\n @current_user ||= User.find_by(id: decoded_payload['user_id'])\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
called after the user has been destroyed delete all user maps | def delete_maps
own_maps.each do | map |
logger.debug "deleting map #{map.inspect}"
map.destroy
end
end | [
"def clear_users\n @users = {}\n end",
"def clear_users\n @users = {}\n end",
"def delete_user_machine_mapping\n output = IO.popen(\"mozybfstcli user show\").readlines\n data = JSON.parse(output[1])\n data = data['items']\n data.each do |item|\n if (item['data'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set meta tags for the page. See MetaTags::ViewHelperset_meta_tags for details. | def set_meta_tags(meta_tags)
self.meta_tags.update(meta_tags)
end | [
"def set_page_meta_tags\n req = self.request\n set_meta_tags_for_url_path(req.base_url, req.fullpath)\n end",
"def page_meta_tags\n set_meta_tags title: seo_data[:title]\n set_meta_tags description: seo_data[:description]\n set_meta_tags keywords: seo_data[:keywords]\n set_meta_tags canonical: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
routines to add: is mysql even installed? is mysql process started? is mysql listening at all on remote node? check the cluster status on a remote node start the mysql service with the given address restart the mysql service cos the cluster is complete | def create
# this routine creates the cluster - if this runs, exists? has exited false
# first we check all the nodes to ensure mysql is listening, and if the
# wsrep_cluster_status is primary. If one is, we'll join it.
# array cluster_servers is the list of hosts to check
first_node = true
... | [
"def check_for_mysql_presence(host,user,system_user)\n Net::SSH.start(host,system_user, {auth_methods: %w( publickey )}) do |ssh|\n output = ssh.exec!(\"ps -U #{user} -u #{user} u\")\n if output =~ /mysql/\n $results += 1\n # Grab the port number. This requires ruby 1.9.2+\n /port=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /report_orders_by_users GET /report_orders_by_users.json | def index
@report_orders_by_users = ReportOrdersByUser.all
end | [
"def show_user_reports\n reports = User.find(params[:id]).reports\n render :json => reports\n end",
"def orders_report(start_date, end_date, status, format, offset=0)\n rest_url = \"#{@api}/report/orders/detail/#{format}?startDate=#{start_date}&endDate=#{end_date}&status=#{status}&offset=#{offset}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /report_orders_by_users POST /report_orders_by_users.json | def create
@report_orders_by_user = ReportOrdersByUser.new(report_orders_by_user_params)
respond_to do |format|
if @report_orders_by_user.save
format.html { redirect_to @report_orders_by_user, notice: 'Report orders by user was successfully created.' }
format.json { render :show, status: ... | [
"def index\n @report_orders_by_users = ReportOrdersByUser.all\n end",
"def export_user_request\n @user = User.find(params[:id])\n @user_requests = @user.pto_requests\n\n respond_to do |format|\n format.csv { send_data @user_requests.to_csv }\n end\n end",
"def user_report\n user = User.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /report_orders_by_users/1 PATCH/PUT /report_orders_by_users/1.json | def update
respond_to do |format|
if @report_orders_by_user.update(report_orders_by_user_params)
format.html { redirect_to @report_orders_by_user, notice: 'Report orders by user was successfully updated.' }
format.json { render :show, status: :ok, location: @report_orders_by_user }
else
... | [
"def update\n @users_report = UsersReport.find(params[:id])\n\n if @users_report.update(params[:users_report])\n head :no_content\n else\n render json: @users_report.errors, status: :unprocessable_entity\n end\n end",
"def update #only patch owned reports, do not edit client/user since thei... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /report_orders_by_users/1 DELETE /report_orders_by_users/1.json | def destroy
@report_orders_by_user.destroy
respond_to do |format|
format.html { redirect_to report_orders_by_users_url, notice: 'Report orders by user was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @users_report = UsersReport.find(params[:id])\n @users_report.destroy\n\n head :no_content\n end",
"def destroy\n @user_reports = UserReport.find(params[:id])\n @user_reports.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_reports_url) }\n format.xml... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the point offset in a 3D space | def view_offset
@position + Moon::Vector3[@view.position, 0]
end | [
"def origin\r\n Point3.origin\r\n end",
"def dot(point3)\n (@x*point3.x)+(@y*point3.y)+(@z*point3.z)\n end",
"def distance_to(point3)\n Math.sqrt(((@x-point3.x)**2)+((@y-point3.y)**2)+((@z-point3.z)**2))\n end",
"def ll_to_point3d(flatten)\n #puts \"x: \" + @x.to_s\n #puts \"y: \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a response from the Solr endpoint for a faceted query | def get_fq_solr_response(fq)
solr_url = @blacklight_context.connection_config[:url]
conn = Faraday.new(url: solr_url) do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
end
facet_request = ... | [
"def get_facet_field_response(facet_field, user_params = params || {}, extra_controller_params = {})\n solr_params = solr_facet_params(facet_field, user_params, extra_controller_params)\n # Make the solr call\n find(solr_params)\n end",
"def get_facet_field_response(facet_field, user_params = params || ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the URL for the current Blacklight Solr core | def core_url
@blacklight_context.default_index.connection.uri.to_s.gsub(%r{^.*\/solr}, '/solr')
end | [
"def blacklight_url\n blacklight_connection.base_uri\n rescue StandardError\n ENV[\"SOLR_URL\"] || \"http://127.0.0.1:8983/solr/blacklight-core\"\n end",
"def url\n \"http://#{host}:#{port}/solr/\"\n end",
"def url\n \"http://127.0.0.1:#{port}/solr/\"\n end",
"def solr_url\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /nostros/1 GET /nostros/1.xml | def show
@nostro = Nostro.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @nostro }
end
end | [
"def show\n @nossos_servico = NossosServico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /nostros/new GET /nostros/new.xml | def new
@nostro = Nostro.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @nostro }
end
end | [
"def new\n @nossos_servico = NossosServico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @nossos_servico }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /nostros POST /nostros.xml | def create
@nostro = Nostro.new(params[:nostro])
respond_to do |format|
if @nostro.save
flash[:notice] = 'Nostro was successfully created.'
format.html { redirect_to(@nostro) }
format.xml { render :xml => @nostro, :status => :created, :location => @nostro }
else
for... | [
"def create\n @nossos_servico = NossosServico.new(params[:nossos_servico])\n\n respond_to do |format|\n if @nossos_servico.save\n format.html { redirect_to(@nossos_servico, :notice => 'Nossos servico was successfully created.') }\n format.xml { render :xml => @nossos_servico, :status => :c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /nostros/1 DELETE /nostros/1.xml | def destroy
@nostro = Nostro.find(params[:id])
@nostro.destroy
respond_to do |format|
format.html { redirect_to(nostros_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @domino = Domino.find(params[:id])\n @domino.destroy\n\n respond_to do |format|\n format.html { redirect_to(dominos_url) }\n format.xml { head :ok }\n end\n end",
"def del\n @status1 = Status1.find(params[:id])\n @status1.destroy\n\n respond_to do |format|\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If children need to do anything special on apply, now's their chance. | def apply_children
end | [
"def apply_to_children(&block)\n self.entities.each do |entity|\n block.call(entity)\n entity.apply_to_children(&block)\n end\n end",
"def ignore_children!\n @ignoring_children += 1\n end",
"def measure_children()\n children.each do |child|\n child.measure()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If our object has a blueprint and a max_field equivalent of a field, offer a 'max' button. field is a sym of the field in question, input is the input field to populate. | def check_max_button(field,input)
if @object.respond_to?(:blueprint)
max = ("max_" + field.to_s ).to_sym
if @object.blueprint.respond_to?(max)
num_max = @object.send(max)
maxButton = Button.new("Max") do
input.text = num_max.to_s
end
maxButton.rect.x = input.rec... | [
"def max\n read_attribute(:max) or ( input and input.max )\n end",
"def set_max(fields)\n view.update_many(\"$max\" => collect_operations(fields))\n end",
"def set_Max(value)\n set_input(\"Max\", value)\n end",
"def max(action)\n limits(action)[:max]\n end",
"def max(fiel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the maximum number of times to retry sending the request to the API. (Default is 5) Returns self to accommodate method chaining. | def retry_at_most(max_retries)
@max_retries = max_retries
self
end | [
"def max_retry\n 5\n end",
"def send_maximum_retry\n super\n end",
"def set_send_maximum_retry(opts)\n opts = check_params(opts,[:retries])\n super(opts)\n end",
"def max_retry_delay\n @max_retry_delay ||= DEFAULT_MAX_RETRY_DELAY\n end",
"def retry_limit\n @re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Changes the Serializer from the default. Returns self to accommodate method chaining. | def with_serializer(serializer)
@serializer = serializer
self
end | [
"def freeze!\n serializers.freeze\n\n self\n end",
"def set_root_serializer(name); root_serializer_options[:serializer_class] ||= name; end",
"def set_serializer(self_class, serializer_class)\n self_class.instance_variable_set(SERIALIZER_CLASS, serializer_class)\n end",
"def serialize... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This may be useful when using a local installation of the SmartyStreets APIs. base_url is a string that defaults to the URL for the API corresponding to the Client object being built. Returns self to accommodate method chaining. | def with_base_url(base_url)
@url_prefix = base_url
self
end | [
"def initialize base_url\n @base_url = base_url\n end",
"def initialize(base_uri= \"http://localhost:8080\")\n @base_uri = base_uri\n @version = \"v1\"\n end",
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Enables debug mode, which will print information about the HTTP request and response to $stdout. Returns self to accommodate method chaining. | def with_debug
@debug = true
self
end | [
"def set_debug_flag\n if @http_log_debug\n @httparty_log_level = :debug\n @httparty_log_format = :curl\n end\n end",
"def enable_debug\n self.class.enable_debug\n self\n end",
"def debug enable\n @debug_mode = enable\n end",
"def debug!\n self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call given request and create matching response object | def call(request)
begin
response = RestClient.post(URI.escape(Config.api_url + request.operation), request.data)
rescue RestClient::Unauthorized, Exception
return nil
end
# Check response
if response.code != 200
return nil
end
# Parse response
parsed_response = JSON... | [
"def call(request, response_class)\n request.valid?\n uri = @endpoint.clone\n uri.query = query(request).to_s\n response = request(uri)\n puts \"Response:\\n#{response.body}\\n\\n\" if $DEBUG\n response_class.new(response.body)\n end",
"def request\n Response.new(make_request... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sofas/1 GET /sofas/1.xml | def show
#@sofa = Sofa.find(params[:title])
@sofa = Sofa.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @sofa }
end
end | [
"def new\n @sofa = Sofa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sofa }\n end\n end",
"def show\n @soon = Soon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @soon }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sofas/new GET /sofas/new.xml | def new
@sofa = Sofa.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @sofa }
end
end | [
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n @soon = Soon.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @soon }\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /sofas POST /sofas.xml | def create
@sofa = Sofa.new(params[:sofa])
respond_to do |format|
if @sofa.save
flash[:notice] = 'Sofa was successfully created.'
format.html { redirect_to(@sofa) }
format.xml { render :xml => @sofa, :status => :created, :location => @sofa }
else
format.html { rende... | [
"def create\n @sofa = Sofa.new(sofa_params)\n\n respond_to do |format|\n if @sofa.save\n format.html { redirect_to @sofa, notice: 'Sofa was successfully created.' }\n format.json { render :show, status: :created, location: @sofa }\n else\n format.html { render :new }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /sofas/1 PUT /sofas/1.xml | def update
@sofa = Sofa.find(params[:id])
respond_to do |format|
if @sofa.update_attributes(params[:sofa])
flash[:notice] = 'Sofa was successfully updated.'
format.html { redirect_to(@sofa) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post opts.fetch(:path, update_path), opts\n end",
"def update\n respond_to do |format|\n if @sofa.update(sofa_params)\n format.html { redirect_to @sofa, notice: 'Sofa was successfully updated.'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /sofas/1 DELETE /sofas/1.xml | def destroy
@sofa = Sofa.find(params[:id])
@sofa.destroy
respond_to do |format|
format.html { redirect_to(sofas_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @softdb = Softdb.find(params[:id])\n @softdb.destroy\n\n respond_to do |format|\n format.html { redirect_to(softdbs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @sa = Sa.find(params[:id])\n @sa.destroy\n\n respond_to do |format|\n format.html {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests to see if specified dropdown group should be highlighted or not | def highlight?(dropdown_group)
if dropdown_group == 'home'
["/", "/dashboard/network"].any? do | route |
current_page?(route)
end
elsif dropdown_group == 'manage'
["/dashboard/visualconfig", "/dashboard/manage", "/dashboard/instances"].any? do | route |
current_page?(route)
... | [
"def group_choosen?\n !current_group.nil?\n end",
"def selected_group?(group_name)\n @selected_path[1].to_s == group_name.to_s\n end",
"def group?\n return self.selector == Selector::GROUP\n end",
"def is_option_from_radio_button_group_selected(access_type, by, option, access_name, should_be_selec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the current page number of the manga. This will not make any api calls and only looks at (url, referer_url). | def manga_page
# http://i2.pixiv.net/img04/img/syounen_no_uta/46170939_p0.jpg
# http://i1.pixiv.net/c/600x600/img-master/img/2014/09/24/23/25/08/46168376_p0_master1200.jpg
# http://i1.pixiv.net/img-original/img/2014/09/25/23/09/29/46183440_p0.jpg
if url =~ %r{/\d+_p(\d+)(?:_\w+)?\.#{EXT}... | [
"def page_number\n @page_number ||= full_response[\"PageNumber\"]&&full_response[\"PageNumber\"].to_i\n end",
"def current_page_number\n return 1 if page_is_first_page?\n page_number\n end",
"def page_number\n from_meta(:page_number, 1)\n end",
"def PageNo()\n\t\t#Get current page... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST CASE: CONSTANT OPERATORS. IT SHOULD CONTAIN ALL VALID OPERATORS | def test_operator_array
assert_equal(OPERATORS, RomanMathmaticalOperation::OPERATORS)
assert_not_equal(WRONG_OPERATORS, RomanMathmaticalOperation::OPERATORS )
end | [
"def test_operator_valid\n assert @rpn.operator?('+')\n assert @rpn.operator?('-')\n assert @rpn.operator?('/')\n assert @rpn.operator?('*')\n end",
"def test_valid_input\n assert_equal(nil, RomanMathmaticalOperation.new(\"X\", \"+\",\"V\").send(:valid_input))\n exception = assert_raise(\"Roman... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST CASE: to_num METHOD. IT SHOULD RETURN INTEGER VALUE IF VALID INPUT (ROMAN LETTER) PASSED ELSE RETURN 0 | def test_to_num
assert_equal(11, RomanMathmaticalOperation.new.send(:to_num,"XI"))
assert_equal(0, RomanMathmaticalOperation.new.send(:to_num,"wrong"))
assert_not_equal(11, RomanMathmaticalOperation.new.send(:to_num,"X"))
end | [
"def to_num\n if token == \"i\"\n return token.to_c\n elsif token.include? \".\"\n return token.to_f\n elsif (token =~ /[a-zA-Z]/) == 0\n return token\n else\n return token.to_i\n end\n end",
"def charToNum(letter)\n return letter.upcase.ord-65 #ensure this is uppercase???\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST CASE: valid_input METHOD. IT SHOULD RETURN nil IF VALID(ROMAN LETTERS AND OPERATORS) INPUT PASSED ELSE RAISE EXCEPTION | def test_valid_input
assert_equal(nil, RomanMathmaticalOperation.new("X", "+","V").send(:valid_input))
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.new("X", "+",nil).send(:valid_input)}
assert_equal("This X or is not valid", exception.message)
exception = assert... | [
"def test_accepting_vaild_input\n input = ''\n end",
"def test_handle_input_valid\r\n input = '1 1 +'\r\n assert_output(\"2\\n\") {@arg_checker.handle_input(input)}\r\n end",
"def get_and_validate_input\n result = gets.chomp.strip\n case\n when result.length < 2\n return FALSE\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST is_roman METHOD IT SHOULD RETURN TRUE IF VALID(ROMAN LETTER) INPUT PASSED ELSE RAISE EXCEPTION | def test_is_roman
assert_equal(true, RomanMathmaticalOperation.is_roman("V"))
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmaticalOperation.is_roman(1)}
assert_equal("Not valid input", exception.message)
exception = assert_raise("RomanMathmaticalOperationError") {RomanMathmatical... | [
"def is_roman?\n @input.is_a? String\n end",
"def validate_roman roman_str\n\tif roman_str.scan(/^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/).empty?\n\t\tabort(\"Invalid Roman Language\")\n\tend\nend",
"def roman?\r\n # Liberal definition: all Roman numeral letters\r\n self.upcase =~ ROM... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TEST OUTPUT OF THE EXPRESSION PASSED TO THE execute_expression IF VALID INPUT(ROMAN LETTERS) GIVEN IT SHOULD RETURN VALID OUTPUT(ROMAN LETTERS) ELSE RAISE EXCEPTION | def test_execute_expression
assert_equal("L", RomanMathmaticalOperation.new("XL","+","X").execute_expression)
assert_equal("XCIX", RomanMathmaticalOperation.new("C","-","I").execute_expression)
assert_equal("X", RomanMathmaticalOperation.new("C","/","X").execute_expression)
assert_equal("C", RomanMathma... | [
"def test_empty_str(empty_str, exp_result)\n actual_result = Validator.string_of_nums?(empty_str)\n if(actual_result == exp_result)\n puts(\"PASS\")\n else\n puts(\"FAIL\")\n end\n return actual_result\nend",
"def test_valid_input\n assert_equal(nil, RomanMathmaticalOperation.new(\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor == Parameters: api_key The api_key of the partner (which may be found in the api_keys section of the console) id The account id of the partner (which may be found in the settings page of the console) | def initialize(api_key = Sift.api_key, id = Sift.account_id)
@api_key = api_key
@id = id
end | [
"def initialize(api_key = Sift.api_key, id = Sift.account_id)\n raise(\"api_key must be a non-empty string\") unless valid_string?(api_key)\n raise(\"partner must be a non-empty string\") unless valid_string?(id)\n @api_key = api_key\n @id = id\n end",
"def initialize(api_key, account_id, a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new merchant account under the given partner. == Parameters: site_url the url of the merchant site site_email an email address for the merchant analyst_email an email address which will be used to log in at the Sift Console password password (at least 10 chars) to be used to sign into the Console When success... | def new_account(site_url, site_email, analyst_email, password)
reqBody = {:site_url => site_url, :site_email => site_email,
:analyst_email => analyst_email, :password => password}
begin
http_post(accounts_url(), reqBody)
rescue Exception => e
puts e.message
put... | [
"def new_account(site_url, site_email, analyst_email, password)\n\n raise(\"site url must be a non-empty string\") unless valid_string?(site_url)\n raise(\"site email must be a non-empty string\") unless valid_string?(site_email)\n raise(\"analyst email must be a non-empty string\") unless valid_stri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the configuration which controls http notifications for all merchant accounts under this partner. == Parameters cfg A Hash, with keys :http_notification_url and :http_notification_threshold The value of the notification_url will be a url containing the string '%s' exactly once. This allows the url to be used as... | def update_notification_config(cfg)
http_put(notification_config_url(), cfg)
end | [
"def update_notification_config(cfg = nil)\n\n raise(\"configuration must be a hash\") unless cfg.is_a? Hash\n\n http_put(notification_config_url(), cfg)\n end",
"def notify_config\n { url: new_resource.notify_url }\n end",
"def action_enable_web_push_rss_with_http_info(campaign_hash, opts = {}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List of games where current_user is either black or white player | def my_games
return unless user_signed_in?
@my_games = Game.where('white_player_id = ? or black_player_id = ?', current_user.id, current_user.id).where(winning_player_id: nil).order(:created_at)
end | [
"def white_players\n Player.joins(:player_games).where(player_games: { game_id: self.id, team_color: PlayerGame::WHITE_TEAM })\n end",
"def games\n\t\tChessGame.where(\"black_player_id = ? OR white_player_id = ?\", self.id , self.id)\n\tend",
"def active_games_by_user db, username\n sql = %q[SELE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find unstarted games where the white_player_id matches the searched email address | def search_query(params)
user = User.find_by(email: params)
Game.where(white_player_id: user.id, black_player_id: nil).order(:created_at)
end | [
"def white_players\n Player.joins(:player_games).where(player_games: { game_id: self.id, team_color: PlayerGame::WHITE_TEAM })\n end",
"def my_games\n return unless user_signed_in?\n @my_games = Game.where('white_player_id = ? or black_player_id = ?', current_user.id, current_user.id).where(winnin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
rubocop:disable Metrics/AbcSize Prevent access to games_controllershow if player is not a part of that game | def own_game?
return unless @game.black_player_id
return if @game.white_player_id == current_user.id || @game.black_player_id == current_user.id
flash[:alert] = "Sorry, you're not a player in that game"
redirect_to games_path
end | [
"def player_of_game(game)\n game.player(self)\n end",
"def owner\n playerships.first(:conditions => {:owner => true}).player\n rescue\n destroy\n end",
"def computers_turn?\n self.current_player.class == Players::Computer ? true : false\n end",
"def must_be_my_turn\n @game = Game.find(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if game is in checkmate If so, present message indicating winner | def checkmate?
return unless @game.determine_checkmate
if @game.turn_number.even?
@game.update(winning_player_id: @game.black_player_id)
elsif game.turn_number.odd?
@game.update(winning_player_id: @game.white_player_id)
end
end | [
"def check_for_mate\n if @board.in_checkmate?( match.next_to_move )\n match.active = false\n match.winner = (match.next_to_move==:white ? match.player2 : match.player1)\n match.save\n end\n end",
"def winner\n winning_conditions_met? == \"x\" ? \"#{@player_one} won!\" : \"#{@player_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/buildings POST /admin/buildings.json | def create
@admin_building = Admin::Building.new(admin_building_params)
@admin_building.user = current_user
respond_to do |format|
if @admin_building.save
@admin_buildings = buildings(current_user)
create_default_service(@admin_building)
format.html { redirect_to @admin_buil... | [
"def create\n @building = Building.new(admin_building_params)\n\n respond_to do |format|\n if @building.save\n format.html { redirect_to admin_building_path(@building), notice: 'Building was successfully created.' }\n format.json { render :show, status: :created, location: @building }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/buildings/1 PATCH/PUT /admin/buildings/1.json | def update
respond_to do |format|
if @admin_building.update(admin_building_params)
@admin_buildings = buildings(current_user)
format.html { redirect_to @admin_building, notice: t(:building_notice_updated) }
format.json { render :show, status: :ok, location: @admin_building }
f... | [
"def update\n respond_to do |format|\n if @building.update(admin_building_params)\n format.html { redirect_to admin_building_path(@building), notice: 'Building was successfully updated.' }\n format.json { render :show, status: :ok, location: @building }\n else\n format.html { rende... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/buildings/1 DELETE /admin/buildings/1.json | def destroy
@admin_building.destroy
respond_to do |format|
format.html { redirect_to admin_buildings_url, notice: t(:building_notice_destroyed) }
format.json { head :no_content }
end
end | [
"def destroy\n @admin_building = Building.find params[:id]\n @admin_building.destroy\n respond_to do |format|\n format.html { redirect_to admin_buildings_url, notice: 'Building was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @building = Buildi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update this fetches the existing student by the id for editing in the view and updates changes to that id if there is an error preventing update, it renders the edit form again | def update
set_student
if @student.update_attributes(edit_params)
redirect_to @student
else
render 'edit'
end
end | [
"def update\n\t\t#for each student, find the student using student id\n\t\t@student = Student.find(params[:id])\n\t\t#update the student using the student params\n\t\t@student.update(student_params)\n\t\t#go back to the student path when done\n\t\tredirect_to student_path(@student)\n\t#wraps up \"update\" action\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
supervisors for the student | def supervisor
@supervisors = Allocation.all.order(created_at: :desc).where(student_id: current_student.id)
end | [
"def supervisores\n @supervisor = User.all\n end",
"def academics\n [supervisor] + examiners\n end",
"def senior(students)\n students.select {|student| student.senior? }\nend",
"def students\n self.course_person.all(:type => \"student\").persons\n end",
"def get_student\n\t\tstudent... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Find a named cluster by name | def named_cluster(name = context&.cluster)
return nil if name.nil?
clusters.find { |c| c.name == name }
end | [
"def cluster(name)\n return nil unless cluster?(name)\n\n clusters.select { |x| x.name == name }.first\n end",
"def has_cluster?( name )\n \n return @clusters.has_key?( name.to_sym )\n \n end",
"def cluster_exists?(cluster_name)\n existing_clusters = self.get('/clusters')\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /strategic_objectives POST /strategic_objectives.json | def create
@strategic_objective = StrategicObjective.new(strategic_objective_params)
if @strategic_objective.save
flash[:success] = 'Strategic objective was successfully created.'
redirect_to :back
else
flash[:danger] = 'Strategic objective was not created.'
redirect_to ... | [
"def create\n @objective = @goal.objectives.create(objective_params)\n render json: @objective\n end",
"def create\n @objective = current_user.objectives.create(params[:objective])\n\n respond_to do |format|\n if @objective.save\n format.html { redirect_to @objective, notice: 'O... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /strategic_objectives/1 PATCH/PUT /strategic_objectives/1.json | def update
if @strategic_objective.update(strategic_objective_params)
flash[:success] = 'Strategic objective was successfully updated.'
redirect_to :back
else
flash[:danger] = 'Strategic objective was not updated.'
redirect_to :back
end
end | [
"def update\n respond_to do |format|\n if @strategic_goal.update(strategic_goal_params)\n format.html { redirect_to @strategic_goal, notice: 'Strategic goal was successfully updated.' }\n format.json { render :show, status: :ok, location: @strategic_goal }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mash uses convert_value to mashify values on input. We override it here to convert hash or array values to VividMash or AttrArray for consistency and to ensure that the added parts of the attribute tree will have the correct cache invalidation behavior. | def convert_value(value)
case value
when VividMash, AttrArray
value
when Hash
VividMash.new(value, __root__, __node__, __precedence__)
when Array
AttrArray.new(value, __root__, __node__, __precedence__)
else
value
end
end | [
"def convert_value(value)\n case value\n when VividMash\n value\n when AttrArray\n value\n when Hash\n VividMash.new(value, __root__, __node__, __precedence__)\n when Array\n AttrArray.new(value, __root__, __node__, __precedence__)\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates actual cost from the activities claiming this project as a parent. In the even there are no activities, sets this projects' cost to 0. | def update_actual_cost
cost = BigDecimal(0.00, 10)
self.activities.each do |activity|
cost += activity.actualCost
end
self.actual_cost = cost
end | [
"def update_target_cost\n cost = BigDecimal(0.00, 10)\n self.activities.each do |activity|\n cost += activity.targetCost\n end\n self.target_cost = cost\n end",
"def total_cost\n @cost + @child_cost\n end",
"def calculate_base_cost!\n result_obj = self.cost_matrix.reduction\n\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a hash of (year, zeroBigDecimal) with one year for each year this project spans. | def initialized_year_hash
year_in_range = self.startDate.year
year_hash = {}
while year_in_range <= self.endDate.year
year_hash[year_in_range] = BigDecimal(0.0, 10)
year_in_range += 1
end
year_hash
end | [
"def hashCode\n @year * daysInYear + ordinalDate\n end",
"def last_year_as_hash(offset = 1)\n data_klass.metrics.zip(aggregated_quarter(offset).metric_values).to_h\n end",
"def activity_year_fractions_hash(activity)\n year_fractions = {}\n total_activity_days = activity.endDate - activity.star... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
given an activity, returns a hash of (year, fraction of activity's time) across the activity's start and end dates. Note this is inclusive of the startDate, exclusive of the endDate. | def activity_year_fractions_hash(activity)
year_fractions = {}
total_activity_days = activity.endDate - activity.startDate # Cannot be zero, by :validDate
range_start = activity.startDate
while range_start.year < activity.endDate.year
range_end = Date.new(range_start.year + 1)
year_fractions... | [
"def activity\n activity = {}\n return activity if empty?\n\n commit_count = values.size\n\n active_days = {}\n each do |commit|\n date = commit.committed_date.utc\n day = Time.utc(date.year, date.month, date.day).send :to_date\n if active_days.key? day\n acti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO decide if this should be calculated from yearly_target_cost | def update_target_cost
cost = BigDecimal(0.00, 10)
self.activities.each do |activity|
cost += activity.targetCost
end
self.target_cost = cost
end | [
"def future_cost(initial_cost, number_of_years, interest_rate)\n initial_cost * (1 + interest_rate) ** number_of_years\n end",
"def total_cost_approx\n years_active = @bike_trips.reject { |t| t.end_time.nil? }\n .group_by { |t| t.end_time.year }.map { |y, _| y }\n annual_fees = years_active.m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
It will fill the hash_record with data from the input file that matches the column_names | def fill_hash_record_from_line(column_names, headers, line)
hash_record = {}
fields = line.split(@sep)
fields.each_with_index do |field, field_id|
hash_record[headers[field_id]] = field if column_names.include?(headers[field_id])
end
hash_record
end | [
"def create_lookup_table\n File.open(source).each_with_index do |line|\n next if line.chomp.empty?\n\n values = unstring(line).chomp.split(';')\n\n next if values.empty?\n\n @joiners.each do |joiner|\n key = values[joiner.join[0]]\n joiner.lookup[:row... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Actively searches for hubs by talking to publisher directly | def discover_hubs_for_topic
@hubs = Nelumba.feed_from_url(self.topic_url).hubs
end | [
"def get_hubs!\n # TODO\n end",
"def ping_hubs\n feed_url = \"#{url}.atom\"\n OPub::Publisher.new(feed_url, hubs).ping_hubs\n end",
"def search(q)\n rv = []\n Chef::Search::Query.new.search(:hubs, q) do |z|\n rv << Hub.new(z)\n end\n return rv\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subscribe to the topic through the given hub. | def subscribe
return unless self.hub.nil?
# Discover hubs if none exist
@hubs = discover_hubs_for_topic(self.topic_url) if self.hubs.empty?
@hub = self.hubs.first
change_subscription(:subscribe, token)
# TODO: Check response, if failed, try a different hub
end | [
"def subscribe(*args)\n params = arguments(args, required: [:topic, :callback]).params\n _merge_action!(\"subscribe\", arguments.topic, arguments.callback, params)\n params['headers'] = HEADERS\n\n post_request(\"/hub\", params)\n end",
"def subscribe(_topic, **)\n raise 'not impleme... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change our subscription to this topic at a hub. mode: Either :subscribe or :unsubscribe hub_url: The url of the hub to negotiate with token: A token to verify the response from the hub. | def change_subscription(mode)
token ||= SecureRandom.hex(32)
@tokens << token.to_s
# TODO: Set up HTTPS foo
res = Net::HTTP.post_form(URI.parse(self.hub),
{
'hub.mode' => mode.to_s,
'hub.callback... | [
"def subscribe\n return unless self.hub.nil?\n\n # Discover hubs if none exist\n @hubs = discover_hubs_for_topic(self.topic_url) if self.hubs.empty?\n @hub = self.hubs.first\n change_subscription(:subscribe, token)\n\n # TODO: Check response, if failed, try a different hub\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.