query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
GET /client_profiles GET /client_profiles.json | def index
@client_profiles = ClientProfile.all
end | [
"def show\n @clientprofile = Clientprofile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientprofile }\n end\n end",
"def profiles\n hash = {:username => @username}\n @api.request(\"users/profiles/?#{build_query_string(hash... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /client_profiles POST /client_profiles.json | def create
@client_profile = ClientProfile.new(client_profile_params)
respond_to do |format|
if @client_profile.save
format.json { render :show, status: :created, location: @client_profile }
else
format.json { render json: @client_profile.errors, status: :unprocessable_e... | [
"def create\n @client_profile = current_client.build_client_profile(client_profile_params)\n\n authorize @client_profile\n\n respond_to do |format|\n if @client_profile.save\n format.html { redirect_to @client_profile, notice: 'Client profile was successfully created.' }\n format.json { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /client_profiles/1 PATCH/PUT /client_profiles/1.json | def update
respond_to do |format|
if @client_profile.update(client_profile_params)
format.json { render :show, status: :ok, location: @client_profile }
else
format.json { render json: @client_profile.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @clientprofile = Clientprofile.find(params[:id])\n\n respond_to do |format|\n if @clientprofile.update_attributes(params[:clientprofile])\n format.html { redirect_to :back, notice: 'Client\\'s profile was successfully updated.' }\n format.json { head :no_content }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /client_profiles/1 DELETE /client_profiles/1.json | def destroy
@client_profile.destroy
respond_to do |format|
format.json { head :no_content }
end
end | [
"def destroy\n @clientprofile = Clientprofile.find(params[:id])\n @clientprofile.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize @client_profile\n \n @client_profile.destroy\n respon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a DDI metadata file, parse it and return study information Returns a Nesstar::Study object | def parse ddi_file
@logger.info 'Parsing DDI file ' + ddi_file
catalog = DDI::Catalog.new
study = DDI::Study.new
study_info_hash = Hash.new
#TODO This will not work on windows since it depends on the unix tool file need to use a different way. Possibly use rchardet instead
begin
en... | [
"def get_study_information uri, dataset_id\n #TODO use the get_ddi method above\n ddi_uri = URI.parse(uri)\n ddi_uri.merge!(\"/obj/fStudy/\" + dataset_id)\n ddi_uri.merge!('?http://www.nesstar.org/rdf/method=http://www.nesstar.org/rdf/Dataset/GetDDI')\n res = Net::HTTP.get(ddi_uri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /theloaisaches or /theloaisaches.json | def index
@theloaisaches = Theloaisach.all
end | [
"def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end",
"def index\n # TODO - this should only be enabled for an admin, no user should ever see everyone's headaches\n @headaches = Headache.all\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /theloaisaches or /theloaisaches.json | def create
@theloaisach = Theloaisach.new(theloaisach_params)
respond_to do |format|
if @theloaisach.save
format.html { redirect_to @theloaisach, notice: "Theloaisach was successfully created." }
format.json { render :show, status: :created, location: @theloaisach }
else
for... | [
"def create_allele(a)\n allele_data = request(\n :url => \"alleles.json\",\n :method => \"post\",\n :payload => { :allele => a }.to_json\n )\n allele = JSON.parse(allele_data)[\"allele\"]\n return allele\nend",
"def create\n @wayaku = Wayaku.new(wayaku_params)\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /theloaisaches/1 or /theloaisaches/1.json | def update
respond_to do |format|
if @theloaisach.update(theloaisach_params)
format.html { redirect_to @theloaisach, notice: "Theloaisach was successfully updated." }
format.json { render :show, status: :ok, location: @theloaisach }
else
format.html { render :edit, status: :unpro... | [
"def update\n respond_to do |format|\n if @kela.update(kela_params)\n format.html { redirect_to @kela, notice: 'Kela was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kela.errors, stat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /theloaisaches/1 or /theloaisaches/1.json | def destroy
@theloaisach.destroy
respond_to do |format|
format.html { redirect_to theloaisaches_url, notice: "Theloaisach was successfully destroyed." }
format.json { head :no_content }
end
end | [
"def destroy\n @tache = Tache.find(params[:id])\n @tache.destroy\n\n respond_to do |format|\n format.html { redirect_to taches_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hypocrite = Hypocrite.find(params[:id])\n @hypocrite.destroy\n\n respond_to do |form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a single project segment | def segment(project_id, key_id, language_iso, segment_number, req_params = {})
params = { query: [project_id, key_id, language_iso, segment_number], req: req_params }
data = endpoint(name: 'Segments', params: params).do_get
resource 'Segment', data
end | [
"def segment\n return asset_on_segment_history.segment rescue nil\n end",
"def project(project=nil)\n return nil if not project\n cmd = {\"cmd\" => \"viewProject\", \"token\" => @token}\n cmd = {\"ixProject\" => project.to_s}.merge(cmd) if project.class == Fixnum\n cmd = {\"sProject\" => project}.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set and return user rate: example > set_rate(4) if value user_rate is zero, user_rate sets random between from 1 to 5 | def rate(user_rate = nil)
@user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (0..5).cover?(user_rate.to_i))
end | [
"def rate=(value)\n @rate = value\n end",
"def set_rate(rate)\n ra_rate(rate)\n dec_rate(rate)\n end",
"def rate=(rate)\n @rate = rate\n end",
"def set_rate\n @presenter = current_user.presenter\n @present... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add user in Usergroup | def add_user(newuser)
@group_users.push(newuser)
end | [
"def add_user_to_group(user, group)\n\t\t\tend",
"def add_to_users_group\n\t\tc = Command.new(\"usermod -g users -a -G users \\\"#{self.login}\\\"\")\n\t\tc.execute\n\tend",
"def add_user(user)\n group_members.create(group: self, user: user, accepted: DateTime.now)\n end",
"def addUserToGroup\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
delete user from Usergroup with user_id | def delete_user(deluser_id)
@group_users.delete_if { |item| item.user_id == deluser_id }
end | [
"def group_delete_user(group_id, user_id)\n post_data = {\n :group_id => group_id,\n :user_id => user_id\n }\n nessus_rest_delete(\"groups/#{group_id}/users\", post_data)\n end",
"def remove_from_my_group\n @group = Group.find(params[:id])\n @user = User.find(params[:user])\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retur user with max rate | def best_user
@group_users.max_by(&:rate)
end | [
"def worst_user\n @group_users.min_by(&:get_rate)\n end",
"def evaluate_rate(rate) # ovplyvnuje sancu s akou sa dostane do vyberu\n ((rate - @user.average + 4) ** 4) / 8\n end",
"def rate(user_rate = nil)\n @user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retur user with min rate | def worst_user
@group_users.min_by(&:get_rate)
end | [
"def evaluate_rate(rate) # ovplyvnuje sancu s akou sa dostane do vyberu\n ((rate - @user.average + 4) ** 4) / 8\n end",
"def rate(user_rate = nil)\n @user_rate = user_rate.nil? ? @user_rate : (user_rate.to_i.zero? ? rand(1..5) : user_rate if (0..5).cover?(user_rate.to_i))\n end",
"def best_user\n @gr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
An alias for RUBY_PLATFORM === Return name(String):: RUBY_PLATFORM | def name
RUBY_PLATFORM
end | [
"def ruby_platform_osname\n return unless Object.const_defined? :RUBY_PLATFORM\n\n case RUBY_PLATFORM\n when /darwin/ # macOS\n :macos\n when /linux/\n :linux\n when /mingw/\n :windows\n when /openbsd/\n :openbsd\n end\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Are we in an EC2 cloud? === Return true:: If machine is located in an EC2 cloud false:: Otherwise | def ec2?
resolve_cloud_type if @ec2.nil?
@ec2
end | [
"def ec2?\n self.cloud_provider == \"ec2\"\n end",
"def ec2?\n @ec2 ||= EC2.instance_id.include?('i-')\n end",
"def on_ec2?\n ec2 != nil\n end",
"def on_rightscale_ec2_platform?\n return false if (ec2 == nil || ec2[:userdata].match(/RS_/) == nil) # only ec2 supported\n true\nend",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Are we in a Rackspace cloud? === Return true:: If machine is located in an EC2 cloud false:: Otherwise | def rackspace?
resolve_cloud_type if @rackspace.nil?
@rackspace
end | [
"def rackspace?\n self.cloud_provider == \"rackspace\"\n end",
"def has_rackspace_kernel?\n kernel[:release].end_with?(\"-rscloud\")\n end",
"def on_rackspace?\n rackspace != nil\n end",
"def has_rackspace_kernel?\n kernel[:release].split('-').last.eql?(\"rscloud\")\nend",
"def ec2?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Controller object === Return c(Controller):: Platformspecific controller object | def controller
platform_service(:controller)
end | [
"def controller\n @controller ||= @base.controller(controller_name.to_sym)\n end",
"def controller\n @controller ||= ApplicationController.new\n end",
"def controller\n @controller ||= controller_name.constantize\n end",
"def real_controller; Controller.actual_object; end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Filesystem config object === Return fs(Filesystem):: Platformspecific filesystem config object | def filesystem
platform_service(:filesystem)
end | [
"def filesystem\n @fs ||= C.filesystem( self )\n end",
"def fs\n Filesystem.new(self)\n end",
"def filesystem_data\n self['filesystem2'] || self['filesystem']\n end",
"def filesystem_impl=(impl)\n @filesystem_impl = impl\n end",
"def fs\n fs ||= repos.fs\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
SSH information object === Return platform specific ssh object | def ssh
platform_service(:ssh)
end | [
"def ssh_info\n # Return the ssh_info if already retrieved otherwise call the driver\n # and save the result.\n #\n # Ssh info has following format..\n #\n # {\n # :host => \"1.2.3.4\",\n # :port => \"22\",\n # :username => \"mitchellh\",\n # ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Linux platformspecific platform object === Return instance of Platform::Linux:: If ruby interpreter is running on Linux nil:: Otherwise | def linux
raise PlatformError.new("Only available under Linux") unless linux?
require_linux
return Linux.new
end | [
"def linux?\n /linux/.match(RUBY_PLATFORM)\n end",
"def platform_linux?\n RUBY_PLATFORM =~ /linux/\n end",
"def linux?\n RUBY_PLATFORM =~ /linux/\n end",
"def linux?\n RUBY_PLATFORM.match(/linux/)\n end",
"def running_linux?\n /linux/i === RbConfig::CONFIG[\"host_os\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines which cloud we're on by the cheap but simple expedient of reading the RightScale cloud file. | def resolve_cloud_type
cloud_type = File.read(File.join(self.filesystem.right_scale_state_dir, 'cloud')) rescue nil
@ec2 = false
@rackspace = false
@eucalyptus = false
case cloud_type
when 'ec2' then ec2 = true
when 'rackspace' then @rackspace = true
when 'eucalyptu... | [
"def read_cloud_file\n File.read(File.join(self.filesystem.right_scale_state_dir, 'cloud')) rescue nil\n end",
"def resolve_cloud_type\n cloud_type = read_cloud_file\n @ec2 = false\n @rackspace = false\n @eucalyptus = false\n case cloud_type\n when 'ec2' then @ec2 = true\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
in case we need one, e.g. "Rechnung000001082011.pdf" Note: this is | def human_pdf_filename
"Rechnung-#{self.short_number}.pdf"
end | [
"def filename_in_series(pre,post)\n existingfile = File.last_added(\"#{pre}*#{post}\")\n if existingfile\n c = existingfile.scan(/(..)#{post}/)[0][0].to_i \n c += 1\n else\n c = 1\n end\n\n pagenum = c.to_s\n pagenum = \"0\" + pagenum if pagenum.size == 1\n return \"#{pre}#{pagenum}#{post}\", pagen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the first ten responses that would be scheduled for the given protocol. | def execute
@responses = []
@end_date = end_date
@end_date = TimeTools.increase_by_duration(start_date, protocol.duration) if @end_date.blank?
schedule_responses
# Return at most ten responses
@responses.sort_by! { |response| response[:open_from] }
@responses[0...MAX_PREVIEW_RESPONSE_COUNT]
... | [
"def top_ten\n Rails.cache.fetch('top_ten_resp', expires_in: 1.minutes) do\n conn = Faraday.new(url: @base_url) do |faraday|\n faraday.adapter(Faraday.default_adapter)\n end\n\n resp = conn.get do |req|\n req.url '/v1/cryptocurrency/listings/latest'\n req.headers['X-CMC_PRO_AP... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
8kyu I implemented a function which convert the given boolean value into its string representation. | def boolean_to_string(b)
return b.to_s
end | [
"def boolean_to_string(b)\n b.to_s\nend",
"def boolean_to_string(b)\n if b \n \"true\"\n else\n \"false\"\n end\nend",
"def boolean_to_string(b)\n b ? \"true\" : \"false\"\nend",
"def bool_to_str(bool)\n bool ? 'true' : 'false'\n end",
"def bool_to_str(bool)\n if bool == true th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /vehicle_armies POST /vehicle_armies.json | def create
@vehicle_army = VehicleArmy.new(vehicle_army_params)
respond_to do |format|
if @vehicle_army.save
format.html { redirect_to @vehicle_army, notice: (t 'vehicle_armies.title')+(t 'actions.created')}
format.json { render action: 'show', status: :created, location: @vehicle_army }
... | [
"def create\n @vehicle = Vehicle.new(vehicle_params)\n\n if @vehicle.save\n render json: @vehicle, status: :created, location: @vehicle\n else\n render json: @vehicle.errors, status: :unprocessable_entity\n end\n end",
"def create\n @vehicle = Vehicle.new(vehicle_params)\n if @vehicle... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Behaves the same as File.dirname from the standard library, except when passed a second argument, n. In this case, dirname is called n times, essentially finding the file's nth parent. | def dirname file_name, n=1
n.times { file_name = _old_dirname(file_name) }
return file_name
end | [
"def dirname() Path::Name.new(File.dirname(path)) end",
"def pathmap_partial(n)\n target = File.dirname(self)\n dirs = target.pathmap_explode\n if n > 0\n File.join(dirs[0...n])\n elsif n < 0\n partial = dirs[n..-1]\n if partial.nil? || partial.empty?\n target\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the number of tokens in this text. | def length
@tokens.length
end | [
"def token_count\n tokens.size\n end",
"def size\n @tokens.size\n end",
"def char_count\n tokens.join.size\n end",
"def count\n set.tokens[token]\n end",
"def text_number_of_words\n @text.text.nr_of_words\n end",
"def count_tokens?\n true\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
appends a single token to the end of this text. | def <<(new_token)
@tokens << new_token
end | [
"def add_token(token)\n process_unknown\n @tokens << token\n @position += token.length\n end",
"def add_token(aToken)\n append_symbol_to(start, aToken)\n end",
"def add_this_char\n add_look_ahead\n @token\n end",
"def add_token(token)\n @token_stream.push(token)\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Try to find a single xero record by its xero id | def find_record(xero_id)
raise_must_override
end | [
"def find_record(xero_id)\n raise_must_override\n end",
"def find_by_id(id)\n find_one(id)\n rescue RecordNotFound\n nil\n end",
"def retrieve_object(id)\n ActiveFedora::Base.find(id, cast: true)\n end",
"def retrieve_object(id)\n ident = DRI::Identifier.find_by(alternat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
OPTIONAL Update the local status code of the model to match what is in xero. This is needed to avoid status changes that will later cause failure when trying to sync. Example CreditNote: 1. Local status: submitted 2. Remote status: authorized This will be flagged for remote save, but will be updated with the local stat... | def sync_local_model_status(model, record)
true
end | [
"def update_status\n if (!runner_status_code.nil? && !support_status_code.nil?)\n stage_status_code = StageStatusCode.get_state(runner_status_code.short_code, support_status_code.short_code)\n update_attributes(:stage_status_code_id => stage_status_code.id) unless stage_status_code.nil?\n end\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Responsible for finding the local model for this record It is up to the subclass to determine lookup logic or to create a new model if none is found. If nil is returned, the task won't attempt to process the record | def find_model(record)
raise_must_override
end | [
"def find_model!\n model = find_model\n return model if model\n halt 404, 'Not found'\n end",
"def local_entity\n @local_entity ||= begin\n int_klasses.keys.find do |klass_name|\n entity = klass_name.constantize.find_by(local_filter)\n break entity if entity.present... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /milkings/1 PATCH/PUT /milkings/1.json | def update
if @milking.update(milking_params)
render :show, status: :ok, location: v1_milking_url(@milking)
else
render json: @milking.errors, status: :unprocessable_entity
end
end | [
"def update\n respond_to do |format|\n if @milk.update(milk_params)\n format.html { redirect_to @milk, notice: 'Milk was successfully updated.' }\n format.json { render :show, status: :ok, location: @milk }\n else\n format.html { render :edit }\n format.json { render json: @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /milkings/1 DELETE /milkings/1.json | def destroy
@milking.destroy
render json: {status: "Record Deleted"}
end | [
"def destroy\n @milk.destroy\n respond_to do |format|\n format.html { redirect_to milks_url, notice: 'Milk was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request(:delete, \"/recipes/#{id}.json\")\n end",
"def delete_floor_plan(args =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines irregular verbs from the expression Params: infinitive, the given verb preterite, denote events that took place in the past past_participle, form of a verb, ending in 'ed' &blk, block of code that may be run | def irregular(infinitive, preterite = nil, past_participle = nil, &blk)
if block_given?
# create new Verb object with infinitive and &blk
irregular = ::Verbs::Verb.new infinitive, &blk
else
unless preterite && past_participle
raise ArgumentError,
... | [
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s\n\n if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb)\n regular_preterite_with_doubled_terminal_conso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Using options given, determine the conjugation and the subject Return the subject, if there is one, and the proper conjugation Params: infinitive, the given verb options, the list of parameters to alter the conjugation | def conjugate(infinitive, options = {})
infinitive = infinitive.dup if infinitive.is_a?(String)
# set all options according to parameter, or the default
tense = options[:tense] || :present # present, past, future
person = options[:person] || :third # first, second, third
... | [
"def conjugate(infinitive, options = {})\n infinitive = infinitive.dup if infinitive.is_a?(String)\n\n # set all options according to parameter, or the default\n tense = options[:tense] || :present # present, past, future\n person = options[:person] || :third # first, secon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resolves conflictions between options of the conjugation Params: element, infinitive, the given verb tense, an option given by the user person, an option given by the user plurality, an option given by the user mood, an option given by the user | def resolve(element, infinitive, tense, person, plurality, mood)
case element
when String
element
when :infinitive
infinitive
when :present, :past, :present_participle, :past_participle
inflect infinitive, element, person, plurality, mood
when Symbol
inflect... | [
"def conjugation (infinitive, tense, person = nil)\n \n verb = infinitive.downcase\n \n result = get_irregular(verb, person, tense)\n return result unless result.nil?\n\n result = case tense\n when :present then conjugate_present(verb, person)\n when :present_participle then conjugate_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply thir person rules to the verb for the conjugation Params: verb, apply proper third person rules to this | def present_third_person_singular_form_for(verb)
infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
case infinitive
when /[a-z&&#{CONSONANT_PATTERN}]y$/i
"#{infinitive[0..-2]}ies"
when /(ss|sh|t?ch|zz|x|#{CONSONANT_PATTERN}o)$/i
"#{infinitive}es"
when /[^s]s$... | [
"def conjugate_present( verb, person=:third_person_singular )\n\t\treturn verb unless person == :third_person_singular\n\n\t\tcase verb\n\t\twhen /(ch|s|sh|x|z)$/\n\t\t\treturn verb + 'es'\n\t\twhen /(ay|ey|oy|uy)$/\n\t\t\treturn verb + 's'\n\t\twhen /[^aeiou]y$/\n\t\t\treturn verb[ 0..-2 ] + 'ies'\n\t\telse\n\t\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply the regular past tense to a given verb for the conjugation Params: verb, apply regular past tense rules to this | def regular_preterite_for(verb)
infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s
if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_WITHOUT_C_PATTERN}$/) &&
!conjugations.single_terminal_consonants.include?(verb.to_sym)
return regular_preterite_with... | [
"def regular_preterite_for(verb)\n infinitive = verb.is_a?(Verb) ? verb.infinitive.to_s : verb.to_s\n\n if verb.to_s.match(/#{CONSONANT_PATTERN}#{VOWEL_PATTERN}#{DOUBLED_CONSONANT_PATTERN}$/) and !conjugations.single_terminal_consonants.include?(verb)\n regular_preterite_with_doubled_terminal_conso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply proper rules to consonant endings Params: verb, apply double consonant to this | def regular_preterite_with_doubled_terminal_consonant_for(verb)
regular_preterite_for verb.to_s.concat(verb.to_s[-1, 1]).to_sym
end | [
"def regular_preterite_with_doubled_terminal_consonant_for(verb)\n regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym\n end",
"def present_participle_with_doubled_terminal_consonant_for(verb)\n if /c$/ =~ verb.to_s\n present_participle verb.to_sym\n else\n present_parti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply proper rules to consonant endings Params: verb, apply double consonant to this | def present_participle_with_doubled_terminal_consonant_for(verb)
if /c$/ =~ verb.to_s
present_participle verb.to_sym
else
present_participle verb.to_s.concat(verb.to_s[-1, 1]).to_sym
end
end | [
"def regular_preterite_with_doubled_terminal_consonant_for(verb)\n regular_preterite_for verb.to_s.concat(verb.to_s[-1, 1]).to_sym\n end",
"def regular_preterite_with_doubled_terminal_consonant_for(verb)\n regular_preterite_for verb.to_s.concat(verb.to_s[-1,1]).to_sym\n end",
"def regular_preter... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Confirm an imperative mood contains the present tense and second person Params: tense, an option given by the user person, how the conjugation refers to the subject mood, an option given by the user diathesis, an option given by the user | def check_for_improper_constructions(infinitive, tense, person, mood, diathesis)
if (mood == :imperative) && !((person == :second) && (tense == :present))
raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'
end
if (infinitive.to_sym == :be) && (dia... | [
"def check_for_improper_constructions(tense, person, mood)\n if mood == :imperative and not (person == :second and tense == :present)\n raise Verbs::ImproperConstruction, 'The imperative mood requires present tense and second person'\n end\n end",
"def passive_voice_subjunctive_mood_perfect_te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send a file to the given email address | def send_email_by_passing_file(sendto, attachmnent_filename, path='./public')
Pony.mail({
:to => sendto,
:from => 'Magic Team',
:subject => 'Your web scrapper successfully finished',
:body => 'Thanks for using web scrapper service offered by MAGiC',
:attachments => {attachmnent_filenam... | [
"def email(receiver_id, file_name)\n # server and user details\n smtp_server = 'smtp.gmail.com'\n email_id = 'quaranteamcse3901@gmail.com'\n password = 'Quaranteam3901'\n domain = 'gmail.com'\n port = 587\n\n mail = Mail.new do\n from email_id\n to receiver_id\n subject 'Job Sear... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Send a jsonobject to the given email address | def send_email_by_passing_jsonobject(sendto, json_object, filename)
Pony.mail({
:to => sendto,
:from => 'Magic Team',
:subject => 'Your web scrapper successfully finished',
:body => 'Thanks for using web scrapper service offered by MAGiC',
:attachments => {filename => "json_object"},
... | [
"def send_email(email_template_id, request)\n start.uri('/api/email/send')\n .url_segment(email_template_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def send_email(email_template_id, request)\n start.uri('/api/email/... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate IIIF Presentation 2.0 manifest | def manifest
seed = { 'label' => title }
manifest = IIIF::Presentation::Manifest.new(seed)
manifest['@id'] = uri(image_server, "#{id}/manifest")
manifest.attribution = 'University of Pennsylvania Libraries'
manifest.viewing_hint = viewing_hint
manifest.viewing_direction = viewing_direction
... | [
"def create_iiif_manifest(document, image_files)\n manifest = IIIF::Presentation::Manifest.new('@id' => \"#{document[:identifier_uri_ss]}/manifest\")\n manifest.service = iiif_search_service(document) if document[:has_searchable_pages_bsi]\n manifest.label = render_title(document, false)\n manif... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns canvas with one annotated image. The canvas and image size are the same. | def canvas(index:, width:, height:, profile:, label: nil, filepath:, additional_downloads: nil)
canvas = IIIF::Presentation::Canvas.new
canvas['@id'] = uri(image_server, "#{id}/canvas/p#{index}")
canvas.label = label || "p. #{index}"
canvas.height = height
canvas.width = width
annotation = II... | [
"def canvas_from_id(image_id, label, document)\n image_id_suffix = image_id.gsub(/\\A[\\w-]+:/, '/')\n annotation = image_annotation_from_image_id(image_id, document)\n canvas = IIIF::Presentation::Canvas.new('@id' => \"#{document[:identifier_uri_ss]}/canvas#{image_id_suffix}\")\n canvas.label =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns range with sub ranges for each table of contents entry. For each table of contents entry will point to the entire canvas. Note: If at some point coordinates are provided for each table of contents entry we can point directly to the coordinates given. | def range(index:, label:, table_of_contents:)
subranges = table_of_contents.map.with_index do |entry, subrange_index|
IIIF::Presentation::Range.new(
'@id' => uri(image_server, "#{id}/range/r#{index}-#{subrange_index + 1}"),
'label' => entry[:text],
'canvases' => [uri(image_server, "#{i... | [
"def get_subgrid(cords)\n subgrid = []\n x_pos = cords[0] - cords[0] % 3\n (x_pos..x_pos + 2).each do |row_num|\n y_pos = cords[1] - cords[1] % 3\n subgrid += @grid[row_num][y_pos, 3]\n end\n subgrid\n end",
"def cell_range(cells, absolute = T.unsafe(nil)); end",
"def ranges\n @ro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set API response data Author: Aman Date: 03/05/2018 Reviewed By: | def set_api_response_data
meta = {
page_payload: {
}
}
data = {
meta: meta,
result_set: 'admin_user_list',
admin_user_list: @curr_page_data,
can_invite_new_user: @can_invite_new_user.to_i
}
@api_response_d... | [
"def set_api_response_data\n meta = {\n page_number: 1,\n page_payload: {\n }\n }\n\n @api_response_data = {\n meta: meta,\n result_set: 'user_duplicate_list',\n user_duplicate_list: @duplicate_kycs.values\n }\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /questionnairedetails POST /questionnairedetails.json | def create
@questionnairedetail = Questionnairedetail.new(questionnairedetail_params)
respond_to do |format|
if @questionnairedetail.save
format.html { redirect_to @questionnairedetail, notice: 'Questionnairedetail was successfully created.' }
format.json { render :show, status: :created,... | [
"def new\n @questionnaire = Questionnaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def new\n @lab_question = LabQuestion.new\n @questionnaire = params[:lab_questionnaire_id]\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /questionnairedetails/1 PATCH/PUT /questionnairedetails/1.json | def update
respond_to do |format|
if @questionnairedetail.update(questionnairedetail_params)
format.html { redirect_to @questionnairedetail, notice: 'Questionnairedetail was successfully updated.' }
format.json { render :show, status: :ok, location: @questionnairedetail }
else
fo... | [
"def update\n update_resource @questionnaire, questionnaire_params\n respond_with @questionnaire unless response_body\n end",
"def update\n @lab_questionnaire = LabQuestionnaire.find(params[:id])\n\n respond_to do |format|\n if @lab_questionnaire.update_attributes(params[:lab_questionnaire])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /questionnairedetails/1 DELETE /questionnairedetails/1.json | def destroy
@questionnairedetail.destroy
respond_to do |format|
format.html { redirect_to questionnairedetails_url, notice: 'Questionnairedetail was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Little piggy return `:legacy` if columns include legacy timestamp. If not return true if include normal... | def timestamps?
if (model_column_names & %w[created_on updated_on]).any?
:legacy
else
(model_column_names & %w[created_at updated_at]).any?
end
end | [
"def timestamp?\n columns.include?(:created_at) && columns.include?(:updated_at)\n end",
"def legacy_sql?\n val = @gapi.configuration.query.use_legacy_sql\n return true if val.nil?\n val\n end",
"def timestamp?\n type == \"TIMESTAMP\"\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
only admins or team leads can swap duties | def swap?
sid = record.duty_day.season_id
user.has_role?(:admin) or user.has_role?(:leader, user.roster_spots.find_by(season_id: sid, team_id: record.duty_day.team_id)) or user.has_role?(:staff, user.roster_spots.find_by(season_id: sid))
end | [
"def test_swap\n @back_door.swap_child(@door1)\n assert_equal(@back_door.get_child, @door1.get_child)\n assert_equal(@back_door.get_parent, @door1.get_parent)\n assert_equal(@back_door.designation, @door1.designation)\n assert_equal(@back_door.weight, @door1.weight)\n \n @doorknob_door2.swap_ch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call_HT_Event:: Call the specified Common Event | def call_ht_event(event_id, mode)
case mode
when 0
$game_temp.common_event_id = SynHT::Call_event_hunger[event_id]
when 1
$game_temp.common_event_id = SynHT::Call_event_thirst[event_id]
end
end | [
"def common_event_call(object)\n # if object calls common event\n if object.common_event_id > 0\n # temporary variable\n common_event = $data_common_events[object.common_event_id]\n # setup common event execution\n $game_system.map_interpreter.setup(common_event.list, 0, object.common_even... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ssh_login attempts to log in as host_admin on all hosts from current user | def ssh_login
deploy_test_on_hosts_as self.host_admin, self.hosts, "/home/#{self.host_admin}\n", "should be able to connect via ssh" do
'pwd'
end
end | [
"def ssh_login_as_root\n deploy_test_on_hosts_as 'root', self.hosts, '/root', \"Should be able to connect as root via ssh\" do\n 'pwd'\n end\n end",
"def ssh_user_and_host\n self[:user].blank? ? self[:hostname] : self[:user] + '@' + self[:hostname]\n end",
"def ssh_login(do_t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
ssh_login_as_root attempts to log in as root on all hosts from current user | def ssh_login_as_root
deploy_test_on_hosts_as 'root', self.hosts, '/root', "Should be able to connect as root via ssh" do
'pwd'
end
end | [
"def enable_root(host)\n if host['user'] != 'root'\n copy_ssh_to_root(host, @options)\n enable_root_login(host, @options)\n host['user'] = 'root'\n host.close\n end\n end",
"def disable_root_login\n Net::SSH.start host, 'root', :keys => @keys do |ssh|\n log_to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make sure we end up with a flat array of probe_sets | def probe_sets=(probe_sets)
@probe_sets = Array(probe_sets).flatten
end | [
"def probe_sets\n @probe_sets ||= Array.new\n end",
"def prepare_dataset(ds)\n ds = [ds] unless ds.first.is_a?(Array)\n ds\n end",
"def reset\n probe_sets.each(&:reset)\n end",
"def set_up_test(input_plates)\n input_plates.each do |plate|\n sample = plate.parts.first.sample\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Grab some probe_sets or an array | def probe_sets
@probe_sets ||= Array.new
end | [
"def probe_sets=(probe_sets)\n @probe_sets = Array(probe_sets).flatten\n end",
"def probe_set\n report[@probe_set ||= report.keys.first]\n end",
"def setup_probes( probes )\n probes.map do |probe|\n probe_group?( probe ) ? probes_grouped( probe ) : probe_definition( p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hash representation of all the probe_sets. This gives is an intermediate format that we can parse from other systems or code that needs reporting data for formatting, or whatever. | def to_hash
# Drop the probes into the report
probe_sets.inject({}) { |report, set|
report[set.name.to_s] = set.probes.inject({}) { |memo, (_, probe)|
# round the values to 2 decimal places
memo[probe.name] = (probe.value.to_f * 100).round().to_f/100
memo
}
... | [
"def probe_sets\n @probe_sets ||= Array.new\n end",
"def probe_set\n report[@probe_set ||= report.keys.first]\n end",
"def dump_hashes\n @hashes\n end",
"def dump_hashes!\n hashes = @sets.inject({}) do |hashes, setinfo|\n hashes[setinfo.name] = setinfo.set.hash ; ha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Reset all the counters in each probe. | def reset
probe_sets.each(&:reset)
end | [
"def reset\n probes.each{|_, probe| probe.reset }\n end",
"def clear\n probes.clear\n end",
"def reset\n sync {stats.each_value {|sampler| sampler.reset}}\n self\n end",
"def reset\n @collected_metrics = []\n end",
"def reset\n @uses = 0\n end",
"def reset_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The remodel method takes an Xml object as parameter. Output is expected to be the same. Modify the node in place. is preferred. An "information" hash is also passed in. | def remodel( node, info={} )
level = info[:count] || 1
node.attributes['level'] = level
node
end | [
"def rexml!\n @@parser = USE_REXML\n end",
"def xml_replace_node(xml, old_node, new_node)\n xml.find(\"//osm/way/nd[@ref='#{old_node}']\").first[\"ref\"] = new_node.to_s\n xml\n end",
"def rexmlify(data)\n\t\tdoc = data.kind_of?(REXML::Document) ? data : REXML::Document.new(data)\n\tend",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate the HTML report for the Scan | def html_report
begin
require 'ruport'
rescue LoadError
abort("Couldn't load ruport, suggest that gem install ruport should help")
end
unless @options.report_file
html_report_file_name = 'Kismet-Wireless-Report-' + Time.now.to_s + '.html'
end
unless @options.report_file =~ /h... | [
"def generate_scan_report\n freshclam_stderr = IO.read($config[\"freshclam_stderr\"])\n freshclam_stdout = @freshclam_stdout\n template = IO.read(\"views/clamav.html.erb\")\n output = ERB.new(template).result(binding)\n File.open(\"clamav.html\", \"w\") {|file| file.write(output)}\nend",
"def report\n get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets up the HTML report header. CSS and Javascript for the Google Maps Option | def html_report_header
@report << '
<html>
<head>
<title> Kismet Wireless Report</title>
<style>
body {
font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
background: #E6EAE9;
}
#report-header {
... | [
"def header()\n apikey = \"ABQIAAAAmxDIRcelCE7QQOeFeIJlKBTGG_UT9D1o9I64E2gi7TbsJ77h0BRE8mxlSeFh8c_V1P1tW2oE4WQWSg\"\n apikey = \"ABQIAAAAmxDIRcelCE7QQOeFeIJlKBSbofJ6434O1fjLInemwcEZUD5mwBQzVbYptimtJHQhOlybNCur67h9EQ\"\n # TODO disabled fix apikey = ApiKey.get({:with_vml=>true})\n # TODO use this - break... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates the report section for Infrastructure Networks | def html_report_inf
@report << '<div id="title">Infrastructure Networks</div><br /><br />'
@log.debug("Starting reporting Infrastructure networks there were " + @infrastructure_networks.length.to_s + " networks to list")
@infrastructure_networks.each do |ssid,bssid|
tab = Ruport::Data::Table(%w[bssid ... | [
"def network_report\n get_resource_list('network', 'v2.0/networks', 'networks')\n @network_csv_array = []\n @network_print_array = []\n @resource_id_list.each do |networkid|\n network = rest_get(\"#{@resource_url}/v2.0/networks/#{networkid}\", @token_id)\n network_array = JSON.parse(network)['... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets up the HTML report for AdHoc Networks | def html_report_adhoc
@log.debug("Starting to report ad-hoc networks, there were " + @adhoc_networks.length.to_s + "to report")
@report << '<div id="title">Adhoc Networks</div><br /><br />'
@adhoc_networks.each do |ssid,bssid|
tab = Ruport::Data::Table(%w[bssid channel cipher cloaked? manufacturer fir... | [
"def html_report_inf\n @report << '<div id=\"title\">Infrastructure Networks</div><br /><br />'\n @log.debug(\"Starting reporting Infrastructure networks there were \" + @infrastructure_networks.length.to_s + \" networks to list\")\n @infrastructure_networks.each do |ssid,bssid|\n tab = Ruport::Data::... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets up the report for Probe Networks | def html_report_probe
@log.debug("Starting to report probe networks, there were " + @probe_networks.length.to_s + " to report")
@report << '<div id="title">Probe Networks</div><br /><br />'
@probe_tab = Ruport::Data::Table(%w[bssid manufacturer])
@probe_networks.each do |probe,info|
if @options.gp... | [
"def report_network_list\n header\n puts 'Creating the Networks report'\n network_report\n begin\n print_table(@network_print_headers, @network_print_array)\n rescue NoMethodError\n puts 'The number of Networks seems to be zero!'\n end\n end",
"def html_report_inf\n @report << '<di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /time_gliders/1 GET /time_gliders/1.xml | def show
@time_glider = TimeGlider.find(params[:id])
respond_to do |format|
format.html # show.html.erb
# we do not want to use this
# format.json { render :json => @time_glider }
# because we want to change the json output of a few fields
format.json # show.json.erb
format... | [
"def new\n @time_glider = TimeGlider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_glider }\n end\n end",
"def index\n if params[:start_time]\n @light_powers = LightPower.where(\"time >= ?\", params[:start_time].to_f)\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /time_gliders/new GET /time_gliders/new.xml | def new
@time_glider = TimeGlider.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @time_glider }
end
end | [
"def new\n @timelost = Timelost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @timelost }\n end\n end",
"def create\n @time_glider = TimeGlider.new(params[:time_glider])\n\n respond_to do |format|\n if @time_glider.save\n format.ht... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /time_gliders POST /time_gliders.xml | def create
@time_glider = TimeGlider.new(params[:time_glider])
respond_to do |format|
if @time_glider.save
format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully created.') }
format.xml { render :xml => @time_glider, :status => :created, :location => @time_glide... | [
"def new\n @time_glider = TimeGlider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @time_glider }\n end\n end",
"def update\n @time_glider = TimeGlider.find(params[:id])\n\n respond_to do |format|\n if @time_glider.update_attributes(param... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /time_gliders/1 PUT /time_gliders/1.xml | def update
@time_glider = TimeGlider.find(params[:id])
respond_to do |format|
if @time_glider.update_attributes(params[:time_glider])
format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully updated.') }
format.xml { head :ok }
else
format.html { ren... | [
"def create\n @time_glider = TimeGlider.new(params[:time_glider])\n\n respond_to do |format|\n if @time_glider.save\n format.html { redirect_to(@time_glider, :notice => 'Time glider was successfully created.') }\n format.xml { render :xml => @time_glider, :status => :created, :location => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /time_gliders/1 DELETE /time_gliders/1.xml | def destroy
@time_glider = TimeGlider.find(params[:id])
@time_glider.destroy
respond_to do |format|
format.html { redirect_to(time_gliders_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrap_xmls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @daily_grr = DailyGrr.find(params[:id])\n @daily_grr.destroy\n\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Use email as a search term to set the delegate_user | def find_email
val = @email
return if val.nil?
val = LdapQuery::Scanner.search(val).as_user_attributes[:email]
if val.nil?
errors.add :base, 'Email address not found'
return false
end
@email = val
xdelegate = User.find_by_email(val.to_s)
if xdelegate.nil?
errors... | [
"def set_email(email = nil, email_selector = nil, ldap_lookup = nil)\n self.email = email || []\n if email_selector\n # Get the primary email address from the address list\n self.primary_email = email_selector.email(self.email)\n # Get the username from the primary... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overrides auth_handler= so if the authentication changes, the session cookie is cleared. | def auth_handler=(handler)
@session_cookie = nil
return super(handler)
end | [
"def after_session_authentication\n end",
"def touch_auth_session\n auth_session.touch! if logged_in?\n end",
"def unobtrusively_authenticate_user!\n if cookies[:user_uid]\n set_user_session_from_cookie\n else\n sign_out_user\n end\n end",
"def force_auth\n\t\tlogger.debug \" ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overrides make_request to handle 302 redirects with a session cookie. | def make_request(method, url, body = '', retries = 4)
response = super(method, url, body)
if response.status_code == 302 and retries > 0
@session_cookie = response.headers['set-cookie']
return self.make_request(method, url, body,
retries - 1)
else
retur... | [
"def follow_redirect opts={}, &block\n return if !redirect?\n new_opts = @request ? @request.to_hash : {}\n\n if @code == \"303\" || @code == \"302\"\n new_opts[:http_method] = \"GET\"\n new_opts.delete(:form)\n new_opts.delete(:data)\n end\n\n new_opts.delete(:headers)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom prepare_headers to include the session cookie if it exists | def prepare_headers
if @session_cookie
@headers['cookie'] = @session_cookie
end
super
end | [
"def set_headers! session = nil\n response.headers['sid'] = session.id\n response.headers['utoken'] = session.utoken\n end",
"def add_cookie_headers\n return unless @cookie\n header.merge!(cookie.to_header)\n end",
"def add_cookie_if_needed(req)\n req.headers = { \"Cookie\" => conn.head... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method that test the dark roast class | def test_dark_roast
beverage = DarkRoast.new
beverage = Milk.new(beverage)
beverage = Mocha.new(beverage)
beverage = Mocha.new(beverage)
beverage = Whip.new(beverage)
assert_equal("Dark Roast Coffee, Milk, Mocha, Mocha, Whip",
beverage.description)
assert_equal(1.59, beverag... | [
"def test_dark_roast\n beverage = DarkRoast.new\n beverage = Milk.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Whip.new(beverage)\n assert_equal(\"Dark Roast Coffee, Milk, Mocha, Mocha, Whip\",\n beverage.description)\n assert_equal... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method that test the house blend class | def test_house_blend
beverage = HouseBlend.new
beverage = Soy.new(beverage)
beverage = Mocha.new(beverage)
beverage = Whip.new(beverage)
assert_equal("House Blend Coffee, Soy, Mocha, Whip",
beverage.description)
assert_equal(1.34, beverage.cost)
end | [
"def test_house_blend\n beverage = HouseBlend.new\n beverage = Soy.new(beverage)\n beverage = Mocha.new(beverage)\n beverage = Whip.new(beverage)\n assert_equal(\"House Blend Coffee, Soy, Mocha, Whip\",\n beverage.description)\n assert_equal(1.34, beverage.cost)\n end",
"def test... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Problem Write a method that takes an Array of integers as input, multiplies all the numbers together, divides the result by the number of entries in the Array, and then prints the result rounded to 3 decimal places. Assume the array is nonempty. Examples / Test Cases show_multiplicative_average([3, 5]) The result is 7.... | def show_multiplicative_average(array)
multiplied = array.reduce(:*)
average = multiplied / array.size.to_f
average.round(3)
#sprintf('%.3f', average )
end | [
"def show_multiplicative_average(array)\n result = (array.reduce(:*) / array.size.to_f).round(3)\n puts \"The result is #{format('%0.3f', result)}\"\nend",
"def show_multiplicative_average(array)\n product = 1\n array.each do |n|\n product *= n\n end\n result = (product.to_f / array.size).round(3)\n put... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returner enrollment type for en seksjon s | def getEnrollmentType(s)
# //The enrollment type. One of 'StudentEnrollment', 'TeacherEnrollment',
# //'TaEnrollment', 'DesignerEnrollment', 'ObserverEnrollment'.
# "type": "StudentEnrollment",
type = ""
case s["type"]
when "StudentEnrollment"
type = "student"
when "TeacherEnrollment"
type = "teac... | [
"def enrollment_type\n return @enrollment_type\n end",
"def enrollment_class\n (params[:enrollment].blank? || params[:enrollment][:type].blank? ? 'Enrollment' : params[:enrollment][:type]).constantize\n end",
"def enrollment_type=(value)\n @enrollment_type = value\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returner en liste av enrollments i seksjon sid. | def getEnrollmentsInSection(sid)
uri = sprintf("/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999", sid)
enrollments = $canvas.get(uri)
return enrollments
end | [
"def articles_list\n\t\trespond_to do |format|\n\t\t\tif params_doesnt_have_sid params\n\t\t\t\tformat.json { render json: { \"error\" => \"You must provide a session ID!\" }, status: 401 }\n\t\t\telse\n\t\t\t\tuser_id = get_user_id params[:sid]\n\t\t\t\tif user_id\n\t\t\t\t\tformat.json { render json: { \"res\" =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create all screenshots for the Scrollytelling. | def create_all!
if title_card_path.exist?
Dir
.glob(story.screenshots.join("*page*.png"))
.sort_by { |path| path.scan(/\d+/).first.to_i }
.each do |path|
path.slice! File.extname(path) # drop the extension
@paths[:pages] << absolute(path... | [
"def make_screenshot_here\n data_time = Time.now.strftime('%d-%m-%Y_%H:%M')\n puts \"Saving screenshot #{data_time}.png ...\"\n page.save_screenshot('tmp/screens/' + data_time + '.png')\n end",
"def make_screenshot\n Logbook.step('Taking a screenshot of a result page')\n @browser.save_screenshot(\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor > Get the listing details to be submitted in the given site | def initialize(listingDetails, site_url,login_details)
@site_details = listingDetails
@login_details = login_details
@site_url = site_url
@browser = Watir::Browser.new :chrome
end | [
"def listing_url\n self.dig_for_string(\"listingSummary\", \"listingURL\")\n end",
"def initialize(site)\n @site = site\n end",
"def fetch_listing_page\n @listing_agent.user_agent_alias = Mechanize::AGENT_ALIASES.keys.sample\n\n @page = @listing_agent.get(@listing_url)\n collect_table... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delivers this payload to CrashLog Captures any exceptions and logs them. | def deliver!
deliver
rescue Exception => e
error('Failed to deliver notification to CrashLog collector')
log_exception(e)
end | [
"def processCrash; raise \"Abstract Exception: AbstractBeezwaxCrashProcessor.processCrash must be extended\"; end",
"def crashlog(exception, request, context, options = {})\n Crashlog.new(exception, request, context, options)\n end",
"def render_exception_with_crash_log(env, exception)\n contro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes a Community model and Plan entity. Returns a Hash in a form that MarketplaceRouter expects | def community_hash(community, plan)
Maybe(community).map { |c|
{
ident: c.ident,
domain: c.domain,
deleted: c.deleted?,
use_domain: c.use_domain?,
closed: Maybe(plan)[:closed].or_else(false),
hold: Maybe(plan)[:hold].or_else(false),
}
}.or_else(nil)
... | [
"def plan_params plan\n {\n name: plan.name,\n plan_id: plan.id,\n status: plan.status,\n chargebee_data: {\n price: plan.price,\n period: plan.period,\n period_unit: plan.period_unit,\n trial_period: plan.trial_period,\n trial_period_unit: plan.trial_period... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /private_album_images GET /private_album_images.json | def index
@private_album_images = PrivateAlbumImage.all
end | [
"def get_album_images(hash)\n response = make_request(\"GET\", \"album/#{hash}/images\")\n return response\nend",
"def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end",
"def im... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /private_album_images POST /private_album_images.json | def create
@private_album_image = PrivateAlbumImage.new(private_album_image_params)
respond_to do |format|
if @private_album_image.save
format.html { redirect_to @private_album_image, notice: 'Private album image was successfully created.' }
format.json { render action: 'show', status: :c... | [
"def create\n image_ids = params[:album][:image_ids]\n\n @album = @event.albums.new(album_params)\n\n respond_to do |format|\n if @album.save\n @album.add_images_by_id(image_ids)\n format.html { redirect_to [@event, @album], notice: 'Album was successfully created.' }\n format.jso... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /private_album_images/1 PATCH/PUT /private_album_images/1.json | def update
respond_to do |format|
if @private_album_image.update(private_album_image_params)
format.html { redirect_to @private_album_image, notice: 'Private album image was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | [
"def update\n respond_to do |format|\n if @private_album.update(private_album_params)\n format.html { redirect_to @private_album, notice: 'Private album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.js... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /private_album_images/1 DELETE /private_album_images/1.json | def destroy
@private_album_image.destroy
respond_to do |format|
format.html { redirect_to private_album_images_url }
format.json { head :no_content }
end
end | [
"def destroy\n @public_album_image.destroy\n respond_to do |format|\n format.html { redirect_to public_album_images_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Internal: Determine what clock to use for the machine we are one. We want the highest resolution clock possible, which should be nanosecond resolution. Get the resolution of each clock id and then return the higest resolution id from the list Returns the clock id to use on this ruby | def determine_clock_id
ids_and_resolutions = potential_clock_ids.map { |clock_id|
[clock_id, Process.clock_getres(clock_id)]
}
# Sort them by the resolution - we want the smallest one first
ids_and_resolutions.sort_by! { |pair| pair[1] }
return ids_and_resolutions.first[0]
en... | [
"def clock_resolution_description\n \"#{CLOCK_RESOLUTION_NANOSECONDS}ns\"\n end",
"def clock_name\n case CLOCK_ID\n when Symbol\n CLOCK_ID.to_s\n else\n const = Process.constants.grep(/CLOCK/).find { |c|\n CLOCK_ID == Process.const_get(c)\n }\n \"Process::#{const.to_s}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an inbox ruleset Create a new inbox rule for forwarding, blocking, and allowing emails when sending and receiving | def create_new_inbox_ruleset(create_inbox_ruleset_options, opts = {})
data, _status_code, _headers = create_new_inbox_ruleset_with_http_info(create_inbox_ruleset_options, opts)
data
end | [
"def create_inbox_ruleset(inbox_id, create_inbox_ruleset_options, opts = {})\n data, _status_code, _headers = create_inbox_ruleset_with_http_info(inbox_id, create_inbox_ruleset_options, opts)\n data\n end",
"def test_new_inbox_ruleset(test_new_inbox_ruleset_options, opts = {})\n data, _status_co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete an inbox ruleset Delete inbox ruleset | def delete_inbox_ruleset(id, opts = {})
delete_inbox_ruleset_with_http_info(id, opts)
nil
end | [
"def delete_inbox_rulesets(opts = {})\n delete_inbox_rulesets_with_http_info(opts)\n nil\n end",
"def remove_ruleset\n @rules = []\n BeEF::Core::Models::Dns::Rule.destroy\n end",
"def test_13_remove_ruleset\n removed = @@dns.remove_ruleset\n ruleset = @@dns.get_ruleset\n\n ass... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete inbox rulesets Delete inbox rulesets. Accepts optional inboxId filter. | def delete_inbox_rulesets(opts = {})
delete_inbox_rulesets_with_http_info(opts)
nil
end | [
"def delete_inbox_ruleset(id, opts = {})\n delete_inbox_ruleset_with_http_info(id, opts)\n nil\n end",
"def test_inbox_rulesets_for_inbox(inbox_id, inbox_ruleset_test_options, opts = {})\n data, _status_code, _headers = test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
List inbox rulesets List all rulesets attached to an inbox | def get_inbox_rulesets(opts = {})
data, _status_code, _headers = get_inbox_rulesets_with_http_info(opts)
data
end | [
"def list_inbox_rulesets(inbox_id, opts = {})\n data, _status_code, _headers = list_inbox_rulesets_with_http_info(inbox_id, opts)\n data\n end",
"def list_rulesets(inspector)\n inspector.describe_rules_packages({rules_package_arns: inspector.list_rules_packages({})[0] })[0]\nend",
"def test_inbox_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test an inbox ruleset Test an inbox ruleset | def test_inbox_ruleset(id, inbox_ruleset_test_options, opts = {})
data, _status_code, _headers = test_inbox_ruleset_with_http_info(id, inbox_ruleset_test_options, opts)
data
end | [
"def test_inbox_rulesets_for_inbox(inbox_id, inbox_ruleset_test_options, opts = {})\n data, _status_code, _headers = test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts)\n data\n end",
"def test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test inbox rulesets for inbox Test inbox rulesets for inbox | def test_inbox_rulesets_for_inbox(inbox_id, inbox_ruleset_test_options, opts = {})
data, _status_code, _headers = test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts)
data
end | [
"def test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxRulesetControllerApi.test_inbox_rulesets_for_inbox ...'\n end\n # verify the required parameter 'inbox_id' i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test inbox rulesets for inbox Test inbox rulesets for inbox | def test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: InboxRulesetControllerApi.test_inbox_rulesets_for_inbox ...'
end
# verify the required parameter 'inbox_id' is set
... | [
"def test_inbox_rulesets_for_inbox(inbox_id, inbox_ruleset_test_options, opts = {})\n data, _status_code, _headers = test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts)\n data\n end",
"def test_inbox_ruleset(id, inbox_ruleset_test_options, opts = {})\n data, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test new inbox ruleset Test new inbox ruleset | def test_new_inbox_ruleset(test_new_inbox_ruleset_options, opts = {})
data, _status_code, _headers = test_new_inbox_ruleset_with_http_info(test_new_inbox_ruleset_options, opts)
data
end | [
"def test_inbox_rulesets_for_inbox(inbox_id, inbox_ruleset_test_options, opts = {})\n data, _status_code, _headers = test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_options, opts)\n data\n end",
"def test_inbox_rulesets_for_inbox_with_http_info(inbox_id, inbox_ruleset_test_o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
merge pr_branch into upstream targeted branch | def merge_pr_totarget(upstream, pr_branch, repo)
goto_prj_dir(repo)
# check that we are in a git dir
check_git_dir
`git checkout #{upstream}`
`git remote update`
`git fetch`
`git pull origin #{upstream}`
`git checkout -b PR-#{pr_branch} origin/#{pr_branch}`
puts `git branch`
end | [
"def merge_pr_totarget(upstream, pr_branch)\n goto_prj_dir\n check_git_dir\n `git checkout #{upstream}`\n check_duplicata_pr_branch(\"#{pr_fix}#{pr_branch}\")\n `git remote update`\n `git fetch`\n `git pull origin #{upstream}`\n `git checkout -b #{pr_fix}#{pr_branch} origin/#{pr_branch}`\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cleanup the pr_branch(delete it) | def del_pr_branch(upstream, pr)
`git checkout #{upstream}`
`git branch -D PR-#{pr}`
end | [
"def del_pr_branch(upstream, pr)\n `git checkout #{upstream}`\n `git branch -D #{pr_fix}#{pr}`\n end",
"def clean_tree (branch)\n\n branch.children = branch.children.inject(Children.new(branch)) do |r, c|\n cc = if c.name == 'sequence' and c.children.size == 1\n c.children.first... | {
"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.