query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Selects the closest DJ slot to the current time should a user have more than one | def current_dj_slot
dj_slots.order('created_at DESC').order("ABS(start_time - #{Time.now.to_i})").first
end | [
"def next_available_slot date = Date.today, session = 'Morning'\n #link up get the available slots within time frame\n # something like search, but spit out slots available\n end",
"def best_time(event)\n registrant_best_times.find_by(event: event) || registrant_choices.joins(:event_choice).merge(EventC... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
shows printable login instructions for the user | def login_instructions
end | [
"def draw_login_form\n term.print_block(17, 32, <<END.freeze)\n type 'new' to join\n there is no guest ID\n┌─────────────────────────────────┐\n│ ID : │\n│ PW : │\n│ │\n└─────────────────────────────────┘\nEND\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
exports the selected users to VCF format | def export
respond_to do |format|
format.vcf do
@users = params[:selected] ? load_selected_objects(User) : []
render(:text => @users.collect{|u| u.to_vcf}.join("\n"))
end
end
end | [
"def export\n \n CsvUtils.setup_request_for_csv headers, request, \"users\"\n \n stream_csv do |csv|\n csv << [\"email\",\n \"first name\", \n \"last name\", \n \"enterprise\",\n \"allocations mgr (Y|N)\",\n \"voter (Y|N)\"\n ]\n end\n end",
"def export... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sets the current user's current mission to the last one used, and redirects to home page for that mission | def exit_admin_mode
if m = Mission.where(:id => session[:last_mission_id]).first
current_user.change_mission!(m)
end
redirect_to(root_url(:admin_mode => nil))
end | [
"def set_mission_as_done\n mission = Mission.find(params[:id].to_i)\n entr_missions = mission.entr_mission_users\n\n # No users attached to the mission\n if entr_missions.empty?\n flash[:success] = \"<h2>La mission < #{mission.title} > <span style='color:red'>ne peut pas être terminée (aucun utilis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prepares objects and renders the form template | def prepare_and_render_form
# create a blank mission assignment with the appropriate user_id for the boilerplate, but don't add it to the collection
@blank_assignment = Assignment.new(:active => true, :user_id => current_user.id)
# get assignable missons and roles for this user
@assignable_miss... | [
"def render_form(model,object,method)\n object = model.new unless object\n render(model.name.downcase + 'form', binding)\n end",
"def prepare_and_render_form\n @options = Option.accessible_by(current_ability).all\n render(:form)\n end",
"def render_fields_for(object)\n pre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
builds a user with an appropriate mission assignment if the current_user doesn't have permission to edit a blank user | def build_user_with_proper_mission
@user = User.new(params[:user])
if cannot?(:create, @user) && @user.assignments.empty?
@user.assignments.build(:mission => current_mission, :active => true)
end
end | [
"def build_user_with_proper_mission\n @user = User.new(params[:user])\n if cannot?(:create, @user) && @user.assignments.empty?\n @user.assignments.build(:mission => current_mission)\n end\n end",
"def correct_user_to_edit\n not_allow if (@job.user.id != current_user.id) \n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: get authentication failed text Example | def authentication_failed
authentication_failed_msg.text
end | [
"def failure\n msg_returned = request.params['message']\n login_failed msg_returned.nil? ? 'Auth0 login failed.' : msg_returned\n end",
"def auth_fail\n fail(Kankri::AuthenticationFailure)\n end",
"def failed_text\n 'Failed: %d' % failed\n end",
"def password_error\n return \"Incorre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create recap daily new job for freelancer | def recap_daily_for_new_job(options)
job = Job.find options['job_id']
admin_user = User.find options['admin_user_id']
skills = job.skills.map(&:id)
freelancers = FreelancerMember.where(email_validation_key: nil, email_notif_new_job: true, disabled: false)
freelancers = freelancers.any_in(skill_ids:... | [
"def create_scheduled_job(payload)\n if payload.include?('task')\n post_schedule_task(payload)\n else\n post_schedule_plan(payload)\n end\n end",
"def install!\n schedule = render\n unless schedule.blank?\n file = Tempfile.new('schedule')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create program from a file and compile it cl_context : ctx, cl_device_id : dev, const char : filename | def build_program(ctx, dev, filename)
abort("Couldn't find the program file") if not File.exists?(filename)
# Read program file and place content into buffer
program_buffer = File.read(filename)
# Create program from file
err_buf = ' ' * 4
program = clCreateProgramWithSource(ctx, 1, [program_buffer].pack(... | [
"def build_program(ctx, dev, kernel_source)\n # Create program from file\n err_buf = ' ' * 4\n program = clCreateProgramWithSource(ctx, 1, [kernel_source].pack(\"p\"), [kernel_source.bytesize].pack(\"Q\"), err_buf)\n err = err_buf.unpack(\"l\")[0]\n abort(\"Couldn't create the program\") if err < 0\n\n # Buil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns whether the storage_name exists. | def storage_exists?(storage_name)
statement = <<-SQL.compress_lines
SELECT COUNT(*)
FROM "information_schema"."tables"
WHERE "table_type" = 'BASE TABLE'
AND "table_schema" = ?
AND "table_name" = ?
SQL
query(statement, schema_name, storage_name).... | [
"def storage_exists?(storage_name)\n adapter.storage_exists?(storage_name)\n end",
"def storage_exists?(storage_name)\n domains = sdb.list_domains[:domains]\n domains.detect {|d| d == storage_name }!=nil\n end",
"def exists?\n storage.exists?(id)\n end",
"def e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the XML representation for this Command Object An example of a returned XML is: source test_app_otg2 /usr/bin/otg2 udp:dst_host 192.168.0.3 udp:local_host 192.168.0.2 OML_SERVER=tcp:10.0.0.200:3003 OML_EXP_ID=sandbox1 OML_NAME=source [Return] an XML element | def to_xml()
msg = REXML::Document.new
msg << REXML::Element.new("#{@type.to_s}")
msg.root << REXML::Element.new("GROUP").add_text("#{@group}") if @group != nil
msg.root << REXML::Element.new("ID").add_text("#{@procID}") if @procID != nil
msg.root << REXML::Element.new("PATH").add_text("#{@path... | [
"def to_xml\n xml = String.new\n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n builder.source(:primary => primary_source) do\n builder.id(id, :type => \"integer\")\n builder.uri(u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Command Object from a valid XML representation xmlDoc = an xml document (REXML::Document) object | def init_from_xml(xmlDoc)
@type = xmlDoc.expanded_name
xmlDoc.each_element("ID") { |e| @procID = e.text }
xmlDoc.each_element("GROUP") { |e| @group = e.text }
xmlDoc.each_element("PATH") { |e| @path = e.text }
xmlDoc.each_element("ARGSLINE") { |e| @cmdLineArgs = e.text }
xmlDoc.each_elemen... | [
"def create_from(xmlDoc)\n begin\n # Set the Type\n @attributes[:CMDTYPE] = xmlDoc.expanded_name.to_sym\n # Parse the XML object\n xmlDoc.each_element { |e|\n # For the OMLCONFIG tag, add the XML value to this Command Object\n if e.expanded_name.upcase.to_sym == :OMLCONFIG\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /exceller_skills GET /exceller_skills.json | def index
@exceller_skills = ExcellerSkill.all
end | [
"def index\n @skills = Skills\n\n render json: @skills\n end",
"def index\n @experience_skills = ExperienceSkill.all\n end",
"def list_skills\n\t\trender json: Skill.where(language_id: params[:language_id]).to_json\n\tend",
"def test_get_skills_route\n render :json => get_profile_skills_for_prof... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /exceller_skills POST /exceller_skills.json | def create
@exceller_skill = ExcellerSkill.new(exceller_skill_params)
respond_to do |format|
if @exceller_skill.save
format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully created.' }
format.json { render :show, status: :created, location: @exceller_skill }
... | [
"def create\n @experience_skill = ExperienceSkill.new(experience_skill_params)\n\n respond_to do |format|\n if @experience_skill.save\n format.html { redirect_to @experience_skill, notice: 'Experience skill was successfully created.' }\n format.json { render :show, status: :created, locatio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /exceller_skills/1 PATCH/PUT /exceller_skills/1.json | def update
respond_to do |format|
if @exceller_skill.update(exceller_skill_params)
format.html { redirect_to @exceller_skill, notice: 'Exceller skill was successfully updated.' }
format.json { render :show, status: :ok, location: @exceller_skill }
else
format.html { render :edit ... | [
"def update\n if @skill.update(basic_params)\n render json: @skill\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end",
"def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @ski... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /exceller_skills/1 DELETE /exceller_skills/1.json | def destroy
@exceller_skill.destroy
respond_to do |format|
format.html { redirect_to exceller_skills_url, notice: 'Exceller skill was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @skill = Skill.find(params[:id])\n @skill.destroy\n\n respond_to do |format|\n format.html { redirect_to skills_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @skill.destroy\n respond_to do |format|\n format.html { redirect_to skills_url }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /members/1 DELETE /members/1.xml | def destroy
@member = Member.find(params[:id])
@member.destroy
respond_to do |format|
format.html { redirect_to(members_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @member.destroy\n\n respond_to do |format|\n format.html { redirect_to(members_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @member = Member.with_permissions_to(:destroy).find(params[:id])\n @member.destroy\n\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the callee property value. Endpoint that answered this segment. | def callee
return @callee
end | [
"def callee_number\n return @callee_number\n end",
"def callee_device\n return @callee_device\n end",
"def endpoint\n @reference[1]\n end",
"def callee_network\n return @callee_network\n end",
"def callee=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the callee property value. Endpoint that answered this segment. | def callee=(value)
@callee = value
end | [
"def callee_number=(value)\n @callee_number = value\n end",
"def caller=(value)\n @caller = value\n end",
"def callee_device=(value)\n @callee_device = value\n end",
"def callee_network=(value)\n @callee_network = val... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the caller property value. Endpoint that initiated this segment. | def caller=(value)
@caller = value
end | [
"def set_caller(caller)\n @caller = caller\n self\n end",
"def caller_number=(value)\n @caller_number = value\n end",
"def caller_device=(value)\n @caller_device = value\n end",
"def set_caller_name\n caller = user.contacts.select{ |c| c.number == ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the failureInfo property value. Failure information associated with the segment if it failed. | def failure_info
return @failure_info
end | [
"def failure_info=(value)\n @failure_info = value\n end",
"def failure_message\n @errors[0]\n end",
"def get_FailureDescription()\n \t return @outputs[\"FailureDescription\"]\n \tend",
"def error_information\n return @error_information\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the failureInfo property value. Failure information associated with the segment if it failed. | def failure_info=(value)
@failure_info = value
end | [
"def health_status_mismatch_info=(value)\n @health_status_mismatch_info = value\n end",
"def error_information=(value)\n @error_information = value\n end",
"def failure_info\n return @failure_info\n end",
"def error=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the media property value. Media associated with this segment. | def media
return @media
end | [
"def media=(value)\n @media = value\n end",
"def media\n @media || ( \n media = read_attribute(:media)\n media ? self.class::UPLOADER.new(self, :media, media) : nil \n )\n end",
"def media\n self.dig_for_array(\"media\")\n end",
"def media_con... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the media property value. Media associated with this segment. | def media=(value)
@media = value
end | [
"def media=(media)\n @media = write_attribute :media, (media.present? ? self.class::UPLOADER.new(self, :media, media) : nil)\n end",
"def set_Media(value)\n set_input(\"Media\", value)\n end",
"def media_config=(value)\n @media_config = value\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns advancedtype keyword queries, see also keyword_op | def keyword_queries
unless(@keyword_queries)
@keyword_queries = {}
return @keyword_queries unless @params[:search_field] == ::AdvancedController.blacklight_config.advanced_search[:url_key]
config.search_fields.each do | key, field_def |
if ! @params[ key.to_sym ].blank?... | [
"def keyword_queries\n unless @keyword_queries\n @keyword_queries = {}\n\n return @keyword_queries unless @params[:search_field] == ::AdvancedController.blacklight_config.advanced_search[:url_key]\n\n config.search_fields.each do |key, _field_def|\n unless @params[key.to_sym].blan... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /ambassadorships GET /ambassadorships.json | def index
@ambassadorships = Ambassadorship.all
end | [
"def index\n @assigned_ships = AssignedShip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @assigned_ships }\n end\n end",
"def index\n @clientships = current_user.clientships.all \n\n respond_to do |format|\n format.html # index.html.e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /ambassadorships/1 PATCH/PUT /ambassadorships/1.json | def update
respond_to do |format|
if @ambassadorship.update(ambassadorship_params)
format.html { redirect_to @ambassadorship, notice: t('.notice') }
format.json { render :show, status: :ok, location: @ambassadorship }
else
format.html { render :edit }
format.json { render... | [
"def update\n @clientship = current_user.clientships.find(params[:id])\n\n respond_to do |format|\n if @clientship.update_attributes(params[:clientship])\n format.html { redirect_to @clientship, notice: 'Clientship was successfully updated.' }\n format.json { head :ok }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ambassadorships/1 DELETE /ambassadorships/1.json | def destroy
@ambassadorship.destroy
@ambassadorship = Ambassadorship.new(area: @ambassadorship.area)
respond_to do |format|
format.html { redirect_to ambassadorships_url, notice: t('.notice') }
format.json { head :no_content }
format.js { render :destroy }
end
end | [
"def destroy\n @clientship = current_user.clientships.find(params[:id])\n @clientship.destroy\n\n respond_to do |format|\n format.html { redirect_to clientships_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @badgeship = Badgeship.find(params[:id])\n @badgeship.destroy\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch user projects from Github | def fetch_projects!
projects.destroy_all
if github?
result = YAML.load open("http://github.com/api/v2/yaml/repos/show/#{github}/")
result['repositories'].each do |repository|
projects.create! :name => repository[:name], :description => repository[:description]
end
end
rescue O... | [
"def github_projects\n return [] unless self.github_username\n @repositories ||= get_github_repositories\n end",
"def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /space_cats GET /space_cats.json | def index
@space_cats = SpaceCat.all
end | [
"def get_appcon_categories \n get(\"/appcon.json/categories\")\nend",
"def show\n @space_cat = SpaceCat.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @space_cat }\n end\n end",
"def get_appcon_categories \n get(\"/appcon.json/ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /space_cats POST /space_cats.json | def create
@space_cat = SpaceCat.new(space_cat_params)
respond_to do |format|
if @space_cat.save
format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }
format.json { render action: 'show', status: :created, location: @space_cat }
else
format.ht... | [
"def create\n @space_cat = SpaceCat.new(params[:space_cat])\n\n respond_to do |format|\n if @space_cat.save\n format.html { redirect_to @space_cat, notice: 'Space cat was successfully created.' }\n format.json { render json: @space_cat, status: :created, location: @space_cat }\n else\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /space_cats/1 PATCH/PUT /space_cats/1.json | def update
respond_to do |format|
if @space_cat.update(space_cat_params)
format.html { redirect_to @space_cat, notice: 'Space cat was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @space_cat... | [
"def update\n @cat.update(cat_params)\n render json: @cat\n end",
"def update\n cat = Cat.find(params[:id])\n if cat.update(cat_params)\n render json: cat, status: 200\n else\n render json: cat, status: 422\n end\n end",
"def update\n @space_cat = SpaceCa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /space_cats/1 DELETE /space_cats/1.json | def destroy
@space_cat.destroy
respond_to do |format|
format.html { redirect_to space_cats_url }
format.json { head :no_content }
end
end | [
"def destroy\n @space_cat = SpaceCat.find(params[:id])\n @space_cat.destroy\n\n respond_to do |format|\n format.html { redirect_to space_cats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rest_cat.destroy\n respond_to do |format|\n format.html { redirect_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
CUSTOM FUNCTIONS Builds a maven command line according to the given goals, project and the current environment | def maven(goals, project)
command = 'mvn '
# Goals
if !goals.is_a?(Array)
goals = [goals]
end
for goal in goals
command += goal+' '
end
# Options (from environment)
if ENV['offline'] == 'yes'
command += '-o '
end
if ENV['test'] == 'no'
command += '-DskipTests=true '
end
... | [
"def get_maven_commandline(prefix, options)\n executable = find_executable(\"mvn\")\n\n if !executable.nil?\n mvn_path = File.join(prefix, executable)\n repo_path = File.join(prefix, \"kit\", \"m2\")\n config_path = File.join(prefix, \"kit\", \"m2\", \"settings.xml\")\n\n \"#{m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a hash with numeric values, return the key for the smallest valu | def key_for_min_value(hash)
lowest_key = nil
lowest_value = Float::INFINITY
hash.each do |key, value|
if value < lowest_value
lowest_value = value
lowest_key = key
end
end
lowest_key
end | [
"def key_for_min_value(hash)\n lowest_key=nil \n lowest_value= Float::INFINITY\n hash.each do |name,number|\n if number < lowest_value\n lowest_value=number\n lowest_key= name\n end \n end\n lowest_key\nend",
"def smallest_key(q, hash)\n\t\ttemp = {}\n\t\tq.each do |v|\n\t\t\ttemp[v] = hash[v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /estimates/1 GET /estimates/1.json | def show
@estimate = Estimate.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @estimate }
end
end | [
"def index\n @estimates = Estimate.all\n end",
"def retrieve_estimates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimates ...'\n end\n # resource path\n local_var_path = '/v1/estimates'\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /estimates/new GET /estimates/new.json | def new
@estimate = Estimate.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @estimate }
end
end | [
"def new\n @rentestimate = Rentestimate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rentestimate }\n end\n end",
"def new\n @estimate = Estimate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /estimates POST /estimates.json | def create
@estimate = Estimate.new(params[:estimate])
respond_to do |format|
if @estimate.save
format.html { redirect_to @estimate, notice: 'Estimate was successfully created.' }
format.json { render json: @estimate, status: :created, location: @estimate }
else
format.html ... | [
"def create\n @estimate = current_user.estimates.new(estimate_params)\n respond_to do |format|\n if @estimate.save\n format.html { redirect_to @estimate, notice: 'Estimate was successfully created.' }\n format.json { render :show, status: :created, location: @estimate }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /estimates/1 PUT /estimates/1.json | def update
@estimate = Estimate.find(params[:id])
respond_to do |format|
if @estimate.update_attributes(params[:estimate])
format.html { redirect_to @estimate, notice: 'Estimate was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "... | [
"def update\n @estimate = Estimate.find(params[:id])\n\n respond_to do |format|\n if @estimate.update_attributes(params[:estimate])\n format.html { redirect_to(@estimate, :notice => 'Estimate was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /estimates/1 DELETE /estimates/1.json | def destroy
@estimate = Estimate.find(params[:id])
@estimate.destroy
respond_to do |format|
format.html { redirect_to estimates_url }
format.json { head :no_content }
end
end | [
"def destroy\n @estimate.destroy\n\n respond_to do |format|\n format.html { redirect_to estimates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @estimate = Estimate.find(params[:id])\n @estimate.destroy\n\n respond_to do |format|\n format.html { redirect_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Initialize a new Gollum Repo. path The String path to the Git repository that holds the Gollum site. options Optional Hash: :universal_toc Table of contents on all pages. Default: false :base_path String base path for all Wiki links. Default: "/" :page_file_dir String the directory in which all page files resid... | def initialize(path, options = {})
options = self.class.default_options.merge(options)
if path.is_a?(GitAccess)
options[:access] = path
path = path.path
end
@path = path
@repo_is_bare = options.fetch :repo_is_bare, nil
@page_file_d... | [
"def initialize(path, options = {})\n if path.is_a?(GitAccess)\n options[:access] = path\n path = path.path\n end\n @path = path\n @page_file_dir = options[:page_file_dir]\n @access = options[:access] || GitAccess.new(path, @page_file_dir)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Create an inmemory Page with the given data and format. This is useful for previewing what content will look like before committing it to the repository. name The String name of the page. format The Symbol format of the page. data The new String contents of the page. Returns the inmemory Gollum::Page. | def preview_page(name, data, format)
::Gollum::PreviewPage.new(self, "#{name}.#{::Gollum::Page.format_to_ext(format.to_sym)}", data, @access.commit(@ref))
end | [
"def preview_page(name, data, format)\n page = @page_class.new(self)\n ext = @page_class.format_to_ext(format.to_sym)\n name = @page_class.cname(name) + '.' + ext\n blob = OpenStruct.new(:name => name, :data => data)\n page.populate(blob)\n page.version = @access.commit('master')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Rename an existing page without altering content. page The Gollum::Page to update. rename The String extensionless full path of the page (leading '/' is ignored). commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optio... | def rename_page(page, rename, commit = {})
return false if page.nil?
return false if rename.nil? or rename.empty?
(target_dir, target_name) = ::File.split(rename)
(source_dir, source_name) = ::File.split(page.path)
source_name = page.filename_stripped
# File.split giv... | [
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Update an existing page with new content. The location of the page inside the repository will not change. If the given format is different than the current format of the page, the filename will be changed to reflect the new format. page The Gollum::Page to update. name The String extensionless name of the page.... | def update_page(page, name, format, data, commit = {})
name ||= page.name
format ||= page.format
dir = ::File.dirname(page.path)
dir = nil if dir == '.'
rename = (page.name != name || page.format != format)
new_path = ::File.join([dir, self.page_file_name(name, form... | [
"def update_page(page, name, format, data, commit = {})\n pcommit = @repo.commit('master')\n map = tree_map(pcommit.tree)\n name ||= page.name\n format ||= page.format\n index = nil\n\n if page.name == name && page.format == format\n index = tree_map_to_index(map)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Delete a page. page The Gollum::Page to delete. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :com... | def delete_page(page, commit)
delete_file(page.url_path, commit)
end | [
"def delete_page(page, commit)\n pcommit = @repo.commit('master')\n map = tree_map(pcommit.tree)\n\n map = delete_from_tree_map(map, page.path)\n index = tree_map_to_index(map)\n\n actor = Grit::Actor.new(commit[:name], commit[:email])\n index.commit(commit[:message], [pcommit], ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Delete a file. path The path to the file to delete commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :... | def delete_file(path, commit)
fullpath = ::File.join([page_file_dir, path].compact)
multi_commit = !!commit[:committer]
committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
committer.delete(fullpath)
committer.after_commit do |index, _sha|
dir = '' i... | [
"def remove(path)\n object = object! path\n path += '/' if object.is_a?(Grit::Tree) && path[-1].chr != '/'\n index = @git.index\n index.read_tree 'HEAD'\n index.delete path\n type = object.is_a?(Grit::Tree) ? 'directory' : 'file'\n commit_msg = \"Removed #{type} #{path}\"\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Applies a reverse diff for a given page. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs are given, the reverse diff is taken from SHA1...SHA2. page The Gollum::Page to delete. sha1 String SHA1 of the earlier parent if two SHAs are given, or the child. sha2 Optio... | def revert_page(page, sha1, sha2 = nil, commit = {})
return false unless page
left, right, options = parse_revert_options(sha1, sha2, commit)
commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)
end | [
"def full_reverse_diff_for(page, sha1, sha2 = nil)\n sha1, sha2 = \"#{sha1}^\", sha1 if sha2.nil?\n args = [{:R => true}, sha1, sha2]\n if page\n args << '--' << (page.respond_to?(:path) ? page.path : page.to_s)\n end\n repo.git.native(:diff, *args)\n end",
"def revert_commit(sh... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Applies a reverse diff to the repo. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs are given, the reverse diff is taken from SHA1...SHA2. sha1 String SHA1 of the earlier parent if two SHAs are given, or the child. sha2 Optional String SHA1 of the child. commit T... | def revert_commit(sha1, sha2 = nil, commit = {})
left, right, options = parse_revert_options(sha1, sha2, commit)
tree, files = repo.git.revert_commit(left, right)
commit_and_update_paths(tree, files, options)
end | [
"def full_reverse_diff(sha1, sha2 = nil)\n full_reverse_diff_for(nil, sha1, sha2)\n end",
"def full_reverse_diff_for(page, sha1, sha2 = nil)\n sha1, sha2 = \"#{sha1}^\", sha1 if sha2.nil?\n args = [{:R => true}, sha1, sha2]\n if page\n args << '--' << (page.respond_to?(:path) ? page.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Returns the number of pages accessible from a commit ref A String ref that is either a commit SHA or references one. Returns a Fixnum | def size(ref = nil)
tree_map_for(ref || @ref).inject(0) do |num, entry|
num + (::Gollum::Page.valid_page_name?(entry.name) ? 1 : 0)
end
rescue Gollum::Git::NoSuchShaFound
0
end | [
"def size(ref = nil)\n tree_map_for(ref || @ref).inject(0) do |num, entry|\n num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)\n end\n rescue Grit::GitRuby::Repository::NoSuchShaFound\n 0\n end",
"def size(ref = nil)\n tree_map_for(ref || 'master').inject(0) do |num, entry|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Search all pages for this wiki. query The string to search for Returns an Array with Objects of page name and count of matches | def search(query)
options = {:path => page_file_dir, :ref => ref}
search_terms = query.scan(/"([^"]+)"|(\S+)/).flatten.compact.map {|term| Regexp.escape(term)}
search_terms_regex = search_terms.join('|')
query = /^(.*(?:#{search_terms_regex}).*)$/i
results = @repo.git.grep(search_terms, op... | [
"def search(query)\n args = [{}, '-i', '-c', query, @ref, '--']\n args << '--' << @page_file_dir if @page_file_dir\n\n @repo.git.grep(*args).split(\"\\n\").map! do |line|\n result = line.split(':')\n file_name = Gollum::Page.canonicalize_filename(::File.basename(result[1]))\n\n {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the latest changes in the wiki (globally) options The options Hash: :max_count The Integer number of items to return. Returns an Array of Gollum::Git::Commit. | def latest_changes(options={})
options[:max_count] = 10 unless options[:max_count]
@repo.log(@ref, page_file_dir, options)
end | [
"def latest_changes\n request_params = wiki_serach_params\n response = make_request(request_params)\n parsed_response = parse_response(response)\n recent_changes_titles = filter_titles(parsed_response)\n end",
"def commits(max_count=nil)\n max_count = Rails.configuration.recent_commits if max_coun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Normalize the data. data The String data to be normalized. Returns the normalized data String. | def normalize(data)
data.gsub(/\r/, '')
end | [
"def normalize_data(input)\n Normalizator.normalize(@rules, [input])\nend",
"def pre_normalize(text); end",
"def normalize_data(input)\n year = input[:year].to_i\n return input unless validate_year(input, year)\n input[:year] = year\n\n make = validate_make(input[:make])\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assemble a Page's filename from its name and format. name The String name of the page (should be precanonicalized). format The Symbol format of the page. Returns the String filename. | def page_file_name(name, format)
format.nil? ? name : "#{name}.#{::Gollum::Page.format_to_ext(format)}"
end | [
"def page_file_name(name, format)\n ext = @page_class.format_to_ext(format)\n @page_class.cname(name) + '.' + ext\n end",
"def filename(format)\n \"#{filename_without_extension}.#{format}\"\n end",
"def filename\n @basename + PAGE_FILE_EXT\n end",
"def create_name_from(name)\n\t\tFile... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fill an array with a list of pages and files in the wiki. ref A String ref that is either a commit SHA or references one. Returns a flat Array of Gollum::Page and Gollum::File instances. | def tree_list(ref = @ref, pages=true, files=true)
if (sha = @access.ref_to_sha(ref))
commit = @access.commit(sha)
tree_map_for(sha).inject([]) do |list, entry|
if ::Gollum::Page.valid_page_name?(entry.name)
list << entry.page(self, commit) if pages
elsif files && !e... | [
"def file_list(ref)\n if sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list if @page_class.valid_page_name?(entry.name)\n list << entry.file(self, commit)\n end\n else\n []\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the default name for commits. Returns the String name. | def default_committer_name
@default_committer_name ||= \
@repo.config['user.name'] || self.class.default_committer_name
end | [
"def default_name\n @default_name ||= self['default_name'] || DEFAULT_NAME\n end",
"def default_name\n @default_name ||= \"__#{name}_default__\"\n end",
"def default_name\n self.name ||= self.class.get_default_name(date)\n end",
"def default_repository_name\n Repository.default_na... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the default email for commits. Returns the String email address. | def default_committer_email
email = @repo.config['user.email']
email = email.delete('<>') if email
@default_committer_email ||= email || self.class.default_committer_email
end | [
"def default_committer_email\n @default_committer_email ||= \\\n @repo.config['user.email'] || self.class.default_committer_email\n end",
"def default_email( cid )\n return \"#{cid}@#{DEFAULT_DOMAIN}\"\n end",
"def get_useremail()\n email = nil\n git_user_email = %x(git config user.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the commit object for the given ref or sha. ref A string ref or SHA pointing to a valid commit. Returns a Gollum::Git::Commit instance. | def commit_for(ref)
@access.commit(ref)
rescue Gollum::Git::NoSuchShaFound
end | [
"def commit(ref)\n Commit.new(self, git.gcommit(ref))\n end",
"def resolve_commit(ref)\n commit = git \"rev-parse #{ref}^{commit}\", :git_dir => @cache_path\n commit.chomp\n rescue R10K::ExecutionFailure => e\n logger.error \"Could not resolve ref #{ref.inspect} for git cache #{@cache_path}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds a full listing of files and their blob SHA for a given ref. Each listing is cached based on its actual commit SHA. ref A String ref that is either a commit SHA or references one. ignore_page_file_dir Boolean, if true, searches all files within the git repo, regardless of dir/subdir Returns an Array of BlobEntry i... | def tree_map_for(ref, ignore_page_file_dir = false)
if ignore_page_file_dir && !@page_file_dir.nil?
@root_access ||= GitAccess.new(path, nil, @repo_is_bare)
@root_access.tree(ref)
else
@access.tree(ref)
end
rescue Gollum::Git::NoSuchShaFound
[]
end | [
"def file_list(ref)\n if sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list if @page_class.valid_page_name?(entry.name)\n list << entry.file(self, commit)\n end\n else\n []\n end\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Conjoins elements of a page or file path and prefixes the page_file_dir. Throws Gollum::IllegalDirectoryPath if page_file_dir is set, and the resulting path is not below it (e.g. if the dir or name contained '../') dir The String directory path name The String name of the Page or File format The Symbol format of the pa... | def merge_path_elements(dir, name, format)
result = ::File.join([@page_file_dir, dir, self.page_file_name(name, format)].compact)
result = Pathname.new(result).cleanpath.to_s
if @page_file_dir
raise Gollum::IllegalDirectoryPath unless result.start_with?("#{@page_file_dir}/")
result
... | [
"def format_directory(dir)\n format_dir = dir.strip\n format_dir = \"/#{format_dir}\" unless format_dir.start_with?('/')\n format_dir\nend",
"def file_name(dir, name)\n \"#{dir}#{\"/\" unless dir.empty?}#{name}\"\n end",
"def merge_pdfs_in_dir(dir, name: nil , output_dir: nil)\n name = lname || \"me... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns either "rock", "paper", or "scissors" using rand() | def comp_choose_rps
rand_num = rand(3)
if rand_num == 1
"rock"
elsif rand_num == 2
"paper"
else
"scissors"
end
end | [
"def random_rps\n return case rand(1 ... 4)\n when 1 then \"Rock\"\n when 2 then \"Paper\"\n when 3 then \"Scissors\"\n end\nend",
"def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end",
"def rps(choice)\n choice = choice.capitalize\n rps = [\"Rock\", \"Pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Identifie si le array inclu un 42 | def array_42(z)
if z.include? 42
return true
else
return false
end
end | [
"def test_function_array_contains_13\n\t\tpopulated_array = mined_minds_array()\n\t\tcheck_array = populated_array.include? 13\n\t\tassert_equal(true, check_array)\n\tend",
"def include_array?(array)\n array.any? { |member| array?(member) }\n end",
"def include?(array)\n puts \"include?\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an existing project by its name. :project_name The name of the project | def project_by_name(project_name)
projects.find { |project| project['name'].casecmp(project_name) == 0 }
end | [
"def project(name)\n @projects.find { |p| p.name == name }\n end",
"def get_project(name)\n @projects[name]\n end",
"def by_name(name)\n find { |project| project.name == name }\n end",
"def get_project(name)\n params = {\n 'command' => 'listProjects',\n\t'listall' => true\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override validate with our encrypt method: causes objects being saved to have relevant columns encrypted any errors raised during the encryption process result in validation failure. | def validate
encrypt
end | [
"def before_validation(model)\n return if model.send(@attr_name).blank?\n model.send(\"crypted_#{@attr_name}=\", AsymmetricSentry.encrypt_to_base64(model.send(@attr_name)))\n end",
"def before_validation(model)\n return unless model.send(@attribute)\n model.send(\"crypted_#{@attribute}=\", ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert page into tree tree Empty hash, to be filled with pages page Page to add as gollum::Page | def tree_insert(tree, page)
node_list = page.path.split("/")
_tree_insert(tree, page, node_list)
end | [
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Recursively prints the page tree as a list tree tree Tree of Hash gollum::Pages folder Current folder, start with empty string | def tree_print(tree, folder)
str = "";
tree.each do |key, value|
if not value.is_a?(Hash)
# page
if value.name != "Home"
str += "<li><a href=\"/#{@wiki.base_path}#{value.url_path}\">#{value.name}</a></li>"
end
else
# folde... | [
"def subpages_tree\n empty_string = ''.html_safe\n subpages_list = self.children.inject(empty_string) do |tree, subpage|\n tree + h.content_tag(:li, h.link_to(subpage.title, h.show_path(subpage.path)) + subpage.subpages_tree)\n end\n subpages_list.blank? ? empty_string : h.content_tag(:ul, subpages... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Free user converts to paid subscription | def convert_to_paid(user_name, email, plan)
@user_name = user_name
@email = email
@plan = plan
mail to: "Susie Ye <susie@baserails.com>", subject: "Convert to #{plan}: #{email}"
end | [
"def convert_to_paid(user_name, email, plan)\n @user_name = user_name\n @email = email\n @plan = plan\n\n mail to: \"Dean Gibbons <dg@teloslax.com>\", subject: \"Convert to #{plan}: #{email}\"\n end",
"def paid?\n subscription_type == :paid\n end",
"def change_subscription\n\tbounce_free_ac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
User manually changes subscription plan | def edit_subscription(user_name, email, plan)
@user_name = user_name
@email = email
@plan = plan
mail to: "Susie Ye <susie@baserails.com>", subject: "Subscription changed to #{plan}"
end | [
"def change_plan(stripe_customer, subscription_id, plan_id)\n stripe_subscription = stripe_customer.subscriptions.retrieve(subscription_id)\n stripe_subscription.plan = plan_id\n stripe_subscription.prorate = false\n stripe_subscription.save\n end",
"def change_plan(new_plan_name, new_record_options=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
number The Integer to check the previous Integer. Examples next_number(4) => 3 Returns the previous integer. | def previous_number(number)
return number - 1
end | [
"def previous_number(num)\n return num - 1\nend",
"def previous_number(num)\n num -= 1\n return num\nend",
"def prev_num(num)\n return num - 1\nend",
"def previous_number(input)\n output = input - 1\n return output\nend",
"def next_number(number)\n return number +1\nend",
"def next_nu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override in your job to change the perform requeue delay | def requeue_perform_delay
1.0
end | [
"def queue_retry_delay(delay=nil)\n if delay\n @queue_retry_delay = delay\n else # accessor\n @queue_retry_delay\n end\n end",
"def reschedule(delay); end",
"def queue_time_ms; end",
"def set_queue_delay\n new_delay = params[:delay].to_f\n if new_delay... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reverses the direction of a connection to an engine If the connection is currently initiated from the console this method will have the engine initiate the connection. If the connection is currently initiated by the engine this method with initiate the connection from the console instead. Requires a restart of the cons... | def reverse_engine_connection(engine_id)
uri = "/api/2.1/engine/#{engine_id}/reverseConnection"
response = AJAX.put(self, uri)
response.eql?('true')
end | [
"def reverse\n\t\t\trevEdge = [ Command::MoveTo.new(endPoint) ]\n\t\t\trevCmds = commands.reverse # reverses an array of commands.\n\t\t\trevCmds[0..-2].each_with_index do |cmd,index|\n\t\t\t\tnewCmd = cmd.dup\n\t\t\t\tnewCmd.endPoint = revCmds[index+1].endPoint\n\t\t\t\trevEdge << newCmd\n\t\t\tend\n\t\t\tEdge.ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provide a list of current scan activities for a specific Scan Engine. | def engine_activity(engine_id)
xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id })
r = execute(xml)
arr = []
if r.success
r.res.elements.each('//ScanSummary') do |scan_event|
arr << ScanSummary.parse(scan_event)
end
end
arr
end | [
"def engine_activity(engine_id)\n xml = make_xml('EngineActivityRequest', {'engine-id' => engine_id})\n r = execute(xml)\n arr = []\n if r.success\n r.res.elements.each('//ScanSummary') do |scan_event|\n arr << ScanSummary.parse(scan_event)\n end\n end\n arr\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a list of all Scan Engines managed by the Security Console. | def list_engines
response = execute(make_xml('EngineListingRequest'))
arr = []
if response.success
response.res.elements.each('//EngineSummary') do |engine|
arr << EngineSummary.new(engine.attributes['id'].to_i,
engine.attributes['name'],
... | [
"def get_scan_engines(opts = {})\n data, _status_code, _headers = get_scan_engines_with_http_info(opts)\n data\n end",
"def list_scanners\n http_get(uri: '/scanners', fields: x_cookie)\n end",
"def list_scanners\n http_get(:uri=>\"/scanners\", :fields=>x_cookie)\n end",
"def index... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extracts and raises an error from +xml+, if any. | def check_error(xml) #:nodoc:
if error = Error.parse(xml, :single => true)
raise Graticule::Error, error.message
end
end | [
"def check_error(xml) #:nodoc:\n err = xml.elements['Error']\n raise Error, err.elements['Message'].text if err\n end",
"def parse_error(xml)\n parse(xml)\n rescue LL::ParserError => error\n return error.message\n end",
"def error_check(xml)\n if xml = xml.elements['Error... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a URL from the Hash +params+. Automatically adds the appid and sets the output type to 'xml'. | def make_url(params) #:nodoc:
params[:appid] = @appid
params[:output] = 'xml'
super params
end | [
"def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end",
"def make_url(params) #:nodoc:\n super params.merge(:output => \"xml\", :oe => 'utf8', :ll => @ll, :spn => @spn, :sensor => false)\n end",
"def make_url(params) #:nodoc:\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the service ticket validation endpoint for the configured CAS URL. The service ticket validation endpoint is defined as `cas_url` + `"/serviceValidate"`. | def service_validate_url
URI.join(cas_url, 'serviceValidate').to_s
end | [
"def validation_url\n Client.cas_url(:validate, :ticket => @ticket, :service => @service_url)\n end",
"def validation_url\n service_validate_url\n end",
"def service_validate_url(service_url, ticket)\n service_url = Addressable::URI.parse(service_url)\n service_url.query_values... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the proxy ticket grantor endpoint for the configured CAS URL. | def proxy_url
URI.join(cas_url, 'proxy').to_s
end | [
"def proxy_ticket\n @proxy_ticket\n end",
"def request_proxy_ticket(pgt, target_service)\n uri = URI.parse(proxy_url)\n h = uri.query ? query_to_hash(uri.query) : {}\n h['pgt'] = pgt.ticket\n h['targetService'] = target_service\n uri.query = hash_to_query(h)\n \n pr = re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the proxy ticket validation endpoint for the configured CAS URL. | def proxy_validate_url
URI.join(cas_url, 'proxyValidate').to_s
end | [
"def validation_url\n Client.cas_url(:validate, :ticket => @ticket, :service => @service_url)\n end",
"def service_validate_url\n URI.join(cas_url, 'serviceValidate').to_s\n end",
"def proxy_url\n URI.join(cas_url, 'proxy').to_s\n end",
"def validation_url\n service_validate_u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build a cloneable repo url using http and basic auth | def repo_url_with_auth
auth = "gitlab-ci-token:#{token}@"
http_url_to_repo.sub(/^https?:\/\//) do |prefix|
prefix + auth
end
end | [
"def clone_url\n \"https://#{url}.git\"\n end",
"def clone_url\n \"git://github.com/#{owner}/#{name}.git\"\n end",
"def clone_url\n \"git://github.com/#{@account}/#{name}.git\"\n end",
"def create_base_url(username, repo_name)\n return \"https://github.com/#{username}/#{repo_nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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... | [
"def run(current_expire = @expire)\n start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC).to_f\n pop_reserve(start_time)\n if current_expire == 0\n run_once_without_pop_reserve until empty?\n else\n @end_time = end_time = start_time + @expire\n run_once_without_pop_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def index\n @social_media_links = SocialMediaLink.all\n end",
"def show\n render json: @social_media_link\n end",
"def index\n @api_v1_social_links = Api::V1::SocialLink.all\n end",
"def edit_media_links #media_resource_links\n Utility.find_links_all_types(links, \"edit-media\")\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /web/v1/social_media_links/1 GET /web/v1/social_media_links/1.json | def show
render json: @social_media_link
end | [
"def index\n @social_media_links = SocialMediaLink.all\n\n render json: @social_media_links\n end",
"def index\n @api_v1_social_links = Api::V1::SocialLink.all\n end",
"def index\n @social_media_links = SocialMediaLink.all\n end",
"def show\n @media_link = MediaLink.find(params[:id])\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def create\n @social_media_link = SocialMediaLink.new(social_media_link_params)\n\n respond_to do |format|\n if @social_media_link.save\n format.html { redirect_to @social_media_link, notice: 'Social media link was successfully created.' }\n format.json { render :show, status: :created, lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def update\n respond_to do |format|\n if @api_v1_social_link.update(api_v1_social_link_params)\n format.html { redirect_to @api_v1_social_link, notice: 'Social link was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_social_link }\n else\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def destroy\n @api_v1_social_link.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_social_links_url, notice: 'Social link was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social_media_link.destroy\n respond_to do |format|... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private methods below helper for loading the tickets presenter | def tickets_presenter
@tickets_presenter ||= V1::TicketsPresenter.new(@tickets, @template)
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_details(res)\n @ticket.requester_name = get_user_name(@ticket.requester_id)\n return @ticket\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def extension_separator\n @@extension_separator\n end",
"def sep; '.' end",
"def identify_delimiter(filename_or_sample)\n #filename_or_sample input can be either a File or an Array or a string - Return delimiter for File or an Array of strings (if found)\n if filename_or_sample.class == Strin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"def fetch_active_watermark\n if current_resource_owner.watermarks.present? && current_resource_owner.watermarks.find_by(status: \"active\") != nil\n if current_resource_owner.watermarks.present?\n Photo.watermark_url = current_resource_owner.watermarks.find_by(status: \"active\").photo.image.path\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=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 | [
"def alice_word_count_hash(text)\n count_hash = Hash.new(0)\n keys = alice_normalize(text)\n keys.each do |word|\n count_hash[word] += 1\n end\n\n count_hash\nend",
"def wc\n words = @str.split(/[\\s,.]+/)\n h=Hash.new(0)\n words.each do |w|\n if h.has_key?(w) == true then\n val = h.fetch(w)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Binomial, a simple sum of Bernoulli samples. | def rbinomial(mean, prob)
((1..mean).map { rbernoulli(prob) }).sum
end | [
"def binomial(n, k)\r\n n.factorial / (k.factorial * (n - k).factorial)\r\nend",
"def binomial_coefficient(n, k); end",
"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 bernoulli(p)\r\n rnd <= p ? 1 : 0\r\n end",
"def binomial... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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... | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 ... | [
"def show\n @control_point = ControlPoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @control_point }\n end\n end",
"def index\n \n unless @parent.nil?\n @control_points = @parent.control_points.order(:updated_at).page(par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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
... | [
"def create\n @controlled_access_point = ControlledAccessPoint.new(params[:controlled_access_point])\n\n respond_to do |format|\n if @controlled_access_point.save\n format.html { redirect_to @controlled_access_point, notice: 'Controlled access point was successfully created.' }\n format.jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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... | [
"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... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 index\n @blogs = Blog.all\n\n respond_to do |format|\n format.json { render json: @blogs}\n format.xml { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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 @newsfeed = Newsfeed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @newsfeed }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 }
... | [
"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 ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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... | [
"def update\n @microblog = Microblog.find(params[:id])\n\n respond_to do |format|\n if @microblog.update_attributes(params[:microblog])\n format.html { redirect_to @microblog, notice: 'Microblog was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
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 | [
"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\n @blog = Blog.find(params[:id])\n @blog.destroy\n\n respond_to do |format|\n ... | {
"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.