query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Return a JSON object with image information add &metadata=true for image metadata add &presets=true for preset url for this image add &relative=true for relative urls instead of absolute | def info(preset, source_path, format)
url_opts = { :storage => params[:storage], :preset => preset, :format => format }
relative_uri = url_for_image(params[:relative_path], url_opts)
absolute_path = Merb.dir_for(:public) / relative_uri
base_url = params[:relative] ? '' : (request.protocol ... | [
"def get_image_info\n info = get_new_info\n if File.exists?(json_path)\n begin\n data = JSON.parse(File.read(json_path))\n if data.respond_to?(:key?)\n (info['title'] = data['title']) if data.key?('title')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show list of collection_numbers. | def list_all
store_location
query = create_query(:CollectionNumber, :all)
show_selected_collection_numbers(query)
end | [
"def list_collection_numbers\n store_location\n query = create_query(:CollectionNumber, :all)\n show_selected_collection_numbers(query)\n end",
"def index_collection_number\n query = find_or_create_query(:CollectionNumber, by: params[:by])\n show_selected_collection_numbers(query, id: params[:id].... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Displays matrix of selected CollectionNumber's (based on current Query). | def index_query_results
query = find_or_create_query(:CollectionNumber, by: params[:by])
show_selected_collection_numbers(query, id: params[:id].to_s,
always_index: true)
end | [
"def list_collection_numbers\n store_location\n query = create_query(:CollectionNumber, :all)\n show_selected_collection_numbers(query)\n end",
"def index_collection_number\n query = find_or_create_query(:CollectionNumber, by: params[:by])\n show_selected_collection_numbers(query, id: params[:id].... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Display list of CollectionNumbers whose text matches a string pattern. | def pattern
pat = params[:pattern].to_s
if pat.match?(/^\d+$/) &&
(collection_number = CollectionNumber.safe_find(pat))
redirect_to(action: :show, id: collection_number.id)
else
query = create_query(:CollectionNumber, :pattern_search, pattern: pat)
show_selected_collection_numbers(q... | [
"def collection_number_search\n pattern = params[:pattern].to_s\n if pattern.match(/^\\d+$/) &&\n (collection_number = CollectionNumber.safe_find(pattern))\n redirect_to(action: :show, id: collection_number.id)\n else\n query = create_query(:CollectionNumber, :pattern_search, pattern: patte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Construct path to a temp file with extension that does not exist. | def temp_file(extension)
File.join(@temp_dir, ::SecureRandom.hex(7) + '.' + extension.trim('.', '')).to_s
end | [
"def temp (extension)\n path = \"#{FileUtils::Config.tmp_dir}/tmp.#{extension}\"\n id = 1\n while File.exists?(path)\n path = \"#{FileUtils::Config.tmp_dir}/tmp.#{id}.#{extension}\"\n id += 1\n end\n\n path\n end",
"def temp_file(part)\n file_name =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Construct path to a temp file with full_name as the file name that does not exist. | def temp_file_from_name(file_name)
File.join(@temp_dir, file_name).to_s
end | [
"def create_temp_file\n copy_to_temp_file full_filename\n end",
"def create_temp_file\n copy_to_temp_file full_filename\n end",
"def file_name\n Pathname(\"#{dir_name}temporaryfile\")\n end",
"def temp_file(part)\n file_name = filename?(part)\n File.expand_path(File.j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new audio file from source path in target path, modified according to the parameters in modify_parameters. Possible options for modify_parameters: :start_offset :end_offset :channel :sample_rate | def modify(source, target, modify_parameters = {})
raise ArgumentError, "Source and Target are the same file: #{target}" if source == target
source = check_source(source)
raise Exceptions::FileAlreadyExistsError, "Target exists: #{target}" if File.exist? target
raise Exceptions::InvalidTargetMed... | [
"def modify(source, target, modify_parameters = {})\n source = Pathname(source)\n target = Pathname(target)\n raise ArgumentError, \"Source is not a wav file: : #{source}\" unless source.extname == '.wav'\n raise ArgumentError, \"Target is not a png file: : #{target}\" unless target.extname == '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether the sample rate in modify_parameters is allowed | def check_sample_rate(target, modify_parameters = {}, source_info = {})
if modify_parameters.include?(:sample_rate)
sample_rate = modify_parameters[:sample_rate].to_i
# source_info sample_rate_hertz should match modify_parameters original_sample_rate if both are supplied
if source_info.in... | [
"def fails_threshold?\n return false if sample_size < options.sample_threshold\n\n failure_rate >= options.rate_threshold\n end",
"def check_for_rate_limits\n rate_limit_remaining < 10\n end",
"def validate_parameters?(op)\n temp_params = op.temporary[:plan_params]\n errors_noted = \"The ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Check if a source exists, and is a file. | def check_source(path)
raise Exceptions::FileNotFoundError, 'Source path was empty or nil' if path.nil? || (path.is_a?(String) && path.empty?)
path = Pathname(path)
# Maybe worth resolving symlinks to a realpath, but currently does not cause any failures without
#path = File.realpath(File.readl... | [
"def has_source?\n !!file\n end",
"def exist?\n File.exist?(source_path)\n end",
"def valid_source?(source)\n absolute_uri?(source) ? true : ::File.exist?(source)\n end",
"def validate_source(source)\n unless File.exist? source\n puts \"Source #{source} doesn't exis... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
def modify_shntool(source, source_info, target, start_offset, end_offset) | def audio_tool_segment(extension, audio_tool_method, source, source_info, target, modify_parameters)
# process the source file, put output to temp file
temp_file = temp_file(extension)
send(audio_tool_method, source, source_info, temp_file, modify_parameters[:start_offset], modify_parameters[:end_offs... | [
"def slice( dest, source, beg_line, end_line )\n file dest => source do\n sh \"sed -n '#{beg_line},#{end_line}p' < #{source} > #{dest}\"\n end\n end",
"def source=(newsource)\n %x[pacmd move-source-output #{self.output_id} #{newsource.source_id}]\n return nil\n end",
"def update_targe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Path to previous page, or to index action, or to Index controller | def path_to_back
back_path = request.referer
return back_path if back_path && back_path != request.url
return path_to :index if self.class.actions.include?(:index)
'/'
end | [
"def previous_esdl_action\n session[:return_to] or root_path\n end",
"def back_path\n if (defined? @controller.page_back_button_path).nil?\n :back\n else\n @controller.page_back_button_path\n end\n end",
"def prev_page_url\n if @page <= 2\n request.path\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
test klass primary key is integer type. (rails default) | def integer?
primary_key_attribute = klass.attribute_types.select { |name, _| name == User.primary_key }
if primary_key_attribute.key?(klass.primary_key.to_s)
primary_key_attribute[klass.primary_key].type == :integer
else
true
end
end | [
"def primary_key_type\n 'integer PRIMARY KEY'\n end",
"def primary_key_type\n \"integer PRIMARY KEY\"\n end",
"def activerecord_class_has_no_real_primary_key?\n (! active_record_class.primary_key) ||\n (active_record_class.primary_key == [ ]) ||\n ( ([ [ 'id' ], [ :id ] ].include?(Arr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set default status as pending | def default_status
self.status = "Pending"
end | [
"def set_status\n self.status = \"pending\"\n end",
"def mark_as_pending!\n self.update_attribute(:status, PENDING)\n end",
"def pending!\n self.update_attribute(:status, PENDING)\n end",
"def set_default_status!\n self.status = nil\n set_default_status\n end",
"def set_state_pending\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Function to receive message from the subscribed topics. It runs as a forever / infinite loop if it is called with a block. If not, it waits until a message is received and is returned to a the caller If the method is called with a block, it is necessary to create a thread in order to doesn't block the program | def receive_messages_from_subscribed_topics
if block_given?
#@client.get do |topic, message|
get do |topic, message|
yield(topic, message)
end
else
#topic, message = @client.get
topic, message = get
return topic, message
end
end | [
"def receive\n raise \"No subscriptions to receive messages from.\" if (@subscriptions.nil? || @subscriptions.empty?)\n start = @current_subscription\n while true\n # puts \"calling receive...\"\n @current_subscription = ((@current_subscription < @subscriptions.lengt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /file_packages GET /file_packages.json | def index
@file_packages = FilePackage.all
end | [
"def get_packages(file)\n file ||= SRC_FILE\n # noinspection RubyMismatchedArgumentType\n text = File.read(file); # debug(\"text == #{text.inspect}\")\n json = JSON.parse(text); # debug(\"json == #{json.inspect}\")\n pkgs = json&.dig('dependencies')&.keys; debug(\"pkgs == #{pkg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /file_packages POST /file_packages.json | def create
@file_package = FilePackage.new(file_package_params)
respond_to do |format|
if @file_package.save
@file_to_update_file_package = FileToUpdateFilePackage.new(file_package_id: @file_package.id)
@file_to_update_file_package.save
format.html { redirect_to @file_package, noti... | [
"def package_request(file_number, name, document_reference)\n {\n body: {\n fileNumber: file_number,\n name: name,\n documentReferences: [{\n id: document_reference[:id],\n copies: document_reference[:copies]\n }]\n },\n headers: HE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /file_packages/1 PATCH/PUT /file_packages/1.json | def update
respond_to do |format|
if @file_package.update(file_package_params)
format.html { redirect_to @file_package, notice: 'File package was successfully updated.' }
format.json { render :show, status: :ok, location: @file_package }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @file_to_update_file_package.update(file_to_update_file_package_params)\n format.html { redirect_to @file_to_update_file_package, notice: 'File to update file package was successfully updated.' }\n format.json { render :show, status: :ok, location: @fi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /file_packages/1 DELETE /file_packages/1.json | def destroy
@file_package.destroy
respond_to do |format|
format.html { redirect_to file_packages_url, notice: 'File package was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @file_to_update_file_package.destroy\n respond_to do |format|\n format.html { redirect_to file_to_update_file_packages_url, notice: 'File to update file package was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @package_file.destro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generates the boolean 'foo?' methods | def build_boolean( sym, val )
#puts "build: #{sym} - value: #{val}"
class_eval(<<-EOS, __FILE__, __LINE__)
def self.#{sym}?
return #{sym} == true
end
def #{sym}?
self.class.#{sym}?
end
EOS
end | [
"def be_truthy; end",
"def build_boolean_instance_methods(attribute, options=[])\n options.each do |const|\n class_eval <<-RUBY\n def #{const.to_s.demodulize.tableize.singularize}?\n self.#{attribute.downcase} == #{attribute}::#{const.to_s.demodulize}\n end\n RUBY\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
for backwards compatibility Use this in the console to get a list of font families | def family_list
UIFont.familyNames.sort
end | [
"def font_families\n font_families = [\"Lucida Grande\", \"Arial\", \"Helvetica\", \"Times New Roman\", \"Courier\", \"Georgia\", \"Trebuchet MS\", \"Verdana\"]\n end",
"def family\n @family ||= family_options.map do |font_name, font_options|\n name = parse_font_name(font_name)\n\n op... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /option_types POST /option_types.json | def create
@option_type = OptionType.new(option_type_params)
respond_to do |format|
if @option_type.save
format.html { redirect_to [:admin, @option_type], notice: 'Option type was successfully created.' }
format.json { render action: 'show', status: :created, location: @option_type }
... | [
"def create\n @option_type = OptionType.new(params[:option_type])\n\n respond_to do |format|\n if @option_type.save\n format.html { redirect_to admin_option_types_url, notice: 'Option type was successfully created.' }\n format.json { render json: @option_type, status: :created, location: @o... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /option_types/1 PATCH/PUT /option_types/1.json | def update
respond_to do |format|
if @option_type.update(option_type_params)
format.html { redirect_to [:admin, @option_type], notice: 'Option type was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { rende... | [
"def update\n @option_type = OptionType.find(params[:id])\n\n respond_to do |format|\n if @option_type.update_attributes(params[:option_type])\n format.html { redirect_to admin_option_types_url, notice: 'Option type was successfully updated.' }\n format.json { head :no_content }\n else... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /option_types/1 DELETE /option_types/1.json | def destroy
@option_type.destroy
respond_to do |format|
format.html { redirect_to admin_option_types_url }
format.json { head :no_content }
end
end | [
"def destroy\n @option_type = OptionType.find(params[:id])\n @option_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_option_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @option_type = OptionType.find(params[:id])\n @option_type.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
It should be possible to change the properties of a file and see stat return a different result | def test_stat_modifications
@client.write(@file, '')
[0745, 0600, 0443].each do |mode|
@client.chmod(@file, mode)
assert_equal mode, @client.stat(@file, refresh: true).mode
end
end | [
"def stat() File.stat(path) end",
"def stat\n @stat ||= File.stat(path)\n end",
"def stat\n return @stat unless @stat == :needs_stat\n\n method = :stat\n\n # Files are the only types that support links\n if (self.class.name == :file and self[:links] != :follow) or self.class.name == :tidy\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /venues/1 DELETE /venues/1.json | def destroy
@venue = Venue.find(params[:id])
@venue.destroy
respond_to do |format|
format.html { redirect_to venues_url }
format.json { head :ok }
end
end | [
"def destroy\n @tailgate_venue = TailgateVenue.find(params[:id])\n @tailgate_venue.destroy\n\n respond_to do |format|\n format.html { redirect_to tailgate_venues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @venue = Venue.find(params[:id])\n @venue.destroy\n\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /representant_locataires GET /representant_locataires.json | def index
@representant_locataires = RepresentantLocataire.all
end | [
"def index\n @locatarios = Locatario.all\n end",
"def index\n @lesion_locations = LesionLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesion_locations }\n end\n end",
"def locations\n customer = Customer.find_by(id: params[:id], c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /representant_locataires POST /representant_locataires.json | def create
@representant_locataire = RepresentantLocataire.new(representant_locataire_params)
respond_to do |format|
if @representant_locataire.save
format.html { redirect_to @representant_locataire, notice: 'Representant locataire was successfully created.' }
format.json { render :show, ... | [
"def create\n @locataire = Locataire.new(locataire_params)\n\n respond_to do |format|\n if @locataire.save\n format.html { redirect_to @locataire, notice: 'Locataire was successfully created.' }\n format.json { render :show, status: :created, location: @locataire }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /representant_locataires/1 PATCH/PUT /representant_locataires/1.json | def update
respond_to do |format|
if @representant_locataire.update(representant_locataire_params)
format.html { redirect_to @representant_locataire, notice: 'Representant locataire was successfully updated.' }
format.json { render :show, status: :ok, location: @representant_locataire }
... | [
"def update\n respond_to do |format|\n if @locataire.update(locataire_params)\n format.html { redirect_to @locataire, notice: 'Locataire was successfully updated.' }\n format.json { render :show, status: :ok, location: @locataire }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /representant_locataires/1 DELETE /representant_locataires/1.json | def destroy
@representant_locataire.destroy
respond_to do |format|
format.html { redirect_to representant_locataires_url, notice: 'Representant locataire was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @locacion = Locacion.find(params[:id])\n @locacion.destroy\n\n respond_to do |format|\n format.html { redirect_to locacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @locataire.destroy\n respond_to do |format|\n format.html { redirect_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Takes in student test scores | def test_scores(score)
puts "Student scored an #{score}"
end | [
"def scores(student)\n ExamScore.score(student.id, id) unless student.nil?\n end",
"def get_score_for(test)\n print test[:question] + \"\\n> \"\n is_answer_correct?( STDIN.gets, test ) ? SCORE_CORRECT : SCORE_INCORRECT\n end",
"def score(student_id)\n @scores[student_id]\n end",
"def scores... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
TODO : Rename to 'supplier_specs' | def actual_specs
as = supplier_orders.map(&:actual_specs)
as = as.uniq.compact
as
end | [
"def info_for_supplier(supplier, supplier_part_number, manufacturer_part_number=nil, quantity=nil)\n send(\"info_for_#{supplier.downcase}\", supplier_part_number, manufacturer_part_number, quantity)\nend",
"def supplemental_specs()\n supp_specs = []\n supp_specs << { :category => :remote, :c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tries to get `default_value` from localization_key checks other localizations | def fallback_to_default(localization_key, localization)
localization_key.localizations.where.not(default_value: nil). \
where.not(id: localization.id).first&.default_value
end | [
"def use_and_copy_default_locale_translations_if_they_exist(locale, key)\n default_locale_entry = lookup(::Locale.default_locale, key)\n return unless default_locale_entry\n\n if default_locale_entry.is_a?(Array)\n default_locale_entry.each_with_index do |entry, index|\n loc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /source_pages GET /source_pages.json | def index
@source_pages = SourcePage.all
end | [
"def get_pages(options = nil)\n @client.raw('get', '/content/pages', options)\n end",
"def pages\n get(\"v1/event/#{@id}/pages\")\n end",
"def show\n @page_source = PageSource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /source_pages POST /source_pages.json | def create
@source_page = SourcePage.new(source_page_params)
respond_to do |format|
if @source_page.save
format.html { redirect_to @source_page, notice: 'Source page was successfully created.' }
format.json { render :show, status: :created, location: @source_page }
else
form... | [
"def create\n @page_source = PageSource.new(params[:page_source])\n\n respond_to do |format|\n if @page_source.save\n format.html { redirect_to(@page_source, :notice => 'Page source was successfully created.') }\n format.xml { render :xml => @page_source, :status => :created, :location => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /source_pages/1 PATCH/PUT /source_pages/1.json | def update
respond_to do |format|
if @source_page.update(source_page_params)
format.html { redirect_to @source_page, notice: 'Source page was successfully updated.' }
format.json { render :show, status: :ok, location: @source_page }
else
format.html { render :edit }
forma... | [
"def update\n @page_source = PageSource.find(params[:id])\n\n respond_to do |format|\n if @page_source.update_attributes(params[:page_source])\n format.html { redirect_to(@page_source, :notice => 'Page source was successfully updated.') }\n format.xml { head :ok }\n else\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /source_pages/1 DELETE /source_pages/1.json | def destroy
@source_page.destroy
respond_to do |format|
format.html { redirect_to source_pages_url, notice: 'Source page was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @page_source = PageSource.find(params[:id])\n @page_source.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_sources_url) }\n format.xml { head :ok }\n end\n end",
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def des... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /admin/furniture/sets GET /admin/furniture/sets.json | def index
@admin_furniture_sets = Admin::Furniture::Set.all.paginate(page: params[:page])
respond_to do |format|
format.html
format.json { render json: @admin_furniture_sets.map { |i| { value: i.id, text: "#{i.name} #{i.config.to_s}" } }, status: :ok }
end
end | [
"def setlist\n setlist_json = []\n total_sets = Show.find(params[\"id\"]).total_sets\n Show.find(params[\"id\"]).setlists.each do |setlist|\n song = Song.find(setlist.song_id)\n setlist_json << {\"set_id\" => setlist.set_id, \"song_order\" => setlist.song_order, \"song_name\" => song.song_name, \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/furniture/sets POST /admin/furniture/sets.json | def create
@admin_furniture_set = Admin::Furniture::Set.new(admin_furniture_set_params)
respond_to do |format|
if @admin_furniture_set.save
format.html { redirect_to admin_furniture_sets_path, notice: mk_notice(@admin_furniture_set, :name, 'ست مبل', :create) }
format.json { render json: @... | [
"def create\n @gig_set = GigSet.new(gig_set_params)\n @gig_set.number = (@gig_set.gig.gig_sets.map(&:number).compact.max || 0) + 1\n\n respond_to do |format|\n if @gig_set.save\n format.html { redirect_to edit_gig_path(@gig_set.gig) }\n format.json { redirect_to edit_gig_path(@gig_set.gi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/furniture/sets/1 PATCH/PUT /admin/furniture/sets/1.json | def update
respond_to do |format|
if @admin_furniture_set.update(admin_furniture_set_params)
format.html { redirect_to admin_furniture_sets_path, notice: mk_notice(@admin_furniture_set, :name, 'ست مبل', :update) }
format.json { render json: @admin_furniture_set, status: :ok, location: admin_fu... | [
"def update\n respond_to do |format|\n if @defset.update(defset_params)\n format.html { redirect_to @defset, notice: 'Defset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @defset.er... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/furniture/sets/1 DELETE /admin/furniture/sets/1.json | def destroy
@admin_furniture_set.destroy
respond_to do |format|
format.html { redirect_to admin_furniture_sets_path, notice: mk_notice(@admin_furniture_set, :name, 'ست مبل', :destroy) }
format.json { head :no_content }
end
end | [
"def destroy\n @defset.destroy\n respond_to do |format|\n format.html { redirect_to defsets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fabricsofaset.destroy\n respond_to do |format|\n format.html { redirect_to fabricsofasets_url, notice: 'Fabricsofaset wa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The create_empty_field method creates a twodimensional array. One comprising the rows of the field matrix, and the other the columns. | def create_empty_field
@field_matrix = Array.new(length) { Array.new(width, ' . ') }
end | [
"def build_minefield\n @field = []\n @row_count.times do\n row = []\n @column_count.times do\n row << Cell.new\n end\n @field << row\n end\n end",
"def empty_2d_arr rows, cols\n Array.new(rows) {empty_1d_arr cols}\nend",
"def create_grid\n grid = Array.new(6, Array.new... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The create_snake method creates a twodimensional array. The inner array consists of the horizontal and vertical location of each snake part. | def create_snake
vertical_position = location[0]
horizontal_position = location[1]
@snake_matrix = Array.new(size) { |part_index| [vertical_position, horizontal_position + part_index] }
end | [
"def create_snake\n\n @snake = Snake.new\n\n @init_len = 3\n\n fill_snake\n\n @speed = 150 # speed of snake in millisecond increments\n\n @next_direct = \"left\"\n\n @level = 1\n\n @bg_color_i = 1\n\n @bg_color = COLOR_ARR[0]\n\n @snake_color_i = 1\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The head of the snake is always the first array of the snake matrix. | def locate_head
snake_matrix.first
end | [
"def head\n @snake.first\n end",
"def create_snake\n vertical_position = location[0]\n horizontal_position = location[1]\n @snake_matrix = Array.new(size) { |part_index| [vertical_position, horizontal_position + part_index] }\n end",
"def initialize_snake\n new_snake_coords = [\n rand(0..@... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The body consists of all the arrays in the snake matrix except the first one. | def locate_body
snake_matrix[1..-1]
end | [
"def initialize\n @bodies = []\n end",
"def add_snakes area\n\t\t@snakes.each do |snake|\n\t\t\tme = (snake.id == @me)\n\t\t\tsnake.body.each do |b|\n\t\t\t\tarea[b.x][b.y] = me ? Settings.get(\"grid\",\"me_body\") : Settings.get(\"grid\",\"enemy_body\") \n\t\t\tend\n\t\t\tarea[snake.head.x][snake.head.y] = m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Inputs a new horizontal location for the head of the snake in order to simulate horizontal movement. | def update_head_horizontal_location(column)
locate_head[1] = column
end | [
"def place_snake_head(position, move_over_tunnel)\n snake_part = SnakePart.new(@head)\n @world[@head] = snake_part\n @head = position\n @world[position] = SnakeHead.new(position)\n\t\t\t@world[position].set_over_tunnel(move_over_tunnel)\n @body.unshift @head\n end",
"def test_moving_ho... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The print_filled_field method first creates an empty field and then adds a snake matrix and an apple to that empty field matrix and prints the result. | def print_filled_field
field.create_empty_field
# Add an apple to the field.
field.field_matrix[apple.vertical_location][apple.horizontal_location] = ' o '
# Add a snake to the field.
snake.snake_matrix.each do |part|
field.field_matrix[part.first][part.last] = ' x '
end
print_field... | [
"def generate_field(empty_char = @last_empty_char)\n if plottable\n new_field = []\n @field.each do |rows|\n rows.each do |items|\n if items.length == 0\n items.insert(0, \"#{empty_char} \")\n elsif empty_char != @last_empty_char && items == [\"#{last_e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The animate_game method prints the filled field first, then it allows the user to change the snake's direction, then moves the snake one frame, and finally checks for conditions that change the circumstances of the game. All of this is done repeatedly until the game ends. | def animate_game
begin
Curses.stdscr.keypad = true
Curses.noecho
Curses.curs_set(0)
Curses.timeout = 0
loop do
print_filled_field
# Add a sleep method with a value of 0.1 to prevent the snake from
# moving too fast. Adjust the value of sleep to speed up or slow... | [
"def gameplay\n\t\tplayer_names\n\t\tloop do\n\t\t\t@move_count += 1 \n\t\t\tdisplay_board\n\t\t\tmake_your_move\n\t\t\tcheck_winning_combos\n\t\t\tswitch_player\n\t\tend\n\tend",
"def player_move\n player_position = gets.chomp\n player_position = player_position.split(' ')\n if player_positi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create query using field parser. Equivalent to Lucene's field:"value" query. Inspired from ActiveFedora::SolrQueryBuilder.field_query. | def field_query(field, value)
"_query_:\"{!field f=#{field}}#{value}\""
end | [
"def perform_field_query query, response, scope\n if Array === query\n case query.first\n when :method # a method call\n query.shift\n return eval(query.join('.'))\n when :literal # a literal value\n return query.last\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create query using join parser, similar to sql join. | def join_query(from, to, field, value)
"_query_:\"{!join from=#{from} to=#{to}}#{field}:\\\"#{value}\\\"\""
end | [
"def _init_sql\n # Create the SQL code of the join\n @sql = %(\n #{self.class::JOIN_TYPE} JOIN #{@target_table.name} #{@target_table.table_alias}\n ON #{@target_table.table_alias}.#{@target_table.key} = #{@origin_table.table_alias}.#{@origin_table.key}\n ).delete(\"\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
original `create_format_method` overrides `format` method with metaprogramming | def create_format_method
end | [
"def create_format_method\n case @style\n when :json; Parseable.create_json_format_method(self)\n when :yaml; Parseable.create_yaml_format_method(self)\n else raise ArgumentError, \"unknown format style '#@style'\" end\n end",
"def format(*formatters); end",
"def format(fmt, *rest) end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an instance of this Awesome class that holds a Ruby value. Like a String, number, or true | def new_with_value(value)
AwesomeObject.new(self, value)
end | [
"def new_value(value)\n AwesomeObject.new(self, value)\n end",
"def initialize(awesome_class, ruby_value=self)\n @awesome_class = awesome_class\n @ruby_value = ruby_value\n end",
"def new_with_value(value, type = nil)\n BikeObject.new(self, value, type || @type)\n end",
"def ruby_value\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /minisounds POST /minisounds.json | def create
@minisound = Minisound.new(minisound_params)
respond_to do |format|
if @minisound.save
format.html { redirect_to @minisound, notice: 'Minisound was successfully created.' }
format.json { render :show, status: :created, location: @minisound }
else
format.html { ren... | [
"def create\n post_params = {\n name: params[:name].downcase,\n units: params[:units] || 0\n }\n render json: Ingredient.create!(post_params), status: :created\n end",
"def update\n respond_to do |format|\n if @minisound.update(minisound_params)\n format.html { redirect_to @mini... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /minisounds/1 PATCH/PUT /minisounds/1.json | def update
respond_to do |format|
if @minisound.update(minisound_params)
format.html { redirect_to @minisound, notice: 'Minisound was successfully updated.' }
format.json { render :show, status: :ok, location: @minisound }
else
format.html { render :edit }
format.json { r... | [
"def update\n respond_to do |format|\n if @minimeal.update(minimeal_params)\n format.html { redirect_to minimeals_url, notice: 'Minimeal was successfully updated.' }\n format.json { render :show, status: :ok, location: @minimeal }\n else\n format.html { render :edit }\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /minisounds/1 DELETE /minisounds/1.json | def destroy
@minisound.destroy
respond_to do |format|
format.html { redirect_to minisounds_url, notice: 'Minisound was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @smallmobunit = Smallmobunit.find(params[:id])\n @smallmobunit.destroy\n\n respond_to do |format|\n format.html { redirect_to smallmobunits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @compound = Compound.find(params[:id])\n @compound.destroy\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /laporan_guru_agama_katolik GET /laporan_guru_agama_katolik.json | def index
@laporan_guru_agama_katolik = LaporanGuruAgamaKatolik.order("created_at DESC").page(params[:daftar_laporan_guru_agama_katolik_page]).per(6)
end | [
"def index\n @laporan_penyuluh_agama_katolik = LaporanPenyuluhAgamaKatolik.order(\"created_at DESC\").page(params[:daftar_laporan_penyuluh_agama_katolik_page]).per(6)\n end",
"def index\n @laporan_penyuluh_agama_katolik = LaporanPenyuluhAgamaKatolik.all\n end",
"def index\n @lokasi_atms = LokasiAtm.a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /laporan_guru_agama_katolik POST /laporan_guru_agama_katolik.json | def create
@laporan_guru_agama_katolik = LaporanGuruAgamaKatolik.new(laporan_guru_agama_katolik_params)
@laporan_guru_agama_katolik.pengguna_id = current_pengguna.id
respond_to do |format|
if @laporan_guru_agama_katolik.save
format.html { redirect_to @laporan_guru_agama_katolik, notice: 'Lapo... | [
"def create\n @laporan_penyuluh_agama_katolik = LaporanPenyuluhAgamaKatolik.new(laporan_penyuluh_agama_katolik_params)\n @laporan_penyuluh_agama_katolik.pengguna_id = current_pengguna.id\n\n respond_to do |format|\n if @laporan_penyuluh_agama_katolik.save\n format.html { redirect_to @laporan_pe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /laporan_guru_agama_katolik/1 PATCH/PUT /laporan_guru_agama_katolik/1.json | def update
respond_to do |format|
if @laporan_guru_agama_katolik.update(laporan_guru_agama_katolik_params)
format.html { redirect_to @laporan_guru_agama_katolik, notice: 'Laporan guru agama katolik was successfully updated.' }
format.json { render :show, status: :ok, location: @laporan_guru_ag... | [
"def update\n respond_to do |format|\n if @laporan_penyuluh_agama_katolik.update(laporan_penyuluh_agama_katolik_params)\n format.html { redirect_to @laporan_penyuluh_agama_katolik, notice: 'Laporan penyuluh agama katolik was successfully updated.' }\n format.json { render :show, status: :ok, l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /laporan_guru_agama_katolik/1 DELETE /laporan_guru_agama_katolik/1.json | def destroy
@laporan_guru_agama_katolik.destroy
respond_to do |format|
format.html { redirect_to laporan_guru_agama_katolik_index_url, notice: 'Laporan guru agama katolik was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @laporan_penyuluh_agama_katolik.destroy\n respond_to do |format|\n format.html { redirect_to laporan_penyuluh_agama_katolik_index_url, notice: 'Laporan penyuluh agama katolik was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lapor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add given hash or block and return new config object | def add(config_or_block)
self.class.new @config_list + Array.wrap(config_or_block)
end | [
"def add_block name, hash\n\t\t\t@blocks ||= {}\n\t\t\t@blocks[name] = hash\n\t\tend",
"def add_block\n\t\tyield if block_given?\n\n block = self.last_block.create_next( *self.current_transactions )\n\n self.current_transactions.clear\n self.chain.push( block )\n\n\t\tself.log.debug \"Added b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a new configuration object bound to the given instance. This instance will be instance_eval'ed with any procs in the config. | def bind(instance)
self.class.new @config_list.dup, instance
end | [
"def run_config(config)\n instance_eval(&config) if config.is_a?(Proc)\n instance_eval(config) unless config.is_a?(Proc)\n end",
"def configure(&block)\r\n instance_exec(&block)\r\n end",
"def config\n @config ||= lambda_config? ? @config_value.call(parent.config) : @config_value.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the compiled config. This will be a hash built by combining added hashes and blocks. | def config
@config ||= compile
end | [
"def computed_config; end",
"def config_body_for(config)\n res = <<-CONTENT.gsub(/^ +/, '')\n # This file is managed by Chef.\n # Any changes to it will be overwritten.\n CONTENT\n res << Hash[config.sort].map { |k, v| config_for(k, v) }.compact\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Order.tax_zone.tax_rates is used here to check if the order is taxable by Tax Cloud. It's not possible check against the order's tax adjustments because an adjustment is not created for 0% rates. However, US orders must be submitted to Tax Cloud even when the rate is 0%. Note that we explicitly use ship_address instead... | def is_taxed_using_tax_cloud?
::Spree::TaxRate.for_address(ship_address).any? { |rate| rate.calculator_type == 'Spree::Calculator::TaxCloudCalculator' }
end | [
"def apply_tax\n rate = case addresses.detect {|a| a.address_type == 'shipping' }.region\n when 'KY' then 0.06\n when 'IL' then 0.0625\n when 'CA' then 0.0725\n else 0\n end\n\n # Shipping N/A if this is an order quote (in which case the shipping address is blank).\n self.shipping_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hands/1 GET /hands/1.json | def show
@hand = Hand.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @hand }
end
end | [
"def show\n @hand_back = HandBack.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hand_back }\n end\n end",
"def show\n @hand_state = HandState.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Is this a valid app? | def valid?
App.valid?(path)
end | [
"def valid_app?(app)\n !!(app =~ APP_REGEX)\n end",
"def app_type_valid?\n app_type_id.in? accessible_app_type_ids\n end",
"def run_app?; true; end",
"def has_app?\n !!@app_dir\n end",
"def valid_apps\n apps.select { |app| app.valid? }\n end",
"def app?\n app_host = Ra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the arches for the binary. | def arches
@arches ||= lipo.info
end | [
"def get_barriers\n res = []\n pos = 0\n board.chars.each do |ch|\n res << pos_to_coords(pos) if BARRIERS.include? ch\n pos += 1\n end\n\n res\n end",
"def macs\n result = []\n str_macs = cmd_exec(\"for fn in /sys/class/net/*; do echo $fn; done\")\n parts = str_macs.split(\"\\n\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if the app has been built for the simulator | def simulator?
arches.include?("i386") || arches.include?("x86_64")
end | [
"def simulator?\n not physical_device?\n end",
"def simulator?\n !physical_device?\n end",
"def is_simulator? uuid\n # Check if UUID is from a device or a simulator\n # Getting all the simulator's UUID\n uuids = `xcrun simctl list`\n return true if uuids.include? uuid\n return false\nend",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
True if the app has been built for physical devices | def physical_device?
arches.any? do |arch|
arch[/arm/, 0]
end
end | [
"def has_physical_device\n return @has_physical_device\n end",
"def simulator?\n not physical_device?\n end",
"def simulator?\n !physical_device?\n end",
"def has_physical_device\n return @has_physical_device\n end",
"def ph... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the CFBundleVersion of the app as Version instance. Apple docs: CFBundleVersion specifies the build version number of the bundle, which identifies an iteration (released or unreleased) of the bundle. The build version number should be a string comprised of three nonnegative, periodseparated integers with the fi... | def build_version
string = plist_buddy.plist_read("CFBundleVersion", info_plist_path)
begin
version = RunLoop::Version.new(string)
rescue
if string && string != ""
RunLoop.log_debug("CFBundleVersion: '#{string}' is not a well formed version string")
else
Run... | [
"def getversion\n if not @vars[\"CFBundleShortVersionString\"].nil?\n version = procversion(@vars[\"CFBundleShortVersionString\"])\n return version\n elsif not @vars[\"CFBundleVersion\"].nil?\n version = procversion(@vars[\"CFBundleVersion\"])\n return version\n else\n raise QuickP... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a modified copy with the optimize_model_load setting changed. | def with_optimize_model_load(v)
clone(:optimize_model_load=>v)
end | [
"def reload\n @dirty = []\n @cache = Preference.find_all_by_model_type_and_model_id(@model.class.name, @model.id).index_by(&:key)\n end",
"def load_to_cache\n save_to_cache(load)\n end",
"def reload_with_clear_original_attributes #:nodoc:\n clear_original_attributes\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
module CoversWithCache add Covercache supporting to model | def covers_with_cache
caller_source = caller.first[/[^:]+/]
class_eval do
@covercache_caller_source = caller_source
include Covercache::ModelConcern
extend Covercache::DefiningHelper
end
end | [
"def cache_fetcher; end",
"def get_cover_photo_and_set_cache\r\n cp = self.cover_photo\r\n set_cover_photo_cache(cp)\r\n cp\r\n end",
"def add_cache_control; end",
"def shared_cache?; end",
"def cache_driver\n model.cache_driver\n end",
"def cache\n if defined?(@cache)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates elevators, and floors. Places elevators on floors | def initialize(number_of_elevators, number_of_floors, elevator_capacity,elevator_resting_floor)
puts "Setting up #{number_of_elevators} elevators of capacity #{elevator_capacity}"
@elevators = Array.new(number_of_elevators).map{
|elevator| Elevator.new(self, elevator_capacity)
}
puts "Setting up #{number_of_... | [
"def create_elevators\n\t\ti = @num_elevators\n\t\twhile i > 0 do\n\t\t\t@elevators.push(Elevators.new(5, 1))\n\t\t\ti = i - 1\n\t\tend\n\tend",
"def create_floors \n\t\ti = @max_floor\n\t\twhile i > 0 do\n\t\t\t@floors.push(Floors.new(i, @elevators, @people))\n\t\t\ti -= 1\n\t\tend\n\tend",
"def add_elevators(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Height of a floor | def floor_height(floor)
floors.index(floor)
end | [
"def get_height\n return get_keyword_value(\"FLOOR-HEIGHT\").to_f\n end",
"def get_height\n height = get_keyword_value(\"FLOOR-HEIGHT\")\n height = height.to_f\n return height\n end",
"def ceiling_height\n self.dig_for_string(\"ceilingHeight\")\n end",
"def height\n boun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Lets a person enter on the first floor | def enter(person)
floors.first.enter(person)
end | [
"def startGame()\n floor = @floor_arr.shift\n floor.buildFloor(@floor_arr)\n floor.start(@player)\n end",
"def add_person(person)\n\t\tcurrent_floor = @floor_hash[person.current_floor]\n\t\tif current_floor.space>0\n\t\t\tcurrent_floor.add_person(person)\n\t\tend\n\tend",
"def generate_new_floo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the next floor in some direction. Null if none | def get_next_floor(floor, direction)
index = floor.number
if direction.eql? :UP
return floors[index+1]
end
if index-1 < 0
return nil
end
floors[index-1]
end | [
"def next_floor_in_current_direction\n current = elevator_state[:floor]\n if direction == 1\n # We can use bsearch because requests array is sorted.\n requests.bsearch { |x| x > current }\n elsif direction == -1\n # bsearch can search only for minimum position, so we search\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets all the elevators at a specific floor | def elevators_at_floor(floor)
elevators.select{|elevator| elevator.floor.eql? floor}
end | [
"def floor_rooms\n\t\t@rooms[floor_no]\n\tend",
"def floor_request(floor)\n elevator = elevators.find { |e| e.current_floor == floor } # this is wrong\n elevator.floor_request(floor) if elevator\n end",
"def floors\n # start with a range of all the floors\n # collect a hash of the apartments on... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /grid_fs_files GET /grid_fs_files.json | def index
@grid_fs_files = GridFsFile.all
end | [
"def grid_request(id)\n begin\n unless file = ::Mongoid::GridFS.get(id)\n return [404, {'Content-Type' => 'text/plain'}, ['File not found.']]\n end\n headers = {\n 'ETag' => file.md5,\n 'Last-Modified' => file.uploadDate.httpdate,\n 'Cache-Control' => @c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /grid_fs_files POST /grid_fs_files.json | def create
@grid_fs_file = GridFsFile.new(grid_fs_file_params)
respond_to do |format|
if @grid_fs_file.save
format.html { redirect_to @grid_fs_file, notice: 'Grid fs file was successfully created.' }
format.json { render :show, status: :created, location: @grid_fs_file }
else
... | [
"def gridfs_upload\n n = 50\n client.database.drop\n fs = client.database.fs\n\n files = [*0...n].collect do |i|\n name = \"#{GRIDFS_MULTI_BASE}#{i}.txt\"\n {\n file: File.open(name, 'r'),\n name: File.basename(name)\n }\n end\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /grid_fs_files/1 PATCH/PUT /grid_fs_files/1.json | def update
respond_to do |format|
if @grid_fs_file.update(grid_fs_file_params)
format.html { redirect_to @grid_fs_file, notice: 'Grid fs file was successfully updated.' }
format.json { render :show, status: :ok, location: @grid_fs_file }
else
format.html { render :edit }
... | [
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /grid_fs_files/1 DELETE /grid_fs_files/1.json | def destroy
@grid_fs_file.destroy
respond_to do |format|
format.html { redirect_to grid_fs_files_url, notice: 'Grid fs file was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n Rails.logger.debug {\"destroying gridfs file #{@id}\"}\n if persisted?\n Photo.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end\n end",
"def delete_file(f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /colegios GET /colegios.json | def index
@colegios = Colegio.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @colegios }
end
end | [
"def show\n @colegio = Colegio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colegio }\n end\n end",
"def index\n @colegios = Colegio.all\n end",
"def index\n @convos = Convo.all\n render json: @convos\n end",
"def index... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /colegios/1 GET /colegios/1.json | def show
@colegio = Colegio.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @colegio }
end
end | [
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @convos = Convo.all\n render json: @convos\n end",
"def index\n @colegios = Colegio.all\n end",
"def show\n @cofi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /colegios/new GET /colegios/new.json | def new
@colegio = Colegio.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @colegio }
end
end | [
"def new\n @loco = Loco.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loco }\n end\n end",
"def new\n @cota = Cota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cota }\n end\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /colegios POST /colegios.json | def create
@colegio = Colegio.new(params[:colegio])
respond_to do |format|
if @colegio.save
format.html { redirect_to @colegio, notice: 'El colegio fue creado satisfactoriamente.' }
format.json { render json: @colegio, status: :created, location: @colegio }
else
format.html ... | [
"def create\n @colegio = Colegio.new(colegio_params)\n\n respond_to do |format|\n if @colegio.save\n format.html { redirect_to @colegio, notice: 'Colegio was successfully created.' }\n format.json { render :show, status: :created, location: @colegio }\n else\n format.html { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /colegios/1 PUT /colegios/1.json | def update
@colegio = Colegio.find(params[:id])
respond_to do |format|
if @colegio.update_attributes(params[:colegio])
format.html { redirect_to @colegio, notice: 'El Colegio fue actualizado satisfactoriamente.' }
format.json { head :no_content }
else
format.html { render ac... | [
"def update\n respond_to do |format|\n if @colegio.update(colegio_params)\n format.html { redirect_to @colegio, notice: 'Colegio was successfully updated.' }\n format.json { render :show, status: :ok, location: @colegio }\n else\n format.html { render :edit }\n format.json {... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /colegios/1 DELETE /colegios/1.json | def destroy
@colegio = Colegio.find(params[:id])
@colegio.destroy
respond_to do |format|
format.html { redirect_to colegios_url }
format.json { head :no_content }
end
end | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @condominios = Condominio.find(params[:id])\n @condominios.destroy\n\n respond_to do |format|\n format.html { redirect_to condominia_url }\n format.json { head :ok }\n end\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /occasions POST /occasions.json | def create
@occasion = Occasion.new(occasion_params)
@occasion.administrators << current_user
respond_to do |format|
if @occasion.save
format.html { redirect_to @occasion, notice: 'Occasion was successfully created.' }
format.json { render :show, status: :created, location: @occasion }... | [
"def create\n @occasion = Occasion.new(params[:occasion])\n\n respond_to do |format|\n if @occasion.save\n format.html { redirect_to @occasion, notice: 'Occasion was successfully created.' }\n format.json { render json: @occasion, status: :created, location: @occasion }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /occasions/1 DELETE /occasions/1.json | def destroy
@occasion.destroy
respond_to do |format|
format.html { redirect_to occasions_url, notice: 'Occasion was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @occasion = Occasion.find(params[:id])\n @occasion.destroy\n\n respond_to do |format|\n format.html { redirect_to occasions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @occaision.destroy\n respond_to do |format|\n format.html { redirect_to... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
getredisproto method mostly taken from redis documentation, with no license noted there. | def getredisproto(*args)
proto = []
proto.push("*"+args.length.to_s+"\r\n")
args.each{|arg|
proto.push("$"+arg.to_s.bytesize.to_s+"\r\n")
proto.push(arg.to_s+"\r\n")
}
proto
end | [
"def gen_redis_proto(*cmd)\n proto = \"\"\n proto << \"*\"+cmd.length.to_s+\"\\r\\n\"\n cmd.each{|arg|\n proto << \"$\"+arg.to_s.bytesize.to_s+\"\\r\\n\"\n proto << arg.to_s+\"\\r\\n\"\n }\n proto\nend",
"def read_proto(pkt)\n\t\tproto = PacketPf.parse(pkt)\n\t\tif PacketPf.packet_pre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
clean up dangling content blobs that are older than BLOB_GRACE_PERIOD and not associated with an asset | def clean_content_blobs
ContentBlob.where(asset: nil).where('created_at < ?', BLOB_GRACE_PERIOD.ago).select do |blob|
Rails.logger.info("Cleaning up content blob #{blob.id}")
blob.reload
blob.destroy if blob.asset.nil?
end
end | [
"def perform\n orphan_query = 'SELECT id FROM active_storage_blobs asb EXCEPT SELECT DISTINCT blob_id ' \\\n 'FROM active_storage_attachments asa INNER JOIN active_storage_blobs asb ON asb.id=asa.blob_id'\n orphan_blobs = ActiveStorage::Blob.find_by_sql(orphan_query)\n orphan_blobs.each(&... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
removes any users accounts that have not fully registered by creating an associated profile, and that were created longer ago than the USER_GRACE_PERIOD | def remove_unregistered_users
User.where(person: nil).where('created_at < ?', USER_GRACE_PERIOD.ago).destroy_all
end | [
"def lost_users(days_ago = 10)\n lost = []\n new_users = User.where(created_at: (starting_on - days_ago.day)..ending_on, account_id: Account.current.id)\n new_users.each do |user|\n next unless user.user_site_profiles.where(account_id: Account.current.id)\n\n lost << user if user.user_profile.reg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
trims old sessions, using the db:sessions:trim task | def trim_session
Rails.application.load_tasks
Rake::Task['db:sessions:trim'].invoke
end | [
"def cleanup\n\t\tcurrent_time = current_date_time\n\n\t\tputs current_time\n\n\t\t# delete all sessions that are older than 30 minutes\n\t\tActiveRecord::Base.connection.execute(\"DELETE FROM sessions WHERE updated_at < '#{current_time}'\")\n\tend",
"def cleanup\r\n# puts ''\r\n# puts @sessionInactivit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
resends an activation email, for unactivated users that haven't received an email since RESEND_ACTIVATION_EMAIL_DELAY and a total maximum of MAX_ACTIVATION_EMAILS (which will include the first one) | def resend_activation_emails
User.where.not(person: nil).where.not(activation_code: nil).each do |user|
if user.person
logs = user.person.activation_email_logs
if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)
Mailer.ac... | [
"def resend_activation_emails\n User.where.not(person: nil).where.not(activation_code: nil).each do |user|\n if user.person\n logs = user.person.activation_email_logs\n if logs.count < MAX_ACTIVATION_EMAILS && (logs.empty? || logs.last.created_at < RESEND_ACTIVATION_EMAIL_DELAY.ago)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /service_type_masters GET /service_type_masters.json | def index
@service_type_masters = ServiceTypeMaster.all
end | [
"def index\n @masterservices = Masterservice.all\n end",
"def index\n @service_master = ServiceMaster.new\n @service_masters = ServiceMaster.all\n end",
"def index\n @puppetmasters = Puppetmaster.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"
]
]
}
} |
POST /service_type_masters POST /service_type_masters.json | def create
@service_type_master = ServiceTypeMaster.new(service_type_master_params)
respond_to do |format|
if @service_type_master.save
format.html { redirect_to @service_type_master, notice: 'Service type master was successfully created.' }
format.json { render action: 'show', status: :c... | [
"def create\n @masterservice = Masterservice.new(masterservice_params)\n\n respond_to do |format|\n if @masterservice.save\n format.html { redirect_to @masterservice, notice: 'Masterservice was successfully created.' }\n format.json { render :show, status: :created, location: @masterservice... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /service_type_masters/1 PATCH/PUT /service_type_masters/1.json | def update
respond_to do |format|
if @service_type_master.update(service_type_master_params)
format.html { redirect_to @service_type_master, notice: 'Service type master was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
... | [
"def update\n respond_to do |format|\n if @service_type.update(service_type_params)\n format.json { head :no_content }\n else\n format.json { render json: @service_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @service_master.update(service_m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /service_type_masters/1 DELETE /service_type_masters/1.json | def destroy
@service_type_master.destroy
respond_to do |format|
format.html { redirect_to service_type_masters_url }
format.json { head :no_content }
end
end | [
"def destroy\n @service_master.destroy\n respond_to do |format|\n format.html { redirect_to service_masters_url, notice: 'Service master was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @masterservice.destroy\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /adversaires GET /adversaires.json | def index
@adversaires = Adversaire.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @adversaires }
end
end | [
"def show\n @adversaire = Adversaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @adversaire }\n end\n end",
"def index\n @descuento_clientes = DescuentoCliente.all\n\n respond_to do |format|\n format.html # index.html.e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /adversaires/1 GET /adversaires/1.json | def show
@adversaire = Adversaire.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @adversaire }
end
end | [
"def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end",
"def show\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /adversaires POST /adversaires.json | def create
@adversaire = Adversaire.new(params[:adversaire])
@equipe = Equipe.find(params[:equipe_id])
respond_to do |format|
if @adversaire.save
format.html { redirect_to @equipe, :notice => 'Adversaire was successfully created.' }
format.json { render :json => @adversaire, :status =... | [
"def index\n @adversaires = Adversaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @adversaires }\n end\n end",
"def create\n @serv_adicionale = ServAdicionale.new(params[:serv_adicionale])\n\n respond_to do |format|\n if @serv_adici... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /adversaires/1 PUT /adversaires/1.json | def update
@adversaire = Adversaire.find(params[:id])
@equipe = Equipe.find(params[:equipe_id])
respond_to do |format|
if @adversaire.update_attributes(params[:adversaire])
format.html { redirect_to @equipe, :notice => 'Adversaire was successfully updated.' }
format.json { head :no_con... | [
"def update\n request = RestClient.put File.join(API_SERVER,\"rest-api/departments\"), { \n 'id' => params['id'], \n 'name' => params['department']['name'], \n 'description' => params['department']['description'] }.to_json, :content_type => :json, :accept => :json\n\n redirect_to :action ... | {
"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.