query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
if target is _, returns false if we've guessed the word's char already if target is az, returns false if our word has a different char | def char_valid?(char, guesses, target)
if target == '_'
return !guesses.include?(char)
end
char == target
end | [
"def guess?(letter)\n @word.downcase.include?(letter)\n end",
"def all_letters_guessed?\n word_guessed = true\n @player_work.each { |c| word_guessed = false if c == '_' }\n word_guessed\n end",
"def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend",
"def check(char)\n found =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create new connection between BeaconCtrl and BeaconClient New oauth token should be returned by server. | def connect!
@connection = user ? connection_for_user : connection_for_application
@auth_token = @connection.token
BeaconClient.logger.debug("Client token: #{@auth_token}") if BeaconClient.config.debug?
@auth_token
rescue OAuth2::Error => error
BeaconClient.logger.error(error.message)
... | [
"def oauth2_client(token, params = {})\n @oauth2_client = RubyLokaliseApi::OAuth2Client.new token, params\n end",
"def create_client\n @client = LinkedIn::API.new(auth_hash[\"token\"])\n end",
"def connect!\n retrieve_auth_token unless connected?\n auth_token[:token]\n end",
"def conn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Connect as an User Require ApplicationID, ApplicationSecret, UserEmail, UserPassword | def connection_for_user
BeaconClient.logger.debug([user.email.inspect, user.password.inspect].join(' : '))
oauth_client.password.get_token(
user.email, user.password,
email: user.email
)
end | [
"def login\n client.login(\n params[:user],\n params[:password],\n authParams: {\n scope: 'openid name email'\n },\n connection: 'Username-Password-Authentication'\n )\n end",
"def connect\n @user = User.where(:email => params[:user][:email]).first\n # If there is no u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /time/time_reports GET /time/time_reports.json | def index
@time_time_reports = Time::TimeReport.all
end | [
"def show\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_report }\n end\n end",
"def index\n get_todays_data\n\n respond_to do |format|\n format.html { }\n format.json { ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /time/time_reports POST /time/time_reports.json | def create
@time_time_report = Time::TimeReport.new(time_time_report_params)
respond_to do |format|
if @time_time_report.save
format.html { redirect_to @time_time_report, notice: 'Time report was successfully created.' }
format.json { render :show, status: :created, location: @time_time_... | [
"def create\n @time_report = TimeReport.new(params[:time_report])\n\n respond_to do |format|\n if @time_report.save\n format.html { redirect_to @time_report, notice: 'Time report was successfully created.' }\n format.json { render json: @time_report, status: :created, location: @time_report... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /time/time_reports/1 PATCH/PUT /time/time_reports/1.json | def update
respond_to do |format|
if @time_time_report.update(time_time_report_params)
format.html { redirect_to @time_time_report, notice: 'Time report was successfully updated.' }
format.json { render :show, status: :ok, location: @time_time_report }
else
format.html { render :... | [
"def update\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n if @time_report.update_attributes(params[:time_report])\n format.html { redirect_to @time_report, notice: 'Time report was successfully updated.' }\n format.json { head :no_content }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /time/time_reports/1 DELETE /time/time_reports/1.json | def destroy
@time_time_report.destroy
respond_to do |format|
format.html { redirect_to time_time_reports_url, notice: 'Time report was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @time_report = TimeReport.find(params[:id])\n @time_report.destroy\n\n respond_to do |format|\n format.html { redirect_to time_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy!\n render json: {status: :ok}\n end",
"def des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
shims from Blacklight 6 controller fetch to BL 7 search service | def search_service
Blacklight::SearchService.new(config: blacklight_config, user_params: {})
end | [
"def search_service\n Dcv::SearchService.new(config: blacklight_config, user_params: {})\n end",
"def search\r\n SearchController.instance\r\n end",
"def search\n SearchController.instance\n end",
"def search_service_context\n {}\n end",
"def search_model\n end",
"def fetch_data\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:only=>[:edit, :index, :new, :show] GET /user_device_configurations GET /user_device_configurations.json | def index
@user_device_configurations = UserDeviceConfiguration.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @user_device_configurations }
end
end | [
"def show\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def show\n render json: @device_configuration.to_json\n end",
"def new\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_device_configurations/1 GET /user_device_configurations/1.json | def show
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_device_configuration }
end
end | [
"def index\n @user_device_configurations = UserDeviceConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_device_configurations }\n end\n end",
"def show\n render json: @device_configuration.to_json\n end",
"def get_resource_confi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_device_configurations/new GET /user_device_configurations/new.json | def new
@user_device_configuration = UserDeviceConfiguration.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_device_configuration }
end
end | [
"def create\n @user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])\n\n respond_to do |format|\n if @user_device_configuration.save\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /user_device_configurations POST /user_device_configurations.json | def create
@user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])
respond_to do |format|
if @user_device_configuration.save
format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }
format.js... | [
"def create\n if !current_user.manager?\n head :forbidden\n else\n @device_configuration = DeviceConfiguration.new(device_configuration_params)\n device = Device.find(params[:device_id])\n @device_configuration.device_type = device.device_type\n if @device_configuration.save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /user_device_configurations/1 PUT /user_device_configurations/1.json | def update
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
respond_to do |format|
if @user_device_configuration.update_attributes(params[:user_device_configuration])
format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully up... | [
"def update\n if !current_user.manager?\n head :forbidden\n else\n if @device_configuration.update(device_configuration_params)\n render json: @device_configuration.to_json, status: :ok\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /user_device_configurations/1 DELETE /user_device_configurations/1.json | def destroy
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
@user_device_configuration.destroy
respond_to do |format|
format.html { redirect_to user_device_configurations_url }
format.json { head :ok }
end
end | [
"def destroy\n @user_config = UserConfig.find(params[:id])\n @user_config.destroy\n\n respond_to do |format|\n format.html { redirect_to user_configs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @graphium_configuration.destroy\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Save output to the output file (one paragraph per line). Include additional HTML and CSS if attr additional_html = true | def save_to_file
File.open(@output, 'w+') do |file|
file.puts HEADER if @additional_html
file.puts @data_for_output.join("\n")
file.puts FOOTER if @additional_html
end
end | [
"def write_html(html)\n File.open(\"assignment02-output.html\", \"w\") do |file|\n file.write html\n end\n end",
"def save(path)\n File.open(path, \"w\") { |outfile| outfile.print self.render }\n end",
"def output(contents, filename = \"output.html\")\n out_file = File.new(filename, \"w\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Actions for Fulfillment Rights subform | def add_fulfillment_rights_row
@organization = Organization.find(params[:organization_id])
@new_fr_identity = Identity.find_or_create(params[:new_fr_identity_id])
@fulfillment_rights = fulfillment_rights(@organization_id)
set_registrar_enabled(@organization)
end | [
"def claim_form\n end",
"def single_item_action_form_fields(form, document, action)\n render '/collections/single_item_action_fields', form: form, document: document, action: action\n end",
"def reseller_allow_edit(permission)\n return reseller_right(permission) == 2\n end",
"def authorize_edit_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Temporarily merges the migration files by copying them over and then deletes them. Sequel's migration class cannot work with migrations in different directories even if sequelrails can. This is the simplest solution that works until ::Sequel::Migrator supports merging of multiple migration directories. | def temporarily_merge_migration_files(explanation=nil)
copy_files = []
Rails.application.config.paths["db/migrate"].expanded.each do |specified_migration_dir|
if migrations_dir.to_s != specified_migration_dir
Dir[File.join(specified_migration_dir, '*')].each do |file_name|
... | [
"def update_migration_files\n migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort\n migration_templates.each do |template_file|\n destination_file = template_file.match(/^\\d*_(.*\\.rb)/)[1] # 01_create_good_jobs.rb.erb => create_good_jobs.rb\n migration_template \"mi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the Zlist to the list of comments for this config item. | def _zlist
@config.ffi_delegate.comments
end | [
"def comments\r\n return node_list(TYPE_COMMENT, nil)\r\n end",
"def comments\n get_ticket_property_list(\"comments\" , Unfuddled::Comment)\n end",
"def comments\n return @comments\n end",
"def comments\n item.comments ? item.comments.strip : ''\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Last push button helper. push_job_class is FtpPushJob, RhnStagePushJob or RhnLivePushJob | def last_push_link(push_job_class, errata)
if (last_push = push_job_class.last_push(errata))
push_job_link(last_push, 'Last job')
end
end | [
"def last_push_link(push_job_class, errata)\n \"<a href='#'>Last job</a>\"\n end",
"def last_prepush_link(push_job_class, errata)\n jobs_since_respin = errata.push_jobs_since_last_state(push_job_class, 'NEW_FILES')\n if (job = jobs_since_respin.nochannel.order('id desc').first)\n push_job_link(job,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Shows link to last nochannel job, if any. This is represented to the user as a "prepush" of the live content | def last_prepush_link(push_job_class, errata)
jobs_since_respin = errata.push_jobs_since_last_state(push_job_class, 'NEW_FILES')
if (job = jobs_since_respin.nochannel.order('id desc').first)
push_job_link(job, 'Pre-push')
end
end | [
"def last_push_link(push_job_class, errata)\n \"<a href='#'>Last job</a>\"\n end",
"def last_push_link(push_job_class, errata)\n if (last_push = push_job_class.last_push(errata))\n push_job_link(last_push, 'Last job')\n end\n end",
"def push_history_link(push_job_class, errata)\n if push_job_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Won't show the link if here are no pushes of the given type since having the button there tends to imply there might be a relevant push job to look at. | def push_history_link(push_job_class, errata)
if push_job_class.for_errata(errata).any?
workflow_action_link("Push History", { :controller => 'push', :action => 'push_history_for_errata', :id => errata })
end
end | [
"def type_link_up(type)\n text = type.is_a?(String) ? type : class_label(type)\n w.remote_link(text,\n {\n :javascript => :ipod_up,\n :navigation_type => type.is_a?(String) ? \"root\" : type.to_name_s('#'),\n :fallback => static_url_for(type)\n },\n { :class => \"ipodStyle\" } )\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
People that merged (not necessarily through pull requests) up to months_back from the time the built PR was created. if months_back is nil, don't take create time into consideration | def merger_team(pr, months_back = nil)
recently_merged = prs.find_all do |b|
close_reason[b[:github_id]] != :unknown and
(months_back.nil? ? true : b[:created_at].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600))
end.map do |b|
b[:github_id]
end
q = <<-QUERY
select... | [
"def merger_team(pr, months_back)\n @close_reason.map do |k,v|\n created_at = @prs.find{|x| x[:github_id] == k}\n [created_at[:created_at], v[2]]\n end.find_all do |x|\n x[0].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600)\n end.map do |x|\n x[1]\n end.select{|x| x != '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /insider_deals/1 GET /insider_deals/1.json | def show
@insider_deal = InsiderDeal.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @insider_deal }
end
end | [
"def index\n @deals = @business.deals \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deals }\n end\n end",
"def show_deal(id)\n get(\"deals/#{id}\")\n end",
"def deal(id, options={})\n get(\"/v2/deals/#{id}\", options)\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /insider_deals/new GET /insider_deals/new.json | def new
@insider_deal = InsiderDeal.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @insider_deal }
end
end | [
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meal }\n end\n end",
"def new\n @dental = Dental.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dental }\n end\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /insider_deals/1 DELETE /insider_deals/1.json | def destroy
@insider_deal = InsiderDeal.find(params[:id])
@insider_deal.destroy
respond_to do |format|
format.html { redirect_to insider_deals_url }
format.json { head :no_content }
end
end | [
"def delete_deals(**args)\n params = parameters(args) do\n required_params :ids\n optional_params :ids\n end\n request(:delete, 'deals', params)\n end",
"def destroy\n @deal = Deal.find(params[:id])\n @deal.destroy\n\n respond_to do |format|\n format.html ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
disable the callbacks that are used for workflow; this ensures that we control sgtate changes, etc better during ingest, and various other | def disable_workflow_callbacks
# disable the allocate DOI callback
LibraWork.skip_callback( :save, :after, :allocate_doi )
LibraWork.skip_callback( :update, :before, :update_doi )
# disable the email send callback
LibraWork.skip_callback( :save, :after, :determine_email_behavior )
end | [
"def disable_callback_methods\n StashEngine::Resource.skip_callback(:create, :after, :init_state_and_version)\n # StashEngine::Resource.skip_callback(:create, :after, :create_share)\n end",
"def replicate_disable_callbacks(instance)\n if ::ActiveRecord::VERSION::MAJOR >= 3\n # A... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
construct a default email address given a computing Id | def default_email( cid )
return "#{cid}@#{DEFAULT_DOMAIN}"
end | [
"def email_address\n require \"mail\"\n address = Mail::Address.new email\n address.display_name = name.dup\n address.format\n end",
"def generateEmailAddress()\n uuid = SecureRandom.hex(3)\n return \"%s.%s@mailosaur.in\" % [uuid, @MAILBOX]\n end",
"def generate_email\n formatted_name =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get a work by the specified ID | def get_work_by_id( work_id )
begin
return LibraWork.find( work_id )
rescue => e
end
return nil
end | [
"def get_work_by_id( work_id )\n\n begin\n return GenericWork.find( work_id )\n rescue => e\n end\n\n return nil\n end",
"def get_run(id)\n get_runs.each {|run| return run if run.id==id}\n end",
"def set_work\n work.first.id\n end",
"def get_task_by_id(id)\n require_r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
download a random cat image | def get_random_image( )
print "getting image... "
dest_file = "#{File::SEPARATOR}tmp#{File::SEPARATOR}#{SecureRandom.hex( 5 )}.jpg"
Net::HTTP.start( "lorempixel.com" ) do |http|
resp = http.get("/640/480/cats/")
open( dest_file, "wb" ) do |file|
file.write( resp.body )
end
en... | [
"def fetchImage\n url = \"https://dog.ceo/api/breeds/image/random\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n imgURL = JSON.parse(response)\n output = imgURL[\"message\"]\nend",
"def randomOctocat\n\t\tcURL($baseURL+\"?random\")\n\tend",
"def random_image(query = 'safe, cute', nsfw = false)\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get user information from an email address | def user_info_by_email( email )
id = User.cid_from_email( email )
return user_info_by_cid( id )
end | [
"def user_by_email(email)\n get(\"get_user_by_email&email=#{email}\")\n end",
"def get_user_email\n useremail[:value]\n end",
"def get_email(email)\n self.api_get(:email, {:email => email})\n end",
"def return_user_email(username, client)\n user_list = client.user_search(username:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get user information from a computing id | def user_info_by_cid( id )
print "Looking up user details for #{id}..."
# lookup the user by computing id
user_info = Helpers.lookup_user( id )
if user_info.nil?
puts "not found"
return nil
end
puts "done"
return user_info
end | [
"def user_info_by_cid( id )\n\n print \"Looking up user details for #{id}...\"\n\n # lookup the user by computing id\n user_info = Helpers::EtdHelper::lookup_user( id )\n if user_info.nil?\n puts \"not found\"\n return nil\n end\n\n puts \"done\"\n return user_info\n end",
"def fet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
lookup a user by computing id and create their account if we locate them | def lookup_and_create_account( id )
# lookup locally with the default email
user = User.find_by_email( User.email_from_cid( id ) )
return user if user.present?
# if we cannot find them, lookup in LDAP
user_info = user_info_by_cid( id )
return nil if user_info.nil?
# now look them up with ... | [
"def get_account_user user_id, role\n AccountUser.where( account_id: self.id, \n user_id: user_id\n )\n .first_or_create( account_id: self.id, \n user_id: user_id, \n role: role\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
batch process a group of SOLR works | def batched_process_solr_works( solr_works, &f )
solr_works.each do |gw_solr|
begin
gw = LibraWork.find( gw_solr['id'] )
f.call( gw )
rescue => e
puts e
end
end
end | [
"def batched_process_solr_works( solr_works, &f )\n\n solr_works.each do |gw_solr|\n begin\n gw = GenericWork.find( gw_solr['id'] )\n f.call( gw )\n rescue => e\n puts e\n end\n end\n\n end",
"def run_bulk; end",
"def perform\n Rails.logger.info \"<< Scanning for ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
show full details of a libra work | def show_libra_work( work )
return if work.nil?
j = JSON.parse( work.to_json )
j.keys.sort.each do |k|
val = j[ k ]
if k.end_with?( '_id' ) == false && k.end_with?( '_ids' ) == false
show_field( k, val, ' ' )
end
end
show_field( 'visibility', work.visibility, ' ' )
A... | [
"def workspace_info\n link_to_workspace_info(\"http://library.nyu.edu/info/myworkspace.html\", \"left\")\n end",
"def show_generic_work( work )\n\n return if work.nil?\n j = JSON.parse( work.to_json )\n j.keys.sort.each do |k|\n val = j[ k ]\n if k.end_with?( \"_id\" ) == false\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
show the contents of a person subfield | def show_person( title, person )
#puts "#{title} #{person}"
puts "#{title}"
show_field( 'ix', person.index, ' ' )
show_field( 'cid', person.computing_id, ' ' )
show_field( 'first_name', person.first_name, ' ' )
show_field( 'last_name', person.last_name, ' ' )
show_field( 'department... | [
"def field_content\n f = ''\n subfields.each do |sf|\n f += \"|#{sf.code}#{sf.value}\"\n end\n f\n end",
"def render_marc_subfields(field)\n content_tag(:div, class: 'subfields') do\n field.map { |sf| render_marc_subfield(sf) }.join(\"\\n\").html_safe\n end\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
show a field if it is not empty | def show_field( name, val, indent )
return if val.nil?
return if val.respond_to?( :empty? ) && val.empty?
puts "#{indent}#{name} => #{val}"
end | [
"def show_field( name, val )\n return if val.nil?\n return if val.respond_to?( :empty? ) && val.empty?\n puts \" #{name} => #{val}\"\n end",
"def field_check_display(item, field)\n return true if item.item_type.display_emtpy_fields\n\n if %w[Field::Geometry Field::File Field::Image Field::Embed].i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
upload the specified file to the specified work on behalf of the specified user | def upload_file( user, work, filename, title, visibility )
print "uploading #{filename}... "
fileset = ::FileSet.new
fileset.title << title unless title.nil?
file_actor = ::CurationConcerns::Actors::FileSetActor.new( fileset, user )
file_actor.create_metadata( work )
file_actor.create_content(... | [
"def upload_file( user, work, filename, title, visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC )\n\n print \"uploading #{filename} (#{title})... \"\n\n fileset = ::FileSet.new\n fileset.title << title unless title.nil?\n file_actor = ::CurationConcerns::Actors::FileSetActor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
load a file containing xml data and return an oga document | def load_xml_doc( filename )
File.open( filename, 'r') do |file|
return Oga.parse_xml( file )
end
puts "ERROR: loading #{filename}"
return nil
end | [
"def load_xml_doc( filename )\n File.open( filename, 'r') do |file|\n return Oga.parse_xml( file )\n end\n end",
"def load_xml file\n f = File.open file\n doc = Nokogiri::XML f\n f.close\n doc\n end",
"def get_xml_data\n begin\n file = File.open(@xml_file)\n @document = Nok... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /ab_teams/1 DELETE /ab_teams/1.json | def destroy
@ab_team.destroy
respond_to do |format|
format.html { redirect_to ab_teams_url, notice: 'Record was destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_team.destroy\n respond_to do |format|\n format.html { redirect_to api_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url(au... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Denies access for public users to private projects | def require_proj_access
if params[:gr]
@project ||= Group.find(params[:gr]).project
else
@project = Project.find(params[:id] || params[:pr])
end
if ((not is_logged?) || current_user.is_public?) && @project.is_private?
flash_msgs(1, "Access denied.")
redirect_to root_path
end
... | [
"def project_private! if_metageneration_match: nil\n update_predefined_acl! \"projectPrivate\", if_metageneration_match: if_metageneration_match\n end",
"def project_private! if_metageneration_match: nil\n update_predefined_default_acl! \"projectPrivate\", if_metageneration_match: i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /step_commands GET /step_commands.json | def index
@step_commands = StepCommand.all
end | [
"def get_a_page_of_cli_command_execution_history(args = {}) \n get(\"/commands.json/\", args)\nend",
"def steps\n steps = @request[\"steps\"]\n end",
"def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /step_commands POST /step_commands.json | def create
@step_command = StepCommand.new(step_command_params)
respond_to do |format|
if @step_command.save
format.html { redirect_to @step_command, notice: 'Step command was successfully created.' }
format.json { render :show, status: :created, location: @step_command }
else
... | [
"def create\n @step = Step.new(step_params)\n @step.save\n render json: @step\n end",
"def create\n @step = @tutorial.steps.new(params[:step])\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to [@tutorial, @step], notice: 'Step was successfully created.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /step_commands/1 PATCH/PUT /step_commands/1.json | def update
respond_to do |format|
if @step_command.update(step_command_params)
format.html { redirect_to @step_command, notice: 'Step command was successfully updated.' }
format.json { render :show, status: :ok, location: @step_command }
else
format.html { render :edit }
... | [
"def update\n scenario = Scenario.find(params[:id])\n scenario.update(scenario_params)\n scenario.steps = []\n json_response(step_builder(scenario), status: :updated)\n rescue => e\n render json: {error: e.message}, status: 422\n end",
"def update\n @step.update(step_params)\n render json: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /step_commands/1 DELETE /step_commands/1.json | def destroy
@step_command.destroy
respond_to do |format|
format.html { redirect_to step_commands_url, notice: 'Step command was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @step = RunStep.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Connect to the SmartView provider and obtain a session id. Two methods of connection are supported: 1. Userid and password 2. SSO token If only a single parameter is passed, the SSO method is assumed; if two parameters are passed, these are assumed to be userid and password. | def connect(user_or_sso, password = nil)
if @provider
raise AlreadyConnected, "Cannot change provider once connected" if @provider
end
# Obtain a session id
if password.nil?
# Connect via SSO token
@sso = user_or_sso
@logger.info "Connecti... | [
"def connect_session(vcenter_connection)\n if @cached_powercli_sessions.key?(vcenter_connection['server'])\n session_id = @cached_powercli_sessions[vcenter_connection['server']]\n else\n # our session is nil, so we need to conenct\n session_cmd = <<-EOF\n $session = Connect-V... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Close the connection to the current application cube. | def close_app
if @session_id && @app
@logger.info "Disconnecting from #{@app}.#{@cube}"
@req.Logout do |xml|
xml.sID @session_id
end
invoke
@app = nil
@cube = nil
@dimensions = nil
@default_pov = nil
... | [
"def close\n try{ @cube_view.close() }\n @cube_view = nil\n end",
"def close\n @ole_connection.Close\n end",
"def close\n inactive!\n close_connections\n end",
"def close!\n live_queries = @volt_app.channel_live_queries[@channel]\n\n if live_queries\n l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve a list of dimensions for the current connection. | def get_dimensions
check_attached
@logger.info "Retrieving list of dimensions"
@req.EnumDims do |xml|
xml.sID @session_id
xml.alsTbl @preferences.alias_table
end
@dimensions = []
invoke.search('//res_EnumDims/dimList/dim').each do |dim|
... | [
"def dimensions() Dimension.find(dimension_ids) end",
"def dimensions(node_id)\n database.getlist(\"#{prefix}#{node_id}:dimensions\") || []\n end",
"def list_dimensions\n puts 'STUB: list_dimensions in importer.rb'\n end",
"def dimension_names\n unless @dimensions\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of available member filters for the specified dimension. A filter can be used to restrict a member query to a certain subset of members, such as the members in a member list. | def get_filters(dimension, force = false)
check_attached
if @fiters && @filters[dimension] && !force
@logger.debug "Retrieving filters for #{dimension} from cache"
filters = @filters[dimension]
else
@logger.info "Retrieving list of available member filters fo... | [
"def get_members(dimension, filter_spec = nil, all_gens = true)\n check_attached\n\n @logger.info \"Retrieving list of members for #{dimension}\"\n filter_name, filter_args = process_filter(dimension, filter_spec)\n @req.EnumMembers do |xml|\n xml.sID @session_id\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves a list of members for the specified dimension, optionally satisfying a filter. | def get_members(dimension, filter_spec = nil, all_gens = true)
check_attached
@logger.info "Retrieving list of members for #{dimension}"
filter_name, filter_args = process_filter(dimension, filter_spec)
@req.EnumMembers do |xml|
xml.sID @session_id
xml.dim dimens... | [
"def members(filters={})\n members = Barton::Models::Member.find filters\n results = []\n if members.respond_to? :each\n members.each do |elec|\n results.push elec\n end\n else\n results.push members\n end\n results.compact\n end",
"def find_member(di... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Search for the specified member name or pattern in a dimension. Returns an array of arrays, each inner array representing a path to a matching member. | def find_member(dimension, pattern, filter_spec = nil)
check_attached
@logger.info "Finding members of #{dimension} matching '#{pattern}'"
filter_name, filter_args = process_filter(dimension, filter_spec)
@req.FindMember do |xml|
xml.sID @session_id
xml.dim dimen... | [
"def children_lookup(cube_unique_name, member = nil, recursive = false)\n return dimensions cube_unique_name if member.nil?\n\n if member.split(\".\").length == 1\n cube(cube_unique_name).get_dimensions.reject { |dimension| dimension.get_unique_name != member }.first.get_hierarchies.map { |hierarch... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the current POV | def pov=(new_pov)
new_pov
@pov = pov.merge(new_pov)
end | [
"def current_waypoint= _wp\n @current_waypoint = _wp\n SQF.setCurrentWaypoint @this, _wp\n end",
"def viewpoint=(value)\n @viewpoint = value\n end",
"def data=(pokemon)\n self.sy = pokemon.status if (self.visible = (pokemon ? true : false))\n end",
"def cvv=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the default POV | def default_pov
# Make sure we are connected
check_attached
@logger.info "Retrieving default POV"
@req.GetDefaultPOV do |xml|
xml.sID @session_id
xml.getAtts '0'
xml.alsTbl @preferences.alias_table
end
doc = invoke
dims = doc.a... | [
"def default\n _default_id = ENV['MB_DEFAULT_PROVISIONER'] || self.default_id\n get!(_default_id) if _default_id\n end",
"def default_variant\n return nil if self.parent\n @default_variant ||= self.variants.select { |v| v.default? }.first\n end",
"def default_value\n property_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets a default grid with the specified POV | def default_grid
# Make sure we are attached to a cube
check_attached
@logger.info "Retrieving default grid"
@req.GetDefaultGrid do |xml|
xml.sID @session_id
@preferences.inject_xml xml, @provider_type
xml.backgroundpov do |xml|
pov.ea... | [
"def default_grid\n\t\t\t\tguesses_and_hints_grid + solution_grid\n\t\t\tend",
"def default_grid\n Array.new(3) { Array.new(3) { BoardCase.new } }\n end",
"def default_grid\n Array.new(3) { Array.new(3) { Cell.new } }\n end",
"def default_grid\n Array.new(9) { Array.new(9) { Cell.new } ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Refresh a grid from the current provider | def refresh(grid)
# Make sure we are attached to a cube
check_attached
@logger.info "Refreshing grid"
@req.Refresh do |xml|
xml.sID @session_id
@preferences.inject_xml xml, @provider_type
grid.to_xml(xml)
end
doc = invoke
Grid.... | [
"def reload_grid\n render :text => grid_reload\n end",
"def refresh\n do_refresh\n end",
"def reload_generic_grid\n conn = User.connection\n @recordset = conn.select_all(Globals.cleanup_where(dm_session[:final_statement]))\n @stat = dm_sessi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a grid for the spcified rows and columns and optional POV The rows must be a hash whose key is a single dimension name, or array of dimension names. The value of the hash must be an array containing tuples of member names for the dimension(s) in the rows. The cols must be a hash whose key is a single dimension n... | def free_form_grid(rows, cols, grid_pov=nil)
# Make sure we are attached to a cube
check_attached
get_dimensions unless @dimensions
# Update the POV if one is specified
if grid_pov
self.pov = grid_pov
end
grid = Grid.define(@dimensions, pov, rows, co... | [
"def prepare_grid\n Array.new(rows) do |row|\n Array.new(columns) do |column|\n Cell.new(row: row, column: column)\n end\n end\n end",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks to see that a session has been established, raising a NotConnected exception if one has not. | def check_connected
raise NotConnected unless @session_id && @sso && @provider
end | [
"def session_check!\n raise CAError.new(\"You are not connected to the server.\") if !connected?\n end",
"def assert_connected\n raise ConnectionError, 'not connected' unless @connected\n end",
"def check\n begin\n unless @client.connected?\n self.logging \"[#{Time.now}]Discon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks that a cube is open, raising a NotAttached exception if one is not. | def check_attached
check_connected
raise NotAttached unless @app && @cube
end | [
"def attached?\n\t\tCommon.device_status(@handle);\n end",
"def attached?\n not send(self.class.container_name).nil?\n end",
"def check()\n # check if teh volume still exists\n begin\n volumes = $ec2.describe_volumes([self.id])\n rescue RightAws::AwsError\n if $!.errors[0][0] == \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sends the current request XML to the SmartView provider, and parses the response with hpricot. If an exception was returned, an SmartViewException is raised with the details of the error. | def invoke
resp = nil
ms = Benchmark.realtime do
resp = @http.post @url, @req.to_s
end
@logger.info 'SmartView request %s completed in %.1fs' % [@req.method, ms]
doc = Hpricot::XML(resp.body.content)
if !doc.at("//res_#{@req.method}")
@logger.error... | [
"def send_request( xml )\n write( xml )\n read\n end",
"def send_request\n @request = to_xml\n @response = post_webex_request(security_context.site_name, @request)\n check_response_and_return_data(@response)\n end",
"def send_raw(xml)\n open\n @soap_client.Proces... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Insert filter arguments to a request | def insert_filter_args(xml, filter_args)
if filter_args
filter_args.each_with_index do |filter_arg, i|
xml.arg({'id' => "#{i}"}, filter_arg)
end
end
end | [
"def add_to_filter_parameters; end",
"def add_to_filter_parameters=(_arg0); end",
"def add_filtered_parameters\n append_to_file('config/initializers/filter_parameter_logging.rb', 'Rails.application.config.filter_parameters += %i[email ip]')\n end",
"def excluded_from_filter_parameters=(_arg0); end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
store the countries information and create region list | def store_countries
Countries::Data.get_data
@regions = Countries::Country.create_region_list
end | [
"def countries_and_regions=(value)\n @countries_and_regions = value\n end",
"def add_to_region\r\n western_states = [\"Arizona\", \"Colorado\", \"Idaho\", \"Montana\", \"Nevada\", \"New Mexico\", \"Utah\", \"Wyoming\", \"Alaska\", \"California\", \"Hawaii\", \"Oregon\", \"Washingt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the country list of given region | def country_list_by_region(region)
# select list of countries based on the region
@countries = Countries::Country.find_by_region(region)
# print the list of countries as table format
Table.display_as_table(@countries)
end | [
"def country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end",
"def regions\n\t\tignore_nil { country.regions }\n\tend",
"def country_list\n return [] if kind == \"state\"\n return members.collect { |zon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
country details based on region and country | def country_details(region, input)
country = @countries[input - 1]
Table.display_as_summary(country)
browse_online(country)
end | [
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def represented_country; end",
"def registered_country; end",
"def region_of_country(country_code = 'JP')\n result = @regions['asia'].to_s\n @regions.each do |region, countries|\n countries.each do |country|\n return res... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert a cart into an order go through and check each cart entry, if in stock and valid then convert to an order entry. If the order is valid after the creation of the entry then ammend stock levels. Once all valid entries are generated save the whole thing and clear the shopping cart | def create
candidateOrder = Order.new(email: params[:order][:Email],
totalCost: cart_total,
user: curr_user)
cart.each do |pId, info|
if (prod = Product.find_by(id: pId))
if prod.stockCount > info["Num"].to_i
candidateOrder.order_entries.new(
... | [
"def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_acces... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Empty the user's shopping cart | def clear_cart
update_cart({})
end | [
"def clear_carts\n current_user.carts.each_with_index do |cart, i|\n cart.delete if i != current_user.carts.length - 1\n end\n end",
"def empty_to_buy\n self.cart_items.delete(self.items_to_buy)\n end",
"def empty!\n self.cart_items.each { |ci| ci.destroy }\n end",
"def clear\n Cart... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns first of the given paths that exists, or the last one if none exists | def first_existing(*paths)
last_path = nil
paths.each do |path|
last_path = path
break if @io.exist?(path)
end
last_path
end | [
"def find_first(*paths)\n xpath(*paths).first\n end",
"def path_find_first(path)\n node = @root\n return node.value unless node.value.nil?\n path.each { |path_item|\n node = node.get_child(path_item)\n return nil unless node\n return node.value unless node.value.nil?\n }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
matt's sweet code def clamp_to_edgeeee(node, x, y base=BASE) originX = node % base originY = node / base if originX + x > base node = originX + x base end if originY + y > base node = base (originY + y base) end return node end | def clamp_to_edge(node, x, y, base=BASE)
while base - (node % base) < x
node -= 1
end
while (node + (base*(y-1))) >= (base*base)
node -= base
end
return node
end | [
"def fineTuneEdge(start_x, start_y, inc_x, inc_y, edge, inc_edge, min, max)\n x, y = self.send(start_x), self.send(start_y)\n while (x <= @right) and (y <= @bottom) and (self.send(edge) > min) and (self.send(edge) < max)\n top_x, top_y = (inc_x != 0) ? [x, y+inc_edge] : [x+inc_edge, y]\n idx... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: serves as the getter and setter for the Array of Symbol column names. Union join the existing column names with those passed Example: ``` header.columns :name, :age, :location ``` `args` Array of Symbol arguments passed Returns as Array of Symbols | def columns(*args)
@columns = @columns | args.map(&:to_sym)
end | [
"def named_columns( names )\n @columns.values_at( *names )\n end",
"def multiple_columns(*args)\n @records.inject([]){ |memo, record|\n memo << args.map{ |arg| record.send(arg) }\n memo\n }\n end",
"def column_names\n columns.map(&:name)\n end",
"def columns(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: converts columns and mappings into mapped columns ready for encoding. If a mapped value is found that is used, else the Symbol column name is humanized by default or can be specified with header_inflector option Returns an Array of Strings | def mapped_columns
@columns.map do |column|
@mappings[column] || column.to_s.send(@inflector)
end
end | [
"def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.humanize\n end\n end",
"def symbol cols\n decode_values :symbol, cols\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tipo_convenios/1 GET /tipo_convenios/1.json | def show
@tipo_convenio = TipoConvenio.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @tipo_convenio }
end
end | [
"def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end",
"def show\n @conversazione = Conversazione.find(params[:id])\n\n respond_to do |format|\n format.html # sh... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tipo_convenios/new GET /tipo_convenios/new.json | def new
@tipo_convenio = TipoConvenio.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tipo_convenio }
end
end | [
"def new\n @tipo_seguro = TipoSeguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_seguro }\n end\n end",
"def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tipo_convenios/1 DELETE /tipo_convenios/1.json | def destroy
@tipo_convenio = TipoConvenio.find(params[:id])
@tipo_convenio.destroy
respond_to do |format|
format.html { redirect_to tipo_convenios_url }
format.json { head :no_content }
end
end | [
"def destroy\n @tipo_concurso.destroy\n respond_to do |format|\n format.html { redirect_to tipo_de_concursos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /faxes/1 PATCH/PUT /faxes/1.json | def update
respond_to do |format|
if @fax.update(fax_params)
format.html { redirect_to @fax, notice: 'Fax was successfully updated.' }
format.json { render :show, status: :ok, location: @fax }
else
format.html { render :edit }
format.json { render json: @fax.errors, statu... | [
"def update\n @faxis = Fax.find(params[:id])\n\n respond_to do |format|\n if @faxis.update_attributes(params[:faxis])\n format.html { redirect_to @faxis, notice: 'Fax was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /faxes/1 DELETE /faxes/1.json | def destroy
@fax.destroy
respond_to do |format|
format.html { redirect_to faxes_url, notice: 'Fax was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @faxis = Fax.find(params[:id])\n @faxis.destroy\n\n respond_to do |format|\n format.html { redirect_to faxes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @axis.destroy\n respond_to do |format|\n format.html { redirect_to axes_url, notice: '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /descuento_adicionals GET /descuento_adicionals.json | def index
@descuento_adicionals = DescuentoAdicional.all
end | [
"def index\n @adicionals = Adicional.all\n end",
"def index\n @recurso_adicionals = RecursoAdicional.all\n end",
"def index\n @item_adicionals = ItemAdicional.all\n end",
"def index\n @descuentos ||= Descuento.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /descuento_adicionals POST /descuento_adicionals.json | def create
@descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)
respond_to do |format|
if @descuento_adicional.save
format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' }
format.json { render :show, status: :created, l... | [
"def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /descuento_adicionals/1 PATCH/PUT /descuento_adicionals/1.json | def update
respond_to do |format|
if @descuento_adicional.update(descuento_adicional_params)
format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }
format.json { render :show, status: :ok, location: @descuento_adicional }
else
... | [
"def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /descuento_adicionals/1 DELETE /descuento_adicionals/1.json | def destroy
@descuento_adicional.destroy
respond_to do |format|
format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }
format.json { head :no_content }
end
end | [
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recurso_adicional.destroy\n respond_to d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a pipeline on AWS Elastic Transcoder | def create_pipeline name, input_bucket, output_bucket, role
begin
@elastictranscoder.create_pipeline(
name: name,
input_bucket: input_bucket,
output_bucket: output_bucket,
role: role
)
rescue
#Raise informative exception
end
end | [
"def create_pipeline_object(actions:, environment:, resources:, timeout: nil)\n Google::Apis::GenomicsV2alpha1::Pipeline.new(\n actions: actions,\n environment: environment,\n resources: resources,\n timeout: timeout\n )\n end",
"def pipeline(name)\n return PipelineT.new(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deletes a pipeline on AWS Elastic Transcoder given an id | def delete_pipeline id
begin
@elastictranscoder.delete_pipeline(id: id)
rescue
#Raise informative exception
end
end | [
"def delete_pipeline(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:delete, \"pipelines/#{id}\", params)\n end",
"def delete_pipeline(id)\n delete(\"dealGroups/#{id}\")\n end",
"def delete(pipeline_id)\n @client.pipeline.delete(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tells if a free trial is defined in the price group | def has_free_trial?
return (trial and trial.free?)
end | [
"def has_free_trial_lesson?\n return self.prices.where( Price.arel_table[:type].eq('Price::Trial').and(\n (Price.arel_table[:amount].eq(nil).or(Price.arel_table[:amount].eq(0)))) ).any?\n end",
"def free?\n if prices.blank?\n !word_document.paid?\n else\n current_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sieve of eratosthenes page 16 for each i, a[i] true if prime for each i, setting array element corresponding to each multiple of i to false then loop through again, printing them out | def primes
arr=Array.new
arr[1]=false
(2..1000).each {|i| arr[i]=true}
(2..1000).each {|i| (i/2).floor
(2..1000).each {|j| (j/i).floor
arr[i*j] = false
}}
for i in 1..1000
if arr[i] == true
puts i
end
end
end | [
"def revised_sieve(limit)\r\n\t# Create boolean array from 0 to limit\r\n\tcrosslimit = Math.sqrt(limit)\r\n\tsieve = Array.new(limit,false)\r\n\tstart = Time.now\r\n\r\n\t# Set all even numbers to true (not prime)\r\n\t(4..limit).step(2).each do |n|\r\n\t\tsieve[n] = true\r\n\tend\r\n\r\n\t# Iterate from 3 to squa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
3.1 fill in 2d array of bools by setting a[i,j] to true if gcd i,j is 1 and false otherwise uses ruby's built in gcd function | def twoDArray(m,n)
arr = Hash.new
for m in 0..m
for n in 0..n
if m.gcd(n) == 1
arr[[m,n]] = true
else
arr[[m,n]] = false
end
end
end
for m in 0..m
for n in 0..n
if arr[[m,n]] == true
puts "#{m} :m and #{n} :n"
end
end
end
end | [
"def coprime?(i,j)\n\tmygcd(i,j) == 1\nend",
"def solve_array(array)\n check_array = Array.new(9){Array.new(9){Array.new(9){0}}}\n # p array\n for i in 0..8\n for j in 0..8\n if array[i][j] == 0\n p \"for each variable\\n\\n\\n\\n\\n\\n\\n\\n #{i}, #{j}\"\n p \"before_modify... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
3.4 solve the josephus problem with an array N people have decided to commit mass suicide by arranging themselves in a circle and killing the mth person around the circle, closing ranks as each person drops out of the circle. find out the order in which the people die | def josephus(n,m)
arr = Array.new
order = Array.new
for i in 1..n
arr[i] = i
end
arr.compact!
for i in 0..n-1
arr= arr.rotate(m-1)
order << arr[0]
arr[0] = nil
arr.compact!
end
puts "order: #{order.to_s}"
end | [
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def judge(n, trusts)\n puts \"Trusts: #{trusts}\"\n judge = -1\n\n #Build Unique Towns People \n unique_townspeople = []\n n.times do |i|\n unique_townspeople.pus... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
load the lines from the file, remove comments, blank lines, whitespace, set the ivar | def load_lines file
lines = Array.new
lines = @file.split("\n")
#fuck that, i dont like the dyanmic feed, just pre-parse it
lines.map! do |line| #map overwrites the old array
if line.include? '#'
split = line.split '#'
#puts split.to_s
split.shift
else
line
end
end
#removing blan... | [
"def refresh!\n @lines = load_from_file\n end",
"def to_set\n @lines ||= load_from_file\n end",
"def populate_from_file(dec_line, infile)\n comment_count = blank_count = 0\n done = false\n \n if /^\\s*(\\w+\\s+)?object\\s+(\\w+)(:(\\d*))?\\s+{/.match(dec_line) && !$2.nil?\n @cla... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
primary access control point: returns all tenant permissions for user currently not used as user will only have one tenant with current implementation | def current_tenant_permissions
if current_or_guest_user
current_or_guest_user.tenant_ids
else
nil
end
end | [
"def primary_tenant_permission\n if current_or_guest_user\n current_or_guest_user.tenant_ids.first\n else\n nil\n end\n end",
"def permission_grants\n return @permission_grants\n end",
"def get_active_permissions\n set_access_token\n if @access_token && !@perm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns primary (base) tenant permission for user | def primary_tenant_permission
if current_or_guest_user
current_or_guest_user.tenant_ids.first
else
nil
end
end | [
"def current_tenant_permissions\n if current_or_guest_user\n current_or_guest_user.tenant_ids\n else\n nil\n end\n end",
"def tenant\n #OPTIMIZE Add a tenant_id to SipAccount\n case self.phone_numberable\n when SipAccount\n self.phone_numberable.tenant\n when Conference\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Parses the given stream and returns a node tree | def load(stream, root_class = nil)
root_class ||= PrisonParser::Node
line_num = 0
nodes = []
@tokens = []
current_node = root_class.new
while !stream.eof? do
line = stream.readline.strip
line_num += 1
tokenize(line)
next if tokens... | [
"def parse(stream, encoding=nil)\n _parse(stream, false, encoding)\n @tree.get_document\n end",
"def parse(stream, encoding=nil)\r\n _parse(stream, false, encoding)\r\n return @tree.getDocument\r\n end",
"def parse!(stream,options={})\n\t\tparse(stream,options.merge(debug: true))\n\ten... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all entity type identifiers related to a given type identifier | def get_entity_types_related_to(type_identifier)
Occi::Log.debug("Getting entity type identifiers related to #{type_identifier}")
collection = @model.get type_identifier
collection.kinds.collect { |kind| kind.type_identifier }
end | [
"def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end",
"def types_by_entity_id\n @types_by_entity_id\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available entity types. | def get_entity_types
Occi::Log.debug("Getting entity types ...")
@model.kinds.collect { |kind| kind.term }
end | [
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def entity_types\n self.class.entity_types.flatten.flatten.compact\n end",
"def types_by_entity_id\n @t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available entity type identifiers. | def get_entity_type_identifiers
get_entity_types_related_to Occi::Core::Entity.kind.type_identifier
end | [
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available resource types. | def get_resource_types
Occi::Log.debug("Getting resource types ...")
collection = @model.get Occi::Core::Resource.kind
collection.kinds.collect { |kind| kind.term }
end | [
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def list_resource_types(feed = nil)\n if feed.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape feed\n ret = http_get('/feeds/' + the_feed + '/resourceTypes')\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available resource type identifiers. | def get_resource_type_identifiers
get_entity_types_related_to Occi::Core::Resource.kind.type_identifier
end | [
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n coll... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available link types. | def get_link_types
Occi::Log.debug("Getting link types ...")
collection = @model.get Occi::Core::Link.kind
collection.kinds.collect { |kind| kind.term }
end | [
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end",
"def index\n @code_link_types = CodeLinkType.all\n end",
"def index\n @link_types = LinkType.all\n\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves all available link type identifiers. | def get_link_type_identifiers
get_entity_types_related_to Occi::Core::Link.kind.type_identifier
end | [
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_types\n Occi::Log.debug(\"Getting link types ...\")\n collection = @model.get Occi::Core::Link.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def index\n @code_link_types ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Looks up a mixin using its name and, optionally, a type as well. Will return mixin's full location (a link) or a description. | def find_mixin(name, type = nil, describe = false)
Occi::Log.debug("Looking for mixin #{name} + #{type} + #{describe}")
# is type valid?
if type
raise "Unknown mixin type! [#{type}]" unless @mixins.has_key? type.to_sym
end
# TODO: extend this code to supp... | [
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves available mixins of a specified type or all available mixins if the type wasn't specified. Mixins are returned in the form of mixin identifiers. | def get_mixins(type = nil)
if type
# is type valid?
raise "Unknown mixin type! #{type}" unless @mixins.has_key? type.to_sym
# return mixin of the selected type
@mixins[type.to_sym]
else
# we did not get a type, return all mixins
... | [
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n get_mixi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves available mixin types. Mixin types are presented in a shortened format (i.e. not as type identifiers). | def get_mixin_types
@mixins.keys.map { |k| k.to_s }
end | [
"def get_mixin_types\n get_mixins.to_a.collect { |m| m.term }\n end",
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves available mixin type identifiers. | def get_mixin_type_identifiers
identifiers = []
get_mixin_types.each do |mixin_type|
identifiers << 'http://schemas.ogf.org/occi/infrastructure#' + mixin_type
end
identifiers
end | [
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def get_mixin_types\n @mixins.keys.map { |k| k.to_s }\n end",
"def get_mixin_types\n get_mixins.to_a.collect { |m| m.term }\n end",
"def get_mixins_ary(mixin_type)\n mixins = []\n\n send(\"get... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves descriptions for available resources specified by a type identifier or resource location. If no type identifier or location is specified, all available resources in all available resource types will be described. | def describe(resource_type_identifier=nil)
# convert type to type identifier
resource_type_identifier = @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.first.type_identifier if @model.kinds.select {
|kind| kind.term == resource_type_identifier
... | [
"def describe(resource_type_identifier=nil); end",
"def find_all_resources(resource_descr, resource_type, authorizer)\n debug \"find_resources: descr: '#{resource_descr.inspect}'\"\n if resource_descr.kind_of? Hash\n can_handle = eval(\"OMF::SFA::Model::#{resource_type.classify}\").respond_to? :h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Deploys a compute resource based on an OVF/OVA descriptor available on a local file system. | def deploy(location)
media_types = self.class.head(@endpoint).headers['accept'].to_s
raise "File #{location} does not exist" unless File.exist? location
file = File.read(location)
if location.include? '.ovf'
if media_types.include? 'application/ovf'
he... | [
"def deploy_ovf(descriptor); end",
"def deploy_ova(descriptor); end",
"def add_file(filename)\n cookbook_file '/var/opt/dynatrace-managed/sources/' + filename do\n source '' + filename\n owner node['dynatrace-quickstart-gcp']['user']\n group node['dynatrace-quickstart-gcp']['user']\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.