query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
projects: kickstarter.css("li.project.grid_4").first gives the title of the project project.css("h2.bbcard_name strong a").text gives the project MOBY DICK thumbnail link project.css("div.projectthumbnail a img").attribute("src").value description project.css("p.bbcard_blurb").text locationname project.css("span.locati... | def create_project_hash
html=File.read('fixtures/kickstarter.html')
kickstarter = Nokogiri::HTML(html)
projects={}
#iterate through the projects
kickstarter.css("li.project.grid_4").each do |project|
title=project.css("h2.bbcard_name strong a").text
projects[title.to_sym]={
:image_l... | [
"def project_name(pid)\n Nokogiri::HTML(pivotal_tracker(project_url(pid)).content).css('project > name').text.split(' ').join\nend",
"def create_project_hash # can be called on with no errors /returns a hash /includes at least five projects\n html = File.read('fixtures/kickstarter.html')\n kickstarter = Nok... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validates the size of an uploaded picture. | def picture_size
if picture.size > 5.megabytes
errors.add(:picture, "should be less than 5MB")
end
end | [
"def picture_size\n errors.add(:image, 'should be less than 1MB') if image.size > 1.megabytes\n end",
"def picture_size\n if picture.size > 5.megabytes\n errors.add(:picture, \"should be less than 5MB\")\n end\n end",
"def picture_size\n return unless picture.size > 5.megabytes\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ingest a dictionary of words separated by lines and add the valid ones (based on length) to an array | def load_dict
words = []
File.open("dict.txt").each do |line| # Hard code for now
if line.length.between?(5, 12)
words << line.rstrip.downcase
end
end
words
end | [
"def prepare_dictionary(dictionary, length)\n result = IO.readlines(dictionary).map(&:chop)\n result.delete_if { |word| word.length > length }\n result.sort_by!(&:length).reverse!\n end",
"def create_dictionary\n all_words = word_list.collect { |word| word.strip.downcase } \n all_words.each do |wo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate that the guess is a single alpha character that has not yet been guessed | def valid_guess?(letter_guess)
(letter_guess.length == 1 && !letter_guess.match(/[^A-Za-z]/) && !@guesses.include?(letter_guess)) ? true : false
end | [
"def valid_letter?\n if (@guess =~ /[A-Z]/) == 0 && !(@guessed_letters.include? @guess)\n @valid = true\n else\n print \"That's not a valid letter or you've already guessed this one. \"\n @valid = false\n end\n end",
"def letter?(guess)\n return guess[/[a-zA-Z]+/] == guess\nend",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Private: Automatically set the STI type based on the imap_provider. | def fix_type
self.type ||= self.partner_connection.imap_provider.class_for(User).to_s
end | [
"def fix_type\n self.type ||= self.imap_provider.class_for(PartnerConnection).to_s\n end",
"def identity_provider_type=(value)\n @identity_provider_type = value\n end",
"def set_type\n new_type = [sport.name, \"Infrastructure\"].join('')\n\n begin\n new_type.constantize\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the successor to the ipaddr. | def succ
return self.clone.set(@addr + 1, @family)
end | [
"def next_ip\n\t\treturn false if not valid?\n\t\tif (@curr_addr > @ranges[@curr_range][1])\n\t\t\tif (@curr_range >= @ranges.length - 1)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\t@curr_range += 1\n\t\t\t@curr_addr = @ranges[@curr_range][0]\n\t\tend\n\t\taddr = Rex::Socket.addr_itoa(@curr_addr, @ranges[@curr_range][2])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Author: Mohamed Ashraf Description: retrieved approved synonyms for a keyword through the project parameters and optional overides Parameters: word: a string representing the keyword for which the synonyms will be retrieved country: [optional] filter by country name age_from: [optional] filter by age lower limit age_to... | def get_synonym_for(word, country = nil, age_from = nil, age_to = nil,
gender = nil, education = nil)
keyword = Keyword.find_by_name(word)
if keyword.blank?
Keyword.add_keyword_to_database(word)
return nil
end
if self.project.present?
prefered_synonym = PreferedSynonym
... | [
"def get_synonyms\n keywords = params[:keywords]\n overrides = params[:overrides]\n\n if keywords.blank?\n head :bad_request\n return\n end\n\n country = request.location.country\n\n if overrides.present?\n country = overrides[:country]\n age_from = overrides[:age_from]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Author: Mohamed Ashraf Description: downcase the website before storing Params: Success: the website gets downcased Failure: | def downcase_website
self.website.downcase! if self.website.present?
end | [
"def downcase_title_url\n self.title_url = title_url.downcase\n end",
"def cleanup_urls\n self.url = self.url.to_s.downcase\n end",
"def upcase() end",
"def upcase!() end",
"def proofread(s)\n s.downcase.gsub(\"ie\",\"ei\").capitalize.gsub(/\\. ([a-z])/, &:upcase)\nend",
"def downcase!() end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
update of edit panel after changing the type | def update_type
fname= "#{self.class.name}.#{__method__}"
LOG.debug(fname){"params=#{params.inspect}"}
@object_plm = Customer.find(params[:id])
ctrl_update_type @object_plm, params[:object_type]
end | [
"def edit\n \t@type=Type.find(params[:id])\n end",
"def update\n \t@type=Type.find(params[:id])\n\n \tif @type.update(type_params)\n redirect_to types_path\n else\n render 'edit'\n end\n end",
"def edit\n @field_type = get_field_type\n @data_types = FieldType.data_types_list.map {|k, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test_edit Description: This method does the functional testing of the edit method from the FabHouse class Parameters: None Return value: None | def test_edit
merix = fab_houses(:merix)
get(:edit, {:id => merix.id}, cathy_admin_session)
assert_equal(merix.name, assigns(:fab_house).name)
end | [
"def test_edit\n \n admin_session = cathy_admin_session\n \n # Try editing from an Admin account\n get(:edit, {:id => divisions(:std).id}, admin_session)\n assert_response 200\n assert_equal(divisions(:std).name, assigns(:division).name)\n\n assert_raise(ActiveRecord::RecordNotFound) { post(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test_update Description: This method does the functional testing of the update method from the FabHouse Controller class Parameters: None Return value: None | def test_update
admin_session = cathy_admin_session
ibm = fab_houses(:ibm)
fab_house = FabHouse.find(ibm.id)
fab_house.name = 'new_fab_house'
post(:update, { :fab_house => fab_house.attributes }, admin_session)
assert_redirected_to(:action => 'edit', :id => fab_house.id)
assert_e... | [
"def test_update\n\n design_center = DesignCenter.find(design_centers(:fridley).id)\n design_center.name = 'San Jose'\n design_center.pcb_path = '/hwnet/board_sj'\n design_center.hw_path = '/hwnet/hw_sj'\n\n put(:update, { :design_center => design_center.attributes }, cathy_admin_sessio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test_create Description: This method does the functional testing of the create method from the FabHouse Controller class Parameters: None Return value: None | def test_create
fab_house_count = FabHouse.count
new_fab_house = { 'active' => '1', 'name' => 'FabsRus' }
admin_session = cathy_admin_session
post(:create, { :new_fab_house => new_fab_house }, admin_session)
fab_house_count += 1
assert_equal(fab_house_count, FabHouse.count)
assert... | [
"def test_create\n\n design_center_count = DesignCenter.count\n assert_equal(design_center_count, DesignCenter.count)\n\n new_design_center = { 'active' => '1',\n 'name' => 'Pembroke',\n 'pcb_path' => '/hwnet/board_pem',\n 'hw... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /shareportfolios GET /shareportfolios.json | def index
@shareportfolios = Shareportfolio.all
end | [
"def portfolios options = {}\n perform_get(\"/me/portfolios\", options)\n end",
"def index\n # TODO: ideally instead of eager loading sells, we could just include\n # quantity_sold in the eager_lod for lots.\n @portfolios = Portfolio.eager_graph(lots: :sells).eager_graph(allocations: {:asset_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /shareportfolios POST /shareportfolios.json | def create
@shareportfolio = Shareportfolio.new(shareportfolio_params)
respond_to do |format|
if @shareportfolio.save
format.html { redirect_to @shareportfolio, notice: 'Shareportfolio was successfully created.' }
format.json { render :show, status: :created, location: @shareportfolio }
... | [
"def index\n @shareportfolios = Shareportfolio.all\n end",
"def create\n if current_user\n @portfolio = current_user.portfolios.create(portfolio_params)\n render json: @portfolio\n else\n render json: []\n end\n end",
"def create\n @portfolio = current_user.portfolios.new(params[... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /shareportfolios/1 PATCH/PUT /shareportfolios/1.json | def update
respond_to do |format|
if @shareportfolio.update(shareportfolio_params)
format.html { redirect_to @shareportfolio, notice: 'Shareportfolio was successfully updated.' }
format.json { render :show, status: :ok, location: @shareportfolio }
else
format.html { render :edit ... | [
"def update\n if current_user\n @portfolio = current_user.portfolios.find(params[:id])\n @portfolio.update_attributes(portfolio_params)\n render json: @portfolio\n end\n end",
"def update\n respond_to do |format|\n if @portfolio.update(portfolio_params)\n format.html { redirec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /shareportfolios/1 DELETE /shareportfolios/1.json | def destroy
@shareportfolio.destroy
respond_to do |format|
format.html { redirect_to shareportfolios_url, notice: 'Shareportfolio was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @portfolio.destroy\n respond_to do |format|\n format.html { redirect_to portfolios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dev_folio = DevFolio.find(params[:id])\n @dev_folio.destroy\n\n respond_to do |format|\n format.html { redirect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=begin Supported features by name implemented on iOS (v 1.9 and up) positional effect on the user layer (transforms rotation, position, scale + tweening) gray scale effect on the user layer dynamic mask effect on the user layer planned on future versions: color tint effect on user layer alpha channel effect on user lay... | def supported_features_filter_for_client(client_name, client_version)
# by default, will return only packages that have no "required version" set.
version_string = formatted_version_string(client_version)
if (client_name != "Emu iOS" and client_name !="Emu Android") or version_string == nil
filter = {
"required... | [
"def features(version)\n feature_setup.include?(version) ? feature_names : []\n end",
"def relevant_packages\n packages.select { |p| p['version'] == version }\n end",
"def client_version_above?(v, options={})\n ((client_version <=> v) >= 0) || (client_version.empty? && options[:un... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
read sparse matrix data in csv format and save it as a R serialized object | def serializeDataSMX(ifile,cfile,oPath,doZ,key,var,val,yVar,exposure,verbose,existingVar2vno)
wf=MCMD::Mtemp.new(DebugPath)
xxrow =wf.file
xxcol =wf.file
xxval =wf.file
xxy =wf.file if cfile
xxexposure=wf.file if exposure
# preprocessing for x and y variables
rowSize,colSize=smatrix(ifile,key... | [
"def read_sparse_matrix(str)\n sparse = str.split(SEP_LINE).map do |line|\n row , col , value = line.split(SEP_ITEM)\n [row.to_i , col.to_i , value.to_f]\n end\n sparse_to_full(sparse)\n end",
"def to_sparse!(matrix)\n @row = matrix.row_size\n @col = matrix.column_size\n @elements = H... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
expects config var HOST to be set on Heroku to 'HEROKU' | def heroku?
host == 'HEROKU'
end | [
"def we_are_on_production\n \tENV['URL_HOST'] == 'https://justpassiton.herokuapp.com'\n end",
"def onHeroku?()\n\treturn ENV.any? {|x,_| x =~ /^HEROKU/ }\nend",
"def _host_from_env\n ENV['BEANSTALKD_URL'].respond_to?(:length) && ENV['BEANSTALKD_URL'].length > 0 && ENV['BEANSTALKD_URL'].strip\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set path to clientside app file within rb_path. Conventionally 'appname/client/app.rb'. | def client_app_rb_path=(n)
@client_app_rb_path = n
end | [
"def app_root_path=(path)\n @app_root_path = Pathname.new(path).expand_path\n end",
"def app_root= path\n self.init_from path\n end",
"def app_path(path)\n File.expand_path(File.join(path), APP_ROOT)\nend",
"def app_defaults=(v)\n return if @app_defaults\n\n v = File.join(File.dirna... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Default is 'assets' within public | def public_assets_path
@public_assets_path ||= 'assets'
end | [
"def default_public_directory\r\n %w(assets public).select { |dir| File.directory?(File.join(root, dir)) }.first || \"assets\"\r\n end",
"def private_assets_path\n path_for \"_assets\".freeze\n end",
"def assets_path\n @assets_path ||= root_path.join(\"assets\")\n end",
"def _assets path, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes in the referral type and updates it with a new value if it was one of the enum values which was updated | def update_referral_value(referral_type_id)
if referral_type_id == 2
return 3
elsif referral_type_id == 3
return 4
elsif referral_type_id == 4
return 5
elsif referral_type_id == 5
return 7
else
return referral_type_id
end
end | [
"def update\n respond_to do |format|\n if @referral_type.update(referral_type_params)\n format.html { redirect_to @referral_type, notice: 'Referral type was successfully updated.' }\n format.json { render :show, status: :ok, location: @referral_type }\n else\n format.html { render ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute closure of user provided set of attributes as seed User can exit by typing 'quit'. | def compute_closure(rdb)
puts
puts "Closure Operator:"
while true
puts "Enter any set of relation attributes as the seed:(type quit to exit)"
seed = gets.strip.upcase
break if seed == 'QUIT'
closure = rdb.closure(seed)
if closure && !closure&.empty?
puts "Closure of #{seed}: { #{closure.... | [
"def prompt_attrs\n resp_attrs = []\n ATTRIBUTES.each do |attr|\n print \"#{attr}? \"\n resp_attrs[ATTRIBUTES.index(attr)] = gets.chomp\n end\n return resp_attrs\nend",
"def collect_complete_data\n PROMPTABLE_ATTRIBUTES.each do |promptable_attribute|\n next unless send(promptable_attri... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an NSDateFormatter for `template` for the current locale. This is not cached. It's the caller's responsibility to update this if the locale changes. | def dateFormatter(template)
template = NSDateFormatter.dateFormatFromTemplate(template, options:0, locale:NSLocale.currentLocale)
dayLabelFormatter = NSDateFormatter.alloc.init.setDateFormat(template)
end | [
"def factory(locale = :en)\n if block_given?\n yield Factory.instance(locale)\n else\n Factory.instance(locale)\n end\n end",
"def template\n self.class.registry.resolve({format: @scope.format})\n end",
"def format_template(template)\n Utils.template_like_str(o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Puts the empty functions into the correct C files for a given project with a starter documentation form | def funcify
unless File.exists?('.projectProtoMap') and File.exists?('.projectFileMap')
puts "'.projectProtoMap' and/or '.projectFileMap' not found. Please run creatify first."
exit(1)
end
File.open(".projectProtoMap", "r").each_line do
|line|
pMatch = line.match(/^(\d+):(.*?)([^\s^\*]*)\((.*)\);... | [
"def create_set_up_docs\n # Gemfile\n gemfile = File.open(\"Gemfile\",\"w\")\n gemfile.puts(\"\"\"source 'https://rubygems.org'\\nruby '2.5.1'\\ngem 'rubocop', '~> 0.57.2'\\ngem 'rspec'\\ngem 'dotenv'\\ngem 'pry'\\ngem 'launchy'\\ngem 'nokogiri'\"\"\")\n gemfile.close\n puts \"> Gemfile created\"\n\n # .env\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Start the Karafka server | def call
puts 'Starting Karafka server'
cli.info
if cli.options[:daemon]
# For some reason Celluloid spins threads that break forking
# Threads are not shutdown immediately so deamonization will stale until
# those threads are killed by Celluloid manager (via timeo... | [
"def call\n cli.info\n\n validate!\n\n if cli.options[:daemon]\n FileUtils.mkdir_p File.dirname(cli.options[:pid])\n daemonize\n end\n\n # We assign active topics on a server level, as only server is expected to listen on\n # part of the topics\n Ka... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /incidentmanagements GET /incidentmanagements.json | def index
@incidentmanagements = Incidentmanagement.all
end | [
"def index\n @managers_incident_recordings = current_manager.reported_incidents.all\n end",
"def index\n @managements = Management.all\n end",
"def index\n @customer_managements = CustomerManagement.all\n end",
"def index\n @users_managements = Users::Management.all\n end",
"def index\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /incidentmanagements POST /incidentmanagements.json | def create
@incidentmanagement = Incidentmanagement.new(incidentmanagement_params)
respond_to do |format|
if @incidentmanagement.save
format.html { redirect_to @incidentmanagement, notice: 'Incidentmanagement was successfully created.' }
format.json { render :show, status: :created, locat... | [
"def index\n @incidentmanagements = Incidentmanagement.all\n end",
"def create\n Rails.logger.info \"==========================\"\n Rails.logger.info request.raw_post\n Rails.logger.info \"==========================\"\n data = JSON.parse(request.raw_post).symbolize_keys\n ignore = [\"victims\",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /incidentmanagements/1 PATCH/PUT /incidentmanagements/1.json | def update
respond_to do |format|
if @incidentmanagement.update(incidentmanagement_params)
format.html { redirect_to @incidentmanagement, notice: 'Incidentmanagement was successfully updated.' }
format.json { render :show, status: :ok, location: @incidentmanagement }
else
format.... | [
"def update\n respond_to do |format|\n if @incident.update(incident_params)\n format.json { head :no_content }\n else\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /incidentmanagements/1 DELETE /incidentmanagements/1.json | def destroy
@incidentmanagement.destroy
respond_to do |format|
format.html { redirect_to incidentmanagements_url, notice: 'Incidentmanagement was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n #@incident.destroy\n render json: {}, status: 200\n end",
"def destroy\n response = RestClient.delete $api_service+\"/claim_issues/\"+params['id']\n redirect_to :action => \"index\"\n end",
"def destroy\n @incident = Incident.find(params[:id])\n\n @incident.destroy\n\n resp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
callseq: some_curry.new(spice) > Create a new curried proc by applying the supplied spice to the current spice in this curried proc. This does not simply append the spices Arguments in the supplied spice are applied to the curried spice arguments, with black/white hole and antiholes operating as documented. See also +c... | def new(*spice)
Curry.new(*merge_spice(spice), &@uncurried)
end | [
"def curry_with_context(*args,&ruby_block)\n return proc do |cxt,*new_args|\n cxt.instance_exec(*(args+new_args),&ruby_block)\n end\n end",
"def curry(arity, &block)\n fail \"cannot curry for unknown arity\" if arity < 0\n Functors.make_curry(arity, &block)\n end",
"def curry(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that _re_ appears in the log. | def assert_log_match(re)
assert_match(re, log, "#{re.inspect} was not found in log.")
end | [
"def assert_log_no_match(re)\n assert_no_match(re, log, \"#{re.inspect} was found in log.\")\n end",
"def assert_log_every_input_match(re)\n message = \"\"\n each_input do |input_id, input_log|\n if input_log !~ re\n message += \"Input #{input_id} did not match #{re.inspect}.\\n\"\n end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that _re_ does not appear in the log. | def assert_log_no_match(re)
assert_no_match(re, log, "#{re.inspect} was found in log.")
end | [
"def assert_log_every_input_no_match(re)\n message = \"\"\n each_input do |input_id, input_log|\n if input_log =~ re\n message += \"Input #{input_id} matched #{re.inspect}.\\n\"\n end\n end\n assert(message.empty?, message)\n end",
"def assert_log_match(re)\n assert_match(re, log,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that clipp did exit cleanly (status code = 0). | def assert_clean_exit
assert(0 == exit_status)
end | [
"def test_clean_exit\r\n code = 0\r\n assert_output(\"\") {@init.clean_exit(code, false)}\r\n end",
"def assert_no_clean_exit\n assert(0 != exit_status)\n end",
"def test_exitstatus\n with_fixture 'exitstatus' do\n assert system(\"ruby\", ocra, \"exitstatus.rb\", *DefaultArgs)\n system... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that clipp did not exit cleanly (status code != 0). | def assert_no_clean_exit
assert(0 != exit_status)
end | [
"def assert_clean_exit\n assert(0 == exit_status)\n end",
"def test_clean_exit\r\n code = 0\r\n assert_output(\"\") {@init.clean_exit(code, false)}\r\n end",
"def assert_error_occurred\n assert_not_exit_status 0\n end",
"def assert_no_error_occurred\n assert_exit_status(0)\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that every input matches _re_. | def assert_log_every_input_match(re)
message = ""
each_input do |input_id, input_log|
if input_log !~ re
message += "Input #{input_id} did not match #{re.inspect}.\n"
end
end
assert(message.empty?, message)
end | [
"def assert_log_every_input_no_match(re)\n message = \"\"\n each_input do |input_id, input_log|\n if input_log =~ re\n message += \"Input #{input_id} matched #{re.inspect}.\\n\"\n end\n end\n assert(message.empty?, message)\n end",
"def verify\n specials.each do |s|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Assert that every input does not match _re_. | def assert_log_every_input_no_match(re)
message = ""
each_input do |input_id, input_log|
if input_log =~ re
message += "Input #{input_id} matched #{re.inspect}.\n"
end
end
assert(message.empty?, message)
end | [
"def assert_not_match( re, str )\n\t\tmsg = \"<%s> expected not to match %p\" %\n\t\t\t[ str, re ]\n\t\tassert_block( msg ) {\n\t\t\t!re.match( str )\n\t\t}\n\trescue Test::Unit::AssertionFailedError => err\n\t\tcutframe = err.backtrace.reverse.find {|frame|\n\t\t\t/assert_not_match/ =~ frame\n\t\t}\n\t\tfirstIdx =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Execute clipp using the clipp config at config_path. Output is displayed to standard out. This returns a 2element list in which the first element is the status code from the clipp command and the second element is the log output. A status code of 0 indicates success. A status code of nonzero indicates failure. | def run_clipp(config_path)
output, status = run_command(
CLIPP, '-c', config_path
)
puts "#{CLIPP} -c #{config_path}"
if status.exitstatus != 0
puts "== CLIPP Configuration =="
puts IO.read(config_path)
puts "== OUTPUT =="
puts output
puts
puts "Exit status: #{... | [
"def clipp(config)\n config = config.dup\n\n if ! config[:input] && ! config[:input_hashes] && ! block_given?\n CLIPPTest::fatal \"Must have :input, :input_hashes, or a block.\"\n end\n\n config[:id] ||= generate_id\n\n if block_given?\n config[:input_hashes] ||= []\n ClippScript::eval... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Replace CLIPPDIR and BUILDDIR in path with the appropriate values (see above). | def expand_path(path)
File.expand_path(
path.gsub(
'CLIPPDIR', CLIPPDIR
).gsub(
'BUILDDIR', BUILDDIR
)
)
end | [
"def build_dir\n @build_dir ||= File.join(staging_dir, \"BUILD\")\n end",
"def build_directory\n File.expand_path(config['build_directory'])\n end",
"def SetProjectPath(path)\n #puts \"Setting proect path \" + path.to_s\n pathParts = path.RelativePath().split(\"/\")\n @Parts = pat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate an IronBee configuration where context is the context to evaluate the erb in and template is the path to the erb template (defaults to DEFAULT_TEMPLATE). | def generate_ironbee_configuration(context, template = nil)
template ||= DEFAULT_TEMPLATE
template = expand_path(template)
CLIPPTest::fatal "Could not read #{template}" if ! File.readable?(template)
erb = ERB.new(IO.read(template))
config = erb.result(context)
end | [
"def generate_configuration\n template \"mebla.yml\", \"config/mebla.yml\"\n end",
"def generate_bootstrap_config\n HubClustersCreator::Utils::Template::Render\n .new(config)\n .render(File.read(\"#{__dir__}/bootstrap.yaml.erb\"))\n end",
"def config_template\n file = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Write contents to name_template in a temporary location and return path. name_template will have RAND replaced with a random number. | def write_temp_file(name_template, contents)
to = File.join(
BUILDDIR,
name_template.gsub('RAND') {rand(10000)}
)
File.open(to, 'w') {|fp| fp.print contents}
to
end | [
"def template infile, outfile\n filename = \"#{@template_dir}/#{infile}\"\n filetext = File.read(filename).gsub DUMMY_TEXT, @name\n File.write outfile, filetext\n end",
"def make_remote_filename( template, tempdir=\"/tmp/\" )\n\t\tbasename = File.basename( template, File.extname(template) )\n\t\ttmpname... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Construct an identifier for use in filenames. This routine is highly specific to clipp tests. | def generate_id
test = nil
caller.each do |s|
if s =~ /in `test_(.+)'/
test = $1
break
end
end
if test
prefix = "#{test}_"
else
prefix = ""
end
i = 1
while File.exists?(File.join(BUILDDIR, "clipp_test_#{prefix}#{i}.clipp"))
i += 1
end
... | [
"def identifier_for_filename(filename)\n # Item is a directory with an index file\n if filename =~ /index(\\.[a-z]{2})?\\.[^\\/]+$/\n regex = ((@config && @config[:allow_periods_in_identifiers]) ? /index(\\.[a-z]{2})?(\\.[^\\/\\.]+)$/ : /index(\\.[a-z]{2})?(\\.[^\\/]+)$/)\n # Item is a ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run clipp. Determines the context which all clipp assertions run under. Includes an assertion that clipp exited normally. All arguments are keyvalues. :input or :input_hashes is required. Configuration Options: +input+:: One or more clipp input chains. +input_hashes+:: Input as array of hashes. See hash_to_pb.rb. +temp... | def clipp(config)
config = config.dup
if ! config[:input] && ! config[:input_hashes] && ! block_given?
CLIPPTest::fatal "Must have :input, :input_hashes, or a block."
end
config[:id] ||= generate_id
if block_given?
config[:input_hashes] ||= []
ClippScript::eval(Proc.new) do |inp... | [
"def execute!\n config = instantiate_configuration(options)\n config.debug = options[:debug]\n config.dry_run = options[:dry_run]\n config.preserve_roles = options[:preserve_roles]\n config.logger.level = options[:verbose]\n\n set_pre_vars(config)\n load_recipes(conf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def _hensel_lift(g0, f0, char, height) | def _hensel_lift(g0, f0, _char, height, where)
# self in MPolynomial/ZorZp
# g0 in Polyomial/ZorZp, candidate of factor of f0
# f0 in Polyomial/ZoZzp, one variable reduction of self
ring = self.class
ring_one = g0.class
h0, r0 = f0.divmod g0
raise 'each_product does not work ... | [
"def hensel_lift_int(g0, f0, char, height, where)\n # self in MPolynomial/int\n # g0 in Polyomial/Z, candidate of factor of f0\n # f0 in Polyomial/Z, one variable reduction of self\n\n pheight = gelfond_bound(char)\n\n fk = _hensel_lift(g0, f0, char, height, where) do |ha, ary, cofacts|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the basic usage generating an executable | def testBasicBinary
execTest('Applications/Basic', [], 'ReleaseInfo_Exe.rb') do |iReleaseDir, iReleaseInfo|
checkReleaseInfo(iReleaseDir, iReleaseInfo)
checkReleaseNotes(iReleaseDir, iReleaseInfo)
lExeFileName = "#{iReleaseDir}/Release/ExeName"
assert(File.exist... | [
"def test_output_option\n with_fixture 'helloworld' do\n assert system(\"ruby\", ocra, \"helloworld.rb\", *(DefaultArgs + [\"--output\", \"goodbyeworld.exe\"]))\n assert !File.exist?(\"helloworld.exe\")\n assert File.exist?(\"goodbyeworld.exe\")\n end\n end",
"def test_helloworld\n with_f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the basic usage generating an executable in a terminal | def testBasicBinaryInTerminal
execTest('Applications/Basic', [], 'ReleaseInfo_ExeTerm.rb') do |iReleaseDir, iReleaseInfo|
checkReleaseInfo(iReleaseDir, iReleaseInfo)
checkReleaseNotes(iReleaseDir, iReleaseInfo)
lExeFileName = "#{iReleaseDir}/Release/ExeName"
ass... | [
"def test_output_option\n with_fixture 'helloworld' do\n assert system(\"ruby\", ocra, \"helloworld.rb\", *(DefaultArgs + [\"--output\", \"goodbyeworld.exe\"]))\n assert !File.exist?(\"helloworld.exe\")\n assert File.exist?(\"goodbyeworld.exe\")\n end\n end",
"def testBasicBinaryInTerminal\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Rotates the config file | def rotate_file(config_file)
config_file = nil if config_file.is_a?(String) and config_file.empty?
raise ArgumentError, "Must provide a configuration file: config_file => 'some_file.conf'" unless
config_file
@content = File.read(config_file)
LogRotate.rotate_file(config_f... | [
"def roll_file\n config.roll_file\n end",
"def write_config\n File.open(@config_file, \"w\"){|f| YAML.dump(config, f)}\n end",
"def revert_config\n config_temp = @config + '.tmp'\n return unless File.exist?(config_temp)\n\n File.delete(@config) if File.exist?(@config)\n F... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This prepares the request body to match with wbmock's expected one to successfully stub `POST /invitations/join_space_request` | def stub_join_space_request_api_call(space_id, state: 0, body: "")
stub_ribose_join_space_request_create_api(
state: state,
body: body,
type: "Invitation::JoinSpaceRequest",
space_id: space_id.to_s,
)
end | [
"def create_mentor_request(body)\n request_body = {\n 'fields' => {\n 'Slack User' => body[:slack_user],\n 'Service' => format_for_posting(body[:services]),\n 'Skillsets' => format_for_posting(body[:skillsets]),\n 'Additional Details' => body[:additional_details],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The difference in the insert sequence size and the insert location | def size_diff
insert_size = (close - open) + 1
sequence.length - insert_size
end | [
"def insert_row_pos; end",
"def insert_rows_length\n 1_000\n end",
"def insert_count\n @rows.count - error_count\n end",
"def insertion_point\n end",
"def pos_doublewrite_info\n size - 200\n end",
"def pos_doublewrite_info\n size - 200\n end",
"def offset_s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Serialize and send given input to command listener | def send_input(input)
EM.connect('127.0.0.1', RightScale::CommandConstants::SOCKET_PORT, OutputHandler, input)
end | [
"def on_input(&block); @input = block; end",
"def input(data)\n if @stdin_data\n @stdin_data += data.to_s\n else\n @stdin_data = data.to_s\n end\n end",
"def serialize(_object, data)\n IO.popen(@cmd, 'w') {|io| io.write(data) }\n end",
"def send_input(input)\n @s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the initial usage right after the request is read. | def post_read_request( request )
# Only count the main request, not subrequests
if request.main?
@counter += 1
@initial_usage = Process.rusage
request.server.log_info "Initial rusage (%s): %p" %
[ request.uri, @initial_usage ]
end
return Apache::DECLINED
end | [
"def reset_usage!\n @usage.reset!\n end",
"def state_initial\n @request = ServerSide::HTTP::Request.new(self)\n @response_sent = false\n set_state(:state_request_line)\n end",
"def set_request_start_time\n @request_start_time = Time.now\n end",
"def usage=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
loops through each color in guess, looks for it in key, and then deletes the color from the key to avoid duplicates | def check_for_color_matches(guess, key)
i = 0
while i < guess.length
match = key.index(guess[i])
unless match.nil?
@@color_matches.push(guess[i])
keep_color_matches = @@color_matches.dup
key.delete_at(match)
end
i += 1
end
end | [
"def delete_extra_guesses(guess_hash)\n guess_hash.each do |k, v|\n guess_hash.reject! { |k| (@secret_code.count k) == 0 } # Getting rid of key colours not present in the secret code\n end\n guess_hash.each do |k, v|\n num_extra_guesses = v.length - (@secret_code.count k) # How many more of a co... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If 4 direct matches are found, it puts a winning message and exits the program | def check_for_winner(message)
return unless @@direct_matches.length == 4
puts message
exit
end | [
"def exact_matches\n matches = 0\n 4.times{ |x| matches += 1 if @num_guess[x] == @code[x] }\n matches\n end",
"def check_win\n\tp = tokenize($current_player)\n\tvert1 = $row1[0] + $row2[0] + $row3[0]\n\tvert2 = $row1[2] + $row2[2] + $row3[2]\n\tvert3 = $row1[4] + $row2[4] +... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks for direct matches, then deletes those matches from the key and guess arrays. Then checks for color matches | def check_for_matches(guess, key)
check_for_direct_matches(guess, key)
delete_matches(@@direct_matches, guess)
delete_matches(@@direct_matches, key)
check_for_color_matches(guess, key)
end | [
"def check_for_color_matches(guess, key)\n i = 0\n while i < guess.length\n match = key.index(guess[i])\n unless match.nil?\n @@color_matches.push(guess[i]) \n keep_color_matches = @@color_matches.dup\n key.delete_at(match)\n end\n i += 1\n end\n end",
"def delet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
saves direct matches from previous round to be used in next round | def save_direct_matches
@@direct_matches.each do |i|
keep_matches[i] = @@player_key[i]
end
end | [
"def store_end_match(best_pl_segni)\r\n @info_match[:match_winner] = best_pl_segni\r\n end",
"def store_end_match(best_pl_segni)\n @info_match[:match_winner] = best_pl_segni\n end",
"def save_round(their_move,my_move,winner)\n @last_round = [their_move,my_move,winner]\n @last_round\n end",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /meal_templates GET /meal_templates.json | def index
@meal_templates = MealTemplate.all
end | [
"def templates\n response = get \"storage/template\"\n data = JSON.parse response.body\n data\n end",
"def index\n @exercise_templates = ExerciseTemplate.all\n render json: @exercise_templates\n end",
"def templates\n response = get \"storage/template\"\n data = JSON.parse r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /meal_templates POST /meal_templates.json | def create
@meal_template = MealTemplate.new(meal_template_params)
respond_to do |format|
if @meal_template.save
format.html { redirect_to @meal_template, notice: 'Meal template was successfully created.' }
format.json { render :show, status: :created, location: @meal_template }
els... | [
"def index\n @meal_templates = MealTemplate.all\n end",
"def create\n meal = Meal.new(meal_params)\n\n if meal.save\n render json: meal, status: 201, location: meal\n else\n render json: meal.errors, status: 422\n end\n end",
"def template\n ensure_ingredient_present; return if per... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /meal_templates/1 PATCH/PUT /meal_templates/1.json | def update
respond_to do |format|
if @meal_template.update(meal_template_params)
format.html { redirect_to @meal_template, notice: 'Meal template was successfully updated.' }
format.json { render :show, status: :ok, location: @meal_template }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @create_meal.update(create_meal_params)\n format.html { redirect_to @create_meal, notice: 'Create meal was successfully updated.' }\n format.json { render :show, status: :ok, location: @create_meal }\n else\n format.html { render :edit }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /meal_templates/1 DELETE /meal_templates/1.json | def destroy
@meal_template.destroy
respond_to do |format|
format.html { redirect_to meal_templates_url, notice: 'Meal template was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @item_meal.destroy\n head :no_content, status: 204\n else\n render json: @item_meal.errors, status: 405\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
set the exception_data deliverer OR retrieve the exception_data | def exception_data(deliverer = nil)
if deliverer
write_inheritable_attribute(:exception_data, deliverer)
else
read_inheritable_attribute(:exception_data)
end
end | [
"def prepare_exception_notifier\n request.env[\"exception_notifier.exception_data\"] = {\n request_original_url: request.original_url,\n request_method: request.request_method,\n request_path: request.fullpath,\n params_as_json: params.as_json,\n params_inspect: params.inspect,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
overrides Rails' local_request? method to also check any ip addresses specified through consider_local. | def local_request?
remote = IPAddr.new(request.remote_ip)
!self.class.local_addresses.detect { |addr| addr.include?(remote) }.nil?
end | [
"def local_request?\n return false unless $LOCAL_REQUEST_ADDRESSES.is_a? Array\n $LOCAL_REQUEST_ADDRESSES.any?{ |local_ip| request.remote_addr == local_ip && request.remote_ip == local_ip }\n end",
"def local_request? #:doc:\n request.remote_addr == LOCALHOST && request.remote_ip == LOCALHOST\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to call openpgp to make a keypair | def make_keypair
gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')
key_id = gpg.gen_key({
:key_type => 'DSA',
:key_length => 1024,
:subkey_type => 'ELG-E',
:subkey_length => 1024,
:name => @dname,
:comment => nil,
#:email => '',
#:passphrase ... | [
"def make_keypair\n\t gpg = OpenPGP::Engine::GnuPG.new(:homedir => '~/.gnupg')\n\t key_id = gpg.gen_key({\n\t\t :key_type => 'RSA',\n\t\t :key_length => 4096,\n\t\t :subkey_type => 'RSA',\n\t\t :subkey_length => 4096,\n\t\t :name => @dname,\n\t\t :comment => nil,\n\t\t #:email ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /informativo_obras POST /informativo_obras.json | def create
@informativo_obra = InformativoObra.new(informativo_obra_params)
@status = Statusobra.find_by_statusobra_type("Salvo")
@informativo_obra.statusobra_id = @status.id
respond_to do |format|
if @informativo_obra.save
format.html { redirect_to @informativo_obra, notice: 'Informativ... | [
"def create\n @arribo_bauxita = ArriboBauxita.new(:bax_id => params[:bax_id], :fecha_hora_arribo_bauxita => DateTime.now)\n\n respond_to do |format|\n if @arribo_bauxita.save\n format.json { render json: @arribo_bauxita, status: :created }\n else\n format.json { render json: @arribo_ba... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /informativo_obras/1 PATCH/PUT /informativo_obras/1.json | def update
respond_to do |format|
if @informativo_obra.update(informativo_obra_params)
format.html { redirect_to @informativo_obra, notice: 'Informativo de obra foi atualizado com sucesso.' }
format.json { render :show, status: :ok, location: @informativo_obra }
else
format.html ... | [
"def update\n\trespond_to do |format|\n\tif @precio_boleto.update(precio_boleto_params)\n\t\tformat.html { redirect_to @precio_boleto, notice: 'Precio boleto was successfully updated.' }\n\t\tformat.json { head :no_content }\n\telse\n\t\tformat.html { render action: 'edit' }\n\t\tformat.json { render json: @precio_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /informativo_obras/1 DELETE /informativo_obras/1.json | def destroy
@informativo_obra.destroy
respond_to do |format|
format.html { redirect_to informativo_obras_url, notice: 'Informativo obra was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @dados_banco.destroy\n respond_to do |format|\n format.html { redirect_to dados_bancos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
remove comments that exist outside of the HTML element. these comments are allowed by the HTML spec: but are not scrubbed by Loofah because these nodes don't meet the contract that scrubbers expect of a node (e.g., it can be replaced, sibling and children nodes can be created). | def remove_comments_before_html_element(doc)
doc.children.each do |child|
child.unlink if child.comment?
end
doc
end | [
"def remove_comments_before_html_element(doc); end",
"def remove_comment comment\n return if @comments.empty?\n\n case @comments\n when Array then\n @comments.delete_if do |my_comment|\n my_comment.file == comment.file\n end\n when RDoc::Markup::Document then\n @comments.parts.de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve the location of Qt from conan | def get_qt_location
cmd_str = "conan info qt/5.12.2@bincrafters/stable " +
"--package-filter \"qt*\" " +
"--paths --only package_folder " +
""
resp_str = `#{cmd_str}`
resp_str.lines.each do |line|
return line.split(": ")[1].strip if line.include?("package_folder")
end
e... | [
"def get_location(dep)\n\n cmd_str = \"conan info #{dep} \" +\n \"--paths --only package_folder \" +\n \"\"\n\n resp_str = `#{cmd_str}`\n\n resp_str.lines.each do |line|\n return line.split(\": \")[1].strip if line.include?(\"package_folder\")\n end\n\nend",
"def location\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
carga el area automaticamente | def cargar_area_id
area= Area.where(nombre: 'Nutrición').first.id
self.area_id= area
end | [
"def cargar_area_id\n area= Area.where(nombre: 'Odontología').first.id\n self.area_id= area\n end",
"def draw_area(data,serie1,serie2,r,g,b,alpha = 50)\n validate_data(\"draw_area\",data)\n layer_width = @g_area_x2-@g_area_x1\n layer_height = @g_area_y2-@g_area_y1\n\n @layers[0] = image_create_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We try a password with a valid absence of a 3 letter/number sequence | def test_sequence_valid13
result = contains_password?("passwrd12*")
assert(result, "'passwrd12*' should be valid because it doesn't contain a sequence")
end | [
"def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end",
"def three_letters_in_order?(password)\n #subtract two becuase we do not need to check the last nor the second to last\n # => characters for ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to remove spaces in the link field | def strip_blanks
self.link = self.link.strip
end | [
"def clear_link(link)\n link.gsub!(/\\.|\\?|\\!\\&|»|«|\\,|\\\"|\\'|\\:/,'')\n link.gsub!('<br>','')\n link.gsub!(' ','-')\n link.gsub!('---','-')\n link.gsub!('--','-')\n# it shall not be greater than 100 chars. Don't break in the middle of words \n if link.size > 100\n link = link[0,100]\n link.chop!... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /charities GET /charities.xml | def index
@charities = Charity.find(:all, :order => "created_at DESC")
respond_to do |format|
format.html { render :template => "charities/list" unless admin?}
format.xml { render :xml => @charities }
end
end | [
"def get_charities(params = {})\n commit(Ebay::Requests::GetCharities, params)\n end",
"def index\n @charities = Charity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charities }\n end\n end",
"def index\n @charities = Charity.all\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /charities/1 GET /charities/1.xml | def show
@charity = Charity.find_by_ident_name(params[:id]) || Charity.find(params[:id])
#@charities = Charity.find_all_by_lang(@charity.lang)
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @charity }
end
end | [
"def index\n @charities = Charity.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charities }\n end\n end",
"def index\n @charities = Charity.find(:all, :order => \"created_at DESC\")\n\n respond_to do |format|\n format.html { render :tem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /charities POST /charities.xml | def create
@charity = Charity.new(params[:charity])
respond_to do |format|
if @charity.save
flash[:notice] = 'Charity was successfully created.'
format.html { redirect_to charities_path }
format.xml { render :xml => @charity, :status => :created, :location => @charity }
els... | [
"def createCharities\n\tcharity_list = [\"Direct Relief\", \"Catholic Medical Mission Board\", \"MAP International\", \"United Nations Foundation\", \"The Rotary Foundation of Rotary International\", \"Samaritan's Purse\", \"Institute of International Education\", \"International Rescue Committee\", \"Compassion In... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /charities/1 PUT /charities/1.xml | def update
@charity = Charity.find(params[:id])
@charity.attributes = params[:charity]
respond_to do |format|
if @charity.save!
flash[:notice] = 'Charity was successfully updated.'
format.html { redirect_to lang_charity_path(@lang.to_s.split('-').first,@charity) }
format.xml ... | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def update\n @charity = Charity.find(params[:id])\n\n respond_to do |format|\n if @charity.update_attributes(params[:charity])\n format.html { redirect_to @chari... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /charities/1 DELETE /charities/1.xml | def destroy
@charity = Charity.find(params[:id])
@charity.destroy
respond_to do |format|
format.html { redirect_to(charities_url) }
format.xml { head :ok }
end
end | [
"def destroy\n if !params[:id].to_s.match(/^\\d+$/)\n @charity = Charity.find_by_seo_name(params[:id])\n else\n @charity = Charity.find(params[:id])\n end\n @charity.destroy\n respond_to do |format|\n format.html { redirect_to([:manage, charities_url]) }\n format.xml { head :ok }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
When you declare an association, you can then think of the code_attributes as an extension of the declaring model. This setter method is like any other, expect it happens to accept an array of attributes. We call find_or_create to see if an existing record is in the database. If not, then we create one. We assign it to... | def code_attributes=(params)
code_to_save = Code.find_or_create_by_code_name(params[:code_name])
self.code = code_to_save
code_to_save.status = params[:status]
code_to_save.description = params[:description]
code_to_save.save
end | [
"def associate_hipaa_codes(reason_code_id, payer, hipaa_code)\n reason_code = ReasonCode.find(reason_code_id)\n set_name = payer.reason_code_set_name\n reasoncodes_clients_facilities_setname = ReasonCodesClientsFacilitiesSetName.\n find_or_create_by_reason_code_id(reason_code.id)\n crosswalk_item =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Authorizes each newlybuilt experience points record. Each record has to be checked otherwise it might be possible for a course staff to award experience points to a student from a different course. Only checking the records is also insufficient since access will not be denied if there are no records to authroize. | def authorize_resource
authorize!(:disburse, @disbursement)
@disbursement.experience_points_records.each do |record|
authorize!(:create, record)
end
end | [
"def check_access_to_employer_profile\n employer_profile = EmployerProfile.find(params[:id])\n policy = ::AccessPolicies::EmployerProfile.new(current_user)\n policy.authorize_edit(employer_profile, self)\n end",
"def authorize_record(action, record)\n true\n end",
"def authorize_achievement!\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tourneys GET /tourneys.json | def index
@tourneys = Tourney.all
end | [
"def journeys\n response = get 'journeys'\n response.map{|item| Hashie::Mash.new(item)}\n end",
"def get_journeys(page)\n full_path = full_resource_path '/journeys'\n query_params = MaropostApi.set_query_params({:page => page})\n \n MaropostApi.get_result(full_path, query_params)\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /tourneys POST /tourneys.json | def create
user = User.find(current_user.id)
@tourney = user.tourneys.create(tourney_params)
respond_to do |format|
if @tourney.save
foro = Foro.create({:title => "Forum of " + @tourney.name, :description => "In this forum you can ask any doubt you have about the procedures, rules, etc. of th... | [
"def create\n @tourney = current_user.tourneys.new(tourney_params)\n\n respond_to do |format|\n if @tourney.save\n format.html { redirect_to tourneys_url, notice: t('tourneyCreated') }\n format.json { render action: 'show', status: :created, location: @tourney }\n else\n format.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /tourneys/1 DELETE /tourneys/1.json | def destroy
@tourney.destroy
respond_to do |format|
format.html { redirect_to tourneys_url, notice: 'Tourney was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @tourney.destroy\n respond_to do |format|\n format.html { redirect_to tourneys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @journey = Journey.find(params[:id])\n @journey.destroy\n\n respond_to do |format|\n format.html { redirect_to journ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /super_files/1 GET /super_files/1.json | def show
@super_file = SuperFile.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @super_file }
end
end | [
"def new\n @super_file = SuperFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @super_file }\n end\n end",
"def index\n @user_files = UserFile.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /super_files/new GET /super_files/new.json | def new
@super_file = SuperFile.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @super_file }
end
end | [
"def create\n @super_file = SuperFile.new(params[:super_file])\n\n respond_to do |format|\n if @super_file.save\n format.html { redirect_to @super_file, notice: 'Super file was successfully created.' }\n format.json { render json: @super_file, status: :created, location: @super_file }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /super_files POST /super_files.json | def create
@super_file = SuperFile.new(params[:super_file])
respond_to do |format|
if @super_file.save
format.html { redirect_to @super_file, notice: 'Super file was successfully created.' }
format.json { render json: @super_file, status: :created, location: @super_file }
else
... | [
"def new\n @super_file = SuperFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @super_file }\n end\n end",
"def create\n @super_d_upload = current_user.super_d_uploads.build(super_d_upload_params)\n\n respond_to do |format|\n if @super_d_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /super_files/1 PUT /super_files/1.json | def update
@super_file = SuperFile.find(params[:id])
respond_to do |format|
if @super_file.update_attributes(params[:super_file])
format.html { redirect_to @super_file, notice: 'Super file was successfully updated.' }
format.json { head :no_content }
else
format.html { rende... | [
"def create\n @super_file = SuperFile.new(params[:super_file])\n\n respond_to do |format|\n if @super_file.save\n format.html { redirect_to @super_file, notice: 'Super file was successfully created.' }\n format.json { render json: @super_file, status: :created, location: @super_file }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /super_files/1 DELETE /super_files/1.json | def destroy
@super_file = SuperFile.find(params[:id])
@super_file.destroy
respond_to do |format|
format.html { redirect_to super_files_url }
format.json { head :no_content }
end
end | [
"def destroy\n @super_d_upload.destroy\n respond_to do |format|\n format.html { redirect_to super_d_uploads_url, notice: 'Super d upload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def file_delete(path)\n params = {\n \"root\" => @root,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overrides test from LocalCacheBehavior in order to stub out the cache clear and replace it with a delete. | def test_clear_also_clears_local_cache
key = SecureRandom.uuid
cache = lookup_store(raw: true)
stub_called = false
client(cache).stub(:flush_all, -> { stub_called = true; client.delete("#{@namespace}:#{key}") }) do
cache.with_local_cache do
cache.write(key, SecureRandom.alphanumeric)
... | [
"def cache_delete\n model.send(:cache_delete, cache_key)\n end",
"def cache_delete\n model.send(:cache_delete, cache_key)\n end",
"def delete\n cache_delete\n super\n end",
"def clear_cache; end",
"def delete(&block)\n result = super\n cache_del... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /sprinkles GET /sprinkles.json | def index
@sprinkles = Sprinkle.all
end | [
"def index\n @snakes = Snake.all\n render json: @snakes\n end",
"def skier_pings_index \n @pings = Skier.find(params[:id]).pings\n render json: @pings \n end",
"def show\n render json: @shelter\n end",
"def index\n @shoes = Shoe.all\n\n respond_to do |format|\n format.html # index... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /sprinkles POST /sprinkles.json | def create
@sprinkle = Sprinkle.new(sprinkle_params)
respond_to do |format|
if @sprinkle.save
format.html { redirect_to @sprinkle, notice: 'Sprinkle was successfully created.' }
format.json { render :show, status: :created, location: @sprinkle }
else
format.html { render :ne... | [
"def create\n fruit = Fruit.new(params[:fruit])\n #fruits = Fruits.get(\"http://localhost:9292/fruits\", 'application/json').fruits\n #fruits << fruit\n\n fruit.post(\"http://localhost:9292/fruits\", 'application/json')\n #fruits.post(fruits.links[:self])\n redirect_to fruits_path, notice: \"May y... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /sprinkles/1 PATCH/PUT /sprinkles/1.json | def update
respond_to do |format|
if @sprinkle.update(sprinkle_params)
format.html { redirect_to @sprinkle, notice: 'Sprinkle was successfully updated.' }
format.json { render :show, status: :ok, location: @sprinkle }
else
format.html { render :edit }
format.json { render... | [
"def update\n spice = Spice.find_by(id: params[:id])\n spice.update(spice_params)\n render json: spice\nend",
"def update\n respond_to do |format|\n if @retail_shelf.update(retail_shelf_params)\n format.html { redirect_to @retail_shelf, notice: 'Retail shelf was successfully updated.' }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def error_cannot_be_composed puts "\n ERROR: THE AMOUNT YOU REQUESTED CANNOT BE COMPOSED FROM BILLS AVAILABLE IN THIS ATM. PLEASE ENTER A DIFFERENT AMOUNT:" input end | def error_not_enough_money
puts "\n ERROR: THE AMOUNT YOU REQUESTED CANNOT BE COMPOSED NOT ENOUGH MONEY. PLEASE TRY AGAIN with DIFFERENT AMOUNT"
end | [
"def confirm_msg\n amt = CalcTotal::get_amt\n msg = amt && amt > 0 ? \"Your credit card \" : \"Your order \"\n msg += \"will be processed. Would you like to proceed?\"\n end",
"def user_bet_amount\n balance = $current_user[:balance].to_i\n system(\"clear\")\n font = font_instance\n puts fon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /user_has_role_for_nodes GET /user_has_role_for_nodes.json | def index
@user_has_role_for_nodes = UserHasRoleForNode.all
end | [
"def current_user_has_any_role?(node)\n current_user.present? && current_user.has_any_role?(node)\n end",
"def node_roles\n hiera_lookup(\"node_roles\") || {}\n end",
"def nodes_for_role role\n Chef::Log.info \"Searching for node with role:#{role} and environment:#{node.chef_environment}\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /user_has_role_for_nodes/1 DELETE /user_has_role_for_nodes/1.json | def destroy
@user_has_role_for_node.destroy
respond_to do |format|
format.html { redirect_to user_has_role_for_nodes_url, notice: 'User has role for node was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @core_user_role.destroy\n respond_to do |format|\n format.html { redirect_to core_user_roles_url }\n format.json { head :no_content }\n end\n end",
"def remove_node(node)\n has_node = HAS_NODE_ROLE.find_by_node_id_and_role_instance_id node.id, self.id\n HAS_NODE_ROLE.delet... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
displays the letters to the user | def displayLettersFound()
@lettersDisplayArr.each do |i|
print i
end
print "\n"
end | [
"def show\n @wordlist.chunk { |word| word.to_s.length }.each do |length, words|\n print yellow, bold, \"\\n\\n#{length} Letters: \", reset\n\n list(words)\n end\n\n puts\n end",
"def display\n @flower_array.each { |flower| print \"#{flower} \".colorize(:light_red) }\n puts\n @stem_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Store the file in the MSF local directory (eg, /root/.msf4/local/) | def store_file(data, filename)
ltype = "exploit.fileformat.#{self.shortname}"
if ! ::File.directory?(Msf::Config.local_directory)
FileUtils.mkdir_p(Msf::Config.local_directory)
end
if filename and not filename.empty?
if filename =~ /(.*)\.(.*)/
ext = $2
fname = $1... | [
"def put(path, local_file)\n post(\n 'dbfs/put',\n {\n path: path,\n contents: ::File.new(local_file, 'rb'),\n overwrite: true\n }\n )\n end",
"def store_wffile\n # verify if there is actually a file to be saved\n if @file_data\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /espacios_comunes/1 DELETE /espacios_comunes/1.json | def destroy
@espacio_comun.destroy
respond_to do |format|
format.html { redirect_to espacios_comunes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @comune = Comune.find(params[:id])\n @comune.destroy\n\n respond_to do |format|\n format.html { redirect_to(comunes_url) }\n format.xml { head :ok }\n end\n end",
"def delete_mobile_carrier(args = {}) \n delete(\"/mobile.json/#{args[:carrierId]}\", args)\nend",
"def destro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /activity_events/1 GET /activity_events/1.json | def show
@activity_event = ActivityEvent.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @activity_event }
end
end | [
"def show\n event_id = params[:id]\n if event_id.present?\n @event = Com::Nbos::Events::Event.active_events.where(id: event_id, tenant_id: @user.tenant_id)\n if @event.present?\n render :json => @event\n else\n render :json => {messageCode: \"event.notfound\", message: \"Event Not... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /activity_events/new GET /activity_events/new.json | def new
@activity_event = ActivityEvent.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @activity_event }
end
end | [
"def new\n @create_event = CreateEvent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @create_event }\n end\n end",
"def new\n @event = Event.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"
]
]
}
} |
POST /activity_events POST /activity_events.json | def create
@activity_event = ActivityEvent.new(params[:activity_event])
respond_to do |format|
if @activity_event.save
format.html { redirect_to @activity_event, notice: 'Activity event was successfully created.' }
format.json { render json: @activity_event, status: :created, location: @a... | [
"def create\n Rails.logger.debug(\"Received event #{params[:event]}\")\n head :ok\n end",
"def create\n @event = Event.new(event_params)\n if @event.save\n render json: @event.to_json, status: :created\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /activity_events/1 PUT /activity_events/1.json | def update
@activity_event = ActivityEvent.find(params[:id])
respond_to do |format|
if @activity_event.update_attributes(params[:activity_event])
format.html { redirect_to @activity_event, notice: 'Activity event was successfully updated.' }
format.json { head :no_content }
else
... | [
"def update\n #TODO params -> strong_params\n if @event.update(params)\n head :no_content\n else\n render json: @event.errors, status: :unprocessable_entity\n end\n end",
"def update\n event = event.find(params[\"id\"]) \n event.update_attributes(event_params) \n respond_with event... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /activity_events/1 DELETE /activity_events/1.json | def destroy
@activity_event = ActivityEvent.find(params[:id])
@activity_event.destroy
respond_to do |format|
format.html { redirect_to activity_events_url }
format.json { head :no_content }
end
end | [
"def destroy\n @simple_event = SimpleEvent.find(params[:id])\n @simple_event.destroy\n\n respond_to do |format|\n format.html { redirect_to simple_events_dashboard_index_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @event.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.